enrichedPatchPointMap.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-2016 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 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 void Foam::enrichedPatch::completePointMap() const
31 {
32  if (pointMapComplete_)
33  {
35  << "Point map already completed"
36  << abort(FatalError);
37  }
38 
39  pointMapComplete_ = true;
40 
41  const Map<label>& pmm = pointMergeMap();
42 
43  // Get the mesh points for both patches. If the point has not been
44  // merged away, add it to the map
45 
46  // Do master patch
47  const labelList& masterMeshPoints = masterPatch_.meshPoints();
48  const pointField& masterLocalPoints = masterPatch_.localPoints();
49 
50  forAll(masterMeshPoints, pointi)
51  {
52  if (!pmm.found(masterMeshPoints[pointi]))
53  {
54  pointMap_.insert
55  (
56  masterMeshPoints[pointi],
57  masterLocalPoints[pointi]
58  );
59  }
60  }
61 
62  // Do slave patch
63  const labelList& slaveMeshPoints = slavePatch_.meshPoints();
64  const pointField& slaveLocalPoints = slavePatch_.localPoints();
65 
66  forAll(slaveMeshPoints, pointi)
67  {
68  if (!pmm.found(slaveMeshPoints[pointi]))
69  {
70  pointMap_.insert
71  (
72  slaveMeshPoints[pointi],
73  slaveLocalPoints[pointi]
74  );
75  }
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 
84 {
85  if (!pointMapComplete_)
86  {
87  completePointMap();
88  }
89 
90  return pointMap_;
91 }
92 
93 
95 {
96  if (!pointMapComplete_)
97  {
98  completePointMap();
99  }
100 
101  return pointMap_;
102 }
103 
104 
105 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
Map< point > & pointMap()
Return non-const access to point map to add points.
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Map< label > & pointMergeMap()
Return map of point merges.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49