OpenFOAM
v2512
The open source CFD toolbox
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
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13
Description
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
"
23
#include "
foamVtkInternalWriter.H
"
24
25
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
26
27
namespace
Foam
28
{
29
30
template
<
class
GeoField>
31
label
writeDimFields
32
(
33
autoPtr<vtk::internalWriter>
&
internalWriter
,
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
63
template
<
class
GeoField>
64
label
writeDimFields
65
(
66
autoPtr<vtk::internalWriter>
&
internalWriter
,
67
const
autoPtr<volPointInterpolation>
&
pInterp
,
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
98
label
writeAllDimFields
99
(
100
autoPtr<vtk::internalWriter>
&
internalWriter
,
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);
132
doLocalWriteCode
(
vector
);
133
doLocalWriteCode
(
sphericalTensor
);
134
doLocalWriteCode
(
symmTensor
);
135
doLocalWriteCode
(
tensor
);
136
137
#undef doLocalWriteField
138
}
139
while
(
false
);
140
141
return
count;
142
}
143
144
145
label
writeAllDimFields
146
(
147
autoPtr<vtk::internalWriter>
&
internalWriter
,
148
const
autoPtr<volPointInterpolation>
&
pInterp
,
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);
180
doLocalWriteCode
(
vector
);
181
doLocalWriteCode
(
sphericalTensor
);
182
doLocalWriteCode
(
symmTensor
);
183
doLocalWriteCode
(
tensor
);
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
// ************************************************************************* //
readFields.H
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
Foam::HashTable::size
label size() const noexcept
The number of elements in table.
Definition
HashTable.H:358
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
Definition
IOobjectList.H:58
Foam::IOobjectList::sortedNames
wordList sortedNames() const
The sorted names of the IOobjects.
Definition
IOobjectList.C:253
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition
autoPtr.H:65
Foam::fvMeshSubsetProxy
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
Definition
fvMeshSubsetProxy.H:52
Foam::objectRegistry
Registry of regIOobjects.
Definition
objectRegistry.H:57
Foam::tmp
A class for managing temporary objects.
Definition
tmp.H:75
Foam::tmp::clear
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition
tmpI.H:289
Foam::word
A class for handling words, derived from Foam::string.
Definition
word.H:66
internalWriter
autoPtr< vtk::internalWriter > internalWriter
Definition
convertProcessorPatches.H:46
doLocalWriteCode
#define doLocalWriteCode(Type)
pInterp
autoPtr< volPointInterpolation > pInterp
Definition
convertVolumeFields.H:76
foamVtkInternalWriter.H
Foam
Namespace for OpenFOAM.
Definition
atmBoundaryLayer.C:27
Foam::writeAllDimFields
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition
writeDimFields.H:96
Foam::tensor
Tensor< scalar > tensor
Definition
symmTensor.H:57
Foam::writeDimFields
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition
writeDimFields.H:62
Foam::vector
Vector< scalar > vector
Definition
vector.H:57
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Definition
sphericalTensor.H:50
Foam::getField
tmp< GeoField > getField(const IOobject &io, const typename GeoField::Mesh &mesh)
Get the field or FatalError.
Definition
readFields.H:51
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition
symmTensor.H:55
applications
utilities
postProcessing
dataConversion
foamToVTK
writeDimFields.H
Generated by
1.16.1