diff --git a/unported-examples/advection/var-velocity.py b/examples/advection/var-velocity.py similarity index 94% rename from unported-examples/advection/var-velocity.py rename to examples/advection/var-velocity.py index 00e4f0c8496dced20a21e808e68986ecec1d5be2..bc720731a820fd063fda36657218315174f3c5f3 100644 --- a/unported-examples/advection/var-velocity.py +++ b/examples/advection/var-velocity.py @@ -40,6 +40,9 @@ from grudge import sym, bind, DGDiscretizationWithBoundaries from pytools.obj_array import join_fields +FINAL_TIME = 5 + + def main(write_output=True, order=4): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) @@ -105,10 +108,9 @@ def main(write_output=True, order=4): def rhs(t, u): return bound_op(queue, t=t, u=u) - final_time = 50 dt = dt_factor * h/order**2 - nsteps = (final_time // dt) + 1 - dt = final_time/nsteps + 1e-15 + nsteps = (FINAL_TIME // dt) + 1 + dt = FINAL_TIME/nsteps + 1e-15 from grudge.shortcuts import set_up_rk4 dt_stepper = set_up_rk4("u", dt, u, rhs) @@ -118,14 +120,14 @@ def main(write_output=True, order=4): step = 0 - for event in dt_stepper.run(t_end=final_time): + for event in dt_stepper.run(t_end=FINAL_TIME): if isinstance(event, dt_stepper.StateComputed): step += 1 if step % 30 == 0: print(step) - vis.write_vtk_file("fld-%04d.vtu" % step, + vis.write_vtk_file("fld-var-velocity-%04d.vtu" % step, [("u", event.state_component)]) diff --git a/unported-examples/advection/weak.py b/examples/advection/weak.py similarity index 98% rename from unported-examples/advection/weak.py rename to examples/advection/weak.py index cdadb49e79e85c08a611f856c54970bf3c417b12..bd9d61ca3e2bbfd416a271ffbbabca22f366e3fd 100644 --- a/unported-examples/advection/weak.py +++ b/examples/advection/weak.py @@ -103,7 +103,7 @@ def main(write_output=True, order=4): step += 1 #print(step, event.t, norm(queue, u=event.state_component[0])) - vis.write_vtk_file("fld-%04d.vtu" % step, + vis.write_vtk_file("fld-weak-%04d.vtu" % step, [ ("u", event.state_component) ]) diff --git a/examples/dagrt_fusion/fusion-study.py b/examples/dagrt-fusion.py similarity index 100% rename from examples/dagrt_fusion/fusion-study.py rename to examples/dagrt-fusion.py diff --git a/unported-examples/geometry.py b/examples/geometry.py similarity index 92% rename from unported-examples/geometry.py rename to examples/geometry.py index e10254bfb9b10323b61c150dd5f9105a2525df79..6e146f21dd31545b392d8006d45d94bed7a9db02 100644 --- a/unported-examples/geometry.py +++ b/examples/geometry.py @@ -26,7 +26,7 @@ THE SOFTWARE. import numpy as np # noqa import pyopencl as cl -from grudge import sym, bind, Discretization, shortcuts +from grudge import sym, bind, DGDiscretizationWithBoundaries, shortcuts def main(write_output=True): @@ -36,14 +36,14 @@ def main(write_output=True): from meshmode.mesh.generation import generate_warped_rect_mesh mesh = generate_warped_rect_mesh(dim=2, order=4, n=6) - discr = Discretization(cl_ctx, mesh, order=4) + discr = DGDiscretizationWithBoundaries(cl_ctx, mesh, order=4) sym_op = sym.normal(sym.BTAG_ALL, mesh.dim) #sym_op = sym.nodes(mesh.dim, where=sym.BTAG_ALL) print(sym.pretty(sym_op)) op = bind(discr, sym_op) print() - print(op.code) + print(op.eval_code) vec = op(queue) diff --git a/unported-examples/maxwell/cavities.py b/examples/maxwell/cavities.py similarity index 92% rename from unported-examples/maxwell/cavities.py rename to examples/maxwell/cavities.py index 85a7c3dec0cef99b4a72fe9c23439c4212c0c32d..a58f27399ccfb6e32a16d6cf594ed2a3c78076b2 100644 --- a/unported-examples/maxwell/cavities.py +++ b/examples/maxwell/cavities.py @@ -28,11 +28,14 @@ THE SOFTWARE. import numpy as np import pyopencl as cl from grudge.shortcuts import set_up_rk4 -from grudge import sym, bind, Discretization +from grudge import sym, bind, DGDiscretizationWithBoundaries from grudge.models.em import get_rectangular_cavity_mode +STEPS = 60 + + def main(dims, write_output=True, order=4): cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) @@ -43,7 +46,7 @@ def main(dims, write_output=True, order=4): b=(1.0,)*dims, n=(5,)*dims) - discr = Discretization(cl_ctx, mesh, order=order) + discr = DGDiscretizationWithBoundaries(cl_ctx, mesh, order=order) if 0: epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) @@ -84,7 +87,7 @@ def main(dims, write_output=True, order=4): dt_stepper = set_up_rk4("w", dt, fields, rhs) - final_t = dt * 600 + final_t = dt * STEPS nsteps = int(final_t/dt) print("dt=%g nsteps=%d" % (dt, nsteps)) @@ -102,7 +105,7 @@ def main(dims, write_output=True, order=4): e, h = op.split_eh(fields) if 1: - vis.write_vtk_file("fld-%04d.vtu" % step, + vis.write_vtk_file("fld-cavities-%04d.vtu" % step, [ ("e", e), ("h", h), @@ -119,7 +122,7 @@ def main(dims, write_output=True, order=4): time()-t_last_step) if step % 10 == 0: e, h = op.split_eh(event.state_component) - vis.write_vtk_file("fld-%04d.vtu" % step, + vis.write_vtk_file("fld-cavities-%04d.vtu" % step, [ ("e", e), ("h", h),