|
4 | 4 | from firedrake.preconditioners.base import PCBase |
5 | 5 | from firedrake.petsc import PETSc |
6 | 6 | from firedrake.dmhooks import get_function_space |
| 7 | +from firedrake.mesh import DistributedMeshOverlapType |
7 | 8 | from firedrake.logging import warning |
8 | 9 | from tinyasm import _tinyasm as tinyasm |
9 | 10 | from mpi4py import MPI |
@@ -160,6 +161,8 @@ def get_patches(self, V): |
160 | 161 | opts = PETSc.Options(self.prefix) |
161 | 162 | depth = opts.getInt("construct_dim", default=0) |
162 | 163 | ordering = opts.getString("mat_ordering_type", default="natural") |
| 164 | + validate_overlap(mesh, depth, "star") |
| 165 | + |
163 | 166 | # Accessing .indices causes the allocation of a global array, |
164 | 167 | # so we need to cache these for efficiency |
165 | 168 | V_local_ises_indices = tuple(iset.indices for iset in V.dof_dset.local_ises) |
@@ -233,8 +236,11 @@ def get_patches(self, V): |
233 | 236 | ises = [] |
234 | 237 | if depth != -1: |
235 | 238 | (start, end) = mesh_dm.getDepthStratum(depth) |
| 239 | + patch_dim = depth |
236 | 240 | else: |
237 | 241 | (start, end) = mesh_dm.getHeightStratum(height) |
| 242 | + patch_dim = mesh_dm.getDimension() - height |
| 243 | + validate_overlap(mesh, patch_dim, "vanka") |
238 | 244 |
|
239 | 245 | for seed in range(start, end): |
240 | 246 | # Only build patches over owned DoFs |
@@ -453,6 +459,7 @@ def get_patches(self, V): |
453 | 459 | else: |
454 | 460 | continue |
455 | 461 |
|
| 462 | + validate_overlap(mesh, base_depth, "star") |
456 | 463 | start, end = mesh_dm.getDepthStratum(base_depth) |
457 | 464 | for seed in range(start, end): |
458 | 465 | # Only build patches over owned DoFs |
@@ -508,3 +515,26 @@ def get_patches(self, V): |
508 | 515 | iset = PETSc.IS().createGeneral(indices, comm=PETSc.COMM_SELF) |
509 | 516 | ises.append(iset) |
510 | 517 | return ises |
| 518 | + |
| 519 | + |
| 520 | +def validate_overlap(mesh, patch_dim, patch_type): |
| 521 | + if patch_type == "python": |
| 522 | + return |
| 523 | + patch_depth = {"pardecomp": 0, "star": 1, "vanka": 2}[patch_type] |
| 524 | + |
| 525 | + tdim = mesh.topology_dm.getDimension() |
| 526 | + overlap_entity, overlap_depth = mesh._distribution_parameters["overlap_type"] |
| 527 | + overlap_dim = { |
| 528 | + DistributedMeshOverlapType.VERTEX: 0, |
| 529 | + DistributedMeshOverlapType.FACET: tdim-1, |
| 530 | + DistributedMeshOverlapType.NONE: tdim, |
| 531 | + }[overlap_entity] |
| 532 | + |
| 533 | + if mesh.comm.size > 1: |
| 534 | + if overlap_dim > patch_dim: |
| 535 | + patch_entity = {0: "vertex", 1: "edge", 2: "face", tdim: "cell"}[patch_dim] |
| 536 | + warning(f"{overlap_entity} does not support {patch_entity}-patches. " |
| 537 | + "Did you forget to set overlap_type in your mesh's distribution_parameters?") |
| 538 | + if overlap_depth < patch_depth: |
| 539 | + warning(f"Mesh overlap depth of {overlap_depth} does not support {patch_type}-patches. " |
| 540 | + "Did you forget to set overlap_type in your mesh's distribution_parameters?") |
0 commit comments