diff --git a/examples/advection/advection.py b/examples/advection/advection.py index 5179e9141a07b5f88dbb9e698f9757ddb43e2dbe..f55bd98a0c3e5e25364dea0041d9b6b2e9a14079 100644 --- a/examples/advection/advection.py +++ b/examples/advection/advection.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -25,11 +25,11 @@ import numpy.linalg as la def main(write_output=True, flux_type_arg="upwind"): - from hedge.tools import mem_checkpoint + from grudge.tools import mem_checkpoint from math import sin, cos, pi, sqrt from math import floor - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() def f(x): @@ -49,17 +49,17 @@ def main(write_output=True, flux_type_arg="upwind"): if dim == 1: v = numpy.array([1]) if rcon.is_head_rank: - from hedge.mesh.generator import make_uniform_1d_mesh + from grudge.mesh.generator import make_uniform_1d_mesh mesh = make_uniform_1d_mesh(0, 2, 10, periodic=True) elif dim == 2: v = numpy.array([2,0]) if rcon.is_head_rank: - from hedge.mesh.generator import make_disk_mesh + from grudge.mesh.generator import make_disk_mesh mesh = make_disk_mesh(boundary_tagger=boundary_tagger) elif dim == 3: v = numpy.array([0,0,1]) if rcon.is_head_rank: - from hedge.mesh.generator import make_cylinder_mesh, make_ball_mesh, make_box_mesh + from grudge.mesh.generator import make_cylinder_mesh, make_ball_mesh, make_box_mesh mesh = make_cylinder_mesh(max_volume=0.04, height=2, boundary_tagger=boundary_tagger, periodic=False, radial_subdivisions=32) @@ -79,16 +79,16 @@ def main(write_output=True, flux_type_arg="upwind"): discr = rcon.make_discretization(mesh_data, order=4) vis_discr = discr - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(vis_discr, rcon, "fld") # operator setup ---------------------------------------------------------- - from hedge.data import \ + from grudge.data import \ ConstantGivenFunction, \ TimeConstantGivenFunction, \ TimeDependentGivenFunction - from hedge.models.advection import StrongAdvectionOperator, WeakAdvectionOperator + from grudge.models.advection import StrongAdvectionOperator, WeakAdvectionOperator op = WeakAdvectionOperator(v, inflow_u=TimeDependentGivenFunction(u_analytic), flux_type=flux_type_arg) @@ -96,7 +96,7 @@ def main(write_output=True, flux_type_arg="upwind"): u = discr.interpolate_volume_function(lambda x, el: u_analytic(x, el, 0)) # timestep setup ---------------------------------------------------------- - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper() if rcon.is_head_rank: @@ -121,7 +121,7 @@ def main(write_output=True, flux_type_arg="upwind"): stepper.add_instrumentation(logmgr) - from hedge.log import Integral, LpNorm + from grudge.log import Integral, LpNorm u_getter = lambda: u logmgr.add_quantity(Integral(u_getter, discr, name="int_u")) logmgr.add_quantity(LpNorm(u_getter, discr, p=1, name="l1_u")) @@ -133,7 +133,7 @@ def main(write_output=True, flux_type_arg="upwind"): rhs = op.bind(discr) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=3, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/advection/var-velocity.py b/examples/advection/var-velocity.py index fa97c7d0b9c68ee271183ab782d4900cf3504e8d..89bd973ea350da866c0ac3c6558024507a3fae02 100644 --- a/examples/advection/var-velocity.py +++ b/examples/advection/var-velocity.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2009 Andreas Stock # # This program is free software: you can redistribute it and/or modify @@ -28,14 +28,14 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, final_time=20): from math import sin, cos, pi, sqrt - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() # mesh setup -------------------------------------------------------------- if rcon.is_head_rank: - #from hedge.mesh.generator import make_disk_mesh + #from grudge.mesh.generator import make_disk_mesh #mesh = make_disk_mesh() - from hedge.mesh.generator import make_rect_mesh + from grudge.mesh.generator import make_rect_mesh mesh = make_rect_mesh(a=(-1,-1),b=(1,1),max_area=0.008) if rcon.is_head_rank: @@ -102,12 +102,12 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, # For `VField`: advec_v=TimeConstantGivenFunction(GivenFunction(VField())) # Same for the Bc_u Function! If you don't define Bc_u then the BC for u = 0. - from hedge.data import \ + from grudge.data import \ ConstantGivenFunction, \ TimeConstantGivenFunction, \ TimeDependentGivenFunction, \ GivenFunction - from hedge.models.advection import VariableCoefficientAdvectionOperator + from grudge.models.advection import VariableCoefficientAdvectionOperator op = VariableCoefficientAdvectionOperator(mesh.dimensions, #advec_v=TimeDependentGivenFunction( # TimeDependentVField()), @@ -136,7 +136,7 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, vis_discr = discr # visualization setup ----------------------------------------------------- - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(vis_discr, rcon, "fld") @@ -159,7 +159,7 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, u = discr.interpolate_volume_function(initial) # timestep setup ---------------------------------------------------------- - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper( vector_primitive_factory=discr.get_vector_primitive_factory()) @@ -167,8 +167,8 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, print("%d elements" % len(discr.mesh.elements)) # filter setup------------------------------------------------------------- - from hedge.discretization import ExponentialFilterResponseFunction - from hedge.optemplate.operators import FilterOperator + from grudge.discretization import ExponentialFilterResponseFunction + from grudge.optemplate.operators import FilterOperator mode_filter = FilterOperator( ExponentialFilterResponseFunction(min_amplification=0.9,order=4))\ .bind(discr) @@ -192,7 +192,7 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, stepper.add_instrumentation(logmgr) - from hedge.log import Integral, LpNorm + from grudge.log import Integral, LpNorm u_getter = lambda: u logmgr.add_quantity(Integral(u_getter, discr, name="int_u")) logmgr.add_quantity(LpNorm(u_getter, discr, p=1, name="l1_u")) @@ -206,7 +206,7 @@ def main(write_output=True, flux_type_arg="central", use_quadrature=True, # timestep loop ----------------------------------------------------------- rhs = op.bind(discr) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=final_time, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/burgers/burgers.py b/examples/burgers/burgers.py index 0b9bc93c37032d3bf4cc3c024f026e6467a0ead3..c360fde95083d6f6c5bf2cc903e205e13814ef51 100644 --- a/examples/burgers/burgers.py +++ b/examples/burgers/burgers.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -100,16 +100,16 @@ def main(write_output=True, flux_type_arg="upwind", #case = OffCenterMigratingTestCase(), case = ExactTestCase(), ): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() order = 3 if rcon.is_head_rank: if True: - from hedge.mesh.generator import make_uniform_1d_mesh + from grudge.mesh.generator import make_uniform_1d_mesh mesh = make_uniform_1d_mesh(case.a, case.b, 20, periodic=True) else: - from hedge.mesh.generator import make_rect_mesh + from grudge.mesh.generator import make_rect_mesh print((pi*2)/(11*5*2)) mesh = make_rect_mesh((-pi, -1), (pi, 1), periodicity=(True, True), @@ -126,13 +126,13 @@ def main(write_output=True, flux_type_arg="upwind", quad_min_degrees={"quad": 3*order}) if write_output: - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer vis = VtkVisualizer(discr, rcon, "fld") # operator setup ---------------------------------------------------------- - from hedge.second_order import IPDGSecondDerivative + from grudge.second_order import IPDGSecondDerivative - from hedge.models.burgers import BurgersOperator + from grudge.models.burgers import BurgersOperator op = BurgersOperator(mesh.dimensions, viscosity_scheme=IPDGSecondDerivative()) @@ -162,7 +162,7 @@ def main(write_output=True, flux_type_arg="upwind", add_simulation_quantities(logmgr) discr.add_instrumentation(logmgr) - from hedge.log import LpNorm + from grudge.log import LpNorm u_getter = lambda: u logmgr.add_quantity(LpNorm(u_getter, discr, p=1, name="l1_u")) @@ -171,13 +171,13 @@ def main(write_output=True, flux_type_arg="upwind", # timestep loop ----------------------------------------------------------- rhs = op.bind(discr) - from hedge.timestep.runge_kutta import ODE45TimeStepper, LSRK4TimeStepper + from grudge.timestep.runge_kutta import ODE45TimeStepper, LSRK4TimeStepper stepper = ODE45TimeStepper() stepper.add_instrumentation(logmgr) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps # for visc=0.01 #stab_fac = 0.1 # RK4 #stab_fac = 1.6 # dumka3(3), central @@ -192,7 +192,7 @@ def main(write_output=True, flux_type_arg="upwind", step_it = times_and_steps( final_time=case.final_time, logmgr=logmgr, max_dt_getter=lambda t: dt) - from hedge.optemplate import InverseVandermondeOperator + from grudge.optemplate import InverseVandermondeOperator inv_vdm = InverseVandermondeOperator().bind(discr) for step, t, dt in step_it: diff --git a/examples/conftest.py b/examples/conftest.py index ec99a4c7fd882c79b4c0e1b6b78b16ab578b8532..273b1c4a6bd099f96831d406678c910fc9371722 100644 --- a/examples/conftest.py +++ b/examples/conftest.py @@ -3,5 +3,5 @@ def pytest_collect_file(path, parent): - if "hedge/examples" in str(path.dirpath()) and path.ext == ".py": + if "grudge/examples" in str(path.dirpath()) and path.ext == ".py": return parent.Module(path, parent=parent) diff --git a/examples/gas_dynamics/box-in-box.py b/examples/gas_dynamics/box-in-box.py index 5cc0764e2eb842bea83bfc09d15f9e82cca3f99c..44b00c7a55e694dcef6bc620b7b203762491b2b9 100644 --- a/examples/gas_dynamics/box-in-box.py +++ b/examples/gas_dynamics/box-in-box.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -82,18 +82,18 @@ def make_boxmesh(): face_marker = fvi2fm[fvi] return [face_marker_to_tag[face_marker]] - from hedge.mesh import make_conformal_mesh + from grudge.mesh import make_conformal_mesh return make_conformal_mesh( mesh.points, mesh.elements, bdry_tagger) def main(): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context(["cuda"]) if rcon.is_head_rank: mesh = make_boxmesh() - #from hedge.mesh import make_rect_mesh + #from grudge.mesh import make_rect_mesh #mesh = make_rect_mesh( # boundary_tagger=lambda fvi, el, fn, all_v: ["inflow"]) mesh_data = rcon.distribute_mesh(mesh) @@ -107,7 +107,7 @@ def main(): from gas_dynamics_initials import UniformMachFlow box = UniformMachFlow(angle_of_attack=0) - from hedge.models.gas_dynamics import GasDynamicsOperator + from grudge.models.gas_dynamics import GasDynamicsOperator op = GasDynamicsOperator(dimensions=3, gamma=box.gamma, mu=box.mu, prandtl=box.prandtl, spec_gas_const=box.spec_gas_const, @@ -127,7 +127,7 @@ def main(): default_scalar_type=numpy.float32, tune_for=op.op_template()) - from hedge.visualization import SiloVisualizer, VtkVisualizer # noqa + from grudge.visualization import SiloVisualizer, VtkVisualizer # noqa #vis = VtkVisualizer(discr, rcon, "shearflow-%d" % order) vis = SiloVisualizer(discr, rcon) @@ -150,7 +150,7 @@ def main(): print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep import RK4TimeStepper + from grudge.timestep import RK4TimeStepper stepper = RK4TimeStepper() # diagnostics setup --------------------------------------------------- @@ -186,7 +186,7 @@ def main(): # timestep loop ------------------------------------------------------- try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=200, #max_steps=500, diff --git a/examples/gas_dynamics/euler/sine-wave.py b/examples/gas_dynamics/euler/sine-wave.py index 2916e3fb79120771662a630ff48ae1cc3e13f30f..941ee2adbee15de06ccbb106c94e0c8b550b2be5 100644 --- a/examples/gas_dynamics/euler/sine-wave.py +++ b/examples/gas_dynamics/euler/sine-wave.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -42,7 +42,7 @@ class SineWave: rho_v = rho * velocity[1] rho_w = rho * velocity[2] - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho, e, rho_u, rho_v, rho_w) def properties(self): @@ -62,14 +62,14 @@ class SineWave: def main(final_time=1, write_output=False): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() - from hedge.tools import EOCRecorder, to_obj_array + from grudge.tools import EOCRecorder, to_obj_array eoc_rec = EOCRecorder() if rcon.is_head_rank: - from hedge.mesh import make_box_mesh + from grudge.mesh import make_box_mesh mesh = make_box_mesh((0,0,0), (10,10,10), max_volume=0.5) mesh_data = rcon.distribute_mesh(mesh) else: @@ -79,7 +79,7 @@ def main(final_time=1, write_output=False): discr = rcon.make_discretization(mesh_data, order=order, default_scalar_type=numpy.float64) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer vis = VtkVisualizer(discr, rcon, "sinewave-%d" % order) #vis = SiloVisualizer(discr, rcon) @@ -87,8 +87,8 @@ def main(final_time=1, write_output=False): fields = sinewave.volume_interpolant(0, discr) gamma, mu, prandtl, spec_gas_const = sinewave.properties() - from hedge.mesh import TAG_ALL - from hedge.models.gas_dynamics import GasDynamicsOperator + from grudge.mesh import TAG_ALL + from grudge.models.gas_dynamics import GasDynamicsOperator op = GasDynamicsOperator(dimensions=mesh.dimensions, gamma=gamma, mu=mu, prandtl=prandtl, spec_gas_const=spec_gas_const, bc_inflow=sinewave, bc_outflow=sinewave, bc_noslip=sinewave, @@ -109,7 +109,7 @@ def main(final_time=1, write_output=False): print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep import RK4TimeStepper + from grudge.timestep import RK4TimeStepper stepper = RK4TimeStepper() # diagnostics setup --------------------------------------------------- @@ -132,7 +132,7 @@ def main(final_time=1, write_output=False): # timestep loop ------------------------------------------------------- try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=final_time, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/gas_dynamics/euler/sod-2d.py b/examples/gas_dynamics/euler/sod-2d.py index 207e00e7382cefcc899647634b4cae2044bd5535..0e6320c216f0965fe65ad77cb51307025768cf34 100644 --- a/examples/gas_dynamics/euler/sod-2d.py +++ b/examples/gas_dynamics/euler/sod-2d.py @@ -14,8 +14,8 @@ class Sod: def __call__(self, t, x_vec): - from hedge.tools import heaviside - from hedge.tools import heaviside_a + from grudge.tools import heaviside + from grudge.tools import heaviside_a x_rel = x_vec[0] y_rel = x_vec[1] @@ -30,7 +30,7 @@ class Sod: e = (1.0/(self.gamma-1.0))*(heaviside(-r_shift)+.1*heaviside_a(r_shift,1.0)) p = (self.gamma-1.0)*e - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho, e, rho*u, rho*v) @@ -48,13 +48,13 @@ class Sod: def main(): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() - from hedge.tools import to_obj_array + from grudge.tools import to_obj_array if rcon.is_head_rank: - from hedge.mesh.generator import make_rect_mesh + from grudge.mesh.generator import make_rect_mesh mesh = make_rect_mesh((-5,-5), (5,5), max_area=0.01) mesh_data = rcon.distribute_mesh(mesh) else: @@ -64,15 +64,15 @@ def main(): discr = rcon.make_discretization(mesh_data, order=order, default_scalar_type=numpy.float64) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer vis = VtkVisualizer(discr, rcon, "Sod2D-%d" % order) #vis = SiloVisualizer(discr, rcon) sod_field = Sod(gamma=1.4) fields = sod_field.volume_interpolant(0, discr) - from hedge.models.gas_dynamics import GasDynamicsOperator - from hedge.mesh import TAG_ALL + from grudge.models.gas_dynamics import GasDynamicsOperator + from grudge.mesh import TAG_ALL op = GasDynamicsOperator(dimensions=2, gamma=sod_field.gamma, mu=0.0, prandtl=sod_field.prandtl, bc_inflow=sod_field, @@ -97,11 +97,11 @@ def main(): print("#elements=", len(mesh.elements)) # limiter setup ------------------------------------------------------------ - from hedge.models.gas_dynamics import SlopeLimiter1NEuler + from grudge.models.gas_dynamics import SlopeLimiter1NEuler limiter = SlopeLimiter1NEuler(discr, sod_field.gamma, 2, op) # integrator setup--------------------------------------------------------- - from hedge.timestep import SSPRK3TimeStepper, RK4TimeStepper + from grudge.timestep import SSPRK3TimeStepper, RK4TimeStepper stepper = SSPRK3TimeStepper(limiter=limiter) #stepper = SSPRK3TimeStepper() #stepper = RK4TimeStepper() @@ -120,13 +120,13 @@ def main(): logmgr.add_watches(["step.max", "t_sim.max", "t_step.max"]) # filter setup------------------------------------------------------------- - from hedge.discretization import Filter, ExponentialFilterResponseFunction + from grudge.discretization import Filter, ExponentialFilterResponseFunction mode_filter = Filter(discr, ExponentialFilterResponseFunction(min_amplification=0.9,order=4)) # timestep loop ------------------------------------------------------- try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=1.0, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/gas_dynamics/euler/vortex-adaptive-grid.py b/examples/gas_dynamics/euler/vortex-adaptive-grid.py index 1f03d393e468758a81eee4da2a8dd00a801b5408..faff8d2877b8db24d98fdb11d85859c6f32ab211 100644 --- a/examples/gas_dynamics/euler/vortex-adaptive-grid.py +++ b/examples/gas_dynamics/euler/vortex-adaptive-grid.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -30,15 +30,15 @@ def main(write_output=True): from pytools import add_python_path_relative_to_script add_python_path_relative_to_script("..") - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() - from hedge.tools import EOCRecorder + from grudge.tools import EOCRecorder eoc_rec = EOCRecorder() if rcon.is_head_rank: - from hedge.mesh.generator import \ + from grudge.mesh.generator import \ make_rect_mesh, \ make_centered_regular_rect_mesh @@ -51,7 +51,7 @@ def main(write_output=True): # a second mesh to regrid to if rcon.is_head_rank: - from hedge.mesh.generator import \ + from grudge.mesh.generator import \ make_rect_mesh, \ make_centered_regular_rect_mesh @@ -80,7 +80,7 @@ def main(write_output=True): }) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer vis = VtkVisualizer(discr, rcon, "vortex-%d" % order) #vis = SiloVisualizer(discr, rcon) @@ -88,8 +88,8 @@ def main(write_output=True): vortex = Vortex() fields = vortex.volume_interpolant(0, discr) - from hedge.models.gas_dynamics import GasDynamicsOperator - from hedge.mesh import TAG_ALL + from grudge.models.gas_dynamics import GasDynamicsOperator + from grudge.mesh import TAG_ALL op = GasDynamicsOperator(dimensions=2, gamma=vortex.gamma, mu=vortex.mu, prandtl=vortex.prandtl, spec_gas_const=vortex.spec_gas_const, @@ -115,14 +115,14 @@ def main(write_output=True): # limiter ------------------------------------------------------------ - from hedge.models.gas_dynamics import SlopeLimiter1NEuler + from grudge.models.gas_dynamics import SlopeLimiter1NEuler limiter = SlopeLimiter1NEuler(discr, vortex.gamma, 2, op) - from hedge.timestep import SSPRK3TimeStepper + from grudge.timestep import SSPRK3TimeStepper #stepper = SSPRK3TimeStepper(limiter=limiter) stepper = SSPRK3TimeStepper() - #from hedge.timestep import RK4TimeStepper + #from grudge.timestep import RK4TimeStepper #stepper = RK4TimeStepper() # diagnostics setup --------------------------------------------------- @@ -146,7 +146,7 @@ def main(write_output=True): # timestep loop ------------------------------------------------------- try: final_time = 0.2 - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=final_time, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/gas_dynamics/euler/vortex-sources.py b/examples/gas_dynamics/euler/vortex-sources.py index 09b5ff7d427e835fbb8ee262b610c04b93eda9a4..548dd3998087c4519e61541003110ec7b9bd2a6f 100644 --- a/examples/gas_dynamics/euler/vortex-sources.py +++ b/examples/gas_dynamics/euler/vortex-sources.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -56,7 +56,7 @@ class Vortex: e = p/(self.gamma-1) + rho/2*(u**2+v**2) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho, e, rho*u, rho*v) def volume_interpolant(self, t, discr): @@ -132,7 +132,7 @@ class SourceTerms: source_rhou = factorA*rho_gamma_x source_rhov = factorA*rho_gamma_y - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(source_rho, source_e, source_rhou, source_rhov, x_vec[0]-x_vec[0]) def volume_interpolant(self,t,q,discr): @@ -142,7 +142,7 @@ class SourceTerms: def main(write_output=True): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context( #["cuda"] ) @@ -153,11 +153,11 @@ def main(write_output=True): # arise for other values densityA = 2.0 - from hedge.tools import EOCRecorder, to_obj_array + from grudge.tools import EOCRecorder, to_obj_array eoc_rec = EOCRecorder() if rcon.is_head_rank: - from hedge.mesh import \ + from grudge.mesh import \ make_rect_mesh, \ make_centered_regular_rect_mesh @@ -175,7 +175,7 @@ def main(write_output=True): ], default_scalar_type=numpy.float64) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer #vis = VtkVisualizer(discr, rcon, "vortex-%d" % order) vis = SiloVisualizer(discr, rcon) @@ -187,9 +187,9 @@ def main(write_output=True): center=[5,0], velocity=[1,0], densityA=densityA) - from hedge.models.gas_dynamics import ( + from grudge.models.gas_dynamics import ( GasDynamicsOperator, GammaLawEOS) - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL op = GasDynamicsOperator(dimensions=2, mu=0.0, prandtl=0.72, spec_gas_const=287.1, @@ -213,11 +213,11 @@ def main(write_output=True): print("#elements=", len(mesh.elements)) # limiter setup ------------------------------------------------------- - from hedge.models.gas_dynamics import SlopeLimiter1NEuler + from grudge.models.gas_dynamics import SlopeLimiter1NEuler limiter = SlopeLimiter1NEuler(discr, gamma, 2, op) # time stepper -------------------------------------------------------- - from hedge.timestep import SSPRK3TimeStepper, RK4TimeStepper + from grudge.timestep import SSPRK3TimeStepper, RK4TimeStepper #stepper = SSPRK3TimeStepper(limiter=limiter) #stepper = SSPRK3TimeStepper() stepper = RK4TimeStepper() @@ -246,7 +246,7 @@ def main(write_output=True): #fields = limiter(fields) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=.1, #max_steps=500, diff --git a/examples/gas_dynamics/euler/vortex.py b/examples/gas_dynamics/euler/vortex.py index 4e425a5f78acaca3813c8a412e516913cd584f7b..70e56baca10b7033e88d5c21709310876be8cf55 100644 --- a/examples/gas_dynamics/euler/vortex.py +++ b/examples/gas_dynamics/euler/vortex.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -29,14 +29,14 @@ def main(write_output=True): from pytools import add_python_path_relative_to_script add_python_path_relative_to_script("..") - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() - from hedge.tools import EOCRecorder + from grudge.tools import EOCRecorder eoc_rec = EOCRecorder() if rcon.is_head_rank: - from hedge.mesh.generator import \ + from grudge.mesh.generator import \ make_rect_mesh, \ make_centered_regular_rect_mesh @@ -51,10 +51,10 @@ def main(write_output=True): from gas_dynamics_initials import Vortex flow = Vortex() - from hedge.models.gas_dynamics import ( + from grudge.models.gas_dynamics import ( GasDynamicsOperator, PolytropeEOS, GammaLawEOS) - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL # works equally well for GammaLawEOS op = GasDynamicsOperator(dimensions=2, mu=flow.mu, prandtl=flow.prandtl, spec_gas_const=flow.spec_gas_const, @@ -71,7 +71,7 @@ def main(write_output=True): tune_for=op.op_template(), debug=["cuda_no_plan"]) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer vis = VtkVisualizer(discr, rcon, "vortex-%d" % order) #vis = SiloVisualizer(discr, rcon) @@ -94,15 +94,15 @@ def main(write_output=True): # limiter ------------------------------------------------------------ - from hedge.models.gas_dynamics import SlopeLimiter1NEuler + from grudge.models.gas_dynamics import SlopeLimiter1NEuler limiter = SlopeLimiter1NEuler(discr, flow.gamma, 2, op) - from hedge.timestep.runge_kutta import SSP3TimeStepper + from grudge.timestep.runge_kutta import SSP3TimeStepper #stepper = SSP3TimeStepper(limiter=limiter) stepper = SSP3TimeStepper( vector_primitive_factory=discr.get_vector_primitive_factory()) - #from hedge.timestep import RK4TimeStepper + #from grudge.timestep import RK4TimeStepper #stepper = RK4TimeStepper() # diagnostics setup --------------------------------------------------- @@ -126,7 +126,7 @@ def main(write_output=True): # timestep loop ------------------------------------------------------- try: final_time = flow.final_time - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=final_time, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/gas_dynamics/gas_dynamics_initials.py b/examples/gas_dynamics/gas_dynamics_initials.py index 2bfeb4a05acfa6b8995609542cb9cffa8fe78041..a9947445a7b54fe6d70aa4338e520ec17ca851d6 100644 --- a/examples/gas_dynamics/gas_dynamics_initials.py +++ b/examples/gas_dynamics/gas_dynamics_initials.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -102,11 +102,11 @@ class UniformMachFlow: direction = self.direction_vector(x_vec.shape[0]) - from hedge.tools import make_obj_array + from grudge.tools import make_obj_array u_field = make_obj_array([ones*self.velocity*dir_i for dir_i in direction]) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho_field, self.e*ones, self.rho*u_field) def volume_interpolant(self, t, discr): @@ -152,7 +152,7 @@ class Vortex: e = p/(self.gamma-1) + rho/2*(u**2+v**2) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho, e, rho*u, rho*v) def volume_interpolant(self, t, discr): @@ -205,7 +205,7 @@ class Vortex: e = p/(self.gamma-1) + rho/2*(u**2+v**2) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho, e, rho*u, rho*v) def volume_interpolant(self, t, discr): diff --git a/examples/gas_dynamics/lbm-simple.py b/examples/gas_dynamics/lbm-simple.py index 0c5a3d0ff79e1b28a4999770afee9b352f252217..a8b86b328a235f59f5474a1eb4f773f56bd44fd3 100644 --- a/examples/gas_dynamics/lbm-simple.py +++ b/examples/gas_dynamics/lbm-simple.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2011 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -28,17 +28,17 @@ from six.moves import range def main(write_output=True, dtype=np.float32): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() - from hedge.mesh.generator import make_rect_mesh + from grudge.mesh.generator import make_rect_mesh if rcon.is_head_rank: h_fac = 1 mesh = make_rect_mesh(a=(0,0),b=(1,1), max_area=h_fac**2*1e-4, periodicity=(True,True), subdivisions=(int(70/h_fac), int(70/h_fac))) - from hedge.models.gas_dynamics.lbm import \ + from grudge.models.gas_dynamics.lbm import \ D2Q9LBMMethod, LatticeBoltzmannOperator op = LatticeBoltzmannOperator( @@ -53,18 +53,18 @@ def main(write_output=True, dtype=np.float32): discr = rcon.make_discretization(mesh_data, order=3, default_scalar_type=dtype, debug=["cuda_no_plan"]) - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper(dtype=dtype, #vector_primitive_factory=discr.get_vector_primitive_factory() ) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, "fld") - from hedge.data import CompiledExpressionData + from grudge.data import CompiledExpressionData def ic_expr(t, x, fields): - from hedge.optemplate import CFunction + from grudge.optemplate import CFunction from pymbolic.primitives import IfPositive from pytools.obj_array import make_obj_array @@ -76,7 +76,7 @@ def main(write_output=True, dtype=np.float32): w = 0.05 delta = 0.05 - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse u = cse(make_obj_array([ IfPositive(x[1]-1/2, u0*tanh(4*(3/4-x[1])/w), @@ -99,8 +99,8 @@ def main(write_output=True, dtype=np.float32): f_bar = CompiledExpressionData(ic_expr).volume_interpolant(0, discr) - from hedge.discretization import ExponentialFilterResponseFunction - from hedge.optemplate.operators import FilterOperator + from grudge.discretization import ExponentialFilterResponseFunction + from grudge.optemplate.operators import FilterOperator mode_filter = FilterOperator( ExponentialFilterResponseFunction(min_amplification=0.9, order=4))\ .bind(discr) diff --git a/examples/gas_dynamics/naca.py b/examples/gas_dynamics/naca.py index 7eaadfabb661d9ade70676ad0d3e3d3bec9154f2..29aa043e42187e75e152e4d99f1f4275fb4de3e4 100644 --- a/examples/gas_dynamics/naca.py +++ b/examples/gas_dynamics/naca.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -97,10 +97,10 @@ def make_nacamesh(): face_marker = fvi2fm[fvi] return [face_marker_to_tag[face_marker]] - from hedge.mesh import make_conformal_mesh_ext + from grudge.mesh import make_conformal_mesh_ext vertices = numpy.asarray(mesh.points, order="C") - from hedge.mesh.element import Triangle + from grudge.mesh.element import Triangle return make_conformal_mesh_ext( vertices, [Triangle(i, el_idx, vertices) @@ -113,7 +113,7 @@ def make_nacamesh(): def main(): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() if rcon.is_head_rank: @@ -129,7 +129,7 @@ def main(): from gas_dynamics_initials import UniformMachFlow uniform_flow = UniformMachFlow() - from hedge.models.gas_dynamics import GasDynamicsOperator, GammaLawEOS + from grudge.models.gas_dynamics import GasDynamicsOperator, GammaLawEOS op = GasDynamicsOperator(dimensions=2, equation_of_state=GammaLawEOS(uniform_flow.gamma), prandtl=uniform_flow.prandtl, @@ -148,7 +148,7 @@ def main(): default_scalar_type=numpy.float32, tune_for=op.op_template()) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer #vis = VtkVisualizer(discr, rcon, "shearflow-%d" % order) vis = SiloVisualizer(discr, rcon) @@ -169,7 +169,7 @@ def main(): print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep.runge_kutta import \ + from grudge.timestep.runge_kutta import \ ODE23TimeStepper, LSRK4TimeStepper stepper = ODE23TimeStepper(dtype=discr.default_scalar_type, rtol=1e-6, @@ -206,7 +206,7 @@ def main(): #logmgr.add_quantity(ChangeSinceLastStep()) # filter setup------------------------------------------------------------- - from hedge.discretization import Filter, ExponentialFilterResponseFunction + from grudge.discretization import Filter, ExponentialFilterResponseFunction mode_filter = Filter(discr, ExponentialFilterResponseFunction(min_amplification=0.9,order=4)) # timestep loop ------------------------------------------------------- @@ -214,7 +214,7 @@ def main(): logmgr.add_watches(["step.max", "t_sim.max", "t_step.max"]) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=200, #max_steps=500, diff --git a/examples/gas_dynamics/navierstokes/shearflow.py b/examples/gas_dynamics/navierstokes/shearflow.py index 7045165da00dd196be53a9ce153563fd0cee5ade..6ba08a285840fbd2b0c0ba498f85c3f8d97e25f8 100644 --- a/examples/gas_dynamics/navierstokes/shearflow.py +++ b/examples/gas_dynamics/navierstokes/shearflow.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -41,7 +41,7 @@ class SteadyShearFlow: rho_v = numpy.zeros_like(x_vec[0]) e = (2 * self.mu * x_vec[0] + 10) / (self.gamma - 1) + x_vec[1]**4 / 2 - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(rho, e, rho_u, rho_v) def properties(self): @@ -64,19 +64,19 @@ class SteadyShearFlow: def main(): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context( #["cuda"] ) - from hedge.tools import EOCRecorder, to_obj_array + from grudge.tools import EOCRecorder, to_obj_array eoc_rec = EOCRecorder() def boundary_tagger(vertices, el, face_nr, all_v): return ["inflow"] if rcon.is_head_rank: - from hedge.mesh import make_rect_mesh, \ + from grudge.mesh import make_rect_mesh, \ make_centered_regular_rect_mesh #mesh = make_rect_mesh((0,0), (10,1), max_area=0.01) refine = 1 @@ -92,7 +92,7 @@ def main(): discr = rcon.make_discretization(mesh_data, order=order, default_scalar_type=numpy.float64) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer #vis = VtkVisualizer(discr, rcon, "shearflow-%d" % order) vis = SiloVisualizer(discr, rcon) @@ -100,7 +100,7 @@ def main(): fields = shearflow.volume_interpolant(0, discr) gamma, mu, prandtl, spec_gas_const = shearflow.properties() - from hedge.models.gas_dynamics import GasDynamicsOperator + from grudge.models.gas_dynamics import GasDynamicsOperator op = GasDynamicsOperator(dimensions=2, gamma=gamma, mu=mu, prandtl=prandtl, spec_gas_const=spec_gas_const, bc_inflow=shearflow, bc_outflow=shearflow, bc_noslip=shearflow, @@ -123,7 +123,7 @@ def main(): print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep import RK4TimeStepper + from grudge.timestep import RK4TimeStepper stepper = RK4TimeStepper() # diagnostics setup --------------------------------------------------- @@ -142,7 +142,7 @@ def main(): # timestep loop ------------------------------------------------------- try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=0.3, #max_steps=500, diff --git a/examples/gas_dynamics/square.py b/examples/gas_dynamics/square.py index 61a83bb102dd2d5639b6e39784207fb8a0b03105..f82f831e283fe9e622c73827153ea3f7ecd83345 100644 --- a/examples/gas_dynamics/square.py +++ b/examples/gas_dynamics/square.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -87,9 +87,9 @@ def make_squaremesh(): face_marker = fvi2fm[fvi] return [face_marker_to_tag[face_marker]] - from hedge.mesh import make_conformal_mesh_ext + from grudge.mesh import make_conformal_mesh_ext vertices = numpy.asarray(mesh.points, dtype=float, order="C") - from hedge.mesh.element import Triangle + from grudge.mesh.element import Triangle return make_conformal_mesh_ext( vertices, [Triangle(i, el_idx, vertices) @@ -103,14 +103,14 @@ def main(): import logging logging.basicConfig(level=logging.INFO) - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() if rcon.is_head_rank: if True: mesh = make_squaremesh() else: - from hedge.mesh import make_rect_mesh + from grudge.mesh import make_rect_mesh mesh = make_rect_mesh( boundary_tagger=lambda fvi, el, fn, all_v: ["inflow"], max_area=0.1) @@ -127,7 +127,7 @@ def main(): square = UniformMachFlow(gaussian_pulse_at=numpy.array([-2, 2]), pulse_magnitude=0.003) - from hedge.models.gas_dynamics import ( + from grudge.models.gas_dynamics import ( GasDynamicsOperator, GammaLawEOS) @@ -154,13 +154,13 @@ def main(): } ) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer #vis = VtkVisualizer(discr, rcon, "shearflow-%d" % order) vis = SiloVisualizer(discr, rcon) - from hedge.timestep.runge_kutta import ( + from grudge.timestep.runge_kutta import ( LSRK4TimeStepper, ODE23TimeStepper, ODE45TimeStepper) - from hedge.timestep.dumka3 import Dumka3TimeStepper + from grudge.timestep.dumka3 import Dumka3TimeStepper #stepper = LSRK4TimeStepper(dtype=discr.default_scalar_type, #vector_primitive_factory=discr.get_vector_primitive_factory()) @@ -172,7 +172,7 @@ def main(): #rtol=1e-7, pol_index=2, #vector_primitive_factory=discr.get_vector_primitive_factory()) - #from hedge.timestep.dumka3 import Dumka3TimeStepper + #from grudge.timestep.dumka3 import Dumka3TimeStepper #stepper = Dumka3TimeStepper(3, rtol=1e-7) # diagnostics setup --------------------------------------------------- @@ -207,7 +207,7 @@ def main(): logmgr.add_watches(["step.max", "t_sim.max", "t_step.max"]) # filter setup ------------------------------------------------------------ - from hedge.discretization import Filter, ExponentialFilterResponseFunction + from grudge.discretization import Filter, ExponentialFilterResponseFunction mode_filter = Filter(discr, ExponentialFilterResponseFunction(min_amplification=0.95, order=6)) @@ -230,7 +230,7 @@ def main(): print("#elements=", len(mesh.elements)) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=1000, #max_steps=500, diff --git a/examples/gas_dynamics/wing.py b/examples/gas_dynamics/wing.py index a7dd3de92e92bb3826335509bf8fc438161a0da5..a7201070438bcbe45e67243529b5f0bb4a6ea7e4 100644 --- a/examples/gas_dynamics/wing.py +++ b/examples/gas_dynamics/wing.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2008 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -101,19 +101,19 @@ def make_wingmesh(): face_marker = fvi2fm[fvi] return [face_marker_to_tag[face_marker]] - from hedge.mesh import make_conformal_mesh + from grudge.mesh import make_conformal_mesh return make_conformal_mesh(mesh.points, mesh.elements, bdry_tagger) def main(): - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context( ["cuda", "mpi"]) if rcon.is_head_rank: mesh = make_wingmesh() - #from hedge.mesh import make_rect_mesh + #from grudge.mesh import make_rect_mesh #mesh = make_rect_mesh( # boundary_tagger=lambda fvi, el, fn, all_v: ["inflow"]) mesh_data = rcon.distribute_mesh(mesh) @@ -127,7 +127,7 @@ def main(): from gas_dynamics_initials import UniformMachFlow wing = UniformMachFlow(angle_of_attack=0) - from hedge.models.gas_dynamics import GasDynamicsOperator + from grudge.models.gas_dynamics import GasDynamicsOperator op = GasDynamicsOperator(dimensions=3, gamma=wing.gamma, mu=wing.mu, prandtl=wing.prandtl, spec_gas_const=wing.spec_gas_const, @@ -146,7 +146,7 @@ def main(): default_scalar_type=numpy.float64, tune_for=op.op_template()) - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer #vis = VtkVisualizer(discr, rcon, "shearflow-%d" % order) vis = SiloVisualizer(discr, rcon) @@ -167,7 +167,7 @@ def main(): print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep import RK4TimeStepper + from grudge.timestep import RK4TimeStepper stepper = RK4TimeStepper() # diagnostics setup --------------------------------------------------- @@ -185,7 +185,7 @@ def main(): # timestep loop ------------------------------------------------------- try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=200, #max_steps=500, @@ -201,7 +201,7 @@ def main(): #rhs_fields = rhs(t, fields) from pyvisfile.silo import DB_VARTYPE_VECTOR - from hedge.discretization import ones_on_boundary + from grudge.discretization import ones_on_boundary vis.add_data(visf, [ ("rho", discr.convert_volume(op.rho(fields), kind="numpy")), diff --git a/examples/heat/heat.py b/examples/heat/heat.py index 0f95d5002f569a3c7e4d5ac9e3acbd69bd1a46b8..4023f7d850f58d012a13a113b3b3596ab643a64d 100644 --- a/examples/heat/heat.py +++ b/examples/heat/heat.py @@ -1,6 +1,6 @@ from __future__ import absolute_import from __future__ import print_function -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -27,10 +27,10 @@ import numpy.linalg as la def main(write_output=True) : from math import sin, cos, pi, exp, sqrt - from hedge.data import TimeConstantGivenFunction, \ + from grudge.data import TimeConstantGivenFunction, \ ConstantGivenFunction - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() dim = 2 @@ -43,11 +43,11 @@ def main(write_output=True) : if dim == 2: if rcon.is_head_rank: - from hedge.mesh.generator import make_disk_mesh + from grudge.mesh.generator import make_disk_mesh mesh = make_disk_mesh(r=0.5, boundary_tagger=boundary_tagger) elif dim == 3: if rcon.is_head_rank: - from hedge.mesh.generator import make_ball_mesh + from grudge.mesh.generator import make_ball_mesh mesh = make_ball_mesh(max_volume=0.001) else: raise RuntimeError("bad number of dimensions") @@ -63,7 +63,7 @@ def main(write_output=True) : default_scalar_type=numpy.float64) if write_output: - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer vis = VtkVisualizer(discr, rcon, "fld") def u0(x, el): @@ -84,7 +84,7 @@ def main(write_output=True) : def neumann_bc(t, x): return 2 - from hedge.models.diffusion import DiffusionOperator + from grudge.models.diffusion import DiffusionOperator op = DiffusionOperator(discr.dimensions, #coeff=coeff, dirichlet_tag="dirichlet", @@ -111,7 +111,7 @@ def main(write_output=True) : add_simulation_quantities(logmgr) discr.add_instrumentation(logmgr) - from hedge.log import LpNorm + from grudge.log import LpNorm u_getter = lambda: u logmgr.add_quantity(LpNorm(u_getter, discr, 1, name="l1_u")) logmgr.add_quantity(LpNorm(u_getter, discr, name="l2_u")) @@ -119,8 +119,8 @@ def main(write_output=True) : logmgr.add_watches(["step.max", "t_sim.max", "l2_u", "t_step.max"]) # timestep loop ----------------------------------------------------------- - from hedge.timestep.runge_kutta import LSRK4TimeStepper, ODE45TimeStepper - from hedge.timestep.dumka3 import Dumka3TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper, ODE45TimeStepper + from grudge.timestep.dumka3 import Dumka3TimeStepper #stepper = LSRK4TimeStepper() stepper = Dumka3TimeStepper(3, rtol=1e-6, rcon=rcon, vector_primitive_factory=discr.get_vector_primitive_factory(), @@ -135,7 +135,7 @@ def main(write_output=True) : next_dt = op.estimate_timestep(discr, stepper=LSRK4TimeStepper(), t=0, fields=u) - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=0.1, logmgr=logmgr, max_dt_getter=lambda t: next_dt, diff --git a/examples/maxwell/analytic_solutions.py b/examples/maxwell/analytic_solutions.py index 86dd05ae8eb2db5aeb3f748018252fbbae50f08e..152130f91b335c60ee0adb9e0468714ff7eb6981 100644 --- a/examples/maxwell/analytic_solutions.py +++ b/examples/maxwell/analytic_solutions.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ from __future__ import division from __future__ import absolute_import from __future__ import print_function -from hedge.tools import \ +from grudge.tools import \ cyl_bessel_j, \ cyl_bessel_j_prime from math import sqrt, pi, sin, cos, atan2, acos @@ -390,11 +390,11 @@ class DipoleFarField: # analytic solution tools ----------------------------------------------------- def check_time_harmonic_solution(discr, mode, c_sol): - from hedge.discretization import bind_nabla, bind_mass_matrix - from hedge.visualization import SiloVisualizer - from hedge.silo import SiloFile - from hedge.tools import dot, cross - from hedge.silo import DB_VARTYPE_VECTOR + from grudge.discretization import bind_nabla, bind_mass_matrix + from grudge.visualization import SiloVisualizer + from grudge.silo import SiloFile + from grudge.tools import dot, cross + from grudge.silo import DB_VARTYPE_VECTOR def curl(field): return cross(nabla, field) diff --git a/examples/maxwell/cavities.py b/examples/maxwell/cavities.py index a337b49ef20bbba3f4d6fe36b0a01412253fcd97..cbfc45bdd01283408beed8f4a258e72c4a85b402 100644 --- a/examples/maxwell/cavities.py +++ b/examples/maxwell/cavities.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -26,8 +26,8 @@ logger = logging.getLogger(__name__) def main(write_output=True, allow_features=None, flux_type_arg=1, bdry_flux_type_arg=None, extra_discr_args={}): - from hedge.mesh.generator import make_cylinder_mesh, make_box_mesh - from hedge.tools import EOCRecorder, to_obj_array + from grudge.mesh.generator import make_cylinder_mesh, make_box_mesh + from grudge.tools import EOCRecorder, to_obj_array from math import sqrt, pi # noqa from analytic_solutions import ( # noqa RealPartAdapter, @@ -36,11 +36,11 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, CylindricalCavityMode, RectangularWaveguideMode, RectangularCavityMode) - from hedge.models.em import MaxwellOperator + from grudge.models.em import MaxwellOperator logging.basicConfig(level=logging.DEBUG) - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context(allow_features) epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) @@ -93,7 +93,7 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, tune_for=op.op_template(), **extra_discr_args) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, "em-%d" % order) @@ -113,9 +113,9 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper(dtype=discr.default_scalar_type, rcon=rcon) - #from hedge.timestep.dumka3 import Dumka3TimeStepper + #from grudge.timestep.dumka3 import Dumka3TimeStepper #stepper = Dumka3TimeStepper(3, dtype=discr.default_scalar_type, rcon=rcon) # {{{ diagnostics setup @@ -140,7 +140,7 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, vis_timer = IntervalTimer("t_vis", "Time spent visualizing") logmgr.add_quantity(vis_timer) - from hedge.log import EMFieldGetter, add_em_quantities + from grudge.log import EMFieldGetter, add_em_quantities field_getter = EMFieldGetter(discr, op, lambda: fields) add_em_quantities(logmgr, op, field_getter) @@ -158,7 +158,7 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, final_time = 0.5e-9 try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=final_time, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/maxwell/dipole.py b/examples/maxwell/dipole.py index 8b24a13d8f0afcbc96d18700b9a82d06aa9bf783..afed4b145adab832b4d2a463cf5e3f4a6cb848c9 100644 --- a/examples/maxwell/dipole.py +++ b/examples/maxwell/dipole.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -31,15 +31,15 @@ from six.moves import zip def main(write_output=True, allow_features=None): - from hedge.timestep import RK4TimeStepper - from hedge.mesh import make_ball_mesh, make_cylinder_mesh, make_box_mesh - from hedge.visualization import \ + from grudge.timestep import RK4TimeStepper + from grudge.mesh import make_ball_mesh, make_cylinder_mesh, make_box_mesh + from grudge.visualization import \ VtkVisualizer, \ SiloVisualizer, \ get_rank_partition from math import sqrt, pi - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context(allow_features) epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) @@ -51,14 +51,14 @@ def main(write_output=True, allow_features=None): if rcon.is_head_rank: if dims == 2: - from hedge.mesh import make_rect_mesh + from grudge.mesh import make_rect_mesh mesh = make_rect_mesh( a=(-10.5,-1.5), b=(10.5,1.5), max_area=0.1 ) elif dims == 3: - from hedge.mesh import make_box_mesh + from grudge.mesh import make_box_mesh mesh = make_box_mesh( a=(-10.5,-1.5,-1.5), b=(10.5,1.5,1.5), @@ -76,7 +76,7 @@ def main(write_output=True, allow_features=None): vis = VtkVisualizer(discr, rcon, "dipole") from analytic_solutions import DipoleFarField, SphericalFieldAdapter - from hedge.data import ITimeDependentGivenFunction + from grudge.data import ITimeDependentGivenFunction sph_dipole = DipoleFarField( q=1, #C @@ -98,18 +98,18 @@ def main(write_output=True, allow_features=None): self.vol_0 = discr.volume_zeros() def volume_interpolant(self, t, discr): - from hedge.tools import make_obj_array + from grudge.tools import make_obj_array return make_obj_array([ self.vol_0, self.vol_0, sph_dipole.source_modulation(t)*self.num_sf ]) - from hedge.mesh import TAG_ALL, TAG_NONE + from grudge.mesh import TAG_ALL, TAG_NONE if dims == 2: - from hedge.models.em import TMMaxwellOperator as MaxwellOperator + from grudge.models.em import TMMaxwellOperator as MaxwellOperator else: - from hedge.models.em import MaxwellOperator + from grudge.models.em import MaxwellOperator op = MaxwellOperator( epsilon, mu, @@ -146,7 +146,7 @@ def main(write_output=True, allow_features=None): vis_timer = IntervalTimer("t_vis", "Time spent visualizing") logmgr.add_quantity(vis_timer) - from hedge.log import EMFieldGetter, add_em_quantities + from grudge.log import EMFieldGetter, add_em_quantities field_getter = EMFieldGetter(discr, op, lambda: fields) add_em_quantities(logmgr, op, field_getter) @@ -173,7 +173,7 @@ def main(write_output=True, allow_features=None): mask = discr.interpolate_volume_function(sph_dipole.far_field_mask) def apply_mask(field): - from hedge.tools import log_shape + from grudge.tools import log_shape ls = log_shape(field) result = discr.volume_empty(ls) from pytools import indices_in_shape @@ -186,7 +186,7 @@ def main(write_output=True, allow_features=None): t = 0 try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=1e-8, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, @@ -221,7 +221,7 @@ def main(write_output=True, allow_features=None): visf.close() sub_timer.stop().submit() - from hedge.tools import relative_error + from grudge.tools import relative_error relerr_e_q.push_value( relative_error( discr.norm(mask_e-mask_true_e), diff --git a/examples/maxwell/inhom-cavity.py b/examples/maxwell/inhom-cavity.py index a9cb908569b10408b34cd34ebd8a76f1f7675d36..80325b978156e63f549f9e199405aca5fbb6828d 100644 --- a/examples/maxwell/inhom-cavity.py +++ b/examples/maxwell/inhom-cavity.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # Adapted 2010 by David Powell # @@ -60,9 +60,9 @@ Physical Surface("dielectric") = {2}; def main(write_output=True, allow_features=None, flux_type_arg=1, bdry_flux_type_arg=None, extra_discr_args={}): from math import sqrt, pi - from hedge.models.em import TEMaxwellOperator + from grudge.models.em import TEMaxwellOperator - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context(allow_features) epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) @@ -113,13 +113,13 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, else: return -l*sin(h*d)/sin(l*(a-d))*cos(l*(a-x[0])) - from hedge.tools import make_obj_array + from grudge.tools import make_obj_array result_zero = discr.volume_zeros(kind="numpy", dtype=numpy.float64) H_z = make_tdep_given(initial_Hz).volume_interpolant(0, discr) return make_obj_array([result_zero, result_zero, H_z]) if rcon.is_head_rank: - from hedge.mesh.reader.gmsh import generate_gmsh + from grudge.mesh.reader.gmsh import generate_gmsh mesh = generate_gmsh(CAVITY_GEOMETRY, 2, force_dimension=2) mesh_data = rcon.distribute_mesh(mesh) else: @@ -134,8 +134,8 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, #extra_discr_args.setdefault("debug", []).append("cuda_no_plan") #extra_discr_args.setdefault("debug", []).append("dump_optemplate_stages") - from hedge.data import make_tdep_given - from hedge.mesh import TAG_ALL + from grudge.data import make_tdep_given + from grudge.mesh import TAG_ALL op = TEMaxwellOperator(epsilon=make_tdep_given(eps_val), mu=make_tdep_given(mu_val), \ flux_type=flux_type_arg, \ @@ -151,7 +151,7 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, # create the initial solution fields = initial_val(discr) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: from os.path import join vis = VtkVisualizer(discr, rcon, join(output_dir, "cav-%d" % order)) @@ -168,9 +168,9 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, print("---------------------------------------------") print("#elements=", len(mesh.elements)) - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper(dtype=discr.default_scalar_type, rcon=rcon) - #from hedge.timestep.dumka3 import Dumka3TimeStepper + #from grudge.timestep.dumka3 import Dumka3TimeStepper #stepper = Dumka3TimeStepper(3, dtype=discr.default_scalar_type, rcon=rcon) # diagnostics setup --------------------------------------------------- @@ -195,7 +195,7 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, vis_timer = IntervalTimer("t_vis", "Time spent visualizing") logmgr.add_quantity(vis_timer) - #from hedge.log import EMFieldGetter, add_em_quantities + #from grudge.log import EMFieldGetter, add_em_quantities #field_getter = EMFieldGetter(discr, op, lambda: fields) #add_em_quantities(logmgr, op, field_getter) @@ -214,7 +214,7 @@ def main(write_output=True, allow_features=None, flux_type_arg=1, pointfile = open(join(output_dir, "point.txt"), "wt") done_dt = False try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps from os.path import join step_it = times_and_steps( final_time=final_time, logmgr=logmgr, diff --git a/examples/maxwell/maxwell-2d.py b/examples/maxwell/maxwell-2d.py index 736983b2e8bf1dc44804858ef91cd36a86406eff..7f44c4dbee2392a1dbb6223b4ae7b17747a25fb5 100644 --- a/examples/maxwell/maxwell-2d.py +++ b/examples/maxwell/maxwell-2d.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -27,7 +27,7 @@ def main(write_output=True): from math import sqrt, pi, exp from os.path import join - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) @@ -40,7 +40,7 @@ def main(write_output=True): if not os.access(output_dir, os.F_OK): os.makedirs(output_dir) - from hedge.mesh.generator import make_disk_mesh + from grudge.mesh.generator import make_disk_mesh mesh = make_disk_mesh(r=0.5, max_area=1e-3) if rcon.is_head_rank: @@ -59,7 +59,7 @@ def main(write_output=True): discr = rcon.make_discretization(mesh_data, order=order, debug=["cuda_no_plan"]) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, join(output_dir, "em-%d" % order)) @@ -67,16 +67,16 @@ def main(write_output=True): print("order %d" % order) print("#elements=", len(mesh.elements)) - from hedge.mesh import TAG_ALL, TAG_NONE - from hedge.models.em import TMMaxwellOperator - from hedge.data import make_tdep_given, TimeIntervalGivenFunction + from grudge.mesh import TAG_ALL, TAG_NONE + from grudge.models.em import TMMaxwellOperator + from grudge.data import make_tdep_given, TimeIntervalGivenFunction op = TMMaxwellOperator(epsilon, mu, flux_type=1, current=TimeIntervalGivenFunction( make_tdep_given(CurrentSource()), off_time=final_time/10), absorb_tag=TAG_ALL, pec_tag=TAG_NONE) fields = op.assemble_eh(discr=discr) - from hedge.timestep import LSRK4TimeStepper + from grudge.timestep import LSRK4TimeStepper stepper = LSRK4TimeStepper() from time import time last_tstep = time() @@ -102,7 +102,7 @@ def main(write_output=True): vis_timer = IntervalTimer("t_vis", "Time spent visualizing") logmgr.add_quantity(vis_timer) - from hedge.log import EMFieldGetter, add_em_quantities + from grudge.log import EMFieldGetter, add_em_quantities field_getter = EMFieldGetter(discr, op, lambda: fields) add_em_quantities(logmgr, op, field_getter) @@ -113,7 +113,7 @@ def main(write_output=True): rhs = op.bind(discr) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=final_time, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/maxwell/maxwell-pml.py b/examples/maxwell/maxwell-pml.py index bc0dbee518c09059f3c5d02a2faceb05b967e64c..59e88b49fee5acb9965bcb7a2d81ba43a0d40eb3 100644 --- a/examples/maxwell/maxwell-pml.py +++ b/examples/maxwell/maxwell-pml.py @@ -1,4 +1,4 @@ -"""Hedge is the Hybrid'n'Easy Discontinuous Galerkin Environment.""" +"""grudge is the Hybrid'n'Easy Discontinuous Galerkin Environment.""" from __future__ import division from __future__ import absolute_import @@ -56,8 +56,8 @@ def make_mesh(a, b, pml_width=0.25, **kwargs): def boundary_tagger(fvi, el, fn, points): return [] - from hedge.mesh import make_conformal_mesh_ext - from hedge.mesh.element import Triangle + from grudge.mesh import make_conformal_mesh_ext + from grudge.mesh.element import Triangle pts = np.asarray(built_mi.points, dtype=np.float64) return make_conformal_mesh_ext( pts, @@ -69,10 +69,10 @@ def make_mesh(a, b, pml_width=0.25, **kwargs): def main(write_output=True): - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper from math import sqrt, pi, exp - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) @@ -96,7 +96,7 @@ def main(write_output=True): class Current: def volume_interpolant(self, t, discr): - from hedge.tools import make_obj_array + from grudge.tools import make_obj_array result = discr.volume_zeros(kind="numpy", dtype=np.float64) @@ -119,14 +119,14 @@ def main(write_output=True): discr = rcon.make_discretization(mesh_data, order=order, debug=["cuda_no_plan"]) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, "em-%d" % order) - from hedge.mesh import TAG_ALL, TAG_NONE - from hedge.data import GivenFunction, TimeHarmonicGivenFunction, TimeIntervalGivenFunction - from hedge.models.em import MaxwellOperator - from hedge.models.pml import \ + from grudge.mesh import TAG_ALL, TAG_NONE + from grudge.data import GivenFunction, TimeHarmonicGivenFunction, TimeIntervalGivenFunction + from grudge.models.em import MaxwellOperator + from grudge.models.pml import \ AbarbanelGottliebPMLMaxwellOperator, \ AbarbanelGottliebPMLTMMaxwellOperator, \ AbarbanelGottliebPMLTEMaxwellOperator @@ -166,13 +166,13 @@ def main(write_output=True): vis_timer = IntervalTimer("t_vis", "Time spent visualizing") logmgr.add_quantity(vis_timer) - from hedge.log import EMFieldGetter, add_em_quantities + from grudge.log import EMFieldGetter, add_em_quantities field_getter = EMFieldGetter(discr, op, lambda: fields) add_em_quantities(logmgr, op, field_getter) logmgr.add_watches(["step.max", "t_sim.max", ("W_field", "W_el+W_mag"), "t_step.max"]) - from hedge.log import LpNorm + from grudge.log import LpNorm class FieldIdxGetter: def __init__(self, whole_getter, idx): self.whole_getter = whole_getter @@ -188,7 +188,7 @@ def main(write_output=True): rhs = op.bind(discr, pml_coeff) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=4/c, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/poisson/helmholtz.py b/examples/poisson/helmholtz.py index 26864bcc0745b64634a18c5b568aed2c7822b57a..d87b581bd6df077930234ed9c982ab914be74dbf 100644 --- a/examples/poisson/helmholtz.py +++ b/examples/poisson/helmholtz.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ from __future__ import absolute_import from __future__ import print_function import numpy import numpy.linalg as la -from hedge.tools import Reflection, Rotation +from grudge.tools import Reflection, Rotation @@ -47,9 +47,9 @@ class ResidualPrinter: def main(write_output=True): - from hedge.data import GivenFunction, ConstantGivenFunction + from grudge.data import GivenFunction, ConstantGivenFunction - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() dim = 2 @@ -67,13 +67,13 @@ def main(write_output=True): if dim == 2: if rcon.is_head_rank: - from hedge.mesh.generator import make_disk_mesh + from grudge.mesh.generator import make_disk_mesh mesh = make_disk_mesh(r=0.5, boundary_tagger=dirichlet_boundary_tagger, max_area=1e-3) elif dim == 3: if rcon.is_head_rank: - from hedge.mesh.generator import make_ball_mesh + from grudge.mesh.generator import make_ball_mesh mesh = make_ball_mesh(max_volume=0.0001, boundary_tagger=lambda fvi, el, fn, points: ["dirichlet"]) @@ -105,16 +105,16 @@ def main(write_output=True): return result try: - from hedge.models.poisson import ( + from grudge.models.poisson import ( PoissonOperator, HelmholtzOperator) - from hedge.second_order import \ + from grudge.second_order import \ IPDGSecondDerivative, LDGSecondDerivative, \ StabilizedCentralSecondDerivative k = 1 - from hedge.mesh import TAG_NONE, TAG_ALL + from grudge.mesh import TAG_NONE, TAG_ALL op = HelmholtzOperator(k, discr.dimensions, #diffusion_tensor=my_diff_tensor(), @@ -138,7 +138,7 @@ def main(write_output=True): bound_op = op.bind(discr) if False: - from hedge.iterative import parallel_cg + from grudge.iterative import parallel_cg u = -parallel_cg(rcon, -bound_op, bound_op.prepare_rhs(discr.interpolate_volume_function(rhs_c)), debug=20, tol=5e-4, @@ -165,7 +165,7 @@ def main(write_output=True): print(la.norm(bound_op(u)-rhs)/la.norm(rhs)) if write_output: - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer vis = VtkVisualizer(discr, rcon) visf = vis.make_file("fld") vis.add_data(visf, [ ("sol", discr.convert_volume(u, kind="numpy")), ]) diff --git a/examples/poisson/poisson.py b/examples/poisson/poisson.py index a532ee694e1c19105c476c20c3246a50398458fb..c5401a8e1efb5d3b699611e608a71a1c75f1d40f 100644 --- a/examples/poisson/poisson.py +++ b/examples/poisson/poisson.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -22,15 +22,15 @@ from __future__ import absolute_import from __future__ import print_function import numpy import numpy.linalg as la -from hedge.tools import Reflection, Rotation +from grudge.tools import Reflection, Rotation def main(write_output=True): - from hedge.data import GivenFunction, ConstantGivenFunction + from grudge.data import GivenFunction, ConstantGivenFunction - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() dim = 2 @@ -45,12 +45,12 @@ def main(write_output=True): if dim == 2: if rcon.is_head_rank: - from hedge.mesh.generator import make_disk_mesh + from grudge.mesh.generator import make_disk_mesh mesh = make_disk_mesh(r=0.5, boundary_tagger=boundary_tagger, max_area=1e-2) elif dim == 3: if rcon.is_head_rank: - from hedge.mesh.generator import make_ball_mesh + from grudge.mesh.generator import make_ball_mesh mesh = make_ball_mesh(max_volume=0.0001, boundary_tagger=lambda fvi, el, fn, points: ["dirichlet"]) @@ -82,11 +82,11 @@ def main(write_output=True): return result try: - from hedge.models.poisson import PoissonOperator - from hedge.second_order import \ + from grudge.models.poisson import PoissonOperator + from grudge.second_order import \ IPDGSecondDerivative, LDGSecondDerivative, \ StabilizedCentralSecondDerivative - from hedge.mesh import TAG_NONE, TAG_ALL + from grudge.mesh import TAG_NONE, TAG_ALL op = PoissonOperator(discr.dimensions, diffusion_tensor=my_diff_tensor(), @@ -108,7 +108,7 @@ def main(write_output=True): ) bound_op = op.bind(discr) - from hedge.iterative import parallel_cg + from grudge.iterative import parallel_cg u = -parallel_cg(rcon, -bound_op, bound_op.prepare_rhs(discr.interpolate_volume_function(rhs_c)), debug=20, tol=5e-4, @@ -116,7 +116,7 @@ def main(write_output=True): x=discr.volume_zeros()) if write_output: - from hedge.visualization import SiloVisualizer, VtkVisualizer + from grudge.visualization import SiloVisualizer, VtkVisualizer vis = VtkVisualizer(discr, rcon) visf = vis.make_file("fld") vis.add_data(visf, [ ("sol", discr.convert_volume(u, kind="numpy")), ]) diff --git a/examples/wave/var-propagation-speed.py b/examples/wave/var-propagation-speed.py index 898e05a9e8a607df281fc7e8f938926f41c8e47f..29cf0d8aae167276bc604e4bdbb041d9ffcb265d 100644 --- a/examples/wave/var-propagation-speed.py +++ b/examples/wave/var-propagation-speed.py @@ -29,7 +29,7 @@ THE SOFTWARE. import numpy as np -from hedge.mesh import TAG_ALL, TAG_NONE +from grudge.mesh import TAG_ALL, TAG_NONE def main(write_output=True, @@ -39,22 +39,22 @@ def main(write_output=True, flux_type_arg="upwind"): from math import sin, cos, pi, exp, sqrt # noqa - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() dim = 2 if dim == 1: if rcon.is_head_rank: - from hedge.mesh.generator import make_uniform_1d_mesh + from grudge.mesh.generator import make_uniform_1d_mesh mesh = make_uniform_1d_mesh(-10, 10, 500) elif dim == 2: - from hedge.mesh.generator import make_rect_mesh + from grudge.mesh.generator import make_rect_mesh if rcon.is_head_rank: mesh = make_rect_mesh(a=(-1, -1), b=(1, 1), max_area=0.003) elif dim == 3: if rcon.is_head_rank: - from hedge.mesh.generator import make_ball_mesh + from grudge.mesh.generator import make_ball_mesh mesh = make_ball_mesh(max_volume=0.0005) else: raise RuntimeError("bad number of dimensions") @@ -67,10 +67,10 @@ def main(write_output=True, discr = rcon.make_discretization(mesh_data, order=4) - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper() - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, "fld") @@ -78,11 +78,11 @@ def main(write_output=True, source_width = 1/16 source_omega = 3 - import hedge.optemplate as sym + import grudge.optemplate as sym sym_x = sym.nodes(2) sym_source_center_dist = sym_x - source_center - from hedge.models.wave import VariableVelocityStrongWaveOperator + from grudge.models.wave import VariableVelocityStrongWaveOperator op = VariableVelocityStrongWaveOperator( c=sym.If(sym.Comparison( np.dot(sym_x, sym_x), "<", 0.4**2), @@ -99,7 +99,7 @@ def main(write_output=True, flux_type=flux_type_arg ) - from hedge.tools import join_fields + from grudge.tools import join_fields fields = join_fields(discr.volume_zeros(), [discr.volume_zeros() for i in range(discr.dimensions)]) @@ -126,7 +126,7 @@ def main(write_output=True, logmgr.add_quantity(vis_timer) stepper.add_instrumentation(logmgr) - from hedge.log import LpNorm + from grudge.log import LpNorm u_getter = lambda: fields[0] logmgr.add_quantity(LpNorm(u_getter, discr, 1, name="l1_u")) logmgr.add_quantity(LpNorm(u_getter, discr, name="l2_u")) @@ -139,7 +139,7 @@ def main(write_output=True, rhs = op.bind(discr) try: - from hedge.timestep.stability import \ + from grudge.timestep.stability import \ approximate_rk4_relative_imag_stability_region max_dt = ( 1/discr.compile(op.max_eigenvalue_expr())() @@ -149,7 +149,7 @@ def main(write_output=True, if flux_type_arg == "central": max_dt *= 0.25 - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps(final_time=3, logmgr=logmgr, max_dt_getter=lambda t: max_dt) diff --git a/examples/wave/wave.py b/examples/wave/wave.py index 3c59f38c56998be4a8388186f0693ea3e1d7b23c..ac68c8d84ee97ac77507a9f8e59a9e18d4d8e6fc 100644 --- a/examples/wave/wave.py +++ b/examples/wave/wave.py @@ -1,4 +1,4 @@ -# Hedge - the Hybrid'n'Easy DG Environment +# grudge - the Hybrid'n'Easy DG Environment # Copyright (C) 2007 Andreas Kloeckner # # This program is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@ from __future__ import division from __future__ import absolute_import from __future__ import print_function import numpy as np -from hedge.mesh import TAG_ALL, TAG_NONE +from grudge.mesh import TAG_ALL, TAG_NONE from six.moves import range @@ -28,22 +28,22 @@ def main(write_output=True, flux_type_arg="upwind", dtype=np.float64, debug=[]): from math import sin, cos, pi, exp, sqrt # noqa - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() dim = 2 if dim == 1: if rcon.is_head_rank: - from hedge.mesh.generator import make_uniform_1d_mesh + from grudge.mesh.generator import make_uniform_1d_mesh mesh = make_uniform_1d_mesh(-10, 10, 500) elif dim == 2: - from hedge.mesh.generator import make_rect_mesh + from grudge.mesh.generator import make_rect_mesh if rcon.is_head_rank: mesh = make_rect_mesh(a=(-0.5, -0.5), b=(0.5, 0.5), max_area=0.008) elif dim == 3: if rcon.is_head_rank: - from hedge.mesh.generator import make_ball_mesh + from grudge.mesh.generator import make_ball_mesh mesh = make_ball_mesh(max_volume=0.0005) else: raise RuntimeError("bad number of dimensions") @@ -54,17 +54,17 @@ def main(write_output=True, else: mesh_data = rcon.receive_mesh() - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper(dtype=dtype) - from hedge.models.wave import StrongWaveOperator - from hedge.mesh import TAG_ALL, TAG_NONE # noqa + from grudge.models.wave import StrongWaveOperator + from grudge.mesh import TAG_ALL, TAG_NONE # noqa source_center = np.array([0.1, 0.22]) source_width = 0.05 source_omega = 3 - import hedge.optemplate as sym + import grudge.optemplate as sym sym_x = sym.nodes(2) sym_source_center_dist = sym_x - source_center @@ -84,11 +84,11 @@ def main(write_output=True, default_scalar_type=dtype, tune_for=op.op_template()) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, "fld") - from hedge.tools import join_fields + from grudge.tools import join_fields fields = join_fields(discr.volume_zeros(dtype=dtype), [discr.volume_zeros(dtype=dtype) for i in range(discr.dimensions)]) @@ -115,7 +115,7 @@ def main(write_output=True, logmgr.add_quantity(vis_timer) stepper.add_instrumentation(logmgr) - from hedge.log import LpNorm + from grudge.log import LpNorm u_getter = lambda: fields[0] logmgr.add_quantity(LpNorm(u_getter, discr, 1, name="l1_u")) logmgr.add_quantity(LpNorm(u_getter, discr, name="l2_u")) @@ -128,7 +128,7 @@ def main(write_output=True, rhs = op.bind(discr) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=4, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/examples/wave/wiggly.py b/examples/wave/wiggly.py index d38088cbfc6aaf3f8aab7134716951a85b0c4a8c..489855e99249a1f159843547160bd3660d9208d9 100644 --- a/examples/wave/wiggly.py +++ b/examples/wave/wiggly.py @@ -29,18 +29,18 @@ THE SOFTWARE. import numpy as np -from hedge.mesh import TAG_ALL, TAG_NONE # noqa +from grudge.mesh import TAG_ALL, TAG_NONE # noqa def main(write_output=True, flux_type_arg="upwind", dtype=np.float64, debug=[]): from math import sin, cos, pi, exp, sqrt # noqa - from hedge.backends import guess_run_context + from grudge.backends import guess_run_context rcon = guess_run_context() if rcon.is_head_rank: - from hedge.mesh.reader.gmsh import generate_gmsh + from grudge.mesh.reader.gmsh import generate_gmsh mesh = generate_gmsh(GEOMETRY, 2, allow_internal_boundaries=True, force_dimension=2) @@ -52,10 +52,10 @@ def main(write_output=True, discr = rcon.make_discretization(mesh_data, order=4, debug=debug, default_scalar_type=dtype) - from hedge.timestep.runge_kutta import LSRK4TimeStepper + from grudge.timestep.runge_kutta import LSRK4TimeStepper stepper = LSRK4TimeStepper(dtype=dtype) - from hedge.visualization import VtkVisualizer + from grudge.visualization import VtkVisualizer if write_output: vis = VtkVisualizer(discr, rcon, "fld") @@ -63,11 +63,11 @@ def main(write_output=True, source_width = 0.05 source_omega = 3 - import hedge.optemplate as sym + import grudge.optemplate as sym sym_x = sym.nodes(2) sym_source_center_dist = sym_x - source_center - from hedge.models.wave import StrongWaveOperator + from grudge.models.wave import StrongWaveOperator op = StrongWaveOperator(-1, discr.dimensions, source_f= sym.CFunction("sin")(source_omega*sym.ScalarParameter("t")) @@ -80,7 +80,7 @@ def main(write_output=True, flux_type=flux_type_arg ) - from hedge.tools import join_fields + from grudge.tools import join_fields fields = join_fields(discr.volume_zeros(dtype=dtype), [discr.volume_zeros(dtype=dtype) for i in range(discr.dimensions)]) @@ -108,7 +108,7 @@ def main(write_output=True, # timestep loop ----------------------------------------------------------- rhs = op.bind(discr) try: - from hedge.timestep import times_and_steps + from grudge.timestep import times_and_steps step_it = times_and_steps( final_time=4, logmgr=logmgr, max_dt_getter=lambda t: op.estimate_timestep(discr, diff --git a/grudge/models/__init__.py b/grudge/models/__init__.py index 93433eca19717a53d1c0e4da1115bbe77ee383bd..0b33a6f3d45a6a125311c885fb2f2e2944469eb3 100644 --- a/grudge/models/__init__.py +++ b/grudge/models/__init__.py @@ -62,7 +62,7 @@ class HyperbolicOperator(Operator): * (discr.dt_non_geometric_factor() * discr.dt_geometric_factor()) - from hedge.timestep.stability import \ + from grudge.timestep.stability import \ approximate_rk4_relative_imag_stability_region return rk4_dt * approximate_rk4_relative_imag_stability_region( stepper, stepper_class, stepper_args) diff --git a/grudge/models/advection.py b/grudge/models/advection.py index 337699912f4c9d2f46ede82e4badb22647bd683c..c1546b88101f94df51d416cbedac543b8833be40 100644 --- a/grudge/models/advection.py +++ b/grudge/models/advection.py @@ -32,9 +32,9 @@ THE SOFTWARE. import numpy import numpy.linalg as la -import hedge.data -from hedge.models import HyperbolicOperator -from hedge.second_order import CentralSecondDerivative +import grudge.data +from grudge.models import HyperbolicOperator +from grudge.second_order import CentralSecondDerivative @@ -49,7 +49,7 @@ class AdvectionOperatorBase(HyperbolicOperator): def __init__(self, v, inflow_tag="inflow", - inflow_u=hedge.data.make_tdep_constant(0), + inflow_u=grudge.data.make_tdep_constant(0), outflow_tag="outflow", flux_type="central" ): @@ -61,7 +61,7 @@ class AdvectionOperatorBase(HyperbolicOperator): self.flux_type = flux_type def weak_flux(self): - from hedge.flux import make_normal, FluxScalarPlaceholder + from grudge.flux import make_normal, FluxScalarPlaceholder from pymbolic.primitives import IfPositive u = FluxScalarPlaceholder(0) @@ -87,7 +87,7 @@ class AdvectionOperatorBase(HyperbolicOperator): def bind(self, discr): compiled_op_template = discr.compile(self.op_template()) - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [self.inflow_tag, self.outflow_tag]) def rhs(t, u): @@ -99,13 +99,13 @@ class AdvectionOperatorBase(HyperbolicOperator): def bind_interdomain(self, my_discr, my_part_data, nb_discr, nb_part_data): - from hedge.partition import compile_interdomain_flux + from grudge.partition import compile_interdomain_flux compiled_op_template, from_nb_indices = compile_interdomain_flux( self.op_template(), "u", "nb_bdry_u", my_discr, my_part_data, nb_discr, nb_part_data, use_stupid_substitution=True) - from hedge.tools import with_object_array_or_scalar, is_zero + from grudge.tools import with_object_array_or_scalar, is_zero def nb_bdry_permute(fld): if is_zero(fld): @@ -124,7 +124,7 @@ class AdvectionOperatorBase(HyperbolicOperator): class StrongAdvectionOperator(AdvectionOperatorBase): def flux(self): - from hedge.flux import make_normal, FluxScalarPlaceholder + from grudge.flux import make_normal, FluxScalarPlaceholder u = FluxScalarPlaceholder(0) normal = make_normal(self.dimensions) @@ -132,7 +132,7 @@ class StrongAdvectionOperator(AdvectionOperatorBase): return u.int * numpy.dot(normal, self.v) - self.weak_flux() def op_template(self): - from hedge.optemplate import Field, BoundaryPair, \ + from grudge.optemplate import Field, BoundaryPair, \ get_flux_operator, make_nabla, InverseMassOperator u = Field("u") @@ -157,7 +157,7 @@ class WeakAdvectionOperator(AdvectionOperatorBase): return self.weak_flux() def op_template(self): - from hedge.optemplate import ( + from grudge.optemplate import ( Field, BoundaryPair, get_flux_operator, @@ -196,9 +196,9 @@ class WeakAdvectionOperator(AdvectionOperatorBase): class VariableCoefficientAdvectionOperator(HyperbolicOperator): """A class for space- and time-dependent DG advection operators. - :param advec_v: Adheres to the :class:`hedge.data.ITimeDependentGivenFunction` + :param advec_v: Adheres to the :class:`grudge.data.ITimeDependentGivenFunction` interfacer and is an n-dimensional vector representing the velocity. - :param bc_u_f: Adheres to the :class:`hedge.data.ITimeDependentGivenFunction` + :param bc_u_f: Adheres to the :class:`grudge.data.ITimeDependentGivenFunction` interface and is a scalar representing the boundary condition at all boundary faces. @@ -227,7 +227,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): # {{{ flux ---------------------------------------------------------------- def flux(self): - from hedge.flux import ( + from grudge.flux import ( make_normal, FluxVectorPlaceholder, flux_max) @@ -263,9 +263,9 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): # }}} def bind_characteristic_velocity(self, discr): - from hedge.optemplate.operators import ( + from grudge.optemplate.operators import ( ElementwiseMaxOperator) - from hedge.optemplate import make_sym_vector + from grudge.optemplate import make_sym_vector velocity_vec = make_sym_vector("v", self.dimensions) velocity = ElementwiseMaxOperator()( numpy.dot(velocity_vec, velocity_vec)**0.5) @@ -279,20 +279,20 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): def op_template(self, with_sensor=False): # {{{ operator preliminaries ------------------------------------------ - from hedge.optemplate import (Field, BoundaryPair, get_flux_operator, + from grudge.optemplate import (Field, BoundaryPair, get_flux_operator, make_stiffness_t, InverseMassOperator, make_sym_vector, ElementwiseMaxOperator, BoundarizeOperator) - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse - from hedge.optemplate.operators import ( + from grudge.optemplate.operators import ( QuadratureGridUpsampler, QuadratureInteriorFacesGridUpsampler) to_quad = QuadratureGridUpsampler("quad") to_if_quad = QuadratureInteriorFacesGridUpsampler("quad") - from hedge.tools import join_fields, \ + from grudge.tools import join_fields, \ ptwise_dot u = Field("u") @@ -308,7 +308,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): # {{{ boundary conditions --------------------------------------------- - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL bc_c = to_quad(BoundarizeOperator(TAG_ALL)(c)) bc_u = to_quad(Field("bc_u")) bc_v = to_quad(BoundarizeOperator(TAG_ALL)(v)) @@ -335,7 +335,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): if with_sensor: diffusion_coeff += Field("sensor") - from hedge.second_order import SecondDerivativeTarget + from grudge.second_order import SecondDerivativeTarget # strong_form here allows IPDG to reuse the value of grad u. grad_tgt = SecondDerivativeTarget( @@ -372,7 +372,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): compiled_op_template = discr.compile( self.op_template(with_sensor=sensor is not None)) - from hedge.mesh import check_bc_coverage, TAG_ALL + from grudge.mesh import check_bc_coverage, TAG_ALL check_bc_coverage(discr.mesh, [TAG_ALL]) def rhs(t, u): @@ -398,7 +398,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator): # magnitude of the velocity at each node. From this vector the maximum # values limits the timestep. - from hedge.tools import ptwise_dot + from grudge.tools import ptwise_dot v = self.advec_v.volume_interpolant(t, discr) return discr.nodewise_max(ptwise_dot(1, 1, v, v)**0.5) diff --git a/grudge/models/burgers.py b/grudge/models/burgers.py index d8a22c9da1b8abe1925b84251a1110c202d4a929..ecf169b2e4f649b93c844c0bae530da4e4cafc30 100644 --- a/grudge/models/burgers.py +++ b/grudge/models/burgers.py @@ -29,9 +29,9 @@ THE SOFTWARE. -from hedge.models import HyperbolicOperator +from grudge.models import HyperbolicOperator import numpy -from hedge.second_order import CentralSecondDerivative +from grudge.second_order import CentralSecondDerivative @@ -46,12 +46,12 @@ class BurgersOperator(HyperbolicOperator): self.viscosity_scheme = viscosity_scheme def characteristic_velocity_optemplate(self, field): - from hedge.optemplate.operators import ( + from grudge.optemplate.operators import ( ElementwiseMaxOperator) return ElementwiseMaxOperator()(field**2)**0.5 def bind_characteristic_velocity(self, discr): - from hedge.optemplate import Field + from grudge.optemplate import Field compiled = discr.compile( self.characteristic_velocity_optemplate( Field("u"))) @@ -62,7 +62,7 @@ class BurgersOperator(HyperbolicOperator): return do def op_template(self, with_sensor): - from hedge.optemplate import ( + from grudge.optemplate import ( Field, make_stiffness_t, make_nabla, @@ -70,7 +70,7 @@ class BurgersOperator(HyperbolicOperator): ElementwiseMaxOperator, get_flux_operator) - from hedge.optemplate.operators import ( + from grudge.optemplate.operators import ( QuadratureGridUpsampler, QuadratureInteriorFacesGridUpsampler) @@ -90,7 +90,7 @@ class BurgersOperator(HyperbolicOperator): #return u0*u emax_u = self.characteristic_velocity_optemplate(u) - from hedge.flux.tools import make_lax_friedrichs_flux + from grudge.flux.tools import make_lax_friedrichs_flux from pytools.obj_array import make_obj_array num_flux = make_lax_friedrichs_flux( #u0, @@ -99,7 +99,7 @@ class BurgersOperator(HyperbolicOperator): [make_obj_array([flux(to_if_quad(u))])], [], strong=False)[0] - from hedge.second_order import SecondDerivativeTarget + from grudge.second_order import SecondDerivativeTarget if self.viscosity is not None or with_sensor: viscosity_coeff = 0 @@ -140,7 +140,7 @@ class BurgersOperator(HyperbolicOperator): compiled_op_template = discr.compile( self.op_template(with_sensor=sensor is not None)) - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, []) def rhs(t, u): diff --git a/grudge/models/diffusion.py b/grudge/models/diffusion.py index babdbed11d0bc5071791b7278d9fdb8108fa9490..eb38f77d138a2fcab7b88ad009efd2b0a772e2ae 100644 --- a/grudge/models/diffusion.py +++ b/grudge/models/diffusion.py @@ -30,18 +30,18 @@ THE SOFTWARE. import numpy -import hedge.data -from hedge.models import TimeDependentOperator -from hedge.models.poisson import LaplacianOperatorBase -from hedge.second_order import CentralSecondDerivative +import grudge.data +from grudge.models import TimeDependentOperator +from grudge.models.poisson import LaplacianOperatorBase +from grudge.second_order import CentralSecondDerivative class DiffusionOperator(TimeDependentOperator, LaplacianOperatorBase): def __init__(self, dimensions, diffusion_tensor=None, - dirichlet_bc=hedge.data.make_tdep_constant(0), dirichlet_tag="dirichlet", - neumann_bc=hedge.data.make_tdep_constant(0), neumann_tag="neumann", + dirichlet_bc=grudge.data.make_tdep_constant(0), dirichlet_tag="dirichlet", + neumann_bc=grudge.data.make_tdep_constant(0), neumann_tag="neumann", scheme=CentralSecondDerivative()): self.dimensions = dimensions @@ -61,7 +61,7 @@ class DiffusionOperator(TimeDependentOperator, LaplacianOperatorBase): assert self.dimensions == discr.dimensions - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [self.dirichlet_tag, self.neumann_tag]) return BoundDiffusionOperator(self, discr) @@ -77,7 +77,7 @@ class DiffusionOperator(TimeDependentOperator, LaplacianOperatorBase): * (discr.dt_non_geometric_factor() * discr.dt_geometric_factor())**2 - from hedge.timestep.stability import \ + from grudge.timestep.stability import \ approximate_rk4_relative_imag_stability_region return rk4_dt * approximate_rk4_relative_imag_stability_region( stepper, stepper_class, stepper_args) @@ -85,11 +85,11 @@ class DiffusionOperator(TimeDependentOperator, LaplacianOperatorBase): -class BoundDiffusionOperator(hedge.iterative.OperatorBase): +class BoundDiffusionOperator(grudge.iterative.OperatorBase): """Returned by :meth:`DiffusionOperator.bind`.""" def __init__(self, diffusion_op, discr): - hedge.iterative.OperatorBase.__init__(self) + grudge.iterative.OperatorBase.__init__(self) self.discr = discr dop = self.diffusion_op = diffusion_op @@ -101,7 +101,7 @@ class BoundDiffusionOperator(hedge.iterative.OperatorBase): # Check whether use of Poincaré mean-value method is required. # (for pure Neumann or pure periodic) - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL self.poincare_mean_value_hack = ( len(self.discr.get_boundary(TAG_ALL).nodes) == len(self.discr.get_boundary(diffusion_op.neumann_tag).nodes)) diff --git a/grudge/models/em.py b/grudge/models/em.py index 51971cc1f8550f8add8dfa563592f673bd7b471e..3929c6ac399a6f4fd5d2d121f5ca7360946465f9 100644 --- a/grudge/models/em.py +++ b/grudge/models/em.py @@ -1,5 +1,5 @@ # -*- coding: utf8 -*- -"""Hedge operators modelling electromagnetic phenomena.""" +"""grudge operators modelling electromagnetic phenomena.""" from __future__ import division from __future__ import absolute_import @@ -29,10 +29,10 @@ THE SOFTWARE. from pytools import memoize_method -import hedge.mesh -from hedge.models import HyperbolicOperator -from hedge.optemplate.primitives import make_common_subexpression as cse -from hedge.tools import make_obj_array +import grudge.mesh +from grudge.models import HyperbolicOperator +from grudge.optemplate.primitives import make_common_subexpression as cse +from grudge.tools import make_obj_array # TODO: Check PML @@ -49,10 +49,10 @@ class MaxwellOperator(HyperbolicOperator): def __init__(self, epsilon, mu, flux_type, bdry_flux_type=None, - pec_tag=hedge.mesh.TAG_ALL, - pmc_tag=hedge.mesh.TAG_NONE, - absorb_tag=hedge.mesh.TAG_NONE, - incident_tag=hedge.mesh.TAG_NONE, + pec_tag=grudge.mesh.TAG_ALL, + pmc_tag=grudge.mesh.TAG_NONE, + absorb_tag=grudge.mesh.TAG_NONE, + incident_tag=grudge.mesh.TAG_NONE, incident_bc=lambda maxwell_op, e, h: 0, current=0, dimensions=None): """ :arg flux_type: can be in [0,1] for anything between central and upwind, @@ -76,7 +76,7 @@ class MaxwellOperator(HyperbolicOperator): e_subset = self.get_eh_subset()[0:3] h_subset = self.get_eh_subset()[3:6] - from hedge.tools import SubsettableCrossProduct + from grudge.tools import SubsettableCrossProduct self.space_cross_e = SubsettableCrossProduct( op1_subset=space_subset, op2_subset=e_subset, @@ -124,14 +124,14 @@ class MaxwellOperator(HyperbolicOperator): As per Hesthaven and Warburton page 433. """ - from hedge.flux import (make_normal, FluxVectorPlaceholder, + from grudge.flux import (make_normal, FluxVectorPlaceholder, FluxConstantPlaceholder) - from hedge.tools import join_fields + from grudge.tools import join_fields normal = make_normal(self.dimensions) if self.fixed_material: - from hedge.tools import count_subset + from grudge.tools import count_subset w = FluxVectorPlaceholder(count_subset(self.get_eh_subset())) e, h = self.split_eh(w) @@ -139,7 +139,7 @@ class MaxwellOperator(HyperbolicOperator): mu = FluxConstantPlaceholder(self.mu) else: - from hedge.tools import count_subset + from grudge.tools import count_subset w = FluxVectorPlaceholder(count_subset(self.get_eh_subset())+2) epsilon, mu, e, h = self.split_eps_mu_eh(w) @@ -153,7 +153,7 @@ class MaxwellOperator(HyperbolicOperator): if self.fixed_material: max_c = (self.epsilon*self.mu)**(-0.5) else: - from hedge.flux import Max + from grudge.flux import Max c_int = (epsilon.int*mu.int)**(-0.5) c_ext = (epsilon.ext*mu.ext)**(-0.5) max_c = Max(c_int, c_ext) # noqa @@ -204,8 +204,8 @@ class MaxwellOperator(HyperbolicOperator): def h_curl(field): return self.space_cross_h(nabla, field) - from hedge.optemplate import make_nabla - from hedge.tools import join_fields + from grudge.optemplate import make_nabla + from grudge.tools import join_fields nabla = make_nabla(self.dimensions) @@ -217,10 +217,10 @@ class MaxwellOperator(HyperbolicOperator): def field_placeholder(self, w=None): "A placeholder for E and H." - from hedge.tools import count_subset + from grudge.tools import count_subset fld_cnt = count_subset(self.get_eh_subset()) if w is None: - from hedge.optemplate import make_sym_vector + from grudge.optemplate import make_sym_vector w = make_sym_vector("w", fld_cnt) return w @@ -229,8 +229,8 @@ class MaxwellOperator(HyperbolicOperator): "Construct part of the flux operator template for PEC boundary conditions" e, h = self.split_eh(self.field_placeholder(w)) - from hedge.tools import join_fields - from hedge.optemplate import BoundarizeOperator + from grudge.tools import join_fields + from grudge.optemplate import BoundarizeOperator pec_e = BoundarizeOperator(self.pec_tag)(e) pec_h = BoundarizeOperator(self.pec_tag)(h) @@ -240,8 +240,8 @@ class MaxwellOperator(HyperbolicOperator): "Construct part of the flux operator template for PMC boundary conditions" e, h = self.split_eh(self.field_placeholder(w)) - from hedge.tools import join_fields - from hedge.optemplate import BoundarizeOperator + from grudge.tools import join_fields + from grudge.optemplate import BoundarizeOperator pmc_e = BoundarizeOperator(self.pmc_tag)(e) pmc_h = BoundarizeOperator(self.pmc_tag)(h) @@ -252,11 +252,11 @@ class MaxwellOperator(HyperbolicOperator): absorbing boundary conditions. """ - from hedge.optemplate import normal + from grudge.optemplate import normal absorb_normal = normal(self.absorb_tag, self.dimensions) - from hedge.optemplate import BoundarizeOperator, Field - from hedge.tools import join_fields + from grudge.optemplate import BoundarizeOperator, Field + from grudge.tools import join_fields e, h = self.split_eh(self.field_placeholder(w)) @@ -294,14 +294,14 @@ class MaxwellOperator(HyperbolicOperator): e, h = self.split_eh(self.field_placeholder(w)) if not self.fixed_material: from warnings import warn - if self.incident_tag != hedge.mesh.TAG_NONE: + if self.incident_tag != grudge.mesh.TAG_NONE: warn("Incident boundary conditions assume homogeneous" " background material, results may be unphysical") - from hedge.tools import count_subset + from grudge.tools import count_subset fld_cnt = count_subset(self.get_eh_subset()) - from hedge.tools import is_zero + from grudge.tools import is_zero incident_bc_data = self.incident_bc_data(self, e, h) if is_zero(incident_bc_data): return make_obj_array([0]*fld_cnt) @@ -315,7 +315,7 @@ class MaxwellOperator(HyperbolicOperator): Combines the relevant operator templates for spatial derivatives, flux, boundary conditions etc. """ - from hedge.tools import join_fields + from grudge.tools import join_fields w = self.field_placeholder(w) if self.fixed_material: @@ -326,13 +326,13 @@ class MaxwellOperator(HyperbolicOperator): flux_w = join_fields(epsilon, mu, w) - from hedge.optemplate import BoundaryPair, \ + from grudge.optemplate import BoundaryPair, \ InverseMassOperator, get_flux_operator flux_op = get_flux_operator(self.flux(self.flux_type)) bdry_flux_op = get_flux_operator(self.flux(self.bdry_flux_type)) - from hedge.tools.indexing import count_subset + from grudge.tools.indexing import count_subset elec_components = count_subset(self.get_eh_subset()[0:3]) mag_components = count_subset(self.get_eh_subset()[3:6]) @@ -356,7 +356,7 @@ class MaxwellOperator(HyperbolicOperator): if self.fixed_material: return bc else: - from hedge.optemplate import BoundarizeOperator + from grudge.optemplate import BoundarizeOperator return join_fields( cse(BoundarizeOperator(tag)(epsilon)), cse(BoundarizeOperator(tag)(mu)), @@ -374,7 +374,7 @@ class MaxwellOperator(HyperbolicOperator): def bind(self, discr): "Convert the abstract operator template into compiled code." - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.pec_tag, self.absorb_tag, self.incident_tag]) @@ -397,7 +397,7 @@ class MaxwellOperator(HyperbolicOperator): def zero(): return discr.volume_zeros() - from hedge.tools import count_subset + from grudge.tools import count_subset e_components = count_subset(self.get_eh_subset()[0:3]) h_components = count_subset(self.get_eh_subset()[3:6]) @@ -410,7 +410,7 @@ class MaxwellOperator(HyperbolicOperator): e = default_fld(e, e_components) h = default_fld(h, h_components) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(e, h) assemble_fields = assemble_eh @@ -425,7 +425,7 @@ class MaxwellOperator(HyperbolicOperator): e_subset = self.get_eh_subset()[0:3] h_subset = self.get_eh_subset()[3:6] - from hedge.tools import partial_to_all_subset_indices + from grudge.tools import partial_to_all_subset_indices return tuple(partial_to_all_subset_indices( [e_subset, h_subset])) @@ -437,7 +437,7 @@ class MaxwellOperator(HyperbolicOperator): e_idx, h_idx = self.partial_to_eh_subsets() epsilon, mu, e, h = w[[0]], w[[1]], w[e_idx+2], w[h_idx+2] - from hedge.flux import FluxVectorPlaceholder as FVP + from grudge.flux import FluxVectorPlaceholder as FVP if isinstance(w, FVP): return ( FVP(scalars=epsilon), @@ -452,7 +452,7 @@ class MaxwellOperator(HyperbolicOperator): e_idx, h_idx = self.partial_to_eh_subsets() e, h = w[e_idx], w[h_idx] - from hedge.flux import FluxVectorPlaceholder as FVP + from grudge.flux import FluxVectorPlaceholder as FVP if isinstance(w, FVP): return FVP(scalars=e), FVP(scalars=h) else: @@ -473,7 +473,7 @@ class MaxwellOperator(HyperbolicOperator): if self.fixed_material: return 1/sqrt(self.epsilon*self.mu) # a number else: - import hedge.optemplate as sym + import grudge.optemplate as sym return sym.NodalMax()(1/sym.CFunction("sqrt")(self.epsilon*self.mu)) def max_eigenvalue(self, t, fields=None, discr=None, context={}): diff --git a/grudge/models/gas_dynamics/__init__.py b/grudge/models/gas_dynamics/__init__.py index c2d8edddcf70aed18340432f0671542506afdff3..c0caad51e17577494778bb1c70773a2a9fb58bbc 100644 --- a/grudge/models/gas_dynamics/__init__.py +++ b/grudge/models/gas_dynamics/__init__.py @@ -31,24 +31,24 @@ THE SOFTWARE. import numpy -import hedge.tools -import hedge.mesh -import hedge.data -from hedge.models import TimeDependentOperator +import grudge.tools +import grudge.mesh +import grudge.data +from grudge.models import TimeDependentOperator from pytools import Record -from hedge.tools import is_zero -from hedge.second_order import ( +from grudge.tools import is_zero +from grudge.second_order import ( StabilizedCentralSecondDerivative, CentralSecondDerivative, IPDGSecondDerivative) -from hedge.optemplate.primitives import make_common_subexpression as cse +from grudge.optemplate.primitives import make_common_subexpression as cse from pytools import memoize_method -from hedge.optemplate.tools import make_sym_vector +from grudge.optemplate.tools import make_sym_vector from pytools.obj_array import make_obj_array, join_fields AXES = ["x", "y", "z", "w"] -from hedge.optemplate.operators import ( +from grudge.optemplate.operators import ( QuadratureGridUpsampler, QuadratureInteriorFacesGridUpsampler) @@ -146,12 +146,12 @@ class GasDynamicsOperator(TimeDependentOperator): ): """ :param source: should implement - :class:`hedge.data.IFieldDependentGivenFunction` + :class:`grudge.data.IFieldDependentGivenFunction` or be None. :param artificial_viscosity_mode: """ - from hedge.data import ( + from grudge.data import ( TimeConstantGivenFunction, ConstantGivenFunction) @@ -224,7 +224,7 @@ class GasDynamicsOperator(TimeDependentOperator): @memoize_method def sensor(self): - from hedge.optemplate.primitives import Field + from grudge.optemplate.primitives import Field sensor = Field("sensor") def rho(self, q): @@ -298,7 +298,7 @@ class GasDynamicsOperator(TimeDependentOperator): def primitive_to_conservative(self, prims, use_cses=True): if not use_cses: - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse else: def cse(x, name): return x @@ -314,7 +314,7 @@ class GasDynamicsOperator(TimeDependentOperator): def conservative_to_primitive(self, q, use_cses=True): if use_cses: - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse else: def cse(x, name): return x @@ -324,9 +324,9 @@ class GasDynamicsOperator(TimeDependentOperator): self.u(q)) def characteristic_velocity_optemplate(self, state): - from hedge.optemplate.operators import ElementwiseMaxOperator + from grudge.optemplate.operators import ElementwiseMaxOperator - from hedge.optemplate.primitives import CFunction + from grudge.optemplate.primitives import CFunction sqrt = CFunction("sqrt") sound_speed = cse(sqrt( @@ -353,7 +353,7 @@ class GasDynamicsOperator(TimeDependentOperator): # {{{ compute gradient of state --------------------------------------- def grad_of(self, var, faceq_var): - from hedge.second_order import SecondDerivativeTarget + from grudge.second_order import SecondDerivativeTarget grad_tgt = SecondDerivativeTarget( self.dimensions, strong_form=False, operand=var, @@ -498,7 +498,7 @@ class GasDynamicsOperator(TimeDependentOperator): c0 = (self.equation_of_state.gamma * p0 / rho0)**0.5 - from hedge.optemplate import BoundarizeOperator + from grudge.optemplate import BoundarizeOperator bdrize_op = BoundarizeOperator(tag) class SingleBCInfo(Record): @@ -516,11 +516,11 @@ class GasDynamicsOperator(TimeDependentOperator): - p0, "dpm")) def outflow_state(self, state): - from hedge.optemplate import make_normal + from grudge.optemplate import make_normal normal = make_normal(self.outflow_tag, self.dimensions) bc = self.make_bc_info("bc_q_out", self.outflow_tag, state) - # see hedge/doc/maxima/euler.mac + # see grudge/doc/maxima/euler.mac return join_fields( # bc rho cse(bc.rho0 @@ -537,7 +537,7 @@ class GasDynamicsOperator(TimeDependentOperator): + bc.dpm*normal/(2*bc.c0*bc.rho0), "bc_u_outflow")) def inflow_state_inner(self, normal, bc, name): - # see hedge/doc/maxima/euler.mac + # see grudge/doc/maxima/euler.mac return join_fields( # bc rho cse(bc.rho0 @@ -552,13 +552,13 @@ class GasDynamicsOperator(TimeDependentOperator): + normal*numpy.dot(normal, bc.dumvec)/2 + bc.dpm*normal/(2*bc.c0*bc.rho0), "bc_u_"+name)) def inflow_state(self, state): - from hedge.optemplate import make_normal + from grudge.optemplate import make_normal normal = make_normal(self.inflow_tag, self.dimensions) bc = self.make_bc_info("bc_q_in", self.inflow_tag, state) return self.inflow_state_inner(normal, bc, "inflow") def noslip_state(self, state): - from hedge.optemplate import make_normal + from grudge.optemplate import make_normal state0 = join_fields( make_sym_vector("bc_q_noslip", 2), [0]*self.dimensions) @@ -567,13 +567,13 @@ class GasDynamicsOperator(TimeDependentOperator): return self.inflow_state_inner(normal, bc, "noslip") def wall_state(self, state): - from hedge.optemplate import BoundarizeOperator + from grudge.optemplate import BoundarizeOperator bc = BoundarizeOperator(self.wall_tag)(state) wall_rho = self.rho(bc) wall_e = self.e(bc) # <3 eve wall_rho_u = self.rho_u(bc) - from hedge.optemplate import make_normal + from grudge.optemplate import make_normal normal = make_normal(self.wall_tag, self.dimensions) return join_fields( @@ -596,7 +596,7 @@ class GasDynamicsOperator(TimeDependentOperator): def get_conservative_boundary_conditions(self): state = self.state() - from hedge.optemplate import BoundarizeOperator + from grudge.optemplate import BoundarizeOperator return { self.supersonic_inflow_tag: make_sym_vector("bc_q_supersonic_in", self.dimensions+2), @@ -614,7 +614,7 @@ class GasDynamicsOperator(TimeDependentOperator): @memoize_method def _normalize_expr(self, expr): """Normalize expressions for use as hash keys.""" - from hedge.optemplate.mappers import ( + from grudge.optemplate.mappers import ( QuadratureUpsamplerRemover, CSERemover) @@ -652,7 +652,7 @@ class GasDynamicsOperator(TimeDependentOperator): # 'cbstate' is the boundary state in conservative variables. - from hedge.optemplate.mappers import QuadratureUpsamplerRemover + from grudge.optemplate.mappers import QuadratureUpsamplerRemover expr = QuadratureUpsamplerRemover({}, do_warn=False)(expr) def subst_func(expr): @@ -664,18 +664,18 @@ class GasDynamicsOperator(TimeDependentOperator): return cbstate[expr.index] elif isinstance(expr, Variable) and expr.name =="sensor": - from hedge.optemplate import BoundarizeOperator + from grudge.optemplate import BoundarizeOperator result = BoundarizeOperator(tag)(self.sensor()) return cse(to_bdry_quad(result), "bdry_sensor") - from hedge.optemplate import SubstitutionMapper + from grudge.optemplate import SubstitutionMapper return SubstitutionMapper(subst_func)(expr) # }}} # {{{ second order part def div(self, vol_operand, int_face_operand): - from hedge.second_order import SecondDerivativeTarget + from grudge.second_order import SecondDerivativeTarget div_tgt = SecondDerivativeTarget( self.dimensions, strong_form=False, operand=vol_operand, @@ -743,7 +743,7 @@ class GasDynamicsOperator(TimeDependentOperator): volq_flux = self.flux(self.volq_state()) faceq_flux = self.flux(self.faceq_state()) - from hedge.optemplate.primitives import CFunction + from grudge.optemplate.primitives import CFunction sqrt = CFunction("sqrt") speed = self.characteristic_velocity_optemplate(self.state()) @@ -753,10 +753,10 @@ class GasDynamicsOperator(TimeDependentOperator): # }}} # {{{ operator assembly ----------------------------------------------- - from hedge.flux.tools import make_lax_friedrichs_flux - from hedge.optemplate.operators import InverseMassOperator + from grudge.flux.tools import make_lax_friedrichs_flux + from grudge.optemplate.operators import InverseMassOperator - from hedge.optemplate.tools import make_stiffness_t + from grudge.optemplate.tools import make_stiffness_t primitive_bcs_as_quad_conservative = dict( (tag, self.primitive_to_conservative(to_bdry_quad(bc))) @@ -812,7 +812,7 @@ class GasDynamicsOperator(TimeDependentOperator): sensor_scaling=sensor_scaling, viscosity_only=False)) - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.inflow_tag, self.outflow_tag, @@ -871,7 +871,7 @@ class GasDynamicsOperator(TimeDependentOperator): # see JSH/TW, eq. (7.32) rk4_dt = dg_factor / (max_eigenvalue + self.mu / dg_factor) - from hedge.timestep.stability import \ + from grudge.timestep.stability import \ approximate_rk4_relative_imag_stability_region return rk4_dt * approximate_rk4_relative_imag_stability_region( stepper, stepper_class, stepper_args) @@ -891,11 +891,11 @@ class SlopeLimiter1NEuler: self.dimensions=dimensions self.op=op - from hedge.optemplate.operators import AveragingOperator + from grudge.optemplate.operators import AveragingOperator self.get_average = AveragingOperator().bind(discr) def __call__(self, fields): - from hedge.tools import join_fields + from grudge.tools import join_fields #get conserved fields rho=self.op.rho(fields) diff --git a/grudge/models/gas_dynamics/lbm.py b/grudge/models/gas_dynamics/lbm.py index 45de4b61ce29783148ef77ba79a839a700aa099f..41b09559644021d3641a5c5b0d814b71c376fae4 100644 --- a/grudge/models/gas_dynamics/lbm.py +++ b/grudge/models/gas_dynamics/lbm.py @@ -30,7 +30,7 @@ THE SOFTWARE. import numpy as np import numpy.linalg as la -from hedge.models import HyperbolicOperator +from grudge.models import HyperbolicOperator from pytools.obj_array import make_obj_array @@ -115,7 +115,7 @@ class LatticeBoltzmannOperator(HyperbolicOperator): (self.lbm_delta_t*self.method.speed_of_sound**2)) def get_advection_flux(self, velocity): - from hedge.flux import make_normal, FluxScalarPlaceholder + from grudge.flux import make_normal, FluxScalarPlaceholder from pymbolic.primitives import IfPositive u = FluxScalarPlaceholder(0) @@ -136,7 +136,7 @@ class LatticeBoltzmannOperator(HyperbolicOperator): raise ValueError("invalid flux type") def get_advection_op(self, q, velocity): - from hedge.optemplate import ( + from grudge.optemplate import ( BoundaryPair, get_flux_operator, make_stiffness_t, @@ -149,7 +149,7 @@ class LatticeBoltzmannOperator(HyperbolicOperator): np.dot(velocity, stiff_t*q) - flux_op(q)) def f_bar(self): - from hedge.optemplate import make_sym_vector + from grudge.optemplate import make_sym_vector return make_sym_vector("f_bar", len(self.method)) def rho(self, f_bar): @@ -168,7 +168,7 @@ class LatticeBoltzmannOperator(HyperbolicOperator): zip(self.method.direction_vectors, f_bar)]) def collision_update(self, f_bar): - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse rho = cse(self.rho(f_bar), "rho") rho_u = self.rho_u(f_bar) u = cse(rho_u/rho, "u") @@ -183,7 +183,7 @@ class LatticeBoltzmannOperator(HyperbolicOperator): compiled_op_template = discr.compile( self.stream_rhs(self.f_bar())) - #from hedge.mesh import check_bc_coverage, TAG_ALL + #from grudge.mesh import check_bc_coverage, TAG_ALL #check_bc_coverage(discr.mesh, [TAG_ALL]) def rhs(t, f_bar): @@ -194,7 +194,7 @@ class LatticeBoltzmannOperator(HyperbolicOperator): def bind(self, discr, what): f_bar_sym = self.f_bar() - from hedge.optemplate.mappers.type_inference import ( + from grudge.optemplate.mappers.type_inference import ( type_info, NodalRepresentation) type_hints = dict( diff --git a/grudge/models/nd_calculus.py b/grudge/models/nd_calculus.py index 138b282dd0352b1c971d13b0b6f0688dd71d9991..746cf26933c571aeb10e05c58ef39e3da746a17e 100644 --- a/grudge/models/nd_calculus.py +++ b/grudge/models/nd_calculus.py @@ -29,7 +29,7 @@ THE SOFTWARE. -from hedge.models import Operator +from grudge.models import Operator @@ -39,15 +39,15 @@ class GradientOperator(Operator): self.dimensions = dimensions def flux(self): - from hedge.flux import make_normal, FluxScalarPlaceholder + from grudge.flux import make_normal, FluxScalarPlaceholder u = FluxScalarPlaceholder() normal = make_normal(self.dimensions) return u.int*normal - u.avg*normal def op_template(self): - from hedge.mesh import TAG_ALL - from hedge.optemplate import Field, BoundaryPair, \ + from grudge.mesh import TAG_ALL + from grudge.optemplate import Field, BoundaryPair, \ make_nabla, InverseMassOperator, get_flux_operator u = Field("u") @@ -64,7 +64,7 @@ class GradientOperator(Operator): compiled_op_template = discr.compile(self.op_template()) def op(u): - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL return compiled_op_template(u=u, bc=discr.boundarize_volume_field(u, TAG_ALL)) @@ -84,11 +84,11 @@ class DivergenceOperator(Operator): # chop off any extra dimensions self.subset = subset[:dimensions] - from hedge.tools import count_subset + from grudge.tools import count_subset self.arg_count = count_subset(self.subset) def flux(self): - from hedge.flux import make_normal, FluxVectorPlaceholder + from grudge.flux import make_normal, FluxVectorPlaceholder v = FluxVectorPlaceholder(self.arg_count) @@ -105,8 +105,8 @@ class DivergenceOperator(Operator): return flux def op_template(self): - from hedge.mesh import TAG_ALL - from hedge.optemplate import make_sym_vector, BoundaryPair, \ + from grudge.mesh import TAG_ALL + from grudge.optemplate import make_sym_vector, BoundaryPair, \ get_flux_operator, make_nabla, InverseMassOperator nabla = make_nabla(self.dimensions) @@ -132,7 +132,7 @@ class DivergenceOperator(Operator): compiled_op_template = discr.compile(self.op_template()) def op(v): - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL return compiled_op_template(v=v, bc=discr.boundarize_volume_field(v, TAG_ALL)) diff --git a/grudge/models/pml.py b/grudge/models/pml.py index 6cf1949cb91f4ca28d016a0ef8ab195aa920fb00..29c6312fd49d3c35f31f5416e252fcd1b56da5e4 100644 --- a/grudge/models/pml.py +++ b/grudge/models/pml.py @@ -34,7 +34,7 @@ THE SOFTWARE. import numpy from pytools import memoize_method, Record -from hedge.models.em import \ +from grudge.models.em import \ MaxwellOperator, \ TMMaxwellOperator, \ TEMaxwellOperator @@ -87,7 +87,7 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): result[numpy.array(subset, dtype=bool)] = v return result - from hedge.optemplate import make_sym_vector + from grudge.optemplate import make_sym_vector sig = pad_vec( make_sym_vector("sigma", self.dimensions), dim_subset) @@ -112,7 +112,7 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): my = (mx+1) % 3 mz = (mx+2) % 3 - from hedge.tools.mathematics import levi_civita + from grudge.tools.mathematics import levi_civita assert levi_civita((mx,my,mz)) == 1 rhs[mx] += -sig[my]/self.epsilon*(2*e[mx]+p[mx]) - 2*tau[my]/self.epsilon*e[mx] @@ -124,19 +124,19 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): rhs[6+my] += sig[mx]/self.epsilon*e[my] rhs[9+mx] += -sig[mx]/self.epsilon*q[mx] - (e[my] + e[mz]) - from hedge.tools import full_to_subset_indices + from grudge.tools import full_to_subset_indices sub_idx = full_to_subset_indices(e_subset+h_subset+dim_subset+dim_subset) return rhs[sub_idx] def op_template(self, w=None): - from hedge.tools import count_subset + from grudge.tools import count_subset fld_cnt = count_subset(self.get_eh_subset()) if w is None: - from hedge.optemplate import make_sym_vector + from grudge.optemplate import make_sym_vector w = make_sym_vector("w", fld_cnt+2*self.dimensions) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields( MaxwellOperator.op_template(self, w[:fld_cnt]), numpy.zeros((2*self.dimensions,), dtype=object) @@ -156,7 +156,7 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): def zero(): return discr.volume_zeros() - from hedge.tools import count_subset + from grudge.tools import count_subset e_components = count_subset(self.get_eh_subset()[0:3]) h_components = count_subset(self.get_eh_subset()[3:6]) @@ -171,7 +171,7 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): p = default_fld(p, self.dimensions) q = default_fld(q, self.dimensions) - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(e, h, p, q) @memoize_method @@ -181,7 +181,7 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): dim_subset = [True] * self.dimensions + [False] * (3-self.dimensions) - from hedge.tools import partial_to_all_subset_indices + from grudge.tools import partial_to_all_subset_indices return tuple(partial_to_all_subset_indices( [e_subset, h_subset, dim_subset, dim_subset])) @@ -189,11 +189,11 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): e_idx, h_idx, p_idx, q_idx = self.partial_to_ehpq_subsets() e, h, p, q = w[e_idx], w[h_idx], w[p_idx], w[q_idx] - from hedge.flux import FluxVectorPlaceholder as FVP + from grudge.flux import FluxVectorPlaceholder as FVP if isinstance(w, FVP): return FVP(scalars=e), FVP(scalars=h) else: - from hedge.tools import make_obj_array as moa + from grudge.tools import make_obj_array as moa return moa(e), moa(h), moa(p), moa(q) # sigma business ---------------------------------------------------------- @@ -246,7 +246,7 @@ class AbarbanelGottliebPMLMaxwellOperator(MaxwellOperator): i_min, i_max = inner_bbox o_min, o_max = outer_bbox - from hedge.tools import make_obj_array + from grudge.tools import make_obj_array nodes = discr.nodes if dtype is not None: diff --git a/grudge/models/poisson.py b/grudge/models/poisson.py index 6135f8183f4efb97a9bf34f46e7d3bc663fb66f6..f8b8b49b204127de294d71ff743d3381cc90663b 100644 --- a/grudge/models/poisson.py +++ b/grudge/models/poisson.py @@ -29,10 +29,10 @@ THE SOFTWARE. import numpy as np -from hedge.models import Operator -from hedge.second_order import LDGSecondDerivative -import hedge.data -import hedge.iterative +from grudge.models import Operator +from grudge.second_order import LDGSecondDerivative +import grudge.data +import grudge.iterative class LaplacianOperatorBase(object): @@ -45,11 +45,11 @@ class LaplacianOperatorBase(object): that the mass operator only needs to be applied once, when preparing the right hand side in :meth:`prepare_rhs`. - :class:`hedge.models.diffusion.DiffusionOperator` needs this. + :class:`grudge.models.diffusion.DiffusionOperator` needs this. """ - from hedge.optemplate import Field, make_sym_vector - from hedge.second_order import SecondDerivativeTarget + from grudge.optemplate import Field, make_sym_vector + from grudge.second_order import SecondDerivativeTarget if u is None: u = Field("u") @@ -115,9 +115,9 @@ class PoissonOperator(Operator, LaplacianOperatorBase): """ def __init__(self, dimensions, diffusion_tensor=None, - dirichlet_bc=hedge.data.ConstantGivenFunction(), + dirichlet_bc=grudge.data.ConstantGivenFunction(), dirichlet_tag="dirichlet", - neumann_bc=hedge.data.ConstantGivenFunction(), + neumann_bc=grudge.data.ConstantGivenFunction(), neumann_tag="neumann", scheme=LDGSecondDerivative()): self.dimensions = dimensions @@ -139,17 +139,17 @@ class PoissonOperator(Operator, LaplacianOperatorBase): assert self.dimensions == discr.dimensions - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [self.dirichlet_tag, self.neumann_tag]) return BoundPoissonOperator(self, discr) -class BoundPoissonOperator(hedge.iterative.OperatorBase): +class BoundPoissonOperator(grudge.iterative.OperatorBase): """Returned by :meth:`PoissonOperator.bind`.""" def __init__(self, poisson_op, discr): - hedge.iterative.OperatorBase.__init__(self) + grudge.iterative.OperatorBase.__init__(self) self.discr = discr pop = self.poisson_op = poisson_op @@ -167,7 +167,7 @@ class BoundPoissonOperator(hedge.iterative.OperatorBase): # Check whether use of Poincaré mean-value method is required. # (for pure Neumann or pure periodic) - from hedge.mesh import TAG_ALL + from grudge.mesh import TAG_ALL self.poincare_mean_value_hack = ( len(self.discr.get_boundary(TAG_ALL).nodes) == len(self.discr.get_boundary(poisson_op.neumann_tag).nodes)) @@ -236,7 +236,7 @@ class BoundPoissonOperator(hedge.iterative.OperatorBase): """ pop = self.poisson_op - from hedge.optemplate import MassOperator + from grudge.optemplate import MassOperator return (MassOperator().apply(self.discr, rhs) - self.compiled_bc_op( u=self.discr.volume_zeros(), @@ -252,7 +252,7 @@ class HelmholtzOperator(PoissonOperator): self.k = k def op_template(self, apply_minv, u=None, dir_bc=None, neu_bc=None): - from hedge.optemplate import Field + from grudge.optemplate import Field if u is None: u = Field("u") @@ -262,5 +262,5 @@ class HelmholtzOperator(PoissonOperator): if apply_minv: return result + self.k**2 * u else: - from hedge.optemplate import MassOperator + from grudge.optemplate import MassOperator return result + self.k**2 * MassOperator()(u) diff --git a/grudge/models/second_order.py b/grudge/models/second_order.py index 56eff04b41829c33895caecfdabf67a5f17fd431..dfdb4d4fb7603b5d720b2c014fe0ea136a038163 100644 --- a/grudge/models/second_order.py +++ b/grudge/models/second_order.py @@ -27,20 +27,20 @@ THE SOFTWARE. import numpy as np -import hedge.optemplate +import grudge.optemplate # {{{ stabilization term generator -class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): +class StabilizationTermGenerator(grudge.optemplate.IdentityMapper): def __init__(self, flux_args): - hedge.optemplate.IdentityMapper.__init__(self) + grudge.optemplate.IdentityMapper.__init__(self) self.flux_args = flux_args self.flux_arg_lookup = dict( (flux_arg, i) for i, flux_arg in enumerate(flux_args)) def get_flux_arg_idx(self, expr, quad_above): - from hedge.optemplate.mappers import QuadratureDetector + from grudge.optemplate.mappers import QuadratureDetector quad_below = QuadratureDetector()(expr) if quad_above: @@ -51,7 +51,7 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): # now two layers of quadrature operators. We need to change the # inner layer to be the only layer. - from hedge.optemplate.mappers import QuadratureUpsamplerChanger + from grudge.optemplate.mappers import QuadratureUpsamplerChanger expr = QuadratureUpsamplerChanger(quad_above[0])(expr) else: # Only the part of the expression above the differentiation @@ -62,7 +62,7 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): # Only the part of the expression below the differentiation # operator had quadrature--the stuff above doesn't want it. # Get rid of it. - from hedge.optemplate.mappers import QuadratureUpsamplerRemover + from grudge.optemplate.mappers import QuadratureUpsamplerRemover expr = QuadratureUpsamplerRemover({}, do_warn=False)(expr) else: # No quadrature, no headaches. @@ -77,7 +77,7 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): return flux_arg_idx def map_operator_binding(self, expr, quad_above=[]): - from hedge.optemplate.operators import ( + from grudge.optemplate.operators import ( DiffOperatorBase, FluxOperatorBase, InverseMassOperator, QuadratureInteriorFacesGridUpsampler) @@ -85,7 +85,7 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): if isinstance(expr.op, DiffOperatorBase): flux_arg_idx = self.get_flux_arg_idx(expr.field, quad_above=quad_above) - from hedge.optemplate import \ + from grudge.optemplate import \ WeakFormDiffOperatorBase, \ StrongFormDiffOperatorBase if isinstance(expr.op, WeakFormDiffOperatorBase): @@ -96,7 +96,7 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): raise RuntimeError("unknown type of differentiation " "operator encountered by stab term generator") - from hedge.flux import Normal, FluxScalarPlaceholder + from grudge.flux import Normal, FluxScalarPlaceholder sph = FluxScalarPlaceholder(flux_arg_idx) return (factor * Normal(expr.op.xyz_axis) @@ -112,12 +112,12 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): "when generating stabilization term") return self.rec(expr.field, [expr.op]) else: - from hedge.optemplate.tools import pretty + from grudge.optemplate.tools import pretty raise ValueError("stabilization term generator doesn't know " "what to do with '%s'" % pretty(expr)) def map_variable(self, expr, quad_above=[]): - from hedge.flux import FieldComponent + from grudge.flux import FieldComponent return FieldComponent( self.get_flux_arg_idx(expr, quad_above), is_interior=True) @@ -125,7 +125,7 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): def map_subscript(self, expr, quad_above=[]): from pymbolic.primitives import Variable assert isinstance(expr.aggregate, Variable) - from hedge.flux import FieldComponent + from grudge.flux import FieldComponent return FieldComponent( self.get_flux_arg_idx(expr, quad_above), is_interior=True) @@ -135,15 +135,15 @@ class StabilizationTermGenerator(hedge.optemplate.IdentityMapper): # {{{ neumann bc generator -class NeumannBCGenerator(hedge.optemplate.IdentityMapper): +class NeumannBCGenerator(grudge.optemplate.IdentityMapper): def __init__(self, tag, bc): - hedge.optemplate.IdentityMapper.__init__(self) + grudge.optemplate.IdentityMapper.__init__(self) self.tag = tag self.bc = bc def map_operator_binding(self, expr): - if isinstance(expr.op, hedge.optemplate.DiffOperatorBase): - from hedge.optemplate import \ + if isinstance(expr.op, grudge.optemplate.DiffOperatorBase): + from grudge.optemplate import \ WeakFormDiffOperatorBase, \ StrongFormDiffOperatorBase if isinstance(expr.op, WeakFormDiffOperatorBase): @@ -154,13 +154,13 @@ class NeumannBCGenerator(hedge.optemplate.IdentityMapper): raise RuntimeError("unknown type of differentiation " "operator encountered by stab term generator") - from hedge.optemplate import BoundaryNormalComponent + from grudge.optemplate import BoundaryNormalComponent return (self.bc * factor * BoundaryNormalComponent(self.tag, expr.op.xyz_axis)) - elif isinstance(expr.op, hedge.optemplate.FluxOperatorBase): + elif isinstance(expr.op, grudge.optemplate.FluxOperatorBase): return 0 - elif isinstance(expr.op, hedge.optemplate.InverseMassOperator): + elif isinstance(expr.op, grudge.optemplate.InverseMassOperator): return self.rec(expr.field) else: raise ValueError("neumann normal direction generator doesn't know " @@ -169,10 +169,10 @@ class NeumannBCGenerator(hedge.optemplate.IdentityMapper): # }}} -class IPDGDerivativeGenerator(hedge.optemplate.IdentityMapper): +class IPDGDerivativeGenerator(grudge.optemplate.IdentityMapper): def map_operator_binding(self, expr): - if isinstance(expr.op, hedge.optemplate.DiffOperatorBase): - from hedge.optemplate import ( + if isinstance(expr.op, grudge.optemplate.DiffOperatorBase): + from grudge.optemplate import ( WeakFormDiffOperatorBase, StrongFormDiffOperatorBase) @@ -184,19 +184,19 @@ class IPDGDerivativeGenerator(hedge.optemplate.IdentityMapper): raise RuntimeError("unknown type of differentiation " "operator encountered by stab term generator") - from hedge.optemplate import DifferentiationOperator + from grudge.optemplate import DifferentiationOperator return factor*DifferentiationOperator(expr.op.xyz_axis)(expr.field) - elif isinstance(expr.op, hedge.optemplate.FluxOperatorBase): + elif isinstance(expr.op, grudge.optemplate.FluxOperatorBase): return 0 - elif isinstance(expr.op, hedge.optemplate.InverseMassOperator): + elif isinstance(expr.op, grudge.optemplate.InverseMassOperator): return self.rec(expr.field) elif isinstance(expr.op, - hedge.optemplate.QuadratureInteriorFacesGridUpsampler): - return hedge.optemplate.IdentityMapper.map_operator_binding( + grudge.optemplate.QuadratureInteriorFacesGridUpsampler): + return grudge.optemplate.IdentityMapper.map_operator_binding( self, expr) else: - from hedge.optemplate.tools import pretty + from grudge.optemplate.tools import pretty raise ValueError("IPDG derivative generator doesn't know " "what to do with '%s'" % pretty(expr)) @@ -258,7 +258,7 @@ class SecondDerivativeTarget(object): return vec*operand def normal_times_flux(self, flux): - from hedge.flux import make_normal + from grudge.flux import make_normal return self.vec_times(make_normal(self.dimensions), flux) def apply_diff(self, nabla, operand): @@ -275,10 +275,10 @@ class SecondDerivativeTarget(object): def _local_nabla(self): if self.strong_form: - from hedge.optemplate import make_stiffness + from grudge.optemplate import make_stiffness return make_stiffness(self.dimensions) else: - from hedge.optemplate import make_stiffness_t + from grudge.optemplate import make_stiffness_t return make_stiffness_t(self.dimensions) def add_derivative(self, operand=None): @@ -289,12 +289,12 @@ class SecondDerivativeTarget(object): self.apply_diff(self._local_nabla(), operand)) def add_inner_fluxes(self, flux, expr): - from hedge.optemplate import get_flux_operator + from grudge.optemplate import get_flux_operator self.inner_fluxes = self.inner_fluxes \ + get_flux_operator(self.strong_neg*flux)(expr) def add_boundary_flux(self, flux, volume_expr, bdry_expr, tag): - from hedge.optemplate import BoundaryPair, get_flux_operator + from grudge.optemplate import BoundaryPair, get_flux_operator self.boundary_fluxes = self.boundary_fluxes + \ get_flux_operator(self.strong_neg*flux)(BoundaryPair( volume_expr, bdry_expr, tag)) @@ -309,8 +309,8 @@ class SecondDerivativeTarget(object): @property def minv_all(self): - from hedge.optemplate.primitives import make_common_subexpression as cse - from hedge.optemplate.operators import InverseMassOperator + from grudge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.operators import InverseMassOperator return (cse(InverseMassOperator()(self.local_derivatives), "grad_loc") + cse(InverseMassOperator()(self.fluxes), "grad_flux")) @@ -334,7 +334,7 @@ class SecondDerivativeBase(object): def adjust_flux(f): return f - from hedge.flux import FluxScalarPlaceholder + from grudge.flux import FluxScalarPlaceholder u = FluxScalarPlaceholder() tgt.add_derivative() @@ -395,7 +395,7 @@ class LDGSecondDerivative(SecondDerivativeBase): return np.array([self.beta_value]*tgt.dimensions, dtype=np.float64) def grad_interior_flux(self, tgt, u): - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse n_times = tgt.normal_times_flux v_times = tgt.vec_times @@ -409,8 +409,8 @@ class LDGSecondDerivative(SecondDerivativeBase): *volume_expr* will be None to query the Neumann condition. """ - from hedge.optemplate.primitives import make_common_subexpression as cse - from hedge.flux import FluxVectorPlaceholder, PenaltyTerm + from grudge.optemplate.primitives import make_common_subexpression as cse + from grudge.flux import FluxVectorPlaceholder, PenaltyTerm n_times = tgt.normal_times_flux v_times = tgt.vec_times @@ -459,7 +459,7 @@ class IPDGSecondDerivative(SecondDerivativeBase): self.stab_coefficient = stab_coefficient def grad_interior_flux(self, tgt, u): - from hedge.optemplate.primitives import make_common_subexpression as cse + from grudge.optemplate.primitives import make_common_subexpression as cse n_times = tgt.normal_times_flux return n_times(cse(u.avg, "u_avg")) @@ -469,8 +469,8 @@ class IPDGSecondDerivative(SecondDerivativeBase): *volume_expr* will be None to query the Neumann condition. """ - from hedge.optemplate.primitives import make_common_subexpression as cse - from hedge.flux import FluxVectorPlaceholder, PenaltyTerm + from grudge.optemplate.primitives import make_common_subexpression as cse + from grudge.flux import FluxVectorPlaceholder, PenaltyTerm n_times = tgt.normal_times_flux diff --git a/grudge/models/wave.py b/grudge/models/wave.py index 8f45e6b46403125d7c47fc151b3a38726258678d..5c0f3a323ffc8db273a3694e4e080cd9c5dc808b 100644 --- a/grudge/models/wave.py +++ b/grudge/models/wave.py @@ -28,9 +28,9 @@ THE SOFTWARE. import numpy as np -import hedge.mesh -from hedge.models import HyperbolicOperator -from hedge.second_order import CentralSecondDerivative +import grudge.mesh +from grudge.models import HyperbolicOperator +from grudge.second_order import CentralSecondDerivative # {{{ constant-velocity @@ -55,10 +55,10 @@ class StrongWaveOperator(HyperbolicOperator): def __init__(self, c, dimensions, source_f=0, flux_type="upwind", - dirichlet_tag=hedge.mesh.TAG_ALL, + dirichlet_tag=grudge.mesh.TAG_ALL, dirichlet_bc_f=0, - neumann_tag=hedge.mesh.TAG_NONE, - radiation_tag=hedge.mesh.TAG_NONE): + neumann_tag=grudge.mesh.TAG_NONE, + radiation_tag=grudge.mesh.TAG_NONE): assert isinstance(dimensions, int) self.c = c @@ -79,7 +79,7 @@ class StrongWaveOperator(HyperbolicOperator): self.flux_type = flux_type def flux(self): - from hedge.flux import FluxVectorPlaceholder, make_normal + from grudge.flux import FluxVectorPlaceholder, make_normal dim = self.dimensions w = FluxVectorPlaceholder(1+dim) @@ -87,7 +87,7 @@ class StrongWaveOperator(HyperbolicOperator): v = w[1:] normal = make_normal(dim) - from hedge.tools import join_fields + from grudge.tools import join_fields flux_weak = join_fields( np.dot(v.avg, normal), u.avg * normal) @@ -95,7 +95,7 @@ class StrongWaveOperator(HyperbolicOperator): if self.flux_type == "central": pass elif self.flux_type == "upwind": - # see doc/notes/hedge-notes.tm + # see doc/notes/grudge-notes.tm flux_weak -= self.sign*join_fields( 0.5*(u.int-u.ext), 0.5*(normal * np.dot(normal, v.int-v.ext))) @@ -109,7 +109,7 @@ class StrongWaveOperator(HyperbolicOperator): return -self.c*flux_strong def op_template(self): - from hedge.optemplate import \ + from grudge.optemplate import \ make_sym_vector, \ BoundaryPair, \ get_flux_operator, \ @@ -124,10 +124,10 @@ class StrongWaveOperator(HyperbolicOperator): v = w[1:] # boundary conditions ------------------------------------------------- - from hedge.tools import join_fields + from grudge.tools import join_fields # dirichlet BCs ------------------------------------------------------- - from hedge.optemplate import normal, Field + from grudge.optemplate import normal, Field dir_u = BoundarizeOperator(self.dirichlet_tag) * u dir_v = BoundarizeOperator(self.dirichlet_tag) * v @@ -162,7 +162,7 @@ class StrongWaveOperator(HyperbolicOperator): nabla = make_nabla(d) flux_op = get_flux_operator(self.flux()) - from hedge.tools import join_fields + from grudge.tools import join_fields result = ( - join_fields( -self.c*np.dot(nabla, v), @@ -181,7 +181,7 @@ class StrongWaveOperator(HyperbolicOperator): return result def bind(self, discr): - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.dirichlet_tag, self.neumann_tag, @@ -218,9 +218,9 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): def __init__( self, c, dimensions, source=0, flux_type="upwind", - dirichlet_tag=hedge.mesh.TAG_ALL, - neumann_tag=hedge.mesh.TAG_NONE, - radiation_tag=hedge.mesh.TAG_NONE, + dirichlet_tag=grudge.mesh.TAG_ALL, + neumann_tag=grudge.mesh.TAG_NONE, + radiation_tag=grudge.mesh.TAG_NONE, time_sign=1, diffusion_coeff=None, diffusion_scheme=CentralSecondDerivative() @@ -245,7 +245,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): # {{{ flux ---------------------------------------------------------------- def flux(self): - from hedge.flux import FluxVectorPlaceholder, make_normal + from grudge.flux import FluxVectorPlaceholder, make_normal dim = self.dimensions w = FluxVectorPlaceholder(2+dim) @@ -254,7 +254,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): v = w[2:] normal = make_normal(dim) - from hedge.tools import join_fields + from grudge.tools import join_fields flux = self.time_sign*1/2*join_fields( c.ext * np.dot(v.ext, normal) - c.int * np.dot(v.int, normal), @@ -276,7 +276,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): # }}} def bind_characteristic_velocity(self, discr): - from hedge.optemplate.operators import ElementwiseMaxOperator + from grudge.optemplate.operators import ElementwiseMaxOperator compiled = discr.compile(ElementwiseMaxOperator()(self.c)) @@ -286,7 +286,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): return do def op_template(self, with_sensor=False): - from hedge.optemplate import \ + from grudge.optemplate import \ Field, \ make_sym_vector, \ BoundaryPair, \ @@ -301,11 +301,11 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): u = w[0] v = w[1:] - from hedge.tools import join_fields + from grudge.tools import join_fields flux_w = join_fields(self.c, w) # {{{ boundary conditions - from hedge.tools import join_fields + from grudge.tools import join_fields # Dirichlet dir_c = BoundarizeOperator(self.dirichlet_tag) * self.c @@ -322,7 +322,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): neu_bc = join_fields(neu_c, neu_u, -neu_v) # Radiation - from hedge.optemplate import make_normal + from grudge.optemplate import make_normal rad_normal = make_normal(self.radiation_tag, d) rad_c = BoundarizeOperator(self.radiation_tag) * self.c @@ -351,7 +351,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): if with_sensor: diffusion_coeff += Field("sensor") - from hedge.second_order import SecondDerivativeTarget + from grudge.second_order import SecondDerivativeTarget # strong_form here allows the reuse the value of grad u. grad_tgt = SecondDerivativeTarget( @@ -396,7 +396,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): )) def bind(self, discr, sensor=None): - from hedge.mesh import check_bc_coverage + from grudge.mesh import check_bc_coverage check_bc_coverage(discr.mesh, [ self.dirichlet_tag, self.neumann_tag, @@ -415,7 +415,7 @@ class VariableVelocityStrongWaveOperator(HyperbolicOperator): return rhs def max_eigenvalue_expr(self): - import hedge.optemplate as sym + import grudge.optemplate as sym return sym.NodalMax()(sym.CFunction("fabs")(self.c)) # }}} diff --git a/grudge/symbolic/__init__.py b/grudge/symbolic/__init__.py index b2a58094e2360055a7c5cd258b30b0e7a67cace1..7ffc8db5f281009f3e0faf01f4fcba766706923b 100644 --- a/grudge/symbolic/__init__.py +++ b/grudge/symbolic/__init__.py @@ -26,7 +26,7 @@ THE SOFTWARE. """ -from hedge.optemplate.primitives import * # noqa -from hedge.optemplate.operators import * # noqa -from hedge.optemplate.mappers import * # noqa -from hedge.optemplate.tools import * # noqa +from grudge.optemplate.primitives import * # noqa +from grudge.optemplate.operators import * # noqa +from grudge.optemplate.mappers import * # noqa +from grudge.optemplate.tools import * # noqa diff --git a/grudge/symbolic/compiler.py b/grudge/symbolic/compiler.py index 56734a1a81345b8bd15c79b065af27fc0070cbbb..76486064e31fa628c1f7d4c4d945a3149a5625c9 100644 --- a/grudge/symbolic/compiler.py +++ b/grudge/symbolic/compiler.py @@ -31,7 +31,7 @@ THE SOFTWARE. from pytools import Record, memoize_method -from hedge.optemplate import IdentityMapper +from grudge.optemplate import IdentityMapper # {{{ instructions @@ -76,7 +76,7 @@ class Assign(Instruction): @memoize_method def flop_count(self): - from hedge.optemplate import FlopCounter + from grudge.optemplate import FlopCounter return sum(FlopCounter()(expr) for expr in self.exprs) def get_assignees(self): @@ -138,14 +138,14 @@ class FluxBatchAssign(Instruction): :ivar names: :ivar expressions: - A list of :class:`hedge.optemplate.primitives.OperatorBinding` + A list of :class:`grudge.optemplate.primitives.OperatorBinding` instances bound to flux operators. .. note :: All operators in :attr:`expressions` are guaranteed to yield the same operator from - :meth:`hedge.optemplate.operators.FluxOperatorBase.repr_op`. + :meth:`grudge.optemplate.operators.FluxOperatorBase.repr_op`. :ivar repr_op: The `repr_op` on which all operators agree. """ @@ -154,9 +154,9 @@ class FluxBatchAssign(Instruction): return set(self.names) def __str__(self): - from hedge.flux import PrettyFluxStringifyMapper as PFSM + from grudge.flux import PrettyFluxStringifyMapper as PFSM flux_strifier = PFSM() - from hedge.optemplate import StringifyMapper as OSM + from grudge.optemplate import StringifyMapper as OSM op_strifier = OSM(flux_stringify_mapper=flux_strifier) from pymbolic.mapper.stringifier import PREC_NONE @@ -187,7 +187,7 @@ class DiffBatchAssign(Instruction): .. note :: All operators here are guaranteed to satisfy - :meth:`hedge.optemplate.operators.DiffOperatorBase. + :meth:`grudge.optemplate.operators.DiffOperatorBase. equal_except_for_axis`. :ivar field: @@ -318,7 +318,7 @@ def dot_dataflow_graph(code, max_node_label_length=30, for dep in insn.get_dependencies(): gen_expr_arrow(dep, node_names[insn]) - from hedge.tools import is_obj_array + from grudge.tools import is_obj_array if is_obj_array(code.result): for subexp in code.result: @@ -341,7 +341,7 @@ class Code(object): self.static_schedule_attempts = 5 def dump_dataflow_graph(self): - from hedge.tools import open_unique_debug_file + from grudge.tools import open_unique_debug_file open_unique_debug_file("dataflow", ".dot")\ .write(dot_dataflow_graph(self, max_node_label_length=None)) @@ -377,9 +377,9 @@ class Code(object): if insn not in done_insns)) # {{{ make sure results do not get discarded - from hedge.tools import with_object_array_or_scalar + from grudge.tools import with_object_array_or_scalar - from hedge.optemplate.mappers import DependencyMapper + from grudge.optemplate.mappers import DependencyMapper dm = DependencyMapper(composite_leaves=False) def remove_result_variable(result_expr): @@ -482,7 +482,7 @@ class Code(object): if self.static_schedule_attempts: self.last_schedule = schedule - from hedge.tools import with_object_array_or_scalar + from grudge.tools import with_object_array_or_scalar return with_object_array_or_scalar(exec_mapper, self.result) # }}} @@ -539,7 +539,7 @@ class Code(object): self.last_schedule = None self.static_schedule_attempts -= 1 - from hedge.tools import with_object_array_or_scalar + from grudge.tools import with_object_array_or_scalar return with_object_array_or_scalar(exec_mapper, self.result) # }}} @@ -569,7 +569,7 @@ class OperatorCompilerBase(IdentityMapper): @memoize_method def dep_mapper_factory(self, include_subscripts=False): - from hedge.optemplate import DependencyMapper + from grudge.optemplate import DependencyMapper self.dep_mapper = DependencyMapper( include_operator_bindings=False, include_subscripts=include_subscripts, @@ -588,12 +588,12 @@ class OperatorCompilerBase(IdentityMapper): raise NotImplementedError def collect_diff_ops(self, expr): - from hedge.optemplate.operators import ReferenceDiffOperatorBase - from hedge.optemplate.mappers import BoundOperatorCollector + from grudge.optemplate.operators import ReferenceDiffOperatorBase + from grudge.optemplate.mappers import BoundOperatorCollector return BoundOperatorCollector(ReferenceDiffOperatorBase)(expr) def collect_flux_exchange_ops(self, expr): - from hedge.optemplate.mappers import FluxExchangeCollector + from grudge.optemplate.mappers import FluxExchangeCollector return FluxExchangeCollector()(expr) # }}} @@ -601,10 +601,10 @@ class OperatorCompilerBase(IdentityMapper): # {{{ top-level driver ---------------------------------------------------- def __call__(self, expr, type_hints={}): # Put the result expressions into variables as well. - from hedge.optemplate import make_common_subexpression as cse + from grudge.optemplate import make_common_subexpression as cse expr = cse(expr, "_result") - from hedge.optemplate.mappers.type_inference import TypeInferrer + from grudge.optemplate.mappers.type_inference import TypeInferrer self.typedict = TypeInferrer()(expr, type_hints) # {{{ flux batching @@ -699,7 +699,7 @@ class OperatorCompilerBase(IdentityMapper): from pymbolic.primitives import Variable, Subscript # Observe that the only things that can be legally subscripted in - # hedge are variables. All other expressions are broken down into + # grudge are variables. All other expressions are broken down into # their scalar components. if isinstance(expr, (Variable, Subscript)): return expr @@ -720,10 +720,10 @@ class OperatorCompilerBase(IdentityMapper): except KeyError: priority = getattr(expr, "priority", 0) - from hedge.optemplate.mappers.type_inference import type_info + from grudge.optemplate.mappers.type_inference import type_info is_scalar_valued = isinstance(self.typedict[expr], type_info.Scalar) - from hedge.optemplate import OperatorBinding + from grudge.optemplate import OperatorBinding if isinstance(expr.child, OperatorBinding): # We need to catch operator bindings here and # treat them specially. They get assigned to their @@ -743,7 +743,7 @@ class OperatorCompilerBase(IdentityMapper): return cse_var def map_operator_binding(self, expr, name_hint=None): - from hedge.optemplate.operators import ( + from grudge.optemplate.operators import ( ReferenceDiffOperatorBase, FluxOperatorBase) @@ -780,7 +780,7 @@ class OperatorCompilerBase(IdentityMapper): return self.assign_to_new_var(expr, prefix="normal%d" % expr.axis) def map_call(self, expr): - from hedge.optemplate.primitives import CFunction + from grudge.optemplate.primitives import CFunction if isinstance(expr.function, CFunction): return IdentityMapper.map_call(self, expr) else: @@ -807,7 +807,7 @@ class OperatorCompilerBase(IdentityMapper): from pytools import single_valued op_class = single_valued(type(d.op) for d in all_diffs) - from hedge.optemplate.operators import \ + from grudge.optemplate.operators import \ ReferenceQuadratureStiffnessTOperator if isinstance(op_class, ReferenceQuadratureStiffnessTOperator): assign_class = QuadratureDiffBatchAssign @@ -833,7 +833,7 @@ class OperatorCompilerBase(IdentityMapper): try: return self.expr_to_var[expr] except KeyError: - from hedge.tools import is_field_equal + from grudge.tools import is_field_equal all_flux_xchgs = [fe for fe in self.flux_exchange_ops if is_field_equal(fe.arg_fields, expr.arg_fields)] @@ -969,7 +969,7 @@ class OperatorCompilerBase(IdentityMapper): # filter out zero assignments from pytools import any - from hedge.tools import is_zero + from grudge.tools import is_zero i = 0 @@ -1044,7 +1044,7 @@ class OperatorCompilerBase(IdentityMapper): for insn in processed_assigns + other_insns for expr in insn.get_dependencies()) - from hedge.tools import is_obj_array + from grudge.tools import is_obj_array if is_obj_array(result): externally_used_names |= set(expr for expr in result) else: diff --git a/grudge/symbolic/operators.py b/grudge/symbolic/operators.py index e67a80e7a51a1480c1c4e9057d308e9ec7389063..6bac9fbbf44f9624c708d717ada679881e0a9cc8 100644 --- a/grudge/symbolic/operators.py +++ b/grudge/symbolic/operators.py @@ -36,29 +36,29 @@ from pytools import Record, memoize_method class Operator(pymbolic.primitives.Leaf): def stringifier(self): - from hedge.optemplate import StringifyMapper + from grudge.optemplate import StringifyMapper return StringifyMapper def __call__(self, expr): from pytools.obj_array import with_object_array_or_scalar - from hedge.tools import is_zero + from grudge.tools import is_zero def bind_one(subexpr): if is_zero(subexpr): return subexpr else: - from hedge.optemplate.primitives import OperatorBinding + from grudge.optemplate.primitives import OperatorBinding return OperatorBinding(self, subexpr) return with_object_array_or_scalar(bind_one, expr) @memoize_method def bind(self, discr): - from hedge.optemplate import Field + from grudge.optemplate import Field bound_op = discr.compile(self(Field("f"))) def apply_op(field): - from hedge.tools import with_object_array_or_scalar + from grudge.tools import with_object_array_or_scalar return with_object_array_or_scalar(lambda f: bound_op(f=f), field) return apply_op @@ -152,10 +152,10 @@ class QuadratureStiffnessTOperator(DiffOperatorBase): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`StiffnessTOperator` is applied to a quadrature field, and then eliminated by - :class:`hedge.optemplate.mappers.GlobalToReferenceMapper` + :class:`grudge.optemplate.mappers.GlobalToReferenceMapper` in favor of operators on the reference element. """ @@ -170,7 +170,7 @@ class QuadratureStiffnessTOperator(DiffOperatorBase): def DiffOperatorVector(els): - from hedge.tools import join_fields + from grudge.tools import join_fields return join_fields(*els) # }}} @@ -217,7 +217,7 @@ class ReferenceQuadratureStiffnessTOperator(ReferenceDiffOperatorBase): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`StiffnessTOperator` is applied to a quadrature field. """ @@ -297,7 +297,7 @@ class QuadratureBoundaryGridUpsampler(Operator): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`MassOperator` is applied to a quadrature field. """ def __init__(self, quadrature_tag, boundary_tag): @@ -336,7 +336,7 @@ class FilterOperator(ElementwiseLinearOperator): # build filter matrix vdm = ldis.vandermonde() - from hedge.tools import leftsolve + from grudge.tools import leftsolve mat = np.asarray( leftsolve(vdm, np.dot(vdm, np.diag(filter_coeffs))), @@ -420,10 +420,10 @@ class QuadratureMassOperator(Operator): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`StiffnessTOperator` is applied to a quadrature field, and then eliminated by - :class:`hedge.optemplate.mappers.GlobalToReferenceMapper` + :class:`grudge.optemplate.mappers.GlobalToReferenceMapper` in favor of operators on the reference element. """ @@ -441,7 +441,7 @@ class ReferenceQuadratureMassOperator(Operator): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`MassOperator` is applied to a quadrature field. """ @@ -547,7 +547,7 @@ class FluxOperatorBase(Operator): # override to suppress apply-operator-to-each-operand # behavior from superclass - from hedge.optemplate.primitives import OperatorBinding + from grudge.optemplate.primitives import OperatorBinding return OperatorBinding(self, arg) def __mul__(self, arg): @@ -578,7 +578,7 @@ class BoundaryFluxOperator(BoundaryFluxOperatorBase): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`FluxOperator` is applied to a boundary field. """ def __init__(self, flux, boundary_tag, is_lift=False): @@ -596,7 +596,7 @@ class QuadratureFluxOperator(QuadratureFluxOperatorBase): .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`FluxOperator` is applied to a quadrature field. """ @@ -617,7 +617,7 @@ class QuadratureBoundaryFluxOperator( .. note:: This operator is purely for internal use. It is inserted - by :class:`hedge.optemplate.mappers.OperatorSpecializer` + by :class:`grudge.optemplate.mappers.OperatorSpecializer` when a :class:`FluxOperator` is applied to a quadrature boundary field. """ @@ -643,7 +643,7 @@ class VectorFluxOperator(object): if isinstance(arg, int) and arg == 0: return 0 from pytools.obj_array import make_obj_array - from hedge.optemplate.primitives import OperatorBinding + from grudge.optemplate.primitives import OperatorBinding return make_obj_array( [OperatorBinding(FluxOperator(f), arg) @@ -682,7 +682,7 @@ class WholeDomainFluxOperator(pymbolic.primitives.AlgebraicLeaf): @property @memoize_method def dependencies(self): - from hedge.optemplate.tools import get_flux_dependencies + from grudge.optemplate.tools import get_flux_dependencies return set(get_flux_dependencies( self.flux_expr, self.field_expr)) @@ -692,20 +692,20 @@ class WholeDomainFluxOperator(pymbolic.primitives.AlgebraicLeaf): @property @memoize_method def int_dependencies(self): - from hedge.optemplate.tools import get_flux_dependencies + from grudge.optemplate.tools import get_flux_dependencies return set(get_flux_dependencies( self.flux_expr, self.bpair, bdry="int")) @property @memoize_method def ext_dependencies(self): - from hedge.optemplate.tools import get_flux_dependencies + from grudge.optemplate.tools import get_flux_dependencies return set(get_flux_dependencies( self.flux_expr, self.bpair, bdry="ext")) def __init__(self, is_lift, interiors, boundaries, quadrature_tag): - from hedge.optemplate.tools import get_flux_dependencies + from grudge.optemplate.tools import get_flux_dependencies self.is_lift = is_lift @@ -733,7 +733,7 @@ class WholeDomainFluxOperator(pymbolic.primitives.AlgebraicLeaf): self.dep_to_tag[dep] = bflux.bpair.tag def stringifier(self): - from hedge.optemplate import StringifyMapper + from grudge.optemplate import StringifyMapper return StringifyMapper def repr_op(self): diff --git a/grudge/symbolic/primitives.py b/grudge/symbolic/primitives.py index 221f8e6c03d6e552461d5940c0e95b3bb5635218..aba3c746ba6ac91a70cf1a83bc348203e20827a0 100644 --- a/grudge/symbolic/primitives.py +++ b/grudge/symbolic/primitives.py @@ -29,7 +29,7 @@ THE SOFTWARE. import numpy import pymbolic.primitives -import hedge.mesh +import grudge.mesh from pymbolic.primitives import ( # noqa make_common_subexpression, If, Comparison) @@ -39,7 +39,7 @@ from pytools import MovedFunctionDeprecationWrapper class LeafBase(pymbolic.primitives.AlgebraicLeaf): def stringifier(self): - from hedge.optemplate import StringifyMapper + from grudge.optemplate import StringifyMapper return StringifyMapper @@ -62,7 +62,7 @@ class ScalarParameter(pymbolic.primitives.Variable): """A placeholder for a user-supplied scalar variable.""" def stringifier(self): - from hedge.optemplate import StringifyMapper + from grudge.optemplate import StringifyMapper return StringifyMapper mapper_method = intern("map_scalar_parameter") @@ -73,7 +73,7 @@ class CFunction(pymbolic.primitives.Variable): argument of :class:`pymbolic.primitives.Call`. """ def stringifier(self): - from hedge.optemplate import StringifyMapper + from grudge.optemplate import StringifyMapper return StringifyMapper def __call__(self, expr): @@ -101,13 +101,13 @@ class OperatorBinding(LeafBase): return self.op, self.field def is_equal(self, other): - from hedge.tools import field_equal + from grudge.tools import field_equal return (other.__class__ == self.__class__ and other.op == self.op and field_equal(other.field, self.field)) def get_hash(self): - from hedge.tools import hashable_field + from grudge.tools import hashable_field return hash((self.__class__, self.op, hashable_field(self.field))) @@ -136,7 +136,7 @@ class BoundaryPair(LeafBase): application of boundary fluxes. """ - def __init__(self, field, bfield, tag=hedge.mesh.TAG_ALL): + def __init__(self, field, bfield, tag=grudge.mesh.TAG_ALL): self.field = field self.bfield = bfield self.tag = tag @@ -147,7 +147,7 @@ class BoundaryPair(LeafBase): return (self.field, self.bfield, self.tag) def get_hash(self): - from hedge.tools import hashable_field + from grudge.tools import hashable_field return hash((self.__class__, hashable_field(self.field), @@ -155,7 +155,7 @@ class BoundaryPair(LeafBase): self.tag)) def is_equal(self, other): - from hedge.tools import field_equal + from grudge.tools import field_equal return (self.__class__ == other.__class__ and field_equal(other.field, self.field) and field_equal(other.bfield, self.bfield) diff --git a/grudge/symbolic/tools.py b/grudge/symbolic/tools.py index 3599a74efb5f137aa76c04f95628a7ce3c051b64..6ba7289f4d948557a6ca2c4971f1e1a892854c33 100644 --- a/grudge/symbolic/tools.py +++ b/grudge/symbolic/tools.py @@ -39,8 +39,8 @@ def get_flux_operator(flux): or with a :class:`BoundaryPair` to obtain the lifted boundary flux. """ - from hedge.tools import is_obj_array - from hedge.optemplate import VectorFluxOperator, FluxOperator + from grudge.tools import is_obj_array + from grudge.optemplate import VectorFluxOperator, FluxOperator if is_obj_array(flux): return VectorFluxOperator(flux) @@ -49,35 +49,35 @@ def get_flux_operator(flux): def make_nabla(dim): - from hedge.tools import make_obj_array - from hedge.optemplate import DifferentiationOperator + from grudge.tools import make_obj_array + from grudge.optemplate import DifferentiationOperator return make_obj_array( [DifferentiationOperator(i) for i in range(dim)]) def make_minv_stiffness_t(dim): - from hedge.tools import make_obj_array - from hedge.optemplate import MInvSTOperator + from grudge.tools import make_obj_array + from grudge.optemplate import MInvSTOperator return make_obj_array( [MInvSTOperator(i) for i in range(dim)]) def make_stiffness(dim): - from hedge.tools import make_obj_array - from hedge.optemplate import StiffnessOperator + from grudge.tools import make_obj_array + from grudge.optemplate import StiffnessOperator return make_obj_array( [StiffnessOperator(i) for i in range(dim)]) def make_stiffness_t(dim): - from hedge.tools import make_obj_array - from hedge.optemplate import StiffnessTOperator + from grudge.tools import make_obj_array + from grudge.optemplate import StiffnessTOperator return make_obj_array( [StiffnessTOperator(i) for i in range(dim)]) def integral(arg): - import hedge.optemplate as sym + import grudge.optemplate as sym return sym.NodalSum()(sym.MassOperator()(sym.Ones())*arg) @@ -85,7 +85,7 @@ def norm(p, arg): """ :arg arg: is assumed to be a vector, i.e. have shape ``(n,)``. """ - import hedge.optemplate as sym + import grudge.optemplate as sym if p == 2: comp_norm_squared = sym.NodalSum()( @@ -103,7 +103,7 @@ def norm(p, arg): def flat_end_sin(x): - from hedge.optemplate.primitives import CFunction + from grudge.optemplate.primitives import CFunction from pymbolic.primitives import IfPositive from math import pi return IfPositive(-pi/2-x, @@ -121,12 +121,12 @@ def smooth_ifpos(crit, right, left, width): # {{{ optemplate tools def is_scalar(expr): - from hedge.optemplate import ScalarParameter + from grudge.optemplate import ScalarParameter return isinstance(expr, (int, float, complex, ScalarParameter)) def get_flux_dependencies(flux, field, bdry="all"): - from hedge.flux import FluxDependencyMapper, FieldComponent + from grudge.flux import FluxDependencyMapper, FieldComponent in_fields = list(FluxDependencyMapper( include_calls=False)(flux)) @@ -136,14 +136,14 @@ def get_flux_dependencies(flux, field, bdry="all"): if not isinstance(in_field, FieldComponent)] def maybe_index(fld, index): - from hedge.tools import is_obj_array + from grudge.tools import is_obj_array if is_obj_array(fld): return fld[inf.index] else: return fld - from hedge.tools import is_zero - from hedge.optemplate import BoundaryPair + from grudge.tools import is_zero + from grudge.optemplate import BoundaryPair if isinstance(field, BoundaryPair): for inf in in_fields: if inf.is_interior: @@ -188,7 +188,7 @@ def split_optemplate_for_multirate(state_vector, op_template, killers.append(IndexGroupKillerSubstMap(kill_set)) - from hedge.optemplate import \ + from grudge.optemplate import \ SubstitutionMapper, \ CommutativeConstantFoldingMapper @@ -252,12 +252,12 @@ def process_optemplate(optemplate, post_bind_mapper=None, dumper=lambda name, optemplate: None, mesh=None, type_hints={}): - from hedge.optemplate.mappers import ( + from grudge.optemplate.mappers import ( OperatorBinder, CommutativeConstantFoldingMapper, EmptyFluxKiller, InverseMassContractor, DerivativeJoiner, ErrorChecker, OperatorSpecializer, GlobalToReferenceMapper) - from hedge.optemplate.mappers.bc_to_flux import BCToFluxRewriter - from hedge.optemplate.mappers.type_inference import TypeInferrer + from grudge.optemplate.mappers.bc_to_flux import BCToFluxRewriter + from grudge.optemplate.mappers.type_inference import TypeInferrer dumper("before-bind", optemplate) optemplate = OperatorBinder()(optemplate) @@ -327,7 +327,7 @@ def process_optemplate(optemplate, post_bind_mapper=None, # {{{ pretty printing def pretty(optemplate): - from hedge.optemplate.mappers import PrettyStringifyMapper + from grudge.optemplate.mappers import PrettyStringifyMapper stringify_mapper = PrettyStringifyMapper() from pymbolic.mapper.stringifier import PREC_NONE