Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
3eb95ac5
Commit
3eb95ac5
authored
Feb 08, 2010
by
mattijs
Browse files
ENH: New shared point addressing.
Now mapDistribute structure to pull data from slaves to master and vice versa.
parent
48c280b7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
View file @
3eb95ac5
...
...
@@ -410,33 +410,30 @@ Foam::label Foam::globalMeshData::countCoincidentFaces
}
void
Foam
::
globalMeshData
::
calcGlobalPointSlaves
()
const
void
Foam
::
globalMeshData
::
calcGlobalPointSlaves
(
const
globalPoints
&
globalData
,
autoPtr
<
globalIndex
>&
globalIndicesPtr
,
autoPtr
<
labelListList
>&
globalPointSlavesPtr
,
autoPtr
<
mapDistribute
>&
globalPointSlavesMapPtr
)
const
{
if
(
debug
)
{
Pout
<<
"globalMeshData::calcGlobalPointSlaves() :"
<<
" calculating coupled master to slave point addressing."
<<
endl
;
}
// Calculate connected points for master points
globalPoints
globalData
(
mesh_
,
coupledPatch
(),
true
);
const
Map
<
label
>&
meshToProcPoint
=
globalData
.
meshToProcPoint
();
// Create global numbering for coupled points
global
PointNumbering
Ptr
_
.
reset
global
Indices
Ptr
.
reset
(
new
globalIndex
(
globalData
.
globalIndices
())
);
const
globalIndex
&
globalIndices
=
global
PointNumbering
Ptr
_
();
const
globalIndex
&
globalIndices
=
global
Indices
Ptr
();
// Create master to slave addressing. Empty for slave points.
globalPointSlavesPtr
_
.
reset
globalPointSlavesPtr
.
reset
(
new
labelListList
(
coupledPatch
().
nPoints
())
);
labelListList
&
globalPointSlaves
=
globalPointSlavesPtr_
();
labelListList
&
globalPointSlaves
=
globalPointSlavesPtr
();
const
Map
<
label
>&
meshToProcPoint
=
globalData
.
meshToProcPoint
();
forAllConstIter
(
Map
<
label
>
,
meshToProcPoint
,
iter
)
{
...
...
@@ -465,7 +462,7 @@ void Foam::globalMeshData::calcGlobalPointSlaves() const
// Changes globalPointSlaves to be indices into compact data
List
<
Map
<
label
>
>
compactMap
(
Pstream
::
nProcs
());
globalPointSlavesMapPtr
_
.
reset
globalPointSlavesMapPtr
.
reset
(
new
mapDistribute
(
...
...
@@ -477,41 +474,50 @@ void Foam::globalMeshData::calcGlobalPointSlaves() const
if
(
debug
)
{
Pout
<<
"globalMeshData::calcGlobalPointSlaves() :"
Pout
<<
"globalMeshData::calcGlobalPointSlaves(
..
) :"
<<
" coupled points:"
<<
coupledPatch
().
nPoints
()
<<
" additional remote points:"
<<
globalPointSlavesMapPtr
_
().
constructSize
()
<<
globalPointSlavesMapPtr
().
constructSize
()
-
coupledPatch
().
nPoints
()
<<
endl
;
}
}
void
Foam
::
globalMeshData
::
calcGlobal
Edge
Slaves
()
const
void
Foam
::
globalMeshData
::
calcGlobal
Point
Slaves
()
const
{
if
(
debug
)
{
Pout
<<
"globalMeshData::calcGlobalEdgeSlaves() :"
<<
" calculating coupled master to slave edge addressing."
Pout
<<
"globalMeshData::calcGlobalPointSlaves() :"
<<
" calculating coupled master to collocated"
<<
" slave point addressing."
<<
endl
;
}
const
labelListList
&
globalPointSlaves
=
this
->
globalPointSlaves
();
const
mapDistribute
&
globalPointSlavesMap
=
this
->
globalPointSlavesMap
(
);
// Calculate collocated connected points for master points.
globalPoints
collocatedGlobalData
(
mesh_
,
coupledPatch
(),
true
,
false
);
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
globalEdgeNumberingPtr_
.
reset
calcGlobalPointSlaves
(
new
globalIndex
(
coupledPatch
().
nEdges
())
collocatedGlobalData
,
globalPointNumberingPtr_
,
globalPointSlavesPtr_
,
globalPointSlavesMapPtr_
);
const
globalIndex
&
globalIndices
=
globalEdgeNumberingPtr_
();
}
void
Foam
::
globalMeshData
::
calcGlobalEdgeSlaves
(
const
labelListList
&
pointSlaves
,
const
mapDistribute
&
pointSlavesMap
,
const
globalIndex
&
globalEdgeIndices
,
autoPtr
<
labelListList
>&
globalEdgeSlavesPtr
,
autoPtr
<
mapDistribute
>&
globalEdgeSlavesMapPtr
)
const
{
// Coupled point to global coupled edges.
labelListList
globalPointEdges
(
globalP
ointSlavesMap
.
constructSize
());
labelListList
globalPointEdges
(
p
ointSlavesMap
.
constructSize
());
// Create local version
const
labelListList
&
pointEdges
=
coupledPatch
().
pointEdges
();
...
...
@@ -522,12 +528,12 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
globalPEdges
.
setSize
(
pEdges
.
size
());
forAll
(
pEdges
,
i
)
{
globalPEdges
[
i
]
=
globalIndices
.
toGlobal
(
pEdges
[
i
]);
globalPEdges
[
i
]
=
global
Edge
Indices
.
toGlobal
(
pEdges
[
i
]);
}
}
// Pull slave data to master
globalP
ointSlavesMap
.
distribute
(
globalPointEdges
);
p
ointSlavesMap
.
distribute
(
globalPointEdges
);
// Now check on master if any of my edges are also on slave.
// This assumes that if slaves have a coupled edge it is also on
...
...
@@ -538,14 +544,14 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
const
edgeList
&
edges
=
coupledPatch
().
edges
();
// Create master to slave addressing. Empty for slave edges.
globalEdgeSlavesPtr
_
.
reset
(
new
labelListList
(
edges
.
size
()));
labelListList
&
globalEdgeSlaves
=
globalEdgeSlavesPtr
_
();
globalEdgeSlavesPtr
.
reset
(
new
labelListList
(
edges
.
size
()));
labelListList
&
globalEdgeSlaves
=
globalEdgeSlavesPtr
();
forAll
(
edges
,
edgeI
)
{
const
edge
&
e
=
edges
[
edgeI
];
const
labelList
&
slaves0
=
globalP
ointSlaves
[
e
[
0
]];
const
labelList
&
slaves1
=
globalP
ointSlaves
[
e
[
1
]];
const
labelList
&
slaves0
=
p
ointSlaves
[
e
[
0
]];
const
labelList
&
slaves1
=
p
ointSlaves
[
e
[
1
]];
// Check for edges that are in both slaves0 and slaves1.
pointEdgeSet
.
clear
();
...
...
@@ -576,11 +582,11 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
// Construct map
List
<
Map
<
label
>
>
compactMap
(
Pstream
::
nProcs
());
globalEdgeSlavesMapPtr
_
.
reset
globalEdgeSlavesMapPtr
.
reset
(
new
mapDistribute
(
globalIndices
,
global
Edge
Indices
,
globalEdgeSlaves
,
compactMap
)
...
...
@@ -591,12 +597,39 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
Pout
<<
"globalMeshData::calcGlobalEdgeSlaves() :"
<<
" coupled edge:"
<<
edges
.
size
()
<<
" additional remote edges:"
<<
globalEdgeSlavesMapPtr
_
().
constructSize
()
-
edges
.
size
()
<<
globalEdgeSlavesMapPtr
().
constructSize
()
-
edges
.
size
()
<<
endl
;
}
}
void
Foam
::
globalMeshData
::
calcGlobalEdgeSlaves
()
const
{
if
(
debug
)
{
Pout
<<
"globalMeshData::calcGlobalEdgeSlaves() :"
<<
" calculating coupled master to collocated slave"
<<
" edge addressing."
<<
endl
;
}
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
const
globalIndex
&
globalIndices
=
globalEdgeNumbering
();
calcGlobalEdgeSlaves
(
globalPointSlaves
(),
globalPointSlavesMap
(),
globalIndices
,
globalEdgeSlavesPtr_
,
globalEdgeSlavesMapPtr_
);
}
// Calculate uncoupled boundary faces (without calculating
// primitiveMesh::pointFaces())
void
Foam
::
globalMeshData
::
calcPointBoundaryFaces
...
...
@@ -961,6 +994,55 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
}
void
Foam
::
globalMeshData
::
calcGlobalPointAllSlaves
()
const
{
if
(
debug
)
{
Pout
<<
"globalMeshData::calcGlobalPointAllSlaves() :"
<<
" calculating coupled master to slave point addressing."
<<
endl
;
}
// Calculate collocated&non-collocated connected points for master points.
globalPoints
allGlobalData
(
mesh_
,
coupledPatch
(),
true
,
true
);
calcGlobalPointSlaves
(
allGlobalData
,
globalPointAllNumberingPtr_
,
globalPointAllSlavesPtr_
,
globalPointAllSlavesMapPtr_
);
}
void
Foam
::
globalMeshData
::
calcGlobalEdgeAllSlaves
()
const
{
if
(
debug
)
{
Pout
<<
"globalMeshData::calcGlobalEdgeAllSlaves() :"
<<
" calculating coupled master to slave edge addressing."
<<
endl
;
}
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
const
globalIndex
&
globalIndices
=
globalEdgeNumbering
();
calcGlobalEdgeSlaves
(
globalPointAllSlaves
(),
globalPointAllSlavesMap
(),
globalIndices
,
globalEdgeAllSlavesPtr_
,
globalEdgeAllSlavesMapPtr_
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from polyMesh
...
...
@@ -1057,6 +1139,17 @@ void Foam::globalMeshData::clearOut()
globalBoundaryCellNumberingPtr_
.
clear
();
globalPointBoundaryCellsPtr_
.
clear
();
globalPointBoundaryCellsMapPtr_
.
clear
();
//- Non-collocated
// Point
globalPointAllNumberingPtr_
.
clear
();
globalPointAllSlavesPtr_
.
clear
();
globalPointAllSlavesMapPtr_
.
clear
();
// Edge
globalEdgeAllSlavesPtr_
.
clear
();
globalEdgeAllSlavesMapPtr_
.
clear
();
}
...
...
@@ -1212,7 +1305,7 @@ Foam::pointField Foam::globalMeshData::geometricSharedPoints() const
labelList
pMap
;
pointField
mergedPoints
;
mergePoints
Foam
::
mergePoints
(
sharedPoints
,
// coordinates to merge
tolDim
,
// tolerance
...
...
@@ -1350,7 +1443,10 @@ const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
{
if
(
!
globalEdgeNumberingPtr_
.
valid
())
{
calcGlobalEdgeSlaves
();
globalEdgeNumberingPtr_
.
reset
(
new
globalIndex
(
coupledPatch
().
nEdges
())
);
}
return
globalEdgeNumberingPtr_
();
}
...
...
@@ -1452,6 +1548,293 @@ const
}
// Non-collocated coupled point/edge addressing
const
Foam
::
globalIndex
&
Foam
::
globalMeshData
::
globalPointAllNumbering
()
const
{
if
(
!
globalPointAllNumberingPtr_
.
valid
())
{
calcGlobalPointAllSlaves
();
}
return
globalPointAllNumberingPtr_
();
}
const
Foam
::
labelListList
&
Foam
::
globalMeshData
::
globalPointAllSlaves
()
const
{
if
(
!
globalPointAllSlavesPtr_
.
valid
())
{
calcGlobalPointAllSlaves
();
}
return
globalPointAllSlavesPtr_
();
}
const
Foam
::
mapDistribute
&
Foam
::
globalMeshData
::
globalPointAllSlavesMap
()
const
{
if
(
!
globalPointAllSlavesMapPtr_
.
valid
())
{
calcGlobalPointAllSlaves
();
}
return
globalPointAllSlavesMapPtr_
();
}
const
Foam
::
labelListList
&
Foam
::
globalMeshData
::
globalEdgeAllSlaves
()
const
{
if
(
!
globalEdgeAllSlavesPtr_
.
valid
())
{
calcGlobalEdgeAllSlaves
();
}
return
globalEdgeAllSlavesPtr_
();
}
const
Foam
::
mapDistribute
&
Foam
::
globalMeshData
::
globalEdgeAllSlavesMap
()
const
{
if
(
!
globalEdgeAllSlavesMapPtr_
.
valid
())
{
calcGlobalEdgeAllSlaves
();
}
return
globalEdgeAllSlavesMapPtr_
();
}
Foam
::
autoPtr
<
Foam
::
globalIndex
>
Foam
::
globalMeshData
::
mergePoints
(
labelList
&
pointToGlobal
,
labelList
&
uniquePoints
)
const
{
const
indirectPrimitivePatch
&
cpp
=
coupledPatch
();
const
labelListList
&
pointSlaves
=
globalPointSlaves
();
const
mapDistribute
&
pointSlavesMap
=
globalPointSlavesMap
();
// 1. Count number of masters on my processor.
label
nCoupledMaster
=
0
;
PackedBoolList
isMaster
(
mesh_
.
nPoints
(),
1
);
forAll
(
pointSlaves
,
pointI
)
{
const
labelList
&
slavePoints
=
pointSlaves
[
pointI
];
if
(
slavePoints
.
size
()
>
0
)
{
nCoupledMaster
++
;
}
else
{
isMaster
[
cpp
.
meshPoints
()[
pointI
]]
=
0
;
}
}
label
myUniquePoints
=
mesh_
.
nPoints
()
-
cpp
.
nPoints
()
+
nCoupledMaster
;
//Pout<< "Points :" << nl
// << " mesh : " << mesh_.nPoints() << nl
// << " of which coupled : " << cpp.nPoints() << nl
// << " of which master : " << nCoupledMaster << nl
// << endl;
// 2. Create global indexing for unique points.
autoPtr
<
globalIndex
>
globalPointsPtr
(
new
globalIndex
(
myUniquePoints
));
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal
.
setSize
(
mesh_
.
nPoints
());
pointToGlobal
=
-
1
;
uniquePoints
.
setSize
(
myUniquePoints
);
label
nMaster
=
0
;
forAll
(
isMaster
,
meshPointI
)
{
if
(
isMaster
[
meshPointI
])
{
pointToGlobal
[
meshPointI
]
=
globalPointsPtr
().
toGlobal
(
nMaster
);
uniquePoints
[
nMaster
]
=
meshPointI
;
nMaster
++
;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList
masterToGlobal
(
pointSlavesMap
.
constructSize
(),
-
1
);
forAll
(
pointSlaves
,
pointI
)
{
const
labelList
&
slaves
=
pointSlaves
[
pointI
];
if
(
slaves
.
size
()
>
0
)
{
// Duplicate master globalpoint into slave slots
label
meshPointI
=
cpp
.
meshPoints
()[
pointI
];
masterToGlobal
[
pointI
]
=
pointToGlobal
[
meshPointI
];
forAll
(
slaves
,
i
)
{
masterToGlobal
[
slaves
[
i
]]
=
masterToGlobal
[
pointI
];
}
}
}
// Send back
pointSlavesMap
.
reverseDistribute
(
cpp
.
nPoints
(),
masterToGlobal
);
// On slave copy master index into overal map.
forAll
(
pointSlaves
,
pointI
)
{
const
labelList
&
slaves
=
pointSlaves
[
pointI
];
if
(
slaves
.
size
()
==
0
)
{
label
meshPointI
=
cpp
.
meshPoints
()[
pointI
];
pointToGlobal
[
meshPointI
]
=
masterToGlobal
[
pointI
];
}
}
}
return
globalPointsPtr
;
}
Foam
::
autoPtr
<
Foam
::
globalIndex
>
Foam
::
globalMeshData
::
mergePoints
(
const
labelList
&
meshPoints
,
const
Map
<
label
>&
meshPointMap
,
labelList
&
pointToGlobal
,
labelList
&
uniquePoints
)
const
{
const
indirectPrimitivePatch
&
cpp
=
coupledPatch
();
const
labelListList
&
pointSlaves
=
globalPointSlaves
();
const
mapDistribute
&
pointSlavesMap
=
globalPointSlavesMap
();
// 1. Count number of masters on my processor.
label
nCoupledMaster
=
0
;
label
nCoupledSlave
=
0
;
PackedBoolList
isMaster
(
meshPoints
.
size
(),
1
);
forAll
(
meshPoints
,
localPointI
)
{
label
meshPointI
=
meshPoints
[
localPointI
];
Map
<
label
>::
const_iterator
iter
=
cpp
.
meshPointMap
().
find
(
meshPointI
);
if
(
iter
!=
cpp
.
meshPointMap
().
end
())
{
// My localPointI is a coupled point.
label
coupledPointI
=
iter
();
if
(
pointSlaves
[
coupledPointI
].
size
()
>
0
)
{
nCoupledMaster
++
;
}
else
{
isMaster
[
localPointI
]
=
0
;
nCoupledSlave
++
;
}
}
}
label
myUniquePoints
=
meshPoints
.
size
()
+
nCoupledMaster
-
nCoupledSlave
;
Pout
<<
"Points :"
<<
nl
<<
" patch : "
<<
meshPoints
.
size
()
<<
nl
<<
" of which coupled : "
<<
nCoupledMaster
+
nCoupledSlave
<<
nl
<<
" of which master : "
<<
nCoupledMaster
<<
nl
<<
" of which slave : "
<<
nCoupledSlave
<<
nl
<<
endl
;
// 2. Create global indexing for unique points.
autoPtr
<
globalIndex
>
globalPointsPtr
(
new
globalIndex
(
myUniquePoints
));
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal
.
setSize
(
meshPoints
.
size
());
pointToGlobal
=
-
1
;
uniquePoints
.
setSize
(
myUniquePoints
);
label
nMaster
=
0
;
forAll
(
isMaster
,
localPointI
)
{
if
(
isMaster
[
localPointI
])
{
pointToGlobal
[
localPointI
]
=
globalPointsPtr
().
toGlobal
(
nMaster
);
uniquePoints
[
nMaster
]
=
localPointI
;
nMaster
++
;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList
masterToGlobal
(
pointSlavesMap
.
constructSize
(),
-
1
);
forAll
(
meshPoints
,
localPointI
)
{
label
meshPointI
=
meshPoints
[
localPointI
];
Map
<
label
>::
const_iterator
iter
=
cpp
.
meshPointMap
().
find
(
meshPointI
);
if
(
iter
!=
cpp
.
meshPointMap
().
end
())
{
// My localPointI is a coupled point.
label
coupledPointI
=
iter
();
const
labelList
&
slaves
=
pointSlaves
[
coupledPointI
];
if
(
slaves
.
size
()
>
0
)
{
// Duplicate master globalpoint into slave slots
masterToGlobal
[
coupledPointI
]
=
pointToGlobal
[
meshPointI
];
forAll
(
slaves
,
i
)
{
masterToGlobal
[
slaves
[
i
]]
=
pointToGlobal
[
meshPointI
];
}
}
}
}
// Send back
pointSlavesMap
.
reverseDistribute
(
cpp
.
nPoints
(),
masterToGlobal
);
// On slave copy master index into overal map.
forAll
(
meshPoints
,
localPointI
)
{
label
meshPointI
=
meshPoints
[
localPointI
];
Map
<
label
>::
const_iterator
iter
=
cpp
.
meshPointMap
().
find
(
meshPointI
);
if
(
iter
!=
cpp
.
meshPointMap
().
end
())
{
// My localPointI is a coupled point.
label
coupledPointI
=
iter
();
const
labelList
&
slaves
=
pointSlaves
[
coupledPointI
];
if
(
slaves
.
size
()
==
0
)
{
pointToGlobal
[
meshPointI
]
=
masterToGlobal
[
coupledPointI
];
}
}
}
}
return
globalPointsPtr
;
}
void
Foam
::
globalMeshData
::
movePoints
(
const
pointField
&
newPoints
)
{
// Topology does not change and we don't store any geometry so nothing
...
...
@@ -1482,8 +1865,9 @@ void Foam::globalMeshData::updateMesh()
// Option 1. Topological
{
// Calculate all shared points. This does all the hard work.
globalPoints
parallelPoints
(
mesh_
,
false
);
// Calculate all shared points (excluded points that are only