From c32df123c52bb75358e186221fecebbc6e8c9481 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:06:33 -0500 Subject: [PATCH 01/12] test_mpi_communication.py: Switch to new-style pytest invocation --- test/test_mpi_communication.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_mpi_communication.py b/test/test_mpi_communication.py index 7ed5233d..9327bd51 100644 --- a/test/test_mpi_communication.py +++ b/test/test_mpi_communication.py @@ -293,7 +293,6 @@ if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) else: - from py.test.cmdline import main + from pytest import main main([__file__]) - # vim: fdm=marker -- GitLab From 0858ff411d5117f3c65e915974b85cb0e58baede Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:06:59 -0500 Subject: [PATCH 02/12] Register 'mpi' test mark with pytest to avoid warnings --- pytest.ini | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..01a22d37 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +markers = + mpi: marks tests as using MPI -- GitLab From 91a705938cf6b21d75e03d6a54a9447229240604 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:07:54 -0500 Subject: [PATCH 03/12] Document DTAG_BOUNDARY --- grudge/symbolic/primitives.py | 1 + 1 file changed, 1 insertion(+) diff --git a/grudge/symbolic/primitives.py b/grudge/symbolic/primitives.py index 0b9fac20..4f50b636 100644 --- a/grudge/symbolic/primitives.py +++ b/grudge/symbolic/primitives.py @@ -64,6 +64,7 @@ DOF description .. autoclass:: DTAG_SCALAR .. autoclass:: DTAG_VOLUME_ALL +.. autoclass:: DTAG_BOUNDARY .. autoclass:: QTAG_NONE .. autoclass:: DOFDesc .. data:: DD_SCALAR -- GitLab From 3bf66a7f9eeccded6d96abde96f97da8aa2fa213 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:08:15 -0500 Subject: [PATCH 04/12] Equality comparison and hashability for DTAG_BOUNDARY --- grudge/symbolic/primitives.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grudge/symbolic/primitives.py b/grudge/symbolic/primitives.py index 4f50b636..0e57fcef 100644 --- a/grudge/symbolic/primitives.py +++ b/grudge/symbolic/primitives.py @@ -124,6 +124,18 @@ class DTAG_BOUNDARY: # noqa def __init__(self, tag): self.tag = tag + def __eq__(self, other): + return isinstance(other, DTAG_BOUNDARY) and self.tag == other.tag + + def __ne__(self, other): + return not self.__eq__(other) + + def __hash__(self): + return hash(type(self)) ^ hash(self.tag) + + def __repr__(self): + return "<%s(%s)>" % (type(self).__name__, repr(self.tag)) + class QTAG_NONE: # noqa pass -- GitLab From de026c685715128466c626eced6f113207b7a695 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:08:49 -0500 Subject: [PATCH 05/12] Improve paren indentation in grudge.models.wave --- grudge/models/wave.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grudge/models/wave.py b/grudge/models/wave.py index 0ac60a33..6defafc8 100644 --- a/grudge/models/wave.py +++ b/grudge/models/wave.py @@ -163,7 +163,9 @@ class StrongWaveOperator(HyperbolicOperator): + flux(sym.bv_tpair(self.dirichlet_tag, w, dir_bc)) + flux(sym.bv_tpair(self.neumann_tag, w, neu_bc)) + flux(sym.bv_tpair(self.radiation_tag, w, rad_bc)) - ))) + ) + ) + ) result[0] += self.source_f -- GitLab From 0026dc9728e33f78ed47bd55e8edcfe3877f1d36 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:09:38 -0500 Subject: [PATCH 06/12] Remove some dead 'FluxOperator' code left over from hedge --- grudge/symbolic/mappers/__init__.py | 45 ----------------------------- 1 file changed, 45 deletions(-) diff --git a/grudge/symbolic/mappers/__init__.py b/grudge/symbolic/mappers/__init__.py index 0e9b8e02..8107b4cb 100644 --- a/grudge/symbolic/mappers/__init__.py +++ b/grudge/symbolic/mappers/__init__.py @@ -564,51 +564,6 @@ class OperatorSpecializer(CSECachingMapperMixin, IdentityMapper): raise TypeError("RestrictToBoundary cannot be applied to " "quadrature-based operands--use QuadUpsample(Boundarize(...))") - # {{{ flux operator specialization - elif isinstance(expr.op, op.FluxOperatorBase): - from pytools.obj_array import with_object_array_or_scalar - - repr_tag_cell = [None] - - def process_flux_arg(flux_arg): - arg_repr_tag = self.typedict[flux_arg].repr_tag - if repr_tag_cell[0] is None: - repr_tag_cell[0] = arg_repr_tag - else: - # An error for this condition is generated by - # the type inference pass. - - assert arg_repr_tag == repr_tag_cell[0] - - is_boundary = isinstance(expr.field, BoundaryPair) - if is_boundary: - bpair = expr.field - with_object_array_or_scalar(process_flux_arg, bpair.field) - with_object_array_or_scalar(process_flux_arg, bpair.bfield) - else: - with_object_array_or_scalar(process_flux_arg, expr.field) - - is_quad = isinstance(repr_tag_cell[0], QuadratureRepresentation) - if is_quad: - assert not expr.op.is_lift - quad_tag = repr_tag_cell[0].quadrature_tag - - new_fld = self.rec(expr.field) - flux = expr.op.flux - - if is_boundary: - if is_quad: - return op.QuadratureBoundaryFluxOperator( - flux, quad_tag, bpair.tag)(new_fld) - else: - return op.BoundaryFluxOperator(flux, bpair.tag)(new_fld) - else: - if is_quad: - return op.QuadratureFluxOperator(flux, quad_tag)(new_fld) - else: - return op.FluxOperator(flux, expr.op.is_lift)(new_fld) - # }}} - else: return IdentityMapper.map_operator_binding(self, expr) -- GitLab From 6689bfdc2d4cb31f4885aa759cef44246475ed45 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:10:41 -0500 Subject: [PATCH 07/12] PointsDiscretization: add bogus mpi_communicator and facial_adjacency_groups attributes --- grudge/discretization.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grudge/discretization.py b/grudge/discretization.py index 20fc0505..730c9d3e 100644 --- a/grudge/discretization.py +++ b/grudge/discretization.py @@ -385,6 +385,8 @@ class PointsDiscretization(DiscretizationBase): np.float64: np.complex128 }[self.real_dtype.type]) + self.mpi_communicator = None + def ambient_dim(self): return self._nodes.shape[0] @@ -399,6 +401,10 @@ class PointsDiscretization(DiscretizationBase): def nodes(self): return self._nodes + @property + def facial_adjacency_groups(self): + return [] + def discr_from_dd(self, dd): dd = sym.as_dofdesc(dd) -- GitLab From 5994a40f86fa61f07beca9888b74ba11d5e39c87 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:12:03 -0500 Subject: [PATCH 08/12] Standardize all boundary DOFDescs to use DTAG_BOUNDARY, rename DOFDesc.is_boundary -> is_boundary_or_partition_interface --- grudge/discretization.py | 13 +++++++------ grudge/symbolic/mappers/__init__.py | 15 +++++++-------- grudge/symbolic/operators.py | 9 ++++++--- grudge/symbolic/primitives.py | 17 ++++++----------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/grudge/discretization.py b/grudge/discretization.py index 730c9d3e..d24fb2c0 100644 --- a/grudge/discretization.py +++ b/grudge/discretization.py @@ -131,9 +131,10 @@ class DGDiscretizationWithBoundaries(DiscretizationBase): # FIXME raise NotImplementedError("Distributed communication with quadrature") - assert isinstance(dd.domain_tag, sym.BTAG_PARTITION) + assert isinstance(dd.domain_tag, sym.DTAG_BOUNDARY) + assert isinstance(dd.domain_tag.tag, sym.BTAG_PARTITION) - return self._dist_boundary_connections[dd.domain_tag.part_nr] + return self._dist_boundary_connections[dd.domain_tag.tag.part_nr] @memoize_method def discr_from_dd(self, dd): @@ -161,8 +162,8 @@ class DGDiscretizationWithBoundaries(DiscretizationBase): return self._all_faces_volume_connection().to_discr elif dd.domain_tag is sym.FACE_RESTR_INTERIOR: return self._interior_faces_connection().to_discr - elif dd.is_boundary(): - return self._boundary_connection(dd.domain_tag).to_discr + elif dd.is_boundary_or_partition_interface(): + return self._boundary_connection(dd.domain_tag.tag).to_discr else: raise ValueError("DOF desc tag not understood: " + str(dd)) @@ -239,9 +240,9 @@ class DGDiscretizationWithBoundaries(DiscretizationBase): return self._all_faces_volume_connection() if to_dd.domain_tag is sym.FACE_RESTR_INTERIOR: return self._interior_faces_connection() - elif to_dd.is_boundary(): + elif to_dd.is_boundary_or_partition_interface(): assert from_dd.quadrature_tag is sym.QTAG_NONE - return self._boundary_connection(to_dd.domain_tag) + return self._boundary_connection(to_dd.domain_tag.tag) elif to_dd.is_volume(): from meshmode.discretization.connection import \ make_same_mesh_connection diff --git a/grudge/symbolic/mappers/__init__.py b/grudge/symbolic/mappers/__init__.py index 8107b4cb..21abb9e8 100644 --- a/grudge/symbolic/mappers/__init__.py +++ b/grudge/symbolic/mappers/__init__.py @@ -930,14 +930,13 @@ class EmptyFluxKiller(CSECachingMapperMixin, IdentityMapper): def map_operator_binding(self, expr): from meshmode.mesh import is_boundary_tag_empty if (isinstance(expr.op, sym.InterpolationOperator) - and expr.op.dd_out.is_boundary() - and expr.op.dd_out.domain_tag not in [ - sym.FACE_RESTR_ALL, sym.FACE_RESTR_INTERIOR] - and is_boundary_tag_empty(self.mesh, - expr.op.dd_out.domain_tag)): - return 0 - else: - return IdentityMapper.map_operator_binding(self, expr) + and expr.op.dd_out.is_boundary_or_partition_interface()): + domain_tag = expr.op.dd_out.domain_tag + assert isinstance(domain_tag, sym.DTAG_BOUNDARY) + if is_boundary_tag_empty(self.mesh, domain_tag.tag): + return 0 + + return IdentityMapper.map_operator_binding(self, expr) class _InnerDerivativeJoiner(pymbolic.mapper.RecursiveMapper): diff --git a/grudge/symbolic/operators.py b/grudge/symbolic/operators.py index a1899ed2..7b315317 100644 --- a/grudge/symbolic/operators.py +++ b/grudge/symbolic/operators.py @@ -472,12 +472,15 @@ class OppositePartitionFaceSwap(Operator): dd_out = dd_in super(OppositePartitionFaceSwap, self).__init__(dd_in, dd_out) - if not isinstance(self.dd_in.domain_tag, sym.BTAG_PARTITION): - raise ValueError("dd_in must be a partition boundary faces domain") + if not (isinstance(self.dd_in.domain_tag, sym.DTAG_BOUNDARY) + and isinstance(self.dd_in.domain_tag.tag, sym.BTAG_PARTITION)): + raise ValueError( + "dd_in must be a partition boundary faces domain, not '%s'" + % self.dd_in.domain_tag) if self.dd_out != self.dd_in: raise ValueError("dd_out and dd_in must be identical") - self.i_remote_part = self.dd_in.domain_tag.part_nr + self.i_remote_part = self.dd_in.domain_tag.tag.part_nr assert unique_id is None or isinstance(unique_id, int) self.unique_id = unique_id diff --git a/grudge/symbolic/primitives.py b/grudge/symbolic/primitives.py index 0e57fcef..0cd8c6ee 100644 --- a/grudge/symbolic/primitives.py +++ b/grudge/symbolic/primitives.py @@ -149,7 +149,7 @@ class DOFDesc(object): .. automethod:: is_scalar .. automethod:: is_discretized .. automethod:: is_volume - .. automethod:: is_boundary + .. automethod:: is_boundary_or_partition_interface .. automethod:: is_trace .. automethod:: uses_quadrature .. automethod:: with_qtag @@ -203,10 +203,9 @@ class DOFDesc(object): elif domain_tag is None: pass elif isinstance(domain_tag, BTAG_PARTITION): - pass + domain_tag = DTAG_BOUNDARY(domain_tag) elif domain_tag in [BTAG_ALL, BTAG_REALLY_ALL, BTAG_NONE]: - # FIXME: Should wrap these in DTAG_BOUNDARY - pass + domain_tag = DTAG_BOUNDARY(domain_tag) elif isinstance(domain_tag, DTAG_BOUNDARY): pass else: @@ -230,15 +229,11 @@ class DOFDesc(object): def is_volume(self): return self.domain_tag is DTAG_VOLUME_ALL - def is_boundary(self): - return ( - self.domain_tag in [ - BTAG_ALL, BTAG_NONE, BTAG_REALLY_ALL] - or isinstance(self.domain_tag, BTAG_PARTITION) - or isinstance(self.domain_tag, DTAG_BOUNDARY)) + def is_boundary_or_partition_interface(self): + return isinstance(self.domain_tag, DTAG_BOUNDARY) def is_trace(self): - return (self.is_boundary() + return (self.is_boundary_or_partition_interface() or self.domain_tag in [ FACE_RESTR_ALL, FACE_RESTR_INTERIOR]) -- GitLab From eb191f0192cb719122fe605737a5b8486bb50d96 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:16:11 -0500 Subject: [PATCH 09/12] Use CI env var in flake8 invocation in Gitlab CI --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb3a2e4a..a4cf62a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ Documentation: Flake8: script: - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - - ". ./prepare-and-run-flake8.sh grudge examples test" + - ". ./prepare-and-run-flake8.sh "$CI_PROJECT_NAME" examples test" tags: - python3 except: -- GitLab From bf46ff2dd3ececf1a8a82794b2fe3ecfab70abd5 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:16:21 -0500 Subject: [PATCH 10/12] Use CI env var in flake8 invocation in Github CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 918d5a49..b4cd23f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: "Main Script" run: | curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - . ./prepare-and-run-flake8.sh ./grudge ./examples ./test + . ./prepare-and-run-flake8.sh "$(basename $GITHUB_REPOSITORY)" examples test pytest2: name: Pytest on Py2 -- GitLab From bb90062acb4b66e78b87fce7f7494f3b56fb7e90 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 14:18:03 -0500 Subject: [PATCH 11/12] Placate flake8 3.8 --- examples/dagrt-fusion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dagrt-fusion.py b/examples/dagrt-fusion.py index 27e35abd..bfb6f761 100755 --- a/examples/dagrt-fusion.py +++ b/examples/dagrt-fusion.py @@ -159,7 +159,7 @@ def transcribe_phase(dag, field_var_name, field_components, phase_name, "
": sym.var("input_dt", sym.DD_SCALAR), f"{field_var_name}": sym.make_sym_array( f"input_{field_var_name}", field_components), - f"

residual": sym.make_sym_array( + "

residual": sym.make_sym_array( "input_residual", field_components), } -- GitLab From cfecffd0a4d20d9fc9a596221235a5efc25e7687 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 17 May 2020 15:11:31 -0500 Subject: [PATCH 12/12] Fix Gitlab CI YAML syntax --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4cf62a5..7b042241 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ Documentation: Flake8: script: - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - - ". ./prepare-and-run-flake8.sh "$CI_PROJECT_NAME" examples test" + - . ./prepare-and-run-flake8.sh "$CI_PROJECT_NAME" examples test tags: - python3 except: -- GitLab