GEOS
StressStrainAverageKernels.hpp
Go to the documentation of this file.
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 
20 #ifndef GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_KERNELS_STRESSSTRAINAVERAGEKERNELS_HPP_
21 #define GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_KERNELS_STRESSSTRAINAVERAGEKERNELS_HPP_
22 
23 #include "common/DataTypes.hpp"
24 #include "common/GEOS_RAJA_Interface.hpp"
25 #include "finiteElement/FiniteElementDispatch.hpp"
26 #include "finiteElement/elementFormulations/FiniteElementOperators.hpp"
27 #include "constitutive/ConstitutivePassThru.hpp"
28 #include "mesh/CellElementSubRegion.hpp"
32 
33 #include <utility>
34 
35 namespace geos
36 {
37 
38 
45 template< typename FE_TYPE,
46  typename SOLID_TYPE >
48  public AverageOverQuadraturePointsBase< CellElementSubRegion,
49  FE_TYPE >
50 {
51 public:
52 
55  FE_TYPE >;
56 
60 
76  EdgeManager const & edgeManager,
77  FaceManager const & faceManager,
78  CellElementSubRegion const & elementSubRegion,
79  FE_TYPE const & finiteElementSpace,
80  SOLID_TYPE const & solidModel,
81  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
82  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
83  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
84  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain,
86  fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress,
87  arrayView1d< real64 const > const temperature,
88  arrayView1d< real64 const > const temperature_n ):
89  Base( nodeManager,
90  edgeManager,
91  faceManager,
92  elementSubRegion,
93  finiteElementSpace ),
94  m_solidUpdate( solidModel.createKernelUpdates()),
95  m_displacement( displacement ),
96  m_displacementInc( displacementInc ),
97  m_avgStrain( avgStrain ),
98  m_avgPlasticStrain( avgPlasticStrain ),
99  m_stress( stress ),
100  m_avgStress( avgStress ),
101  m_temperature( temperature ),
102  m_temperature_n( temperature_n )
103  {}
104 
108  struct StackVariables : Base::StackVariables
109  {real64 uLocal[FE_TYPE::maxSupportPoints][3];
110  real64 uHatLocal[FE_TYPE::maxSupportPoints][3]; };
111 
118  void setup( localIndex const k,
119  StackVariables & stack ) const
120  {
121  Base::setup( k, stack );
122 
123  for( localIndex a = 0; a < FE_TYPE::maxSupportPoints; ++a )
124  {
125  localIndex const localNodeIndex = m_elemsToNodes( k, a );
126  for( int i = 0; i < 3; ++i )
127  {
128  stack.uLocal[a][i] = m_displacement[localNodeIndex][i];
129  stack.uHatLocal[a][i] = m_displacementInc[localNodeIndex][i];
130  }
131  }
132 
133  for( int icomp = 0; icomp < 6; ++icomp )
134  {
135  m_avgStrain[k][icomp] = 0.0;
136  m_avgStress[k][icomp] = 0.0;
137  }
138  }
139 
148  localIndex const q,
149  StackVariables & stack ) const
150  {
151  //real64 const weight = FE_TYPE::transformedQuadratureWeight( q, stack.xLocal, stack.feStack ) / m_elementVolume[k];
152 
153  real64 dNdX[ FE_TYPE::maxSupportPoints ][3];
154  real64 const detJxW = FE_TYPE::calcGradN( q, stack.xLocal, stack.feStack, dNdX );
155  real64 strain[6] = {0.0};
156  real64 strainInc[6] = {0.0};
157  finiteElement::feOps::symmetricGradient( dNdX, stack.uLocal, strain );
158  finiteElement::feOps::symmetricGradient( dNdX, stack.uHatLocal, strainInc );
159 
160  real64 elasticStrainInc[6] = {0.0};
161  m_solidUpdate.getElasticStrainInc( k, q, elasticStrainInc );
162 
163  real64 const thermalExpansionCoefficient = m_solidUpdate.getThermalExpansionCoefficient( k );
164  real64 const deltaTemperature = ( m_temperature.size() > 0 )
165  ? ( m_temperature[k] - m_temperature_n[k] )
166  : 0.0;
167 
168  real64 conversionFactor[6] = {1.0, 1.0, 1.0, 0.5, 0.5, 0.5}; // used for converting from engineering shear to tensor shear
169 
170  for( int icomp = 0; icomp < 6; ++icomp )
171  {
172  m_avgStrain[k][icomp] += conversionFactor[icomp]*detJxW*strain[icomp]/m_elementVolume[k];
173  m_avgStress[k][icomp] += detJxW*m_stress[k][q][icomp]/m_elementVolume[k];
174 
175  // Thermal strain is purely volumetric: subtract thermal strain from normal components so that
176  // only the mechanical (plastic) part is accumulated.
177  real64 const thermalStrainInc = ( icomp < 3 ) ? thermalExpansionCoefficient * deltaTemperature : 0.0;
178  real64 const mechanicalStrainInc = strainInc[icomp] - thermalStrainInc;
179 
180  // This is a hack to handle boundary conditions such as those seen in plane-strain wellbore problems
181  // Essentially, if bcs are constraining the strain (and thus total displacement), we do not accumulate any plastic strain (regardless
182  // of stresses in material law)
183  if( std::abs( mechanicalStrainInc ) > 1.0e-8 )
184  {
185  m_avgPlasticStrain[k][icomp] += conversionFactor[icomp]*detJxW*(mechanicalStrainInc - elasticStrainInc[icomp])/m_elementVolume[k];
186  }
187  }
188  }
189 
197  template< typename POLICY,
198  typename KERNEL_TYPE >
199  static void
200  kernelLaunch( localIndex const numElems,
201  KERNEL_TYPE const & kernelComponent )
202  {
203  forAll< POLICY >( numElems,
204  [=] GEOS_HOST_DEVICE ( localIndex const k )
205  {
206  typename KERNEL_TYPE::StackVariables stack;
207 
208  kernelComponent.setup( k, stack );
209  for( integer q = 0; q < FE_TYPE::numQuadraturePoints; ++q )
210  {
211  kernelComponent.quadraturePointKernel( k, q, stack );
212  }
213  } );
214  }
215 
216 protected:
217 
221  using KernelWrapper = decltype( std::declval< SOLID_TYPE const & >().createKernelUpdates() );
222 
225 
227  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement;
228 
230  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc;
231 
233  fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain;
234 
236  fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain;
237 
240 
242  fields::solidMechanics::arrayView2dLayoutAvgStress const m_avgStress;
243 
246 
249 
250 };
251 
252 
253 
259 {
260 public:
261 
276  template< typename FE_TYPE,
277  typename SOLID_TYPE,
278  typename POLICY >
279  static void
280  createAndLaunch( NodeManager & nodeManager,
281  EdgeManager const & edgeManager,
282  FaceManager const & faceManager,
283  CellElementSubRegion const & elementSubRegion,
284  FE_TYPE const & finiteElementSpace,
285  SOLID_TYPE const & solidModel,
286  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
287  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
288  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
289  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain,
291  fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress,
292  arrayView1d< real64 const > const temperature = {},
293  arrayView1d< real64 const > const temperature_n = {} )
294  {
295  AverageStressStrainOverQuadraturePoints< FE_TYPE, SOLID_TYPE >
296  kernel( nodeManager, edgeManager, faceManager, elementSubRegion, finiteElementSpace,
297  solidModel, displacement, displacementInc, avgStrain, avgPlasticStrain, stress, avgStress,
298  temperature, temperature_n );
299 
300  AverageStressStrainOverQuadraturePoints< FE_TYPE, SOLID_TYPE >::template
301  kernelLaunch< POLICY >( elementSubRegion.size(), kernel );
302  }
303 };
304 
305 
306 
307 }
308 
309 
310 
311 #endif /* GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_KERNELS_STRESSSTRAINAVERAGEKERNELS_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
Performs the setup phase for the kernel.
arrayView1d< real64 const > const m_elementVolume
The volume of the elements.
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
Performs the setup phase for the kernel.
arrayView1d< real64 const > const m_temperature
The temperature at the current time step (empty for non-thermal simulations)
static void kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Launch the kernel over the elements in the subRegion.
AverageStressStrainOverQuadraturePoints(NodeManager &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, CellElementSubRegion const &elementSubRegion, FE_TYPE const &finiteElementSpace, SOLID_TYPE const &solidModel, fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement, fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc, fields::solidMechanics::arrayView2dLayoutStrain const avgStrain, fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain, arrayView3d< real64 const, solid::STRESS_USD > const stress, fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress, arrayView1d< real64 const > const temperature, arrayView1d< real64 const > const temperature_n)
Constructor for the class.
fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc
The displacement increment.
fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain
The average plastic strain.
arrayView1d< real64 const > const m_temperature_n
The temperature at the previous time step (empty for non-thermal simulations)
GEOS_HOST_DEVICE void quadraturePointKernel(localIndex const k, localIndex const q, StackVariables &stack) const
Increment the average property with the contribution of the property at this quadrature point.
fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain
The average strain.
fields::solidMechanics::arrayView2dLayoutAvgStress const m_avgStress
The average stress.
fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement
The displacement solution.
arrayView3d< real64 const, solid::STRESS_USD > const m_stress
The stress solution.
static void createAndLaunch(NodeManager &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, CellElementSubRegion const &elementSubRegion, FE_TYPE const &finiteElementSpace, SOLID_TYPE const &solidModel, fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement, fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc, fields::solidMechanics::arrayView2dLayoutStrain const avgStrain, fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain, arrayView3d< real64 const, solid::STRESS_USD > const stress, fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress, arrayView1d< real64 const > const temperature={}, arrayView1d< real64 const > const temperature_n={})
Create a new kernel and launch.
This class provides an interface to ObjectManagerBase in order to manage edge data.
Definition: EdgeManager.hpp:43
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Definition: FaceManager.hpp:44
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Definition: NodeManager.hpp:46
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:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
int integer
Signed integer type.
Definition: DataTypes.hpp:81
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:211