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 -------------------------------------------------------------------------------
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::coordSetWriters::ensightCoordSetWriter
29 
30 Description
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 
51 SourceFiles
52  ensightCoordSetWriter.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef Foam_coordSetWriters_ensightWriter_H
57 #define Foam_coordSetWriters_ensightWriter_H
58 
59 #include "coordSetWriter.H"
60 #include "ensightWriterCaching.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward Declarations
68 class ensightGeoFile;
69 
70 namespace coordSetWriters
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class ensightWriter Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class 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 
91 
92  // Private Data
93 
94  //- Output format option (default: ASCII)
95  IOstreamOption::streamFormat writeFormat_;
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 
154 public:
155 
156  //- Runtime type information (no debug)
157  TypeNameNoDebug("ensight");
158 
159 
160  // Constructors
161 
162  //- Default construct
163  ensightWriter();
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:71
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
State information for writers with collated times.
Specialized Ensight output with extra geometry file header.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:164
Holds list of sampling positions.
Definition: coordSet.H:49
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:100
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
TypeNameNoDebug("ensight")
Runtime type information (no debug)
virtual void close(bool force=false)
Finish output, clears output times.
streamFormat
Data format (ascii | binary)
virtual fileName path() const
Expected (characteristic) output file name - information only.
Tensor of scalars, i.e. Tensor<scalar>.
virtual ~ensightWriter()
Destructor. Calls close()
Namespace for OpenFOAM.