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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::areaWrite
28 
29 Description
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 
72 SourceFiles
73  areaWrite.C
74  areaWriteTemplates.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef areaWrite_H
79 #define areaWrite_H
80 
81 #include "fvMeshFunctionObject.H"
82 #include "polyMesh.H"
83 #include "areaFieldsFwd.H"
84 #include "surfaceWriter.H"
85 #include "HashPtrTable.H"
86 #include "IOobjectList.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 // Forward Declarations
94 class faMesh;
95 class polySurface;
96 
97 /*---------------------------------------------------------------------------*\
98  Class areaWrite Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class 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
140 
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 
178 public:
179 
180  //- Runtime type information
181  TypeName("areaWrite");
182 
183 
184  // Constructors
185 
186  //- Construct from Time and dictionary
187  areaWrite
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
196  areaWrite
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();
220 
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 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
areaWriteTemplates.C
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:114
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::areaWrite::execute
virtual bool execute()
Execute, currently does nothing.
Definition: areaWrite.C:206
Foam::areaWrite::movePoints
virtual void movePoints(const polyMesh &mesh)
Update for mesh point-motion - expires the surfaces.
Definition: areaWrite.C:368
fvMeshFunctionObject.H
Foam::areaWrite::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.
Definition: areaWrite.C:359
IOobjectList.H
Foam::areaWrite::mergeTol
static scalar mergeTol()
Get merge tolerance.
Definition: areaWrite.C:386
surfaceWriter.H
Foam::areaWrite
Write finite area mesh/fields to standard output formats.
Definition: areaWrite.H:140
polyMesh.H
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::areaWrite::readUpdate
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
Definition: areaWrite.C:377
Foam::areaWrite::verbose
bool verbose(const bool on)
Enable/disable verbose output.
Definition: areaWrite.C:112
Foam::areaWrite::~areaWrite
virtual ~areaWrite()=default
Destructor.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::Field
Generic templated field type.
Definition: Field.H:63
areaFieldsFwd.H
Forwards and collection of common area field types.
Foam::areaMesh
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:53
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
Foam::areaWrite::TypeName
TypeName("areaWrite")
Runtime type information.
Foam::polyMesh::readUpdateState
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::HashPtrTable
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
Definition: HashPtrTable.H:54
Foam::areaWrite::write
virtual bool write()
Sample and write.
Definition: areaWrite.C:212
Foam::functionObjects::regionFunctionObject::obr
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Definition: regionFunctionObject.C:47
HashPtrTable.H
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::areaWrite::read
virtual bool read(const dictionary &dict)
Read the areaWrite dictionary.
Definition: areaWrite.C:120