Loading...
Searching...
No Matches
writeAreaFields.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) 2021-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 finite-area fields from disk and write ensightFaMesh
18
19\*---------------------------------------------------------------------------*/
20
21#ifndef FoamToEnsight_writeAreaFields_H
22#define FoamToEnsight_writeAreaFields_H
23
24#include "readFields.H"
25#include "areaFaMesh.H"
26
27// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
28
29namespace Foam
30{
31
32template<class Type>
34(
35 ensightCase& ensCase,
36 const ensightFaMesh& ensMesh,
37 const tmp<AreaField<Type>>& tfield
38)
39{
40 if (!tfield)
41 {
42 return false;
43 }
44 const auto& field = tfield();
45
47 ensCase.newData<Type>(field.name());
48
50 (
51 os.ref(),
52 field,
53 ensMesh
54 );
55
56 tfield.clear();
57 return wrote;
58}
59
60
61template<class Type>
63(
64 ensightCase& ensCase,
65 const ensightFaMesh& ensMesh,
66 const IOobjectList& objects
67)
68{
69 typedef AreaField<Type> FieldType;
70
71 const faMesh& mesh = ensMesh.mesh();
72
73 label count = 0;
74
75 for (const IOobject& io : objects.csorted<FieldType>())
76 {
77 if
78 (
80 (
81 ensCase,
82 ensMesh,
84 )
85 )
86 {
87 Info<< ' ' << io.name();
88 ++count;
89 }
90 }
91
92 return count;
93}
94
95
97(
98 ensightCase& ensCase,
99 const ensightFaMesh& ensMesh,
100 const IOobjectList& objects
101)
102{
103 label count = 0;
104 const label total = objects.size();
105 do
106 {
107 #undef doLocalWriteCode
108 #define doLocalWriteCode(Type) \
109 { \
110 count += writeAreaFields<Type> \
111 ( \
112 ensCase, \
113 ensMesh, \
114 objects \
115 ); \
116 if (count >= total) break; /* early exit */ \
117 }
118
119 doLocalWriteCode(scalar);
124
125 #undef doLocalWriteCode
126 }
127 while (false);
128
129 return count;
130}
131
132} // End namespace Foam
133
134// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135
136#endif
137
138// ************************************************************************* //
Helper routines for reading a field or fields, for foamToEnsight.
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Supports writing of ensight cases as well as providing common factory methods to open new files.
Definition ensightCase.H:64
autoPtr< ensightFile > newData(const word &varName, const bool isPointData=false) const
Open stream for new data file (on master), with current index.
Encapsulation of area meshes for writing in ensight format.
const faMesh & mesh() const noexcept
Reference to the underlying faMesh.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
A class for managing temporary objects.
Definition tmp.H:75
rDeltaTY field()
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
const auto & io
#define doLocalWriteCode(Type)
bool writeAreaField(ensightOutput::floatBufferType &scratch, ensightFile &os, const GeometricField< Type, faPatchField, areaMesh > &fld, const ensightFaMesh &ensMesh)
Write finite-area field component-wise.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
label writeAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
Tensor< scalar > tensor
Definition symmTensor.H:57
GeometricField< Type, faPatchField, areaMesh > AreaField
An area field for a given type.
bool writeAreaField(ensightCase &ensCase, const ensightFaMesh &ensMesh, const tmp< AreaField< Type > > &tfield)
label writeAllAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
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