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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "enrichedPatch.H"
30 #include "primitiveMesh.H"
31 #include "DynamicList.H"
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 void Foam::enrichedPatch::calcMasterPointFaces() const
36 {
37  if (masterPointFacesPtr_)
38  {
40  << "Master point face addressing already calculated."
41  << abort(FatalError);
42  }
43 
44  // Note:
45  // Master point face addressing lists the master faces for all points
46  // in the enriched patch support (if there are no master faces, which is
47  // normal, the list will be empty). The index represents the index of
48  // the master face rather than the index from the enriched patch
49  // Master face points lists the points of the enriched master face plus
50  // points projected into the master face
51 
52  Map<DynamicList<label>> mpf(2*meshPoints().size());
53 
54  const faceList& ef = enrichedFaces();
55 
56  // Add the original face points
57  forAll(masterPatch_, facei)
58  {
59  const face& curFace = ef[facei + slavePatch_.size()];
60 
61  for (const label pointi : curFace)
62  {
63  // Existing or auto-vivify DynamicList
64  mpf(pointi).append(facei);
65  }
66  }
67 
68  // Add the projected points which hit the face
69  const labelList& slaveMeshPoints = slavePatch_.meshPoints();
70 
71  forAll(slavePointFaceHits_, pointi)
72  {
73  if
74  (
75  slavePointPointHits_[pointi] < 0
76  && slavePointEdgeHits_[pointi] < 0
77  && slavePointFaceHits_[pointi].hit()
78  )
79  {
80  // Index of projected point corresponding to this slave point
81  const label mergedPointi = pointMergeMap()[slaveMeshPoints[pointi]];
82 
83  // Existing or auto-vivify DynamicList
84  mpf(mergedPointi).append(slavePointFaceHits_[pointi].hitObject());
85  }
86  }
87 
88  // Re-pack dynamic lists into normal lists
89 
90  masterPointFacesPtr_.reset(new Map<labelList>(2*mpf.size()));
91  auto& masterPointFaceMap = *masterPointFacesPtr_;
92 
93  forAllIters(mpf, mpfIter)
94  {
95  masterPointFaceMap(mpfIter.key()).transfer(mpfIter.val());
96  }
97  // Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl;
98 }
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
104 {
105  if (!masterPointFacesPtr_)
106  {
107  calcMasterPointFaces();
108  }
109 
110  return *masterPointFacesPtr_;
111 }
112 
113 
114 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::enrichedPatch::meshPoints
const labelList & meshPoints() const
Return mesh points.
Definition: enrichedPatch.C:165
Foam::enrichedPatch::masterPointFaces
const Map< labelList > & masterPointFaces() const
Master point face addressing.
Definition: enrichedPatchMasterPoints.C:103
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
primitiveMesh.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
forAllIters
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:223
Foam::FatalError
error FatalError
Foam::enrichedPatch::enrichedFaces
const faceList & enrichedFaces() const
Return enriched faces.
Definition: enrichedPatchFaces.C:387
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::faceList
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
DynamicList.H
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:330
enrichedPatch.H
Foam::enrichedPatch::pointMergeMap
const Map< label > & pointMergeMap() const
Return map of point merges.
Definition: enrichedPatchI.H:52