initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / dynamicMesh / slidingInterface / enrichedPatch / enrichedPatch.C
blobdc78fbbfb7f0f4fffbb73d1a03815e86e9f49b61
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "enrichedPatch.H"
30 #include "demandDrivenData.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace Foam
36     defineTypeNameAndDebug(enrichedPatch, 0);
40 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
42 void Foam::enrichedPatch::calcMeshPoints() const
44     if (meshPointsPtr_)
45     {
46         FatalErrorIn("void enrichedPatch::calcMeshPoints() const")
47             << "Mesh points already calculated."
48             << abort(FatalError);
49     }
51     meshPointsPtr_ = new labelList(pointMap().toc());
52     labelList& mp = *meshPointsPtr_;
54     sort(mp);
58 void Foam::enrichedPatch::calcLocalFaces() const
60     if (localFacesPtr_)
61     {
62         FatalErrorIn("void enrichedPatch::calcLocalFaces() const")
63             << "Local faces already calculated."
64             << abort(FatalError);
65     }
67     // Invert mesh points and renumber faces using it
68     const labelList& mp = meshPoints();
70     Map<label> mpLookup(2*mp.size());
72     forAll (mp, mpI)
73     {
74         mpLookup.insert(mp[mpI], mpI);
75     }
77     const faceList& faces = enrichedFaces();
79     localFacesPtr_ = new faceList(faces.size());
80     faceList& lf = *localFacesPtr_;
82     forAll (faces, faceI)
83     {
84         const face& f = faces[faceI];
86         face& curlf = lf[faceI];
88         curlf.setSize(f.size());
90         forAll (f, pointI)
91         {
92             curlf[pointI] = mpLookup.find(f[pointI])();
93         }
94     }
98 void Foam::enrichedPatch::calcLocalPoints() const
100     if (localPointsPtr_)
101     {
102         FatalErrorIn("void enrichedPatch::calcLocalPoints() const")
103             << "Local points already calculated."
104             << abort(FatalError);
105     }
107     const labelList& mp = meshPoints();
109     localPointsPtr_ = new pointField(mp.size());
110     pointField& lp = *localPointsPtr_;
112     forAll (lp, i)
113     {
114         lp[i] = pointMap().find(mp[i])();
115     }
119 void Foam::enrichedPatch::clearOut()
121     deleteDemandDrivenData(enrichedFacesPtr_);
123     deleteDemandDrivenData(meshPointsPtr_);
124     deleteDemandDrivenData(localFacesPtr_);
125     deleteDemandDrivenData(localPointsPtr_);
126     deleteDemandDrivenData(pointPointsPtr_);
127     deleteDemandDrivenData(masterPointFacesPtr_);
129     clearCutFaces();
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),
147     pointMap_
148     (
149         masterPatch_.meshPoints().size()
150       + slavePatch_.meshPoints().size()
151     ),
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),
163     cutFacesPtr_(NULL),
164     cutFaceMasterPtr_(NULL),
165     cutFaceSlavePtr_(NULL)
169 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
171 Foam::enrichedPatch::~enrichedPatch()
173     clearOut();
177 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
179 const Foam::labelList& Foam::enrichedPatch::meshPoints() const
181     if (!meshPointsPtr_)
182     {
183         calcMeshPoints();
184     }
186     return *meshPointsPtr_;
190 const Foam::faceList& Foam::enrichedPatch::localFaces() const
192     if (!localFacesPtr_)
193     {
194         calcLocalFaces();
195     }
197     return *localFacesPtr_;
201 const Foam::pointField& Foam::enrichedPatch::localPoints() const
203     if (!localPointsPtr_)
204     {
205         calcLocalPoints();
206     }
208     return *localPointsPtr_;
212 const Foam::labelListList& Foam::enrichedPatch::pointPoints() const
214     if (!pointPointsPtr_)
215     {
216         calcPointPoints();
217     }
219     return *pointPointsPtr_;
223 bool Foam::enrichedPatch::checkSupport() const
225     const faceList& faces = enrichedFaces();
227     bool error = false;
229     forAll (faces, faceI)
230     {
231         const face& curFace = faces[faceI];
233         forAll (curFace, pointI)
234         {
235             if (!pointMap().found(curFace[pointI]))
236             {
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."
241                     << endl;
243                 error = true;
244             }
245         }
246     }
248     return error;
252 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
255 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
258 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
261 // ************************************************************************* //