-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2744 from tjhei/nonlinear_fail_strategy
Nonlinear solver: deal with failure
- Loading branch information
Showing
106 changed files
with
1,236 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
include/aspect/time_stepping/repeat_on_nonlinear_fail.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
Copyright (C) 2018 - 2023 by the authors of the ASPECT code. | ||
This file is part of ASPECT. | ||
ASPECT is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2, or (at your option) | ||
any later version. | ||
ASPECT is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with ASPECT; see the file LICENSE. If not see | ||
<http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#ifndef _aspect_time_stepping_repeat_on_nonlinear_fail_h | ||
#define _aspect_time_stepping_repeat_on_nonlinear_fail_h | ||
|
||
#include <aspect/time_stepping/interface.h> | ||
|
||
namespace aspect | ||
{ | ||
namespace TimeStepping | ||
{ | ||
using namespace dealii; | ||
|
||
/** | ||
* A class that implements a time stepping plugin to repeat a time step if the | ||
* nonlinear solver failed to converge in the specified number of iterations. | ||
* The timestep size will be reduced by the given amount specified by the user | ||
* and hopefully results in the nonlinear solver converging. If necessary, the | ||
* timestep size will be repeatedly reduced. | ||
* | ||
* This class is automatically enabled if the user specifies that he/she wants | ||
* to do this. | ||
* | ||
* @ingroup TimeStepping | ||
*/ | ||
template <int dim> | ||
class RepeatOnNonlinearFail : public Interface<dim>, public SimulatorAccess<dim> | ||
{ | ||
public: | ||
/** | ||
* Constructor. | ||
*/ | ||
RepeatOnNonlinearFail (); | ||
|
||
/** | ||
* @copydoc aspect::TimeStepping::Interface<dim>::execute() | ||
*/ | ||
double | ||
execute() override; | ||
|
||
/** | ||
* This function notifies the plugin that the nonlinear solver | ||
* failed. | ||
*/ | ||
void nonlinear_solver_has_failed() const; | ||
|
||
/** | ||
* The main execute() function. | ||
*/ | ||
std::pair<Reaction, double> | ||
determine_reaction(const TimeStepInfo &info) override; | ||
|
||
static | ||
void | ||
declare_parameters (ParameterHandler &prm); | ||
|
||
void | ||
parse_parameters (ParameterHandler &prm) override; | ||
|
||
private: | ||
/** | ||
* Parameter to determine how much smaller the time step should be | ||
* repeated as. | ||
*/ | ||
double cut_back_factor; | ||
|
||
/** | ||
* Enabled by nonlinear_solver_has_failed() to signal that this | ||
* plugin needs to act in the current timestep; | ||
*/ | ||
mutable bool nonlinear_solver_just_failed; | ||
|
||
/** | ||
* How many times should we try cutting the timestep size before giving up? | ||
*/ | ||
unsigned int maximum_number_of_repeats; | ||
|
||
/** | ||
* How many times have we been repeating already in this timestep? | ||
*/ | ||
unsigned int current_number_of_repeats; | ||
}; | ||
} | ||
} | ||
|
||
|
||
#endif |
Oops, something went wrong.