ensightCoordSetWriter.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2021-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::coordSetWriters::ensightCoordSetWriter
29
30Description
31 A coordSetWriter for Ensight format.
32
33 \verbatim
34 formatOptions
35 {
36 ensight
37 {
38 format ascii;
39 collateTimes true;
40 }
41 }
42 \endverbatim
43
44 Format options:
45 \table
46 Property | Description | Required | Default
47 format | ascii/binary | no | ascii
48 collateTimes | use common geometry for times | no | true
49 \endtable
50
51SourceFiles
52 ensightCoordSetWriter.C
53
54\*---------------------------------------------------------------------------*/
55
56#ifndef Foam_coordSetWriters_ensightWriter_H
57#define Foam_coordSetWriters_ensightWriter_H
58
59#include "coordSetWriter.H"
61
62// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63
64namespace Foam
65{
66
67// Forward Declarations
68class ensightGeoFile;
69
70namespace coordSetWriters
71{
72
73/*---------------------------------------------------------------------------*\
74 Class ensightWriter Declaration
75\*---------------------------------------------------------------------------*/
76
77class ensightWriter
78:
79 public coordSetWriter
80{
81 // Data Types
82
83 //- Types of element output
84 enum elemOutputType
85 {
86 NO_ELEMENTS = 0,
87 WRITE_POINTS = 1,
88 WRITE_LINES = 2
89 };
90
92 // Private Data
93
94 //- Output format option (default: IOstream::ASCII)
96
97 //- Collate times (default: true)
98 bool collateTimes_;
99
100 //- Cached information for times, geometry, fields (collated)
102
103
104 // Private Member Functions
105
106 //- Write geometry
107 void writeGeometry
108 (
110 elemOutputType elemOutput
111 ) const;
112
113 //- Write geometry
114 fileName writeCollated(const bool writeTracks);
115
116 //- Write geometry
117 fileName writeUncollated(const bool writeTracks);
118
119 //- Templated write operation - one file per timestep
120 template<class Type>
121 fileName writeCollated
122 (
123 const word& fieldName,
124 const UPtrList<const Field<Type>>& fieldPtrs,
125 elemOutputType elemOutput
126 );
127
128 //- Templated write operation - all time steps in single file
129 template<class Type>
130 fileName writeUncollated
131 (
132 const word& fieldName,
133 const UPtrList<const Field<Type>>& fieldPtrs,
134 elemOutputType elemOutput
135 );
136
137 //- Templated write operation
138 template<class Type>
139 fileName writeTemplate
140 (
141 const word& fieldName,
142 const Field<Type>& values
143 );
144
145 //- Templated write operation
146 template<class Type>
147 fileName writeTemplate
148 (
149 const word& fieldName,
150 const List<Field<Type>>& fieldValues
151 );
152
153
154public:
155
156 //- Runtime type information (no debug)
157 TypeNameNoDebug("ensight");
158
159
160 // Constructors
161
162 //- Default construct
164
165 //- Default construct with specified options
166 explicit ensightWriter(const dictionary& options);
167
168 //- Construct from components
170 (
171 const coordSet& coords,
172 const fileName& outputPath,
173 const dictionary& options = dictionary()
174 );
175
176 //- Construct from components
178 (
179 const UPtrList<coordSet>& tracks,
180 const fileName& outputPath,
181 const dictionary& options = dictionary()
182 );
183
184
185 //- Destructor. Calls close()
186 virtual ~ensightWriter();
187
188
189 // Member Functions
190
191 //- Finish output, clears output times.
192 // Later reuse will rebuild times from fieldsDict file cache.
193 virtual void close(bool force = false); // override
194
195
196 // Write
197
198 //- Expected (characteristic) output file name - information only
199 // \warning incorrect for uncollated output!
200 virtual fileName path() const; // override
201
208};
209
210
211// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213} // End namespace coordSetWriters
214} // End namespace Foam
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218#endif
220// ************************************************************************* //
writer writeGeometry()
Generic templated field type.
Definition: Field.H:82
streamFormat
Data format (ascii | binary)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
Base class for writing coordSet(s) and tracks with fields.
virtual ~ensightWriter()
Destructor. Calls close()
declareCoordSetWriterWriteMethod(sphericalTensor)
virtual fileName path() const
Expected (characteristic) output file name - information only.
virtual void close(bool force=false)
Finish output, clears output times.
TypeNameNoDebug("ensight")
Runtime type information (no debug)
Holds list of sampling positions.
Definition: coordSet.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Specialized Ensight output with extra geometry file header.
State information for writers with collated times.
A class for handling file names.
Definition: fileName.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define declareCoordSetWriterWriteMethod(Type)
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition: typeInfo.H:68