Loading...
Searching...
No Matches
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{
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 * * * * * * * * * * * * * //
69{
70 return mesh_;
71}
72
73
75{
76 // The polyMesh globalMeshData
77 const globalMeshData& pData = mesh_.mesh().globalData();
78
79 const labelList& polyMeshSharedPointLabels =
80 pData.sharedPointLabels();
81
82 const labelList& polyMeshSharedPointAddr =
83 pData.sharedPointAddr();
84
85 labelHashSet sharedPointLabels;
86
87 labelField globalList(pData.nGlobalPoints(), Zero);
88
89 forAll(mesh_.boundary(), patchI)
90 {
91 const faPatch& fap = mesh_.boundary()[patchI];
92
93 if (isA<processorFaPatch>(fap))
94 {
95 const labelList& localPointLabels = fap.pointLabels();
96
97 forAll(localPointLabels, pointI)
98 {
99 label polyMeshPoint =
100 mesh_.patch().meshPoints()[localPointLabels[pointI]];
101
102 const label sharedPolyMeshPoint =
103 polyMeshSharedPointLabels.find(polyMeshPoint);
104
105 if
106 (
107 sharedPolyMeshPoint != -1
108 && !sharedPointLabels.found(localPointLabels[pointI])
109 )
110 {
111 globalList[polyMeshSharedPointAddr[sharedPolyMeshPoint]]
112 += 1;
113
114 sharedPointLabels.insert(localPointLabels[pointI]);
115 }
116 }
117 }
118 }
119
120 sharedPointLabels_ = sharedPointLabels.toc();
121
123
124 nGlobalPoints_ = 0;
125 for (label i=0; i<globalList.size(); ++i)
126 {
127 if (globalList[i] > 0)
128 {
129 globalList[i] = ++nGlobalPoints_;
130 }
131 }
132
133 sharedPointAddr_.setSize(sharedPointLabels_.size());
134 forAll(sharedPointAddr_, pointI)
135 {
136 const label polyMeshSharedPointIndex =
137 polyMeshSharedPointLabels.find
138 (
139 mesh_.patch().meshPoints()[sharedPointLabels_[pointI]]
140 );
141
142 sharedPointAddr_[pointI] =
143 globalList[polyMeshSharedPointAddr[polyMeshSharedPointIndex]]
144 - 1;
145 }
146}
147
148
149// ************************************************************************* //
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition HashSet.H:229
List< Key > toc() const
The table of contents (the keys) in unsorted order.
Definition HashTable.C:141
bool found(const Key &key) const
Same as contains().
Definition HashTable.H:1370
static void combineReduce(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors.
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
label find(const T &val) const
Find index of the first occurrence of the value.
Definition UList.C:160
Inter-processor communications stream.
Definition UPstream.H:69
const faMesh & mesh() const noexcept
Return mesh reference.
const labelList & sharedPointLabels() const noexcept
Return indices of local points that are globally shared.
faGlobalMeshData(const faGlobalMeshData &)=delete
No copy construct.
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:140
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition faPatch.H:76
const labelList & pointLabels() const
Return patch point labels.
Definition faPatch.C:267
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points list.
label nGlobalPoints() const
Return number of globally shared points.
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
const polyMesh & mesh() const noexcept
Return the mesh reference.
const globalMeshData & globalData() const
Return parallel info (demand-driven).
Definition polyMesh.C:1296
Determines/represents processor-processor connection. After instantiation contains the processor-proc...
faceListList boundary
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< label > labelList
A List of labels.
Definition List.H:62
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
Field< label > labelField
Specialisation of Field<T> for label.
Definition labelField.H:48
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
const direction noexcept
Definition scalarImpl.H:265
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:299