particleDistributionTemplates.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) 2016 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
30template<class Type>
32(
33 const objectRegistry& obr,
34 const label fieldi,
35 const List<DynamicList<label>>& addr
36)
37{
38 const word& fieldName = nameVsBinWidth_[fieldi].first();
39 const scalar binWidth = nameVsBinWidth_[fieldi].second();
40
41 if (obr.foundObject<IOField<Type>>(fieldName))
42 {
43 const IOField<Type>& field =
44 obr.lookupObject<IOField<Type>>(fieldName);
45
46 if (addr.size())
47 {
48 forAll(addr, i)
49 {
50 const Field<Type> subField(field, addr[i]);
51 for (direction d = 0; d < pTraits<Type>::nComponents; ++d)
52 {
54 (
55 fieldName,
56 subField.component(d),
57 binWidth,
58 i
59 );
60 }
61 }
62 }
63 else
64 {
65 for (direction d = 0; d < pTraits<Type>::nComponents; ++d)
66 {
67 const word fName = fieldName + pTraits<Type>::componentNames[d];
68 generateDistribution(fName, field.component(d), binWidth);
69 }
70 }
71
72 return true;
73 }
74
75 return false;
76}
77
78
79// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Generic templated field type.
Definition: Field.H:82
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:545
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
List< Tuple2< word, scalar > > nameVsBinWidth_
List of field name vs. bin width.
bool processField(const objectRegistry &obr, const label fieldi, const List< DynamicList< label > > &addr)
void generateDistribution(const word &fieldName, const scalarField &field, const scalar binWidth, const label tag=-1)
Generate the distribution.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
Registry of regIOobjects.
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
const Type & lookupObject(const word &name, const bool recursive=false) const
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaTY field()
uint8_t direction
Definition: direction.H:56
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333