foamVtkCoordSetWriterTemplates.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) 2022 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const word& fieldName,
34  const UPtrList<const Field<Type>>& fieldPtrs
35 )
36 {
37  // Could check sizes:
38 
40  {
41  ++nPointData_;
42  }
43  else
44  {
46  << " for field " << fieldName << nl << endl
47  << exit(FatalError);
48  return;
49  }
50 
51  label nValues = 0;
52 
53  for (const Field<Type>& field : fieldPtrs)
54  {
55  nValues += field.size();
56  }
57 
58  // if (parallel_)
59  // {
60  // reduce(nValues, sumOp<label>());
61  // }
62 
63  this->beginDataArray<Type>(fieldName, nValues);
64 
65  // if (parallel_)
66  // {
67  // vtk::writeListParallel(format_.ref(), field);
68  // }
69  // else
70  {
71  for (const Field<Type>& field : fieldPtrs)
72  {
74  }
75  }
76 
77  this->endDataArray();
78 }
79 
80 
81 // ************************************************************************* //
rDeltaTY field()
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
vtk::formatter & format()
The VTK formatter in use. FatalError for off-processor.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
void endDataArray()
Flush formatter and end of DataArray output (non-legacy)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
label nPointData_
The number of PointData written for the Piece thus far.
bool isState(outputState test) const noexcept
True if output state corresponds to the test state.
Ostream & reportBadState(Ostream &, outputState expected) const
Generate message reporting bad writer state.
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
void writePointData(const word &fieldName, const UPtrList< const Field< Type >> &fieldPtrs)
Write primitive field of PointData.