GEOS
StrainHelper.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_STRAINHELPER_HPP_
21 #define GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_KERNELS_STRAINHELPER_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 {
39 template< typename FE_TYPE,
40  typename SOLID_TYPE >
42  public AverageOverQuadraturePointsBase< CellElementSubRegion,
43  FE_TYPE >
44 {
45 public:
46 
49  FE_TYPE >;
50 
54 
66  EdgeManager const & edgeManager,
67  FaceManager const & faceManager,
68  CellElementSubRegion const & elementSubRegion,
69  FE_TYPE const & finiteElementSpace,
70  SOLID_TYPE const & solidModel,
71  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
72  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
73  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
74  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain ):
75  Base( nodeManager,
76  edgeManager,
77  faceManager,
78  elementSubRegion,
79  finiteElementSpace ),
80  m_solidUpdate( solidModel.createKernelUpdates()),
81  m_displacement( displacement ),
82  m_displacementInc( displacementInc ),
83  m_avgStrain( avgStrain ),
84  m_avgPlasticStrain( avgPlasticStrain )
85  {}
86 
90  struct StackVariables : Base::StackVariables
91  {real64 uLocal[FE_TYPE::maxSupportPoints][3];
92  real64 uHatLocal[FE_TYPE::maxSupportPoints][3]; };
93 
100  void setup( localIndex const k,
101  StackVariables & stack ) const
102  {
103  Base::setup( k, stack );
104 
105  for( localIndex a = 0; a < FE_TYPE::maxSupportPoints; ++a )
106  {
107  localIndex const localNodeIndex = m_elemsToNodes( k, a );
108  for( int i = 0; i < 3; ++i )
109  {
110  stack.uLocal[a][i] = m_displacement[localNodeIndex][i];
111  stack.uHatLocal[a][i] = m_displacementInc[localNodeIndex][i];
112  }
113  }
114 
115  for( int icomp = 0; icomp < 6; ++icomp )
116  {
117  m_avgStrain[k][icomp] = 0.0;
118  //m_avgPlasticStrain[k][icomp] = 0.0;
119  }
120  }
121 
130  localIndex const q,
131  StackVariables & stack ) const
132  {
133  //real64 const weight = FE_TYPE::transformedQuadratureWeight( q, stack.xLocal, stack.feStack ) / m_elementVolume[k];
134 
135  real64 dNdX[ FE_TYPE::maxSupportPoints ][3];
136  real64 const detJxW = m_finiteElementSpace.template getGradN< FE_TYPE >( k, q, stack.xLocal, stack.feStack, dNdX );
137  real64 strain[6] = {0.0};
138  real64 strainInc[6] = {0.0};
139  FE_TYPE::symmetricGradient( dNdX, stack.uLocal, strain );
140  FE_TYPE::symmetricGradient( dNdX, stack.uHatLocal, strainInc );
141 
142  real64 elasticStrainInc[6] = {0.0};
143  m_solidUpdate.getElasticStrainInc( k, q, elasticStrainInc );
144 
145  real64 conversionFactor[6] = {1.0, 1.0, 1.0, 0.5, 0.5, 0.5}; // used for converting from engineering shear to tensor shear
146 
147  for( int icomp = 0; icomp < 6; ++icomp )
148  {
149  m_avgStrain[k][icomp] += conversionFactor[icomp]*detJxW*strain[icomp]/m_elementVolume[k];
150 
151  // This is a hack to handle boundary conditions such as those seen in plane-strain wellbore problems
152  // Essentially, if bcs are constraining the strain (and thus total displacement), we do not accumulate any plastic strain (regardless
153  // of stresses in material law)
154  if( std::abs( strainInc[icomp] ) > 1.0e-8 )
155  {
156  m_avgPlasticStrain[k][icomp] += conversionFactor[icomp]*detJxW*(strainInc[icomp] - elasticStrainInc[icomp])/m_elementVolume[k];
157  }
158  }
159  }
160 
168  template< typename POLICY,
169  typename KERNEL_TYPE >
170  static void
171  kernelLaunch( localIndex const numElems,
172  KERNEL_TYPE const & kernelComponent )
173  {
174  forAll< POLICY >( numElems,
175  [=] GEOS_HOST_DEVICE ( localIndex const k )
176  {
177  typename KERNEL_TYPE::StackVariables stack;
178 
179  kernelComponent.setup( k, stack );
180  for( integer q = 0; q < FE_TYPE::numQuadraturePoints; ++q )
181  {
182  kernelComponent.quadraturePointKernel( k, q, stack );
183  }
184  } );
185  }
186 
187 protected:
188 
190  typename SOLID_TYPE::KernelWrapper const m_solidUpdate;
191 
193  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement;
194 
196  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc;
197 
199  fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain;
200 
202  fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain;
203 
204 };
205 
206 
207 
213 {
214 public:
215 
230  template< typename FE_TYPE,
231  typename SOLID_TYPE,
232  typename POLICY >
233  static void
234  createAndLaunch( NodeManager & nodeManager,
235  EdgeManager const & edgeManager,
236  FaceManager const & faceManager,
237  CellElementSubRegion const & elementSubRegion,
238  FE_TYPE const & finiteElementSpace,
239  SOLID_TYPE const & solidModel,
240  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
241  fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const displacementInc,
242  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain,
243  fields::solidMechanics::arrayView2dLayoutStrain const avgPlasticStrain )
244  {
246  kernel( nodeManager, edgeManager, faceManager, elementSubRegion, finiteElementSpace,
247  solidModel, displacement, displacementInc, avgStrain, avgPlasticStrain );
248 
250  kernelLaunch< POLICY >( elementSubRegion.size(), kernel );
251  }
252 };
253 
254 
255 
256 }
257 
258 
259 #endif /* GEOS_PHYSICSSOLVERS_SOLIDMECHANICS_KERNELS_STRAINHELPER_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.
fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement
The displacement solution.
fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain
The average strain.
SOLID_TYPE::KernelWrapper const m_solidUpdate
The material.
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.
AverageStrainOverQuadraturePoints(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)
Constructor for the class.
fields::solidMechanics::arrayView2dLayoutStrain const m_avgPlasticStrain
The average plastic strain.
fields::solidMechanics::arrayViewConst2dLayoutIncrDisplacement const m_displacementInc
The displacement increment.
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.
Class to create and launch the kernel.
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)
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:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
Kernel variables allocated on the stack.