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 -------------------------------------------------------------------------------
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 writeTime;
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 Foam_areaWrite_H
79 #define Foam_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 (sorted)
132  UPtrList<const faMesh> meshes_;
133 
134  //- Hold intermediate surfaces.
135  // The faMesh has an indirect face list but we require real ones.
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) noexcept;
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() noexcept;
235 
236  //- Set merge tolerance and return old value
237  static scalar mergeTol(const scalar tol) noexcept;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
dictionary dict
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
Definition: areaWrite.C:421
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
engineTime & runTime
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
Definition: HashPtrTable.H:51
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
const word & name() const noexcept
Return the name of this functionObject.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.
Definition: areaWrite.C:403
static scalar mergeTol() noexcept
Get merge tolerance.
Definition: areaWrite.C:430
dynamicFvMesh & mesh
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool write()
Sample and write.
Definition: areaWrite.C:220
virtual ~areaWrite()=default
Destructor.
const direction noexcept
Definition: Scalar.H:258
bool verbose(const bool on) noexcept
Enable/disable verbose output.
Definition: areaWrite.C:110
virtual bool read(const dictionary &dict)
Read the areaWrite dictionary.
Definition: areaWrite.C:118
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:47
virtual void movePoints(const polyMesh &mesh)
Update for mesh point-motion - expires the surfaces.
Definition: areaWrite.C:412
Base class for surface writers.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Registry of regIOobjects.
TypeName("areaWrite")
Runtime type information.
Write finite area mesh/fields to standard output formats.
Definition: areaWrite.H:136
virtual bool execute()
Execute, currently does nothing.
Definition: areaWrite.C:214
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Forwards and collection of common area field types.
Namespace for OpenFOAM.