From f5d00e489ec1f9858ce617713d2ec5af34a6ddc6 Mon Sep 17 00:00:00 2001
From: wolf
Date: Wed, 30 Jan 2002 08:50:05 +0000
Subject: [PATCH] Add tecplot output format.
git-svn-id: https://svn.dealii.org/trunk@5430 0785d39b-7218-0410-832d-ea1e28bc413d
---
deal.II/base/include/base/data_out_base.h | 97 ++++-
.../source/data_out_base.all_dimensions.cc | 19 +
deal.II/base/source/data_out_base.cc | 372 +++++++++++++++++-
deal.II/doc/news/2001/c-3-2.html | 14 +-
deal.II/doc/news/news.html | 12 +
deal.II/doc/readme.html | 4 +-
6 files changed, 512 insertions(+), 6 deletions(-)
diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h
index f011e65d46..034ce4db6d 100644
--- a/deal.II/base/include/base/data_out_base.h
+++ b/deal.II/base/include/base/data_out_base.h
@@ -308,7 +308,7 @@ class ParameterHandler;
* details of the viewpoint, light source, etc.
*
*
- * @author Wolfgang Bangerth 1999, 2000, 2001; EPS output based on an earlier implementation by Stefan Nauber for the old DataOut class; Povray output by Thomas Richter 1999
+ * @author Wolfgang Bangerth 1999, 2000, 2001; EPS output based on an earlier implementation by Stefan Nauber for the old DataOut class; Povray output by Thomas Richter 1999; OpenDX output by Guido Kanschat, 2001; Tecplot output by Benjamin Shelton Kirk, 2002.
*/
class DataOutBase
{
@@ -1070,6 +1070,62 @@ class DataOutBase
* present no flags are implemented.
*/
struct GmvFlags
+ {
+ private:
+ /**
+ * Dummy entry to suppress compiler
+ * warnings when copying an empty
+ * structure. Remove this member
+ * when adding the first flag to
+ * this structure (and remove the
+ * @p{private} as well).
+ */
+ int dummy;
+
+ public:
+ /**
+ * Declare all flags with name
+ * and type as offered by this
+ * class, for use in input files.
+ */
+ static void declare_parameters (ParameterHandler &prm);
+
+ /**
+ * Read the parameters declared in
+ * @p{declare_parameters} and set the
+ * flags for this output format
+ * accordingly.
+ *
+ * The flags thus obtained overwrite
+ * all previous contents of this object.
+ */
+ void parse_parameters (ParameterHandler &prm);
+
+ /**
+ * Determine an estimate for
+ * the memory consumption (in
+ * bytes) of this
+ * object. Since sometimes
+ * the size of objects can
+ * not be determined exactly
+ * (for example: what is the
+ * memory consumption of an
+ * STL @p{std::map} type with a
+ * certain number of
+ * elements?), this is only
+ * an estimate. however often
+ * quite close to the true
+ * value.
+ */
+ unsigned int memory_consumption () const;
+ };
+
+ /**
+ * Flags describing the details of
+ * output in Tecplot format. At
+ * present no flags are implemented.
+ */
+ struct TecplotFlags
{
private:
/**
@@ -1255,6 +1311,19 @@ class DataOutBase
const GmvFlags &flags,
std::ostream &out);
+ /**
+ * Write the given list of patches
+ * to the output stream in Tecplot
+ * format. See the general
+ * documentation for more information
+ * on the parameters.
+ */
+ template
+ static void write_tecplot (const typename std::vector > &patches,
+ const std::vector &data_names,
+ const TecplotFlags &flags,
+ std::ostream &out);
+
/**
* Write the given list of
* patches to the output stream
@@ -1518,7 +1587,7 @@ class DataOutInterface : private DataOutBase
* the presently supported output
* formats.
*/
- enum OutputFormat { default_format, dx, ucd, gnuplot, povray, eps, gmv, vtk };
+ enum OutputFormat { default_format, dx, ucd, gnuplot, povray, eps, gmv, tecplot, vtk };
/**
* Obtain data through the
@@ -1568,6 +1637,15 @@ class DataOutInterface : private DataOutBase
*/
void write_gmv (std::ostream &out) const;
+
+ /**
+ * Obtain data through the
+ * @p{get_patches} function and
+ * write it to @p{out} in Tecplot
+ * format.
+ */
+ void write_tecplot (std::ostream &out) const;
+
/**
* Obtain data through the
* @p{get_patches} function and
@@ -1638,6 +1716,12 @@ class DataOutInterface : private DataOutBase
*/
void set_flags (const GmvFlags &gmv_flags);
+ /**
+ * Set the flags to be used for
+ * output in Tecplot format.
+ */
+ void set_flags (const TecplotFlags &tecplot_flags);
+
/**
* Set the flags to be used for
* output in GMV format.
@@ -1860,6 +1944,15 @@ class DataOutInterface : private DataOutBase
*/
GmvFlags gmv_flags;
+ /**
+ * Flags to be used upon output
+ * of Tecplot data in one space
+ * dimension. Can be changed by
+ * using the @p{set_flags}
+ * function.
+ */
+ TecplotFlags tecplot_flags;
+
/**
* Flags to be used upon output
* of vtk data in one space
diff --git a/deal.II/base/source/data_out_base.all_dimensions.cc b/deal.II/base/source/data_out_base.all_dimensions.cc
index 8ae9cdfdb7..9788987fbd 100644
--- a/deal.II/base/source/data_out_base.all_dimensions.cc
+++ b/deal.II/base/source/data_out_base.all_dimensions.cc
@@ -382,6 +382,25 @@ DataOutBase::GmvFlags::memory_consumption () const
+void DataOutBase::TecplotFlags::declare_parameters (ParameterHandler &/*prm*/)
+{};
+
+
+
+void DataOutBase::TecplotFlags::parse_parameters (ParameterHandler &/*prm*/)
+{};
+
+
+unsigned int
+DataOutBase::TecplotFlags::memory_consumption () const
+{
+ // only simple data elements, so
+ // use sizeof operator
+ return sizeof (*this);
+};
+
+
+
void DataOutBase::VtkFlags::declare_parameters (ParameterHandler &/*prm*/)
{};
diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc
index db2fd6d9d3..9e6516b6f0 100644
--- a/deal.II/base/source/data_out_base.cc
+++ b/deal.II/base/source/data_out_base.cc
@@ -2302,6 +2302,340 @@ void DataOutBase::write_gmv (const typename std::vector > &p
+template
+void DataOutBase::write_tecplot (const typename std::vector > &patches,
+ const std::vector &data_names,
+ const TecplotFlags &/*flags*/,
+ std::ostream &out)
+{
+ AssertThrow (out, ExcIO());
+
+ Assert (patches.size() > 0, ExcNoPatches());
+
+ const unsigned int n_data_sets = data_names.size();
+ // check against # of data sets in
+ // first patch. checks against all
+ // other patches are made in
+ // write_gmv_reorder_data_vectors
+ Assert (n_data_sets == patches[0].data.n_rows(),
+ ExcUnexpectedNumberOfDatasets (patches[0].data.n_rows(), n_data_sets));
+
+
+
+ // first count the number of cells
+ // and cells for later use
+ unsigned int n_cells = 0,
+ n_nodes = 0;
+ for (typename std::vector >::const_iterator patch=patches.begin();
+ patch!=patches.end(); ++patch)
+ switch (dim)
+ {
+ case 1:
+ n_cells += patch->n_subdivisions;
+ n_nodes += patch->n_subdivisions+1;
+ break;
+ case 2:
+ n_cells += patch->n_subdivisions *
+ patch->n_subdivisions;
+ n_nodes += (patch->n_subdivisions+1) *
+ (patch->n_subdivisions+1);
+ break;
+ case 3:
+ n_cells += patch->n_subdivisions *
+ patch->n_subdivisions *
+ patch->n_subdivisions;
+ n_nodes += (patch->n_subdivisions+1) *
+ (patch->n_subdivisions+1) *
+ (patch->n_subdivisions+1);
+ break;
+ default:
+ Assert (false, ExcNotImplemented());
+ };
+
+
+ ///////////////////////
+ // preamble
+ {
+ std::time_t time1= std::time (0);
+ std::tm *time = std::localtime(&time1);
+ out << "# This file was generated by the deal.II library." << std::endl
+ << "# Date = "
+ << time->tm_year+1900 << "/"
+ << time->tm_mon+1 << "/"
+ << time->tm_mday << std::endl
+ << "# Time = "
+ << time->tm_hour << ":"
+ << std::setw(2) << time->tm_min << ":"
+ << std::setw(2) << time->tm_sec << std::endl
+ << "#" << std::endl
+ << "# For a description of the Tecplot format see the Tecplot documentation."
+ << std::endl
+ << "#" << std::endl;
+
+
+ out << "Variables=";
+
+ switch (dim)
+ {
+ case 1:
+ out << "\"x\"";
+ break;
+ case 2:
+ out << "\"x\", \"y\"";
+ break;
+ case 3:
+ out << "\"x\", \"y\", \"z\"";
+ break;
+ default:
+ Assert (false, ExcNotImplemented());
+ };
+
+ for (unsigned int data_set=0; data_set 1)
+ {
+ out << "zone f=feblock, n=" << n_nodes << ", e=" << n_cells << ", et=";
+
+ switch (dim)
+ {
+ case 2:
+ out << "quadrilateral" << std::endl;
+ break;
+ case 3:
+ out << "brick" << std::endl;
+ break;
+ default:
+ Assert (false, ExcNotImplemented());
+ };
+ }
+ else
+ {
+ out << "zone f=block, n=" << n_nodes << std::endl;
+ };
+ };
+
+
+ // in Tecplot block format the vertex
+ // coordinates and the data have an
+ // order that is a bit unpleasant
+ // (first all x coordinates, then
+ // all y coordinate, ...; first all
+ // data of variable 1, then
+ // variable 2, etc), so we have to
+ // copy the data vectors a bit around
+ //
+ // note that we copy vectors when
+ // looping over the patches since we
+ // have to write them one variable
+ // at a time and don't want to use
+ // more than one loop
+ //
+ // this copying of data vectors can
+ // be done while we already output
+ // the vertices, so do this on a
+ // separate thread and when wanting
+ // to write out the data, we wait
+ // for that thread to finish
+ std::vector > data_vectors (n_data_sets,
+ std::vector (n_nodes));
+ Threads::ThreadManager thread_manager;
+ void (*fun_ptr) (const typename std::vector > &,
+ std::vector > &)
+ = &DataOutBase::template write_gmv_reorder_data_vectors;
+ Threads::spawn (thread_manager,
+ Threads::encapsulate (fun_ptr)
+ .collect_args(patches, data_vectors));
+
+ ///////////////////////////////
+ // first make up a list of used
+ // vertices along with their
+ // coordinates
+
+
+ for (unsigned int d=1; d<=spacedim; ++d)
+ {
+ for (typename std::vector >::const_iterator patch=patches.begin();
+ patch!=patches.end(); ++patch)
+ {
+ const unsigned int n_subdivisions = patch->n_subdivisions;
+
+ switch (dim)
+ {
+ case 1:
+ {
+ for (unsigned int i=0; ivertices[1](0) * i / n_subdivisions) +
+ (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions))
+ << '\n';
+ break;
+ };
+
+ case 2:
+ {
+ for (unsigned int i=0; ivertices[1](d-1) * x_frac) +
+ (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
+ ((patch->vertices[2](d-1) * x_frac) +
+ (patch->vertices[3](d-1) * (1-x_frac))) * y_frac)
+ << '\n';
+ };
+ break;
+ };
+
+ case 3:
+ {
+ for (unsigned int i=0; ivertices[1](d-1) * x_frac) +
+ (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
+ ((patch->vertices[2](d-1) * x_frac) +
+ (patch->vertices[3](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) +
+ (((patch->vertices[5](d-1) * x_frac) +
+ (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) +
+ ((patch->vertices[6](d-1) * x_frac) +
+ (patch->vertices[7](d-1) * (1-x_frac))) * y_frac) * z_frac)
+ << '\n';
+ };
+
+ break;
+ };
+
+ default:
+ Assert (false, ExcNotImplemented());
+ };
+ };
+ out << std::endl;
+ };
+
+
+ ///////////////////////////////////////
+ // data output.
+ //
+ // now write the data vectors to
+ // @p{out} first make sure that all
+ // data is in place
+ thread_manager.wait ();
+
+ // then write data.
+ for (unsigned int data_set=0; data_set(out, "\n"));
+ out << std::endl;
+ };
+
+
+ /////////////////////////////////
+ // now for the cells. note that
+ // vertices are counted from 1 onwards
+
+ unsigned int first_vertex_of_patch = 0;
+
+ for (typename std::vector >::const_iterator patch=patches.begin();
+ patch!=patches.end(); ++patch)
+ {
+ const unsigned int n_subdivisions = patch->n_subdivisions;
+
+ // write out the cells making
+ // up this patch
+ switch (dim)
+ {
+ case 1:
+ {
+ break;
+ };
+ case 2:
+ {
+ for (unsigned int i=0; i
void DataOutBase::write_vtk (const typename std::vector > &patches,
const std::vector &data_names,
@@ -2777,6 +3111,15 @@ void DataOutInterface::write_gmv (std::ostream &out) const
+template
+void DataOutInterface::write_tecplot (std::ostream &out) const
+{
+ DataOutBase::write_tecplot (get_patches(), get_dataset_names(),
+ tecplot_flags, out);
+};
+
+
+
template
void DataOutInterface::write_vtk (std::ostream &out) const
{
@@ -2821,6 +3164,10 @@ DataOutInterface::write (std::ostream &out,
write_gmv (out);
break;
+ case tecplot:
+ write_tecplot (out);
+ break;
+
case vtk:
write_vtk (out);
break;
@@ -2889,6 +3236,14 @@ void DataOutInterface::set_flags (const GmvFlags &flags)
+template
+void DataOutInterface::set_flags (const TecplotFlags &flags)
+{
+ tecplot_flags = flags;
+};
+
+
+
template
void DataOutInterface::set_flags (const VtkFlags &flags)
{
@@ -2924,6 +3279,9 @@ DataOutInterface::default_suffix (const OutputFormat output_format
case gmv:
return ".gmv";
+
+ case tecplot:
+ return ".dat";
case vtk:
return ".vtk";
@@ -2957,6 +3315,9 @@ DataOutInterface::parse_output_format (const std::string &format_n
if (format_name == "gmv")
return gmv;
+
+ if (format_name == "tecplot")
+ return tecplot;
if (format_name == "vtk")
return vtk;
@@ -2972,7 +3333,7 @@ DataOutInterface::parse_output_format (const std::string &format_n
template
std::string DataOutInterface::get_output_format_names ()
{
- return "dx|ucd|gnuplot|povray|eps|gmv|vtk";
+ return "dx|ucd|gnuplot|povray|eps|gmv|tecplot|vtk";
}
@@ -3007,6 +3368,10 @@ void DataOutInterface::declare_parameters (ParameterHandler &prm)
GmvFlags::declare_parameters (prm);
prm.leave_subsection ();
+ prm.enter_subsection ("Tecplot output parameters");
+ TecplotFlags::declare_parameters (prm);
+ prm.leave_subsection ();
+
prm.enter_subsection ("Vtk output parameters");
VtkFlags::declare_parameters (prm);
prm.leave_subsection ();
@@ -3044,6 +3409,10 @@ void DataOutInterface::parse_parameters (ParameterHandler &prm)
gmv_flags.parse_parameters (prm);
prm.leave_subsection ();
+ prm.enter_subsection ("Tecplot output parameters");
+ tecplot_flags.parse_parameters (prm);
+ prm.leave_subsection ();
+
prm.enter_subsection ("Vtk output parameters");
vtk_flags.parse_parameters (prm);
prm.leave_subsection ();
@@ -3061,6 +3430,7 @@ DataOutInterface::memory_consumption () const
MemoryConsumption::memory_consumption (povray_flags) +
MemoryConsumption::memory_consumption (eps_flags) +
MemoryConsumption::memory_consumption (gmv_flags) +
+ MemoryConsumption::memory_consumption (tecplot_flags) +
MemoryConsumption::memory_consumption (vtk_flags));
};
diff --git a/deal.II/doc/news/2001/c-3-2.html b/deal.II/doc/news/2001/c-3-2.html
index 88a3fe15bf..4e69a8496c 100644
--- a/deal.II/doc/news/2001/c-3-2.html
+++ b/deal.II/doc/news/2001/c-3-2.html
@@ -26,6 +26,14 @@ documentation, etc.
General
+ -
+ New: Output for
+ Tecplot has
+ been added. It can be used by choosing output format «tecplot».
+
+ (Benjamin Shelton Kirk 2002/01/29)
+
+
-
New: configuration detects whether the compiler has the
include file <ostream>
. Most files in the
library then include this file over
@@ -43,11 +51,13 @@ documentation, etc.
-
- New: Output for OpenDX has
+ New: Output for
+ OpenDX has
been added. It can be used by choosing output format «dx» (not
yet for grid output). The data format is very basic now, but it
is planned to improve this to make use of the excellent
- capabilites of OpenDX.
+ capabilites of OpenDX.
+
Additionally, a directory contrib/dx has been added,
containing visual programs for OpenDX. Programs for the
diff --git a/deal.II/doc/news/news.html b/deal.II/doc/news/news.html
index 9a57212499..9a3d955524 100644
--- a/deal.II/doc/news/news.html
+++ b/deal.II/doc/news/news.html
@@ -29,6 +29,18 @@
+ -
+ 2002/01/30: New output formats OpenDX and Tecplot
+
+ -
+ Guido Kanschat and Benjamin Shelton Kirk contributed output
+ for OpenDX and Tecplot graphics formats, which are now
+ supported along a long list of other graphics
+ format. Switching output formats is possible at run time of
+ applications.
+
+
+
-
2001/12/07: Memory allocation and access checked
with
purify
diff --git a/deal.II/doc/readme.html b/deal.II/doc/readme.html
index 80179040ec..748f49ebc4 100644
--- a/deal.II/doc/readme.html
+++ b/deal.II/doc/readme.html
@@ -158,6 +158,7 @@
GNUPLOT,
GMV
(general mesh viewer),
+ Tecplot,
Visualization Toolkit (Vtk),
AVS Explorer,
@@ -169,7 +170,8 @@
everywhere, GMV and Open DX are freely available for most Unix
platforms. Povray is freely available for almost all
platforms. AVS is a commercial program available for most
- Unix flavors. HiVision is available for free after
+ Unix flavors. Tecplot is a commercial program available for
+ Windows and most Unix platforms. HiVision is available for free after
registration.
--
2.39.5