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-2022 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 InNamespace
27  Foam
28 
29 Description
30  Read finite-area fields from disk
31  and write with vtk::uindirectPatchGeoFieldsWriter
32 
33 SourceFiles
34  writeAreaFields.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef writeAreaFields_H
39 #define writeAreaFields_H
40 
41 #include "readFields.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Writer type for finite-area mesh + fields
51 
52 template<class GeoField>
53 bool writeAreaField
54 (
56  const tmp<GeoField>& tfield
57 )
58 {
59  if (tfield)
60  {
61  writer.write(tfield());
62  tfield.clear();
63 
64  return true;
65  }
66 
67  return false;
68 }
69 
70 
71 template<class GeoField>
72 label writeAreaFields
73 (
75  const typename GeoField::Mesh& mesh,
76  const IOobjectList& objects,
77  const bool syncPar
78 )
79 {
80  label count = 0;
81 
82  for (const word& fieldName : objects.sortedNames<GeoField>())
83  {
84  if
85  (
86  writeAreaField<GeoField>
87  (
88  writer,
89  getField<GeoField>(mesh, objects, fieldName, syncPar)
90  )
91  )
92  {
93  ++count;
94  }
95  }
96 
97  return count;
98 }
99 
100 
101 label writeAllAreaFields
102 (
104  const faMesh& mesh,
105  const IOobjectList& objects,
106  const bool syncPar
107 )
108 {
109  #undef foamToVtk_WRITE_FIELD
110  #define foamToVtk_WRITE_FIELD(FieldType) \
111  writeAreaFields<FieldType> \
112  ( \
113  writer, \
114  mesh, \
115  objects, \
116  syncPar \
117  )
118 
119  label count = 0;
125 
126  #undef foamToVtk_WRITE_FIELD
127  return count;
128 }
129 
130 
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
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
#define foamToVtk_WRITE_FIELD(FieldType)
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:301
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
GeometricField< symmTensor, faPatchField, areaMesh > areaSymmTensorField
Definition: areaFieldsFwd.H:84
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
GeometricField< tensor, faPatchField, areaMesh > areaTensorField
Definition: areaFieldsFwd.H:85
GeometricField< sphericalTensor, faPatchField, areaMesh > areaSphericalTensorField
Definition: areaFieldsFwd.H:83
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
bool writeAreaField(ensightCase &ensCase, const ensightFaMesh &ensMesh, const tmp< AreaField< Type >> &tfield)
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition: tmpI.H:263
A class for managing temporary objects.
Definition: HashPtrTable.H:50
GeometricField< vector, faPatchField, areaMesh > areaVectorField
Definition: areaFieldsFwd.H:81
vtk::uindirectPatchGeoFieldsWriter vtkWriterType_areaMesh
Namespace for OpenFOAM.
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:80