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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
meshToMesh0.H
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::meshToMesh0::interpolate
void interpolate(GeometricField< Type, fvPatchField, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.
Definition: meshToMesh0Templates.C:249
Foam::meshToMesh0::order
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:147
Foam::meshToMesh0::fromMesh
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:233
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
Foam::MapVolFields
void MapVolFields(const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const meshToMesh0::order &mapOrder, const CombineOp &cop)
Definition: MapVolFields.H:42
GeometricField.H
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::meshToMesh0
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:65
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::IOobjectList::lookupClass
IOobjectList lookupClass(const char *clsName) const
The list of IOobjects with the given headerClassName.
Definition: IOobjectList.C:290
fields
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
Foam::IOobject::MUST_READ
Definition: IOobject.H:185
Foam::meshToMesh0::toMesh
const fvMesh & toMesh() const
Definition: meshToMesh0.H:238