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 namespace geos
34 {
35 
36 
43 template< typename FE_TYPE,
44  typename SOLID_TYPE >
46  public AverageOverQuadraturePointsBase< CellElementSubRegion,
47  FE_TYPE >
48 {
49 public:
50 
53  FE_TYPE >;
54 
58 
74  EdgeManager const & edgeManager,
75  FaceManager const & faceManager,
76  CellElementSubRegion const & elementSubRegion,
77  FE_TYPE const & finiteElementSpace,
78  SOLID_TYPE const & solidModel,
79  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
80  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
81  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
82  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain,
84  fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress,
85  arrayView1d< real64 const > const temperature,
86  arrayView1d< real64 const > const temperature_n ):
87  Base( nodeManager,
88  edgeManager,
89  faceManager,
90  elementSubRegion,
91  finiteElementSpace ),
92  m_solidUpdate( solidModel.createKernelUpdates()),
93  m_displacement( displacement ),
94  m_displacementInc( displacementInc ),
95  m_avgStrain( avgStrain ),
96  m_avgPlasticStrain( avgPlasticStrain ),
97  m_stress( stress ),
98  m_avgStress( avgStress ),
99  m_temperature( temperature ),
100  m_temperature_n( temperature_n )
101  {}
102 
106  struct StackVariables : Base::StackVariables
107  {real64 uLocal[FE_TYPE::maxSupportPoints][3];
108  real64 uHatLocal[FE_TYPE::maxSupportPoints][3]; };
109 
116  void setup( localIndex const k,
117  StackVariables & stack ) const
118  {
119  Base::setup( k, stack );
120 
121  for( localIndex a = 0; a < FE_TYPE::maxSupportPoints; ++a )
122  {
123  localIndex const localNodeIndex = m_elemsToNodes( k, a );
124  for( int i = 0; i < 3; ++i )
125  {
126  stack.uLocal[a][i] = m_displacement[localNodeIndex][i];
127  stack.uHatLocal[a][i] = m_displacementInc[localNodeIndex][i];
128  }
129  }
130 
131  for( int icomp = 0; icomp < 6; ++icomp )
132  {
133  m_avgStrain[k][icomp] = 0.0;
134  m_avgStress[k][icomp] = 0.0;
135  }
136  }
137 
146  localIndex const q,
147  StackVariables & stack ) const
148  {
149  //real64 const weight = FE_TYPE::transformedQuadratureWeight( q, stack.xLocal, stack.feStack ) / m_elementVolume[k];
150 
151  real64 dNdX[ FE_TYPE::maxSupportPoints ][3];
152  real64 const detJxW = FE_TYPE::calcGradN( q, stack.xLocal, stack.feStack, dNdX );
153  real64 strain[6] = {0.0};
154  real64 strainInc[6] = {0.0};
155  finiteElement::feOps::symmetricGradient( dNdX, stack.uLocal, strain );
156  finiteElement::feOps::symmetricGradient( dNdX, stack.uHatLocal, strainInc );
157 
158  real64 elasticStrainInc[6] = {0.0};
159  m_solidUpdate.getElasticStrainInc( k, q, elasticStrainInc );
160 
161  real64 const thermalExpansionCoefficient = m_solidUpdate.getThermalExpansionCoefficient( k );
162  real64 const deltaTemperature = ( m_temperature.size() > 0 )
163  ? ( m_temperature[k] - m_temperature_n[k] )
164  : 0.0;
165 
166  real64 conversionFactor[6] = {1.0, 1.0, 1.0, 0.5, 0.5, 0.5}; // used for converting from engineering shear to tensor shear
167 
168  for( int icomp = 0; icomp < 6; ++icomp )
169  {
170  m_avgStrain[k][icomp] += conversionFactor[icomp]*detJxW*strain[icomp]/m_elementVolume[k];
171  m_avgStress[k][icomp] += detJxW*m_stress[k][q][icomp]/m_elementVolume[k];
172 
173  // Thermal strain is purely volumetric: subtract thermal strain from normal components so that
174  // only the mechanical (plastic) part is accumulated.
175  real64 const thermalStrainInc = ( icomp < 3 ) ? thermalExpansionCoefficient * deltaTemperature : 0.0;
176  real64 const mechanicalStrainInc = strainInc[icomp] - thermalStrainInc;
177 
178  // This is a hack to handle boundary conditions such as those seen in plane-strain wellbore problems
179  // Essentially, if bcs are constraining the strain (and thus total displacement), we do not accumulate any plastic strain (regardless
180  // of stresses in material law)
181  if( std::abs( mechanicalStrainInc ) > 1.0e-8 )
182  {
183  m_avgPlasticStrain[k][icomp] += conversionFactor[icomp]*detJxW*(mechanicalStrainInc - elasticStrainInc[icomp])/m_elementVolume[k];
184  }
185  }
186  }
187 
195  template< typename POLICY,
196  typename KERNEL_TYPE >
197  static void
198  kernelLaunch( localIndex const numElems,
199  KERNEL_TYPE const & kernelComponent )
200  {
201  forAll< POLICY >( numElems,
202  [=] GEOS_HOST_DEVICE ( localIndex const k )
203  {
204  typename KERNEL_TYPE::StackVariables stack;
205 
206  kernelComponent.setup( k, stack );
207  for( integer q = 0; q < FE_TYPE::numQuadraturePoints; ++q )
208  {
209  kernelComponent.quadraturePointKernel( k, q, stack );
210  }
211  } );
212  }
213 
214 protected:
215 
217  typename SOLID_TYPE::KernelWrapper const m_solidUpdate;
218 
220  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement;
221 
223  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc;
224 
226  fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain;
227 
229  fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain;
230 
233 
235  fields::solidMechanics::arrayView2dLayoutAvgStress const m_avgStress;
236 
239 
242 
243 };
244 
245 
246 
252 {
253 public:
254 
269  template< typename FE_TYPE,
270  typename SOLID_TYPE,
271  typename POLICY >
272  static void
273  createAndLaunch( NodeManager & nodeManager,
274  EdgeManager const & edgeManager,
275  FaceManager const & faceManager,
276  CellElementSubRegion const & elementSubRegion,
277  FE_TYPE const & finiteElementSpace,
278  SOLID_TYPE const & solidModel,
279  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
280  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
281  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
282  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain,
284  fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress,
285  arrayView1d< real64 const > const temperature = {},
286  arrayView1d< real64 const > const temperature_n = {} )
287  {
288  AverageStressStrainOverQuadraturePoints< FE_TYPE, SOLID_TYPE >
289  kernel( nodeManager, edgeManager, faceManager, elementSubRegion, finiteElementSpace,
290  solidModel, displacement, displacementInc, avgStrain, avgPlasticStrain, stress, avgStress,
291  temperature, temperature_n );
292 
293  AverageStressStrainOverQuadraturePoints< FE_TYPE, SOLID_TYPE >::template
294  kernelLaunch< POLICY >( elementSubRegion.size(), kernel );
295  }
296 };
297 
298 
299 
300 }
301 
302 
303 
304 #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.
SOLID_TYPE::KernelWrapper const m_solidUpdate
The material.
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