MapVolFields.H
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-2015 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 {
47  const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
48  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
49 
50  word fieldClassName
51  (
53  );
54 
55  IOobjectList fields = objects.lookupClass(fieldClassName);
56 
57  forAllIter(IOobjectList, fields, fieldIter)
58  {
59  IOobject fieldTargetIOobject
60  (
61  fieldIter()->name(),
62  meshTarget.time().timeName(),
63  meshTarget,
66  );
67 
68  if (fieldTargetIOobject.headerOk())
69  {
70  Info<< " interpolating " << fieldIter()->name()
71  << endl;
72 
73  // Read field fieldSource
75  (
76  *fieldIter(),
77  meshSource
78  );
79 
80  // Read fieldTarget
82  (
83  fieldTargetIOobject,
84  meshTarget
85  );
86 
87  // Interpolate field
88  meshToMesh0Interp.interpolate
89  (
90  fieldTarget,
91  fieldSource,
92  mapOrder,
93  cop
94  );
95 
96  // Write field
97  fieldTarget.write();
98  }
99  }
100 }
101 
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 } // End namespace Foam
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 #endif
110 
111 // ************************************************************************* //
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Definition: IOobjectList.C:197
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:229
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
void interpolate(GeometricField< Type, fvPatchField, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:453
mesh to mesh interpolation class.
Definition: meshToMesh0.H:63
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:142
Generic GeometricField class.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:715
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
const fvMesh & toMesh() const
Definition: meshToMesh0.H:234
A class for handling words, derived from string.
Definition: word.H:59
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual bool write() const
Write using setting from DB.
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:91
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243