writePointFields.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 point fields from disk
31 and write with vtk::internalWriter and vtk::patchWriter
32
33SourceFiles
34 writePointFields.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef writePointFields_H
39#define writePointFields_H
40
41#include "readFields.H"
43#include "foamVtkPatchWriter.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50template<class GeoField>
52(
55
56 const tmp<GeoField>& tfield,
57 const fvMeshSubsetProxy& proxy
58)
59{
60 if (!tfield)
61 {
62 return false;
63 }
64
65 tmp<GeoField> tproxied;
66 if (proxy.useSubMesh())
67 {
68 tproxied = proxy.interpolate(tfield());
69 tfield.clear();
70 }
71 else
72 {
73 tproxied = tfield;
74 }
75
76 if (!tproxied)
77 {
78 // Or Error?
79 return false;
80 }
81
82
83 const auto& field = tproxied();
84
85 // Internal
87 {
88 internalWriter->write(field);
89 }
90
91 // Boundary
93 {
94 writer.write(field);
95 }
96
97
98 tproxied.clear();
99
100 return true;
101}
102
103
104template<class GeoField>
106(
109
110 const fvMeshSubsetProxy& proxy,
111 const typename GeoField::Mesh& ptMesh,
112 const IOobjectList& objects,
113 const bool syncPar
114)
115{
116 label count = 0;
117
118 for (const word& fieldName : objects.sortedNames<GeoField>())
119 {
120 if
121 (
122 writePointField<GeoField>
123 (
126 getField<GeoField>(ptMesh, objects, fieldName, syncPar),
127 proxy
128 )
129 )
130 {
131 ++count;
132 }
133 }
134
135 return count;
136}
137
138
140(
143
144 const fvMeshSubsetProxy& proxy,
145 const IOobjectList& objects,
146 const bool syncPar
147)
148{
149 const pointMesh& ptMesh = pointMesh::New(proxy.baseMesh());
150
151 #undef foamToVtk_WRITE_FIELD
152 #define foamToVtk_WRITE_FIELD(FieldType) \
153 writePointFields<FieldType> \
154 ( \
155 internalWriter, \
156 patchWriters, \
157 proxy, ptMesh, \
158 objects, \
159 syncPar \
160 )
161
162 label count = 0;
168
169 #undef foamToVTK_WRITE_FIELD
170 return count;
171}
172
173
174} // End namespace Foam
175
176// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178#endif
179
180// ************************************************************************* //
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
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
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
Simple proxy for holding a mesh, or mesh-subset. The subMeshes are currently limited to cellSet or ce...
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const GeoField &fld)
Wrapper for field or the subsetted field.
const fvMesh & baseMesh() const noexcept
The entire base mesh.
bool useSubMesh() const noexcept
True if sub-mesh should be used.
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:55
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
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
#define foamToVtk_WRITE_FIELD(FieldType)
Namespace for OpenFOAM.
label writeAllPointFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
bool writePointField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< PointField< Type > > &tfield)
label writePointFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)