foamVtkSurfaceMeshWriterTemplates.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 Foam::vtk::surfaceMeshWriter::getFaceField
34 (
36 ) const
37 {
38  const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh();
39 
40  const labelList& faceAddr = this->patch().addressing();
41 
42  auto tfld = tmp<Field<Type>>::New(faceAddr.size());
43  auto iter = tfld.ref().begin();
44 
45  for (const label facei : faceAddr)
46  {
47  const label patchi = patches.whichPatch(facei);
48 
49  if (patchi == -1)
50  {
51  *iter = sfld[facei];
52  }
53  else
54  {
55  const label localFacei = facei - patches[patchi].start();
56  *iter = sfld.boundaryField()[patchi][localFacei];
57  }
58 
59  ++iter;
60  }
61 
62  return tfld;
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 template<class Type>
70 (
72 )
73 {
74  if (notState(outputState::CELL_DATA))
75  {
77  << "Bad writer state (" << stateNames[state_]
78  << ") - should be (" << stateNames[outputState::CELL_DATA]
79  << ") for field " << field.name() << nl << endl
80  << exit(FatalError);
81  }
82 
83  this->indirectPatchWriter::write(field.name(), getFaceField(field)());
84 }
85 
86 
87 template<class Type>
89 (
91 )
92 {
93  if (notState(outputState::CELL_DATA))
94  {
96  << "Bad writer state (" << stateNames[state_]
97  << ") - should be (" << stateNames[outputState::CELL_DATA]
98  << ") for field " << field.name() << nl << endl
99  << exit(FatalError);
100  }
101 
102  this->indirectPatchWriter::write(field.name(), field.primitiveField());
103 }
104 
105 
106 // ************************************************************************* //
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
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
Foam::vtk::surfaceMeshWriter::write
void write(const GeometricField< Type, fvsPatchField, surfaceMesh > &field)
Write surface field (CellData)
Definition: foamVtkSurfaceMeshWriterTemplates.C:70
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
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