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 -------------------------------------------------------------------------------
10 License
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 
30 template<class PatchType>
31 template<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 
76 template<class PatchType>
77 template<class Type>
79 (
81  const labelUList& faceAddr
82 )
83 {
85  (
86  field.name(),
87  getFaceField(field, faceAddr)()
88  );
89 }
90 
91 
92 template<class PatchType>
93 template<class Type>
95 (
97 )
98 {
100  (
101  field.name(),
102  field.primitiveField()
103  );
104 }
105 
106 
107 // ************************************************************************* //
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::vtk::GenericPatchWriter
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
Definition: foamVtkGenericPatchWriter.H:65
Foam::vtk::GenericPatchGeoFieldsWriter
A Foam::vtk::GenericPatchWriter with support for geometric fields.
Definition: foamVtkGenericPatchGeoFieldsWriter.H:57
Foam::vtk::GenericPatchGeoFieldsWriter::write
void write(const GeometricField< Type, fvsPatchField, surfaceMesh > &field, const labelUList &faceAddr)
Definition: foamVtkGenericPatchGeoFieldsWriter.C:79
field
rDeltaTY field()
Foam::FatalError
error FatalError
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::UList< label >
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62