All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lagrangianFieldDecomposerDecomposeFields.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "IOobjectList.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const label cloudI,
35  const IOobjectList& lagrangianObjects,
36  PtrList<PtrList<IOField<Type>>>& lagrangianFields
37 )
38 {
39  // Search list of objects for lagrangian fields
40  IOobjectList lagrangianTypeObjects
41  (
42  lagrangianObjects.lookupClass(IOField<Type>::typeName)
43  );
44 
45  lagrangianFields.set
46  (
47  cloudI,
48  new PtrList<IOField<Type>>
49  (
50  lagrangianTypeObjects.size()
51  )
52  );
53 
54  label lagrangianFieldi = 0;
55  forAllIter(IOobjectList, lagrangianTypeObjects, iter)
56  {
57  lagrangianFields[cloudI].set
58  (
59  lagrangianFieldi++,
60  new IOField<Type>(*iter())
61  );
62  }
63 }
64 
65 
66 template<class Type>
68 (
69  const label cloudI,
70  const IOobjectList& lagrangianObjects,
71  PtrList<PtrList<CompactIOField<Field<Type>, Type>>>& lagrangianFields
72 )
73 {
74  // Search list of objects for lagrangian fields
75  IOobjectList lagrangianTypeObjectsA
76  (
77  lagrangianObjects.lookupClass(IOField<Field<Type>>::typeName)
78  );
79 
80  IOobjectList lagrangianTypeObjectsB
81  (
82  lagrangianObjects.lookupClass
83  (
84  CompactIOField<Field<Type>,
85  Type>::typeName
86  )
87  );
88 
89  lagrangianFields.set
90  (
91  cloudI,
92  new PtrList<CompactIOField<Field<Type>, Type>>
93  (
94  lagrangianTypeObjectsA.size() + lagrangianTypeObjectsB.size()
95  )
96  );
97 
98  label lagrangianFieldi = 0;
99 
100  forAllIter(IOobjectList, lagrangianTypeObjectsA, iter)
101  {
102  lagrangianFields[cloudI].set
103  (
104  lagrangianFieldi++,
105  new CompactIOField<Field<Type>, Type>(*iter())
106  );
107  }
108 
109  forAllIter(IOobjectList, lagrangianTypeObjectsB, iter)
110  {
111  lagrangianFields[cloudI].set
112  (
113  lagrangianFieldi++,
114  new CompactIOField<Field<Type>, Type>(*iter())
115  );
116  }
117 }
118 
119 
120 template<class Type>
123 (
124  const word& cloudName,
125  const IOField<Type>& field
126 ) const
127 {
128  // Create and map the internal field values
129  Field<Type> procField(field, particleIndices_);
130 
131  // Create the field for the processor
132  return tmp<IOField<Type>>
133  (
134  new IOField<Type>
135  (
136  IOobject
137  (
138  field.name(),
139  procMesh_.time().timeName(),
141  procMesh_,
144  false
145  ),
146  procField
147  )
148  );
149 }
150 
151 
152 template<class Type>
153 Foam::tmp<Foam::CompactIOField<Foam::Field<Type>, Type>>
155 (
156  const word& cloudName,
157  const CompactIOField<Field<Type>, Type>& field
158 ) const
159 {
160  // Create and map the internal field values
161  Field<Field<Type>> procField(field, particleIndices_);
162 
163  // Create the field for the processor
164  return tmp<CompactIOField<Field<Type>, Type>>
165  (
166  new CompactIOField<Field<Type>, Type>
167  (
168  IOobject
169  (
170  field.name(),
171  procMesh_.time().timeName(),
173  procMesh_,
176  false
177  ),
178  procField
179  )
180  );
181 }
182 
183 
184 template<class GeoField>
186 (
187  const word& cloudName,
188  const PtrList<GeoField>& fields
189 ) const
190 {
191  const bool write = particleIndices_.size() > 0;
192  forAll(fields, fieldi)
193  {
194  decomposeField(cloudName, fields[fieldi])().write(write);
195  }
196 }
197 
198 
199 template<class GeoField>
201 (
202  const word& cloudName,
203  const PtrList<GeoField>& fields
204 ) const
205 {
206  const bool write = particleIndices_.size() > 0;
207  forAll(fields, fieldi)
208  {
209  decomposeFieldField(cloudName, fields[fieldi])().write(write);
210  }
211 }
212 
213 
214 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static const char *const typeName
Definition: Field.H:105
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
void decomposeFieldFields(const word &cloudName, const PtrList< GeoField > &fields) const
tmp< IOField< Type > > decomposeField(const word &cloudName, const IOField< Type > &field) const
Decompose volume field.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:622
static void readFieldFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< CompactIOField< Field< Type >, Type >> > &lagrangianFields)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
const Time & time() const
Return time.
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:62
void decomposeFields(const word &cloudName, const PtrList< GeoField > &fields) const
const word cloudName(propsDict.lookup("cloudName"))
A class for managing temporary objects.
Definition: PtrList.H:53
static void readFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< IOField< Type >>> &lagrangianFields)
tmp< CompactIOField< Field< Type >, Type > > decomposeFieldField(const word &cloudName, const CompactIOField< Field< Type >, Type > &field) const