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 -------------------------------------------------------------------------------
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 #include "IOField.H"
29 
30 template<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]);
52  {
54  (
55  fieldName,
56  subField.component(d),
57  binWidth,
58  i
59  );
60  }
61  }
62  }
63  else
64  {
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 // ************************************************************************* //
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
rDeltaTY field()
uint8_t direction
Definition: direction.H:46
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
void generateDistribution(const word &fieldName, const scalarField &field, const scalar binWidth, const label tag=-1)
Generate the distribution.
bool processField(const objectRegistry &obr, const label fieldi, const List< DynamicList< label >> &addr)
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
::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
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:608
List< Tuple2< word, scalar > > nameVsBinWidth_
List of field name vs. bin width.
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
Registry of regIOobjects.
A primitive field of type <T> with automated input and output.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.