diff --git a/examples/advection/surface.py b/examples/advection/surface.py index c1134de9cbe26ecb48dc73ca60dedd077aa7bdb1..05deb364c025ac7becedb52b3793c2f1f66ae8e9 100644 --- a/examples/advection/surface.py +++ b/examples/advection/surface.py @@ -236,7 +236,7 @@ def main(ctx_factory, dim=2, order=4, use_quad=False, visualize=False): overwrite=True ) - df = dof_desc.DOFDesc(FACE_RESTR_INTERIOR) + df = dof_desc.as_dofdesc(FACE_RESTR_INTERIOR) face_discr = dcoll.discr_from_dd(df) face_normal = geo.normal(actx, dcoll, dd=df) diff --git a/examples/advection/var-velocity.py b/examples/advection/var-velocity.py index 217df74d5fd16bd339e726d540ddfb6009a713f8..9c73a1af35a871d816c34a2513b25ed41cc8ba48 100644 --- a/examples/advection/var-velocity.py +++ b/examples/advection/var-velocity.py @@ -160,7 +160,7 @@ def main(ctx_factory, dim=2, order=4, use_quad=False, visualize=False, * (0.5+0.5*actx.np.tanh(500*(dist[0])))) def zero_inflow_bc(dtag, t=0): - dd = dof_desc.DOFDesc(dtag, qtag) + dd = dof_desc.as_dofdesc(dtag, qtag) return dcoll.discr_from_dd(dd).zeros(actx) from grudge.models.advection import VariableCoefficientAdvectionOperator diff --git a/examples/wave/wave-op-var-velocity.py b/examples/wave/wave-op-var-velocity.py index 8b1b28a28082e25cf4f96712b7fd376f641a23d2..486608a398fe6aad1d1ced3069699576cd14ccf1 100644 --- a/examples/wave/wave-op-var-velocity.py +++ b/examples/wave/wave-op-var-velocity.py @@ -38,7 +38,7 @@ import grudge.geometry as geo import grudge.op as op from grudge.array_context import PyOpenCLArrayContext from grudge.discretization import make_discretization_collection -from grudge.dof_desc import DISCR_TAG_BASE, DISCR_TAG_QUAD, DOFDesc +from grudge.dof_desc import DISCR_TAG_BASE, DISCR_TAG_QUAD, as_dofdesc from grudge.shortcuts import make_visualizer, rk4_step @@ -84,13 +84,13 @@ def wave_operator(actx, dcoll, c, w): dir_bval = flat_obj_array(dir_u, dir_v) dir_bc = flat_obj_array(-dir_u, dir_v) - dd_quad = DOFDesc("vol", DISCR_TAG_QUAD) + dd_quad = as_dofdesc("vol", DISCR_TAG_QUAD) c_quad = op.project(dcoll, "vol", dd_quad, c) w_quad = op.project(dcoll, "vol", dd_quad, w) u_quad = w_quad[0] v_quad = w_quad[1:] - dd_allfaces_quad = DOFDesc("all_faces", DISCR_TAG_QUAD) + dd_allfaces_quad = as_dofdesc("all_faces", DISCR_TAG_QUAD) return ( op.inverse_mass( diff --git a/grudge/dof_desc.py b/grudge/dof_desc.py index da1f4a41b26208d3e106f27c6b557b508da30919..27c031b3726349ed35655e731af7bdcf86dbff2f 100644 --- a/grudge/dof_desc.py +++ b/grudge/dof_desc.py @@ -230,8 +230,9 @@ class DOFDesc: domain_tag: DomainTag discretization_tag: DiscretizationTag - def __init__(self, domain_tag: Any, - discretization_tag: Optional[type[DiscretizationTag]] = None): + def __init__(self, + domain_tag: Any, + discretization_tag: Optional[Type[DiscretizationTag]] = None): if ( not (isinstance(domain_tag, diff --git a/grudge/models/advection.py b/grudge/models/advection.py index c5cba7798064c0ae7e807674f417df06e6259be5..8bf2260d374d90058da54ed20eb90898c2d068f3 100644 --- a/grudge/models/advection.py +++ b/grudge/models/advection.py @@ -106,8 +106,10 @@ class StrongAdvectionOperator(AdvectionOperatorBase): return op.project(dcoll, tpair.dd, "all_faces", self.flux(tpair)) if self.inflow_u is not None: + from grudge.dof_desc import as_dofdesc + inflow_flux = flux(op.bv_trace_pair(dcoll, - BTAG_ALL, + as_dofdesc(BTAG_ALL), interior=u, exterior=self.inflow_u(t))) else: @@ -149,8 +151,9 @@ class WeakAdvectionOperator(AdvectionOperatorBase): return op.project(dcoll, tpair.dd, "all_faces", self.flux(tpair)) if self.inflow_u is not None: + from grudge.dof_desc import as_dofdesc inflow_flux = flux(op.bv_trace_pair(dcoll, - BTAG_ALL, + as_dofdesc(BTAG_ALL), interior=u, exterior=self.inflow_u(t))) else: @@ -225,11 +228,11 @@ class VariableCoefficientAdvectionOperator(AdvectionOperatorBase): from meshmode.discretization.connection import FACE_RESTR_ALL from meshmode.mesh import BTAG_ALL - from grudge.dof_desc import DD_VOLUME_ALL, DTAG_VOLUME_ALL, DOFDesc + from grudge.dof_desc import DD_VOLUME_ALL, DTAG_VOLUME_ALL, as_dofdesc - face_dd = DOFDesc(FACE_RESTR_ALL, self.quad_tag) - boundary_dd = DOFDesc(BTAG_ALL, self.quad_tag) - quad_dd = DOFDesc(DTAG_VOLUME_ALL, self.quad_tag) + face_dd = as_dofdesc(FACE_RESTR_ALL, self.quad_tag) + boundary_dd = as_dofdesc(BTAG_ALL, self.quad_tag) + quad_dd = as_dofdesc(DTAG_VOLUME_ALL, self.quad_tag) dcoll = self.dcoll @@ -340,10 +343,10 @@ class SurfaceAdvectionOperator(AdvectionOperatorBase): def operator(self, t, u): from meshmode.discretization.connection import FACE_RESTR_ALL - from grudge.dof_desc import DD_VOLUME_ALL, DTAG_VOLUME_ALL, DOFDesc + from grudge.dof_desc import DD_VOLUME_ALL, DTAG_VOLUME_ALL, as_dofdesc - face_dd = DOFDesc(FACE_RESTR_ALL, self.quad_tag) - quad_dd = DOFDesc(DTAG_VOLUME_ALL, self.quad_tag) + face_dd = as_dofdesc(FACE_RESTR_ALL, self.quad_tag) + quad_dd = as_dofdesc(DTAG_VOLUME_ALL, self.quad_tag) dcoll = self.dcoll diff --git a/grudge/models/em.py b/grudge/models/em.py index c7c5a72568a716118362f70ad54a5d3c0c6dcc1d..4e32c9ba8afd19969a0f64dba5a5adb6bf6b76d6 100644 --- a/grudge/models/em.py +++ b/grudge/models/em.py @@ -410,6 +410,8 @@ class MaxwellOperator(HyperbolicOperator): def flux(pair): return op.project(dcoll, pair.dd, "all_faces", self.flux(pair)) + from grudge.dof_desc import as_dofdesc + return ( - self.local_derivatives(w) - op.inverse_mass( @@ -417,7 +419,7 @@ class MaxwellOperator(HyperbolicOperator): op.face_mass( dcoll, sum(flux(tpair) for tpair in op.interior_trace_pairs(dcoll, w)) - + sum(flux(op.bv_trace_pair(dcoll, tag, w, bc)) + + sum(flux(op.bv_trace_pair(dcoll, as_dofdesc(tag), w, bc)) for tag, bc in tags_and_bcs) ) ) @@ -462,7 +464,8 @@ class MaxwellOperator(HyperbolicOperator): self.pec_tag, self.pmc_tag, self.absorb_tag, - self.incident_tag]) + self.incident_tag, + ]) # }}} diff --git a/grudge/models/euler.py b/grudge/models/euler.py index a288b486e65c6476f8537c27e93c78c807fcf82b..8d182986ccf824309d2464feba5cfd1d678f7ecc 100644 --- a/grudge/models/euler.py +++ b/grudge/models/euler.py @@ -180,7 +180,7 @@ class PrescribedBC(InviscidBCObject): dd_bc: DOFDesc, state: ConservedEulerField, t=0): actx = state.array_context - dd_base = as_dofdesc("vol").with_discr_tag(DISCR_TAG_BASE) + dd_base = as_dofdesc("vol", DISCR_TAG_BASE) return TracePair( dd_bc, @@ -197,7 +197,7 @@ class InviscidWallBC(InviscidBCObject): dd_bc: DOFDesc, state: ConservedEulerField, t=0): actx = state.array_context - dd_base = as_dofdesc("vol").with_discr_tag(DISCR_TAG_BASE) + dd_base = as_dofdesc("vol", DISCR_TAG_BASE) nhat = geo.normal(actx, dcoll, dd_bc) interior = op.project(dcoll, dd_base, dd_bc, state) @@ -253,8 +253,12 @@ def euler_numerical_flux( dissipation. :returns: A :class:`ConservedEulerField` containing the interface fluxes. """ + from grudge.dof_desc import FACE_RESTR_ALL, VTAG_ALL, BoundaryDomainTag + dd_intfaces = tpair.dd - dd_allfaces = dd_intfaces.with_dtag("all_faces") + dd_allfaces = dd_intfaces.with_domain_tag( + BoundaryDomainTag(FACE_RESTR_ALL, VTAG_ALL) + ) q_ll = tpair.int q_rr = tpair.ext actx = q_ll.array_context @@ -310,8 +314,8 @@ class EulerOperator(HyperbolicOperator): dcoll = self.dcoll gamma = self.gamma qtag = self.qtag - dq = DOFDesc("vol", qtag) - df = DOFDesc("all_faces", qtag) + dq = as_dofdesc("vol", qtag) + df = as_dofdesc("all_faces", qtag) def interp_to_quad(u): return op.project(dcoll, "vol", dq, u) @@ -341,7 +345,7 @@ class EulerOperator(HyperbolicOperator): dcoll, self.bdry_conditions[btag].boundary_tpair( dcoll, - as_dofdesc(btag).with_discr_tag(qtag), + as_dofdesc(btag, qtag), q, t=t ), diff --git a/test/test_grudge.py b/test/test_grudge.py index 38f4af4fdd4c12bd9481d8e5c82db8d5f9a705ff..8a5a5a67852f35a719cceafe7b1f503ae1c5a018 100644 --- a/test/test_grudge.py +++ b/test/test_grudge.py @@ -1024,7 +1024,7 @@ def test_improvement_quadrature(actx_factory, order): nodes = actx.thaw(dcoll.nodes()) def zero_inflow(dtag, t=0, dcoll=dcoll): - dd = dof_desc.DOFDesc(dtag, qtag) + dd = dof_desc.as_dofdesc(dtag, qtag) return dcoll.discr_from_dd(dd).zeros(actx) adv_op = VariableCoefficientAdvectionOperator( diff --git a/test/test_op.py b/test/test_op.py index 125c69570e85f404964ff9131cc891d94c5b8564..17f49a0744625ef8b206201c21788503b11d98b8 100644 --- a/test/test_op.py +++ b/test/test_op.py @@ -42,7 +42,9 @@ from grudge.dof_desc import ( DISCR_TAG_BASE, DISCR_TAG_QUAD, DTAG_VOLUME_ALL, - DOFDesc, + FACE_RESTR_ALL, + VTAG_ALL, + BoundaryDomainTag, as_dofdesc, ) from grudge.trace_pair import bv_trace_pair @@ -118,7 +120,9 @@ def test_gradient(actx_factory, form, dim, order, vectorize, nested, def get_flux(u_tpair, dcoll=dcoll): dd = u_tpair.dd - dd_allfaces = dd.with_domain_tag("all_faces") + dd_allfaces = dd.with_domain_tag( + BoundaryDomainTag(FACE_RESTR_ALL, VTAG_ALL) + ) normal = geometry.normal(actx, dcoll, dd) u_avg = u_tpair.avg if vectorize: @@ -149,7 +153,7 @@ def test_gradient(actx_factory, form, dim, order, vectorize, nested, else: quad_discr_tag = DISCR_TAG_BASE - allfaces_dd_base = as_dofdesc("all_faces", quad_discr_tag) + allfaces_dd_base = as_dofdesc(FACE_RESTR_ALL, quad_discr_tag) vol_dd_base = as_dofdesc(DTAG_VOLUME_ALL) vol_dd_quad = vol_dd_base.with_discr_tag(quad_discr_tag) bdry_dd_quad = bdry_dd_base.with_discr_tag(quad_discr_tag) @@ -270,12 +274,14 @@ def test_divergence(actx_factory, form, dim, order, vectorize, nested, def get_flux(u_tpair, dcoll=dcoll): dd = u_tpair.dd - dd_allfaces = dd.with_dtag("all_faces") + dd_allfaces = dd.with_domain_tag( + BoundaryDomainTag(FACE_RESTR_ALL, VTAG_ALL) + ) normal = geometry.normal(actx, dcoll, dd) flux = u_tpair.avg @ normal return op.project(dcoll, dd, dd_allfaces, flux) - dd_allfaces = DOFDesc("all_faces") + dd_allfaces = as_dofdesc(FACE_RESTR_ALL) if form == "strong": div_u = (