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 "mesh/CellElementSubRegion.hpp"
29 
30 namespace geos
31 {
37 template< typename SUBREGION_TYPE,
38  typename FE_TYPE >
40  public AverageOverQuadraturePointsBase< SUBREGION_TYPE,
41  FE_TYPE >
42 {
43 public:
44 
46  using Base = AverageOverQuadraturePointsBase< SUBREGION_TYPE,
47  FE_TYPE >;
48 
52 
64  EdgeManager const & edgeManager,
65  FaceManager const & faceManager,
66  SUBREGION_TYPE const & elementSubRegion,
67  FE_TYPE const & finiteElementSpace,
68  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
69  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain ):
70  Base( nodeManager,
71  edgeManager,
72  faceManager,
73  elementSubRegion,
74  finiteElementSpace ),
75  m_displacement( displacement ),
76  m_avgStrain( avgStrain )
77  {}
78 
83  {real64 uLocal[FE_TYPE::maxSupportPoints][3]; };
84 
91  void setup( localIndex const k,
92  StackVariables & stack ) const
93  {
94  Base::setup( k, stack );
95 
96  for( localIndex a = 0; a < FE_TYPE::maxSupportPoints; ++a )
97  {
98  localIndex const localNodeIndex = m_elemsToNodes( k, a );
99  for( int i = 0; i < 3; ++i )
100  {
101  stack.uLocal[a][i] = m_displacement[localNodeIndex][i];
102  }
103  }
104 
105  for( int icomp = 0; icomp < 6; ++icomp )
106  {
107  m_avgStrain[k][icomp] = 0.0;
108  }
109  }
110 
119  localIndex const q,
120  StackVariables & stack ) const
121  {
122  //real64 const weight = FE_TYPE::transformedQuadratureWeight( q, stack.xLocal, stack.feStack ) / m_elementVolume[k];
123 
124  real64 dNdX[ FE_TYPE::maxSupportPoints ][3];
125  real64 const detJxW = m_finiteElementSpace.template getGradN< FE_TYPE >( k, q, stack.xLocal, stack.feStack, dNdX );
126  real64 strain[6] = {0.0};
127  FE_TYPE::symmetricGradient( dNdX, stack.uLocal, strain );
128 
129  for( int icomp = 0; icomp < 6; ++icomp )
130  {
131  m_avgStrain[k][icomp] += detJxW*strain[icomp]/m_elementVolume[k];
132  }
133  }
134 
142  template< typename POLICY,
143  typename KERNEL_TYPE >
144  static void
145  kernelLaunch( localIndex const numElems,
146  KERNEL_TYPE const & kernelComponent )
147  {
148  forAll< POLICY >( numElems,
149  [=] GEOS_HOST_DEVICE ( localIndex const k )
150  {
151  typename KERNEL_TYPE::StackVariables stack;
152 
153  kernelComponent.setup( k, stack );
154  for( integer q = 0; q < FE_TYPE::numQuadraturePoints; ++q )
155  {
156  kernelComponent.quadraturePointKernel( k, q, stack );
157  }
158  } );
159  }
160 
161 protected:
162 
164  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement;
165 
167  fields::solidMechanics::arrayView2dLayoutStrain const m_avgStrain;
168 
169 };
170 
171 
172 
178 {
179 public:
180 
194  template< typename SUBREGION_TYPE,
195  typename FE_TYPE,
196  typename POLICY >
197  static void
198  createAndLaunch( NodeManager & nodeManager,
199  EdgeManager const & edgeManager,
200  FaceManager const & faceManager,
201  SUBREGION_TYPE const & elementSubRegion,
202  FE_TYPE const & finiteElementSpace,
203  fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement,
204  fields::solidMechanics::arrayView2dLayoutStrain const avgStrain )
205  {
207  kernel( nodeManager, edgeManager, faceManager, elementSubRegion, finiteElementSpace,
208  displacement, avgStrain );
209 
211  kernelLaunch< POLICY >( elementSubRegion.size(), kernel );
212  }
213 };
214 
215 
216 
217 }
218 
219 
220 #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::arrayView2dLayoutStrain const m_avgStrain
The average strain.
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
Performs the setup phase for the kernel.
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.
arrayView1d< real64 const > const m_elementVolume
The volume of the elements.
AverageStrainOverQuadraturePoints(NodeManager &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement, fields::solidMechanics::arrayView2dLayoutStrain const avgStrain)
Constructor for the class.
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
static void kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Launch the kernel over the elements in the subRegion.
fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const m_displacement
The displacement solution.
Class to create and launch the kernel.
static void createAndLaunch(NodeManager &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, fields::solidMechanics::arrayViewConst2dLayoutTotalDisplacement const displacement, fields::solidMechanics::arrayView2dLayoutStrain const avgStrain)
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
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
FE_TYPE::StackVariables feStack
Stack variables needed for the underlying FEM type.
real64 xLocal[FE_TYPE::maxSupportPoints][3]
C-array stack storage for element local the nodal positions.
Kernel variables allocated on the stack.