1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::MapInternalField
29 Generic internal field mapper. For "real" mapping, add template
30 specialisations for mapping of internal fields depending on mesh
33 \*---------------------------------------------------------------------------*/
35 #ifndef MapGeometricFields_H
36 #define MapGeometricFields_H
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 template<class Type, class MeshMapper, class GeoMesh>
46 class MapInternalField
56 const MeshMapper& mapper
61 //- Generic Geometric field mapper.
62 // For "real" mapping, add template specialisations
63 // for mapping of internal fields depending on mesh type.
67 template<class> class PatchField,
71 void MapGeometricFields
73 const MeshMapper& mapper
76 HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields
78 mapper.thisDb().objectRegistry::lookupClass
79 <GeometricField<Type, PatchField, GeoMesh> >()
82 // It is necessary to enforce that all old-time fields are stored
83 // before the mapping is performed. Otherwise, if the
84 // old-time-level field is mapped before the field itself, sizes
89 typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>::
90 iterator fieldIter = fields.begin();
91 fieldIter != fields.end();
95 GeometricField<Type, PatchField, GeoMesh>& field =
96 const_cast<GeometricField<Type, PatchField, GeoMesh>&>
99 //Note: check can be removed once pointFields are actually stored on
100 // the pointMesh instead of now on the polyMesh!
101 if (&field.mesh() == &mapper.mesh())
103 field.storeOldTimes();
109 typename HashTable<const GeometricField<Type, PatchField, GeoMesh>*>::
110 iterator fieldIter = fields.begin();
111 fieldIter != fields.end();
115 GeometricField<Type, PatchField, GeoMesh>& field =
116 const_cast<GeometricField<Type, PatchField, GeoMesh>&>
119 if (&field.mesh() == &mapper.mesh())
123 Info<< "Mapping " << field.typeName << ' ' << field.name()
127 // Map the internal field
128 MapInternalField<Type, MeshMapper, GeoMesh>()
130 field.internalField(),
134 // Map the patch fields
135 forAll(field.boundaryField(), patchi)
137 // Cannot check sizes for patch fields because of
138 // empty fields in FV and because point fields get their size
139 // from the patch which has already been resized
142 field.boundaryField()[patchi].autoMap
144 mapper.boundaryMap()[patchi]
148 field.instance() = field.time().timeName();
150 else if (polyMesh::debug)
152 Info<< "Not mapping " << field.typeName << ' ' << field.name()
153 << " since originating mesh differs from that of mapper."
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 } // End namespace Foam
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 // ************************************************************************* //