-
Notifications
You must be signed in to change notification settings - Fork 240
/
transfer.py
68 lines (58 loc) · 1.76 KB
/
transfer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Define the Transfer base class."""
class Transfer(object):
"""
Base Transfer class.
Attributes
----------
_in_inds : int ndarray
input indices for the transfer.
_out_inds : int ndarray
output indices for the transfer.
_comm : MPI.Comm or FakeComm
communicator of the system that owns this transfer.
"""
def __init__(self, in_vec, out_vec, in_inds, out_inds, comm):
"""
Initialize all attributes.
Parameters
----------
in_vec : <Vector>
pointer to the input vector.
out_vec : <Vector>
pointer to the output vector.
in_inds : int ndarray
input indices for the transfer.
out_inds : int ndarray
output indices for the transfer.
comm : MPI.Comm or <FakeComm>
communicator of the system that owns this transfer.
"""
self._in_inds = in_inds
self._out_inds = out_inds
self._comm = comm
def __str__(self):
"""
Return a string representation of the Transfer object.
Returns
-------
str
String rep of this object.
"""
try:
return "%s(in=%s, out=%s" % (self.__class__.__name__, self._in_inds, self._out_inds)
except Exception as err:
return "<error during call to Transfer.__str__: %s" % err
def __call__(self, in_vec, out_vec, mode='fwd'):
"""
Perform transfer.
Must be implemented by the subclass.
Parameters
----------
in_vec : <Vector>
pointer to the input vector.
out_vec : <Vector>
pointer to the output vector.
mode : str
'fwd' or 'rev'.
"""
pass