foamVtkGenericPatchGeoFieldsWriter.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) 2016-2021 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 PatchType>
31template<class Type>
34(
36 const labelUList& faceAddr
37) const
38{
39 if (this->patch().size() != faceAddr.size())
40 {
42 << "Inconsistent sizing: patch has "
43 << this->patch().size() << " faces, addressing has "
44 << faceAddr.size() << " faces!" << nl
46 }
47
48 const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
49
50 auto tfld = tmp<Field<Type>>::New(faceAddr.size());
51 auto iter = tfld.ref().begin();
52
53 for (const label facei : faceAddr)
54 {
55 const label patchi = patches.whichPatch(facei);
56
57 if (patchi == -1)
58 {
59 *iter = sfld[facei];
60 }
61 else
62 {
63 const label localFacei = facei - patches[patchi].start();
64 *iter = sfld.boundaryField()[patchi][localFacei];
65 }
66
67 ++iter;
68 }
69
70 return tfld;
71}
72
73
74// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75
76template<class PatchType>
77template<class Type>
79(
81 const labelUList& faceAddr
82)
83{
85 (
86 field.name(),
87 getFaceField(field, faceAddr)()
88 );
89}
90
91
92template<class PatchType>
93template<class Type>
95(
97)
98{
100 (
101 field.name(),
102 field.primitiveField()
103 );
104}
105
106
107// ************************************************************************* //
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
virtual bool write()
Write the output fields.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
A class for managing temporary objects.
Definition: tmp.H:65
A Foam::vtk::GenericPatchWriter with support for geometric fields.
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
rDeltaTY field()
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53