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 Copyright (C) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Author
28 Hrvoje Jasak
29
30\*----------------------------------------------------------------------------*/
31
32#include "faGlobalMeshData.H"
33#include "faMesh.H"
34#include "globalMeshData.H"
35#include "processorFaPatch.H"
37
38// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39
41:
42 mesh_(mesh),
43 processorTopology_
44 (
46 (
47 mesh.boundary(),
48 UPstream::worldComm
49 )
50 ),
51 nGlobalPoints_(-1),
52 sharedPointLabels_(),
53 sharedPointAddr_()
54{
55 updateMesh();
56}
57
58
59// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60
61// A non-default destructor since we had incomplete types in the header
63{}
64
65
66// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67
69{
70 return mesh_;
71}
72
73
75{
76 label polyMeshNGlobalPoints = mesh_().globalData().nGlobalPoints();
77
78 const labelList& polyMeshSharedPointLabels =
79 mesh_().globalData().sharedPointLabels();
80
81 const labelList& polyMeshSharedPointAddr =
82 mesh_().globalData().sharedPointAddr();
83
84 labelHashSet sharedPointLabels;
85
86 labelField globalList(polyMeshNGlobalPoints, Zero);
87
88 forAll(mesh_.boundary(), patchI)
89 {
90 const faPatch& fap = mesh_.boundary()[patchI];
91
92 if (isA<processorFaPatch>(fap))
93 {
94 const labelList& localPointLabels = fap.pointLabels();
95
96 forAll(localPointLabels, pointI)
97 {
98 label polyMeshPoint =
99 mesh_.patch().meshPoints()[localPointLabels[pointI]];
100
101 const label sharedPolyMeshPoint =
102 polyMeshSharedPointLabels.find(polyMeshPoint);
103
104 if
105 (
106 sharedPolyMeshPoint != -1
107 && !sharedPointLabels.found(localPointLabels[pointI])
108 )
109 {
110 globalList[polyMeshSharedPointAddr[sharedPolyMeshPoint]]
111 += 1;
112
113 sharedPointLabels.insert(localPointLabels[pointI]);
114 }
115 }
116 }
117 }
118
119 sharedPointLabels_ = sharedPointLabels.toc();
120
122
123 nGlobalPoints_ = 0;
124 for (label i=0; i<globalList.size(); ++i)
125 {
126 if (globalList[i] > 0)
127 {
128 globalList[i] = ++nGlobalPoints_;
129 }
130 }
131
132 sharedPointAddr_.setSize(sharedPointLabels_.size());
133 forAll(sharedPointAddr_, pointI)
134 {
135 const label polyMeshSharedPointIndex =
136 polyMeshSharedPointLabels.find
137 (
138 mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
139 );
140
141 sharedPointAddr_[pointI] =
142 globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
143 - 1;
144 }
145}
146
147
148// ************************************************************************* //
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition: HashSet.H:191
List< Key > toc() const
The table of contents (the keys) in unsorted order.
Definition: HashTable.C:122
bool found(const Key &key) const
Return true if hashed entry is found in table.
Definition: HashTableI.H:100
void setSize(const label n)
Alias for resize()
Definition: List.H:218
static void combineAllGather(const List< commsStruct > &comms, T &value, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
Definition: UList.C:212
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Inter-processor communications stream.
Definition: UPstream.H:59
Various mesh related information for a parallel run.
~faGlobalMeshData()
Destructor.
const faMesh & mesh() const noexcept
Return mesh reference.
void updateMesh()
Change global mesh data given a topological change.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:273
Determines/represents processor-processor connection. After instantiation contains the processor-proc...
faceListList boundary
dynamicFvMesh & mesh
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
const direction noexcept
Definition: Scalar.H:223
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Define the processor-processor connection table by walking a list of patches and detecting the proces...
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333