writeAreaFields.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) 2018-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  Code chunk for reading finite-area fields from disk
15  and write with vtk::uindirectPatchGeoFieldsWriter
16 
17 \*---------------------------------------------------------------------------*/
18 
19 #ifndef FoamToVTK_writeAreaFields_H
20 #define FoamToVTK_writeAreaFields_H
21 
22 #include "readFields.H"
24 
25 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
26 
27 namespace Foam
28 {
29 
30 // Writer type for finite-area mesh + fields
32 
33 template<class GeoField>
34 label writeAreaFields
35 (
37  const typename GeoField::Mesh& mesh,
38  const IOobjectList& objects,
39  const bool syncPar
40 )
41 {
42  label count = 0;
43 
44  for (const word& fieldName : objects.sortedNames<GeoField>())
45  {
46  tmp<GeoField> tfield =
47  getField<GeoField>(mesh, objects, fieldName, syncPar);
48 
49  if (tfield)
50  {
51  writer.write(tfield());
52 
53  tfield.clear();
54  ++count;
55  }
56  }
57 
58  return count;
59 }
60 
61 
63 (
65  const faMesh& mesh,
66  const IOobjectList& objects,
67  const bool syncPar
68 )
69 {
70  #undef foamToVtk_WRITE_FIELD
71  #define foamToVtk_WRITE_FIELD(FieldType) \
72  writeAreaFields<FieldType> \
73  ( \
74  writer, \
75  mesh, \
76  objects, \
77  syncPar \
78  )
79 
80  label count = 0;
86 
87  #undef foamToVtk_WRITE_FIELD
88  return count;
89 }
90 
91 
92 } // End namespace Foam
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #endif
97 
98 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
GenericPatchGeoFieldsWriter< uindirectPrimitivePatch > uindirectPatchGeoFieldsWriter
Write uindirectPrimitivePatch faces/points as a vtp file or a legacy vtk file with support for geomet...
label writeAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
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"))
#define foamToVtk_WRITE_FIELD(FieldType)
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:250
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
void write(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData (Poly or Line) or PointData values.
label writeAllAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
A Foam::vtk::GenericPatchWriter with support for geometric fields.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition: tmpI.H:289
A class for managing temporary objects.
Definition: HashPtrTable.H:50
vtk::uindirectPatchGeoFieldsWriter vtkWriterType_areaMesh
Namespace for OpenFOAM.