1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "topoMapper.H"
27 #include "topoCellMapper.H"
28 #include "topoSurfaceMapper.H"
29 #include "topoBoundaryMeshMapper.H"
34 // Conservatively map all volFields in the registry
36 void conservativeMapVolFields(const topoMapper& mapper)
38 // Define a few typedefs for convenience
39 typedef typename outerProduct<vector, Type>::type gCmptType;
40 typedef GeometricField<Type, fvPatchField, volMesh> volType;
41 typedef GeometricField<gCmptType, fvPatchField, volMesh> gradVolType;
43 HashTable<const volType*> fields(mapper.mesh().lookupClass<volType>());
45 // Store old-times before mapping
46 forAllIter(typename HashTable<const volType*>, fields, fIter)
48 fIter()->storeOldTimes();
51 // Fetch internal/boundary mappers
52 const topoCellMapper& fMap = mapper.volMap();
53 const topoBoundaryMeshMapper& bMap = mapper.boundaryMap();
56 forAllIter(typename HashTable<const volType*>, fields, fIter)
58 volType& field = const_cast<volType&>(*fIter());
62 Info<< "Conservatively mapping "
64 << ' ' << field.name()
68 // Map the internal field
72 mapper.gradient<gradVolType>(field.name()).internalField(),
79 bMap[patchI].mapFvPatchField
82 field.boundaryField()[patchI]
86 // Set the field instance
87 field.instance() = field.mesh().thisDb().time().timeName();
92 // Conservatively map all surfaceFields in the registry
94 void conservativeMapSurfaceFields(const topoMapper& mapper)
96 // Define a few typedefs for convenience
97 typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfType;
99 HashTable<const surfType*> fields(mapper.mesh().lookupClass<surfType>());
101 // Store old-times before mapping
102 forAllIter(typename HashTable<const surfType*>, fields, fIter)
104 fIter()->storeOldTimes();
107 // Fetch internal/boundary mappers
108 const topoSurfaceMapper& fMap = mapper.surfaceMap();
109 const topoBoundaryMeshMapper& bMap = mapper.boundaryMap();
111 // Now map all fields
112 forAllIter(typename HashTable<const surfType*>, fields, fIter)
114 surfType& field = const_cast<surfType&>(*fIter());
118 Info<< "Conservatively mapping "
120 << ' ' << field.name()
124 // Map the internal field
125 fMap.mapInternalField
128 field.internalField()
134 bMap[patchI].mapFvsPatchField
137 field.boundaryField()[patchI]
141 // Set the field instance
142 field.instance() = field.mesh().thisDb().time().timeName();
147 } // End namespace Foam
149 // ************************************************************************* //