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-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 InNamespace
27  Foam
28 
29 Description
30  Read dimensioned fields from disk and write with ensightMesh
31 
32 SourceFiles
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef ensight_writeDimFields_H
37 #define ensight_writeDimFields_H
38 
39 #include "writeVolFields.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 template<class Type>
47 bool writeDimField
48 (
49  ensightCase& ensCase,
50  const ensightMesh& ensMesh,
52 )
53 {
54  if (!tdf.valid())
55  {
56  return false;
57  }
58 
59  auto tfield = makeZeroGradientField<Type>(tdf);
60 
61  // Now a volField with zero-gradient boundaries
62 
63  return writeVolField<Type>
64  (
65  ensCase,
66  ensMesh,
67  tfield,
68  false // No nearCellValue, we already have zero-gradient
69  );
70 }
71 
72 
73 template<class Type>
74 label writeDimFields
75 (
76  ensightCase& ensCase,
77  const ensightMesh& ensMesh,
78  const IOobjectList& objects
79 )
80 {
81  typedef typename
83  <
84  Type, fvPatchField, volMesh
85  >::Internal DimField;
86 
87  const fvMesh& mesh = dynamicCast<const fvMesh>(ensMesh.mesh());
88 
89  label count = 0;
90 
91  for (const word& fieldName : objects.sortedNames<DimField>())
92  {
93  if
94  (
95  writeDimField<Type>
96  (
97  ensCase,
98  ensMesh,
99  getField<DimField>(objects.findObject(fieldName), mesh)
100  )
101  )
102  {
103  Info<< ' ' << fieldName;
104  ++count;
105  }
106  }
107 
108  return count;
109 }
110 
111 
112 label writeAllDimFields
113 (
114  ensightCase& ensCase,
115  const ensightMesh& ensMesh,
116  const IOobjectList& objects
117 )
118 {
119  #undef ensight_WRITE_FIELD
120  #define ensight_WRITE_FIELD(PrimitiveType) \
121  writeDimFields<PrimitiveType> \
122  ( \
123  ensCase, \
124  ensMesh, \
125  objects \
126  )
127 
128  label count = 0;
129  count += ensight_WRITE_FIELD(scalar);
134 
135  #undef ensight_WRITE_FIELD
136  return count;
137 }
138 
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
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:62
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:50
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::writeDimFields
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition: writeDimFields.H:75
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
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:113
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
Read volume fields from disk and write with ensightMesh.
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:48
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::ensightMesh::mesh
const polyMesh & mesh() const
Reference to the underlying polyMesh.
Definition: ensightMeshI.H:30
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