From: guido Date: Fri, 11 Feb 2000 19:53:58 +0000 (+0000) Subject: default format implemented X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=739952cd84c4b69c86081f23cce9be801d98467a;p=dealii-svn.git default format implemented git-svn-id: https://svn.dealii.org/trunk@2393 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h index ae78bcb3f3..41ee5fcbb3 100644 --- a/deal.II/base/include/base/data_out_base.h +++ b/deal.II/base/include/base/data_out_base.h @@ -1116,6 +1116,13 @@ class DataOutBase * the formats presently implemented. User programs need therefore not * be changed whenever a new format is implemented. * + * Additionally, objects of this class have a default format, which + * can be set by the parameter "Output format" of the parameter + * file. Within a program, this can be changed by the member function + * #set_format#. Using this default format, it is possible to leave + * the format selection completely to the parameter file. A suitable + * suffic for the output file name can be obtained by #default_suffix# + * without arguments. * * @author Wolfgang Bangerth, 1999 */ @@ -1127,7 +1134,7 @@ class DataOutInterface : private DataOutBase * Provide a data type specifying the * presently supported output formats. */ - enum OutputFormat { ucd, gnuplot, povray, eps, gmv }; + enum OutputFormat { nil, ucd, gnuplot, povray, eps, gmv }; /** * Obtain data through the #get_patches# @@ -1168,10 +1175,21 @@ class DataOutInterface : private DataOutBase * Write data and grid to #out# according * to the given data format. This function * simply calls the appropriate - * #write_*# function. + * #write_*# function. If no output format is + * requested, the #default_format# is written. + * + * An error occurs if no format is provided and + * the default format is #nil#. */ - void write (ostream &out, const OutputFormat output_format) const; - + void write (ostream &out, const OutputFormat output_format = nil) const; + + /** + * Set the default format. The value set here + * is used anytime, output for format #nil# is + * requested. + */ + void set_format(const OutputFormat default_format); + /** * Set the flags to be used for output * in UCD format. @@ -1216,12 +1234,12 @@ class DataOutInterface : private DataOutBase * \item #gmv#: #.gmv#. * \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. + * If this function is called + * with no argument or #nil#, the + * suffix for the + * #default_format# is returned. */ - static string default_suffix (const OutputFormat output_format); + string default_suffix (const OutputFormat output_format = nil); /** * Return the #OutputFormat# value @@ -1320,6 +1338,14 @@ class DataOutInterface : private DataOutBase virtual vector get_dataset_names () const = 0; private: + /** + * Standard output format. + * Use this format, if output format nil is + * requested. It can be changed by the #set_format# + * function or in a parameter file. + */ + OutputFormat default_format; + /** * Flags to be used upon output of UCD * data. Can be changed by using the diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index e8d936b142..3da07c04ab 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -1728,7 +1728,11 @@ void DataOutInterface::write_gmv (ostream &out) const template void DataOutInterface::write (ostream &out, - const OutputFormat output_format) const { + OutputFormat output_format) const +{ + if (output_format == nil) + output_format = default_format; + switch (output_format) { case ucd: @@ -1756,6 +1760,11 @@ void DataOutInterface::write (ostream &out, }; }; +template +void DataOutInterface::set_format(OutputFormat fmt) +{ + default_format = fmt; +} template @@ -1799,8 +1808,11 @@ void DataOutInterface::set_flags (const GmvFlags &flags) template -string DataOutInterface::default_suffix (const OutputFormat output_format) +string DataOutInterface::default_suffix (OutputFormat output_format) { + if (output_format == nil) + output_format = default_format; + switch (output_format) { case ucd: @@ -1853,64 +1865,68 @@ DataOutInterface::parse_output_format (const string &format_name) { template -string DataOutInterface::get_output_format_names () { +string DataOutInterface::get_output_format_names () +{ return "ucd|gnuplot|povray|eps|gmv"; -}; +} template void DataOutInterface::declare_parameters (ParameterHandler &prm) { + prm.declare_entry ("Output format", "gnuplot", + Patterns::Selection (get_output_format_names ())); + prm.enter_subsection ("UCD output parameters"); UcdFlags::declare_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Gnuplot output parameters"); GnuplotFlags::declare_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Povray output parameters"); PovrayFlags::declare_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Eps output parameters"); EpsFlags::declare_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Gmv output parameters"); GmvFlags::declare_parameters (prm); - prm.leave_subsection(); -}; + prm.leave_subsection (); +} template void DataOutInterface::parse_parameters (ParameterHandler &prm) { + const string& output_name = prm.get ("Output format"); + default_format = parse_output_format (output_name); + prm.enter_subsection ("UCD output parameters"); ucd_flags.parse_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Gnuplot output parameters"); gnuplot_flags.parse_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Povray output parameters"); povray_flags.parse_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Eps output parameters"); eps_flags.parse_parameters (prm); - prm.leave_subsection(); + prm.leave_subsection (); prm.enter_subsection ("Gmv output parameters"); gmv_flags.parse_parameters (prm); - prm.leave_subsection(); -}; - - - + prm.leave_subsection (); +}