Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / dynamicMesh / polyMeshModifiers / slidingInterface / enrichedPatch / enrichedPatchMasterPoints.C
blob33045d272ef1302b12d79c6e1c13b87bf3a83435
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 master points
28 Author
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_)
47     {
48         FatalErrorIn("void enrichedPatch::calcMasterPointFaces() const")
49             << "Master point face addressing already calculated."
50             << abort(FatalError);
51     }
53     // Note:
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)
67     {
68         const face& curFace = ef[faceI + slavePatch_.size()];
69 //         Pout << "Cur face in pfAddr: " << curFace << endl;
70         forAll (curFace, pointI)
71         {
72             Map<DynamicList<label> >::iterator mpfIter =
73                 mpf.find(curFace[pointI]);
75             if (mpfIter == mpf.end())
76             {
77                 // Not found, add new dynamic list
78                 mpf.insert
79                 (
80                     curFace[pointI],
81                     DynamicList<label>(primitiveMesh::facesPerPoint_)
82                 );
84                 // Iterator is invalidated - have to find again
85                 mpf.find(curFace[pointI])().append(faceI);
86             }
87             else
88             {
89                 mpfIter().append(faceI);
90             }
91         }
92     }
94     // Add the projected points which hit the face
95     const labelList& slaveMeshPoints = slavePatch_.meshPoints();
97     forAll (slavePointFaceHits_, pointI)
98     {
99         if
100         (
101             slavePointPointHits_[pointI] < 0
102          && slavePointEdgeHits_[pointI] < 0
103          && slavePointFaceHits_[pointI].hit()
104         )
105         {
106             // Get the index of projected point corresponding to this slave
107             // point
108             const label mergedSmp =
109                 pointMergeMap().find(slaveMeshPoints[pointI])();
111             Map<DynamicList<label> >::iterator mpfIter =
112                 mpf.find(mergedSmp);
114             if (mpfIter == mpf.end())
115             {
116                 // Not found, add new dynamic list
117                 mpf.insert
118                 (
119                     mergedSmp,
120                     DynamicList<label>(primitiveMesh::facesPerPoint_)
121                 );
123                 // Iterator is invalidated - have to find again
124                 mpf.find(mergedSmp)().append
125                 (
126                     slavePointFaceHits_[pointI].hitObject()
127                 );
128             }
129             else
130             {
131                 mpfIter().append(slavePointFaceHits_[pointI].hitObject());
132             }
133         }
134     }
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)
143     {
144         labelList l;
145         l.transfer(mpf.find(mpfToc[mpfTocI])().shrink());
147         masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
148     }
149 //     Pout << "masterPointFaceAddr: " << masterPointFaceAddr << endl;
153 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
155 const Foam::Map<Foam::labelList>& Foam::enrichedPatch::masterPointFaces() const
157     if (!masterPointFacesPtr_)
158     {
159         calcMasterPointFaces();
160     }
162     return *masterPointFacesPtr_;
166 // ************************************************************************* //