1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "enrichedPatch.H"
27 #include "primitiveMesh.H"
28 #include "demandDrivenData.H"
29 #include "DynamicList.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 const Foam::label Foam::enrichedPatch::nFaceHits_ = 4;
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 void Foam::enrichedPatch::calcMasterPointFaces() const
39 if (masterPointFacesPtr_)
41 FatalErrorIn("void enrichedPatch::calcMasterPointFaces() const")
42 << "Master point face addressing already calculated."
47 // Master point face addressing lists the master faces for all points
48 // in the enriched patch support (if there are no master faces, which is
49 // normal, the list will be empty). The index represents the index of
50 // the master face rather than the index from the enriched patch
51 // Master face points lists the points of the enriched master face plus
52 // points projected into the master face
54 Map<DynamicList<label> > mpf(meshPoints().size());
56 const faceList& ef = enrichedFaces();
58 // Add the original face points
59 forAll(masterPatch_, faceI)
61 const face& curFace = ef[faceI + slavePatch_.size()];
62 // Pout<< "Cur face in pfAddr: " << curFace << endl;
63 forAll(curFace, pointI)
65 Map<DynamicList<label> >::iterator mpfIter =
66 mpf.find(curFace[pointI]);
68 if (mpfIter == mpf.end())
70 // Not found, add new dynamic list
74 DynamicList<label>(primitiveMesh::facesPerPoint_)
77 // Iterator is invalidated - have to find again
78 mpf.find(curFace[pointI])().append(faceI);
82 mpfIter().append(faceI);
87 // Add the projected points which hit the face
88 const labelList& slaveMeshPoints = slavePatch_.meshPoints();
90 forAll(slavePointFaceHits_, pointI)
94 slavePointPointHits_[pointI] < 0
95 && slavePointEdgeHits_[pointI] < 0
96 && slavePointFaceHits_[pointI].hit()
99 // Get the index of projected point corresponding to this slave
101 const label mergedSmp =
102 pointMergeMap().find(slaveMeshPoints[pointI])();
104 Map<DynamicList<label> >::iterator mpfIter =
107 if (mpfIter == mpf.end())
109 // Not found, add new dynamic list
113 DynamicList<label>(primitiveMesh::facesPerPoint_)
116 // Iterator is invalidated - have to find again
117 mpf.find(mergedSmp)().append
119 slavePointFaceHits_[pointI].hitObject()
124 mpfIter().append(slavePointFaceHits_[pointI].hitObject());
129 // Re-pack dynamic lists into normal lists
130 const labelList mpfToc = mpf.toc();
132 masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size());
133 Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_;
135 forAll(mpfToc, mpfTocI)
138 l.transfer(mpf.find(mpfToc[mpfTocI])());
140 masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
142 // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl;
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
148 const Foam::Map<Foam::labelList>& Foam::enrichedPatch::masterPointFaces() const
150 if (!masterPointFacesPtr_)
152 calcMasterPointFaces();
155 return *masterPointFacesPtr_;
159 // ************************************************************************* //