MeshToMeshMapGeometricFields.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) 2022-2024 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 Class
25  Foam::MeshToMeshMapGeometricFields
26 
27 Description
28  Generic internal field mapper. For "real" mapping, add template
29  specialisations for mapping of internal fields depending on mesh
30  type.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef MeshToMeshMapGeometricFields_H
35 #define MeshToMeshMapGeometricFields_H
36 
37 #include "polyMesh.H"
38 #include "fvMeshToFvMesh.H"
39 #include "fieldMapper.H"
40 #include "setSizeFieldMapper.H"
41 #include "processorPolyPatch.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 template<class Type>
50 (
51  const fvMesh& mesh,
52  const fvMeshToFvMesh& mapper
53 )
54 {
56 
57  forAll(fields, i)
58  {
59  VolField<Type>& field = fields[i];
60 
61  // Delete old time fields
62  field.clearOldTimes();
63 
64  if (fvMeshToFvMesh::debug)
65  {
66  Info<< "Mapping " << field.typeName << ' ' << field.name()
67  << endl;
68  }
69 
70  field.reset(mapper.srcToTgt(field));
71 
72  field.instance() = field.time().name();
73  }
74 }
75 
76 
77 template<class Type>
79 (
80  const fvMesh& mesh,
81  const fvMeshToFvMesh& mapper
82 )
83 {
85  (
87  );
88 
89  forAll(fields, i)
90  {
91  VolInternalField<Type>& field = fields[i];
92 
93  if (fvMeshToFvMesh::debug)
94  {
95  Info<< "Mapping " << field.typeName << ' ' << field.name()
96  << endl;
97  }
98 
99  field.reset(mapper.srcToTgt<Type>(field));
100 
101  field.instance() = field.time().name();
102  }
103 }
104 
105 
106 template<class Type, class GeoMesh>
107 void NaNGeometricFields(const fvMesh& mesh)
108 {
109  typedef GeometricField<Type, GeoMesh> GField;
110 
112 
113  forAll(fields, i)
114  {
115  GField& field = fields[i];
116 
117  // Delete old time fields
118  field.clearOldTimes();
119 
120  if (fvMeshToFvMesh::debug)
121  {
122  Info<< "Setting to NaN " << field.typeName << ' ' << field.name()
123  << endl;
124  }
125 
126  const typename GField::Mesh& mesh = field.mesh();
127 
128  field.primitiveFieldRef().setSize(GeoMesh::size(mesh));
129  field.primitiveFieldRef() = pTraits<Type>::nan;
130 
131  field.boundaryFieldRef().setSize(mesh.boundary().size());
132 
134  {
135  if (isA<processorPolyPatch>(mesh().boundaryMesh()[patchi]))
136  {
137  field.boundaryFieldRef().set
138  (
139  patchi,
141  (
143  mesh.boundary()[patchi],
144  field
145  )
146  );
147  }
148  else
149  {
150  typename GField::Patch& pf = field.boundaryFieldRef()[patchi];
151  pf.map(pf, setSizeFieldMapper(pf.patch().size()));
152  }
153 
154  field.boundaryFieldRef()[patchi] == pTraits<Type>::nan;
155  }
156 
157  field.instance() = field.time().name();
158  }
159 }
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Generic GeometricField class.
void reset(const GeometricField< Type, GeoMesh, PrimitiveField2 > &)
Reset the field contents to the given field.
const Time & time() const
Return time.
Definition: IOobject.C:315
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
Definition: IOobject.C:352
const word & name() const
Return name.
Definition: IOobject.H:307
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:297
void clearOldTimes()
Clear old-time fields.
Definition: OldTimeField.C:276
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via...
const word & name() const
Return const reference to name.
tmp< VolField< Type > > srcToTgt(const VolField< Type > &srcFld) const
Interpolate a source vol field to the target with no left.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:962
UPtrList< GeoField > curFields(const bool strict=false, const HashSet< word > &geometryFields=fvMesh::geometryFields) const
Return the list of current fields of type GeoField.
UPtrList< GeoField > fields(bool strict=false, const HashSet< word > &geometryFields=fvMesh::geometryFields) const
Return the list of fields of type GeoField.
const polyMesh & mesh() const
Return reference to polyMesh.
Definition: fvMesh.H:443
Traits class for primitives.
Definition: pTraits.H:53
Mapper which sets the field size. It does not actually map values.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
label patchi
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:234
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
void MeshToMeshMapVolFields(const fvMesh &mesh, const fvMeshToFvMesh &mapper)
typename VolField< Type >::Internal VolInternalField
Definition: volFieldsFwd.H:59
void NaNGeometricFields(const fvMesh &mesh)
void MeshToMeshMapVolInternalFields(const fvMesh &mesh, const fvMeshToFvMesh &mapper)