Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
particle_methods
hysop
Commits
13f5c27d
Commit
13f5c27d
authored
11 years ago
by
Franck Pérignon
Browse files
Options
Downloads
Patches
Plain Diff
Add missing class for data redistribution
parent
c9568c7f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
HySoP/hysop/operator/redistribute.py
+118
-0
118 additions, 0 deletions
HySoP/hysop/operator/redistribute.py
with
118 additions
and
0 deletions
HySoP/hysop/operator/redistribute.py
0 → 100644
+
118
−
0
View file @
13f5c27d
"""
@file redistribute.py
Setup for data transfer/redistribution between two parmes topologies.
This operator is an inter operator which is supposed to define the process to
transfer variables and data from one operator to another.
This mainly concerns data redistribution if the two operators work on
different mpi topologies.
When is it required to define an operator between op1 and op2?
If:
- the intersection between op1.output-variables and op2.input-variables
is not empty
- AND if the topology on which the variables of op1 are defined is different
from the one of op2 variables.
Note Franck: this kind of operator may also be useful
to define the interpolation/filter process for data transfer for
a variable defined on several meshes.
"""
from
parmepy.constants
import
debug
from
parmepy.operator.continuous
import
Operator
from
parmepy.mpi.topology
import
Bridge
class
Redistribute
(
Operator
):
"""
Interconnection between two operators.
SetUp will compute (or get if it already exists) a Bridge between two
topologies.
Apply redistributes data from opFrom topology to opTo topology.
"""
@debug
def
__init__
(
self
,
variables
,
opFrom
,
opTo
):
"""
Create an operator to distribute data between two mpi topologies for a
list of variables belonging to two operators.
@param variables : the set of variables to be redistributed
@param opFrom : source operator
@param opTo : target (i.e.) the operator that handles the topology on
which data must be redistributed.
"""
if
isinstance
(
variables
,
list
):
Operator
.
__init__
(
self
,
variables
)
else
:
Operator
.
__init__
(
self
,
[
variables
])
## Source Operator
self
.
opFrom
=
opFrom
## Targeted operator
self
.
opTo
=
opTo
# Then check if variables belong to both operators
for
v
in
self
.
variables
:
assert
v
in
opFrom
.
variables
and
v
in
opTo
.
variables
,
\
'
Redistribute error : one of the variable is not present
\
in both source and target operator.
'
@debug
def
setUp
(
self
):
"""
Computes intersection of two topologies.
"""
assert
self
.
opFrom
.
isUp
and
self
.
opTo
.
isUp
(),
\
'
You should setup both opFrom and opTo operators
\
before any attempt to setup a redistribute operator.
'
self
.
bridges
=
{}
for
v
in
self
.
variables
:
vd_from
=
self
.
opFrom
.
discreteFields
[
v
]
vd_to
=
self
.
opTo
.
discreteFields
[
v
]
self
.
bridges
[
v
]
=
Bridge
(
vd_from
.
topology
,
vd_to
.
topology
)
self
.
_isUpToDate
=
True
def
apply
(
self
):
"""
Proceed with data redistribution from opFrom to opTo
"""
dim
=
self
.
domain
.
dimension
for
v
in
self
.
variables
:
br
=
self
.
bridges
[
v
]
if
v
.
isVector
:
# Apply for each component of the data
for
d
in
range
(
dim
):
vTo
=
self
.
opTo
.
discreteFields
[
v
].
data
[
d
]
vFrom
=
self
.
opFrom
.
discreteFields
[
v
].
data
[
d
]
vTo
[
br
.
ito
]
=
vFrom
[
br
.
ifrom
]
# scalar
else
:
vTo
=
self
.
opTo
.
discreteFields
[
v
].
data
vFrom
=
self
.
opFrom
.
discreteFields
[
v
].
data
vTo
[
br
.
ito
]
=
vFrom
[
br
.
ifrom
]
#from parmepy.mpi import main_rank
# for rk in br.recvFrom.keys():
# main_rank.Irecv()
def
__str__
(
self
):
"""
ToString method
"""
s
=
"
Bridge from :
\n
"
+
str
(
self
.
opFrom
)
s
+=
"
\n
to operator:
\n
"
+
str
(
self
.
opTo
)
s
+=
"
for variable(s)
"
+
str
([
v
.
name
for
v
in
self
.
variables
])
return
s
+
"
\n
"
if
__name__
==
"
__main__
"
:
print
__doc__
print
"
- Provided class : Redistribute
"
print
Redistribute
.
__doc__
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