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
645ba8e6
Commit
645ba8e6
authored
Apr 06, 2010
by
mattijs
Browse files
ENH: Split exchange into two step process (send+receive) so we can intersperse calculations.
parent
7783e806
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H
View file @
645ba8e6
...
...
@@ -70,6 +70,7 @@ namespace Foam
class
mapPolyMesh
;
class
globalIndex
;
class
PstreamBuffers
;
/*---------------------------------------------------------------------------*\
Class mapDistribute Declaration
...
...
@@ -318,6 +319,13 @@ public:
}
}
//- Do all sends using PstreamBuffers
template
<
class
T
>
void
send
(
PstreamBuffers
&
,
const
List
<
T
>&
)
const
;
//- Do all receives using PstreamBuffers
template
<
class
T
>
void
receive
(
PstreamBuffers
&
,
List
<
T
>&
)
const
;
//- Correct for topo change.
void
updateMesh
(
const
mapPolyMesh
&
)
{
...
...
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
View file @
645ba8e6
...
...
@@ -185,7 +185,7 @@ void Foam::mapDistribute::distribute
{
if
(
!
contiguous
<
T
>
())
{
PstreamBuffers
pBuf
f
s
(
Pstream
::
nonBlocking
);
PstreamBuffers
pBufs
(
Pstream
::
nonBlocking
);
// Stream data into buffer
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
...
...
@@ -195,13 +195,13 @@ void Foam::mapDistribute::distribute
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
())
{
// Put data into send buffer
UOPstream
toDomain
(
domain
,
pBuf
f
s
);
UOPstream
toDomain
(
domain
,
pBufs
);
toDomain
<<
UIndirectList
<
T
>
(
field
,
map
);
}
}
// Start receiving
pBuf
f
s
.
finishedSends
();
pBufs
.
finishedSends
();
{
// Set up 'send' to myself
...
...
@@ -231,7 +231,7 @@ void Foam::mapDistribute::distribute
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
())
{
UIPstream
str
(
domain
,
pBuf
f
s
);
UIPstream
str
(
domain
,
pBufs
);
List
<
T
>
recvField
(
str
);
if
(
recvField
.
size
()
!=
map
.
size
())
...
...
@@ -551,7 +551,7 @@ void Foam::mapDistribute::distribute
{
if
(
!
contiguous
<
T
>
())
{
PstreamBuffers
pBuf
f
s
(
Pstream
::
nonBlocking
);
PstreamBuffers
pBufs
(
Pstream
::
nonBlocking
);
// Stream data into buffer
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
...
...
@@ -561,13 +561,13 @@ void Foam::mapDistribute::distribute
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
())
{
// Put data into send buffer
UOPstream
toDomain
(
domain
,
pBuf
f
s
);
UOPstream
toDomain
(
domain
,
pBufs
);
toDomain
<<
UIndirectList
<
T
>
(
field
,
map
);
}
}
// Start receiving
pBuf
f
s
.
finishedSends
();
pBufs
.
finishedSends
();
{
// Set up 'send' to myself
...
...
@@ -597,7 +597,7 @@ void Foam::mapDistribute::distribute
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
())
{
UIPstream
str
(
domain
,
pBuf
f
s
);
UIPstream
str
(
domain
,
pBufs
);
List
<
T
>
recvField
(
str
);
if
(
recvField
.
size
()
!=
map
.
size
())
...
...
@@ -757,4 +757,66 @@ void Foam::mapDistribute::distribute
}
template
<
class
T
>
void
Foam
::
mapDistribute
::
send
(
PstreamBuffers
&
pBufs
,
const
List
<
T
>&
field
)
const
{
// Stream data into buffer
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
{
const
labelList
&
map
=
subMap_
[
domain
];
if
(
map
.
size
())
{
// Put data into send buffer
UOPstream
toDomain
(
domain
,
pBufs
);
toDomain
<<
UIndirectList
<
T
>
(
field
,
map
);
}
}
// Start sending and receiving but do not block.
pBufs
.
finishedSends
(
false
);
}
template
<
class
T
>
void
Foam
::
mapDistribute
::
receive
(
PstreamBuffers
&
pBufs
,
List
<
T
>&
field
)
const
{
// Consume
field
.
setSize
(
constructSize_
);
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
{
const
labelList
&
map
=
constructMap_
[
domain
];
if
(
map
.
size
())
{
UIPstream
str
(
domain
,
pBufs
);
List
<
T
>
recvField
(
str
);
if
(
recvField
.
size
()
!=
map
.
size
())
{
FatalErrorIn
(
"template<class T>
\n
"
"void mapDistribute::receive
\n
"
"(
\n
"
" PstreamBuffers&,
\n
"
" List<T>&
\n
"
")
\n
"
)
<<
"Expected from processor "
<<
domain
<<
" "
<<
map
.
size
()
<<
" but received "
<<
recvField
.
size
()
<<
" elements."
<<
abort
(
FatalError
);
}
forAll
(
map
,
i
)
{
field
[
map
[
i
]]
=
recvField
[
i
];
}
}
}
}
// ************************************************************************* //
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment