OpenFOAM: API Guide
v2112
The open source CFD toolbox
vtkCloudTemplates.C
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-2021 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
\*---------------------------------------------------------------------------*/
27
28
#include "
IOField.H
"
29
30
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31
32
template
<
class
Type>
33
Foam::wordList
Foam::functionObjects::vtkCloud::writeFields
34
(
35
autoPtr<vtk::formatter>
&
format
,
36
const
objectRegistry
& obrTmp,
37
const
label nTotParcels
38
)
const
39
{
40
const
direction
nCmpt(
pTraits<Type>::nComponents
);
41
42
static_assert
43
(
44
(
45
std::is_same<label,
typename
pTraits<Type>::cmptType
>::value
46
|| std::is_floating_point<
typename
pTraits<Type>::cmptType
>::value
47
),
48
"Label and Floating-point vector space only"
49
);
50
51
// Other integral types (eg, bool etc) would need cast/convert to label.
52
// Similarly for labelVector etc.
53
54
55
// Fields are not always on all processors (eg, multi-component parcels).
56
// Thus need to resolve names between all processors.
57
58
wordList
fieldNames
(obrTmp.
names
<
IOField<Type>
>());
59
Pstream::combineGather(
fieldNames
,
ListOps::uniqueEqOp<word>
());
60
Pstream::combineScatter(
fieldNames
);
61
62
// Consistent order on all processors
63
Foam::sort
(
fieldNames
);
64
65
for
(
const
word
& fieldName :
fieldNames
)
66
{
67
const
List<Type>
* fldPtr = obrTmp.
findObject
<
IOField<Type>
>(fieldName);
68
const
List<Type>
&
values
= (fldPtr ? *fldPtr :
List<Type>
());
69
70
if
(Pstream::master())
71
{
72
if
(std::is_same<label,
typename
pTraits<Type>::cmptType
>::value)
73
{
74
const
uint64_t payLoad =
75
vtk::sizeofData<label, nCmpt>(nTotParcels);
76
77
format
().beginDataArray<label, nCmpt>(fieldName);
78
format
().writeSize(payLoad);
79
}
80
else
81
{
82
const
uint64_t payLoad =
83
vtk::sizeofData<float, nCmpt>(nTotParcels);
84
85
format
().beginDataArray<float, nCmpt>(fieldName);
86
format
().writeSize(payLoad);
87
}
88
}
89
90
if
(applyFilter_)
91
{
92
vtk::writeListParallel
(
format
.ref(),
values
, parcelAddr_);
93
}
94
else
95
{
96
vtk::writeListParallel
(
format
.ref(),
values
);
97
}
98
99
if
(Pstream::master())
100
{
101
// Non-legacy
102
format
().flush();
103
format
().endDataArray();
104
}
105
}
106
107
return
fieldNames
;
108
}
109
110
111
// ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition:
word.H:65
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition:
foamVtkLagrangianWriter.H:61
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition:
HashOps.H:149
Foam::objectRegistry
Registry of regIOobjects.
Definition:
objectRegistry.H:60
format
word format(conversionProperties.get< word >("format"))
Foam::sort
void sort(UList< T > &a)
Definition:
UList.C:261
fieldNames
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
Foam::ListOps::uniqueEqOp
List helper to append y unique elements onto the end of x.
Definition:
ListOps.H:577
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition:
HashPtrTable.H:53
Foam::objectRegistry::findObject
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Definition:
objectRegistryTemplates.C:401
Foam::objectRegistry::names
wordList names() const
The names of all objects.
Definition:
objectRegistry.C:147
IOField.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition:
BitOps.H:63
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition:
pTraits.H:56
Foam::direction
uint8_t direction
Definition:
direction.H:52
Foam::vtk::writeListParallel
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
Definition:
foamVtkOutputTemplates.C:164
src
functionObjects
lagrangian
vtkCloud
vtkCloudTemplates.C
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.