GEOS
NonlinearSolverParameters.hpp
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
16 #ifndef GEOS_PHYSICSSOLVERS_NONLINEARSOLVERPARAMETERS_HPP_
17 #define GEOS_PHYSICSSOLVERS_NONLINEARSOLVERPARAMETERS_HPP_
18 
20 #include "dataRepository/Group.hpp"
22 
23 namespace geos
24 {
25 
30 {
31 public:
32 
37 
43  NonlinearSolverParameters( string const & name,
44  Group * const parent );
45 
49  virtual ~NonlinearSolverParameters() = default;
50 
56 
62  {
69 
70  m_newtonTol = params.m_newtonTol;
74 
77 
88 
89  setLogLevel( params.getLogLevel());
90 
91  return *this;
92  }
93 
101  static string catalogName() { return "NonlinearSolverParameters"; }
102 
103  virtual void postInputInitialization() override;
104 
105  void print() const;
106 
108  {
109  static constexpr char const * lineSearchActionString() { return "lineSearchAction"; }
110  static constexpr char const * lineSearchMaxCutsString() { return "lineSearchMaxCuts"; }
111  static constexpr char const * lineSearchCutFactorString() { return "lineSearchCutFactor"; }
112  static constexpr char const * lineSearchInterpolationTypeString() { return "lineSearchInterpolationType"; }
113  static constexpr char const * lineSearchStartingIterationString() { return "lineSearchStartingIteration"; }
114  static constexpr char const * lineSearchResidualFactorString() { return "lineSearchResidualFactor"; }
115 
116  static constexpr char const * normTypeString() { return "normType"; }
117  static constexpr char const * minNormalizerString() { return "minNormalizer"; }
118  static constexpr char const * newtonTolString() { return "newtonTol"; }
119  static constexpr char const * newtonMaxIterString() { return "newtonMaxIter"; }
120  static constexpr char const * newtonMinIterString() { return "newtonMinIter"; }
121  static constexpr char const * newtonNumIterationsString() { return "newtonNumberOfIterations"; }
122  static constexpr char const * newtonSplitOperMaxIterString() { return "newtonSplitOperMaxIter"; }
123 
124  static constexpr char const * allowNonConvergedString() { return "allowNonConverged"; }
125  static constexpr char const * timeStepDecreaseIterLimString() { return "timeStepDecreaseIterLimit"; }
126  static constexpr char const * timeStepIncreaseIterLimString() { return "timeStepIncreaseIterLimit"; }
127  static constexpr char const * timeStepDecreaseFactorString() { return "timeStepDecreaseFactor"; }
128  static constexpr char const * timeStepIncreaseFactorString() { return "timeStepIncreaseFactor"; }
129  static constexpr char const * minTimeStepIncreaseIntervalString() { return "minTimeStepIncreaseInterval"; }
130 
131  static constexpr char const * maxSubStepsString() { return "maxSubSteps"; }
132  static constexpr char const * maxTimeStepCutsString() { return "maxTimeStepCuts"; }
133  static constexpr char const * timeStepCutFactorString() { return "timeStepCutFactor"; }
134  static constexpr char const * maxAllowedResidualNormString() { return "maxAllowedResidualNorm"; }
135 
136  static constexpr char const * maxNumConfigurationAttemptsString() { return "maxNumConfigurationAttempts"; }
137  static constexpr char const * configurationToleranceString() { return "configurationTolerance"; }
138 
139  static constexpr char const * couplingTypeString() { return "couplingType"; }
140  static constexpr char const * sequentialConvergenceCriterionString() { return "sequentialConvergenceCriterion"; }
141  static constexpr char const * subcyclingOptionString() { return "subcycling"; }
142  static constexpr char const * nonlinearAccelerationTypeString() { return "nonlinearAccelerationType"; }
143  } viewKeys;
144 
149  {
150  None,
151  Attempt,
152  Require,
153  };
154 
159  {
160  Linear,
161  Parabolic,
162  };
163 
167  enum class CouplingType : integer
168  {
169  FullyImplicit,
170  Sequential
171  };
172 
177  {
178  ResidualNorm,
181  };
182 
187  {
188  None,
189  Aitken
190  };
191 
198  {
199  return std::ceil( m_timeStepDecreaseIterLimit * m_maxIterNewton );
200  }
201 
202 
209  {
210  return std::ceil( m_timeStepIncreaseIterLimit * m_maxIterNewton );
211  }
212 
218  {
220  }
221 
227  {
229  }
230 
236  {
238  }
239 
245  {
246  return m_normType;
247  }
248 
254  {
255  return m_couplingType;
256  }
257 
263  {
265  }
266 
269 
272 
275 
278 
281 
284 
287 
290 
293 
296 
299 
302 
305 
308 
311 
314 
317 
320 
323 
326 
329 
332 
335 
338 
341 
344 
347 
350 
353 
356 };
357 
359  "None",
360  "Attempt",
361  "Require" );
362 
364  "Linear",
365  "Parabolic" );
366 
368  "FullyImplicit",
369  "Sequential" );
370 
372  "ResidualNorm",
373  "NumberOfNonlinearIterations",
374  "SolutionIncrements" );
375 
377  "None",
378  "Aitken" );
379 
380 } /* namespace geos */
381 
382 #endif /* GEOS_PHYSICSSOLVERS_NONLINEARSOLVERPARAMETERS_HPP_ */
NormType
Type of norm used to check convergence TODO: find a way to put this inside the class.
LineSearchInterpolationType m_lineSearchInterpType
Flag to pick the type of line search.
integer m_numConfigurationAttempts
Number of times that the configuration had to be changed.
SequentialConvergenceCriterion sequentialConvergenceCriterion() const
Getter for the sequential convergence criterion.
integer m_allowNonConverged
Flag to allow for a non-converged nonlinear solution and continue with the problem.
real64 timeStepDecreaseFactor() const
Getter for the factor used to decrease the time step size.
real64 m_newtonTol
The tolerance for the nonlinear convergence check.
NonlinearAccelerationType
Nonlinear acceleration type.
integer timeStepIncreaseIterLimit() const
Calculates the lower limit for the number of iterations to force an increase to the next time step.
real64 m_minNormalizer
Value used to make sure that residual normalizers are not too small when computing residual norm.
real64 timeStepIncreaseFactor() const
Getter for the factor used to increase the time step size.
real64 m_lineSearchResidualFactor
Factor to determine residual increase.
real64 m_timeStepDecreaseIterLimit
Fraction of the max Newton iterations above which the solver asks for the time-step to be decreased f...
NonlinearAccelerationType m_nonlinearAccelerationType
Type of nonlinear acceleration for sequential solver.
LineSearchAction
Indicates the handling of line search in a Newton loop.
@ Require
Use line search. If smaller residual than starting residual is not achieved, cut time step.
@ Attempt
Use line search. Allow exit from line search without achieving smaller residual than starting residua...
NonlinearSolverParameters & operator=(const NonlinearSolverParameters &params)
Copy Constructor.
double m_configurationTolerance
Configuration tolerance.
real64 m_timeStepIncreaseIterLimit
Fraction of the max Newton iterations below which the solver asks for the time-step to be increased f...
physicsSolverBaseKernels::NormType m_normType
Norm used to check the nonlinear loop convergence.
static string catalogName()
The name of this object in the catalog.
real64 m_timeStepIncreaseFactor
Factor used to increase the time step size.
integer m_maxIterNewton
The maximum number of nonlinear iterations that are allowed.
virtual void postInputInitialization() override
real64 m_timeStepCutFactor
Factor by which the time step will be cut if a timestep cut is required.
NonlinearSolverParameters()=delete
Default constructor.
integer m_numNewtonIterations
The number of nonlinear iterations that have been exectued.
integer m_numTimeStepAttempts
Number of times that the time-step had to be cut.
integer m_maxTimeStepCuts
Max number of time step cuts.
integer timeStepDecreaseIterLimit() const
Calculates the upper limit for the number of iterations to allow a decrease to the next time step.
NonlinearSolverParameters(NonlinearSolverParameters &&)=default
Default Move Constructor.
real64 m_maxAllowedResidualNorm
The maximum value of residual norm that we allow (otherwise, we cut the time step)
CouplingType couplingType() const
Getter for the coupling type.
CouplingType m_couplingType
Type of coupling.
NonlinearSolverParameters(string const &name, Group *const parent)
Constructor.
LineSearchAction m_lineSearchAction
Flag to apply a line search.
integer m_lineSearchStartingIteration
Iteration when line search starts.
real64 m_lineSearchCutFactor
The reduction factor for each line search cut.
integer m_minIterNewton
The minimum number of nonlinear iterations that may be applied.
physicsSolverBaseKernels::NormType normType() const
Getter for the norm type used to check convergence in the flow/well solvers.
integer minTimeStepIncreaseInterval() const
Getter for the minimum interval for increasing the time-step.
integer m_maxNumConfigurationAttempts
Max number of times that the configuration can be changed.
integer m_minTimeStepIncreaseInterval
Minimum interval, since the last time-step cut, for increasing the time-step.
LineSearchInterpolationType
Indicates the handling of line each interpolation strategy.
@ Linear
linear decrease of line search scaling factor.
@ Parabolic
use parabolic interpolation to define line search scaling factor.
real64 m_timeStepDecreaseFactor
Factor used to decrease the time step size.
integer m_maxSubSteps
Maximum number of time sub-steps allowed for the solver.
SequentialConvergenceCriterion m_sequentialConvergenceCriterion
Criterion used to check outer-loop convergence in sequential schemes.
SequentialConvergenceCriterion
Sequential convergence criterion.
@ ResidualNorm
convergence achieved when the residual drops below a given norm
@ NumberOfNonlinearIterations
convergence achieved when the subproblems convergence is achieved in less than minNewtonIteration
@ SolutionIncrements
convergence achieved when the solution increments are small enough
integer m_subcyclingOption
Flag to specify whether subcycling is allowed or not in sequential schemes.
virtual ~NonlinearSolverParameters()=default
Default destructor.
integer m_lineSearchMaxCuts
The maximum number of line search cuts to attempt.
integer getLogLevel() const
Definition: Group.hpp:1505
void setLogLevel(integer const logLevel)
Set verbosity level.
Definition: Group.hpp:1502
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82