1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::MapInternalField
28 Generic internal field mapper. For "real" mapping, add template
29 specialisations for mapping of internal fields depending on mesh
32 \*---------------------------------------------------------------------------*/
34 #ifndef MapGeometricFields_H
35 #define MapGeometricFields_H
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 template<class Type, class MeshMapper, class GeoMesh>
45 class MapInternalField
55 const MeshMapper& mapper
60 //- Generic Geometric field mapper.
61 // For "real" mapping, add template specialisations
62 // for mapping of internal fields depending on mesh type.
66 template<class> class PatchField,
70 void MapGeometricFields
72 const MeshMapper& mapper
75 HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields
77 mapper.thisDb().objectRegistry::template
78 lookupClass<GeometricField<Type, PatchField, GeoMesh> >()
81 // It is necessary to enforce that all old-time fields are stored
82 // before the mapping is performed. Otherwise, if the
83 // old-time-level field is mapped before the field itself, sizes
88 typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>::
89 iterator fieldIter = fields.begin();
90 fieldIter != fields.end();
94 GeometricField<Type, PatchField, GeoMesh>& field =
95 const_cast<GeometricField<Type, PatchField, GeoMesh>&>
98 //Note: check can be removed once pointFields are actually stored on
99 // the pointMesh instead of now on the polyMesh!
100 if (&field.mesh() == &mapper.mesh())
102 field.storeOldTimes();
108 typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>::
109 iterator fieldIter = fields.begin();
110 fieldIter != fields.end();
114 GeometricField<Type, PatchField, GeoMesh>& field =
115 const_cast<GeometricField<Type, PatchField, GeoMesh>&>
118 if (&field.mesh() == &mapper.mesh())
122 Info<< "Mapping " << field.typeName << ' ' << field.name()
126 // Map the internal field
127 MapInternalField<Type, MeshMapper, GeoMesh>()
129 field.internalField(),
133 // Map the patch fields
134 forAll(field.boundaryField(), patchi)
136 // Cannot check sizes for patch fields because of
137 // empty fields in FV and because point fields get their size
138 // from the patch which has already been resized
141 field.boundaryField()[patchi].autoMap
143 mapper.boundaryMap()[patchi]
147 field.instance() = field.time().timeName();
149 else if (polyMesh::debug)
151 Info<< "Not mapping " << field.typeName << ' ' << field.name()
152 << " since originating mesh differs from that of mapper."
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace Foam
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 // ************************************************************************* //