Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Feb 6, 2025
1 parent eb796b6 commit 29ace44
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions firedrake/solving_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ def __init__(self, problem, mat_type, pmat_type, appctx=None,
# Drop existing lifting term from the residual
assert isinstance(self.F, ufl.BaseForm)
self.F = ufl.replace(self.F, {self._x: ufl.zero(self._x.ufl_shape)})

A = self.J
if isinstance(A, MatrixBase) and A.has_bcs:
A = A.a
Expand Down Expand Up @@ -325,7 +324,7 @@ def set_nullspace(self, nullspace, ises=None, transpose=False, near=False):

@PETSc.Log.EventDecorator()
def split(self, fields):
from firedrake import replace, as_vector, split
from firedrake import replace, as_vector, split, zero
from firedrake import NonlinearVariationalProblem as NLVP
from firedrake.bcs import DirichletBC, EquationBC
fields = tuple(tuple(f) for f in fields)
Expand Down Expand Up @@ -381,10 +380,13 @@ def split(self, fields):
# coefficients in the new form.
u = as_vector(vec)
J = replace(J, {problem.u_restrict: u})
if problem.is_linear:
# Drop existing lifting term from the residual
F = replace(F, {problem.u_restrict: ufl.zero(problem.u_restrict.ufl_shape)})
F = F - action(J, subu)
if problem.is_linear and isinstance(J, MatrixBase):
# The lifting term contains action(MatrixBase, u).
# We cannot replace u with the split solution, as action expects a Function.
# We drop the existing lifting term from the residual
# and compute the correct split term for a complelty decoupled RHS.
F = replace(F, {problem.u_restrict: zero(problem.u_restrict.ufl_shape)})
F += action(J, subu)
else:
F = replace(F, {problem.u_restrict: u})
if problem.Jp is not None:
Expand Down

0 comments on commit 29ace44

Please sign in to comment.