Skip to content

Commit 4e0a02a

Browse files
authored
Merge pull request geodynamics#2006 from MFraters/add_Newton_stabilisation_as_failsafe
Split newton stabilisation as options and add a failsafe
2 parents 430d2f1 + 8cc6994 commit 4e0a02a

File tree

10 files changed

+619
-231
lines changed

10 files changed

+619
-231
lines changed

include/aspect/newton.h

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,37 @@ namespace aspect
6161
* A Class which can declare and parse parameters and creates
6262
* material model outputs for the Newton solver.
6363
*/
64+
6465
template <int dim>
6566
class NewtonHandler: public SimulatorAccess<dim>
6667
{
6768
public:
69+
70+
/**
71+
* This enum describes the type of stabilization is used
72+
* for the Newton solver. None represents no stabilization,
73+
* SPD represent that the resulting matrix is made Symmetric
74+
* Positive Definite, symmetric represents that the matrix is
75+
* only symmetrized, and PD represents that we do the same as
76+
* what we do for SPD, but without the symmetrization.
77+
*/
78+
enum NewtonStabilization
79+
{
80+
none = 0,
81+
symmetric = 1,
82+
PD = 2,
83+
SPD = symmetric | PD
84+
};
85+
86+
friend
87+
NewtonStabilization
88+
operator| (const NewtonStabilization a,
89+
const NewtonStabilization b)
90+
{
91+
return static_cast<NewtonStabilization>(
92+
static_cast<int>(a) | static_cast<int>(b));
93+
}
94+
6895
/**
6996
* Determine, based on the run-time parameters of the current simulation,
7097
* which functions need to be called in order to assemble linear systems,
@@ -105,6 +132,76 @@ namespace aspect
105132
*/
106133
void set_newton_derivative_scaling_factor(const double newton_derivative_scaling_factor);
107134

135+
/**
136+
* Get the stabilization type used in the preconditioner.
137+
*/
138+
NewtonStabilization get_preconditioner_stabilization() const;
139+
140+
/**
141+
* Set the stabilization type used in the preconditioner.
142+
*/
143+
void set_preconditioner_stabilization(const NewtonStabilization preconditioner_stabilization);
144+
145+
/**
146+
* Get the stabilization type used in the velocity block.
147+
*/
148+
NewtonStabilization get_velocity_block_stabilization() const;
149+
150+
/**
151+
* Sets the stabilization type used in the velocity block.
152+
*/
153+
void set_velocity_block_stabilization(const NewtonStabilization velocity_block_stabilization);
154+
155+
/**
156+
* Get whether to use the Newton failsafe. If the failsafe is used, a failure
157+
* of the linear solver is catched and we try to solve it again with both the
158+
* preconditioner and the velocity block being stabilized with the SPD stabilization.
159+
*/
160+
bool get_use_Newton_failsafe();
161+
162+
/**
163+
* Get the nonlinear tolerance at which to switch the
164+
* nonlinear solver from defect correction Picard to
165+
* Newton.
166+
*/
167+
double get_nonlinear_switch_tolerance();
168+
169+
/**
170+
* Get the maximum number of pre-Newton nonlinear iterations.
171+
*/
172+
unsigned int get_max_pre_newton_nonlinear_iterations();
173+
174+
/**
175+
* Get the maximum number of line search iterations.
176+
*/
177+
unsigned int get_max_newton_line_search_iterations();
178+
179+
/**
180+
* Get whether to use the residual scaling method.
181+
*/
182+
bool get_use_newton_residual_scaling_method();
183+
184+
/**
185+
* Get the maximum linear Stokes solver tolerance.
186+
*/
187+
double get_maximum_linear_stokes_solver_tolerance();
188+
189+
/**
190+
* get a std::string describing the stabilization type used for the preconditioner.
191+
*/
192+
std::string get_newton_stabilization_string(const NewtonStabilization preconditioner_stabilization) const;
193+
194+
/**
195+
* Declare additional parameters that are needed for the Newton.
196+
* solver.
197+
*/
198+
static void declare_parameters (ParameterHandler &prm);
199+
200+
/**
201+
* Parse additional parameters that are needed for the Newton.
202+
* solver.
203+
*/
204+
void parse_parameters (ParameterHandler &prm);
108205

109206
private:
110207
/**
@@ -114,7 +211,15 @@ namespace aspect
114211
* See the get_newton_derivative_scaling_factor() function for an
115212
* explanation of the purpose of this factor.
116213
*/
117-
double newton_derivative_scaling_factor;
214+
double newton_derivative_scaling_factor;
215+
NewtonStabilization preconditioner_stabilization;
216+
NewtonStabilization velocity_block_stabilization;
217+
bool use_Newton_failsafe;
218+
double nonlinear_switch_tolerance;
219+
unsigned int max_pre_newton_nonlinear_iterations;
220+
unsigned int max_newton_line_search_iterations;
221+
bool use_newton_residual_scaling_method;
222+
double maximum_linear_stokes_solver_tolerance;
118223
};
119224

120225
namespace Assemblers

include/aspect/parameters.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,6 @@ namespace aspect
337337
double temperature_solver_tolerance;
338338
double composition_solver_tolerance;
339339
bool use_operator_splitting;
340-
unsigned int max_pre_newton_nonlinear_iterations;
341-
unsigned int max_newton_line_search_iterations;
342-
bool use_newton_residual_scaling_method;
343-
double maximum_linear_stokes_solver_tolerance;
344340

345341
/**
346342
* @}

0 commit comments

Comments
 (0)