Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
2352682a
Commit
2352682a
authored
Oct 26, 2009
by
mattijs
Browse files
use Pstream::exchange
parent
9a139812
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOstreams/Pstreams/exchange.C
View file @
2352682a
...
...
@@ -94,7 +94,7 @@ void Pstream::exchange
{
label
nRecv
=
sizes
[
procI
][
UPstream
::
myProcNo
()];
if
(
nRecv
>
0
)
if
(
procI
!=
Pstream
::
myProcNo
()
&&
nRecv
>
0
)
{
recvBufs
[
procI
].
setSize
(
nRecv
);
label
oldTag
=
UPstream
::
msgType
();
...
...
@@ -116,7 +116,7 @@ void Pstream::exchange
forAll
(
sendBufs
,
procI
)
{
if
(
sendBufs
[
procI
].
size
()
>
0
)
if
(
procI
!=
Pstream
::
myProcNo
()
&&
sendBufs
[
procI
].
size
()
>
0
)
{
label
oldTag
=
UPstream
::
msgType
();
UPstream
::
msgType
()
=
tag
;
...
...
@@ -148,6 +148,9 @@ void Pstream::exchange
Pstream
::
waitRequests
();
}
// Do myself
recvBufs
[
Pstream
::
myProcNo
()]
=
sendBufs
[
Pstream
::
myProcNo
()];
}
...
...
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C
View file @
2352682a
...
...
@@ -381,7 +381,13 @@ Foam::mapDistribute::mapDistribute
}
subMap_
.
setSize
(
Pstream
::
nProcs
());
exchange
(
wantedRemoteElements
,
subMap_
);
labelListList
sendSizes
;
Pstream
::
exchange
<
labelList
,
label
>
(
wantedRemoteElements
,
subMap_
,
sendSizes
);
// Renumber elements
forAll
(
elements
,
i
)
...
...
@@ -528,7 +534,13 @@ Foam::mapDistribute::mapDistribute
}
subMap_
.
setSize
(
Pstream
::
nProcs
());
exchange
(
wantedRemoteElements
,
subMap_
);
labelListList
sendSizes
;
Pstream
::
exchange
<
labelList
,
label
>
(
wantedRemoteElements
,
subMap_
,
sendSizes
);
// Renumber elements
forAll
(
cellCells
,
cellI
)
...
...
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H
View file @
2352682a
...
...
@@ -93,15 +93,6 @@ class mapDistribute
mutable
autoPtr
<
List
<
labelPair
>
>
schedulePtr_
;
//- Exchange data. sendBuf[procI] : data to send to processor procI
// To be moved into Pstream.
template
<
class
T
>
static
void
exchange
(
const
List
<
List
<
T
>
>&
sendBuf
,
List
<
List
<
T
>
>&
recvBuf
);
public:
// Constructors
...
...
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
View file @
2352682a
...
...
@@ -759,78 +759,4 @@ void Foam::mapDistribute::distribute
}
template
<
class
T
>
void
Foam
::
mapDistribute
::
exchange
(
const
List
<
List
<
T
>
>&
sendBuf
,
List
<
List
<
T
>
>&
recvBuf
)
{
if
(
!
contiguous
<
T
>
())
{
FatalErrorIn
(
"mapDistribute::exchange(..)"
)
<<
"Not contiguous"
<<
exit
(
FatalError
);
}
if
(
Pstream
::
parRun
())
{
// Determine sizes
// ~~~~~~~~~~~~~~~
labelListList
allNTrans
(
Pstream
::
nProcs
());
allNTrans
[
Pstream
::
myProcNo
()].
setSize
(
Pstream
::
nProcs
());
forAll
(
allNTrans
,
procI
)
{
allNTrans
[
Pstream
::
myProcNo
()][
procI
]
=
sendBuf
[
procI
].
size
();
}
combineReduce
(
allNTrans
,
listEq
());
// Set up receives
// ~~~~~~~~~~~~~~~
recvBuf
.
setSize
(
Pstream
::
nProcs
());
forAll
(
recvBuf
,
procI
)
{
if
(
procI
!=
Pstream
::
myProcNo
())
{
recvBuf
[
procI
].
setSize
(
allNTrans
[
procI
][
Pstream
::
myProcNo
()]);
IPstream
::
read
(
Pstream
::
nonBlocking
,
procI
,
reinterpret_cast
<
char
*>
(
recvBuf
[
procI
].
begin
()),
recvBuf
[
procI
].
byteSize
()
);
}
}
// Set up sends
// ~~~~~~~~~~~~
forAll
(
sendBuf
,
procI
)
{
if
(
procI
!=
Pstream
::
myProcNo
())
{
OPstream
::
write
(
Pstream
::
nonBlocking
,
procI
,
reinterpret_cast
<
const
char
*>
(
sendBuf
[
procI
].
begin
()),
sendBuf
[
procI
].
byteSize
()
);
}
}
// Wait for completion
Pstream
::
waitRequests
();
}
// Do myself
recvBuf
[
Pstream
::
myProcNo
()]
=
sendBuf
[
Pstream
::
myProcNo
()];
}
// ************************************************************************* //
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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