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
26 Enriched patch master points
29 Hrvoje Jasak, Wikki Ltd. All rights reserved. Copyright Hrvoje Jasak.
31 \*---------------------------------------------------------------------------*/
33 #include "enrichedPatch.H"
34 #include "primitiveMesh.H"
35 #include "demandDrivenData.H"
36 #include "DynamicList.H"
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 const Foam::label Foam::enrichedPatch::nFaceHits_ = 4;
42 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 void Foam::enrichedPatch::calcMasterPointFaces() const
46 if (masterPointFacesPtr_)
48 FatalErrorIn("void enrichedPatch::calcMasterPointFaces() const")
49 << "Master point face addressing already calculated."
54 // Master point face addressing lists the master faces for all points
55 // in the enriched patch support (if there are no master faces, which is
56 // normal, the list will be empty). The index represents the index of
57 // the master face rather than the index from the enriched patch
58 // Master face points lists the points of the enriched master face plus
59 // points projected into the master face
61 Map<DynamicList<label> > mpf(meshPoints().size());
63 const faceList& ef = enrichedFaces();
65 // Add the original face points
66 forAll (masterPatch_, faceI)
68 const face& curFace = ef[faceI + slavePatch_.size()];
69 // Pout << "Cur face in pfAddr: " << curFace << endl;
70 forAll (curFace, pointI)
72 Map<DynamicList<label> >::iterator mpfIter =
73 mpf.find(curFace[pointI]);
75 if (mpfIter == mpf.end())
77 // Not found, add new dynamic list
81 DynamicList<label>(primitiveMesh::facesPerPoint_)
84 // Iterator is invalidated - have to find again
85 mpf.find(curFace[pointI])().append(faceI);
89 mpfIter().append(faceI);
94 // Add the projected points which hit the face
95 const labelList& slaveMeshPoints = slavePatch_.meshPoints();
97 forAll (slavePointFaceHits_, pointI)
101 slavePointPointHits_[pointI] < 0
102 && slavePointEdgeHits_[pointI] < 0
103 && slavePointFaceHits_[pointI].hit()
106 // Get the index of projected point corresponding to this slave
108 const label mergedSmp =
109 pointMergeMap().find(slaveMeshPoints[pointI])();
111 Map<DynamicList<label> >::iterator mpfIter =
114 if (mpfIter == mpf.end())
116 // Not found, add new dynamic list
120 DynamicList<label>(primitiveMesh::facesPerPoint_)
123 // Iterator is invalidated - have to find again
124 mpf.find(mergedSmp)().append
126 slavePointFaceHits_[pointI].hitObject()
131 mpfIter().append(slavePointFaceHits_[pointI].hitObject());
136 // Re-pack dynamic lists into normal lists
137 const labelList mpfToc = mpf.toc();
139 masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size());
140 Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_;
142 forAll (mpfToc, mpfTocI)
145 l.transfer(mpf.find(mpfToc[mpfTocI])().shrink());
147 masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
149 // Pout << "masterPointFaceAddr: " << masterPointFaceAddr << endl;
153 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
155 const Foam::Map<Foam::labelList>& Foam::enrichedPatch::masterPointFaces() const
157 if (!masterPointFacesPtr_)
159 calcMasterPointFaces();
162 return *masterPointFacesPtr_;
166 // ************************************************************************* //