ensightSurfaceWriter.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 OpenFOAM Foundation
9  Copyright (C) 2015-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::surfaceWriters::ensightWriter
29 
30 Description
31  A surfaceWriter 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 for ensight:
45  \table
46  Property | Description | Required | Default
47  format | ascii/binary | no | binary
48  collateTimes | Use common geometry for times | no | true
49  scale | Output geometry scaling | no | 1
50  transform | Output coordinate transform | no |
51  fieldLevel | Subtract field level before scaling | no | empty dict
52  fieldScale | Output field scaling | no | empty dict
53  timeFormat | Time format (ensight case) | no | scientific
54  timePrecision | Time precision (ensight case) | no | 5
55  \endtable
56 
57  The collated format maintains an internal list of the known times
58  as well as a file-cached version with the field information.
59  The information is used for restarts.
60 
61 SourceFiles
62  ensightSurfaceWriter.C
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #ifndef Foam_surfaceWriters_ensightWriter_H
67 #define Foam_surfaceWriters_ensightWriter_H
68 
69 #include "surfaceWriter.H"
70 #include "ensightCase.H"
71 #include "ensightWriterCaching.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace surfaceWriters
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class ensightWriter Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class ensightWriter
85 :
86  public surfaceWriter
87 {
88  // Private Data
89 
90  //- Ensight case options
91  ensightCase::options caseOpts_;
92 
93  //- Collate times (default: true)
94  bool collateTimes_;
95 
96  //- Cached information for times, geometry, fields (collated)
98 
99 
100  // Private Member Functions
101 
102  //- Write geometry
103  fileName writeCollated();
104 
105  //- Write geometry
106  fileName writeUncollated();
107 
108  //- Templated write operation - one file per timestep
109  template<class Type>
110  fileName writeCollated
111  (
112  const word& fieldName,
113  const Field<Type>& localValues
114  );
115 
116  //- Templated write operation - all time steps in single file
117  template<class Type>
118  fileName writeUncollated
119  (
120  const word& fieldName,
121  const Field<Type>& localValues
122  );
123 
124  //- Templated write operation
125  template<class Type>
126  fileName writeTemplate
127  (
128  const word& fieldName,
129  const Field<Type>& localValues
130  );
131 
132 public:
133 
134  //- Declare type-name, virtual type (without debug switch)
135  TypeNameNoDebug("ensight");
136 
137 
138  // Constructors
139 
140  //- Default construct
141  ensightWriter();
142 
143  //- Construct with some output options
144  explicit ensightWriter(const dictionary& options);
145 
146  //- Construct from components
148  (
149  const meshedSurf& surf,
150  const fileName& outputPath,
151  bool parallel = UPstream::parRun(),
152  const dictionary& options = dictionary()
153  );
154 
155  //- Construct from components
157  (
158  const pointField& points,
159  const faceList& faces,
160  const fileName& outputPath,
161  bool parallel = UPstream::parRun(),
162  const dictionary& options = dictionary()
163  );
164 
165 
166  //- Destructor
167  virtual ~ensightWriter() = default;
168 
169 
170  // Member Functions
171 
172  //- Finish output, clears output times.
173  // Later reuse will rebuild times from fieldsDict file cache.
174  virtual void close(); // override
175 
176  //- True if the surface format supports geometry in a separate file.
177  // False if geometry and field must be in a single file
178  virtual bool separateGeometry() const;
179 
180  //- Write surface geometry to file.
181  virtual fileName write(); // override
182 
189 };
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 } // End namespace surfaceWriters
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1061
Foam::ensightOutput::writerCaching writerCaching
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:43
virtual bool separateGeometry() const
True if the surface format supports geometry in a separate file.
TypeNameNoDebug("ensight")
Declare type-name, virtual type (without debug switch)
virtual fileName write()
Write surface geometry to file.
const pointField & points
Generic templated field type.
Definition: Field.H:62
virtual void close()
Finish output, clears output times.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual ~ensightWriter()=default
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.