ensightWriteImpl.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-2023 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::writeVolFieldsImpl
34 (
36  const fvMeshSubset& proxy,
37  const wordHashSet& candidateNames
38 )
39 {
41 
42  const fvMesh& baseMesh = proxy.baseMesh();
43 
44  label count = 0;
45 
46  for
47  (
48  const GeoField& origField
49  : baseMesh.csorted<GeoField>(candidateNames)
50  )
51  {
52  const word& fieldName = origField.name();
53 
54  auto tfield = fvMeshSubsetProxy::interpolate(proxy, origField);
55  const auto& field = tfield();
56 
57  autoPtr<ensightFile> os = ensCase().newData<Type>(fieldName);
58 
59  ensightOutput::writeVolField<Type>
60  (
61  scratch,
62  os.ref(),
63  field,
64  ensMesh(),
65  caseOpts_.nodeValues()
66  );
67 
68  Log << ' ' << fieldName;
69 
70  ++count;
71  }
72 
73  return count;
74 }
75 
76 
77 // ************************************************************************* //
rDeltaTY field()
UPtrList< const Type > csorted() const
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
bool nodeValues() const noexcept
Forced use of values per node instead of per element.
Definition: ensightCase.H:702
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:23
A collection of functions for writing volField content in ensight format.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:51
autoPtr< ensightFile > newData(const word &varName, const bool isPointData=false) const
Open stream for new data file (on master), with current index.
A class for handling words, derived from Foam::string.
Definition: word.H:63
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const GeoField &fld)
Wrapper for field or the subsetted field.
OBJstream os(runTime.globalPath()/outputName)
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
#define Log
Definition: PDRblock.C:28
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48