Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
783b5736
Commit
783b5736
authored
16 years ago
by
mattijs
Browse files
Options
Downloads
Patches
Plain Diff
correct non-blocking
parent
b52bae62
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
+139
-33
139 additions, 33 deletions
...lyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
with
139 additions
and
33 deletions
src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C
+
139
−
33
View file @
783b5736
...
...
@@ -84,16 +84,32 @@ void Foam::mapDistribute::distribute
// Receive sub field from neighbour
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
{
if
(
domain
!=
Pstream
::
myProcNo
()
&&
constructMap
[
domain
].
size
()
>
0
)
const
labelList
&
map
=
constructMap
[
domain
];
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
()
>
0
)
{
IPstream
fromNbr
(
Pstream
::
blocking
,
domain
);
List
<
T
>
subField
(
fromNbr
);
const
labelList
&
map
=
constructMap
[
domain
];
if
(
subField
.
size
()
!=
map
.
size
())
{
FatalErrorIn
(
"template<class T>
\n
"
"void mapDistribute::distribute
\n
"
"(
\n
"
" const Pstream::commsTypes commsType,
\n
"
" const List<labelPair>& schedule,
\n
"
" const label constructSize,
\n
"
" const labelListList& subMap,
\n
"
" const labelListList& constructMap,
\n
"
" List<T>& field
\n
"
")
\n
"
)
<<
"Expected from processor "
<<
domain
<<
" "
<<
map
.
size
()
<<
" but received "
<<
subField
.
size
()
<<
" elements."
<<
abort
(
FatalError
);
}
forAll
(
map
,
i
)
{
...
...
@@ -126,6 +142,7 @@ void Foam::mapDistribute::distribute
newField
[
map
[
i
]]
=
subField
[
i
];
}
// Schedule will already have pruned 0-sized comms
forAll
(
schedule
,
i
)
{
const
labelPair
&
twoProcs
=
schedule
[
i
];
...
...
@@ -154,6 +171,26 @@ void Foam::mapDistribute::distribute
const
labelList
&
map
=
constructMap
[
sendProc
];
if
(
subField
.
size
()
!=
map
.
size
())
{
FatalErrorIn
(
"template<class T>
\n
"
"void mapDistribute::distribute
\n
"
"(
\n
"
" const Pstream::commsTypes commsType,
\n
"
" const List<labelPair>& schedule,
\n
"
" const label constructSize,
\n
"
" const labelListList& subMap,
\n
"
" const labelListList& constructMap,
\n
"
" List<T>& field
\n
"
")
\n
"
)
<<
"Expected from processor "
<<
sendProc
<<
" "
<<
map
.
size
()
<<
" but received "
<<
subField
.
size
()
<<
" elements."
<<
abort
(
FatalError
);
}
forAll
(
map
,
i
)
{
newField
[
map
[
i
]]
=
subField
[
i
];
...
...
@@ -164,65 +201,134 @@ void Foam::mapDistribute::distribute
}
else
if
(
commsType
==
Pstream
::
nonBlocking
)
{
List
<
T
>
newField
(
constructSize
);
// Subset myself
const
labelList
&
mySubMap
=
subMap
[
Pstream
::
myProcNo
()];
List
<
T
>
subField
(
mySubMap
.
size
());
forAll
(
mySubMap
,
i
)
if
(
!
contiguous
<
T
>
())
{
subField
[
i
]
=
field
[
mySubMap
[
i
]];
FatalErrorIn
(
"template<class T>
\n
"
"void mapDistribute::distribute
\n
"
"(
\n
"
" const Pstream::commsTypes commsType,
\n
"
" const List<labelPair>& schedule,
\n
"
" const label constructSize,
\n
"
" const labelListList& subMap,
\n
"
" const labelListList& constructMap,
\n
"
" List<T>& field
\n
"
")
\n
"
)
<<
"Non-blocking only supported for contiguous data."
<<
exit
(
FatalError
);
}
// Receive sub field from myself (subField)
const
labelList
&
map
=
constructMap
[
Pstream
::
myProcNo
()];
// Set up sends to neighbours
forAll
(
map
,
i
)
{
newField
[
map
[
i
]]
=
subField
[
i
];
}
List
<
List
<
T
>
>
sendFields
(
Pstream
::
nProcs
());
// Send sub field to neighbour
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
{
const
labelList
&
map
=
subMap
[
domain
];
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
()
>
0
)
{
List
<
T
>
subField
(
map
.
size
());
List
<
T
>&
subField
=
sendFields
[
domain
];
subField
.
setSize
(
map
.
size
());
forAll
(
map
,
i
)
{
subField
[
i
]
=
field
[
map
[
i
]];
}
OPstream
toNbr
(
Pstream
::
nonBlocking
,
domain
);
toNbr
<<
subField
;
OPstream
::
write
(
Pstream
::
nonBlocking
,
domain
,
reinterpret_cast
<
const
char
*>
(
subField
.
begin
()),
subField
.
size
()
);
}
}
// Set up receives from neighbours
List
<
List
<
T
>
>
recvFields
(
Pstream
::
nProcs
());
// Receive sub field from neighbour
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
{
const
labelList
&
map
=
constructMap
[
domain
];
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
()
>
0
)
{
IPstream
fromNbr
(
Pstream
::
nonBlocking
,
domain
);
List
<
T
>
subField
(
fromNbr
);
recvFields
[
domain
].
setSize
(
map
.
size
());
IPstream
::
read
(
Pstream
::
nonBlocking
,
domain
,
reinterpret_cast
<
char
*>
(
recvFields
[
domain
].
begin
()),
recvFields
[
domain
].
size
()
);
}
}
// Combine bits. Note that can reuse field storage
// Subset myself
const
labelList
&
mySubMap
=
subMap
[
Pstream
::
myProcNo
()];
List
<
T
>
subField
(
mySubMap
.
size
());
forAll
(
mySubMap
,
i
)
{
subField
[
i
]
=
field
[
mySubMap
[
i
]];
}
field
.
setSize
(
constructSize
);
// Receive sub field from myself (subField)
const
labelList
&
map
=
constructMap
[
Pstream
::
myProcNo
()];
forAll
(
map
,
i
)
{
field
[
map
[
i
]]
=
subField
[
i
];
}
// Wait for all to finish
OPstream
::
waitRequests
();
IPstream
::
waitRequests
();
// Collect neighbour fields
for
(
label
domain
=
0
;
domain
<
Pstream
::
nProcs
();
domain
++
)
{
const
labelList
&
map
=
constructMap
[
domain
];
if
(
domain
!=
Pstream
::
myProcNo
()
&&
map
.
size
()
>
0
)
{
if
(
recvFields
[
domain
].
size
()
!=
map
.
size
())
{
FatalErrorIn
(
"template<class T>
\n
"
"void mapDistribute::distribute
\n
"
"(
\n
"
" const Pstream::commsTypes commsType,
\n
"
" const List<labelPair>& schedule,
\n
"
" const label constructSize,
\n
"
" const labelListList& subMap,
\n
"
" const labelListList& constructMap,
\n
"
" List<T>& field
\n
"
")
\n
"
)
<<
"Expected from processor "
<<
domain
<<
" "
<<
map
.
size
()
<<
" but received "
<<
recvFields
[
domain
].
size
()
<<
" elements."
<<
abort
(
FatalError
);
}
forAll
(
map
,
i
)
{
newF
ield
[
map
[
i
]]
=
sub
Field
[
i
];
f
ield
[
map
[
i
]]
=
recv
Field
s
[
domain
]
[
i
];
}
}
}
OPstream
::
waitRequests
();
IPstream
::
waitRequests
();
field
.
transfer
(
newField
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment