|
74 | 74 |
|
75 | 75 |
|
76 | 76 | PartID = Tuple[VolumeTag, int] |
77 | | -ConvertibleToPartID = Union[Tuple[()], VolumeTag, int, PartID] |
78 | 77 |
|
79 | 78 |
|
80 | 79 | # {{{ part ID normalization |
@@ -190,7 +189,7 @@ def __init__(self, array_context: ArrayContext, |
190 | 189 | Mapping[DiscretizationTag, ElementGroupFactory]] = None, |
191 | 190 | mpi_communicator: Optional["mpi4py.MPI.Intracomm"] = None, |
192 | 191 | inter_part_connections: Optional[ |
193 | | - Mapping[Tuple[ConvertibleToPartID, ConvertibleToPartID], |
| 192 | + Mapping[Tuple[PartID, PartID], |
194 | 193 | DiscretizationConnection]] = None, |
195 | 194 | ) -> None: |
196 | 195 | """ |
@@ -287,32 +286,7 @@ def promote_to_part_id(key): |
287 | 286 | "DiscretizationCollection constructor is called in " |
288 | 287 | "'modern' mode") |
289 | 288 |
|
290 | | - if VTAG_ALL not in volume_discrs.keys(): |
291 | | - # Multi-volume |
292 | | - if mpi_communicator is not None: |
293 | | - def promote_to_part_id(key): |
294 | | - return key |
295 | | - else: |
296 | | - def promote_to_part_id(key): |
297 | | - return (key, None) |
298 | | - else: |
299 | | - # Single-volume |
300 | | - if mpi_communicator is not None: |
301 | | - def promote_to_part_id(key): |
302 | | - return (VTAG_ALL, key) |
303 | | - else: |
304 | | - def promote_to_part_id(key): |
305 | | - return (VTAG_ALL, None) |
306 | | - |
307 | | - volume_discrs = { |
308 | | - vtag: Discretization( |
309 | | - array_context, _normalize_mesh_part_ids(volume_discr.mesh), |
310 | | - self.group_factory_for_discretization_tag(DISCR_TAG_BASE)) |
311 | | - for vtag, volume_discr in volume_discrs.items()} |
312 | | - |
313 | | - self._inter_part_connections = { |
314 | | - promote_to_part_id(key): value |
315 | | - for key, value in inter_part_connections.items()} |
| 289 | + self._inter_part_connections = inter_part_connections |
316 | 290 |
|
317 | 291 | self._volume_discrs = volume_discrs |
318 | 292 |
|
@@ -979,16 +953,41 @@ def make_discretization_collection( |
979 | 953 |
|
980 | 954 | del order |
981 | 955 |
|
982 | | - volume_discrs = { |
983 | | - vtag: ( |
984 | | - Discretization( |
985 | | - array_context, mesh_or_discr, |
986 | | - discr_tag_to_group_factory[DISCR_TAG_BASE]) |
987 | | - if isinstance(mesh_or_discr, Mesh) else mesh_or_discr) |
988 | | - for vtag, mesh_or_discr in volumes.items()} |
989 | | - |
990 | 956 | mpi_communicator = getattr(array_context, "mpi_communicator", None) |
991 | 957 |
|
| 958 | + if mpi_communicator is not None: |
| 959 | + rank = mpi_communicator.Get_rank() |
| 960 | + else: |
| 961 | + rank = None |
| 962 | + |
| 963 | + if VTAG_ALL not in volumes.keys(): |
| 964 | + # Multi-volume |
| 965 | + if mpi_communicator is not None: |
| 966 | + def promote_to_part_id(key): |
| 967 | + return key |
| 968 | + else: |
| 969 | + def promote_to_part_id(key): |
| 970 | + return (key, None) |
| 971 | + else: |
| 972 | + # Single-volume |
| 973 | + if mpi_communicator is not None: |
| 974 | + def promote_to_part_id(key): |
| 975 | + return (VTAG_ALL, key) |
| 976 | + else: |
| 977 | + def promote_to_part_id(key): |
| 978 | + return (VTAG_ALL, None) |
| 979 | + |
| 980 | + if any( |
| 981 | + isinstance(mesh_or_discr, Discretization) |
| 982 | + for mesh_or_discr in volumes.values()): |
| 983 | + raise NotImplementedError("Doesn't work at the moment") |
| 984 | + |
| 985 | + volume_discrs = { |
| 986 | + vtag: Discretization( |
| 987 | + array_context, _normalize_mesh_part_ids(mesh, promote_to_part_id), |
| 988 | + discr_tag_to_group_factory[DISCR_TAG_BASE]) |
| 989 | + for vtag, mesh in volumes.items()} |
| 990 | + |
992 | 991 | return DiscretizationCollection( |
993 | 992 | array_context=array_context, |
994 | 993 | volume_discrs=volume_discrs, |
|
0 commit comments