Skip to content

Commit

Permalink
Merge branch 'main' into tulio/radiation_feeder
Browse files Browse the repository at this point in the history
  • Loading branch information
MTCam authored Jun 22, 2023
2 parents 9cca721 + 11472b4 commit 99168eb
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 28 deletions.
8 changes: 4 additions & 4 deletions mirgecom/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MixtureEOSNeededError(Exception):


@dataclass_array_container
@dataclass(frozen=True)
@dataclass(frozen=True, eq=False)
class GasDependentVars:
"""State-dependent quantities for :class:`GasEOS`.
Expand All @@ -89,7 +89,7 @@ class GasDependentVars:


@dataclass_array_container
@dataclass(frozen=True)
@dataclass(frozen=True, eq=False)
class MixtureDependentVars(GasDependentVars):
"""Mixture state-dependent quantities for :class:`MixtureEOS`.
Expand Down Expand Up @@ -187,7 +187,7 @@ def dependent_vars(
temperature = self.temperature(cv, temperature_seed)
# MJA, it doesn't appear that we can have a None field embedded inside DV,
# make a dummy smoothness in this case
zeros = cv.array_context.zeros_like(cv.mass)
zeros = cv.array_context.np.zeros_like(cv.mass)
if smoothness_mu is None:
smoothness_mu = zeros
if smoothness_kappa is None:
Expand Down Expand Up @@ -265,7 +265,7 @@ def dependent_vars(
temperature = self.temperature(cv, temperature_seed)
# MJA, it doesn't appear that we can have a None field embedded inside DV,
# make a dummy smoothness in this case
zeros = cv.array_context.zeros_like(cv.mass)
zeros = cv.array_context.np.zeros_like(cv.mass)
if smoothness_mu is None:
smoothness_mu = zeros
if smoothness_kappa is None:
Expand Down
4 changes: 2 additions & 2 deletions mirgecom/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def get_element_spectrum_from_modal_representation(actx, vol_discr, modal_fields
Array with the element modes accumulated into the corresponding
"modes" for the polynomial basis functions for each field.
"""
modal_spectra = np.stack(
modal_spectra = np.stack([
actx.to_numpy(ary)[0]
for ary in modal_fields)
for ary in modal_fields])

numfields, numelem, nummodes = modal_spectra.shape

Expand Down
5 changes: 3 additions & 2 deletions mirgecom/fluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
bcast_container_types=(DOFArray, np.ndarray),
matmul=True,
_cls_has_array_context_attr=True,
rel_comparison=True)
eq_comparison=False,
rel_comparison=False)
@dataclass_array_container
@dataclass(frozen=True)
@dataclass(frozen=True, eq=False)
class ConservedVars:
r"""Store and resolve quantities according to the fluid conservation equations.
Expand Down
8 changes: 4 additions & 4 deletions mirgecom/gas_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class GasModel:


@dataclass_array_container
@dataclass(frozen=True)
@dataclass(frozen=True, eq=False)
class FluidState:
r"""Gas model-consistent fluid state.
Expand Down Expand Up @@ -318,11 +318,11 @@ def make_fluid_state(cv, gas_model, temperature_seed=None,
dd=limiter_dd)

# FIXME work-around for now
smoothness_mu = (actx.zeros_like(pressure) if smoothness_mu
smoothness_mu = (actx.np.zeros_like(pressure) if smoothness_mu
is None else smoothness_mu)
smoothness_kappa = (actx.zeros_like(pressure) if smoothness_kappa
smoothness_kappa = (actx.np.zeros_like(pressure) if smoothness_kappa
is None else smoothness_kappa)
smoothness_beta = (actx.zeros_like(pressure) if smoothness_beta
smoothness_beta = (actx.np.zeros_like(pressure) if smoothness_beta
is None else smoothness_beta)

dv = GasDependentVars(
Expand Down
2 changes: 1 addition & 1 deletion mirgecom/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TransportModelError(Exception):


@dataclass_array_container
@dataclass(frozen=True)
@dataclass(frozen=True, eq=False)
class GasTransportVars:
"""State-dependent quantities for :class:`TransportModel`.
Expand Down
4 changes: 2 additions & 2 deletions test/test_av.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ def _boundary_state_func(dcoll, dd_bdry, gas_model, state_minus, **kwargs):

bnd_flux_resid = (prescribed_boundary_av_flux - exp_av_flux)
print(f"{bnd_flux_resid=}")
assert bnd_flux_resid == 0
assert actx.np.equal(bnd_flux_resid, 0)

# Solid wall boundaries are expected to have 0 AV flux
wall_bnd_flux = \
adiabatic_noslip.av_flux(dcoll, BTAG_ALL, av_diffusion)
print(f"adiabatic_noslip: {wall_bnd_flux=}")
assert wall_bnd_flux == 0
assert actx.np.equal(wall_bnd_flux, 0)
18 changes: 9 additions & 9 deletions test/test_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def gradient_flux_interior(int_tpair):
grad_t_minus=grad_t_minus)
print(f"{v_flux_bc=}")

assert ff_bndry_state.cv == exp_ff_cv
assert actx.np.equal(ff_bndry_state.cv, exp_ff_cv)
assert actx.np.all(temperature_bc == ff_temp)
for idim in range(dim):
assert actx.np.all(ff_bndry_state.momentum_density[idim]
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_outflow_boundary(actx_factory, dim, flux_func):

print(f"{exp_flowbnd_cv=}")

assert flowbnd_bndry_state.cv == exp_flowbnd_cv
assert actx.np.equal(flowbnd_bndry_state.cv, exp_flowbnd_cv)
assert actx.np.all(flowbnd_bndry_temperature == flowbnd_press_bc)
assert actx.np.all(flowbnd_bndry_pressure == flowbnd_press_bc)

Expand Down Expand Up @@ -421,7 +421,7 @@ def test_outflow_boundary(actx_factory, dim, flux_func):
exp_flowbnd_cv = make_conserved(dim=dim, mass=bnd_dens,
momentum=bnd_mom, energy=bnd_ener)

assert flowbnd_bndry_state.cv == exp_flowbnd_cv
assert actx.np.equal(flowbnd_bndry_state.cv, exp_flowbnd_cv)


@pytest.mark.parametrize("dim", [1, 2, 3])
Expand Down Expand Up @@ -585,7 +585,7 @@ def gradient_flux_interior(int_tpair):
grad_t_minus=grad_t_minus)
print(f"{v_flux_bc=}")

assert wall_state.cv == expected_noslip_cv
assert actx.np.equal(wall_state.cv, expected_noslip_cv)
assert actx.np.all(temperature_bc == expected_wall_temperature)
for idim in range(dim):
assert actx.np.all(wall_state.momentum_density[idim]
Expand Down Expand Up @@ -762,8 +762,8 @@ def gradient_flux_interior(int_tpair):
grad_t_minus=grad_t_minus)
print(f"{v_flux_bc=}")

assert adv_wall_state.cv == expected_adv_wall_cv
assert diff_wall_state.cv == expected_diff_wall_cv
assert actx.np.equal(adv_wall_state.cv, expected_adv_wall_cv)
assert actx.np.equal(diff_wall_state.cv, expected_diff_wall_cv)
assert actx.np.all(temperature_bc == expected_wall_temperature)
for idim in range(dim):
assert actx.np.all(adv_wall_state.momentum_density[idim]
Expand Down Expand Up @@ -956,8 +956,8 @@ def gradient_flux_interior(int_tpair):
temperature_bc = wall.temperature_bc(
dcoll, dd_bdry=BTAG_ALL, state_minus=state_minus)

assert adv_wall_state.cv == expected_adv_wall_cv
assert diff_wall_state.cv == expected_diff_wall_cv
assert actx.np.equal(adv_wall_state.cv, expected_adv_wall_cv)
assert actx.np.equal(diff_wall_state.cv, expected_diff_wall_cv)
assert actx.np.all(temperature_bc == expected_temp_boundary)

for idim in range(dim):
Expand Down Expand Up @@ -1342,4 +1342,4 @@ def scalar_flux_interior(int_tpair):
bc_soln = \
domain_boundary._boundary_state_pair(dcoll, BTAG_ALL, gas_model,
state_minus=state_minus).ext.cv
assert bc_soln == expected_boundary_solution
assert actx.np.equal(bc_soln, expected_boundary_solution)
2 changes: 1 addition & 1 deletion test/test_navierstokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def test_exact_mms(actx_factory, order, dim, manufactured_soln, mu):
tol = 1e-15

if mu == 0:
assert sym_ns_source == sym_euler_source
assert actx.np.equal(sym_ns_source, sym_euler_source)
sym_source = sym_euler_source
else:
sym_source = sym_ns_source
Expand Down
13 changes: 10 additions & 3 deletions test/test_symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,23 @@ def _array_container_deriv_pair():
_obj_array_deriv_pair(),
_array_container_deriv_pair(),
])
def test_symbolic_diff(sym_f, expected_sym_df):
def test_symbolic_diff(actx_factory, sym_f, expected_sym_df):
"""
Compute the symbolic derivative of an expression and compare it to an
expected result.
"""
actx = actx_factory()

sym_df = sym.diff(pmbl.var("x"))(sym_f)
if isinstance(sym_f, np.ndarray):

from pymbolic.primitives import Expression
if isinstance(sym_f, Expression):
assert sym_df == expected_sym_df
elif isinstance(sym_f, np.ndarray):
assert (sym_df == expected_sym_df).all()
else:
assert sym_df == expected_sym_df
# Array container
assert actx.np.equal(sym_df, expected_sym_df)


def test_symbolic_div():
Expand Down

0 comments on commit 99168eb

Please sign in to comment.