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-2021 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<DimensionedField<Type, volMesh>>& tdf
37 )
38 {
39  if (!tdf.valid())
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 typename
67  GeometricField
68  <
69  Type, fvPatchField, volMesh
70  >::Internal DimField;
71 
72  const fvMesh& mesh = dynamicCast<const fvMesh>(ensMesh.mesh());
73 
74  label count = 0;
75 
76  for (const word& fieldName : objects.sortedNames<DimField>())
77  {
78  if
79  (
80  writeDimField<Type>
81  (
82  ensCase,
83  ensMesh,
84  getField<DimField>(objects.findObject(fieldName), mesh)
85  )
86  )
87  {
88  Info<< ' ' << fieldName;
89  ++count;
90  }
91  }
92 
93  return count;
94 }
95 
96 
98 (
99  ensightCase& ensCase,
100  const ensightMesh& ensMesh,
101  const IOobjectList& objects
102 )
103 {
104  #undef ensight_WRITE_FIELD
105  #define ensight_WRITE_FIELD(PrimitiveType) \
106  writeDimFields<PrimitiveType> \
107  ( \
108  ensCase, \
109  ensMesh, \
110  objects \
111  )
112 
113  label count = 0;
114  count += ensight_WRITE_FIELD(scalar);
119 
120  #undef ensight_WRITE_FIELD
121  return count;
122 }
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #endif
129 
130 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::Tensor< scalar >
Foam::ensightMesh
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition: ensightMesh.H:82
Foam::SymmTensor< scalar >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:51
Foam::IOobjectList::findObject
const IOobject * findObject(const word &objName) const
Return const pointer to the object found by name.
Definition: IOobjectList.C:270
Foam::IOobjectList::sortedNames
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:345
Foam::ensightMesh::mesh
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
Definition: ensightMesh.H:148
Foam::writeDimFields
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition: writeDimFields.H:68
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor< scalar >
Foam::writeAllDimFields
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition: writeDimFields.H:106
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
Foam::ensightCase
Supports writing of ensight cases as well as providing common factory methods to open new files.
Definition: ensightCase.H:67
writeVolFields.H
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::Vector< scalar >
Foam::writeDimField
bool writeDimField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< DimensionedField< Type, volMesh >> &tdf)
Definition: writeDimFields.H:41
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
ensight_WRITE_FIELD
#define ensight_WRITE_FIELD(PrimitiveType)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54