ensightWriteTemplates.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-2020 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 #include "ensightOutputVolField.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class Type>
33 Foam::label Foam::functionObjects::ensightWrite::writeVolFields
34 (
35  const fvMeshSubset& proxy,
36  const wordHashSet& acceptField
37 )
38 {
40 
41  const fvMesh& baseMesh = proxy.baseMesh();
42 
43  label count = 0;
44 
45  for (const word& fieldName : baseMesh.sortedNames<GeoField>(acceptField))
46  {
47  const auto* fieldptr = baseMesh.findObject<GeoField>(fieldName);
48 
49  if (!fieldptr)
50  {
51  continue;
52  }
53 
54  auto tfield = fvMeshSubsetProxy::interpolate(proxy, *fieldptr);
55  const auto& field = tfield();
56 
57  autoPtr<ensightFile> os = ensCase().newData<Type>(fieldName);
58 
59  ensightOutput::writeVolField<Type>
60  (
61  os.ref(),
62  field,
63  ensMesh(),
64  caseOpts_.nodeValues()
65  );
66 
67  Log << ' ' << fieldName;
68 
69  ++count;
70  }
71 
72  return count;
73 }
74 
75 
76 // ************************************************************************* //
Foam::objectRegistry::sortedNames
wordList sortedNames() const
The sorted names of all objects.
Definition: objectRegistry.C:153
Log
#define Log
Definition: PDRblock.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fvMeshSubset
Given the original mesh and the list of selected cells, it creates the mesh consisting only of the de...
Definition: fvMeshSubset.H:73
Foam::HashSet< word, Hash< word > >
field
rDeltaTY field()
os
OBJstream os(runTime.globalPath()/outputName)
ensightOutputVolField.H
A collection of functions for writing volField content in ensight format.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::fvMeshSubset::baseMesh
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:30
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::objectRegistry::findObject
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Definition: objectRegistryTemplates.C:401
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.