1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Base class for graphics format writing. Entry points are
31 Write to an Ostream a table of points with corresponding values.
32 - write(scalar/vector/sphericalTensor/symmTensor/tensor). \n
33 Write single scalar/vector/sphericalTensor/symmTensor/tensor.
34 Default is to write space separated components.
38 // Construct writer of xmgr type
39 autoPtr<writer<scalar> > scalarFormatter(writer<scalar>::New("xmgr"));
41 // Output list of points and corresponding values
42 scalarFormatter().write
46 points, // sample coordinates
47 "someLine", // name of coordSet
48 "distance", // write coordinates as distance to refPoint
49 points[0] // reference point
51 "U.component(0)", // name of values
59 \*---------------------------------------------------------------------------*/
69 #include "runTimeSelectionTables.H"
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 // Forward declaration of classes
81 /*---------------------------------------------------------------------------*\
82 Class writer Declaration
83 \*---------------------------------------------------------------------------*/
91 //- Generates filename from coordSet and sampled fields
92 fileName getBaseName(const coordSet&, const wordList&) const;
96 const coordSet& samples,
101 //- Writes single-column ascii write. Column 1 is coordSet coordinate,
102 // columns 2 is the value. Uses write() function
103 // to write coordinate in correct format.
111 //- Writes multi-column ascii write. Column 1 is coordSet coordinate,
112 // columns 2..n are the values. Uses write() function
113 // to write coordinate in correct format.
117 const List<const List<Type>*>&,
124 //- Runtime type information
127 // Declare run-time constructor selection table
129 declareRunTimeSelectionTable
141 //- Return a reference to the selected writer
142 static autoPtr<writer> New
144 const word& writeFormat
155 virtual ~writer() = 0;
160 //- Generate file name with correct extension
161 virtual fileName getFileName
167 //- General entry point for writing.
168 // The data is organized in a set of point with one or
169 // more values per point
174 const List<const Field<Type>*>&,
178 //- Write scalar as ascii
179 virtual Ostream& write(const scalar, Ostream&) const;
181 template<class VSType>
182 Ostream& writeVS(const VSType& value, Ostream& os) const;
184 //- Write vector. Tab separated ascii
185 virtual Ostream& write(const vector&, Ostream&) const;
187 //- Write sphericalTensor. Tab separated ascii
188 virtual Ostream& write(const sphericalTensor&, Ostream&) const;
190 //- Write symmTensor. Tab separated ascii
191 virtual Ostream& write(const symmTensor&, Ostream&) const;
193 //- Write tensor. Tab separated ascii
194 virtual Ostream& write(const tensor&, Ostream&) const;
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 } // End namespace Foam
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 // Only used internally
209 #define makeTypeWritersTypeName(type) \
211 defineNamedTemplateTypeNameAndDebug(type, 0);
213 // Used externally sometimes
214 #define makeWritersTypeName(typeWriter) \
216 makeTypeWritersTypeName(typeWriter##ScalarWriter); \
217 makeTypeWritersTypeName(typeWriter##VectorWriter); \
218 makeTypeWritersTypeName(typeWriter##SphericalTensorWriter); \
219 makeTypeWritersTypeName(typeWriter##SymmTensorWriter); \
220 makeTypeWritersTypeName(typeWriter##TensorWriter);
222 // Define type info for single template instantiation (e.g. vector)
223 #define makeWriterTypes(WriterType, type) \
225 defineNamedTemplateTypeNameAndDebug(type, 0); \
227 addToRunTimeSelectionTable \
229 WriterType, type, word \
233 // Define type info info for scalar, vector etc. instantiations
234 #define makeWriters(typeWriter) \
236 makeWriterTypes(writerScalarWriter, typeWriter##ScalarWriter); \
237 makeWriterTypes(writerVectorWriter, typeWriter##VectorWriter); \
238 makeWriterTypes(writerSphericalTensorWriter, typeWriter##SphericalTensorWriter);\
239 makeWriterTypes(writerSymmTensorWriter, typeWriter##SymmTensorWriter); \
240 makeWriterTypes(writerTensorWriter, typeWriter##TensorWriter);
243 #define makeWritersTypedefs(typeWriter) \
245 typedef typeWriter<scalar> typeWriter##ScalarWriter; \
246 typedef typeWriter<vector> typeWriter##VectorWriter; \
247 typedef typeWriter<sphericalTensor> typeWriter##SphericalTensorWriter; \
248 typedef typeWriter<symmTensor> typeWriter##SymmTensorWriter; \
249 typedef typeWriter<tensor> typeWriter##TensorWriter;
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 // ************************************************************************* //