Skip to content

Commit 07a287b

Browse files
committed
Hook up the GMRES restart option (and make setting it optional).
1 parent 823d921 commit 07a287b

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

femtools/Solvers.F90

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ recursive subroutine setup_ksp_from_options(ksp, mat, pmat, solver_option_path,
15781578
KSPType ksptype
15791579
PC pc
15801580
PetscReal rtol, atol, dtol
1581-
PetscInt max_its
1581+
PetscInt max_its, lrestart
15821582
PetscErrorCode ierr
15831583
PetscObject vf
15841584

@@ -1611,6 +1611,15 @@ recursive subroutine setup_ksp_from_options(ksp, mat, pmat, solver_option_path,
16111611
call KSPSetType(ksp, ksptype, ierr)
16121612
ewrite(2, *) 'ksp_type:', trim(ksptype)
16131613

1614+
if(trim(ksptype) == 'gmres') then
1615+
call get_option(trim(solver_option_path)//&
1616+
'/iterative_method::gmres/restart', lrestart, default=-1)
1617+
if (lrestart >= 0) then
1618+
call KSPGMRESSetRestart(ksp, lrestart, ierr)
1619+
ewrite(2, *) 'restart:', lrestart
1620+
end if
1621+
end if
1622+
16141623
! set max. iterations and tolerances:
16151624
! =======================================
16161625
call get_option(trim(solver_option_path)//'/relative_error', rtol)

schemas/solvers.rnc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ kspgmres_options =
113113
attribute name { "gmres" },
114114
## Restart value for gmres iteration
115115
## Higher values give better convergence but require more memory.
116-
## Suggested value: 30
116+
## Default value: 30
117117
element restart {
118118
integer
119-
}
119+
}?
120120
}
121121
)
122122

schemas/solvers.rng

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ Your safest bet for non-symmetric systems.</a:documentation>
110110
<attribute name="name">
111111
<value>gmres</value>
112112
</attribute>
113-
<element name="restart">
114-
<a:documentation>Restart value for gmres iteration
113+
<optional>
114+
<element name="restart">
115+
<a:documentation>Restart value for gmres iteration
115116
Higher values give better convergence but require more memory.
116-
Suggested value: 30</a:documentation>
117-
<ref name="integer"/>
118-
</element>
117+
Default value: 30</a:documentation>
118+
<ref name="integer"/>
119+
</element>
120+
</optional>
119121
</element>
120122
</define>
121123
<define name="kspcg_options">

0 commit comments

Comments
 (0)