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
29 Hrvoje Jasak, Wikki Ltd. All rights reserved. Copyright Hrvoje Jasak.
31 \*---------------------------------------------------------------------------*/
33 #include "enrichedPatch.H"
34 #include "demandDrivenData.H"
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(enrichedPatch, 0);
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
46 void Foam::enrichedPatch::calcMeshPoints() const
50 FatalErrorIn("void enrichedPatch::calcMeshPoints() const")
51 << "Mesh points already calculated."
55 meshPointsPtr_ = new labelList(pointMap().toc());
56 labelList& mp = *meshPointsPtr_;
62 void Foam::enrichedPatch::calcLocalFaces() const
66 FatalErrorIn("void enrichedPatch::calcLocalFaces() const")
67 << "Local faces already calculated."
71 // Invert mesh points and renumber faces using it
72 const labelList& mp = meshPoints();
74 Map<label> mpLookup(2*mp.size());
78 mpLookup.insert(mp[mpI], mpI);
81 const faceList& faces = enrichedFaces();
83 localFacesPtr_ = new faceList(faces.size());
84 faceList& lf = *localFacesPtr_;
88 const face& f = faces[faceI];
90 face& curlf = lf[faceI];
92 curlf.setSize(f.size());
96 curlf[pointI] = mpLookup.find(f[pointI])();
102 void Foam::enrichedPatch::calcLocalPoints() const
106 FatalErrorIn("void enrichedPatch::calcLocalPoints() const")
107 << "Local points already calculated."
108 << abort(FatalError);
111 const labelList& mp = meshPoints();
113 localPointsPtr_ = new pointField(mp.size());
114 pointField& lp = *localPointsPtr_;
118 lp[i] = pointMap().find(mp[i])();
123 void Foam::enrichedPatch::clearOut()
125 deleteDemandDrivenData(enrichedFacesPtr_);
127 deleteDemandDrivenData(meshPointsPtr_);
128 deleteDemandDrivenData(localFacesPtr_);
129 deleteDemandDrivenData(localPointsPtr_);
130 deleteDemandDrivenData(pointPointsPtr_);
131 deleteDemandDrivenData(masterPointFacesPtr_);
137 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
139 // Construct from components
140 Foam::enrichedPatch::enrichedPatch
142 const primitiveFacePatch& masterPatch,
143 const primitiveFacePatch& slavePatch,
144 const labelList& slavePointPointHits,
145 const labelList& slavePointEdgeHits,
146 const List<objectHit>& slavePointFaceHits
149 masterPatch_(masterPatch),
150 slavePatch_(slavePatch),
153 masterPatch_.meshPoints().size()
154 + slavePatch_.meshPoints().size()
156 pointMapComplete_(false),
157 pointMergeMap_(2*slavePatch_.meshPoints().size()),
158 slavePointPointHits_(slavePointPointHits),
159 slavePointEdgeHits_(slavePointEdgeHits),
160 slavePointFaceHits_(slavePointFaceHits),
161 enrichedFacesPtr_(NULL),
162 meshPointsPtr_(NULL),
163 localFacesPtr_(NULL),
164 localPointsPtr_(NULL),
165 pointPointsPtr_(NULL),
166 masterPointFacesPtr_(NULL),
168 cutFaceMasterPtr_(NULL),
169 cutFaceSlavePtr_(NULL),
170 localCutFacesPtr_(NULL)
174 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
176 Foam::enrichedPatch::~enrichedPatch()
182 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
184 const Foam::labelList& Foam::enrichedPatch::meshPoints() const
191 return *meshPointsPtr_;
195 const Foam::faceList& Foam::enrichedPatch::localFaces() const
202 return *localFacesPtr_;
206 const Foam::pointField& Foam::enrichedPatch::localPoints() const
208 if (!localPointsPtr_)
213 return *localPointsPtr_;
217 const Foam::labelListList& Foam::enrichedPatch::pointPoints() const
219 if (!pointPointsPtr_)
224 return *pointPointsPtr_;
228 bool Foam::enrichedPatch::checkSupport() const
230 const faceList& faces = enrichedFaces();
234 forAll (faces, faceI)
236 const face& curFace = faces[faceI];
238 forAll (curFace, pointI)
240 if (!pointMap().found(curFace[pointI]))
242 WarningIn("void enrichedPatch::checkSupport()")
243 << "Point " << pointI << " of face " << faceI
244 << " global point index: " << curFace[pointI]
245 << " not supported in point map. This is not allowed."
257 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
260 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
263 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
266 // ************************************************************************* //