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 -------------------------------------------------------------------------------
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 template<class Type>
29 void Foam::glTF::object::addData(const Type& fld)
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 
46 template<class Type1, class Type2>
47 void 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 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
uint8_t direction
Definition: direction.H:46
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:160
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
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
void addData(const Type &fld)
Add data to the buffer.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Definition: exprTraits.C:40
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
errorManip< error > abort(error &err)
Definition: errorManip.H:139
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)