Loading...
Searching...
No Matches
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-2023 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
32Usage
33 Minimal example by using \c system/controlDict.functions:
34 \verbatim
35 areaWriteFO
36 {
37 // Mandatory entries
38 type areaWrite;
39 libs (utilityFunctionObjects);
40 fields (<wordRes>); // (p U);
41 surfaceFormat <word>; // vtk;
42
43 // Output surface format
44 formatOptions
45 {
46 vtk
47 {
48 precision 10;
49 }
50 }
51
52 // Optional entries
53 verbose <word>;
54
55 // Conditional entries
56
57 // Option-1
58 areas (<wordRes>);
59
60 // Option-2
61 area <word>;
62
63 // Inherited entries
64 ...
65 }
66 \endverbatim
67
68 where the entries mean:
69 \table
70 Property | Description | Type | Reqd | Deflt
71 type | Type name: areaWrite | word | yes | -
72 libs | Library name: utilityFunctionObjects | word | yes | -
73 fields | Name of operand fields | wordRes | yes | -
74 surfaceFormat | Output surface format | word | yes | -
75 areas | Names of finite-area regions | wordRes | no | -
76 area | Name of finite-area region | word | no | -
77 formatOptions | Dictionary of format options | dict | no | -
78 \endtable
79
80 The inherited entries are elaborated in:
81 - \link functionObject.H \endlink
82 - \link surfaceWriter.H \endlink
83
84SourceFiles
85 areaWrite.cxx
86 areaWriteImpl.cxx
87
88\*---------------------------------------------------------------------------*/
89
90#ifndef Foam_areaWrite_H
91#define Foam_areaWrite_H
92
94#include "polyMesh.H"
95#include "areaFieldsFwd.H"
96#include "surfaceWriter.H"
97#include "HashPtrTable.H"
98
99// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100
101namespace Foam
102{
103
104// Forward Declarations
105class faMesh;
106class polySurface;
107class IOobjectList;
108
109/*---------------------------------------------------------------------------*\
110 Class areaWrite Declaration
111\*---------------------------------------------------------------------------*/
112
113class areaWrite
114:
116{
117 // Static Data Members
118
119 //- Tolerance for merging points (fraction of mesh bounding box)
120 static scalar mergeTol_;
121
122
123 // Private Data
124
125 //- Load fields from files (not from objectRegistry)
126 const bool loadFromFiles_;
127
128 //- Output verbosity
129 bool verbose_;
130
131 //- Output path
132 fileName outputPath_;
133
134
135 // Read from dictionary
136
137 //- Names of areas to select
138 wordRes selectAreas_;
139
140 //- Names of fields to write
141 wordRes fieldSelection_;
142
143 //- Pointers to the requested mesh regions (sorted)
144 UPtrList<const faMesh> meshes_;
145
146 //- Hold intermediate surfaces.
147 // The faMesh has an indirect face list but we require real ones.
148 std::unique_ptr<objectRegistry> surfaces_;
149
150
151 // Output control
152
153 //- Surface writers (one per surface)
154 HashPtrTable<surfaceWriter> writers_;
155
157 // Private Member Functions
158
159 //- Mark intermediate surfaces and writers as needing an update.
160 void expire();
161
162 //- Write fieldName on surface and on outputDir path.
163 // Can have a field nullptr for partially missing fields,
164 // but the caller should generally filter out completely
165 // missing fields.
166 template<class Type>
167 void writeSurface
168 (
170 const Field<Type>* fieldPtr,
171 const word& fieldName
172 );
173
174 //- Write all applicable fields
175 template<class GeoField>
176 void performAction
177 (
179 const faMesh& areaMesh,
180 const IOobjectList& objects
181 );
182
183public:
184
185 //- Runtime type information
186 TypeName("areaWrite");
187
188
189 // Generated Methods
190
191 //- No copy construct
192 areaWrite(const areaWrite&) = delete;
193
194 //- No copy assignment
195 void operator=(const areaWrite&) = delete;
196
197
198 // Constructors
199
200 //- Construct from name, Time and dictionary
202 (
203 const word& name,
204 const Time& runTime,
205 const dictionary& dict
206 );
207
208 //- Construct for given objectRegistry and dictionary.
209 //- Allow the possibility to load fields from files
211 (
212 const word& name,
213 const objectRegistry& obr,
214 const dictionary& dict,
215 const bool loadFromFiles = false
216 );
217
218
219 //- Destructor
220 virtual ~areaWrite();
221
222
223 // Member Functions
224
225 //- Enable/disable verbose output
226 // \return old value
227 bool verbose(bool on) noexcept;
228
229 //- Read the function-object dictionary
230 virtual bool read(const dictionary& dict);
231
232 //- Execute the function-object operations (no-op)
233 virtual bool execute();
234
235 //- Write the function-object results
236 virtual bool write();
237
238 //- Update for changes of mesh - expires the surfaces
239 virtual void updateMesh(const mapPolyMesh& mpm);
240
241 //- Update for mesh point-motion - expires the surfaces
242 virtual void movePoints(const polyMesh& mesh);
243
244 //- Update for changes of mesh due to readUpdate - expires the surfaces
245 virtual void readUpdate(const polyMesh::readUpdateState state);
246
247 //- Get merge tolerance
248 static scalar mergeTol() noexcept;
249
250 //- Set merge tolerance and return old value
251 static scalar mergeTol(scalar tol) noexcept;
252};
253
254
255// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256
257} // End namespace Foam
258
259// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260
261#endif
262
263// ************************************************************************* //
Forwards and collection of common area field types.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition UPtrList.H:101
Mesh data needed to do the Finite Area discretisation.
Definition areaFaMesh.H:50
Write finite area mesh/fields to standard output formats.
Definition areaWrite.H:159
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
virtual bool execute()
Execute the function-object operations (no-op).
areaWrite(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual bool write()
Write the function-object results.
static scalar mergeTol() noexcept
Get merge tolerance.
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
areaWrite(const areaWrite &)=delete
No copy construct.
TypeName("areaWrite")
Runtime type information.
void operator=(const areaWrite &)=delete
No copy assignment.
virtual void movePoints(const polyMesh &mesh)
Update for mesh point-motion - expires the surfaces.
bool verbose(bool on) noexcept
Enable/disable verbose output.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.
areaWrite(const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false)
Construct for given objectRegistry and dictionary. Allow the possibility to load fields from files.
virtual ~areaWrite()
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
A class for handling file names.
Definition fileName.H:75
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.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition polyMesh.H:92
A surface mesh consisting of general polygon faces and capable of holding fields.
Definition polySurface.H:67
Base class for surface writers.
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68