lagrangianFieldDecomposerDecomposeFields.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 | Copyright (C) 2011-2016 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  if (particleIndices_.size())
192  {
193  forAll(fields, fieldi)
194  {
195  decomposeField(cloudName, fields[fieldi])().write();
196  }
197  }
198 }
199 
200 
201 template<class GeoField>
203 (
204  const word& cloudName,
205  const PtrList<GeoField>& fields
206 ) const
207 {
208  if (particleIndices_.size())
209  {
210  forAll(fields, fieldi)
211  {
212  decomposeFieldField(cloudName, fields[fieldi])().write();
213  }
214  }
215 }
216 
217 
218 // ************************************************************************* //
const Time & time() const
Return time.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
tmp< CompactIOField< Field< Type >, Type > > decomposeFieldField(const word &cloudName, const CompactIOField< Field< Type >, Type > &field) const
void decomposeFieldFields(const word &cloudName, const PtrList< GeoField > &fields) const
static const char *const typeName
Definition: Field.H:94
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:453
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
const word cloudName(propsDict.lookup("cloudName"))
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:715
static void readFieldFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< CompactIOField< Field< Type >, Type >> > &lagrangianFields)
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:71
tmp< IOField< Type > > decomposeField(const word &cloudName, const IOField< Type > &field) const
Decompose volume field.
void decomposeFields(const word &cloudName, const PtrList< GeoField > &fields) const
A class for managing temporary objects.
Definition: PtrList.H:54
static void readFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< IOField< Type >>> &lagrangianFields)
runTime write()