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"
31 
32 namespace geos
33 {
34 
35 
42 template< typename FE_TYPE,
43  typename SOLID_TYPE >
45  public AverageOverQuadraturePointsBase< CellElementSubRegion,
46  FE_TYPE >
47 {
48 public:
49 
52  FE_TYPE >;
53 
57 
71  EdgeManager const & edgeManager,
72  FaceManager const & faceManager,
73  CellElementSubRegion const & elementSubRegion,
74  FE_TYPE const & finiteElementSpace,
75  SOLID_TYPE const & solidModel,
76  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
77  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
78  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
79  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain,
81  fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress ):
82  Base( nodeManager,
83  edgeManager,
84  faceManager,
85  elementSubRegion,
86  finiteElementSpace ),
87  m_solidUpdate( solidModel.createKernelUpdates()),
88  m_displacement( displacement ),
89  m_displacementInc( displacementInc ),
90  m_avgStrain( avgStrain ),
91  m_avgPlasticStrain( avgPlasticStrain ),
92  m_stress( stress ),
93  m_avgStress( avgStress )
94  {}
95 
99  struct StackVariables : Base::StackVariables
100  {real64 uLocal[FE_TYPE::maxSupportPoints][3];
101  real64 uHatLocal[FE_TYPE::maxSupportPoints][3]; };
102 
109  void setup( localIndex const k,
110  StackVariables & stack ) const
111  {
112  Base::setup( k, stack );
113 
114  for( localIndex a = 0; a < FE_TYPE::maxSupportPoints; ++a )
115  {
116  localIndex const localNodeIndex = m_elemsToNodes( k, a );
117  for( int i = 0; i < 3; ++i )
118  {
119  stack.uLocal[a][i] = m_displacement[localNodeIndex][i];
120  stack.uHatLocal[a][i] = m_displacementInc[localNodeIndex][i];
121  }
122  }
123 
124  for( int icomp = 0; icomp < 6; ++icomp )
125  {
126  m_avgStrain[k][icomp] = 0.0;
127  m_avgStress[k][icomp] = 0.0;
128  }
129  }
130 
139  localIndex const q,
140  StackVariables & stack ) const
141  {
142  //real64 const weight = FE_TYPE::transformedQuadratureWeight( q, stack.xLocal, stack.feStack ) / m_elementVolume[k];
143 
144  real64 dNdX[ FE_TYPE::maxSupportPoints ][3];
145  real64 const detJxW = FE_TYPE::calcGradN( q, stack.xLocal, stack.feStack, dNdX );
146  real64 strain[6] = {0.0};
147  real64 strainInc[6] = {0.0};
148  finiteElement::feOps::symmetricGradient( dNdX, stack.uLocal, strain );
149  finiteElement::feOps::symmetricGradient( dNdX, stack.uHatLocal, strainInc );
150 
151  real64 elasticStrainInc[6] = {0.0};
152  m_solidUpdate.getElasticStrainInc( k, q, elasticStrainInc );
153 
154  real64 conversionFactor[6] = {1.0, 1.0, 1.0, 0.5, 0.5, 0.5}; // used for converting from engineering shear to tensor shear
155 
156  for( int icomp = 0; icomp < 6; ++icomp )
157  {
158  m_avgStrain[k][icomp] += conversionFactor[icomp]*detJxW*strain[icomp]/m_elementVolume[k];
159  m_avgStress[k][icomp] += detJxW*m_stress[k][q][icomp]/m_elementVolume[k];
160 
161  // This is a hack to handle boundary conditions such as those seen in plane-strain wellbore problems
162  // Essentially, if bcs are constraining the strain (and thus total displacement), we do not accumulate any plastic strain (regardless
163  // of stresses in material law)
164  if( std::abs( strainInc[icomp] ) > 1.0e-8 )
165  {
166  m_avgPlasticStrain[k][icomp] += conversionFactor[icomp]*detJxW*(strainInc[icomp] - elasticStrainInc[icomp])/m_elementVolume[k];
167  }
168  }
169  }
170 
178  template< typename POLICY,
179  typename KERNEL_TYPE >
180  static void
181  kernelLaunch( localIndex const numElems,
182  KERNEL_TYPE const & kernelComponent )
183  {
184  forAll< POLICY >( numElems,
185  [=] GEOS_HOST_DEVICE ( localIndex const k )
186  {
187  typename KERNEL_TYPE::StackVariables stack;
188 
189  kernelComponent.setup( k, stack );
190  for( integer q = 0; q < FE_TYPE::numQuadraturePoints; ++q )
191  {
192  kernelComponent.quadraturePointKernel( k, q, stack );
193  }
194  } );
195  }
196 
197 protected:
198 
200  typename SOLID_TYPE::KernelWrapper const m_solidUpdate;
201 
203  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement;
204 
206  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc;
207 
209  fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain;
210 
212  fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain;
213 
216 
218  fields::solidMechanics::arrayView2dLayoutAvgStress const m_avgStress;
219 
220 };
221 
222 
223 
229 {
230 public:
231 
246  template< typename FE_TYPE,
247  typename SOLID_TYPE,
248  typename POLICY >
249  static void
250  createAndLaunch( NodeManager & nodeManager,
251  EdgeManager const & edgeManager,
252  FaceManager const & faceManager,
253  CellElementSubRegion const & elementSubRegion,
254  FE_TYPE const & finiteElementSpace,
255  SOLID_TYPE const & solidModel,
256  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
257  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
258  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
259  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain,
261  fields::solidMechanics::arrayView2dLayoutAvgStress const avgStress )
262  {
264  kernel( nodeManager, edgeManager, faceManager, elementSubRegion, finiteElementSpace,
265  solidModel, displacement, displacementInc, avgStrain, avgPlasticStrain, stress, avgStress );
266 
268  kernelLaunch< POLICY >( elementSubRegion.size(), kernel );
269  }
270 };
271 
272 
273 
274 }
275 
276 
277 
278 #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.
static void kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Launch the kernel over the elements in the subRegion.
fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc
The displacement increment.
fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain
The average plastic strain.
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)
Constructor for the class.
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)
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
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