GEOS
SolidMechanicsPressureFaceBubbleKernels.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_CONTACT_KERNELS_SOLIDMECHANICSPRESSUREFACEBUBBLEKERNELS_HPP_
21 #define GEOS_PHYSICSSOLVERS_CONTACT_KERNELS_SOLIDMECHANICSPRESSUREFACEBUBBLEKERNELS_HPP_
22 
25 
26 namespace geos
27 {
28 
29 namespace solidMechanicsConformingContactKernels
30 {
31 
38 template< typename SUBREGION_TYPE,
39  typename CONSTITUTIVE_TYPE,
40  typename FE_TYPE >
42  public finiteElement::ImplicitKernelBase< SUBREGION_TYPE,
43  CONSTITUTIVE_TYPE,
44  FE_TYPE,
45  3,
46  3 >
47 {
48 public:
49 
51  using Base = finiteElement::ImplicitKernelBase< SUBREGION_TYPE,
52  CONSTITUTIVE_TYPE,
53  FE_TYPE,
54  3,
55  3 >;
56 
60 
62  static constexpr int numFacesPerElem = FE_TYPE::numFaces;
63 
65  static constexpr int numQuadraturePointsPerElem = FE_TYPE::numQuadraturePoints;
66 
70  using Base::m_dofNumber;
72  using Base::m_matrix;
73  using Base::m_rhs;
74  using Base::m_dt;
75 
80  PressureFaceBubbleKernels( NodeManager const & nodeManager,
81  EdgeManager const & edgeManager,
82  FaceManager const & faceManager,
83  localIndex const targetRegionIndex,
84  SUBREGION_TYPE const & elementSubRegion,
85  FE_TYPE const & finiteElementSpace,
86  CONSTITUTIVE_TYPE & inputConstitutiveType,
87  arrayView1d< globalIndex const > const uDofNumber,
88  arrayView1d< globalIndex const > const bDofNumber,
89  globalIndex const rankOffset,
91  arrayView1d< real64 > const inputRhs,
92  real64 const inputDt ):
93  Base( nodeManager,
94  edgeManager,
95  faceManager,
96  targetRegionIndex,
97  elementSubRegion,
98  finiteElementSpace,
99  inputConstitutiveType,
100  uDofNumber,
101  rankOffset,
102  inputMatrix,
103  inputRhs,
104  inputDt ),
105  m_X( nodeManager.referencePosition()),
106  m_incrementalDisp( nodeManager.getField< fields::solidMechanics::incrementalDisplacement >() ),
107  m_bDofNumber( bDofNumber ),
108  m_bubbleElems( elementSubRegion.bubbleElementsList() ),
109  m_elemsToFaces( elementSubRegion.faceElementsList() ),
110  m_pressure( elementSubRegion.template getField< fields::flow::pressure >().toViewConst() ),
111  m_pressure_n( elementSubRegion.template getField< fields::flow::pressure_n >().toViewConst() ),
112  m_incrementalBubbleDisp( faceManager.getField< fields::contact::incrementalBubbleDisplacement >().toViewConst() )
113  {}
114 
115  //***************************************************************************
116 
121  {
122 public:
123 
125  static constexpr int numUdofs = numNodesPerElem * 3;
126 
128  static constexpr int numBubbleUdofs = numFacesPerElem * 3;
129 
131  static constexpr int numPdofs = 1;
132 
138  bEqnRowIndices{},
139  localRb{},
140  X{ {} },
141  pLocal{},
142  uIncrLocal{},
143  bIncrLocal{}
144  {}
145 
147  globalIndex bEqnRowIndices[3];
148 
150  real64 localRb[numBubbleUdofs];
151 
154 
156  real64 pLocal[numPdofs];
157 
159  real64 uIncrLocal[numUdofs];
160 
162  real64 bIncrLocal[3];
163 
164  };
165 
166  //***************************************************************************
167 
175  //START_kernelLauncher
176  template< typename POLICY,
177  typename KERNEL_TYPE >
178  static
179  real64
180  kernelLaunch( localIndex const numElems,
181  KERNEL_TYPE const & kernelComponent )
182  {
183 
185  GEOS_UNUSED_VAR( numElems );
186 
187  // Define a RAJA reduction variable to get the maximum residual contribution.
188  RAJA::ReduceMax< ReducePolicy< POLICY >, real64 > maxResidual( 0 );
189 
190  forAll< POLICY >( kernelComponent.m_bubbleElems.size(),
191  [=] GEOS_HOST_DEVICE ( localIndex const i )
192  {
193  typename KERNEL_TYPE::StackVariables stack;
194 
195  kernelComponent.setup( i, stack );
196  for( integer q=0; q<numQuadraturePointsPerElem; ++q )
197  {
198  kernelComponent.quadraturePointKernel( i, q, stack );
199  }
200  maxResidual.max( kernelComponent.complete( i, stack ) );
201  } );
202 
203  return maxResidual.get();
204  }
205  //END_kernelLauncher
206 
208  inline
209  void setup( localIndex const kk,
210  StackVariables & stack ) const
211  {
212 
213  localIndex k = m_bubbleElems[kk];
214 
215  for( localIndex a=0; a<numNodesPerElem; ++a )
216  {
217  localIndex const localNodeIndex = m_elemsToNodes( k, a );
218 
219  for( int i=0; i<3; ++i )
220  {
221  stack.X[ a ][ i ] = m_X[ localNodeIndex ][ i ];
222  stack.uIncrLocal[ a*3 + i ] = m_incrementalDisp[ localNodeIndex ][i];
223  }
224  }
225 
226  localIndex const localFaceIndex = m_elemsToFaces[kk][0];
227 
228  for( int i=0; i<3; ++i )
229  {
230  // need to grab the index.
231  stack.bEqnRowIndices[i] = m_bDofNumber[localFaceIndex] + i - m_dofRankOffset;
232  stack.bIncrLocal[ i ] = m_incrementalBubbleDisp[ localFaceIndex ][i];
233  }
234 
235  stack.pLocal[0] = m_pressure( k );
236 
237  }
238 
239 
241  inline
242  void quadraturePointKernel( localIndex const kk,
243  localIndex const q,
244  StackVariables & stack ) const
245  {
246 
247  localIndex k = m_bubbleElems[kk];
248 
249  constexpr int nBubbleUdof = numFacesPerElem*3;
250 
251  constexpr int nUdof = numNodesPerElem*3;
252 
253  real64 dBubbleNdX[ numFacesPerElem ][ 3 ];
254  // Next line is needed because I only inserted a placeholder for calcGradFaceBubbleN in some finite elements
255  LvArray::tensorOps::fill< numFacesPerElem, 3 >( dBubbleNdX, 0 );
256 
257  real64 detJ = m_finiteElementSpace.calcGradFaceBubbleN( q, stack.X, dBubbleNdX );
258 
259  real64 dNdX[ numNodesPerElem ][ 3 ];
260  detJ = m_finiteElementSpace.calcGradN( q, stack.X, dNdX );
261 
262  real64 biotCoefficient;
263  m_constitutiveUpdate.getBiotCoefficient( k, biotCoefficient );
264 
265  real64 strainBubbleMatrix[6][nBubbleUdof];
266  solidMechanicsConformingContactKernelsHelper::assembleStrainOperator< 6, nBubbleUdof, numFacesPerElem >( strainBubbleMatrix, dBubbleNdX );
267 
268  real64 strainMatrix[6][nUdof];
269  solidMechanicsConformingContactKernelsHelper::assembleStrainOperator< 6, nUdof, numNodesPerElem >( strainMatrix, dNdX );
270 
271  real64 biotPressure[6] = {0};
272  LvArray::tensorOps::symAddIdentity< 3 >( biotPressure, -biotCoefficient * stack.pLocal[0] );
273 
274  // transp(Bb)(Identity biot pressure)
275  real64 Rb_gauss[nBubbleUdof];
276  LvArray::tensorOps::Ri_eq_AjiBj< nBubbleUdof, 6 >( Rb_gauss, strainBubbleMatrix, biotPressure );
277  LvArray::tensorOps::scaledAdd< nBubbleUdof >( stack.localRb, Rb_gauss, -detJ );
278 
279  real64 localStrainBubbleMatrix[6][3];
280  localIndex const parentFaceIndex = m_elemsToFaces[kk][1];
281  for( localIndex i = 0; i < 6; ++i )
282  {
283  for( localIndex j = 0; j < 3; ++j )
284  {
285  localStrainBubbleMatrix[i][j] = strainBubbleMatrix[i][parentFaceIndex*3+j];
286  }
287  }
288  real64 strainIncBubble[6] = {0};
289  real64 strainInc[6] = {0};
290 
291  LvArray::tensorOps::Ri_eq_AijBj< 6, 3 >( strainIncBubble, localStrainBubbleMatrix, stack.bIncrLocal );
292  LvArray::tensorOps::Ri_eq_AijBj< 6, nUdof >( strainInc, strainMatrix, stack.uIncrLocal );
293 
294  //LvArray::tensorOps::add< 6 >( strainInc, strainIncBubble );
295 
296  real64 totalStress[6] = {0};
297  typename CONSTITUTIVE_TYPE::KernelWrapper::DiscretizationOps stiffness;
298 
299  m_constitutiveUpdate.smallStrainUpdatePoromechanicsFixedStress( k, q,
300  m_dt,
301  m_pressure[k],
302  m_pressure_n[k],
303  0.0, 0.0, 0.0,
304  strainInc,
305  totalStress,
306  stiffness );
307 
308  }
309 
311  inline
312  real64 complete( localIndex const kk,
313  StackVariables & stack ) const
314  {
315 
316  localIndex const parentFaceIndex = m_elemsToFaces[kk][1];
317 
318  // Extract only the submatrix and known term corresponding to the index of the local face
319  // on which the bubble function was applied.
320  real64 localRb[3];
321  for( localIndex i = 0; i < 3; ++i )
322  {
323  localRb[i] = stack.localRb[parentFaceIndex*3+i];
324  }
325 
326  for( localIndex i=0; i < 3; ++i )
327  {
328  localIndex const dof = LvArray::integerConversion< localIndex >( stack.bEqnRowIndices[ i ] );
329 
330  if( dof < 0 || dof >= m_matrix.numRows() ) continue;
331 
332  RAJA::atomicAdd< parallelDeviceAtomic >( &m_rhs[dof], localRb[i] );
333 
334  }
335 
336  return 0.0;
337  }
338 
339 protected:
340 
343 
346 
349 
352 
357 
360 
363 
366 
367 };
368 
373  globalIndex const,
375  arrayView1d< real64 > const,
376  real64 const >;
377 
378 } // namespace SolidMechanicsPressureFaceBubbleKernels
379 
380 } // namespace geos
381 
382 
383 #endif /* GEOS_PHYSICSSOLVERS_CONTACT_KERNELS_SOLIDMECHANICSPRESSUREFACEBUBBLEKERNELS_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
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
Define the base interface for implicit finite element kernels.
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
Definition: KernelBase.hpp:258
CRSMatrixView< real64, globalIndex const > const m_matrix
The global Jacobian matrix.
arrayView1d< globalIndex const > const m_dofNumber
The global degree of freedom number.
CONSTITUTIVE_TYPE::KernelWrapper const m_constitutiveUpdate
Definition: KernelBase.hpp:265
Used to forward arguments to a class that implements the KernelBase interface.
Definition: KernelBase.hpp:283
Implements kernels for computing the pressure contribution given by the bubble face functions to the ...
arrayView1d< globalIndex const > const m_bDofNumber
The global degree of freedom number of bubble.
arrayView2d< real64 const, nodes::INCR_DISPLACEMENT_USD > const m_incrementalDisp
The rank-global incremental displacement array.
arrayView1d< real64 const > const m_pressure
The array containing the pressure of each element.
arrayView1d< localIndex const > const m_bubbleElems
The array containing the list of bubble elements.
arrayView1d< real64 const > const m_pressure_n
The array containing the pressure at the previous time step of each element.
arrayView2d< real64 const > const m_incrementalBubbleDisp
The incremental bubble displacement field.
static real64 kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Kernel Launcher.
PressureFaceBubbleKernels(NodeManager const &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, localIndex const targetRegionIndex, SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, CONSTITUTIVE_TYPE &inputConstitutiveType, arrayView1d< globalIndex const > const uDofNumber, arrayView1d< globalIndex const > const bDofNumber, globalIndex const rankOffset, CRSMatrixView< real64, globalIndex const > const inputMatrix, arrayView1d< real64 > const inputRhs, real64 const inputDt)
Constructor.
static constexpr int numQuadraturePointsPerElem
Compile time value for the number of quadrature points per element.
arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const m_X
The array containing the nodal position array.
static constexpr int numFacesPerElem
Compile time value for the number of faces per element.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
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
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:309
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:195
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 localRb[numBubbleUdofs]
C-array storage for the element local Rb residual vector.
globalIndex bEqnRowIndices[3]
C-array storage for the element local row degrees of freedom.