From: Guido Kanschat Date: Mon, 6 Mar 2006 13:18:09 +0000 (+0000) Subject: parameter parsing for GridOut X-Git-Tag: v8.0.0~12146 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3126f3905b42aa3201b6632f0f006bd2297cc2f0;p=dealii.git parameter parsing for GridOut git-svn-id: https://svn.dealii.org/trunk@12540 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_out.h b/deal.II/deal.II/include/grid/grid_out.h index c2d70afdf6..24753608f1 100644 --- a/deal.II/deal.II/include/grid/grid_out.h +++ b/deal.II/deal.II/include/grid/grid_out.h @@ -1018,18 +1018,29 @@ class GridOut void write_xfig (const Triangulation &tria, std::ostream &out, const Mapping *mapping=0); + /** - * Write data and grid to @p out according - * to the given data format. This function - * simply calls the appropriate - * write_* function. + * Write grid to @p out according + * to the given data format. This + * function simply calls the + * appropriate write_* + * function. */ template void write (const Triangulation &tria, std::ostream &out, const OutputFormat output_format, const Mapping *mapping=0); - + + /** + * Write mesh in default format + * set by ParameterHandler. + */ + template + void write (const Triangulation &tria, + std::ostream &out, + const Mapping *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. */ diff --git a/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc b/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc index 9859f1a10e..334aebecf8 100644 --- a/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc +++ b/deal.II/deal.II/source/grid/grid_out.all_dimensions.cc @@ -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 { diff --git a/deal.II/deal.II/source/grid/grid_out.cc b/deal.II/deal.II/source/grid/grid_out.cc index 7d4952990e..fccd06d2d9 100644 --- a/deal.II/deal.II/source/grid/grid_out.cc +++ b/deal.II/deal.II/source/grid/grid_out.cc @@ -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 &tria, #endif - template -void GridOut::write (const Triangulation &tria, - std::ostream &out, - const OutputFormat output_format, - const Mapping *mapping) +template +void GridOut::write ( + const Triangulation &tria, + std::ostream &out, + const OutputFormat output_format, + const Mapping *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 +void GridOut::write ( + const Triangulation &tria, + std::ostream &out, + const Mapping *mapping) +{ + write(tria, out, default_format, mapping); +} // explicit instantiations template void GridOut::write_ucd @@ -1666,6 +1675,8 @@ template void GridOut::write_eps #endif template void GridOut::write (const Triangulation &, - std::ostream &, - const OutputFormat, + std::ostream &, const OutputFormat, const Mapping *); +template void GridOut::write +(const Triangulation &, + std::ostream &, const Mapping *); diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index a531f66998..4a2de2b820 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -495,6 +495,15 @@ inconvenience this causes.

deal.II

    + +
  1. Improved: GridOut now has functions for + declaring and parsing parameters in a ParameterHandler, like used in DataOut_Interface for a long time. +
    + (GK 2006/03/06) +

    +
  2. Improved: The Triangulation, PersistentTriangulation,