Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions firedrake/preconditioners/assembled.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class AssembledPC(PCBase):
_prefix = "assembled_"

def initialize(self, pc):
from firedrake.assemble import get_assembler
A, P = pc.getOperators()

if pc.type != "python":
Expand Down Expand Up @@ -45,7 +44,13 @@ def initialize(self, pc):

(a, bcs) = self.form(pc, test, trial)

form_assembler = get_assembler(a, bcs=bcs, form_compiler_parameters=fcp, mat_type=mat_type, options_prefix=options_prefix)
self._ctx_ref = self.new_snes_ctx(opc, a, bcs, mat_type,
fcp=fcp,
sub_mat_type=sub_mat_type,
options_prefix=options_prefix)

form_assembler = self._ctx_ref._assembler_jac

self.P = form_assembler.allocate()
self._assemble_P = form_assembler.assemble
self._assemble_P(tensor=self.P)
Expand All @@ -62,11 +67,6 @@ def initialize(self, pc):
# We set a DM and an appropriate SNESContext on the constructed PC so one
# can do e.g. multigrid or patch solves.
dm = opc.getDM()
self._ctx_ref = self.new_snes_ctx(opc, a, bcs, mat_type,
fcp=fcp,
sub_mat_type=sub_mat_type,
options_prefix=options_prefix)

pc.setDM(dm)
pc.setOptionsPrefix(options_prefix)
pc.setOperators(A, self.P.petscmat)
Expand Down
20 changes: 13 additions & 7 deletions firedrake/solving_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,21 @@ def __init__(self, problem,

def reconstruct(self, problem=None, mat_type=None, pmat_type=None, **kwargs):
"""Reconstruct this _SNESContext instance with new arguments."""
problem = problem or self.problem
problem = problem or self._problem
mat_type = mat_type or self.mat_type
pmat_type = pmat_type or self.pmat_type
kwargs.setdefault("sub_mat_type", self.sub_mat_type)
kwargs.setdefault("sub_pmat_type", self.sub_pmat_type)
kwargs.setdefault("appctx", self.appctx)
kwargs.setdefault("options_prefix", self.options_prefix)
kwargs.setdefault("transfer_manager", self.transfer_manager)
kwargs.setdefault("pre_apply_bcs", self.pre_apply_bcs)

default_options = {
"sub_mat_type": self.sub_mat_type,
"sub_pmat_type": self.sub_pmat_type,
"appctx": self.appctx,
"options_prefix": self.options_prefix,
"transfer_manager": self.transfer_manager,
"pre_apply_bcs": self.pre_apply_bcs,
}
for k, v in default_options.items():
if kwargs.get(k) is None:
kwargs[k] = v
return _SNESContext(problem, mat_type, pmat_type, **kwargs)

@property
Expand Down
Loading