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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #ifndef MapVolFields_H
29 #define MapVolFields_H
30 
31 #include "GeometricField.H"
32 #include "meshToMesh0.H"
33 #include "IOobjectList.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 template<class Type, class CombineOp>
41 void MapVolFields
42 (
43  const IOobjectList& objects,
44  const meshToMesh0& meshToMesh0Interp,
45  const meshToMesh0::order& mapOrder,
46  const CombineOp& cop
47 )
48 {
50 
51  const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
52  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
53 
54  IOobjectList fields = objects.lookupClass(fieldType::typeName);
55 
56  forAllConstIters(fields, fieldIter)
57  {
58  IOobject fieldTargetIOobject
59  (
60  (*fieldIter)->name(),
61  meshTarget.time().timeName(),
62  meshTarget,
65  );
66 
67  if (fieldTargetIOobject.typeHeaderOk<fieldType>(true))
68  {
69  Info<< " interpolating " << (*fieldIter)->name() << endl;
70 
71  // Read field fieldSource. Do not auto-load old-time fields
72  fieldType fieldSource(*fieldIter(), meshSource, false);
73 
74  // Read fieldTarget. Do not auto-load old-time fields
75  fieldType fieldTarget
76  (
77  fieldTargetIOobject,
78  meshTarget,
79  false
80  );
81 
82  // Interpolate field
83  meshToMesh0Interp.interpolate
84  (
85  fieldTarget,
86  fieldSource,
87  mapOrder,
88  cop
89  );
90 
91  // Write field
92  fieldTarget.write();
93  }
94  }
95 }
96 
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 #endif
105 
106 // ************************************************************************* //
void interpolate(VolumeField< Type > &, const VolumeField< Type > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
IOobjectList lookupClass(const char *clsName) const
The list of IOobjects with the given headerClassName.
Definition: IOobjectList.C:200
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:61
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:170
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:362
const fvMesh & toMesh() const
Definition: meshToMesh0.H:275
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:270
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
Definition: Time.C:770
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
Automatically write from objectRegistry::writeObject()
messageStream Info
Information stream (stdout output on master, null elsewhere)
void MapVolFields(const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const meshToMesh0::order &mapOrder, const CombineOp &cop)
Definition: MapVolFields.H:35
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28