1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
28 \*---------------------------------------------------------------------------*/
30 #include "fvSurfaceMapper.H"
32 #include "mapPolyMesh.H"
33 #include "faceMapper.H"
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 void Foam::fvSurfaceMapper::calcAddressing() const
42 || interpolationAddrPtr_
44 || insertedObjectLabelsPtr_
47 FatalErrorIn("void fvSurfaceMapper::calcAddressing() const)")
48 << "Addressing already calculated"
54 const label oldNInternal = faceMap_.nOldInternalFaces();
59 // Direct mapping - slice to size
63 labelList::subList(faceMap_.directAddressing(), size())
65 labelList& addr = *directAddrPtr_;
67 // Adjust for creation of an internal face from a boundary face
70 if (addr[faceI] >= oldNInternal)
78 // Interpolative mapping - slice to size
79 interpolationAddrPtr_ =
82 labelListList::subList(faceMap_.addressing(), size())
84 labelListList& addr = *interpolationAddrPtr_;
89 scalarListList::subList(faceMap_.weights(), size())
91 scalarListList& w = *weightsPtr_;
93 // Adjust for creation of an internal face from a boundary face
96 if (max(addr[faceI]) >= oldNInternal)
98 addr[faceI] = labelList(1, 0);
99 w[faceI] = scalarList(1, 1.0);
106 // If there are, assemble the labels
107 if (insertedObjects())
109 const labelList& insFaces = faceMap_.insertedObjectLabels();
111 insertedObjectLabelsPtr_ = new labelList(insFaces.size());
112 labelList& ins = *insertedObjectLabelsPtr_;
116 forAll (insFaces, faceI)
118 // If the face is internal, keep it here
119 if (insFaces[faceI] < size())
121 ins[nIns] = insFaces[faceI];
130 // No inserted objects
131 insertedObjectLabelsPtr_ = new labelList(0);
136 void Foam::fvSurfaceMapper::clearOut()
138 deleteDemandDrivenData(directAddrPtr_);
139 deleteDemandDrivenData(interpolationAddrPtr_);
140 deleteDemandDrivenData(weightsPtr_);
142 deleteDemandDrivenData(insertedObjectLabelsPtr_);
146 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148 // Construct from components
149 Foam::fvSurfaceMapper::fvSurfaceMapper
152 const faceMapper& fMapper
157 directAddrPtr_(NULL),
158 interpolationAddrPtr_(NULL),
160 insertedObjectLabelsPtr_(NULL)
164 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
166 Foam::fvSurfaceMapper::~fvSurfaceMapper()
172 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
174 const Foam::unallocLabelList& Foam::fvSurfaceMapper::directAddressing() const
180 "const unallocLabelList& fvSurfaceMapper::"
181 "directAddressing() const"
182 ) << "Requested direct addressing for an interpolative mapper."
183 << abort(FatalError);
191 return *directAddrPtr_;
195 const Foam::labelListList& Foam::fvSurfaceMapper::addressing() const
201 "const labelListList& fvSurfaceMapper::addressing() const"
202 ) << "Requested interpolative addressing for a direct mapper."
203 << abort(FatalError);
206 if (!interpolationAddrPtr_)
211 return *interpolationAddrPtr_;
215 const Foam::scalarListList& Foam::fvSurfaceMapper::weights() const
221 "const scalarListList& fvSurfaceMapper::weights() const"
222 ) << "Requested interpolative weights for a direct mapper."
223 << abort(FatalError);
235 const Foam::labelList& Foam::fvSurfaceMapper::insertedObjectLabels() const
237 if (!insertedObjectLabelsPtr_)
242 return *insertedObjectLabelsPtr_;
246 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
249 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
252 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
255 // ************************************************************************* //