Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Code chunk for reading dimensioned fields from disk
15 and write with vtk::internalWriter
16
17\*---------------------------------------------------------------------------*/
18
19#ifndef FoamToVTK_writeDimFields_H
20#define FoamToVTK_writeDimFields_H
21
22#include "readFields.H"
24
25// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
26
27namespace Foam
28{
29
30template<class GeoField>
32(
34 const fvMeshSubsetProxy& proxy,
35 const IOobjectList& objects,
36 const bool syncPar,
37 objectRegistry* cache
38)
39{
40 // Sanity test
41 if (!internalWriter) return 0;
42
43 label count = 0;
44
45 for (const word& fieldName : objects.sortedNames<GeoField>())
46 {
47 tmp<GeoField> tfield =
48 getField<GeoField>(proxy, objects, fieldName, syncPar, cache);
49
50 if (tfield)
51 {
52 internalWriter->write(tfield());
53
54 tfield.clear();
55 ++count;
56 }
57 }
58
59 return count;
60}
61
62
63template<class GeoField>
65(
68
69 const fvMeshSubsetProxy& proxy,
70 const IOobjectList& objects,
71 const bool syncPar,
72 objectRegistry* cache
73)
74{
75 // Sanity test
76 if (!internalWriter || !pInterp) return 0;
77
78 label count = 0;
79
80 for (const word& fieldName : objects.sortedNames<GeoField>())
81 {
82 tmp<GeoField> tfield =
83 getField<GeoField>(proxy, objects, fieldName, syncPar, cache);
84
85 if (tfield)
86 {
87 internalWriter->write(tfield(), *pInterp);
88
89 tfield.clear();
90 ++count;
91 }
92 }
93
94 return count;
95}
96
97
99(
101
102 const fvMeshSubsetProxy& proxy,
103 const IOobjectList& objects,
104 const bool syncPar,
105 objectRegistry* cache
106)
107{
108 // Sanity test
109 if (!internalWriter) return 0;
110
111 label count = 0;
112 const label total = objects.size();
113 do
114 {
115 #undef doLocalWriteCode
116 #define doLocalWriteCode(Type) \
117 { \
118 typedef VolumeInternalField<Type> FieldType; \
119 \
120 count += writeDimFields<FieldType> \
121 ( \
122 internalWriter, \
123 proxy, \
124 objects, \
125 syncPar, \
126 cache \
127 ); \
128 if (count >= total) break; /* early exit */ \
129 }
130
131 doLocalWriteCode(scalar);
136
137 #undef doLocalWriteField
138 }
139 while (false);
140
141 return count;
142}
143
144
146(
149
150 const fvMeshSubsetProxy& proxy,
151 const IOobjectList& objects,
152 const bool syncPar,
153 objectRegistry* cache
154)
155{
156 // Sanity test
157 if (!internalWriter || !pInterp) return 0;
158
159 label count = 0;
160 const label total = objects.size();
161 do
162 {
163 #undef doLocalWriteCode
164 #define doLocalWriteCode(Type) \
165 { \
166 typedef VolumeInternalField<Type> FieldType; \
167 \
168 count += writeDimFields<FieldType> \
169 ( \
170 internalWriter, pInterp, \
171 proxy, \
172 objects, \
173 syncPar, \
174 cache \
175 ); \
176 if (count >= total) break; /* early exit */ \
177 }
178
179 doLocalWriteCode(scalar);
184
185 #undef doLocalWriteCode
186 }
187 while (false);
188
189 return count;
190}
191
192
193} // End namespace Foam
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197#endif
198
199// ************************************************************************* //
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
label size() const noexcept
The number of elements in table.
Definition HashTable.H:358
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
wordList sortedNames() const
The sorted names of the IOobjects.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
Registry of regIOobjects.
A class for managing temporary objects.
Definition tmp.H:75
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 handling words, derived from Foam::string.
Definition word.H:66
autoPtr< vtk::internalWriter > internalWriter
#define doLocalWriteCode(Type)
autoPtr< volPointInterpolation > pInterp
Namespace for OpenFOAM.
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Tensor< scalar > tensor
Definition symmTensor.H:57
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Vector< scalar > vector
Definition vector.H:57
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
tmp< GeoField > getField(const IOobject &io, const typename GeoField::Mesh &mesh)
Get the field or FatalError.
Definition readFields.H:51
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55