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 Implementation of the topoSurfaceMapper class
32 University of Massachusetts Amherst
35 \*---------------------------------------------------------------------------*/
37 #include "topoMapper.H"
38 #include "mapPolyMesh.H"
39 #include "topoSurfaceMapper.H"
40 #include "demandDrivenData.H"
45 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 //- Clear out local storage
48 void topoSurfaceMapper::clearOut()
50 deleteDemandDrivenData(directAddrPtr_);
51 deleteDemandDrivenData(interpolationAddrPtr_);
52 deleteDemandDrivenData(weightsPtr_);
53 deleteDemandDrivenData(insertedFaceLabelsPtr_);
57 //- Calculate the insertedFaceLabels list
58 void topoSurfaceMapper::calcInsertedFaceLabels() const
60 if (insertedFaceLabelsPtr_)
64 "void topoSurfaceMapper::calcInsertedFaceLabels() const"
65 ) << " Inserted labels has already been calculated."
69 // Allocate for inserted face labels
70 label nInsertedFaces = 0;
72 insertedFaceLabelsPtr_ = new labelList(size(), -1);
73 labelList& insertedFaces = *insertedFaceLabelsPtr_;
75 label nIntFaces = size();
77 // Loop through the facesFromFaces map, and ensure that
78 // inserted internal faces are not mapped from any parent faces.
79 const List<objectMap>& fff = mpm_.facesFromFacesMap();
83 const objectMap& fffI = fff[objectI];
85 // Only pick internal faces
86 if (fffI.index() < nIntFaces)
88 insertedFaces[nInsertedFaces++] = fffI.index();
92 // Shorten inserted faces to actual size
93 insertedFaces.setSize(nInsertedFaces);
97 //- Calculate addressing for mapping
98 void topoSurfaceMapper::calcAddressing() const
103 || interpolationAddrPtr_
106 FatalErrorIn("void topoSurfaceMapper::calcAddressing() const")
107 << "Addressing already calculated."
108 << abort(FatalError);
113 // Direct addressing, no weights - slice to size
118 labelList::subList(mpm_.faceMap(), size())
122 labelList& addr = *directAddrPtr_;
124 // Loop through the addressing list,
125 // and set dummy addressing for newly created faces.
136 FatalErrorIn("void topoSurfaceMapper::calcAddressing() const")
137 << " Request for interpolative addressing"
138 << " on internal surface fields. The surfaceMapper"
139 << " is not designed to do this. Interpolate volFields"
140 << " to surfaceFields instead."
141 << abort(FatalError);
146 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148 // Construct from components
149 topoSurfaceMapper::topoSurfaceMapper
151 const mapPolyMesh& mpm,
152 const topoMapper& mapper
159 sizeBeforeMapping_(mpm.nOldInternalFaces()),
160 directAddrPtr_(NULL),
161 interpolationAddrPtr_(NULL),
163 insertedFaceLabelsPtr_(NULL)
165 // Fetch offset sizes from topoMapper
166 const labelList& sizes = tMapper_.faceSizes();
173 sizeBeforeMapping_ += sizes[pI];
177 // Calculate the insertedFaces list
178 calcInsertedFaceLabels();
180 // Set to direct mapping.
184 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
186 topoSurfaceMapper::~topoSurfaceMapper()
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
194 label topoSurfaceMapper::size() const
196 return mesh_.nInternalFaces();
200 //- Return size before mapping
201 label topoSurfaceMapper::sizeBeforeMapping() const
203 return sizeBeforeMapping_;
207 //- Is the mapping direct
208 bool topoSurfaceMapper::direct() const
214 //- Return direct addressing
215 const unallocLabelList& topoSurfaceMapper::directAddressing() const
221 "const unallocLabelList& "
222 "topoSurfaceMapper::directAddressing() const"
223 ) << "Requested direct addressing for an interpolative mapper."
224 << abort(FatalError);
232 return *directAddrPtr_;
236 //- Return interpolation addressing
237 const labelListList& topoSurfaceMapper::addressing() const
243 "const labelListList& "
244 "topoSurfaceMapper::addressing() const"
245 ) << "Requested interpolative addressing for a direct mapper."
246 << abort(FatalError);
249 if (!interpolationAddrPtr_)
254 return *interpolationAddrPtr_;
259 const scalarListList& topoSurfaceMapper::weights() const
265 "const scalarListList& "
266 "topoSurfaceMapper::weights() const"
267 ) << "Requested interpolative weights for a direct mapper."
268 << abort(FatalError);
280 //- Are there any inserted faces
281 bool topoSurfaceMapper::insertedObjects() const
283 return insertedObjectLabels().size();
287 //- Return list of inserted faces
288 const labelList& topoSurfaceMapper::insertedObjectLabels() const
290 if (!insertedFaceLabelsPtr_)
292 calcInsertedFaceLabels();
295 return *insertedFaceLabelsPtr_;
299 //- Return flux flip map
300 const labelHashSet& topoSurfaceMapper::flipFaceFlux() const
302 return mpm_.flipFaceFlux();
306 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
308 void topoSurfaceMapper::operator=(const topoSurfaceMapper& rhs)
310 // Check for assignment to self
313 FatalErrorIn("void topoSurfaceMapper::operator=")
314 << "Attempted assignment to self"
315 << abort(FatalError);
319 } // End namespace Foam
321 // ************************************************************************* //