writeDimFields.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 dimensioned fields from disk
31 and write with vtk::internalWriter
32
33SourceFiles
34 writeDimFields.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef writeDimFields_H
39#define writeDimFields_H
40
41#include "readFields.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49template<class GeoField>
51(
53 const tmp<GeoField>& tfield
54)
55{
56 if (!tfield)
57 {
58 return false;
59 }
60
61 const auto& field = tfield();
62
64 {
65 internalWriter->write(field);
66 }
67
68 tfield.clear();
69 return true;
70}
71
72
73template<class GeoField>
75(
78 const tmp<GeoField>& tfield
79)
80{
81 if (!tfield)
82 {
83 return false;
84 }
85
86 const auto& field = tfield();
87
89 {
91 }
92
93 tfield.clear();
94 return true;
95}
96
97
98template<class GeoField>
100(
102 const fvMeshSubsetProxy& proxy,
103 const IOobjectList& objects,
104 const bool syncPar
105)
106{
107 label count = 0;
108
109 for (const word& fieldName : objects.sortedNames<GeoField>())
110 {
111 if
112 (
113 writeDimField<GeoField>
114 (
116 getField<GeoField>(proxy, objects, fieldName, syncPar)
117 )
118 )
119 {
120 ++count;
121 }
122 }
123
124 return count;
125}
126
127
128template<class GeoField>
130(
133
134 const fvMeshSubsetProxy& proxy,
135 const IOobjectList& objects,
136 const bool syncPar
137)
138{
139 label count = 0;
140
141 for (const word& fieldName : objects.sortedNames<GeoField>())
142 {
143 if
144 (
145 writeDimField<GeoField>
146 (
148 getField<GeoField>(proxy, objects, fieldName, syncPar)
149 )
150 )
151 {
152 ++count;
153 }
154 }
155
156 return count;
157}
158
159
161(
163
164 const fvMeshSubsetProxy& proxy,
165 const IOobjectList& objects,
166 const bool syncPar
167)
168{
169 #undef foamToVtk_WRITE_FIELD
170 #define foamToVtk_WRITE_FIELD(FieldType) \
171 writeDimFields<FieldType> \
172 ( \
173 internalWriter, \
174 proxy, \
175 objects, \
176 syncPar \
177 )
178
179 label count = 0;
185
186 #undef foamToVTK_WRITE_FIELD
187 return count;
188}
189
190
192(
195
196 const fvMeshSubsetProxy& proxy,
197 const IOobjectList& objects,
198 const bool syncPar
199)
200{
201 #undef foamToVtk_WRITE_FIELD
202 #define foamToVtk_WRITE_FIELD(FieldType) \
203 writeDimFields<FieldType> \
204 ( \
205 internalWriter, pInterp, \
206 proxy, \
207 objects, \
208 syncPar \
209 )
210
211 label count = 0;
217
218 #undef foamToVTK_WRITE_FIELD
219 return count;
220}
221
222
223} // End namespace Foam
224
225// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226
227#endif
228
229// ************************************************************************* //
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaTY field()
autoPtr< vtk::internalWriter > internalWriter
autoPtr< volPointInterpolation > pInterp
#define foamToVtk_WRITE_FIELD(FieldType)
Namespace for OpenFOAM.
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
bool writeDimField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< VolumeInternalField< Type > > &tdf)