]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a class GridOut that serves to simply output a triangulation without recourse...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Jun 1999 12:11:48 +0000 (12:11 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Jun 1999 12:11:48 +0000 (12:11 +0000)
Also remove the epsgrid output from the DataOut class that served the same purpose.

git-svn-id: https://svn.dealii.org/trunk@1443 0785d39b-7218-0410-832d-ea1e28bc413d

12 files changed:
deal.II/deal.II/Attic/examples/dof/dof_test.cc
deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc
deal.II/deal.II/Attic/examples/grid/grid_test.cc
deal.II/deal.II/include/grid/grid_io.h [new file with mode: 0644]
deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/include/numerics/data_io.h
deal.II/deal.II/source/grid/grid_io.cc [new file with mode: 0644]
deal.II/deal.II/source/grid/tria.cc
deal.II/deal.II/source/numerics/data_io.cc
tests/big-tests/dof/dof_test.cc
tests/big-tests/error-estimation/error-estimation.cc
tests/big-tests/grid/grid_test.cc

index e72b1a1b86a820426acc6d33d09effb16135e422..01ca12fe47d40a7d03e26d124e36e1ebe0a37dc4 100644 (file)
@@ -3,6 +3,7 @@
 
 
 
+#include <basic/grid_io.h>
 #include <grid/dof.h>
 #include <grid/tria.h>
 #include <fe/fe_lib.lagrange.h>
@@ -345,7 +346,7 @@ void TestCases<dim>::run (ParameterHandler &prm) {
   
   cout << "    Writing grid..." << endl;
   ofstream out((file_prefix + prm.get("Grid file")).c_str());
-  tria->print_gnuplot (out);
+  GridOut::write_gnuplot (tria, out);
 
 
 
index 4ae6049783c1ef47dd5f7e040d5653d12fb2aa3d..f4c91e08bc10978ca296971a38983c04638c97e4 100644 (file)
@@ -12,6 +12,7 @@
 #include <grid/grid_generator.h>
 #include <base/function.h>
 #include <basic/data_io.h>
+#include <basic/grid_io.h>
 #include <base/parameter_handler.h>
 #include <fe/fe_lib.lagrange.h>
 #include <base/quadrature_lib.h>
@@ -629,7 +630,7 @@ void PoissonProblem<dim>::run (ParameterHandler &prm) {
   filename += "finest_mesh.gnuplot";
   cout << "    Writing finest grid to <" << filename << ">... " << endl;
   ofstream finest_mesh (filename.c_str());
-  tria->print_gnuplot (finest_mesh);
+  GridOut::write_gnuplot (tria, finest_mesh);
   finest_mesh.close();
 
   print_history (prm, refine_mode);
index 9d4e2457d21555c7a2a74d97374599e9cad1a14a..b4115cce0691f1e12e743f765a7962f7b1ba0a08 100644 (file)
@@ -7,6 +7,7 @@
 #include <grid/tria_iterator.h>
 #include <grid/tria.h>
 #include <grid/grid_generator.h>
+#include <basic/grid_io.h>
 #include <fstream>
 #include <string>
 #include <cmath>
@@ -220,9 +221,13 @@ void test (const int test_case) {
        Ball<dim>       ball;
        CurvedLine<dim> curved_line;
        if (test_case==2)
-         tria.set_boundary (&ball);
-       else
-         tria.set_boundary (&curved_line);
+         {
+           tria.set_boundary (0, ball);
+           tria.set_boundary (1, ball);
+         } else {
+           tria.set_boundary (0, curved_line);
+           tria.set_boundary (1, curved_line);
+         };
        
                                         // refine once
        tria.begin_active()->set_refine_flag();
@@ -245,6 +250,8 @@ void test (const int test_case) {
          };
 
        tria.set_boundary (0);
+       tria.set_boundary (1);
+       
        break;
       }
 
@@ -287,7 +294,7 @@ void test (const int test_case) {
   filename += ('0'+test_case);
   
   ofstream out(filename.c_str());
-  tria.print_gnuplot (out);
+  GridOut::write_gnuplot (tria, out);
     
   cout << "     Total number of cells        = " << tria.n_cells() << endl
        << "     Total number of active cells = " << tria.n_active_cells() << endl;
diff --git a/deal.II/deal.II/include/grid/grid_io.h b/deal.II/deal.II/include/grid/grid_io.h
new file mode 100644 (file)
index 0000000..eaa73fb
--- /dev/null
@@ -0,0 +1,149 @@
+/*----------------------------   grid_io.h     ---------------------------*/
+/*      $Id$                 */
+#ifndef __grid_io_H
+#define __grid_io_H
+/*----------------------------   grid_io.h     ---------------------------*/
+
+#include <basic/forward-declarations.h>
+#include <base/exceptions.h>
+#include <string>
+
+
+
+/**
+ * This class provides a means to output a triangulation to a file in different
+ * formats. Presently provided are functions to write it in GNUPLOT and
+ * encapsulated postscript format. There are also function to dispatch to
+ * the different output functions based on a parameter given, e.g., through
+ * a parameter file, thus making user programs invariant of the number and
+ * names of the file formats implemented in this class.
+ *
+ *
+ * \subsection{GNUPLOT format}
+ * In GNUPLOT format, each cell is written as a sequence of lines. There is not
+ * much more to be said here since the actual representation as well as the
+ * viewing angle (for 3d plots) is done by GNUPLOT itself.
+ *
+ * One additional feature, however, is worth being mentioned: after each point
+ * denoting one of the end points of a line, the level of the respective cell
+ * is written. Therefore, if you let GNUPLOT draw a 2d grid as a 3d plot, you
+ * will see more refined cells being raised against cells with less refinement.
+ * Also, if you draw a cut through a 3d grid, you can extrude the refinement
+ * level in the direction orthogonal to the cut plane.
+ *
+ *
+ * \subsection{Encapsulated postscript format}
+ * In this format, each line of the triangulation is written separately. We
+ * scale the picture such that x-values range between zero and 300 and the y-range
+ * is scaled with the same factor. The bounding box is close to the triangulation
+ * on all four sides, without an extra frame. The line width is chosen to be 0.5,
+ * which is a thin line relative to the extension of the picture of 300.
+ * 
+ *
+ * @author Wolfgang Bangerth, 1999; postscript format based on an implementation by Stefan Nauber, 1999
+ */
+class GridOut 
+{
+  public:
+                                    /**
+                                     * Declaration of a name for each of the
+                                     * different output formats.
+                                     */
+    enum OutputFormat { gnuplot, eps };
+
+                                    /**
+                                     * Write the triangulation in the
+                                     * gnuplot format. See the general
+                                     * documentation for a description
+                                     * of what happens here.
+                                     */
+    template <int dim>
+    static void write_gnuplot (const Triangulation<dim> &tria,
+                              ostream                  &out);
+
+                                    /**
+                                     * Write the triangulation in the
+                                     * encapsulated postscript format. See the
+                                     * general documentation for a description
+                                     * of what happens here.
+                                     */
+    template <int dim>
+    static void write_eps (const Triangulation<dim> &tria,
+                          ostream                  &out);
+
+                                    /**
+                                     * Write data and grid to #out# according
+                                     * to the given data format. This function
+                                     * simply calls the appropriate
+                                     * #write_*# function.
+                                     */
+    template <int dim>
+    static void write (const Triangulation<dim> &tria,
+                      ostream                  &out,
+                      const OutputFormat        output_format);
+    
+                                    /**
+                                     * Provide a function which tells us which
+                                     * suffix with a given output format
+                                     * usually has. At present the following
+                                     * formats are defined:
+                                     * \begin{itemize}
+                                     * \item #gnuplot#: #.gnuplot#
+                                     * \item #eps#: #.eps#.
+                                     * \end{itemize}
+                                     *
+                                     * Since this function does not need data
+                                     * from this object, it is static and can
+                                     * thus be called without creating an
+                                     * object of this class.
+                                     */
+    static string default_suffix (const OutputFormat output_format);
+
+                                    /**
+                                     * Return the #OutputFormat# value
+                                     * corresponding to the given string. If
+                                     * the string does not match any known
+                                     * format, an exception is thrown.
+                                     *
+                                     * Since this function does not need data
+                                     * from this object, it is static and can
+                                     * thus be called without creating an
+                                     * object of this class. Its main purpose
+                                     * is to allow a program to use any
+                                     * implemented output format without the
+                                     * need to extend the program's parser
+                                     * each time a new format is implemented.
+                                     *
+                                     * To get a list of presently available
+                                     * format names, e.g. to give it to the
+                                     * #ParameterHandler# class, use the
+                                     * function #get_output_format_names ()#.
+                                     */
+    static OutputFormat parse_output_format (const string &format_name);
+
+                                    /**
+                                     * Return a list of implemented output
+                                     * formats. The different names are
+                                     * separated by vertical bar signs (#`|'#)
+                                     * as used by the #ParameterHandler#
+                                     * classes.
+                                     */
+    static string get_output_format_names ();
+
+
+                                    /**
+                                     * Exception
+                                     */
+    DeclException0 (ExcInvalidState);
+                                    /**
+                                     * Exception
+                                     */
+    DeclException0 (ExcIO);
+};
+
+
+
+/*----------------------------   grid_io.h     ---------------------------*/
+/* end of #ifndef __grid_io_H */
+#endif
+/*----------------------------   grid_io.h     ---------------------------*/
index 3eff79189f6f2302f9b4a9bb638814c2d72a751f..443edb590350a194871acc57d7592dc659b48aca 100644 (file)
@@ -456,7 +456,7 @@ class TriaDimensionInfo<3> {
  *      };
  *                                       // output the grid
  *    ofstream out("grid.1");
- *    tria.print_gnuplot (out);
+ *    GridOut::write_gnuplot (tria, out);
  *  };  
  *  \end{verbatim}
  *
@@ -2536,31 +2536,6 @@ class Triangulation
                                     /*@}*/
 
                                     /*---------------------------------------*/
-
-                                    /**
-                                     *  @name Input/Output functions
-                                     */
-                                    /*@{*/
-                                    /**
-                                     *  Print the triangulation in GNUPLOT
-                                     *  format to #out#.
-                                     */
-    void print_gnuplot (ostream &) const;
-
-                                    /**
-                                     *  Print level #level# in GNUPLOT
-                                     *  format to #out#.
-                                     */
-    void print_gnuplot (ostream &, const unsigned int level) const;
-
-                                    /**
-                                     *  Print cell #cell# in GNUPLOT format
-                                     *  to #out#.
-                                     */
-    void print_gnuplot (ostream &, const active_cell_iterator &cell) const;
-                                    /*@}
-                                     */
-
     
                                     /**
                                      * @name Information about the triangulation
@@ -2587,8 +2562,7 @@ class Triangulation
     unsigned int n_lines (const unsigned int level) const;
     
                                     /**
-                                     *  Return total number of active lines,
-                                     *  active or not.
+                                     * Return total number of active lines.
                                      *
                                      * Regarding the computational effort of
                                      * this function, the same applies as
@@ -2598,7 +2572,7 @@ class Triangulation
     
                                     /**
                                      *  Return total number of active lines,
-                                     *  active or not on level #level#.
+                                     *  on level #level#.
                                      *
                                      * Regarding the computational effort of
                                      * this function, the same applies as
index 2fcea190abafafd02994ef3276e55590611f30c6..5c4abe6acad0b36b120cb6fe01da93fce7fbc804 100644 (file)
@@ -299,11 +299,9 @@ class DataIn {
  *
  * \subsection{Encapsulated Postscript format}
  *
- * There are two functions for generating encapsulated Postscript
- * (EPS) without the need for another graphics tool.
- * #write_epsgrid# writes just the 2d grid - This is obsolete and
- * should be removed. The functionality is provided through #write_eps#
- * and #EpsOutputData# now. 
+ * There is a function for generating encapsulated Postscript
+ * (EPS) without the need for another graphics tool. This functionality
+ * is provided through #write_eps# and #EpsOutputData#. 
  * #write_eps# can use one data vector for height information and one
  * cell vector for shading information. Control is done through an
  * object of class #EpsOutputData# as follows or by default.
@@ -384,7 +382,7 @@ class DataOut {
                                      * Provide a data type specifying the
                                      * presently supported output formats.
                                      */
-    enum OutputFormat { ucd, gnuplot, gnuplot_draft, povray_mesh, eps, epsgrid, gmv };
+    enum OutputFormat { ucd, gnuplot, gnuplot_draft, povray_mesh, eps, gmv };
     
                                     /**
                                      * Constructor
@@ -486,12 +484,6 @@ class DataOut {
     void write_eps (ostream &out,
                    const EpsOutputData &eod = EpsOutputData()) const;
 
-                                  /**
-                                   * Write grid in Encapsulated
-                                   * postscript format.
-                                   */
-    void write_epsgrid (ostream &out) const;
-
                                   /**
                                    * Write data and grid in GMV format.
                                    */
@@ -505,7 +497,8 @@ class DataOut {
                                      *
                                      * In case of gnuplot output, the
                                      * standard accuracy of 1 is
-                                     * chosen.  */
+                                     * chosen.
+                                     */
     void write (ostream &out, const OutputFormat output_format) const;
     
                                     /**
@@ -518,7 +511,7 @@ class DataOut {
                                      * \item #gnuplot# and #gnuplot_draft#:
                                      *    #.gnuplot#
                                      * \item #povray_mesh#: #.pov#
-                                     * \item #eps# and #epsgrid#: #.eps#
+                                     * \item #eps#: #.eps#
                                      * \item #gmv#: #.gmv#.
                                      * \end{itemize}
                                      *
@@ -549,7 +542,7 @@ class DataOut {
                                      * #ParameterHandler# class, use the
                                      * function #get_output_format_names ()#.
                                      */
-    static OutputFormat parse_output_format (const string format_name);
+    static OutputFormat parse_output_format (const string &format_name);
 
                                     /**
                                      * Return a list of implemented output
diff --git a/deal.II/deal.II/source/grid/grid_io.cc b/deal.II/deal.II/source/grid/grid_io.cc
new file mode 100644 (file)
index 0000000..a398d12
--- /dev/null
@@ -0,0 +1,269 @@
+/* $Id$ */
+
+
+#include <base/point.h>
+#include <basic/grid_io.h>
+#include <grid/tria.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+
+#include <iomanip>
+#include <algorithm>
+#include <list>
+#include <ctime>
+#include <cmath>
+
+
+
+template <int dim>
+void GridOut::write_gnuplot (const Triangulation<dim> &tria,
+                            ostream                  &out) 
+{
+  AssertThrow (out, ExcIO());
+
+  typename Triangulation<dim>::active_cell_iterator        cell=tria.begin_active();
+  const typename Triangulation<dim>::active_cell_iterator  endc=tria.end();
+  for (; cell!=endc; ++cell)
+    {
+      out << "# cell " << cell << endl;
+      
+      switch (dim)
+       {
+         case 1:
+               out << cell->vertex(0) << ' ' << cell->level() << endl
+                   << cell->vertex(1) << ' ' << cell->level() << endl
+                   << endl;
+               break;
+
+         case 2:
+               out << cell->vertex(0) << ' ' << cell->level() << endl
+                   << cell->vertex(1) << ' ' << cell->level() << endl
+                   << cell->vertex(2) << ' ' << cell->level() << endl
+                   << cell->vertex(3) << ' ' << cell->level() << endl
+                   << cell->vertex(0) << ' ' << cell->level() << endl
+                   << endl  // double new line for gnuplot 3d plots
+                   << endl;
+               break;
+
+         case 3:
+                                                // front face
+               out << cell->vertex(0) << ' ' << cell->level() << endl
+                   << cell->vertex(1) << ' ' << cell->level() << endl
+                   << cell->vertex(2) << ' ' << cell->level() << endl
+                   << cell->vertex(3) << ' ' << cell->level() << endl
+                   << cell->vertex(0) << ' ' << cell->level() << endl
+                   << endl;
+                                                // back face
+               out << cell->vertex(4) << ' ' << cell->level() << endl
+                   << cell->vertex(5) << ' ' << cell->level() << endl
+                   << cell->vertex(6) << ' ' << cell->level() << endl
+                   << cell->vertex(7) << ' ' << cell->level() << endl
+                   << cell->vertex(4) << ' ' << cell->level() << endl
+                   << endl;
+
+                                                // now for the four connecting lines
+               out << cell->vertex(0) << ' ' << cell->level() << endl
+                   << cell->vertex(4) << ' ' << cell->level() << endl
+                   << endl;
+               out << cell->vertex(1) << ' ' << cell->level() << endl
+                   << cell->vertex(5) << ' ' << cell->level() << endl
+                   << endl;
+               out << cell->vertex(2) << ' ' << cell->level() << endl
+                   << cell->vertex(6) << ' ' << cell->level() << endl
+                   << endl;
+               out << cell->vertex(3) << ' ' << cell->level() << endl
+                   << cell->vertex(7) << ' ' << cell->level() << endl
+                   << endl;
+               break;
+       };
+    };
+  
+  AssertThrow (out, ExcIO());
+};
+
+
+
+template <int dim>
+void GridOut::write_eps (const Triangulation<dim> &tria,
+                        ostream                  &out) 
+{
+  Assert (false, ExcNotImplemented());
+};
+
+
+
+#if deal_II_dimension == 2
+
+template <>
+void GridOut::write_eps (const Triangulation<2> &tria,
+                        ostream                &out) 
+{
+  typedef list<pair<Point<2>,Point<2> > > LineList;
+  
+  
+  AssertThrow (out, ExcIO());
+
+                                  // make up a list of lines by which
+                                  // we will construct the triangulation
+  LineList line_list;
+  Triangulation<2>::active_line_iterator line   =tria.begin_active_line ();
+  Triangulation<2>::active_line_iterator endline=tria.end_line ();
+
+  for (; line!=endline; ++line)
+    line_list.push_back (make_pair(line->vertex(0),
+                                  line->vertex(1)));
+
+                                  // find out minimum and maximum x and
+                                  // y coordinates to compute offsets
+                                  // and scaling factors
+  double x_min = tria.begin_active_line()->vertex(0)(0);
+  double x_max = x_min;
+  double y_min = tria.begin_active_line()->vertex(0)(1);
+  double y_max = y_min;
+
+  for (LineList::const_iterator line=line_list.begin();
+       line!=line_list.end(); ++line)
+    {
+      x_min = min (x_min, line->first(0));
+      x_min = min (x_min, line->second(0));
+
+      x_max = max (x_max, line->first(0));
+      x_max = max (x_max, line->second(0));
+
+      y_min = min (y_min, line->first(1));
+      y_min = min (y_min, line->second(1));
+
+      y_max = max (y_max, line->first(1));
+      y_max = max (y_max, line->second(1));
+    };
+
+                                  // scale in x-direction such that
+                                  // in the output 0 <= x <= 300.
+                                  // don't scale in y-direction to
+                                  // preserve the shape of the
+                                  // triangulation
+  const double scale = 300. / (x_max - x_min);
+  
+  
+                                  // now write preamble
+  if (true) 
+    {
+                                      // block this to have local
+                                      // variables destroyed after
+                                      // use
+      time_t  time1= time (0);
+      tm     *time = localtime(&time1); 
+      out << "%!PS-Adobe-2.0 EPSF-1.2" << endl
+         << "%%Title: deal.II Output" << endl
+         << "%%Creator: the deal.II library" << endl
+         << "%%Creation Date: " 
+         << time->tm_year+1900 << "/"
+         << time->tm_mon+1 << "/"
+         << time->tm_mday << " - "
+         << time->tm_hour << ":"
+         << setw(2) << time->tm_min << ":"
+         << setw(2) << time->tm_sec << endl
+         << "%%BoundingBox: "
+                                        // lower left corner
+         << "0 0 "
+                                        // upper right corner
+         << "300 " << static_cast<unsigned int>( (y_max-y_min) * scale )
+         << endl;
+
+                                      // define some abbreviations to keep
+                                      // the output small:
+                                      // m=move turtle to
+                                      // x=execute line stroke
+      out << "/m {moveto} bind def" << endl
+         << "/x {lineto stroke} bind def" << endl;
+      
+      out << "%%EndProlog" << endl
+         << endl;
+
+                                      // set fine lines
+      out << "0.5 setlinewidth" << endl;
+    };
+
+                                  // now write the lines
+  const Point<2> offset(x_min, y_min);
+  
+  for (LineList::const_iterator line=line_list.begin();
+       line!=line_list.end(); ++line)
+    out << (line->first  - offset) * scale << " m "
+       << (line->second - offset) * scale << " x\n";
+
+  out << "showpage" << endl;
+  
+  AssertThrow (out, ExcIO());
+};
+
+#endif
+
+
+
+
+template <int dim>
+void GridOut::write (const Triangulation<dim> &tria,
+                    ostream                  &out,
+                    OutputFormat              output_format)
+{
+  switch (output_format)
+    {
+      case gnuplot:
+           write_gnuplot (tria, out);
+           return;
+
+      case eps:
+           write_eps (tria, out);
+           return;
+    };
+
+  Assert (false, ExcInternalError());
+};
+
+
+
+string GridOut::default_suffix (const OutputFormat output_format) 
+{
+  switch (output_format) 
+    {
+      case gnuplot: 
+           return ".gnuplot";
+           
+      case eps: 
+           return ".eps";
+           
+      default: 
+           Assert (false, ExcNotImplemented()); 
+           return "";
+    };
+};
+  
+
+
+
+GridOut::OutputFormat
+GridOut::parse_output_format (const string &format_name) {
+  if (format_name == "gnuplot")
+    return gnuplot;
+
+  if (format_name == "eps")
+    return eps;
+  
+  AssertThrow (false, ExcInvalidState ());
+                                  // return something weird
+  return OutputFormat(-1);
+};
+
+
+
+string GridOut::get_output_format_names () {
+  return "gnuplot|eps";
+};
+
+
+
+// explicit instantiations
+template void GridOut::write_gnuplot (const Triangulation<deal_II_dimension> &, ostream &);
+//template void GridOut::write_eps (const Triangulation<deal_II_dimension> &, ostream &);
+template void GridOut::write (const Triangulation<deal_II_dimension> &, ostream &, OutputFormat);
index 5f26140bf3311e780a2ccf3dec294a0296d3b52e..eb26357849c8e84facfdda88d9da274fade71136 100644 (file)
@@ -3428,115 +3428,6 @@ unsigned int Triangulation<dim>::max_adjacent_cells () const {
 
 
 
-template <int dim>
-void Triangulation<dim>::print_gnuplot (ostream &out) const {
-  for (unsigned int i=0; i<levels.size(); ++i)
-    print_gnuplot (out, i);
-};
-
-
-
-template <int dim>
-void Triangulation<dim>::print_gnuplot (ostream &out, const unsigned int level) const {
-  active_cell_iterator cell = begin_active (level),
-                      endc = (level == levels.size()-1 ?
-                              active_cell_iterator(end()) :
-                              begin_active (level+1));
-
-  AssertThrow (out, ExcIO());
-  
-  out << "#Active cells on level " << level
-      << ": " << n_active_cells (level) << endl;
-  for (; cell != endc; ++cell)
-    print_gnuplot (out, cell);
-
-  AssertThrow (out, ExcIO());
-};
-
-
-
-#if deal_II_dimension == 1
-
-template <>
-void Triangulation<1>::print_gnuplot (ostream &out,
-                                     const active_cell_iterator & cell) const {
-  AssertThrow (out, ExcIO());
-  
-  out << cell->vertex(0) << ' ' << cell->level() << endl
-      << cell->vertex(1) << ' ' << cell->level() << endl
-      << endl;
-
-  AssertThrow (out, ExcIO());
-};
-
-#endif
-
-
-#if deal_II_dimension == 2
-
-template <>
-void Triangulation<2>::print_gnuplot (ostream &out,
-                                     const active_cell_iterator & cell) const {
-  AssertThrow (out, ExcIO());
-  
-  out << cell->vertex(0) << ' ' << cell->level() << endl
-      << cell->vertex(1) << ' ' << cell->level() << endl
-      << cell->vertex(2) << ' ' << cell->level() << endl
-      << cell->vertex(3) << ' ' << cell->level() << endl
-      << cell->vertex(0) << ' ' << cell->level() << endl
-      << endl  // double new line for gnuplot 3d plots
-      << endl;
-
-  AssertThrow (out, ExcIO());
-};
-
-#endif
-
-
-#if deal_II_dimension == 3
-
-template <>
-void Triangulation<3>::print_gnuplot (ostream &out,
-                                     const active_cell_iterator & cell) const {
-  AssertThrow (out, ExcIO());
-
-                                  // front face
-  out << cell->vertex(0) << ' ' << cell->level() << endl
-      << cell->vertex(1) << ' ' << cell->level() << endl
-      << cell->vertex(2) << ' ' << cell->level() << endl
-      << cell->vertex(3) << ' ' << cell->level() << endl
-      << cell->vertex(0) << ' ' << cell->level() << endl
-      << endl;
-                                  // back face
-  out << cell->vertex(4) << ' ' << cell->level() << endl
-      << cell->vertex(5) << ' ' << cell->level() << endl
-      << cell->vertex(6) << ' ' << cell->level() << endl
-      << cell->vertex(7) << ' ' << cell->level() << endl
-      << cell->vertex(4) << ' ' << cell->level() << endl
-      << endl;
-
-                                  // now for the four connecting lines
-  out << cell->vertex(0) << ' ' << cell->level() << endl
-      << cell->vertex(4) << ' ' << cell->level() << endl
-      << endl;
-  out << cell->vertex(1) << ' ' << cell->level() << endl
-      << cell->vertex(5) << ' ' << cell->level() << endl
-      << endl;
-  out << cell->vertex(2) << ' ' << cell->level() << endl
-      << cell->vertex(6) << ' ' << cell->level() << endl
-      << endl;
-  out << cell->vertex(3) << ' ' << cell->level() << endl
-      << cell->vertex(7) << ' ' << cell->level() << endl
-      << endl;
-
-  AssertThrow (out, ExcIO());
-};
-
-#endif
-
-
-
-
 template <int dim>
 template <typename number>
 void Triangulation<dim>::refine (const Vector<number> &criteria,
index 87a36858a8106f50294919f1e31291c50f97d0d8..6ada277f827935af2ef52174ade66630e6203b34 100644 (file)
@@ -1035,77 +1035,6 @@ void DataOut<dim>::write_povray_mesh (ostream &) const {
 
 #if deal_II_dimension == 2
 
-template <>
-void DataOut<2>::write_epsgrid (ostream &out) const {
-  Assert (dofs != 0, ExcNoDoFHandlerSelected());
-  
-                                  // write preamble
-  if (true) 
-    {
-                                      // block this to have local
-                                      // variables destroyed after
-                                      // use
-      time_t  time1= time (0);
-      tm     *time = localtime(&time1); 
-      out << "%!PS-Adobe-2.0 EPSF-1.2" << endl
-         << "%%Title: deal.II Output" << endl
-         << "%%Creator: the deal.II library" << endl
-         << "%%Creation Date: " 
-         << time->tm_year+1900 << "/"
-         << time->tm_mon+1 << "/"
-         << time->tm_mday << " - "
-         << time->tm_hour << ":"
-         << setw(2) << time->tm_min << ":"
-         << setw(2) << time->tm_sec << endl
-         << "%%BoundingBox: 0 0 310 310" << endl;
-    };  
-
-                                  // Get scaling factors for Bounding Box 310 x 310
-  
-  DoFHandler<2>::active_cell_iterator cell;
-  DoFHandler<2>::active_cell_iterator endc = dofs->end();
-  double x, y, xmin=0, xmax=0, ymin=0, ymax=0, scale, xofs, yofs;
-  int i;
-
-  for (cell=dofs->begin_active(); cell!=endc; ++cell)
-    {
-      for (i=0; i<4; i++)
-       {
-         x=cell->vertex(i)(0);
-         y=cell->vertex(i)(1);
-         xmin = ( x < xmin ? x : xmin );
-         xmax = ( x > xmax ? x : xmax );
-         ymin = ( y < ymin ? y : ymin );
-         ymax = ( y > ymax ? y : ymax );
-       }
-    }
-  x = xmax - xmin;
-  y = ymax - ymin;
-  scale = 300 / (x > y ? x : y);
-  xofs = -(xmin*scale)+5;
-  yofs = -(ymin*scale)+5;
-
-  for (cell=dofs->begin_active(); cell!=endc; ++cell) 
-    {
-      out << (cell->vertex(0)(0))*scale+xofs << " " 
-         << (cell->vertex(0)(1))*scale+yofs << " moveto "
-         << (cell->vertex(1)(0))*scale+xofs << " " 
-         << (cell->vertex(1)(1))*scale+yofs << " lineto "
-         << (cell->vertex(2)(0))*scale+xofs << " " 
-         << (cell->vertex(2)(1))*scale+yofs << " lineto "
-         << (cell->vertex(3)(0))*scale+xofs << " " 
-         << (cell->vertex(3)(1))*scale+yofs << " lineto "
-         << (cell->vertex(0)(0))*scale+xofs << " " 
-         << (cell->vertex(0)(1))*scale+yofs << " lineto "
-         << " closepath stroke" << endl;
-    };
-  out << "showpage" << endl;     
-
-  AssertThrow (out, ExcIO());
-};
-
-
-
 template <>
 void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
   Assert (dofs != 0, ExcNoDoFHandlerSelected());
@@ -1361,14 +1290,6 @@ void DataOut<2>::write_eps (ostream &out, const EpsOutputData &eod) const {
 
 
 
-template <int dim>
-void DataOut<dim>::write_epsgrid (ostream &/*out*/) const {
-                                  // this is for all other dimensions that
-                                  // are not explicitely specialized
-  Assert (false, ExcNotImplemented());
-};
-
-
 template <int dim>
 void DataOut<dim>::write_eps (ostream &,
                              const EpsOutputData &) const{
@@ -1629,10 +1550,6 @@ void DataOut<dim>::write (ostream &out,
            write_eps(out);
            break;
            
-      case epsgrid:
-           write_epsgrid(out);
-           break;
-
       case gmv:
            write_gmv (out);
            break;
@@ -1660,7 +1577,6 @@ string DataOut<dim>::default_suffix (const OutputFormat output_format)
            return ".pov";
            
       case eps: 
-      case epsgrid: 
            return ".eps";
 
       case gmv:
@@ -1676,7 +1592,7 @@ string DataOut<dim>::default_suffix (const OutputFormat output_format)
 
 template <int dim>
 DataOut<dim>::OutputFormat
-DataOut<dim>::parse_output_format (const string format_name) {
+DataOut<dim>::parse_output_format (const string &format_name) {
   if (format_name == "ucd")
     return ucd;
 
@@ -1692,19 +1608,19 @@ DataOut<dim>::parse_output_format (const string format_name) {
   if (format_name == "eps")
     return eps;
 
-  if (format_name == "epsgrid")
-    return epsgrid;
-
   if (format_name == "gmv")
     return gmv;
   
   AssertThrow (false, ExcInvalidState ());
+
+                                  // return something invalid
+  return OutputFormat(-1);
 };
 
 
 template <int dim>
 string DataOut<dim>::get_output_format_names () {
-  return "ucd|gnuplot|gnuplot draft|povray mesh|eps|epsgrid|gmv";
+  return "ucd|gnuplot|gnuplot draft|povray mesh|eps|gmv";
 };
 
 
index e72b1a1b86a820426acc6d33d09effb16135e422..01ca12fe47d40a7d03e26d124e36e1ebe0a37dc4 100644 (file)
@@ -3,6 +3,7 @@
 
 
 
+#include <basic/grid_io.h>
 #include <grid/dof.h>
 #include <grid/tria.h>
 #include <fe/fe_lib.lagrange.h>
@@ -345,7 +346,7 @@ void TestCases<dim>::run (ParameterHandler &prm) {
   
   cout << "    Writing grid..." << endl;
   ofstream out((file_prefix + prm.get("Grid file")).c_str());
-  tria->print_gnuplot (out);
+  GridOut::write_gnuplot (tria, out);
 
 
 
index 4ae6049783c1ef47dd5f7e040d5653d12fb2aa3d..f4c91e08bc10978ca296971a38983c04638c97e4 100644 (file)
@@ -12,6 +12,7 @@
 #include <grid/grid_generator.h>
 #include <base/function.h>
 #include <basic/data_io.h>
+#include <basic/grid_io.h>
 #include <base/parameter_handler.h>
 #include <fe/fe_lib.lagrange.h>
 #include <base/quadrature_lib.h>
@@ -629,7 +630,7 @@ void PoissonProblem<dim>::run (ParameterHandler &prm) {
   filename += "finest_mesh.gnuplot";
   cout << "    Writing finest grid to <" << filename << ">... " << endl;
   ofstream finest_mesh (filename.c_str());
-  tria->print_gnuplot (finest_mesh);
+  GridOut::write_gnuplot (tria, finest_mesh);
   finest_mesh.close();
 
   print_history (prm, refine_mode);
index 9d4e2457d21555c7a2a74d97374599e9cad1a14a..b4115cce0691f1e12e743f765a7962f7b1ba0a08 100644 (file)
@@ -7,6 +7,7 @@
 #include <grid/tria_iterator.h>
 #include <grid/tria.h>
 #include <grid/grid_generator.h>
+#include <basic/grid_io.h>
 #include <fstream>
 #include <string>
 #include <cmath>
@@ -220,9 +221,13 @@ void test (const int test_case) {
        Ball<dim>       ball;
        CurvedLine<dim> curved_line;
        if (test_case==2)
-         tria.set_boundary (&ball);
-       else
-         tria.set_boundary (&curved_line);
+         {
+           tria.set_boundary (0, ball);
+           tria.set_boundary (1, ball);
+         } else {
+           tria.set_boundary (0, curved_line);
+           tria.set_boundary (1, curved_line);
+         };
        
                                         // refine once
        tria.begin_active()->set_refine_flag();
@@ -245,6 +250,8 @@ void test (const int test_case) {
          };
 
        tria.set_boundary (0);
+       tria.set_boundary (1);
+       
        break;
       }
 
@@ -287,7 +294,7 @@ void test (const int test_case) {
   filename += ('0'+test_case);
   
   ofstream out(filename.c_str());
-  tria.print_gnuplot (out);
+  GridOut::write_gnuplot (tria, out);
     
   cout << "     Total number of cells        = " << tria.n_cells() << endl
        << "     Total number of active cells = " << tria.n_active_cells() << endl;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.