Skip to content

Commit

Permalink
Clean up constants for BC
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottMacLachlan committed Nov 18, 2024
1 parent 26d5135 commit 99659a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 8 additions & 6 deletions irksome/dirk_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def getFormDIRK(F, ks, butch, t, dt, u0, bcs=None):
new_bc = bc.reconstruct(g=gdat)
bcnew.append(new_bc)

return stage_F, (k, g, a, c, a_vals, d_val), bcnew
return stage_F, (k, g, a, c), bcnew, (a_vals, d_val)


class DIRKTimeStepper:
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(self, F, butcher_tableau, t, dt, u0, bcs=None,
# that we update as we go. We need to remember the
# stage values we've computed earlier in the time step...

stage_F, (k, g, a, c, a_vals, d_val), bcnew = getFormDIRK(
stage_F, (k, g, a, c), bcnew, (a_vals, d_val) = getFormDIRK(
F, self.ks, butcher_tableau, t, dt, u0, bcs=bcs)

self.bcnew = bcnew
Expand All @@ -128,11 +128,13 @@ def __init__(self, F, butcher_tableau, t, dt, u0, bcs=None,
self.problem, appctx=appctx, solver_parameters=solver_parameters,
nullspace=nullspace)

self.kgac = k, g, a, c, a_vals, d_val
self.kgac = k, g, a, c
self.bc_constants = a_vals, d_val

def update_bc_constants(self, i, a_vals, d_val, c):
def update_bc_constants(self, i, c):
AAb = self.AAb
CCone = self.CCone
a_vals, d_val = self.bc_constants
ns = AAb.shape[1]
for j in range(i):
a_vals[j].assign(AAb[i, j])
Expand All @@ -142,7 +144,7 @@ def update_bc_constants(self, i, a_vals, d_val, c):
c.assign(CCone[i])

def advance(self):
k, g, a, c, a_vals, d_val = self.kgac
k, g, a, c = self.kgac
ks = self.ks
u0 = self.u0
dtc = float(self.dt)
Expand All @@ -160,7 +162,7 @@ def advance(self):
gbit += dtc * float(AA[i, j]) * kbit

# update BC constants for the variational problem
self.update_bc_constants(i, a_vals, d_val, c)
self.update_bc_constants(i, c)
a.assign(AA[i, i])

# solve new variational problem, stash the computed
Expand Down
5 changes: 4 additions & 1 deletion irksome/explicit_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def __init__(self, F, butcher_tableau, t, dt, u0, bcs=None,
# we should impose the BCs so that they are satisfied for the next
# stage for all but that last stage, and that they are satisfied
# for the next timestep for the last stage.
def update_bc_constants(self, AAb, CCone, i, a_vals, d_val, c):
def update_bc_constants(self, i, c):
AAb = self.AAb
CCone = self.CCone
a_vals, d_val = self.bc_constants
ns = AAb.shape[1]
for j in range(i):
a_vals[j].assign(AAb[i+1, j])
Expand Down

0 comments on commit 99659a5

Please sign in to comment.