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-2022 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 ensight_writeDimFields_H
22#define ensight_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,
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
58template<class Type>
60(
61 ensightCase& ensCase,
62 const ensightMesh& ensMesh,
63 const IOobjectList& objects
64)
65{
66 typedef VolumeInternalField<Type> FieldType;
68 const fvMesh& mesh = dynamicCast<const fvMesh>(ensMesh.mesh());
69
70 label count = 0;
71
72 for (const word& fieldName : objects.sortedNames<FieldType>())
73 {
74 if
75 (
76 writeDimField<Type>
77 (
78 ensCase,
79 ensMesh,
80 getField<FieldType>(objects.findObject(fieldName), mesh)
81 )
82 )
83 {
84 Info<< ' ' << fieldName;
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);
111 count += ensight_WRITE_FIELD(vector);
114 count += ensight_WRITE_FIELD(tensor);
115
116 #undef ensight_WRITE_FIELD
117 return count;
118}
119
120} // End namespace Foam
121
122// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123
124#endif
125
126// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
const IOobject * findObject(const word &objName) const
Return const pointer to the object found by name.
Definition: IOobjectList.C:293
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:383
Supports writing of ensight cases as well as providing common factory methods to open new files.
Definition: ensightCase.H:69
Encapsulation of volume meshes for writing in ensight format. It manages cellZones,...
Definition: ensightMesh.H:83
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
Definition: ensightMesh.H:159
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define ensight_WRITE_FIELD(PrimitiveType)
Read volume fields from disk and write with vtk::internalWriter and vtk::patchWriter.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:78
Namespace for OpenFOAM.
label writeAllDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
messageStream Info
Information stream (stdout output on master, null elsewhere)
label writeDimFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
bool writeDimField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< VolumeInternalField< Type > > &tdf)