MapLagrangianFields.H
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-2022 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 InNamespace
25  Foam
26 
27 Description
28  Gets the indices of (source)particles that have been appended to the
29  target cloud and maps the lagrangian fields accordingly.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef MapLagrangianFields_H
34 #define MapLagrangianFields_H
35 
36 #include "cloud.H"
37 #include "GeometricField.H"
38 #include "meshToMesh0.H"
39 #include "IOobjectList.H"
40 #include "CompactIOField.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 //- Gets the indices of (source)particles that have been appended to the
48 // target cloud and maps the lagrangian fields accordingly.
49 template<class Type>
51 (
52  const string& cloudName,
53  const IOobjectList& objects,
54  const meshToMesh0& meshToMesh0Interp,
55  const labelList& addParticles
56 )
57 {
58  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
59 
60  {
62 
63  forAllIter(IOobjectList, fields, fieldIter)
64  {
65  Info<< " mapping lagrangian field "
66  << fieldIter()->name() << endl;
67 
68  // Read field (does not need mesh)
69  IOField<Type> fieldSource(*fieldIter());
70 
71  // Map
72  IOField<Type> fieldTarget
73  (
74  IOobject
75  (
76  fieldIter()->name(),
77  meshTarget.time().name(),
79  meshTarget,
82  false
83  ),
84  addParticles.size()
85  );
86 
87  forAll(addParticles, i)
88  {
89  fieldTarget[i] = fieldSource[addParticles[i]];
90  }
91 
92  // Write field
93  fieldTarget.write();
94  }
95  }
96 
97  {
98  IOobjectList fieldFields =
99  objects.lookupClass(IOField<Field<Type>>::typeName);
100 
101  forAllIter(IOobjectList, fieldFields, fieldIter)
102  {
103  Info<< " mapping lagrangian fieldField "
104  << fieldIter()->name() << endl;
105 
106  // Read field (does not need mesh)
107  IOField<Field<Type>> fieldSource(*fieldIter());
108 
109  // Map - use CompactIOField to automatically write in
110  // compact form for binary format.
111  CompactIOField<Field<Type>> fieldTarget
112  (
113  IOobject
114  (
115  fieldIter()->name(),
116  meshTarget.time().name(),
118  meshTarget,
121  false
122  ),
123  addParticles.size()
124  );
125 
126  forAll(addParticles, i)
127  {
128  fieldTarget[i] = fieldSource[addParticles[i]];
129  }
130 
131  // Write field
132  fieldTarget.write();
133  }
134  }
135 
136  {
137  IOobjectList fieldFields =
138  objects.lookupClass(CompactIOField<Field<Type>>::typeName);
139 
140  forAllIter(IOobjectList, fieldFields, fieldIter)
141  {
142  Info<< " mapping lagrangian fieldField "
143  << fieldIter()->name() << endl;
144 
145  // Read field (does not need mesh)
146  CompactIOField<Field<Type>> fieldSource(*fieldIter());
147 
148  // Map
149  CompactIOField<Field<Type>> fieldTarget
150  (
151  IOobject
152  (
153  fieldIter()->name(),
154  meshTarget.time().name(),
156  meshTarget,
159  false
160  ),
161  addParticles.size()
162  );
163 
164  forAll(addParticles, i)
165  {
166  fieldTarget[i] = fieldSource[addParticles[i]];
167  }
168 
169  // Write field
170  fieldTarget.write();
171  }
172  }
173 }
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
A Field of objects of type <Type> with automated input and output using a compact storage....
Pre-declare SubField and related Field type.
Definition: Field.H:83
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:63
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:418
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:60
const fvMesh & toMesh() const
Definition: meshToMesh0.H:186
virtual bool write(const bool write=true) const
Write using setting from DB.
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:228
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
messageStream Info
void MapLagrangianFields(const string &cloudName, const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const labelList &addParticles)
Gets the indices of (source)particles that have been appended to the.
objects
const word cloudName(propsDict.lookup("cloudName"))