coordSetWriterTemplates.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-------------------------------------------------------------------------------
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// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
29
30template<class Type>
33{
34 UPtrList<const Field<Type>> fieldPtrs(1);
35 fieldPtrs.set(0, &field);
36
37 return fieldPtrs;
38}
39
40
41template<class Type>
44{
45 UPtrList<const Field<Type>> fieldPtrs(fieldValues.size());
46 forAll(fieldValues, i)
47 {
48 fieldPtrs.set(i, &(fieldValues[i]));
49 }
50
51 return fieldPtrs;
52}
53
54
55template<class Type>
57(
58 Ostream& os,
59 const coordSet& coords,
60 const UList<Type>& values,
61 const char* sep
62)
63{
64 forAll(coords, pointi)
65 {
66 // Output coordinate (point or scalar) with separator
67 if (coords.hasVectorAxis())
68 {
69 const vector& p = coords.vectorCoord(pointi);
70 os << p.x() << sep << p.y() << sep << p.z();
71 }
72 else
73 {
74 os << coords.scalarCoord(pointi);
75 }
76
77 // Output component values with separator
78 const auto& val = values[pointi];
79 for (direction d=0; d < pTraits<Type>::nComponents; ++d)
80 {
81 os << sep << component(val, d);
82 }
83 os << nl;
84 }
85}
86
87
88// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
const T * set(const label i) const
Definition: UPtrList.H:248
static UPtrList< const Field< Type > > repackageFields(const Field< Type > &field)
Repackage field into a UPtrList.
static void writeTable(Ostream &os, const coordSet &coords, const UList< Type > &values, const char *sep)
Write coordinates and values.
Holds list of sampling positions.
Definition: coordSet.H:56
const vector & vectorCoord(const label index) const
Get point according to axis="xyz" specification.
Definition: coordSet.C:188
bool hasVectorAxis() const noexcept
True if axis specification is a vector.
Definition: coordSet.C:135
scalar scalarCoord(const label index) const
Get coordinate of point according to axis specification.
Definition: coordSet.C:141
volScalarField & p
rDeltaTY field()
OBJstream os(runTime.globalPath()/outputName)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
uint8_t direction
Definition: direction.H:56
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333