Skip to content
Snippets Groups Projects
Commit fc99884a authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Fix weak advection example for flake8

parent adcd20ca
No related branches found
No related tags found
No related merge requests found
...@@ -32,15 +32,12 @@ from grudge import sym, bind, DGDiscretizationWithBoundaries ...@@ -32,15 +32,12 @@ from grudge import sym, bind, DGDiscretizationWithBoundaries
import numpy.linalg as la import numpy.linalg as la
def main(write_output=True, order=4): def main(write_output=True, order=4):
cl_ctx = cl.create_some_context() cl_ctx = cl.create_some_context()
queue = cl.CommandQueue(cl_ctx) queue = cl.CommandQueue(cl_ctx)
dim = 2 dim = 2
from meshmode.mesh.generation import generate_regular_rect_mesh from meshmode.mesh.generation import generate_regular_rect_mesh
mesh = generate_regular_rect_mesh(a=(-0.5, -0.5), b=(0.5, 0.5), mesh = generate_regular_rect_mesh(a=(-0.5, -0.5), b=(0.5, 0.5),
n=(20, 20), order=order) n=(20, 20), order=order)
...@@ -50,12 +47,10 @@ def main(write_output=True, order=4): ...@@ -50,12 +47,10 @@ def main(write_output=True, order=4):
discr = DGDiscretizationWithBoundaries(cl_ctx, mesh, order=order) discr = DGDiscretizationWithBoundaries(cl_ctx, mesh, order=order)
c = np.array([0.1,0.1]) c = np.array([0.1, 0.1])
norm_c = la.norm(c) norm_c = la.norm(c)
flux_type = "central" flux_type = "central"
def f(x): def f(x):
return sym.sin(3*x) return sym.sin(3*x)
...@@ -64,8 +59,7 @@ def main(write_output=True, order=4): ...@@ -64,8 +59,7 @@ def main(write_output=True, order=4):
return f(-np.dot(c, x)/norm_c+sym.var("t", sym.DD_SCALAR)*norm_c) return f(-np.dot(c, x)/norm_c+sym.var("t", sym.DD_SCALAR)*norm_c)
from grudge.models.advection import WeakAdvectionOperator from grudge.models.advection import WeakAdvectionOperator
from meshmode.mesh import BTAG_ALL, BTAG_NONE
discr = DGDiscretizationWithBoundaries(cl_ctx, mesh, order=order) discr = DGDiscretizationWithBoundaries(cl_ctx, mesh, order=order)
op = WeakAdvectionOperator(c, op = WeakAdvectionOperator(c,
inflow_u=u_analytic(sym.nodes(dim, sym.BTAG_ALL)), inflow_u=u_analytic(sym.nodes(dim, sym.BTAG_ALL)),
...@@ -84,19 +78,14 @@ def main(write_output=True, order=4): ...@@ -84,19 +78,14 @@ def main(write_output=True, order=4):
nsteps = (final_time // dt) + 1 nsteps = (final_time // dt) + 1
dt = final_time/nsteps + 1e-15 dt = final_time/nsteps + 1e-15
from grudge.shortcuts import set_up_rk4 from grudge.shortcuts import set_up_rk4
dt_stepper = set_up_rk4("u", dt, u, rhs) dt_stepper = set_up_rk4("u", dt, u, rhs)
last_u = None
from grudge.shortcuts import make_visualizer from grudge.shortcuts import make_visualizer
vis = make_visualizer(discr, vis_order=order) vis = make_visualizer(discr, vis_order=order)
step = 0 step = 0
norm = bind(discr, sym.norm(2, sym.var("u")))
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): if isinstance(event, dt_stepper.StateComputed):
...@@ -104,15 +93,8 @@ def main(write_output=True, order=4): ...@@ -104,15 +93,8 @@ def main(write_output=True, order=4):
#print(step, event.t, norm(queue, u=event.state_component[0])) #print(step, event.t, norm(queue, u=event.state_component[0]))
vis.write_vtk_file("fld-weak-%04d.vtu" % step, vis.write_vtk_file("fld-weak-%04d.vtu" % step,
[ ("u", event.state_component) ]) [("u", event.state_component)])
if __name__ == "__main__": if __name__ == "__main__":
main() main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment