From b5e8552033666bade93a565ac57f71e478722842 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 18 May 1998 08:29:22 +0000 Subject: [PATCH] Add general write function and more general stuff. git-svn-id: https://svn.dealii.org/trunk@297 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/data_io.h | 33 ++++++++++++++++++++++ deal.II/deal.II/source/numerics/data_io.cc | 29 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/deal.II/deal.II/include/numerics/data_io.h b/deal.II/deal.II/include/numerics/data_io.h index fc8192dc02..08844019b0 100644 --- a/deal.II/deal.II/include/numerics/data_io.h +++ b/deal.II/deal.II/include/numerics/data_io.h @@ -320,6 +320,12 @@ class DataIn { template class DataOut { public: + /** + * Provide a data type specifying the + * presently supported output formats. + */ + enum OutputFormat { ucd, gnuplot }; + /** * Constructor */ @@ -381,6 +387,31 @@ class DataOut { * Write data and grid in GNUPLOT format. */ void write_gnuplot (ostream &out) const; + + /** + * Write data and grid to #out# according + * to the given data format. This function + * simply calles the appropriate + * #write_*# function. + */ + void write (ostream &out, const OutputFormat output_format) const; + + /** + * 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 UCD: #.inp# + * \item GNUPLOT: #.gnuplot# + * \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); /** * Exception @@ -490,6 +521,8 @@ class DataOut { + + /*---------------------------- io.h ---------------------------*/ /* end of #ifndef __data_io_H */ diff --git a/deal.II/deal.II/source/numerics/data_io.cc b/deal.II/deal.II/source/numerics/data_io.cc index a6531dd253..010595842c 100644 --- a/deal.II/deal.II/source/numerics/data_io.cc +++ b/deal.II/deal.II/source/numerics/data_io.cc @@ -553,6 +553,35 @@ void DataOut::write_gnuplot (ostream &out) const { +template +void DataOut::write (ostream &out, + const OutputFormat output_format) const { + switch (output_format) + { + case ucd: + write_ucd (out); + break; + case gnuplot: + write_gnuplot (out); + break; + }; +}; + + + +template +string DataOut::default_suffix (const OutputFormat output_format) { + switch (output_format) + { + case ucd: + return ".inp"; + case gnuplot: + return ".gnuplot"; + }; +}; + + + //explicite instantiations template class DataIn<1>; -- 2.39.5