enrichedPatchMasterPoints.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "enrichedPatch.H"
27 #include "primitiveMesh.H"
28 #include "demandDrivenData.H"
29 #include "DynamicList.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
34 
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 
38 {
40  {
42  << "Master point face addressing already calculated."
43  << abort(FatalError);
44  }
45 
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
53 
54  Map<DynamicList<label> > mpf(meshPoints().size());
55 
56  const faceList& ef = enrichedFaces();
57 
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]);
67 
68  if (mpfIter == mpf.end())
69  {
70  // Not found, add new dynamic list
71  mpf.insert
72  (
73  curFace[pointI],
75  );
76 
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  }
86 
87  // Add the projected points which hit the face
88  const labelList& slaveMeshPoints = slavePatch_.meshPoints();
89 
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])();
103 
104  Map<DynamicList<label> >::iterator mpfIter =
105  mpf.find(mergedSmp);
106 
107  if (mpfIter == mpf.end())
108  {
109  // Not found, add new dynamic list
110  mpf.insert
111  (
112  mergedSmp,
114  );
115 
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  }
128 
129  // Re-pack dynamic lists into normal lists
130  const labelList mpfToc = mpf.toc();
131 
132  masterPointFacesPtr_ = new Map<labelList>(2*mpfToc.size());
133  Map<labelList>& masterPointFaceAddr = *masterPointFacesPtr_;
134 
135  forAll(mpfToc, mpfTocI)
136  {
137  labelList l;
138  l.transfer(mpf.find(mpfToc[mpfTocI])());
139 
140  masterPointFaceAddr.insert(mpfToc[mpfTocI], l);
141  }
142  // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl;
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147 
149 {
150  if (!masterPointFacesPtr_)
151  {
152  calcMasterPointFaces();
153  }
154 
155  return *masterPointFacesPtr_;
156 }
157 
158 
159 // ************************************************************************* //
Foam::enrichedPatch::meshPoints
const labelList & meshPoints() const
Return mesh points.
Definition: enrichedPatch.C:178
Foam::enrichedPatch::masterPointFaces
const Map< labelList > & masterPointFaces() const
Master point face addressing.
Definition: enrichedPatchMasterPoints.C:148
Foam::enrichedPatch::slavePointEdgeHits_
const labelList & slavePointEdgeHits_
Slave point edge hits.
Definition: enrichedPatch.H:90
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::DynamicList< label >
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::enrichedPatch::slavePatch_
const primitiveFacePatch & slavePatch_
Reference to slave patch.
Definition: enrichedPatch.H:75
Foam::List::transfer
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: PrimitivePatchTemplate.H:68
Foam::enrichedPatch::masterPointFacesPtr_
Map< labelList > * masterPointFacesPtr_
Definition: enrichedPatch.H:114
Foam::enrichedPatch::nFaceHits_
static const label nFaceHits_
Estimated number of master face hits by slave points.
Definition: enrichedPatch.H:180
Foam::enrichedPatch::masterPatch_
const primitiveFacePatch & masterPatch_
Reference to master patch.
Definition: enrichedPatch.H:72
Foam::enrichedPatch::pointMergeMap
Map< label > & pointMergeMap()
Return map of point merges.
Definition: enrichedPatch.H:222
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::enrichedPatch::calcMasterPointFaces
void calcMasterPointFaces() const
Calculate master point addressing.
Definition: enrichedPatchMasterPoints.C:37
Foam::enrichedPatch::slavePointFaceHits_
const List< objectHit > & slavePointFaceHits_
Slave point face hits.
Definition: enrichedPatch.H:93
Foam::FatalError
error FatalError
Foam::enrichedPatch::enrichedFaces
const faceList & enrichedFaces() const
Return enriched faces.
Definition: enrichedPatchFaces.C:379
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::enrichedPatch::slavePointPointHits_
const labelList & slavePointPointHits_
Slave point point hits.
Definition: enrichedPatch.H:87
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::primitiveMesh::facesPerPoint_
static const unsigned facesPerPoint_
Estimated number of faces per point.
Definition: primitiveMesh.H:303
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
DynamicList.H
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatchTemplate.C:392
enrichedPatch.H