Skip to content

Commit

Permalink
FDM solver for the de Rham complex (#2801)
Browse files Browse the repository at this point in the history
Sparse FDM preconditioner for the de Rham complex

* add FDM tests for H(curl) and H(div)
* test statically-condensed star-relaxation
* deterministic sort keys of point_dicts

---------

Co-authored-by: David A. Ham <[email protected]>
  • Loading branch information
pbrubeck and dham authored May 11, 2023
1 parent a015738 commit dd12455
Show file tree
Hide file tree
Showing 12 changed files with 2,565 additions and 972 deletions.
1 change: 0 additions & 1 deletion firedrake/matrix_free/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ def view(self, mat, viewer=None):
type(self).__name__)

def getInfo(self, mat, info=None):
from mpi4py import MPI
memory = self._x.dat.nbytes + self._y.dat.nbytes
if hasattr(self, "_xbc"):
memory += self._xbc.dat.nbytes
Expand Down
1,915 changes: 1,511 additions & 404 deletions firedrake/preconditioners/fdm.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions firedrake/preconditioners/gtmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(self, pc):
if ctx is None:
raise ValueError("No context found.")
if not isinstance(ctx, _SNESContext):
raise ValueError("Don't know how to get form from %r", ctx)
raise ValueError("Don't know how to get form from %r" % ctx)

prefix = pc.getOptionsPrefix()
options_prefix = prefix + self._prefix
Expand All @@ -41,7 +41,7 @@ def initialize(self, pc):
if ictx is None:
raise ValueError("No context found on matrix")
if not isinstance(ictx, ImplicitMatrixContext):
raise ValueError("Don't know how to get form from %r", ictx)
raise ValueError("Don't know how to get form from %r" % ictx)

fine_operator = ictx.a
fine_bcs = ictx.row_bcs
Expand Down Expand Up @@ -70,7 +70,7 @@ def initialize(self, pc):
fine_petscmat.setTransposeNullSpace(fine_transpose_nullspace)

# Handle the coarse operator
coarse_options_prefix = options_prefix + "mg_coarse"
coarse_options_prefix = options_prefix + "mg_coarse_"
coarse_mat_type = opts.getString(coarse_options_prefix + "mat_type",
parameters["default_matrix_type"])

Expand Down
2 changes: 1 addition & 1 deletion firedrake/preconditioners/hiptmair.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def coarsen(self, pc):
if G_callback is None:
interp_petscmat = chop(Interpolator(dminus(test), V, bcs=bcs + coarse_space_bcs).callable().handle)
else:
interp_petscmat = G_callback(V, coarse_space, bcs, coarse_space_bcs)
interp_petscmat = G_callback(coarse_space, V, coarse_space_bcs, bcs)

return coarse_operator, coarse_space_bcs, interp_petscmat

Expand Down
4 changes: 2 additions & 2 deletions firedrake/preconditioners/hypre_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def initialize(self, obj):
if G_callback is None:
G = chop(Interpolator(grad(TestFunction(P1)), NC1).callable().handle)
else:
G = G_callback(NC1, P1)
G = G_callback(P1, NC1)
C_callback = appctx.get("get_curl", None)
if C_callback is None:
C = chop(Interpolator(curl(TestFunction(NC1)), V).callable().handle)
else:
C = C_callback(V, NC1)
C = C_callback(NC1, V)

pc = PETSc.PC().create(comm=obj.comm)
pc.incrementTabLevel(1, parent=obj)
Expand Down
2 changes: 1 addition & 1 deletion firedrake/preconditioners/hypre_ams.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def initialize(self, obj):
if G_callback is None:
G = chop(Interpolator(grad(TestFunction(P1)), V).callable().handle)
else:
G = G_callback(V, P1)
G = G_callback(P1, V)

pc = PETSc.PC().create(comm=obj.comm)
pc.incrementTabLevel(1, parent=obj)
Expand Down
4 changes: 2 additions & 2 deletions firedrake/preconditioners/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,14 @@ def initialize(self, obj):
if ctx is None:
raise ValueError("No context found on form")
if not isinstance(ctx, _SNESContext):
raise ValueError("Don't know how to get form from %r", ctx)
raise ValueError("Don't know how to get form from %r" % ctx)

if P.getType() == "python":
ictx = P.getPythonContext()
if ictx is None:
raise ValueError("No context found on matrix")
if not isinstance(ictx, ImplicitMatrixContext):
raise ValueError("Don't know how to get form from %r", ictx)
raise ValueError("Don't know how to get form from %r" % ictx)
J = ictx.a
bcs = ictx.row_bcs
if bcs != ictx.col_bcs:
Expand Down
Loading

0 comments on commit dd12455

Please sign in to comment.