OpenFOAM
v2406
The open source CFD toolbox
writePointFields.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) 2020-2023 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13
InNamespace
14
Foam
15
16
Description
17
Read point fields from disk and write as ensight data
18
19
\*---------------------------------------------------------------------------*/
20
21
#ifndef ensight_writePointFields_H
22
#define ensight_writePointFields_H
23
24
#include "
readFields.H
"
25
#include "
ensightMesh.H
"
26
#include "
fvMesh.H
"
27
28
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29
30
namespace
Foam
31
{
32
33
template
<
class
Type>
34
bool
writePointField
35
(
36
ensightCase& ensCase,
37
const
ensightMesh
& ensMesh,
38
const
tmp
<
PointField<Type>
>& tfield
39
)
40
{
41
if
(!tfield)
42
{
43
return
false
;
44
}
45
46
const
auto
&
field
= tfield();
47
48
// PointData = true
49
autoPtr<ensightFile>
os
= ensCase.newData<Type>(
field
.name(),
true
);
50
51
bool
wrote = ensightOutput::writePointField<Type>
52
(
53
os
.ref(),
54
field
,
55
ensMesh
56
);
57
58
tfield.clear();
59
return
wrote;
60
}
61
62
63
template
<
class
Type>
64
label
writePointFields
65
(
66
ensightCase& ensCase,
67
const
ensightMesh
& ensMesh,
68
const
IOobjectList
& objects
69
)
70
{
71
typedef
PointField<Type>
FieldType;
72
73
const
pointMesh
& pMesh =
pointMesh::New
(ensMesh.
mesh
());
74
75
label
count
= 0;
76
77
for
(
const
IOobject
&
io
: objects.
csorted
<FieldType>())
78
{
79
if
80
(
81
writePointField<Type>
82
(
83
ensCase,
84
ensMesh,
85
getField<FieldType>(
io
, pMesh)
86
)
87
)
88
{
89
Info
<<
' '
<<
io
.
name
();
90
++
count
;
91
}
92
}
93
94
return
count
;
95
}
96
97
98
label
writeAllPointFields
99
(
100
ensightCase& ensCase,
101
const
ensightMesh
& ensMesh,
102
const
IOobjectList
& objects
103
)
104
{
105
#undef ensight_WRITE_FIELD
106
#define ensight_WRITE_FIELD(PrimitiveType) \
107
writePointFields<PrimitiveType> \
108
( \
109
ensCase, \
110
ensMesh, \
111
objects \
112
)
113
114
label
count
= 0;
115
count
+=
ensight_WRITE_FIELD
(scalar);
116
count
+=
ensight_WRITE_FIELD
(
vector
);
117
count
+=
ensight_WRITE_FIELD
(
sphericalTensor
);
118
count
+=
ensight_WRITE_FIELD
(
symmTensor
);
119
count
+=
ensight_WRITE_FIELD
(
tensor
);
120
121
#undef ensight_WRITE_FIELD
122
return
count
;
123
}
124
125
}
// End namespace Foam
126
127
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128
129
#endif
130
131
// ************************************************************************* //
Foam::writePointFields
label writePointFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition:
writePointFields.H:67
field
rDeltaTY field()
Foam::SymmTensor< scalar >
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition:
IOobjectList.H:55
Foam::IOobject::name
const word & name() const noexcept
Return the object name.
Definition:
IOobjectI.H:195
Foam::MeshObject< polyMesh, UpdateableMeshObject, pointMesh >::New
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
Definition:
MeshObject.C:53
fvMesh.H
Foam::GeometricField< Type, pointPatchField, pointMesh >
Foam::ensightMesh::mesh
const polyMesh & mesh() const noexcept
Reference to the underlying polyMesh.
Definition:
ensightMesh.H:191
Foam::writeAllPointFields
label writeAllPointFields(ensightCase &ensCase, const ensightMesh &ensMesh, const IOobjectList &objects)
Definition:
writePointFields.H:101
Foam::writePointField
bool writePointField(ensightCase &ensCase, const ensightMesh &ensMesh, const tmp< PointField< Type >> &tfield)
Definition:
writePointFields.H:37
ensightMesh.H
Foam::pointMesh
Mesh representing a set of points created from polyMesh.
Definition:
pointMesh.H:45
Foam::SphericalTensor< scalar >
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition:
BitOps.H:73
ensight_WRITE_FIELD
#define ensight_WRITE_FIELD(PrimitiveType)
Foam::vector
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Foam::ensightMesh
Encapsulation of volume meshes for writing in ensight format. It manages cellZones, facesZone, patches.
Definition:
ensightMesh.H:78
os
OBJstream os(runTime.globalPath()/outputName)
readFields.H
Helper routines for reading a field or fields, for foamToEnsight.
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition:
HashPtrTable.H:48
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::tmp
A class for managing temporary objects.
Definition:
HashPtrTable.H:50
Foam::tensor
Tensor of scalars, i.e. Tensor<scalar>.
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam::IOobjectList::csorted
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
applications
utilities
postProcessing
dataConversion
foamToEnsight
writePointFields.H
Generated by
1.8.14