Skip to content

Commit 7f96c64

Browse files
committed
Pseudo-Draft for Newton SDC controller
1 parent 7ed1c2b commit 7f96c64

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

pySDC/implementations/controller_classes/controller_nonMPI.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,54 @@ def default(self, local_MS_running):
687687
local_MS_running (list): list of currently running steps
688688
"""
689689
raise ControllerError('Unknown stage, got %s' % local_MS_running[0].status.stage) # TODO
690+
691+
692+
class NewtonSDC(controller_nonMPI):
693+
694+
def it_fine(self, local_MS_running: list[Step]):
695+
"""
696+
Fine sweeps
697+
698+
Args:
699+
local_MS_running (list): list of currently running steps
700+
"""
701+
702+
for S in local_MS_running:
703+
S.levels[0].status.sweep = 0
704+
705+
for k in range(self.nsweeps[0]):
706+
for S in local_MS_running:
707+
S.levels[0].status.sweep += 1
708+
709+
for S in local_MS_running:
710+
# send updated values forward
711+
self.send_full(S, level=0)
712+
# receive values
713+
self.recv_full(S, level=0, add_to_stats=(k == self.nsweeps[0] - 1))
714+
715+
for S in local_MS_running:
716+
# standard sweep workflow: update nodes, compute residual, log progress
717+
for hook in self.hooks:
718+
hook.pre_sweep(step=S, level_number=0)
719+
720+
SDC_maxiter = 5
721+
for j in SDC_maxiter:
722+
for level in S.levels:
723+
level.prob.update_jacobian(level.u[0])
724+
725+
S.levels[0].sweep.updateVariableCoeffs(
726+
j + 1
727+
) # update QDelta coefficients if variable preconditioner
728+
S.levels[0].sweep.update_nodes()
729+
730+
S.levels[0].prob.replace_jacobian_by_full_f()
731+
for i in range(len(S.levels[0].u) - 1):
732+
S.levels[0].f[i + 1] = S.levels[0].prob.eval_f(S.levels[0].u[i + 1], S.levels.t[i + 1])
733+
S.levels[0].sweep.compute_residual(stage='IT_FINE')
734+
735+
for hook in self.hooks:
736+
hook.post_sweep(step=S, level_number=0)
737+
738+
for S in local_MS_running:
739+
# update stage
740+
S.status.stage = 'IT_CHECK'

0 commit comments

Comments
 (0)