Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / dynamicMesh / polyMeshModifiers / slidingInterface / enrichedPatch / enrichedPatch.C
blobd257dad545adff5b7a53823e113c46fa6d7d81c7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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
26     Enriched patch
28 Author
29     Hrvoje Jasak, Wikki Ltd.  All rights reserved.  Copyright Hrvoje Jasak.
31 \*---------------------------------------------------------------------------*/
33 #include "enrichedPatch.H"
34 #include "demandDrivenData.H"
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 namespace Foam
40     defineTypeNameAndDebug(enrichedPatch, 0);
44 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
46 void Foam::enrichedPatch::calcMeshPoints() const
48     if (meshPointsPtr_)
49     {
50         FatalErrorIn("void enrichedPatch::calcMeshPoints() const")
51             << "Mesh points already calculated."
52             << abort(FatalError);
53     }
55     meshPointsPtr_ = new labelList(pointMap().toc());
56     labelList& mp = *meshPointsPtr_;
58     sort(mp);
62 void Foam::enrichedPatch::calcLocalFaces() const
64     if (localFacesPtr_)
65     {
66         FatalErrorIn("void enrichedPatch::calcLocalFaces() const")
67             << "Local faces already calculated."
68             << abort(FatalError);
69     }
71     // Invert mesh points and renumber faces using it
72     const labelList& mp = meshPoints();
74     Map<label> mpLookup(2*mp.size());
76     forAll (mp, mpI)
77     {
78         mpLookup.insert(mp[mpI], mpI);
79     }
81     const faceList& faces = enrichedFaces();
83     localFacesPtr_ = new faceList(faces.size());
84     faceList& lf = *localFacesPtr_;
86     forAll (faces, faceI)
87     {
88         const face& f = faces[faceI];
90         face& curlf = lf[faceI];
92         curlf.setSize(f.size());
94         forAll (f, pointI)
95         {
96             curlf[pointI] = mpLookup.find(f[pointI])();
97         }
98     }
102 void Foam::enrichedPatch::calcLocalPoints() const
104     if (localPointsPtr_)
105     {
106         FatalErrorIn("void enrichedPatch::calcLocalPoints() const")
107             << "Local points already calculated."
108             << abort(FatalError);
109     }
111     const labelList& mp = meshPoints();
113     localPointsPtr_ = new pointField(mp.size());
114     pointField& lp = *localPointsPtr_;
116     forAll (lp, i)
117     {
118         lp[i] = pointMap().find(mp[i])();
119     }
123 void Foam::enrichedPatch::clearOut()
125     deleteDemandDrivenData(enrichedFacesPtr_);
127     deleteDemandDrivenData(meshPointsPtr_);
128     deleteDemandDrivenData(localFacesPtr_);
129     deleteDemandDrivenData(localPointsPtr_);
130     deleteDemandDrivenData(pointPointsPtr_);
131     deleteDemandDrivenData(masterPointFacesPtr_);
133     clearCutFaces();
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),
151     pointMap_
152     (
153         masterPatch_.meshPoints().size()
154       + slavePatch_.meshPoints().size()
155     ),
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),
167     cutFacesPtr_(NULL),
168     cutFaceMasterPtr_(NULL),
169     cutFaceSlavePtr_(NULL),
170     localCutFacesPtr_(NULL)
174 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
176 Foam::enrichedPatch::~enrichedPatch()
178     clearOut();
182 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
184 const Foam::labelList& Foam::enrichedPatch::meshPoints() const
186     if (!meshPointsPtr_)
187     {
188         calcMeshPoints();
189     }
191     return *meshPointsPtr_;
195 const Foam::faceList& Foam::enrichedPatch::localFaces() const
197     if (!localFacesPtr_)
198     {
199         calcLocalFaces();
200     }
202     return *localFacesPtr_;
206 const Foam::pointField& Foam::enrichedPatch::localPoints() const
208     if (!localPointsPtr_)
209     {
210         calcLocalPoints();
211     }
213     return *localPointsPtr_;
217 const Foam::labelListList& Foam::enrichedPatch::pointPoints() const
219     if (!pointPointsPtr_)
220     {
221         calcPointPoints();
222     }
224     return *pointPointsPtr_;
228 bool Foam::enrichedPatch::checkSupport() const
230     const faceList& faces = enrichedFaces();
232     bool error = false;
234     forAll (faces, faceI)
235     {
236         const face& curFace = faces[faceI];
238         forAll (curFace, pointI)
239         {
240             if (!pointMap().found(curFace[pointI]))
241             {
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."
246                     << endl;
248                 error = true;
249             }
250         }
251     }
253     return error;
257 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
260 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
263 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
266 // ************************************************************************* //