Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions grudge/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@

from pytools import memoize_in

def euler_step(y, t, h, f):
return y + h*f(t, y)

def _euler_update(y, h, rhs_val):
return y + h*rhs_val


def compiled_euler_step(actx, y, t, h, f):
@memoize_in(actx, (compiled_euler_step, "update"))
def get_state_updater():
return actx.compile(_euler_update)

update = get_state_updater()

rhs_val = f(t, y)
y = update(y, h, rhs_val)
return y

def rk4_step(y, t, h, f):
k1 = f(t, y)
Expand Down