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-------------------------------------------------------------------------------
10License
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
32template<class Type>
34(
36 const objectRegistry& obrTmp,
37 const label nTotParcels
38) const
39{
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>>());
60 Pstream::broadcast(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 {
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// ************************************************************************* //
bitSet parcelAddr_
The filtered parcel addressing. Eg, for the current cloud.
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
static void combineGather(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag, const label comm)
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
Registry of regIOobjects.
wordList names() const
The unsorted names of all objects.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
splitCell * master() const
Definition: splitCell.H:113
A class for handling words, derived from Foam::string.
Definition: word.H:68
void writeListParallel(vtk::formatter &fmt, const UList< Type > &values)
Write a list of values.
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:342
uint8_t direction
Definition: direction.H:56
word format(conversionProperties.get< word >("format"))
List helper to append y unique elements onto the end of x.
Definition: ListOps.H:570