faGlobalMeshData.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) 2016-2017 Wikki Ltd
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Description
27 
28 Author
29  Hrvoje Jasak
30 
31 \*----------------------------------------------------------------------------*/
32 
33 #include "faGlobalMeshData.H"
34 #include "faMesh.H"
35 #include "globalMeshData.H"
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 Foam::faGlobalMeshData::faGlobalMeshData(const faMesh& mesh)
41 :
43  mesh_(mesh),
44  nGlobalPoints_(-1),
45  sharedPointLabels_(0),
46  sharedPointAddr_(0)
47 {
48  updateMesh();
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
53 
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 
61 {
62  return mesh_;
63 }
64 
65 
67 {
68  label polyMeshNGlobalPoints = mesh_().globalData().nGlobalPoints();
69 
70  const labelList& polyMeshSharedPointLabels =
71  mesh_().globalData().sharedPointLabels();
72 
73  const labelList& polyMeshSharedPointAddr =
74  mesh_().globalData().sharedPointAddr();
75 
76  labelHashSet sharedPointLabels;
77 
78  labelField globalList(polyMeshNGlobalPoints, Zero);
79 
80  forAll(mesh_.boundary(), patchI)
81  {
82  const faPatch& fap = mesh_.boundary()[patchI];
83 
84  if (isA<processorFaPatch>(fap))
85  {
86  const labelList& localPointLabels = fap.pointLabels();
87 
88  forAll(localPointLabels, pointI)
89  {
90  label polyMeshPoint =
91  mesh_.patch().meshPoints()[localPointLabels[pointI]];
92 
93  const label sharedPolyMeshPoint =
94  polyMeshSharedPointLabels.find(polyMeshPoint);
95 
96  if
97  (
98  sharedPolyMeshPoint != -1
99  && !sharedPointLabels.found(localPointLabels[pointI])
100  )
101  {
102  globalList[polyMeshSharedPointAddr[sharedPolyMeshPoint]]
103  += 1;
104 
105  sharedPointLabels.insert(localPointLabels[pointI]);
106  }
107  }
108  }
109  }
110 
111  sharedPointLabels_ = sharedPointLabels.toc();
112 
113  combineReduce(globalList, plusEqOp<labelField>());
114 
115  nGlobalPoints_ = 0;
116  for (label i=0; i<globalList.size(); ++i)
117  {
118  if (globalList[i] > 0)
119  {
120  globalList[i] = ++nGlobalPoints_;
121  }
122  }
123 
124  sharedPointAddr_.setSize(sharedPointLabels_.size());
125  forAll(sharedPointAddr_, pointI)
126  {
127  const label polyMeshSharedPointIndex =
128  polyMeshSharedPointLabels.find
129  (
130  mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
131  );
132 
133  sharedPointAddr_[pointI] =
134  globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
135  - 1;
136  }
137 }
138 
139 
140 // ************************************************************************* //
Foam::faGlobalMeshData::mesh
const faMesh & mesh() const
Return mesh reference.
Definition: faGlobalMeshData.C:60
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
globalMeshData.H
Foam::combineReduce
void combineReduce(const List< UPstream::commsStruct > &comms, T &Value, const CombineOp &cop, const int tag, const label comm)
Definition: PstreamCombineReduceOps.H:54
faMesh.H
Foam::HashSet< label, Hash< label > >
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
PstreamCombineReduceOps.H
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
Foam::UPstream
Inter-processor communications stream.
Definition: UPstream.H:61
Foam::Field< label >
Foam::ProcessorTopology
Determines processor-processor connection. After instantiation contains on all processors the process...
Definition: ProcessorTopology.H:58
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::faPatch::pointLabels
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:202
Foam::List< label >
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition: HashSet.H:191
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::faGlobalMeshData::updateMesh
void updateMesh()
Change global mesh data given a topological change.
Definition: faGlobalMeshData.C:66
Foam::plusEqOp
Definition: ops.H:72
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
boundary
faceListList boundary
Definition: createBlockMesh.H:4
Foam::faGlobalMeshData::~faGlobalMeshData
~faGlobalMeshData()
Destructor.
Definition: faGlobalMeshData.C:54
faGlobalMeshData.H