Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13InNamespace
14 Foam
15
16Description
17 Read dimensioned fields from disk and write with ensightMesh
18
19\*---------------------------------------------------------------------------*/
20
21#ifndef FoamToEnsight_writeDimFields_H
22#define FoamToEnsight_writeDimFields_H
23
24#include "writeVolFields.H"
25
26// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27
28namespace Foam
29{
30
31template<class Type>
33(
34 ensightCase& ensCase,
35 const ensightMesh& ensMesh,
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
49 (
50 ensCase,
51 ensMesh,
52 tfield,
53 false // No nearCellValue, we already have zero-gradient
54 );
55}
56
57
58template<class Type>
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 (
77 (
78 ensCase,
79 ensMesh,
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 label count = 0;
101 const label total = objects.size();
102 do
103 {
104 #undef doLocalWriteCode
105 #define doLocalWriteCode(Type) \
106 { \
107 count += writeDimFields<Type> \
108 ( \
109 ensCase, \
110 ensMesh, \
111 objects \
112 ); \
113 if (count >= total) break; /* early exit */ \
114 }
115
116 doLocalWriteCode(scalar);
121
122 #undef doLocalWriteCode
123 }
124 while (false);
125
126 return count;
127}
128
129} // End namespace Foam
130
131// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132
133#endif
134
135// ************************************************************************* //
label size() const noexcept
The number of elements in table.
Definition HashTable.H:358
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
Supports writing of ensight cases as well as providing common factory methods to open new files.
Definition ensightCase.H:64
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition ensightMesh.H:79
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
A class for managing temporary objects.
Definition tmp.H:75
dynamicFvMesh & mesh
const auto & io
#define doLocalWriteCode(Type)
Namespace for OpenFOAM.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Tensor< scalar > tensor
Definition symmTensor.H:57
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
bool writeVolField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< VolumeField< Type > > &tfield, const bool nearCellValue=false)
DimensionedField< Type, volMesh > VolumeInternalField
A volume internal field for a given Type.
tmp< VolumeField< Type > > makeZeroGradientField(const tmp< VolumeInternalField< Type > > &tdf)
Convert an internal field to zero-gradient volume field.
Definition readFields.H:101
bool writeDimField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< VolumeInternalField< Type > > &tdf)
Vector< scalar > vector
Definition vector.H:57
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
tmp< GeoField > getField(const IOobject &io, const typename GeoField::Mesh &mesh)
Get the field or FatalError.
Definition readFields.H:51
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55