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>
39 void MapVolFields
40 (
41  const IOobjectList& objects,
42  const meshToMesh0& meshToMesh0Interp,
43  const meshToMesh0::order& mapOrder
44 )
45 {
47 
48  const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
49  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
50 
51  IOobjectList fields = objects.lookupClass(fieldType::typeName);
52 
53  forAllIter(IOobjectList, fields, fieldIter)
54  {
55  typeIOobject<fieldType> fieldTargetIOobject
56  (
57  fieldIter()->name(),
58  meshTarget.time().timeName(),
59  meshTarget,
62  );
63 
64  if (fieldTargetIOobject.headerOk())
65  {
66  Info<< " interpolating " << fieldIter()->name() << endl;
67 
68  // Read field fieldSource
69  fieldType fieldSource(*fieldIter(), meshSource);
70 
71  // Read fieldTarget
72  fieldType fieldTarget
73  (
74  fieldTargetIOobject,
75  meshTarget
76  );
77 
78  // Interpolate field
79  meshToMesh0Interp.interpolate
80  (
81  fieldTarget,
82  fieldSource,
83  mapOrder
84  );
85 
86  // Write field
87  fieldTarget.write();
88  }
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 } // End namespace Foam
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 #endif
100 
101 // ************************************************************************* //
void MapVolFields(const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const meshToMesh0::order &mapOrder)
Definition: MapVolFields.H:40
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
Templated form of IOobject providing type information for file reading and header type checking...
Definition: IOobject.H:537
#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.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:372
const fvMesh & toMesh() const
Definition: meshToMesh0.H:235
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
Definition: Time.C:666
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:190
Info<< "Reading field p_rgh\"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, p_rgh, pimple.dict(), thermo.incompressible());mesh.schemes().setFluxRequired(p_rgh.name());hydrostaticInitialisation(p_rgh, p, rho, U, gh, ghf, pRef, thermo, pimple.dict());Info<< "Creating field dpdt\"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar(p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\"<< endl;volScalarField K("K", 0.5 *magSqr(U));dimensionedScalar initialMass=fvc::domainIntegrate(rho);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:131
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
messageStream Info
void interpolate(GeometricField< Type, fvPatchField, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &, order=INTERPOLATE) const
Interpolate volume field.
Namespace for OpenFOAM.