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-------------------------------------------------------------------------------
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
26InNamespace
27 Foam
28
29Description
30 Read finite-area fields from disk
31 and write with vtk::uindirectPatchGeoFieldsWriter
32
33SourceFiles
34 writeAreaFields.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef writeAreaFields_H
39#define writeAreaFields_H
40
41#include "readFields.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Writer type for finite-area mesh + fields
51
52template<class GeoField>
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
71template<class GeoField>
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
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// ************************************************************************* //
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:383
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
A Foam::vtk::GenericPatchWriter with support for geometric fields.
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define foamToVtk_WRITE_FIELD(FieldType)
Namespace for OpenFOAM.
label writeAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
vtk::uindirectPatchGeoFieldsWriter vtkWriterType_areaMesh
bool writeAreaField(ensightCase &ensCase, const ensightFaMesh &ensMesh, const tmp< AreaField< Type > > &tfield)
label writeAllAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)