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 // ************************************************************************* //
Write concrete PrimitivePatch faces/points (optionally with fields) as a vtp file or a legacy vtk fil...
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
rDeltaTY field()
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
A Foam::vtk::GenericPatchWriter with support for geometric fields.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const Mesh & mesh() const noexcept
Return mesh.
void write(const GeometricField< Type, fvsPatchField, surfaceMesh > &field, const labelUList &faceAddr)
Write volume-mesh surface field (CellData) from specified mesh faces.
const polyBoundaryMesh & patches
const std::string patch
OpenFOAM patch number as a std::string.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.