vtkWriteTemplates.C
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-2020 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
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29
30template<class GeoField>
31Foam::label Foam::functionObjects::vtkWrite::writeVolFields
32(
35 const fvMeshSubset& proxy,
36 const wordHashSet& acceptField
37) const
38{
39 const fvMesh& baseMesh = proxy.baseMesh();
40
41 label count = 0;
42
43 for (const word& fieldName : baseMesh.sortedNames<GeoField>(acceptField))
44 {
45 bool ok = false;
46 const auto* fieldptr = baseMesh.findObject<GeoField>(fieldName);
47
48 if (!fieldptr)
49 {
50 continue;
51 }
52
53 auto tfield = fvMeshSubsetProxy::interpolate(proxy, *fieldptr);
54 const auto& field = tfield();
55
56 // Internal
58 {
59 ok = true;
60 internalWriter->write(field);
61 }
62
63 // Boundary
64 label writeri = 0;
66 {
67 ok = true;
68 writer.write(field);
69 ++writeri;
70 }
71
72 if (ok)
73 {
74 ++count;
75
76 if (verbose_)
77 {
78 if (count == 1)
79 {
80 Log << " " << GeoField::typeName << '(';
81 }
82 else
83 {
84 Log << ' ';
85 }
86 Log << fieldName;
87 }
88 }
89 }
90
91 if (verbose_ && count)
92 {
93 Log << ')' << endl;
94 }
95
96 return count;
97}
98
99
100template<class GeoField>
101Foam::label Foam::functionObjects::vtkWrite::writeVolFields
102(
107 const fvMeshSubset& proxy,
108 const wordHashSet& acceptField
109) const
110{
111 const fvMesh& baseMesh = proxy.baseMesh();
112
113 label count = 0;
114
115 for (const word& fieldName : baseMesh.sortedNames<GeoField>(acceptField))
116 {
117 bool ok = false;
118 const auto* fieldptr = baseMesh.findObject<GeoField>(fieldName);
119
120 if (!fieldptr)
121 {
122 continue;
123 }
124
125 auto tfield = fvMeshSubsetProxy::interpolate(proxy, *fieldptr);
126 const auto& field = tfield();
127
128 // Internal
129 if (internalWriter && pInterp)
130 {
131 ok = true;
132 internalWriter->write(field, *pInterp);
133 }
134
135 // Boundary
136 label writeri = 0;
138 {
139 if (writeri < patchInterps.size() && patchInterps.set(writeri))
140 {
141 ok = true;
142 writer.write(field, patchInterps[writeri]);
143 }
144 ++writeri;
145 }
146
147 if (ok)
148 {
149 ++count;
150
151 if (verbose_)
152 {
153 if (count == 1)
154 {
155 Log << " " << GeoField::typeName << "->point(";
156 }
157 else
158 {
159 Log << ' ';
160 }
161 Log << fieldName;
162 }
163 }
164 }
165
166 if (verbose_ && count)
167 {
168 Log << ')' << endl;
169 }
170
171 return count;
172}
173
174
175// ************************************************************************* //
#define Log
Definition: PDRblock.C:35
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:80
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:30
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
wordList sortedNames() const
The sorted names of all objects.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
bool interpolate() const noexcept
Same as isPointData()
Write OpenFOAM patches and patch fields in VTP or legacy vtk format.
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaTY field()
autoPtr< vtk::internalWriter > internalWriter
PtrList< vtk::patchWriter > patchWriters
PtrList< PrimitivePatchInterpolation< primitivePatch > > patchInterps
autoPtr< volPointInterpolation > pInterp
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372