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
17 changes: 8 additions & 9 deletions firedrake/preconditioners/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,12 @@ def get_patches(self, V):
assert mesh.extruded

base_dm = mesh._base_mesh.topology_dm
section = V._base_mesh_section
# Obtain the codimensions to loop over from options, if present
opts = PETSc.Options(self.prefix)
codim_list = list(map(int, opts.getString("codims", "0, 1").split(",")))

if len(V) > 1:
raise NotImplementedError("Not implemeneted for mixed spaces")
# A patch of a mixed space joins the columns of every subspace.
sections = [Vi._base_mesh_section for Vi in V]
V_local_ises_indices = get_local_ises_indices(V)

# Build index sets for the patches
Expand All @@ -337,13 +336,13 @@ def get_patches(self, V):
if base_dm.getLabelValue("firedrake_is_ghost", base_p) != -1:
continue

dof = section.getDof(base_p)
if dof <= 0:
continue
off = section.getOffset(base_p)

indices = V_local_ises_indices[0][off:off+dof]
indices = numpy.concatenate([
local_indices[section.getOffset(base_p):section.getOffset(base_p) + section.getDof(base_p)]
for section, local_indices in zip(sections, V_local_ises_indices)
])
indices = indices[indices >= 0]
if len(indices) == 0:
continue
iset = PETSc.IS().createGeneral(indices, comm=PETSc.COMM_SELF)
ises.append(iset)

Expand Down
32 changes: 32 additions & 0 deletions tests/firedrake/regression/test_linesmoother.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,35 @@ def test_linesmoother(mesh, S1family, expected, backend, rhs):
solver.solve()
nits.append(solver.snes.ksp.getIterationNumber())
assert nits == expected


@pytest.mark.parametrize("backend", ["petscasm", "tinyasm"])
def test_linesmoother_mixed_space_solves_column_operator(backend):
"""On a mixed space, each column patch holds the degrees of freedom of every subspace.

The operator couples only the cells of a column and the two subspaces in
each cell, so the line smoother inverts it exactly.
"""
mesh = ExtrudedMesh(UnitSquareMesh(3, 3, quadrilateral=True), 4)
Q = FunctionSpace(mesh, "DQ", 0)
W = Q * Q
p, r = TrialFunctions(W)
q, s = TestFunctions(W)
n = FacetNormal(mesh)
a = (inner(p, q) + inner(r, s) + inner(p, s) + 2 * inner(r, q)) * dx \
+ (inner(jump(p, n), jump(q, n)) + inner(jump(r, n), jump(s, n))) * dS_h
x = SpatialCoordinate(mesh)
L = (inner(x[0] * x[2], q) + inner(x[1], s)) * dx
w = Function(W)
solver = LinearVariationalSolver(LinearVariationalProblem(a, L, w), solver_parameters={
"mat_type": "aij",
"ksp_type": "richardson",
"ksp_rtol": 1E-12,
"pc_type": "python",
"pc_python_type": "firedrake.ASMLinesmoothPC",
"pc_linesmooth_codims": "0",
"pc_linesmooth_backend": backend,
"pc_linesmooth_sub_pc_type": "lu",
})
solver.solve()
assert solver.snes.ksp.getIterationNumber() == 1
Loading