MapVolFields.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 \*---------------------------------------------------------------------------*/
25 
26 #ifndef MapVolFields_H
27 #define MapVolFields_H
28 
29 #include "GeometricField.H"
30 #include "meshToMesh0.H"
31 #include "IOobjectList.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 template<class Type>
40 (
41  const IOobjectList& objects,
42  const meshToMesh0& meshToMesh0Interp,
43  const meshToMesh0::order& mapOrder
44 )
45 {
46  const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
47  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
48 
50 
51  forAllIter(IOobjectList, fields, fieldIter)
52  {
53  typeIOobject<VolField<Type>> fieldTargetIOobject
54  (
55  fieldIter()->name(),
56  meshTarget.time().name(),
57  meshTarget,
60  );
61 
62  if (fieldTargetIOobject.headerOk())
63  {
64  Info<< " interpolating " << fieldIter()->name() << endl;
65 
66  // Read field fieldSource
67  VolField<Type> fieldSource(*fieldIter(), meshSource);
68 
69  // Read fieldTarget
70  VolField<Type> fieldTarget
71  (
72  fieldTargetIOobject,
73  meshTarget
74  );
75 
76  // Interpolate field
77  meshToMesh0Interp.interpolate
78  (
79  fieldTarget,
80  fieldSource,
81  mapOrder
82  );
83 
84  // Write field
85  fieldTarget.write();
86  }
87  }
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 } // End namespace Foam
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 #endif
98 
99 // ************************************************************************* //
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
Generic GeometricField class.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:406
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:61
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:230
const fvMesh & toMesh() const
Definition: meshToMesh0.H:235
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:144
void interpolate(VolField< Type > &, const VolField< Type > &, order=INTERPOLATE) const
Interpolate volume field.
virtual bool write(const bool write=true) const
Write using setting from DB.
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:531
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
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:230
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
void MapVolFields(const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const meshToMesh0::order &mapOrder)
Definition: MapVolFields.H:40
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
objects