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/>.
28 Class holds all necessary information for mapping fields associated with
29 dynamicTopoFvMesh and fvMesh.
33 University of Massachusetts Amherst
39 \*---------------------------------------------------------------------------*/
48 #include "volFields.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Class forward declarations
58 class topoSurfaceMapper;
59 class topoBoundaryMeshMapper;
61 /*---------------------------------------------------------------------------*\
62 Class topoMapper Declaration
63 \*---------------------------------------------------------------------------*/
69 typedef Tuple2<word, label> GradientMap;
70 typedef HashTable<GradientMap> GradientTable;
74 //- Reference to fvMesh
77 //- Reference to the options dictionary
78 const dictionary& dict_;
80 // Demand-driven private data
83 mutable autoPtr<topoCellMapper> cellMap_;
86 mutable autoPtr<topoSurfaceMapper> surfaceMap_;
89 mutable autoPtr<topoBoundaryMeshMapper> boundaryMap_;
92 mutable autoPtr<fluxCorrector> fluxCorrector_;
94 // Index map for gradients
95 mutable GradientTable gradTable_;
97 // Stored gradients for mapping
98 mutable PtrList<volVectorField> sGradPtrs_;
99 mutable PtrList<volTensorField> vGradPtrs_;
101 //- Geometric information on the old mesh
102 mutable scalarField* cellVolumesPtr_;
103 mutable volVectorField* cellCentresPtr_;
105 //- Intersection weights
106 mutable List<scalarField> faceWeights_;
107 mutable List<scalarField> cellWeights_;
109 //- Intersection centres
110 mutable List<vectorField> faceCentres_;
111 mutable List<vectorField> cellCentres_;
113 //- Sizes / starts for mapping
114 mutable labelList cellSizes_;
115 mutable labelList cellStarts_;
116 mutable labelList faceSizes_;
117 mutable labelList faceStarts_;
118 mutable labelListList patchSizes_;
119 mutable labelListList patchStarts_;
121 // Private Member Functions
123 //- Disallow default bitwise copy construct
124 topoMapper(const topoMapper&);
126 //- Disallow default bitwise assignment
127 void operator=(const topoMapper&);
129 // Store gradients of volFields on the mesh
130 // prior to topology changes
131 template <class Type, class gradType>
134 GradientTable& gradTable,
135 PtrList<gradType>& gradList
138 //- Store gradients prior to mesh reset
139 void storeGradients() const;
141 //- Set geometric information
142 void storeGeometry() const;
148 //- Construct from mesh and dictionary
149 topoMapper(const fvMesh& mesh, const dictionary& dict);
157 //- Return reference to the mesh
158 const fvMesh& mesh() const;
160 //- Return reference to objectRegistry storing fields.
161 const objectRegistry& thisDb() const;
163 //- Set mapping information
164 void setMapper(const mapPolyMesh& mpm) const;
166 //- Set face weighting information
169 const Xfer<List<scalarField> >& weights,
170 const Xfer<List<vectorField> >& centres
173 //- Set cell weighting information
176 const Xfer<List<scalarField> >& weights,
177 const Xfer<List<vectorField> >& centres
180 //- Set cell / patch offset information
183 const labelList& cellSizes,
184 const labelList& cellStarts,
185 const labelList& faceSizes,
186 const labelList& faceStarts,
187 const labelListList& patchSizes,
188 const labelListList& patchStarts
191 //- Fetch face weights
192 const List<scalarField>& faceWeights() const;
194 //- Fetch cell weights
195 const List<scalarField>& cellWeights() const;
197 //- Fetch face centres
198 const List<vectorField>& faceCentres() const;
200 //- Fetch cell centres
201 const List<vectorField>& cellCentres() const;
204 const labelList& cellSizes() const;
207 const labelList& faceSizes() const;
209 //- Fetch patch sizes
210 const labelListList& patchSizes() const;
212 //- Fetch cell starts
213 const labelList& cellStarts() const;
215 //- Fetch face starts
216 const labelList& faceStarts() const;
218 //- Fetch patch starts
219 const labelListList& patchStarts() const;
221 //- Store mesh information for the mapping stage
222 void storeMeshInformation() const;
224 //- Deregister gradient fields and centres,
225 // but retain for mapping
226 void deregisterMeshInformation() const;
228 //- Return non-const access to cell centres
229 volVectorField& volCentres() const;
231 //- Return non-const access to cell volumes
232 scalarField& internalVolumes() const;
234 //- Return stored cell centre information
235 const vectorField& internalCentres() const;
237 //- Return stored patch centre information
238 const vectorField& patchCentres(const label i) const;
240 //- Return names of stored gradients
241 const wordList gradientTable() const;
243 //- Fetch the gradient field
244 template <class Type>
245 Type& gradient(const word& name) const;
247 //- Correct fluxes after topology change
248 void correctFluxes() const;
250 //- Return volume mapper
251 const topoCellMapper& volMap() const;
253 //- Return surface mapper
254 const topoSurfaceMapper& surfaceMap() const;
256 //- Return boundary mapper
257 const topoBoundaryMeshMapper& boundaryMap() const;
259 //- Return flux-corrector
260 const fluxCorrector& surfaceFluxCorrector() const;
262 //- Clear out member data
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 } // End namespace Foam
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 # include "topoMapperTemplates.C"
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 // ************************************************************************* //