writeAreaFields.H
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) 2021-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 InNamespace
14  Foam
15 
16 Description
17  Read finiteArea fields from disk and write ensightFaMesh
18 
19 \*---------------------------------------------------------------------------*/
20 
21 #ifndef ensight_writeAreaFields_H
22 #define ensight_writeAreaFields_H
23 
24 #include "readFields.H"
25 #include "areaFaMesh.H"
26 
27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
28 
29 namespace Foam
30 {
31 
32 template<class Type>
33 bool writeAreaField
34 (
35  ensightCase& ensCase,
36  const ensightFaMesh& ensMesh,
37  const tmp<AreaField<Type>>& tfield
38 )
39 {
40  if (!tfield)
41  {
42  return false;
43  }
44  const auto& field = tfield();
45 
47  ensCase.newData<Type>(field.name());
48 
49  bool wrote = ensightOutput::writeAreaField<Type>
50  (
51  os.ref(),
52  field,
53  ensMesh
54  );
55 
56  tfield.clear();
57  return wrote;
58 }
59 
60 
61 template<class Type>
62 label writeAreaFields
63 (
64  ensightCase& ensCase,
65  const ensightFaMesh& ensMesh,
66  const IOobjectList& objects
67 )
68 {
69  typedef AreaField<Type> FieldType;
70 
71  const faMesh& mesh = ensMesh.mesh();
72 
73  label count = 0;
74 
75  for (const IOobject& io : objects.csorted<FieldType>())
76  {
77  if
78  (
79  writeAreaField<Type>
80  (
81  ensCase,
82  ensMesh,
83  getField<FieldType>(io, mesh)
84  )
85  )
86  {
87  Info<< ' ' << io.name();
88  ++count;
89  }
90  }
91 
92  return count;
93 }
94 
95 
97 (
98  ensightCase& ensCase,
99  const ensightFaMesh& ensMesh,
100  const IOobjectList& objects
101 )
102 {
103  #undef ensight_WRITE_FIELD
104  #define ensight_WRITE_FIELD(PrimitiveType) \
105  writeAreaFields<PrimitiveType> \
106  ( \
107  ensCase, \
108  ensMesh, \
109  objects \
110  )
111 
112  label count = 0;
113  count += ensight_WRITE_FIELD(scalar);
118 
119  #undef ensight_WRITE_FIELD
120  return count;
121 }
122 
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:87
label writeAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
rDeltaTY field()
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
Encapsulation of area meshes for writing in ensight format.
Definition: ensightFaMesh.H:58
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
label writeAllAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
const faMesh & mesh() const noexcept
Reference to the underlying faMesh.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
dynamicFvMesh & mesh
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
#define ensight_WRITE_FIELD(PrimitiveType)
bool writeAreaField(ensightCase &ensCase, const ensightFaMesh &ensMesh, const tmp< AreaField< Type >> &tfield)
Helper routines for reading a field or fields, for foamToEnsight.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Tensor of scalars, i.e. Tensor<scalar>.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
Namespace for OpenFOAM.