1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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
27 \*---------------------------------------------------------------------------*/
29 #include "enrichedPatch.H"
30 #include "demandDrivenData.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(enrichedPatch, 0);
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 void Foam::enrichedPatch::calcMeshPoints() const
46 FatalErrorIn("void enrichedPatch::calcMeshPoints() const")
47 << "Mesh points already calculated."
51 meshPointsPtr_ = new labelList(pointMap().toc());
52 labelList& mp = *meshPointsPtr_;
58 void Foam::enrichedPatch::calcLocalFaces() const
62 FatalErrorIn("void enrichedPatch::calcLocalFaces() const")
63 << "Local faces already calculated."
67 // Invert mesh points and renumber faces using it
68 const labelList& mp = meshPoints();
70 Map<label> mpLookup(2*mp.size());
74 mpLookup.insert(mp[mpI], mpI);
77 const faceList& faces = enrichedFaces();
79 localFacesPtr_ = new faceList(faces.size());
80 faceList& lf = *localFacesPtr_;
84 const face& f = faces[faceI];
86 face& curlf = lf[faceI];
88 curlf.setSize(f.size());
92 curlf[pointI] = mpLookup.find(f[pointI])();
98 void Foam::enrichedPatch::calcLocalPoints() const
102 FatalErrorIn("void enrichedPatch::calcLocalPoints() const")
103 << "Local points already calculated."
104 << abort(FatalError);
107 const labelList& mp = meshPoints();
109 localPointsPtr_ = new pointField(mp.size());
110 pointField& lp = *localPointsPtr_;
114 lp[i] = pointMap().find(mp[i])();
119 void Foam::enrichedPatch::clearOut()
121 deleteDemandDrivenData(enrichedFacesPtr_);
123 deleteDemandDrivenData(meshPointsPtr_);
124 deleteDemandDrivenData(localFacesPtr_);
125 deleteDemandDrivenData(localPointsPtr_);
126 deleteDemandDrivenData(pointPointsPtr_);
127 deleteDemandDrivenData(masterPointFacesPtr_);
133 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
135 // Construct from components
136 Foam::enrichedPatch::enrichedPatch
138 const primitiveFacePatch& masterPatch,
139 const primitiveFacePatch& slavePatch,
140 const labelList& slavePointPointHits,
141 const labelList& slavePointEdgeHits,
142 const List<objectHit>& slavePointFaceHits
145 masterPatch_(masterPatch),
146 slavePatch_(slavePatch),
149 masterPatch_.meshPoints().size()
150 + slavePatch_.meshPoints().size()
152 pointMapComplete_(false),
153 pointMergeMap_(2*slavePatch_.meshPoints().size()),
154 slavePointPointHits_(slavePointPointHits),
155 slavePointEdgeHits_(slavePointEdgeHits),
156 slavePointFaceHits_(slavePointFaceHits),
157 enrichedFacesPtr_(NULL),
158 meshPointsPtr_(NULL),
159 localFacesPtr_(NULL),
160 localPointsPtr_(NULL),
161 pointPointsPtr_(NULL),
162 masterPointFacesPtr_(NULL),
164 cutFaceMasterPtr_(NULL),
165 cutFaceSlavePtr_(NULL)
169 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
171 Foam::enrichedPatch::~enrichedPatch()
177 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
179 const Foam::labelList& Foam::enrichedPatch::meshPoints() const
186 return *meshPointsPtr_;
190 const Foam::faceList& Foam::enrichedPatch::localFaces() const
197 return *localFacesPtr_;
201 const Foam::pointField& Foam::enrichedPatch::localPoints() const
203 if (!localPointsPtr_)
208 return *localPointsPtr_;
212 const Foam::labelListList& Foam::enrichedPatch::pointPoints() const
214 if (!pointPointsPtr_)
219 return *pointPointsPtr_;
223 bool Foam::enrichedPatch::checkSupport() const
225 const faceList& faces = enrichedFaces();
229 forAll (faces, faceI)
231 const face& curFace = faces[faceI];
233 forAll (curFace, pointI)
235 if (!pointMap().found(curFace[pointI]))
237 WarningIn("void enrichedPatch::checkSupport()")
238 << "Point " << pointI << " of face " << faceI
239 << " global point index: " << curFace[pointI]
240 << " not supported in point map. This is not allowed."
252 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
255 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
258 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
261 // ************************************************************************* //