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