GEOS
QuasiDynamicEQRK32.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_INDUCED_QUASIDYNAMICEQRK32_HPP
17 #define GEOS_PHYSICSSOLVERS_INDUCED_QUASIDYNAMICEQRK32_HPP
18 
20 #include "kernels/RateAndStateKernels.hpp"
21 
22 namespace geos
23 {
24 
26 {
27 public:
29  QuasiDynamicEQRK32() = delete;
30 
32  QuasiDynamicEQRK32( const string & name,
33  Group * const parent );
34 
36  virtual ~QuasiDynamicEQRK32() override;
37 
38  static string catalogName() { return "QuasiDynamicEQRK32"; }
39 
43  virtual string getCatalogName() const override { return catalogName(); }
44 
46  virtual void registerDataOnMesh( Group & meshBodies ) override;
47 
49  {
51  constexpr static char const * stressSolverNameString() { return "stressSolverName"; }
53  constexpr static char const * frictionLawNameString() { return "frictionLawName"; }
55  constexpr static char const * shearImpedanceString() { return "shearImpedance"; }
57  constexpr static char const * timeStepTol() { return "timeStepTol"; }
58  };
59 
60  virtual real64 solverStep( real64 const & time_n,
61  real64 const & dt,
62  integer const cycleNumber,
63  DomainPartition & domain ) override final;
64 
65 
66  virtual real64 setNextDt( real64 const & currentDt,
67  DomainPartition & domain ) override final;
68 
74  void stepRateStateODEInitialSubstage( real64 const dt, DomainPartition & domain ) const;
75 
82  void stepRateStateODESubstage( integer const stageIndex,
83  real64 const dt,
84  DomainPartition & domain ) const;
85 
91  void stepRateStateODEAndComputeError( real64 const dt, DomainPartition & domain ) const;
92 
93  real64 updateStresses( real64 const & time_n,
94  real64 const & dt,
95  const int cycleNumber,
96  DomainPartition & domain ) const;
97 
102  void updateSlipVelocity( real64 const & time_n,
103  real64 const & dt,
104  DomainPartition & domain ) const;
105 
110  void saveState( DomainPartition & domain ) const;
111 
112 private:
113 
114  virtual void postInputInitialization() override;
115 
116 
118  PhysicsSolverBase * m_stressSolver;
119 
121  string m_stressSolverName;
122 
124  real64 m_shearImpedance;
125 
127  // TODO: The specific type should not be hardcoded!
128  // Should be possible to change RK-method based on the table.
130 
131  bool m_successfulStep; // Flag indicating if the adative time step was accepted
132 
137  class PIDController
138  {
139 public:
140 
142  PIDController( std::array< const real64, 3 > const & cparams,
143  const real64 atol,
144  const real64 rtol,
145  const real64 safety ):
146  controlParameters{ cparams },
147  absTol( atol ),
148  relTol( rtol ),
149  acceptSafety( safety ),
150  errors{ {0.0, 0.0, 0.0} }
151  {}
152 
154  PIDController( PIDController const & ) = default;
155 
157  PIDController( PIDController && ) = default;
158 
160  PIDController() = delete;
161 
163  PIDController & operator=( PIDController const & ) = delete;
164 
166  PIDController & operator=( PIDController && ) = delete;
167 
169  const std::array< const real64, 3 > controlParameters; // Controller parameters
170 
171  real64 const absTol; // absolut tolerence
172 
173  real64 const relTol; // relative tolerence
174 
175  real64 const acceptSafety; // Acceptance safety
176 
177  std::array< real64, 3 > errors; // Errors for current and two previous updates
178  // stored as [n+1, n, n-1]
179 
180  real64 computeUpdateFactor( integer const algHighOrder, integer const algLowOrder )
181  {
182  // PID error controller + limiter
183  real64 const k = LvArray::math::min( algHighOrder, algLowOrder ) + 1.0;
184  real64 const eps0 = 1.0/(errors[0] + std::numeric_limits< real64 >::epsilon()); // n + 1
185  real64 const eps1 = 1.0/(errors[1] + std::numeric_limits< real64 >::epsilon()); // n
186  real64 const eps2 = 1.0/(errors[2] + std::numeric_limits< real64 >::epsilon()); // n-1
187  // Compute update factor eps0^(beta0/k)*eps1^(beta1/k)*eps2^(beta2/k) where
188  // beta0 - beta2 are the control parameters. Also apply limiter to smoothen changes.
189  // Limiter is 1.0 + atan(x - 1.0). Here use atan(x) = atan2(x, 1.0).
190  return 1.0 + LvArray::math::atan2( pow( eps0, controlParameters[0] / k ) *
191  pow( eps1, controlParameters[1] / k ) *
192  pow( eps2, controlParameters[2] / k ) - 1.0, 1.0 );
193  }
194  };
195 
196  PIDController m_controller;
197 
198 
199  class SpringSliderParameters
200  {
201 public:
202 
204  SpringSliderParameters( real64 const normalTraction, real64 const a, real64 const b, real64 const Dc ):
205  tauRate( 1e-4 ),
206  springStiffness( 0.0 )
207  {
208  real64 const criticalStiffness = normalTraction * (b - a) / Dc;
209  springStiffness = 0.9 * criticalStiffness;
210  }
211 
213  SpringSliderParameters( SpringSliderParameters const & ) = default;
214 
216  SpringSliderParameters( SpringSliderParameters && ) = default;
217 
219  SpringSliderParameters() = delete;
220 
222  SpringSliderParameters & operator=( SpringSliderParameters const & ) = delete;
223 
225  SpringSliderParameters & operator=( SpringSliderParameters && ) = delete;
226 
227  real64 tauRate;
228 
229  real64 springStiffness;
230  };
231 };
232 
233 } /* namespace geos */
234 
235 #endif /* GEOS_PHYSICSSOLVERS_INDUCED_QUASIDYNAMICEQRK32_HPP */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Base class for all physics solvers.
PhysicsSolverBase & operator=(PhysicsSolverBase const &)=delete
Deleted copy assignment operator.
virtual real64 solverStep(real64 const &time_n, real64 const &dt, integer const cycleNumber, DomainPartition &domain) override final
entry function to perform a solver step
void stepRateStateODESubstage(integer const stageIndex, real64 const dt, DomainPartition &domain) const
Computes stage rates at the Runge-Kutta substage specified by stageIndex and updates slip and state.
QuasiDynamicEQRK32()=delete
The default nullary constructor is disabled to avoid compiler auto-generation:
virtual string getCatalogName() const override
void stepRateStateODEAndComputeError(real64 const dt, DomainPartition &domain) const
Updates slip and state to t + dt and approximates the error.
QuasiDynamicEQRK32(const string &name, Group *const parent)
The constructor needs a user-defined "name" and a parent Group (to place this instance in the tree st...
void saveState(DomainPartition &domain) const
save the current state
virtual real64 setNextDt(real64 const &currentDt, DomainPartition &domain) override final
function to set the next time step size
virtual void registerDataOnMesh(Group &meshBodies) override
This method ties properties with their supporting mesh.
virtual ~QuasiDynamicEQRK32() override
Destructor.
void stepRateStateODEInitialSubstage(real64 const dt, DomainPartition &domain) const
Computes stage rates for the initial Runge-Kutta substage and updates slip and state.
void updateSlipVelocity(real64 const &time_n, real64 const &dt, DomainPartition &domain) const
Updates rate-and-state slip velocity.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
Structure to hold scoped key names.
constexpr static char const * frictionLawNameString()
Friction law name string.
constexpr static char const * timeStepTol()
target slip increment
constexpr static char const * stressSolverNameString()
stress solver name
constexpr static char const * shearImpedanceString()
Friction law name string.
Butcher table for the BogackiShampine 3(2) method.