MapConsistentVolFields.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 MapConsistentVolFields_H
27 #define MapConsistentVolFields_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>
40 (
41  const IOobjectList& objects,
42  const meshToMesh0& meshToMesh0Interp,
43  const meshToMesh0::order& mapOrder
44 )
45 {
46  const fvMesh& meshSource = meshToMesh0Interp.fromMesh();
47  const fvMesh& meshTarget = meshToMesh0Interp.toMesh();
48 
50 
51  forAllIter(IOobjectList, fields, fieldIter)
52  {
53  Info<< " interpolating " << fieldIter()->name()
54  << endl;
55 
56  // Read field
57  VolField<Type> fieldSource(*fieldIter(), meshSource);
58 
59  typeIOobject<VolField<Type>> fieldTargetIOobject
60  (
61  fieldIter()->name(),
62  meshTarget.time().name(),
63  meshTarget,
66  );
67 
68  if (fieldTargetIOobject.headerOk())
69  {
70  // Read fieldTarget
71  VolField<Type> fieldTarget
72  (
73  fieldTargetIOobject,
74  meshTarget
75  );
76 
77  // Interpolate field
78  meshToMesh0Interp.interpolate<Type>
79  (
80  fieldTarget,
81  fieldSource,
82  mapOrder
83  );
84 
85  // Write field
86  fieldTarget.write();
87  }
88  else
89  {
90  fieldTargetIOobject.readOpt() = IOobject::NO_READ;
91 
92  // Interpolate field
93  VolField<Type> fieldTarget
94  (
95  fieldTargetIOobject,
96  meshToMesh0Interp.interpolate
97  (
98  fieldSource,
99  mapOrder
100  )
101  );
102 
103  // Write field
104  fieldTarget.write();
105  }
106  }
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace Foam
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 #endif
117 
118 // ************************************************************************* //
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
Generic GeometricField class.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
readOption readOpt() const
Definition: IOobject.H:360
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:406
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:61
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:230
const fvMesh & toMesh() const
Definition: meshToMesh0.H:235
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:144
void interpolate(VolField< Type > &, const VolField< Type > &, order=INTERPOLATE) const
Interpolate volume field.
virtual bool write(const bool write=true) const
Write using setting from DB.
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:531
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:230
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void MapConsistentVolFields(const IOobjectList &objects, const meshToMesh0 &meshToMesh0Interp, const meshToMesh0::order &mapOrder)
messageStream Info
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
objects