Skip to content

Commit fcc68c5

Browse files
authored
Change zeroing of residuals for non-wind terms (#662)
1 parent c7e0dcc commit fcc68c5

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

gusto/timestepping/semi_implicit_quasi_newton.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,13 @@ def timestep(self):
538538
with timed_stage("Apply forcing terms"):
539539
logger.info(f'Semi-implicit Quasi Newton: Implicit forcing {(outer, inner)}')
540540
self.forcing.apply(xp, xnp1, xrhs, "implicit")
541+
xrhs += xrhs_phys
542+
541543
if (inner > 0 and self.accelerator):
542544
# Zero implicit forcing to accelerate solver convergence
543-
self.forcing.zero_forcing_terms(self.equation, xnp1, xrhs, self.equation.field_names)
545+
self.forcing.zero_non_wind_terms(self.equation, xnp1, xrhs, self.equation.field_names)
544546

545547
xrhs -= xnp1(self.field_name)
546-
xrhs += xrhs_phys
547548

548549
# Linear solve -------------------------------------------------
549550
with timed_stage("Implicit solve"):
@@ -738,7 +739,7 @@ def apply(self, x_in, x_nl, x_out, label):
738739
x_out.assign(x_in(self.field_name))
739740
x_out += self.xF
740741

741-
def zero_forcing_terms(self, equation, x_in, x_out, field_names):
742+
def zero_non_wind_terms(self, equation, x_in, x_out, field_names):
742743
"""
743744
Zero forcing term F(x) for non-wind prognostics.
744745

gusto/timestepping/tr_bdf2_quasi_newton.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ def timestep(self):
365365
with timed_stage("Apply forcing terms"):
366366
logger.info(f'TR-BDF2 Quasi Newton: TR Implicit forcing {(outer, inner)}')
367367
self.tr_forcing.apply(xp, xm, xrhs, "implicit")
368+
xrhs += xrhs_phys
368369
if inner > 0:
369370
# Zero implicit forcing to accelerate solver convergence
370-
self.tr_forcing.zero_forcing_terms(self.equation, xm, xrhs, self.equation.field_names)
371+
self.tr_forcing.zero_non_wind_terms(self.equation, xm, xrhs, self.equation.field_names)
371372

372373
xrhs -= xm(self.field_name)
373-
xrhs += xrhs_phys
374374

375375
# Linear solve -------------------------------------------------
376376

@@ -429,12 +429,12 @@ def timestep(self):
429429
with timed_stage("Apply forcing terms"):
430430
logger.info(f'TR-BDF2 Quasi Newton: BDF Implicit forcing {(outer, inner)}')
431431
self.bdf_forcing.apply(xp, xnp1, xrhs, "implicit")
432+
xrhs += xrhs_phys
432433
if inner > 0:
433434
# Zero implicit forcing to accelerate solver convergence
434-
self.bdf_forcing.zero_forcing_terms(self.equation, xnp1, xrhs, self.equation.field_names)
435+
self.bdf_forcing.zero_non_wind_terms(self.equation, xnp1, xrhs, self.equation.field_names)
435436

436437
xrhs -= xnp1(self.field_name)
437-
xrhs += xrhs_phys
438438

439439
# Linear solve -------------------------------------------------
440440
with timed_stage("Implicit solve"):

0 commit comments

Comments
 (0)