areaWrite.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) 2019-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::areaWrite
28
29Description
30 Write finite area mesh/fields to standard output formats.
31
32 Example of function object specification:
33
34 \verbatim
35 surfaces
36 {
37 type areaWrite;
38 libs (utilityFunctionObjects);
39
40 // Write at same frequency as fields
41 writeControl outputTime;
42 writeInterval 1;
43
44 // Fields to be sampled
45 fields (p U);
46
47 // Output surface format
48 surfaceFormat vtk;
49
50 formatOptions
51 {
52 vtk
53 {
54 precision 10;
55 }
56 }
57 }
58 \endverbatim
59
60 Entries:
61 \table
62 Property | Description | Required | Default
63 type | Type-name: \c areaWrite | yes |
64 region | name for a single region | no | region0
65 area | select a single area | no |
66 areas | wordRe list of multiple areas | no |
67 fields | wordRe list of fields | yes |
68 surfaceFormat | output surface format | yes |
69 formatOptions | dictionary of format options | no |
70 \endtable
71
72SourceFiles
73 areaWrite.C
74 areaWriteTemplates.C
75
76\*---------------------------------------------------------------------------*/
77
78#ifndef areaWrite_H
79#define areaWrite_H
80
82#include "polyMesh.H"
83#include "areaFieldsFwd.H"
84#include "surfaceWriter.H"
85#include "HashPtrTable.H"
86#include "IOobjectList.H"
87
88// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89
90namespace Foam
91{
92
93// Forward Declarations
94class faMesh;
95class polySurface;
96
97/*---------------------------------------------------------------------------*\
98 Class areaWrite Declaration
99\*---------------------------------------------------------------------------*/
100
101class areaWrite
102:
103 public functionObjects::fvMeshFunctionObject
104{
105 // Static Data Members
106
107 //- Tolerance for merging points (fraction of mesh bounding box)
108 static scalar mergeTol_;
109
110
111 // Private Data
112
113 //- Load fields from files (not from objectRegistry)
114 const bool loadFromFiles_;
115
116 //- Output verbosity
117 bool verbose_;
118
119 //- Output path
120 fileName outputPath_;
121
122
123 // Read from dictionary
124
125 //- Names of areas to select
126 wordRes selectAreas_;
127
128 //- Names of fields to write
129 wordRes fieldSelection_;
130
131 //- Pointers to the requested mesh regions
132 HashTable<const faMesh*> meshes_;
133
134 //- Hold intermediate surfaces.
135 // The faMesh has an indirect face list but we require real ones.
136 autoPtr<objectRegistry> surfaces_;
137
138
139 // Output control
141 //- Surface writers (one per surface)
143
144
145 // Private Member Functions
146
147 //- Write fieldName on surface and on outputDir path.
148 // Can have a field nullptr for partially missing fields,
149 // but the caller should generally filter out completely
150 // missing fields.
151 template<class Type>
152 void writeSurface
153 (
155 const Field<Type>* fieldPtr,
156 const word& fieldName
157 );
158
159 //- Write all applicable fields
160 template<class GeoField>
161 void performAction
162 (
164 const faMesh& areaMesh,
165 const IOobjectList& objects
166 );
167
168 //- Mark intermediate surfaces and writers as needing an update.
169 void expire();
170
171 //- No copy construct
172 areaWrite(const areaWrite&) = delete;
173
174 //- No copy assignment
175 void operator=(const areaWrite&) = delete;
176
177
178public:
179
180 //- Runtime type information
181 TypeName("areaWrite");
182
183
184 // Constructors
185
186 //- Construct from Time and dictionary
188 (
189 const word& name,
190 const Time& runTime,
191 const dictionary& dict
192 );
193
194 //- Construct for given objectRegistry and dictionary
195 // allow the possibility to load fields from files
197 (
198 const word& name,
199 const objectRegistry& obr,
200 const dictionary& dict,
201 const bool loadFromFiles = false
202 );
203
204
205 //- Destructor
206 virtual ~areaWrite() = default;
207
208
209 // Member Functions
210
211 //- Enable/disable verbose output
212 // \return old value
213 bool verbose(const bool on);
214
215 //- Read the areaWrite dictionary
216 virtual bool read(const dictionary& dict);
217
218 //- Execute, currently does nothing
219 virtual bool execute();
221 //- Sample and write
222 virtual bool write();
223
224 //- Update for changes of mesh - expires the surfaces
225 virtual void updateMesh(const mapPolyMesh& mpm);
226
227 //- Update for mesh point-motion - expires the surfaces
228 virtual void movePoints(const polyMesh& mesh);
229
230 //- Update for changes of mesh due to readUpdate - expires the surfaces
231 virtual void readUpdate(const polyMesh::readUpdateState state);
232
233 //- Get merge tolerance
234 static scalar mergeTol();
235
236 //- Set merge tolerance and return old value
237 static scalar mergeTol(const scalar tol);
238};
239
240
241// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242
243} // End namespace Foam
244
245// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246
247#ifdef NoRepository
248 #include "areaWriteTemplates.C"
249#endif
250
251// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252
253#endif
254
255// ************************************************************************* //
Forwards and collection of common area field types.
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Generic templated field type.
Definition: Field.H:82
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
Definition: HashPtrTable.H:68
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:56
Write finite area mesh/fields to standard output formats.
Definition: areaWrite.H:143
bool verbose(const bool on)
Enable/disable verbose output.
Definition: areaWrite.C:113
virtual void movePoints(const polyMesh &mesh)
Update for mesh point-motion - expires the surfaces.
Definition: areaWrite.C:369
virtual bool read(const dictionary &dict)
Read the areaWrite dictionary.
Definition: areaWrite.C:121
TypeName("areaWrite")
Runtime type information.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.
Definition: areaWrite.C:360
static scalar mergeTol()
Get merge tolerance.
Definition: areaWrite.C:387
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
Definition: areaWrite.C:378
virtual bool execute()
Execute, currently does nothing.
Definition: areaWrite.C:207
virtual bool write()
Sample and write.
Definition: areaWrite.C:213
virtual ~areaWrite()=default
Destructor.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
A class for handling file names.
Definition: fileName.H:76
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:91
Base class for surface writers.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73