Skip to content

Commit

Permalink
Remove unused solver options
Browse files Browse the repository at this point in the history
  • Loading branch information
dham committed Dec 17, 2024
1 parent cc402aa commit cde10ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
33 changes: 23 additions & 10 deletions firedrake/cofunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def assign(self, expr, subset=None, expr_from_assemble=False):
raise ValueError('Cannot assign %s' % expr)

def riesz_representation(self, riesz_map='L2', *, bcs=None,
solver_options=None):
solver_parameters=None,
form_compiler_parameters=None):
"""Return the Riesz representation of this :class:`Cofunction`.
Example: For a L2 Riesz map, the Riesz representation is obtained by
Expand All @@ -245,8 +246,11 @@ def riesz_representation(self, riesz_map='L2', *, bcs=None,
callable.
bcs: DirichletBC or list of DirichletBC
Boundary conditions to apply to the Riesz map.
solver_options: dict
solver_parameters: dict
A dictionary of PETSc options to be passed to the solver.
form_compiler_parameters: dict
A dictionary of form compiler parameters to be passed to the
variational problem that solves for the Riesz map.
Returns
-------
Expand All @@ -255,8 +259,11 @@ def riesz_representation(self, riesz_map='L2', *, bcs=None,
the given Riesz map.
"""
if not callable(riesz_map):
riesz_map = RieszMap(self.function_space(), riesz_map, bcs=bcs,
solver_options=solver_options)
riesz_map = RieszMap(
self.function_space(), riesz_map, bcs=bcs,
solver_parameters=solver_parameters,
form_compiler_parameters=form_compiler_parameters
)

return riesz_map(self)

Expand Down Expand Up @@ -379,12 +386,16 @@ class RieszMap:
Used to determine the inner product.
bcs: DirichletBC or list of DirichletBC
Boundary conditions to apply to the Riesz map.
solver_options: dict
solver_parameters: dict
A dictionary of PETSc options to be passed to the solver.
form_compiler_parameters: dict
A dictionary of form compiler parameters to be passed to the
variational problem that solves for the Riesz map.
"""

def __init__(self, function_space_or_inner_product=None,
sobolev_space=ufl.L2, *, bcs=None, solver_options=None):
sobolev_space=ufl.L2, *, bcs=None, solver_parameters=None,
form_compiler_parameters=None):
if isinstance(function_space_or_inner_product, ufl.Form):
args = ufl.algorithms.extract_arguments(
function_space_or_inner_product
Expand Down Expand Up @@ -414,7 +425,8 @@ def __init__(self, function_space_or_inner_product=None,
self._function_space = function_space
self._inner_product = inner_product
self._bcs = bcs
self._solver_options = solver_options or {}
self._solver_parameters = solver_parameters or {}
self._form_compiler_parameters = form_compiler_parameters or {}

@staticmethod
def _inner_product_form(sobolev_space, u, v):
Expand All @@ -435,10 +447,11 @@ def _solver(self):
LinearVariationalProblem, Function, Cofunction)
rhs = Cofunction(self._function_space.dual())
soln = Function(self._function_space)
lvp = LinearVariationalProblem(self._inner_product, rhs, soln,
bcs=self._bcs)
lvp = LinearVariationalProblem(
self._inner_product, rhs, soln, bcs=self._bcs, restrict=True,
form_compiler_parameters=self._form_compiler_parameters)
solver = LinearVariationalSolver(
lvp, solver_parameters=self._solver_options
lvp, solver_parameters=self._solver_parameters
)
return solver.solve, rhs, soln

Expand Down
8 changes: 2 additions & 6 deletions firedrake/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,7 @@ def assign(self, expr, subset=None):
Assigner(self, expr, subset).assign()
return self

def riesz_representation(self, riesz_map='L2', bcs=None,
solver_options=None):
def riesz_representation(self, riesz_map='L2', bcs=None):
"""Return the Riesz representation of this :class:`Function`.
Example: For a L2 Riesz map, the Riesz representation is obtained by
Expand All @@ -494,8 +493,6 @@ def riesz_representation(self, riesz_map='L2', bcs=None,
callable which applies the Riesz map.
bcs: DirichletBC or list of DirichletBC
Boundary conditions to apply to the Riesz map.
solver_options: dict
A dictionary of PETSc options to be passed to the solver.
Returns
-------
Expand All @@ -504,8 +501,7 @@ def riesz_representation(self, riesz_map='L2', bcs=None,
given Riesz map.
"""
if not callable(riesz_map):
riesz_map = RieszMap(self.function_space(), riesz_map, bcs=bcs,
solver_options=solver_options)
riesz_map = RieszMap(self.function_space(), riesz_map, bcs=bcs)

return riesz_map(self)

Expand Down

0 comments on commit cde10ed

Please sign in to comment.