BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / dynamicMesh / slidingInterface / enrichedPatch / enrichedPatchMasterPoints.C
blob07ad50dc74af4cfbf04cfee30029d5891d70fddb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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_)
40     {
41         FatalErrorIn("void enrichedPatch::calcMasterPointFaces() const")
42             << "Master point face addressing already calculated."
43             << abort(FatalError);
44     }
46     // Note:
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)
60     {
61         const face& curFace = ef[faceI + slavePatch_.size()];
62 //         Pout<< "Cur face in pfAddr: " << curFace << endl;
63         forAll(curFace, pointI)
64         {
65             Map<DynamicList<label> >::iterator mpfIter =
66                 mpf.find(curFace[pointI]);
68             if (mpfIter == mpf.end())
69             {
70                 // Not found, add new dynamic list
71                 mpf.insert
72                 (
73                     curFace[pointI],
74                     DynamicList<label>(primitiveMesh::facesPerPoint_)
75                 );
77                 // Iterator is invalidated - have to find again
78                 mpf.find(curFace[pointI])().append(faceI);
79             }
80             else
81             {
82                 mpfIter().append(faceI);
83             }
84         }
85     }
87     // Add the projected points which hit the face
88     const labelList& slaveMeshPoints = slavePatch_.meshPoints();
90     forAll(slavePointFaceHits_, pointI)
91     {
92         if
93         (
94             slavePointPointHits_[pointI] < 0
95          && slavePointEdgeHits_[pointI] < 0
96          && slavePointFaceHits_[pointI].hit()
97         )
98         {
99             // Get the index of projected point corresponding to this slave
100             // point
101             const label mergedSmp =
102                 pointMergeMap().find(slaveMeshPoints[pointI])();
104             Map<DynamicList<label> >::iterator mpfIter =
105                 mpf.find(mergedSmp);
107             if (mpfIter == mpf.end())
108             {
109                 // Not found, add new dynamic list
110                 mpf.insert
111                 (
112                     mergedSmp,
113                     DynamicList<label>(primitiveMesh::facesPerPoint_)
114                 );
116                 // Iterator is invalidated - have to find again
117                 mpf.find(mergedSmp)().append
118                 (
119                     slavePointFaceHits_[pointI].hitObject()
120                 );
121             }
122             else
123             {
124                 mpfIter().append(slavePointFaceHits_[pointI].hitObject());
125             }
126         }
127     }
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)
136     {
137         labelList l;
138         l.transfer(mpf.find(mpfToc[mpfTocI])());
140         masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
141     }
142     // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl;
146 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
148 const Foam::Map<Foam::labelList>& Foam::enrichedPatch::masterPointFaces() const
150     if (!masterPointFacesPtr_)
151     {
152         calcMasterPointFaces();
153     }
155     return *masterPointFacesPtr_;
159 // ************************************************************************* //