Skip to content

Commit

Permalink
Propagate the min_inner_iter to the config files and picard iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
sblauth committed Oct 26, 2023
1 parent 345fc5b commit c6efb40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cashocs/_pde_problems/state_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
self.newton_atol = self.config.getfloat("StateSystem", "newton_atol")
self.newton_damped = self.config.getboolean("StateSystem", "newton_damped")
self.newton_inexact = self.config.getboolean("StateSystem", "newton_inexact")
self.min_inner_iter = self.config.getint("StateSystem", "min_inner_iter")
self.newton_verbose = self.config.getboolean("StateSystem", "newton_verbose")
self.newton_iter = self.config.getint("StateSystem", "newton_iter")

Expand Down Expand Up @@ -149,6 +150,7 @@ def solve(self) -> List[fenics.Function]:
A_tensor=self.A_tensors[i],
b_tensor=self.b_tensors[i],
preconditioner_form=self.db.form_db.preconditioner_forms[i],
min_inner_iter=self.min_inner_iter,
)

else:
Expand Down
4 changes: 4 additions & 0 deletions cashocs/io/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def __init__(self, config_file: Optional[str] = None) -> None:
"newton_inexact": {
"type": "bool",
},
"min_inner_iter": {
"type": "int",
},
"newton_verbose": {
"type": "bool",
},
Expand Down Expand Up @@ -542,6 +545,7 @@ def __init__(self, config_file: Optional[str] = None) -> None:
newton_iter = 50
newton_damped = False
newton_inexact = False
min_inner_iter = 0
newton_verbose = False
picard_iteration = False
picard_rtol = 1e-10
Expand Down
8 changes: 6 additions & 2 deletions cashocs/nonlinear_solvers/picard_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def picard_iteration(
b_tensors: Optional[List[fenics.PETScVector]] = None,
inner_is_linear: bool = False,
preconditioner_forms: Optional[Union[List[ufl.Form], ufl.Form]] = None,
min_inner_iter: int = 0,
) -> None:
"""Solves a system of coupled PDEs via a Picard iteration.
Expand Down Expand Up @@ -122,8 +123,10 @@ def picard_iteration(
inner_is_linear: Boolean flag, if this is ``True``, all problems are actually
linear ones, and only a linear solver is used.
preconditioner_forms: The list of forms for the preconditioner. The default
is `None`, so that the preconditioner matrix is the same as the system
matrix.
is `None`, so that the preconditioner matrix is the same as the system
matrix.
min_inner_iter: Minimum iterations the inner (linear) solver should perform
regardless of termination criteria.
"""
is_printing = verbose and fenics.MPI.rank(fenics.MPI.comm_world) == 0
Expand Down Expand Up @@ -188,6 +191,7 @@ def picard_iteration(
b_tensor=b_tensor,
is_linear=inner_is_linear,
preconditioner_form=preconditioner_form_list[j],
min_inner_iter=min_inner_iter,
)

if is_printing:
Expand Down

0 comments on commit c6efb40

Please sign in to comment.