From 53334e0afa966debfcc440ba184953b646d4bdda Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 10 Oct 2007 19:54:12 +0000 Subject: [PATCH] Move the stream objects into an internal namespace git-svn-id: https://svn.dealii.org/trunk@15283 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/data_out_base.h | 469 +-------- deal.II/base/source/data_out_base.cc | 1143 ++++++++++++++------- 2 files changed, 809 insertions(+), 803 deletions(-) diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h index 4392ad6318..4f0cd37e20 100644 --- a/deal.II/base/include/base/data_out_base.h +++ b/deal.II/base/include/base/data_out_base.h @@ -56,21 +56,18 @@ class ParameterHandler; *

Structure of the output data

* * Data is not written with the deal.II mesh structure. Instead, it - * relies on a set of patches created by a derived class. - * Each Patch itself consists of a dim-dimensional regular - * grid with the same number of grid points in each direction. In the - * simplest case it may consist of the corner points of a mesh cell. - * For each point of this local grid, the Patch contains an arbitrary - * (but the same for each point) number of data values. - * - * Normally, each Patch is written to the output file as what the - * visualization program should consider a grid. Therefore, the output - * is in most cases a collection of grids with data, not - * a single grid. This became necessary, since many programs cannot - * handle hanging nodes. On the other hand, it means that data once - * written is stripped of its mesh structure and cannot be used for - * further simulation with deal.II. - * + * relies on a set of patches created by a derived class (for + * example the DataOut, DataOutStack, DataOutFaces, DataOutRotation, + * or MatrixOut classes). Each Patch describes a single logical cell + * of a mesh, possibly subdivided a number of times to represent + * higher order polynomials defined on this cell. To this end, a patch + * consists of a dim-dimensional regular grid with the same + * number of grid points in each direction. In the simplest case it + * may consist of the corner points of a single mesh cell. For each + * point of this local grid, the Patch contains an arbitrary number of + * data values, though the number of data sets must be the same for + * each point on each patch. + * * By offering this interface to the different output formats, it is simple * to extend this class to new formats without depending on such things * as actual triangulations and handling of data vectors. These things shall @@ -80,11 +77,9 @@ class ParameterHandler; * lexicographical order, x running fastest, then y and * z. Nodes are stored in this order and cells as well. Each * cell in 3D is stored such that the front face is in the - * xz-plane, where the numbering depends on the output format - * (see DXStream, GmvStream, TecplotStream, UcdStream, VtkStream). - * - * In order to enhance intellegibility of this concept, the following - * two sections are kept from a previous version of this documentation. + * xz-plane. In order to enhance intellegibility of this + * concept, the following two sections are kept from a previous + * version of this documentation. * * *

Patches

@@ -196,7 +191,8 @@ class ParameterHandler; * For each of these fields, output functions are implemented, namely * write_nodes(), write_cells() and write_data(). In order to use * these functions, a format specific output stream must be written, - * following the examples of DXStream, GmvStream, VtkStream and so on. + * following the examples of DXStream, GmvStream, VtkStream and so on, + * implemented in the .cc file. * * In this framework, the implementation of a new output format is * reduced to writing the section headers and the new output stream @@ -1307,7 +1303,8 @@ class DataOutBase * the presently supported output * formats. */ - enum OutputFormat { + enum OutputFormat + { /** * Use the format already * stored in the object. @@ -1374,398 +1371,7 @@ class DataOutBase */ deal_II_intermediate }; - - /** - * Class for writing basic - * entities in @ref - * SoftwareOpenDX format, - * depending on the flags. - */ - class DXStream - { - public: - /** - * Constructor, storing - * persistent values for - * later use. - */ - DXStream (std::ostream& stream, DXFlags flags); - /** - * Output operator for points. - */ - template - void write(const unsigned int index, const Point&); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,2,1,3] - *
  3. [0,4,2,6,1,5,3,7] - *
- */ - template - void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Write a complete set of - * data for a single node. - */ - template - void write_dataset(unsigned int index, - const std::vector& values); - - /** - * Forwarding of output stream - */ - template - std::ostream& operator<< (const T&); - private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ - std::ostream& stream; - /** - * The flags controlling the output - */ - DXFlags flags; - }; - - /** - * Class for writing basic - * entities in @ref SoftwareGMV - * format, depending on the - * flags. - */ - class GmvStream - { - public: - /** - * Constructor, storing - * persistent values for - * later use. - */ - GmvStream (std::ostream& stream, GmvFlags flags); - /** - * Output operator for points. - */ - template - void write(const unsigned int index, const Point&); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,1,3,2] - *
  3. [0,1,3,2,4,5,7,6] - *
- */ - template - void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Write a complete set of - * data for a single node. - */ - template - void write_dataset(unsigned int index, - const std::vector& values); - - /** - * Forwarding of output stream - */ - template - std::ostream& operator<< (const T&); - /** - * Since GMV reads the x, y - * and z coordinates in - * separate fields, we enable - * write() to output only a - * single selected component - * at once and do this dim - * times for the whole set of - * nodes. This integer can be - * used to select the - * component written. - */ - unsigned int selected_component; - - private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ - std::ostream& stream; - /** - * The flags controlling the output - */ - GmvFlags flags; - }; - - /** - * Class for writing basic - * entities in @ref - * SoftwareTecplot format, - * depending on the flags. - */ - class TecplotStream - { - public: - /** - * Constructor, storing - * persistent values for - * later use. - */ - TecplotStream (std::ostream& stream, TecplotFlags flags); - /** - * Output operator for points. - */ - template - void write(const unsigned int index, const Point&); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,1,3,2] - *
  3. [0,1,3,2,4,5,7,6] - *
- */ - template - void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Write a complete set of - * data for a single node. - */ - template - void write_dataset(unsigned int index, - const std::vector& values); - - /** - * Forwarding of output stream - */ - template - std::ostream& operator<< (const T&); - /** - * Since TECPLOT reads the x, y - * and z coordinates in - * separate fields, we enable - * write() to output only a - * single selected component - * at once and do this dim - * times for the whole set of - * nodes. This integer can be - * used to select the - * component written. - */ - unsigned int selected_component; - - private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ - std::ostream& stream; - /** - * The flags controlling the output - */ - TecplotFlags flags; - }; - - /** - * Class for writing basic - * entities in UCD format for - * @ref SoftwareAVS, depending on - * the flags. - */ - class UcdStream - { - public: - /** - * Constructor, storing - * persistent values for - * later use. - */ - UcdStream (std::ostream& stream, UcdFlags flags); - /** - * Output operator for points. - */ - template - void write(const unsigned int index, const Point&); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The additional offset 1 is - * added inside this - * function. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,1,3,2] - *
  3. [0,1,5,4,2,3,7,6] - *
- */ - template - void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Write a complete set of - * data for a single node. - */ - template - void write_dataset(unsigned int index, - const std::vector& values); - - /** - * Forwarding of output stream - */ - template - std::ostream& operator<< (const T&); - private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ - std::ostream& stream; - /** - * The flags controlling the output - */ - UcdFlags flags; - }; - - /** - * Class for writing basic - * entities in @ref SoftwareVTK - * format, depending on the - * flags. - */ - class VtkStream - { - public: - /** - * Constructor, storing - * persistent values for - * later use. - */ - VtkStream (std::ostream& stream, VtkFlags flags); - /** - * Output operator for points. - */ - template - void write(const unsigned int index, const Point&); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [] - *
  3. [] - *
- */ - template - void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Write a complete set of - * data for a single node. - */ - template - void write_dataset(unsigned int index, - const std::vector& values); - - /** - * Forwarding of output stream - */ - template - std::ostream& operator<< (const T&); - private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ - std::ostream& stream; - /** - * The flags controlling the output - */ - VtkFlags flags; - }; + /** * Write the given list of patches to the output stream in @ref @@ -3060,41 +2666,6 @@ operator >> (std::istream &in, -template -std::ostream& -DataOutBase::DXStream::operator<< (const T& t) -{ - stream << t; - return stream; -} - - -template -std::ostream& -DataOutBase::GmvStream::operator<< (const T& t) -{ - stream << t; - return stream; -} - - -template -std::ostream& -DataOutBase::UcdStream::operator<< (const T& t) -{ - stream << t; - return stream; -} - - -template -std::ostream& -DataOutBase::VtkStream::operator<< (const T& t) -{ - stream << t; - return stream; -} - DEAL_II_NAMESPACE_CLOSE #endif diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index 4af720e659..de64366cf0 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -1,4 +1,4 @@ -//--------------------------------------------------------------------------- + //--------------------------------------------------------------------------- // $Id$ // Version: $Name$ // @@ -176,6 +176,794 @@ namespace } } + + + + + /** + * Class for writing basic + * entities in @ref + * SoftwareOpenDX format, + * depending on the flags. + */ + class DXStream + { + public: + /** + * Constructor, storing + * persistent values for + * later use. + */ + DXStream (std::ostream& stream, DataOutBase::DXFlags flags); + /** + * Output operator for points. + */ + template + void write(const unsigned int index, const Point&); + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,2,1,3] + *
  3. [0,4,2,6,1,5,3,7] + *
+ */ + template + void write_cell(const unsigned int index, + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Write a complete set of + * data for a single node. + */ + template + void write_dataset(unsigned int index, + const std::vector& values); + + /** + * Forwarding of output stream + */ + template + std::ostream& operator<< (const T&); + private: + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ + std::ostream& stream; + /** + * The flags controlling the output + */ + DataOutBase::DXFlags flags; + }; + + /** + * Class for writing basic + * entities in @ref SoftwareGMV + * format, depending on the + * flags. + */ + class GmvStream + { + public: + /** + * Constructor, storing + * persistent values for + * later use. + */ + GmvStream (std::ostream& stream, DataOutBase::GmvFlags flags); + /** + * Output operator for points. + */ + template + void write(const unsigned int index, const Point&); + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,1,3,2] + *
  3. [0,1,3,2,4,5,7,6] + *
+ */ + template + void write_cell(const unsigned int index, + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Write a complete set of + * data for a single node. + */ + template + void write_dataset(unsigned int index, + const std::vector& values); + + /** + * Forwarding of output stream + */ + template + std::ostream& operator<< (const T&); + /** + * Since GMV reads the x, y + * and z coordinates in + * separate fields, we enable + * write() to output only a + * single selected component + * at once and do this dim + * times for the whole set of + * nodes. This integer can be + * used to select the + * component written. + */ + unsigned int selected_component; + + private: + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ + std::ostream& stream; + /** + * The flags controlling the output + */ + DataOutBase::GmvFlags flags; + }; + + /** + * Class for writing basic + * entities in @ref + * SoftwareTecplot format, + * depending on the flags. + */ + class TecplotStream + { + public: + /** + * Constructor, storing + * persistent values for + * later use. + */ + TecplotStream (std::ostream& stream, DataOutBase::TecplotFlags flags); + /** + * Output operator for points. + */ + template + void write(const unsigned int index, const Point&); + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,1,3,2] + *
  3. [0,1,3,2,4,5,7,6] + *
+ */ + template + void write_cell(const unsigned int index, + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Write a complete set of + * data for a single node. + */ + template + void write_dataset(unsigned int index, + const std::vector& values); + + /** + * Forwarding of output stream + */ + template + std::ostream& operator<< (const T&); + /** + * Since TECPLOT reads the x, y + * and z coordinates in + * separate fields, we enable + * write() to output only a + * single selected component + * at once and do this dim + * times for the whole set of + * nodes. This integer can be + * used to select the + * component written. + */ + unsigned int selected_component; + + private: + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ + std::ostream& stream; + /** + * The flags controlling the output + */ + DataOutBase::TecplotFlags flags; + }; + + /** + * Class for writing basic + * entities in UCD format for + * @ref SoftwareAVS, depending on + * the flags. + */ + class UcdStream + { + public: + /** + * Constructor, storing + * persistent values for + * later use. + */ + UcdStream (std::ostream& stream, DataOutBase::UcdFlags flags); + /** + * Output operator for points. + */ + template + void write(const unsigned int index, const Point&); + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The additional offset 1 is + * added inside this + * function. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,1,3,2] + *
  3. [0,1,5,4,2,3,7,6] + *
+ */ + template + void write_cell(const unsigned int index, + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Write a complete set of + * data for a single node. + */ + template + void write_dataset(unsigned int index, + const std::vector& values); + + /** + * Forwarding of output stream + */ + template + std::ostream& operator<< (const T&); + private: + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ + std::ostream& stream; + /** + * The flags controlling the output + */ + DataOutBase::UcdFlags flags; + }; + + /** + * Class for writing basic + * entities in @ref SoftwareVTK + * format, depending on the + * flags. + */ + class VtkStream + { + public: + /** + * Constructor, storing + * persistent values for + * later use. + */ + VtkStream (std::ostream& stream, DataOutBase::VtkFlags flags); + /** + * Output operator for points. + */ + template + void write(const unsigned int index, const Point&); + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [] + *
  3. [] + *
+ */ + template + void write_cell(const unsigned int index, + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Write a complete set of + * data for a single node. + */ + template + void write_dataset(unsigned int index, + const std::vector& values); + + /** + * Forwarding of output stream + */ + template + std::ostream& operator<< (const T&); + private: + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ + std::ostream& stream; + /** + * The flags controlling the output + */ + DataOutBase::VtkFlags flags; + }; + + + + +//----------------------------------------------------------------------// + + DXStream::DXStream(std::ostream& out, DataOutBase::DXFlags f) + : + stream(out), flags(f) + {} + + + template + void + DXStream::write (const unsigned int, + const Point& p) + { + if (flags.coordinates_binary) + { + float data[dim]; + for (unsigned int d=0; d(data), + dim * sizeof(*data)); + } + else + { + for (unsigned int d=0; d + void + DXStream::write_cell( + unsigned int, + unsigned int start, + unsigned int d1, + unsigned int d2, + unsigned int d3) + { + int nodes[8]; + nodes[GeometryInfo::dx_to_deal[0]] = start; + nodes[GeometryInfo::dx_to_deal[1]] = start+d1; + if (dim>=2) + { + // Add shifted line in y direction + nodes[GeometryInfo::dx_to_deal[2]] = start+d2; + nodes[GeometryInfo::dx_to_deal[3]] = start+d2+d1; + if (dim>=3) + { + // Add shifted quad in z direction + nodes[GeometryInfo::dx_to_deal[4]] = start+d3; + nodes[GeometryInfo::dx_to_deal[5]] = start+d3+d1; + nodes[GeometryInfo::dx_to_deal[6]] = start+d3+d2; + nodes[GeometryInfo::dx_to_deal[7]] = start+d3+d2+d1; + } + } + + if (flags.int_binary) + stream.write(reinterpret_cast(nodes), + (1< + inline + void + DXStream::write_dataset(unsigned int, + const std::vector& values) + { + if (flags.data_binary) + { + stream.write(reinterpret_cast(&values[0]), + values.size()*sizeof(data)); + } + else + { + for (unsigned int i=0;i + void + GmvStream::write (const unsigned int, + const Point& p) + { + Assert(selected_component != deal_II_numbers::invalid_unsigned_int, + ExcNotInitialized()); + stream << p(selected_component) << ' '; + } + + + template + void + GmvStream::write_cell( + unsigned int, + unsigned int s, + unsigned int d1, + unsigned int d2, + unsigned int d3) + { + // Vertices are numbered starting + // with one. + const unsigned int start=s+1; + stream << gmv_cell_type[dim] << '\n'; + + stream << start << '\t' + << start+d1; + if (dim>=2) + { + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } + } + stream << '\n'; + } + + + template + inline + void + GmvStream::write_dataset(unsigned int, + const std::vector& values) + { + Assert (false, ExcInternalError()); + } + + + +//----------------------------------------------------------------------// + + TecplotStream::TecplotStream(std::ostream& out, DataOutBase::TecplotFlags f) + : + selected_component(deal_II_numbers::invalid_unsigned_int), + stream(out), flags(f) + {} + + + template + void + TecplotStream::write (const unsigned int, + const Point& p) + { + Assert(selected_component != deal_II_numbers::invalid_unsigned_int, + ExcNotInitialized()); + stream << p(selected_component) << '\n'; + } + + + template + void + TecplotStream::write_cell( + unsigned int, + unsigned int s, + unsigned int d1, + unsigned int d2, + unsigned int d3) + { + const unsigned int start = s+1; + + stream << start << '\t' + << start+d1; + if (dim>=2) + { + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } + } + stream << '\n'; + } + + + template + inline + void + TecplotStream::write_dataset(unsigned int, + const std::vector& values) + { + Assert (false, ExcInternalError()); + } + + + +//----------------------------------------------------------------------// + + UcdStream::UcdStream(std::ostream& out, DataOutBase::UcdFlags f) + : + stream(out), flags(f) + {} + + + template + void + UcdStream::write (const unsigned int index, + const Point& p) + { + stream << index+1 + << " "; + // write out coordinates + for (unsigned int i=0; i + void + UcdStream::write_cell( + unsigned int index, + unsigned int start, + unsigned int d1, + unsigned int d2, + unsigned int d3) + { + int nodes[8]; + nodes[GeometryInfo::ucd_to_deal[0]] = start; + nodes[GeometryInfo::ucd_to_deal[1]] = start+d1; + if (dim>=2) + { + // Add shifted line in y direction + nodes[GeometryInfo::ucd_to_deal[2]] = start+d2; + nodes[GeometryInfo::ucd_to_deal[3]] = start+d2+d1; + if (dim>=3) + { + // Add shifted quad in z direction + nodes[GeometryInfo::ucd_to_deal[4]] = start+d3; + nodes[GeometryInfo::ucd_to_deal[5]] = start+d3+d1; + nodes[GeometryInfo::ucd_to_deal[6]] = start+d3+d2; + nodes[GeometryInfo::ucd_to_deal[7]] = start+d3+d2+d1; + } + } + + // Write out all cells and remember + // that all indices must be shifted + // by one. + stream << index+1 << "\t0 " << ucd_cell_type[dim]; + const unsigned int final = (1< + inline + void + UcdStream::write_dataset(unsigned int index, + const std::vector& values) + { + stream << index+1; + for (unsigned int i=0;i + void + VtkStream::write (const unsigned int, + const Point& p) + { + // write out coordinates + stream << p; + // fill with zeroes + for (unsigned int i=dim; i<3; ++i) + stream << " 0"; + stream << '\n'; + } + + + template + void + VtkStream::write_cell( + unsigned int, + unsigned int start, + unsigned int d1, + unsigned int d2, + unsigned int d3) + { + stream << GeometryInfo::vertices_per_cell << '\t' + << start << '\t' + << start+d1; + if (dim>=2) + { + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } + } + stream << '\n'; + } + + + template + inline + void + VtkStream::write_dataset(unsigned int, + const std::vector& values) + { + for (unsigned int i=0;i + std::ostream& + DXStream::operator<< (const T& t) + { + stream << t; + return stream; + } + + + template + std::ostream& + GmvStream::operator<< (const T& t) + { + stream << t; + return stream; + } + + + template + std::ostream& + UcdStream::operator<< (const T& t) + { + stream << t; + return stream; + } + + + template + std::ostream& + VtkStream::operator<< (const T& t) + { + stream << t; + return stream; + } } @@ -858,359 +1646,6 @@ default_suffix (const OutputFormat output_format) } } -//----------------------------------------------------------------------// - -DataOutBase::DXStream::DXStream(std::ostream& out, DataOutBase::DXFlags f) - : - stream(out), flags(f) -{} - - -template -void -DataOutBase::DXStream::write (const unsigned int, - const Point& p) -{ - if (flags.coordinates_binary) - { - float data[dim]; - for (unsigned int d=0; d(data), - dim * sizeof(*data)); - } - else - { - for (unsigned int d=0; d -void -DataOutBase::DXStream::write_cell( - unsigned int, - unsigned int start, - unsigned int d1, - unsigned int d2, - unsigned int d3) -{ - int nodes[8]; - nodes[GeometryInfo::dx_to_deal[0]] = start; - nodes[GeometryInfo::dx_to_deal[1]] = start+d1; - if (dim>=2) - { - // Add shifted line in y direction - nodes[GeometryInfo::dx_to_deal[2]] = start+d2; - nodes[GeometryInfo::dx_to_deal[3]] = start+d2+d1; - if (dim>=3) - { - // Add shifted quad in z direction - nodes[GeometryInfo::dx_to_deal[4]] = start+d3; - nodes[GeometryInfo::dx_to_deal[5]] = start+d3+d1; - nodes[GeometryInfo::dx_to_deal[6]] = start+d3+d2; - nodes[GeometryInfo::dx_to_deal[7]] = start+d3+d2+d1; - } - } - - if (flags.int_binary) - stream.write(reinterpret_cast(nodes), - (1< -inline -void -DataOutBase::DXStream::write_dataset(unsigned int, - const std::vector& values) -{ - if (flags.data_binary) - { - stream.write(reinterpret_cast(&values[0]), - values.size()*sizeof(data)); - } - else - { - for (unsigned int i=0;i -void -DataOutBase::GmvStream::write (const unsigned int, - const Point& p) -{ - Assert(selected_component != deal_II_numbers::invalid_unsigned_int, - ExcNotInitialized()); - stream << p(selected_component) << ' '; -} - - -template -void -DataOutBase::GmvStream::write_cell( - unsigned int, - unsigned int s, - unsigned int d1, - unsigned int d2, - unsigned int d3) -{ - // Vertices are numbered starting - // with one. - const unsigned int start=s+1; - stream << gmv_cell_type[dim] << '\n'; - - stream << start << '\t' - << start+d1; - if (dim>=2) - { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } - } - stream << '\n'; -} - - -template -inline -void -DataOutBase::GmvStream::write_dataset(unsigned int, - const std::vector& values) -{ - Assert (false, ExcInternalError()); -} - - - -//----------------------------------------------------------------------// - -DataOutBase::TecplotStream::TecplotStream(std::ostream& out, DataOutBase::TecplotFlags f) - : - selected_component(deal_II_numbers::invalid_unsigned_int), - stream(out), flags(f) -{} - - -template -void -DataOutBase::TecplotStream::write (const unsigned int, - const Point& p) -{ - Assert(selected_component != deal_II_numbers::invalid_unsigned_int, - ExcNotInitialized()); - stream << p(selected_component) << '\n'; -} - - -template -void -DataOutBase::TecplotStream::write_cell( - unsigned int, - unsigned int s, - unsigned int d1, - unsigned int d2, - unsigned int d3) -{ - const unsigned int start = s+1; - - stream << start << '\t' - << start+d1; - if (dim>=2) - { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } - } - stream << '\n'; -} - - -template -inline -void -DataOutBase::TecplotStream::write_dataset(unsigned int, - const std::vector& values) -{ - Assert (false, ExcInternalError()); -} - - - -//----------------------------------------------------------------------// - -DataOutBase::UcdStream::UcdStream(std::ostream& out, DataOutBase::UcdFlags f) - : - stream(out), flags(f) -{} - - -template -void -DataOutBase::UcdStream::write (const unsigned int index, - const Point& p) -{ - stream << index+1 - << " "; - // write out coordinates - for (unsigned int i=0; i -void -DataOutBase::UcdStream::write_cell( - unsigned int index, - unsigned int start, - unsigned int d1, - unsigned int d2, - unsigned int d3) -{ - int nodes[8]; - nodes[GeometryInfo::ucd_to_deal[0]] = start; - nodes[GeometryInfo::ucd_to_deal[1]] = start+d1; - if (dim>=2) - { - // Add shifted line in y direction - nodes[GeometryInfo::ucd_to_deal[2]] = start+d2; - nodes[GeometryInfo::ucd_to_deal[3]] = start+d2+d1; - if (dim>=3) - { - // Add shifted quad in z direction - nodes[GeometryInfo::ucd_to_deal[4]] = start+d3; - nodes[GeometryInfo::ucd_to_deal[5]] = start+d3+d1; - nodes[GeometryInfo::ucd_to_deal[6]] = start+d3+d2; - nodes[GeometryInfo::ucd_to_deal[7]] = start+d3+d2+d1; - } - } - - // Write out all cells and remember - // that all indices must be shifted - // by one. - stream << index+1 << "\t0 " << ucd_cell_type[dim]; - const unsigned int final = (1< -inline -void -DataOutBase::UcdStream::write_dataset(unsigned int index, - const std::vector& values) -{ - stream << index+1; - for (unsigned int i=0;i -void -DataOutBase::VtkStream::write (const unsigned int, - const Point& p) -{ - // write out coordinates - stream << p; - // fill with zeroes - for (unsigned int i=dim; i<3; ++i) - stream << " 0"; - stream << '\n'; -} - - -template -void -DataOutBase::VtkStream::write_cell( - unsigned int, - unsigned int start, - unsigned int d1, - unsigned int d2, - unsigned int d3) -{ - stream << GeometryInfo::vertices_per_cell << '\t' - << start << '\t' - << start+d1; - if (dim>=2) - { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } - } - stream << '\n'; -} - - -template -inline -void -DataOutBase::VtkStream::write_dataset(unsigned int, - const std::vector& values) -{ - for (unsigned int i=0;i