]> https://gitweb.dealii.org/ - dealii.git/commitdiff
parameter parsing for GridOut
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 6 Mar 2006 13:18:09 +0000 (13:18 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 6 Mar 2006 13:18:09 +0000 (13:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@12540 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_out.h
deal.II/deal.II/source/grid/grid_out.all_dimensions.cc
deal.II/deal.II/source/grid/grid_out.cc
deal.II/doc/news/changes.html

index c2d70afdf61107beef50717c2f91b3a01c91701c..24753608f10dbb1472a510e171d9eb8a8f6929b8 100644 (file)
@@ -1018,18 +1018,29 @@ class GridOut
     void write_xfig (const Triangulation<dim> &tria,
                    std::ostream             &out,
                    const Mapping<dim>       *mapping=0);
+    
                                     /**
-                                     * Write data and grid to @p out according
-                                     * to the given data format. This function
-                                     * simply calls the appropriate
-                                     * <tt>write_*</tt> function.
+                                     * Write grid to @p out according
+                                     * to the given data format. This
+                                     * function simply calls the
+                                     * appropriate <tt>write_*</tt>
+                                     * function.
                                      */
     template <int dim>
     void write (const Triangulation<dim> &tria,
                std::ostream             &out,
                const OutputFormat        output_format,
                const Mapping<dim>       *mapping=0);
-
+    
+                                    /**
+                                     * Write mesh in default format
+                                     * set by ParameterHandler.
+                                     */
+    template <int dim>
+    void write (const Triangulation<dim> &tria,
+               std::ostream             &out,
+               const Mapping<dim>       *mapping=0);
+    
                                     /**
                                      * Set flags for DX output
                                      */
@@ -1093,6 +1104,13 @@ class GridOut
                                      */
     static std::string default_suffix (const OutputFormat output_format);
 
+                                    /**
+                                     * Default suffix for the default
+                                     * output format selected throuw
+                                     * ParameterHandler.
+                                     */
+    std::string default_suffix () const;
+    
                                     /**
                                      * Return the @p OutputFormat value
                                      * corresponding to the given string. If
@@ -1149,6 +1167,12 @@ class GridOut
     DeclException0 (ExcInvalidState);
 
   private:
+                                    /**
+                                     * The default output format, set
+                                     * by a ParameterHandler.
+                                     */
+    OutputFormat default_format;
+    
                                     /**
                                      * Flags for OpenDX output.
                                      */
index 9859f1a10ecac020c705b75ca4856ec3aa17ff3b..334aebecf89b52dc29b8217ab9322663152176dc 100644 (file)
@@ -31,11 +31,19 @@ namespace GridOutFlags
 
   void DX::declare_parameters (ParameterHandler& param)
   {
-    param.declare_entry("Write cells", "true", Patterns::Bool());
-    param.declare_entry("Write faces", "false", Patterns::Bool());
-    param.declare_entry("Write diameter", "false", Patterns::Bool());
-    param.declare_entry("Write measure", "false", Patterns::Bool());
-    param.declare_entry("Write all faces", "true", Patterns::Bool());
+    param.declare_entry("Write cells", "true", Patterns::Bool(),
+                       "Write the mesh connectivity as DX grid cells");
+    param.declare_entry("Write faces", "false", Patterns::Bool(),
+                       "Write faces of cells. These may be boundary faces\n"
+                       "or all faces between mesh cells, according to\n"
+                       "\"Write all faces\"");
+    param.declare_entry("Write diameter", "false", Patterns::Bool(),
+                       "If cells are written, additionally write their"
+                       " diameter\nas data for visualization");
+    param.declare_entry("Write measure", "false", Patterns::Bool(),
+                       "Write the volume of each cell as data");
+    param.declare_entry("Write all faces", "true", Patterns::Bool(),
+                       "Write all faces, not only boundary");
   }
   
   void DX::parse_parameters (ParameterHandler& param)
@@ -126,12 +134,21 @@ namespace GridOutFlags
   void EpsFlagsBase::declare_parameters (ParameterHandler& param)
   {
     param.declare_entry("Size by", "width",
-                           Patterns::Selection("width|height"));
-    param.declare_entry("Size", "300", Patterns::Integer());
-    param.declare_entry("Line width", "0.5", Patterns::Double());
-    param.declare_entry("Color by flag", "false", Patterns::Bool());
-    param.declare_entry("Boundary points", "2", Patterns::Integer());
-    param.declare_entry("Color by level", "false", Patterns::Bool());
+                           Patterns::Selection("width|height"),
+                       "Depending on this parameter, either the"
+                       "width or height\n"
+                       "of the eps is scaled to \"Size\"");
+    param.declare_entry("Size", "300", Patterns::Integer(),
+                       "Size of the output in points");
+    param.declare_entry("Line width", "0.5", Patterns::Double(),
+                       "Width of the lines drawn in points");
+    param.declare_entry("Color by flag", "false", Patterns::Bool(),
+                       "Draw lines with user flag set in different color");
+    param.declare_entry("Boundary points", "2", Patterns::Integer(),
+                       "Number of points on boundary edges.\n"
+                       "Increase this beyond 2 to see curved boundaries.");
+    param.declare_entry("Color by level", "false", Patterns::Bool(),
+                       "Draw different colors according to grid level.");
   }
 
 
@@ -196,9 +213,14 @@ namespace GridOutFlags
   
   void Eps<2>::declare_parameters (ParameterHandler& param)
   {
-    param.declare_entry("Cell number", "false", Patterns::Bool());
-    param.declare_entry("Level number", "false", Patterns::Bool());
-    param.declare_entry("Vertex number", "false", Patterns::Bool());
+    param.declare_entry("Cell number", "false", Patterns::Bool(),
+                       "(2D only) Write cell numbers"
+                       " into the centers of cells");
+    param.declare_entry("Level number", "false", Patterns::Bool(),
+                       "(2D only) if \"Cell number\" is true, write"
+                       "numbers in the form level.number");
+    param.declare_entry("Vertex number", "false", Patterns::Bool(),
+                       "Write numbers for each vertex");
   }
 
 
@@ -230,15 +252,18 @@ namespace GridOutFlags
   
   void Eps<3>::declare_parameters (ParameterHandler& param)
   {
-    param.declare_entry("Azimut angle", "60", Patterns::Double());
-    param.declare_entry("Turn angle", "30", Patterns::Double());    
+    param.declare_entry("Azimuth", "30", Patterns::Double(),
+                       "Azimuth of the viw point, that is, the angle\n"
+                       "in the plane from the x-axis.");
+    param.declare_entry("Elevation", "30", Patterns::Double(),
+                       "Elevation of the view point above the xy-plane.");    
   }
 
 
   void Eps<3>::parse_parameters (ParameterHandler& param)
   {
     EpsFlagsBase::parse_parameters(param);
-    azimut_angle = param.get_double("Azimut angle");
+    azimut_angle = 90- param.get_double("Elevation");
     turn_angle = param.get_double("Turn angle");
   }
 
@@ -374,6 +399,14 @@ GridOut::default_suffix (const OutputFormat output_format)
 
 
 
+std::string
+GridOut::default_suffix () const
+{
+  return default_suffix(default_format);
+}
+
+
+
 GridOut::OutputFormat
 GridOut::parse_output_format (const std::string &format_name)
 {
@@ -446,6 +479,41 @@ GridOut::declare_parameters(ParameterHandler& param)
 }
 
 
+
+void
+GridOut::parse_parameters(ParameterHandler& param)
+{
+  default_format = parse_output_format(param.get("Format"));
+  
+  param.enter_subsection("DX");
+  dx_flags.parse_parameters(param);
+  param.leave_subsection();
+  
+  param.enter_subsection("Msh");
+  msh_flags.parse_parameters(param);
+  param.leave_subsection();
+  
+  param.enter_subsection("Ucd");
+  ucd_flags.parse_parameters(param);
+  param.leave_subsection();
+  
+  param.enter_subsection("Gnuplot");
+  gnuplot_flags.parse_parameters(param);
+  param.leave_subsection();
+  
+  param.enter_subsection("Eps");
+  eps_flags_1.parse_parameters(param);
+  eps_flags_2.parse_parameters(param);
+  eps_flags_3.parse_parameters(param);
+  param.leave_subsection();
+  
+  param.enter_subsection("XFig");
+  xfig_flags.parse_parameters(param);
+  param.leave_subsection();
+}
+
+
+
 unsigned int
 GridOut::memory_consumption () const
 {
index 7d4952990ec55883e923c79a99603d37a515a037..fccd06d2d910d35729bb6f674fd3d2db75d17bc6 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -1613,46 +1613,55 @@ void GridOut::write_eps (const Triangulation<dim> &tria,
 #endif
 
 
-    template <int dim>
-void GridOut::write (const Triangulation<dim> &tria,
-       std::ostream             &out,
-       const OutputFormat        output_format,
-       const Mapping<dim>       *mapping)
+template <int dim>
+void GridOut::write (
+  const Triangulation<dim> &tria,
+  std::ostream             &out,
+  const OutputFormat        output_format,
+  const Mapping<dim>       *mapping)
 {
-    switch (output_format)
+  switch (output_format)
     {
-       case none:
-           return;
-
-       case dx:
-           write_dx (tria, out);
-           return;
-
-       case ucd:
-           write_ucd (tria, out);
-           return;
-
-       case gnuplot:
-           write_gnuplot (tria, out, mapping);
-           return;
-
-       case eps:
-           write_eps (tria, out, mapping);
-           return;
-
-       case xfig:
-           write_xfig (tria, out, mapping);
-           return;
-
-       case msh:
-           write_msh (tria, out);
-           return;
+      case none:
+       return;
+       
+      case dx:
+       write_dx (tria, out);
+       return;
+       
+      case ucd:
+       write_ucd (tria, out);
+       return;
+       
+      case gnuplot:
+       write_gnuplot (tria, out, mapping);
+       return;
+       
+      case eps:
+       write_eps (tria, out, mapping);
+       return;
+       
+      case xfig:
+       write_xfig (tria, out, mapping);
+       return;
+       
+      case msh:
+       write_msh (tria, out);
+       return;
     }
-
-    Assert (false, ExcInternalError());
+  
+  Assert (false, ExcInternalError());
 }
 
 
+template <int dim>
+void GridOut::write (
+  const Triangulation<dim> &tria,
+  std::ostream             &out,
+  const Mapping<dim>       *mapping)
+{
+  write(tria, out, default_format, mapping);
+}
 
 // explicit instantiations
 template void GridOut::write_ucd<deal_II_dimension>
@@ -1666,6 +1675,8 @@ template void GridOut::write_eps<deal_II_dimension>
 #endif
 template void GridOut::write<deal_II_dimension>
 (const Triangulation<deal_II_dimension> &,
- std::ostream &,
- const OutputFormat,
+ std::ostream &, const OutputFormat,
  const Mapping<deal_II_dimension> *);
+template void GridOut::write<deal_II_dimension>
+(const Triangulation<deal_II_dimension> &,
+ std::ostream &, const Mapping<deal_II_dimension> *);
index a531f66998b5e0f6da8f5ee611239aa6d0d00145..4a2de2b8203fef9110bdff8cbe2ab5eeb6a41127 100644 (file)
@@ -495,6 +495,15 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+
+  <li> <p> Improved: <code class="class">GridOut</code> now has functions for
+  declaring and parsing parameters in a <code
+  class="class">ParameterHandler</code>, like used in <code
+  class="class">DataOut_Interface</code> for a long time.
+  <br>
+  (GK 2006/03/06)
+  </p>
+
   <li> <p>
        Improved: The <code class="class">Triangulation</code>, <code
        class="class">PersistentTriangulation</code>, <code

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.