foamGltfObjectTemplates.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) 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
28template<class Type>
30{
32
33 label count = data_.size();
34 data_.resize(data_.size() + fld.size()*nCmpts);
35
36 forAll(fld, fieldi)
37 {
38 for (direction d = 0; d < nCmpts; ++d)
39 {
40 data_[count++] = component(fld[fieldi], d);
41 }
42 }
43}
44
45
46template<class Type1, class Type2>
47void Foam::glTF::object::addData(const Type1& fld1, const Type2& fld2)
48{
49 if (fld1.size() != fld2.size())
50 {
52 << "Field lengths must be the same. Field1:"
53 << fld1.size() << " Field2:" << fld2.size()
54 << abort(FatalError);
55 }
56
59
60 label count = data_.size();
61 data_.resize(data_.size() + fld1.size()*(nCmpts1 + nCmpts2));
62
63 forAll(fld1, fieldi)
64 {
65 for (direction d = 0; d < nCmpts1; ++d)
66 {
67 data_[count++] = component(fld1[fieldi], d);
68 }
69
70 for (direction d = 0; d < nCmpts2; ++d)
71 {
72 data_[count++] = component(fld2[fieldi], d);
73 }
74 }
75}
76
77
78// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
void addData(const Type &fld)
Add data to the buffer.
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
uint8_t direction
Definition: direction.H:56
error FatalError
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333