writeDimFields.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) 2018-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 dimensioned fields from disk and write with ensightMesh
18 
19 \*---------------------------------------------------------------------------*/
20 
21 #ifndef ensight_writeDimFields_H
22 #define ensight_writeDimFields_H
23 
24 #include "writeVolFields.H"
25 
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27 
28 namespace Foam
29 {
30 
31 template<class Type>
32 bool writeDimField
33 (
34  ensightCase& ensCase,
35  const ensightMesh& ensMesh,
36  const tmp<VolumeInternalField<Type>>& tdf
37 )
38 {
39  if (!tdf)
40  {
41  return false;
42  }
43 
44  auto tfield = makeZeroGradientField<Type>(tdf);
45 
46  // Now a volField with zero-gradient boundaries
47 
48  return writeVolField<Type>
49  (
50  ensCase,
51  ensMesh,
52  tfield,
53  false // No nearCellValue, we already have zero-gradient
54  );
55 }
56 
57 
58 template<class Type>
59 label writeDimFields
60 (
61  ensightCase& ensCase,
62  const ensightMesh& ensMesh,
63  const IOobjectList& objects
64 )
65 {
66  typedef VolumeInternalField<Type> FieldType;
67 
68  const auto& mesh = refCast<const fvMesh>(ensMesh.mesh());
69 
70  label count = 0;
71 
72  for (const IOobject& io : objects.csorted<FieldType>())
73  {
74  if
75  (
76  writeDimField<Type>
77  (
78  ensCase,
79  ensMesh,
80  getField<FieldType>(io, mesh)
81  )
82  )
83  {
84  Info<< ' ' << io.name();
85  ++count;
86  }
87  }
88 
89  return count;
90 }
91 
92 
94 (
95  ensightCase& ensCase,
96  const ensightMesh& ensMesh,
97  const IOobjectList& objects
98 )
99 {
100  #undef ensight_WRITE_FIELD
101  #define ensight_WRITE_FIELD(PrimitiveType) \
102  writeDimFields<PrimitiveType> \
103  ( \
104  ensCase, \
105  ensMesh, \
106  objects \
107  )
108 
109  label count = 0;
110  count += ensight_WRITE_FIELD(scalar);
115 
116  #undef ensight_WRITE_FIELD
117  return count;
118 }
119 
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #endif
125 
126 // ************************************************************************* //
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
bool writeDimField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< VolumeInternalField< Type >> &tdf)
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
Definition: ensightMesh.H:191
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
dynamicFvMesh & mesh
#define ensight_WRITE_FIELD(PrimitiveType)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Encapsulation of volume meshes for writing in ensight format. It manages cellZones, facesZone, patches.
Definition: ensightMesh.H:78
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
messageStream Info
Information stream (stdout output on master, null elsewhere)
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.
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Namespace for OpenFOAM.