Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
86eb874
Give NonlinearVariationalProblem and nullspace bases a reconstruct() …
pbrubeck Aug 4, 2026
d593d1f
Rework PMGBase.coarsen() to use NonlinearVariationalProblem.reconstru…
pbrubeck Aug 4, 2026
6151e18
Use native FiniteElement.reconstruct(degree=...) instead of PMGBase.r…
pbrubeck Aug 4, 2026
2688acc
DROP BEFORE MERGE: point CI at unmerged fiat branch
pbrubeck Aug 3, 2026
0b17ec3
review suggestions
pbrubeck Aug 4, 2026
0ffce79
Apply suggestion from @pbrubeck
pbrubeck Aug 4, 2026
38df85f
Add type hints and numpydoc to reconstruct()-family methods
pbrubeck Aug 4, 2026
cf56671
Fix PMG coarsening of residuals containing Cofunctions
pbrubeck Aug 4, 2026
162c5d1
Use ZeroBaseForm as the PC-only coarse residual placeholder
pbrubeck Aug 4, 2026
0f0beb4
DROP BEFORE MERGE: point CI at unmerged ufl branch
pbrubeck Aug 4, 2026
696ad5f
Apply suggestion from @pbrubeck
pbrubeck Aug 5, 2026
11f0adc
Apply suggestions from code review
pbrubeck Aug 5, 2026
f7ff628
review suggestions
pbrubeck Aug 4, 2026
2c811e8
Apply suggestion from @pbrubeck
pbrubeck Aug 4, 2026
9e88825
Add type hints and numpydoc to reconstruct()-family methods
pbrubeck Aug 4, 2026
660c1e3
Fix PMG coarsening of residuals containing Cofunctions
pbrubeck Aug 4, 2026
043c2bc
Use ZeroBaseForm as the PC-only coarse residual placeholder
pbrubeck Aug 4, 2026
a69809f
DROP BEFORE MERGE: point CI at unmerged fiat branch
pbrubeck Aug 5, 2026
172662d
DROP BEFORE MERGE: point CI at unmerged ufl branch
pbrubeck Aug 5, 2026
11eb4a2
drop comment
pbrubeck Aug 5, 2026
b23fe02
Restore pyproject.toml to main
pbrubeck Aug 5, 2026
e07c9b4
drop function_space kwarg
pbrubeck Aug 5, 2026
2c26e19
Merge branch 'main' into pbrubeck/pmg-reconstruct-rework
pbrubeck Aug 5, 2026
16fd8a1
Apply suggestion from @pbrubeck
pbrubeck Aug 5, 2026
4323c50
Apply suggestion from @pbrubeck
pbrubeck Aug 5, 2026
ed1a955
lint
pbrubeck Aug 5, 2026
880fc8c
rediscretise
pbrubeck Aug 5, 2026
5c3acc0
Apply suggestions from code review
pbrubeck Aug 5, 2026
7fd3338
fix
pbrubeck Aug 5, 2026
83b5017
fix
pbrubeck Aug 5, 2026
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
2 changes: 1 addition & 1 deletion firedrake/mg/ufl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def coarsen_callback(fine, coarse):
F = self(problem.F, self, coefficient_mapping=coefficient_mapping)
J = self(problem.J, self, coefficient_mapping=coefficient_mapping)
Jp = self(problem.Jp, self, coefficient_mapping=coefficient_mapping)
u = coefficient_mapping[problem.u_restrict]
u = self(problem.u_restrict, self, coefficient_mapping=coefficient_mapping)

new_problem = firedrake.NonlinearVariationalProblem(
F, u, bcs=bcs, J=J, Jp=Jp, objective=E, is_linear=problem.is_linear,
Expand Down
42 changes: 42 additions & 0 deletions firedrake/nullspace.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from __future__ import annotations

import numpy

from pyop2.mpi import COMM_WORLD

import firedrake
from firedrake import function
from firedrake.logging import warning
from firedrake.matrix import MatrixBase
Expand Down Expand Up @@ -97,6 +100,24 @@ def orthonormalize(self):
self.check_orthogonality()
self._ad_orthogonalized = True

def rediscretise(self, function_space: firedrake.functionspaceimpl.WithGeometryBase) -> VectorSpaceBasis:
r"""Reconstruct this basis on a new function space.

Parameters
----------
function_space
the new :class:`~.FunctionSpace`.

Returns
-------
VectorSpaceBasis
The basis vectors interpolated onto `function_space` and re-orthonormalized.
"""
vecs = [function.Function(function_space).interpolate(vec) for vec in self._vecs]
new_basis = VectorSpaceBasis(vecs, constant=self._constant, comm=self.comm)
new_basis.orthonormalize()
return new_basis

@PETSc.Log.EventDecorator()
def orthogonalize(self, b):
r"""Orthogonalize ``b`` with respect to this :class:`.VectorSpaceBasis`.
Expand Down Expand Up @@ -239,6 +260,27 @@ def __init__(self, function_space, bases):
self._bases = bases
self._nullspace = None

def rediscretise(self, function_space: firedrake.functionspaceimpl.WithGeometryBase) -> MixedVectorSpaceBasis:
r"""Reconstruct this basis on a new mixed function space.

Parameters
----------
function_space
the new :class:`~.FunctionSpace`.

Returns
-------
MixedVectorSpaceBasis
The bases reconstructed on the sub-spaces of `function_space`.
"""
bases = []
for V_, basis in zip(function_space, self._bases):
if isinstance(basis, VectorSpaceBasis):
bases.append(basis.rediscretise(V_))
else:
bases.append(function_space.sub(basis.index))
return MixedVectorSpaceBasis(function_space, bases)

def _build_monolithic_basis(self):
r"""Build a basis for the complete mixed space.

Expand Down
6 changes: 3 additions & 3 deletions firedrake/preconditioners/low_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class P1PC(PMGPC):
def coarsen_element(self, ele):
if super().max_degree(ele) <= self.coarse_degree:
raise ValueError
return super().reconstruct_degree(ele, self.coarse_degree)
return ele.reconstruct(degree=self.coarse_degree)


class P1SNES(PMGSNES):
"""A two-level nonlinear solver with agressive p-coarsening."""
def coarsen_element(self, ele):
if super().max_degree(ele) <= self.coarse_degree:
raise ValueError
return super().reconstruct_degree(ele, self.coarse_degree)
return ele.reconstruct(degree=self.coarse_degree)


class LORPC(PMGPC):
Expand All @@ -33,6 +33,6 @@ def coarsen_element(self, ele):
iso_variant = f"iso({degree})"
else:
iso_variant = f"{variant},iso({degree})"
cele = super().reconstruct_degree(ele, self.coarse_degree)
cele = ele.reconstruct(degree=self.coarse_degree)
cele = cele.reconstruct(variant=iso_variant)
return cele
Loading
Loading