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-2018 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, class CombineOp>
39 void MapVolFields
40 (
41  const IOobjectList& objects,
42  const meshToMesh0& meshToMesh0Interp,
43  const meshToMesh0::order& mapOrder,
44  const CombineOp& cop
45 )
46 {
48 
49  const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
50  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
51 
52  IOobjectList fields = objects.lookupClass(fieldType::typeName);
53 
54  forAllIter(IOobjectList, fields, fieldIter)
55  {
56  IOobject fieldTargetIOobject
57  (
58  fieldIter()->name(),
59  meshTarget.time().timeName(),
60  meshTarget,
63  );
64 
65  if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
66  {
67  Info<< " interpolating " << fieldIter()->name() << endl;
68 
69  // Read field fieldSource
70  fieldType fieldSource(*fieldIter(), meshSource);
71 
72  // Read fieldTarget
73  fieldType fieldTarget
74  (
75  fieldTargetIOobject,
76  meshTarget
77  );
78 
79  // Interpolate field
80  meshToMesh0Interp.interpolate
81  (
82  fieldTarget,
83  fieldSource,
84  mapOrder,
85  cop
86  );
87 
88  // Write field
89  fieldTarget.write();
90  }
91  }
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96 
97 } // End namespace Foam
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 #endif
102 
103 // ************************************************************************* //
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:60
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:143
Generic GeometricField class.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:636
Info<< "Calculating turbulent flame speed field St\"<< endl;volScalarField St(IOobject("St", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:228
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:239
const fvMesh & toMesh() const
Definition: meshToMesh0.H:235
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:230
objects
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Definition: IOobjectList.C:192
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
void MapVolFields(const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const meshToMesh0::order &mapOrder, const CombineOp &cop)
Definition: MapVolFields.H:40
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.
void interpolate(GeometricField< Type, fvPatchField, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.