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) 2018-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Code chunk for reading finite-area fields from disk
15 and write with vtk::uindirectPatchGeoFieldsWriter
16
17\*---------------------------------------------------------------------------*/
18
19#ifndef FoamToVTK_writeAreaFields_H
20#define FoamToVTK_writeAreaFields_H
21
22#include "readFields.H"
24
25// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
26
27namespace Foam
28{
29
30// Writer type for finite-area mesh + fields
31typedef
34
36template<class GeoField>
38(
40 const typename GeoField::Mesh& mesh,
41 const IOobjectList& objects,
42 const bool syncPar
43)
44{
45 label count = 0;
46
47 for (const word& fieldName : objects.sortedNames<GeoField>())
48 {
49 tmp<GeoField> tfield =
50 getField<GeoField>(mesh, objects, fieldName, syncPar);
51
52 if (tfield)
53 {
54 writer.write(tfield());
55
56 tfield.clear();
57 ++count;
58 }
59 }
60
61 return count;
62}
63
64
66(
68 const faMesh& mesh,
69 const IOobjectList& objects,
70 const bool syncPar
71)
72{
73 label count = 0;
74 const label total = objects.size();
75 do
76 {
77 #undef doLocalWriteCode
78 #define doLocalWriteCode(Type) \
79 { \
80 typedef AreaField<Type> FieldType; \
81 \
82 count += writeAreaFields<FieldType> \
83 ( \
84 writer, \
85 mesh, \
86 objects, \
87 syncPar \
88 ); \
89 if (count >= total) break; /* early exit */ \
90 }
91
92 doLocalWriteCode(scalar);
97
98 #undef doLocalWriteCode
99 }
100 while (false);
101
102 return count;
103}
104
105
106} // End namespace Foam
107
108// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109
110#endif
111
112// ************************************************************************* //
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
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,...
wordList sortedNames() const
The sorted names of the IOobjects.
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
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition tmpI.H:289
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
#define doLocalWriteCode(Type)
GenericPatchGeoFieldsWriter< uindirectPrimitivePatch > uindirectPatchGeoFieldsWriter
Write uindirectPrimitivePatch faces/points as a vtp file or a legacy vtk file with support for geomet...
Namespace for OpenFOAM.
label writeAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
Tensor< scalar > tensor
Definition symmTensor.H:57
vtk::uindirectPatchGeoFieldsWriter vtkWriterType_areaMesh
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