GEOS
SeismicityRateKernels.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 Total, S.A
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_SEISMICITYRATEKERNELS_HPP_
17 #define GEOS_PHYSICSSOLVERS_SEISMICITYRATEKERNELS_HPP_
18 
19 #include "common/DataTypes.hpp"
20 #include "common/GEOS_RAJA_Interface.hpp"
23 
24 namespace geos
25 {
26 
27 namespace seismicityRateKernels
28 {
47 {
48 public:
49 
51  m_R( subRegion.getField< fields::inducedSeismicity::seismicityRate >() ),
52  m_logDenom( subRegion.getField< fields::inducedSeismicity::logDenom >() ),
53  m_sigma_0( subRegion.getField< fields::inducedSeismicity::initialProjectedNormalTraction >() ),
54  m_sigma_n( subRegion.getField< fields::inducedSeismicity::projectedNormalTraction_n >() ),
55  m_sigma( subRegion.getField< fields::inducedSeismicity::projectedNormalTraction >() ),
56  m_tau_0( subRegion.getField< fields::inducedSeismicity::initialProjectedShearTraction >() ),
57  m_tau_n( subRegion.getField< fields::inducedSeismicity::projectedShearTraction_n >() ),
58  m_tau( subRegion.getField< fields::inducedSeismicity::projectedShearTraction >() )
59  {}
60 
66  {
67 public:
68 
70  StackVariables( real64 const directEffect,
71  real64 const backgroundStressingRate ):
72  directEffectValue( directEffect ),
73  backgroundStressingRateValue( backgroundStressingRate ),
74  effectiveNormalTraction_0( 0.0 ),
75  effectiveNormalTraction_n( 0.0 ),
76  effectiveNormalTraction( 0.0 )
77  {}
78 
79  real64 const directEffectValue;
80 
81  real64 const backgroundStressingRateValue;
82 
83  real64 effectiveNormalTraction_0;
84 
85  real64 effectiveNormalTraction_n;
86 
87  real64 effectiveNormalTraction;
88  };
89 
91  void setup( localIndex const k,
92  StackVariables & stack ) const
93  {
94  stack.effectiveNormalTraction_0 = -m_sigma_0[k];
95  stack.effectiveNormalTraction_n = -m_sigma_n[k];
96  stack.effectiveNormalTraction = -m_sigma[k];
97  }
98 
100  void computeSeismicityRate( localIndex const k,
101  real64 const & time_n,
102  real64 const & dt,
103  StackVariables & stack ) const
104  {
105 
106  // arguments of stress exponential at current and previous time step
107  real64 const g = ( LvArray::math::abs( m_tau[k] ) + stack.backgroundStressingRateValue*(time_n+dt) ) / ( stack.directEffectValue*stack.effectiveNormalTraction ) -
108  LvArray::math::abs( m_tau_0[k] ) / (stack.directEffectValue * stack.effectiveNormalTraction_0 );
109 
110  real64 const g_n = ( LvArray::math::abs( m_tau_n[k] ) + stack.backgroundStressingRateValue*time_n ) / ( stack.directEffectValue*stack.effectiveNormalTraction_n ) -
111  LvArray::math::abs( m_tau_0[k] ) / (stack.directEffectValue*stack.effectiveNormalTraction_0);
112 
113  // Compute the difference of the log of the denominator of closed for integral solution.
114  // This avoids directly computing the exponential of the current stress state which is more prone to overflow.
115  m_logDenom[k] +=
116  LvArray::math::log( 1 + dt/(2*(stack.directEffectValue*stack.effectiveNormalTraction_0/stack.backgroundStressingRateValue) ) *
117  ( LvArray::math::exp( g - m_logDenom[k] ) + LvArray::math::exp( g_n - m_logDenom[k] ) ));
118 
119  // Convert log seismicity rate to raw value
120  m_R[k] = LvArray::math::exp( g - m_logDenom[k] );
121  }
122 
123 protected:
124 
126 
127  arrayView1d< real64 > m_logDenom;
128 
129  arrayView1d< real64 const > m_sigma_0;
130 
131  arrayView1d< real64 const > m_sigma_n;
132 
134 
136 
138 
140 };
141 
142 
144 {
145 
146 public:
147 
149  SeismicityRateKernel( subRegion ),
150  m_pressure_0( subRegion.getField< fields::flow::initialPressure >() ),
151  m_pressure_n( subRegion.getField< fields::flow::pressure_n >() ),
152  m_pressure( subRegion.getField< fields::flow::pressure >() )
153  {}
154 
156  void setup( localIndex const k,
157  StackVariables & stack ) const
158  {
159  stack.effectiveNormalTraction_0 = -m_sigma_0[k] - m_pressure_0[k];
160  stack.effectiveNormalTraction_n = -m_sigma_n[k] - m_pressure_n[k];
161  stack.effectiveNormalTraction = -m_sigma[k] - m_pressure[k];
162  }
163 
164 private:
165 
166  arrayView1d< real64 const > m_pressure_0;
167 
168  arrayView1d< real64 const > m_pressure_n;
169 
170  arrayView1d< real64 const > m_pressure;
171 };
172 
173 
178 template< typename POLICY, bool ISPORO >
179 static void
180 createAndLaunch( ElementSubRegionBase & subRegion,
181  real64 const time_n,
182  real64 const dt,
183  real64 const directEffectValue,
184  real64 const backgroundStressingRateValue )
185 {
187 
188  using kernelType = std::conditional_t< ISPORO, SeismicityRateKernelPoroelastic, SeismicityRateKernel >;
189  kernelType kernel( subRegion );
190 
191  forAll< POLICY >( subRegion.size(), [=] GEOS_HOST_DEVICE ( localIndex const k )
192  {
193  typename kernelType::StackVariables stack( directEffectValue, backgroundStressingRateValue );
194  kernel.setup( k, stack );
195  kernel.computeSeismicityRate( k, time_n, dt, stack );
196  } );
197 }
198 
199 } /* namespace seismicityRateKernels */
200 
201 }/* namespace geos */
202 
203 #endif /* GEOS_PHYSICSSOLVERS_SEISMICITYRATEKERNELS_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
GEOS_DECLTYPE_AUTO_RETURN getField() const
Get a view to the field associated with a trait from this ObjectManagerBase.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85