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-2019 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 "demandDrivenData.H"
32 #include "DynamicList.H"
33 
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 
36 void Foam::enrichedPatch::calcMasterPointFaces() const
37 {
38  if (masterPointFacesPtr_)
39  {
41  << "Master point face addressing already calculated."
42  << abort(FatalError);
43  }
44 
45  // Note:
46  // Master point face addressing lists the master faces for all points
47  // in the enriched patch support (if there are no master faces, which is
48  // normal, the list will be empty). The index represents the index of
49  // the master face rather than the index from the enriched patch
50  // Master face points lists the points of the enriched master face plus
51  // points projected into the master face
52 
53  Map<DynamicList<label>> mpf(2*meshPoints().size());
54 
55  const faceList& ef = enrichedFaces();
56 
57  // Add the original face points
58  forAll(masterPatch_, facei)
59  {
60  const face& curFace = ef[facei + slavePatch_.size()];
61 
62  for (const label pointi : curFace)
63  {
64  // Existing or auto-vivify DynamicList
65  mpf(pointi).append(facei);
66  }
67  }
68 
69  // Add the projected points which hit the face
70  const labelList& slaveMeshPoints = slavePatch_.meshPoints();
71 
72  forAll(slavePointFaceHits_, pointi)
73  {
74  if
75  (
76  slavePointPointHits_[pointi] < 0
77  && slavePointEdgeHits_[pointi] < 0
78  && slavePointFaceHits_[pointi].hit()
79  )
80  {
81  // Index of projected point corresponding to this slave point
82  const label mergedPointi = pointMergeMap()[slaveMeshPoints[pointi]];
83 
84  // Existing or auto-vivify DynamicList
85  mpf(mergedPointi).append(slavePointFaceHits_[pointi].hitObject());
86  }
87  }
88 
89  // Re-pack dynamic lists into normal lists
90 
91  masterPointFacesPtr_ = new Map<labelList>(2*mpf.size());
92  Map<labelList>& masterPointFaceMap = *masterPointFacesPtr_;
93 
94  forAllIters(mpf, mpfIter)
95  {
96  masterPointFaceMap(mpfIter.key()).transfer(mpfIter.val());
97  }
98  // Pout<< "masterPointFaceMap: " << masterPointFaceMap << endl;
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  if (!masterPointFacesPtr_)
107  {
108  calcMasterPointFaces();
109  }
110 
111  return *masterPointFacesPtr_;
112 }
113 
114 
115 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
Foam::enrichedPatch::meshPoints
const labelList & meshPoints() const
Return mesh points.
Definition: enrichedPatch.C:180
Foam::enrichedPatch::masterPointFaces
const Map< labelList > & masterPointFaces() const
Master point face addressing.
Definition: enrichedPatchMasterPoints.C:104
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: HashTableFwd.H:46
primitiveMesh.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
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:62
forAllIters
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:217
Foam::FatalError
error FatalError
Foam::enrichedPatch::enrichedFaces
const faceList & enrichedFaces() const
Return enriched faces.
Definition: enrichedPatchFaces.C:384
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
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:418
enrichedPatch.H
Foam::enrichedPatch::pointMergeMap
const Map< label > & pointMergeMap() const
Return map of point merges.
Definition: enrichedPatchI.H:52