Skip to content

Commit

Permalink
First stab at DIRK without dat's. Not working for systems...
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottMacLachlan committed Oct 14, 2022
1 parent e20648f commit 3c58bac
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions irksome/dirk_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ def __init__(self):
pass

def __call__(self, u):
return u.dat.data_ro
return u


class BCCompOfNotMixedThingy:
def __init__(self, comp):
self.comp = comp

def __call__(self, u):
return u.dat.data_ro[:, self.comp]
return u[self.comp]


class BCMixedBitThingy:
def __init__(self, sub):
self.sub = sub

def __call__(self, u):
return u.dat[self.sub].data_ro
return u.sub(self.sub)


class BCCompOfMixedBitThingy:
Expand All @@ -39,7 +39,7 @@ def __init__(self, sub, comp):
self.comp = comp

def __call__(self, u):
return u.dat[self.sub].data_ro[:, self.comp]
return u.sub(self.sub)[self.comp]


def getThingy(V, bc):
Expand Down Expand Up @@ -182,6 +182,7 @@ def advance(self):
AA = bt.A
CC = bt.c
BB = bt.b
gsplit = g.split()
for i in range(self.num_stages):
# update a, c constants tucked into the variational problem
# for the current stage
Expand All @@ -191,8 +192,9 @@ def advance(self):
# variational form
g.assign(u0)
for j in range(i):
for (gd, kd) in zip(g.dat, ks[j].dat):
gd.data[:] += dtc * AA[i, j] * kd.data_ro[:]
ksplit = ks[j].split()
for (gbit, kbit) in zip(gsplit, ksplit):
gbit += dtc * float(AA[i, j]) * kbit

# update BC's for the variational problem
for (bc, (gdat, gcur, gmethod, dat4bc)) in zip(self.bcnew, self.gblah):
Expand All @@ -201,14 +203,14 @@ def advance(self):

# Now modify gdat based on the evolving solution
# subtract u0 from gdat
gdat.dat.data[:] -= dat4bc(u0)[:]
gdat -= dat4bc(u0)

# Subtract previous stage values
for j in range(i):
gdat.dat.data[:] -= dtc * AA[i, j] * dat4bc(ks[j])[:]
gdat -= dtc * float(AA[i, j]) * dat4bc(ks[j])

# Rescale gdat
gdat.dat.data[:] /= dtc * AA[i, i]
gdat /= dtc * float(AA[i, i])

# solve new variational problem, stash the computed
# stage value.
Expand All @@ -223,5 +225,5 @@ def advance(self):

# update the solution with now-computed stage values.
for i in range(self.num_stages):
for (u0d, kd) in zip(u0.dat, ks[i].dat):
u0d.data[:] += dtc * BB[i] * kd.data_ro[:]
for (u0bit, kbit) in zip(u0.split(), ks[i].split()):
u0bit += dtc * float(BB[i]) * kbit

0 comments on commit 3c58bac

Please sign in to comment.