GEOS
surfaceGenerationKernels.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 #include "common/DataTypes.hpp"
21 #include "common/TimingMacros.hpp"
22 #include "constitutive/solid/CoupledSolidBase.hpp"
23 #include "constitutive/solid/SolidBase.hpp"
24 #include "constitutive/solid/SolidFields.hpp"
25 
26 #include "constitutive/ConstitutiveManager.hpp"
29 
30 namespace geos
31 {
32 
33 namespace surfaceGenerationKernels
34 {
35 
37 {
38 
39 public:
40 
41  NodalForceKernel( ElementRegionManager const & elemManager,
42  constitutive::ConstitutiveManager const & constitutiveManager,
43  string const solidMaterialKey ):
44  m_dNdX( elemManager.constructViewAccessor< array4d< real64 >, arrayView4d< real64 const > >( dataRepository::keys::dNdX ) ),
45  m_detJ( elemManager.constructViewAccessor< array2d< real64 >, arrayView2d< real64 const > >( dataRepository::keys::detJ ) ),
46  m_bulkModulus( elemManager.constructFullMaterialViewAccessor< array1d< real64 >, arrayView1d< real64 const > >( "bulkModulus", constitutiveManager ) ),
47  m_shearModulus( elemManager.constructFullMaterialViewAccessor< array1d< real64 >, arrayView1d< real64 const > >( "shearModulus", constitutiveManager ) ),
49  arrayView3d< real64 const, geos::solid::STRESS_USD > >( fields::solid::stress::key(),
50  constitutiveManager ) )
51  {
52  m_solidMaterialFullIndex.resize( elemManager.numRegions() );
53  elemManager.forElementRegionsComplete< CellElementRegion >( [&]( localIndex regionIndex,
54  CellElementRegion const & region )
55  {
56  string const & solidMaterialName = region.getSubRegion( 0 ).getReference< string >( solidMaterialKey );
57  constitutive::ConstitutiveBase const & solid = constitutiveManager.getConstitutiveRelation< constitutive::ConstitutiveBase >( solidMaterialName );
58  m_solidMaterialFullIndex[regionIndex] = solid.getIndexInParent();
59  } );
60  }
61 
62  virtual void
63  calculateSingleNodalForce( localIndex const er,
64  localIndex const esr,
65  localIndex const ei,
66  localIndex const targetNode,
67  real64 ( & force )[ 3 ] ) const
68  {
70 
71  localIndex const numQuadraturePoints = m_detJ[er][esr].size( 1 );
72 
73  // Loop over quadrature points
74  for( localIndex q = 0; q < numQuadraturePoints; ++q )
75  {
76  real64 const quadratureStress[6] = LVARRAY_TENSOROPS_INIT_LOCAL_6 ( m_stress[er][esr][m_solidMaterialFullIndex[er]][ei][q] );
77  real64 const dNdX[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3 ( m_dNdX[er][esr][ei][q][targetNode] );
78  surfaceGenerationKernelsHelpers::computeNodalForce( quadratureStress, dNdX, m_detJ[er][esr][ei][q], force );
79  }
80 
81  //wu40: the nodal force need to be weighted by Young's modulus and possion's ratio.
82  surfaceGenerationKernelsHelpers::scaleNodalForce( m_bulkModulus[er][esr][m_solidMaterialFullIndex[er]][ei], m_shearModulus[er][esr][m_solidMaterialFullIndex[er]][ei], force );
83  }
84 
85 protected:
86 
88 
90 
92 
94 
96 
97  array1d< integer > m_solidMaterialFullIndex;
98 };
99 
100 
102 {
103 
104 public:
106  constitutive::ConstitutiveManager const & constitutiveManager,
107  string const solidMaterialKey,
108  string const porosityModelKey ):
109  NodalForceKernel( elemManager, constitutiveManager, solidMaterialKey ),
110  m_pressure( elemManager.constructArrayViewAccessor< real64, 1 >( fields::flow::pressure::key() ) ),
111  m_biotCoefficient( elemManager.constructFullMaterialViewAccessor< array1d< real64 >, arrayView1d< real64 const > >( "biotCoefficient", constitutiveManager ) )
112  {
113  m_porosityMaterialFullIndex.resize( elemManager.numRegions() );
114  elemManager.forElementRegionsComplete< CellElementRegion >( [&]( localIndex regionIndex,
115  CellElementRegion const & region )
116  {
117  string const & porosityModelName = region.getSubRegion( 0 ).getReference< string >( porosityModelKey );
118  constitutive::ConstitutiveBase const & porosityModel = constitutiveManager.getConstitutiveRelation< constitutive::ConstitutiveBase >( porosityModelName );
119  m_porosityMaterialFullIndex[regionIndex] = porosityModel.getIndexInParent();
120  } );
121 
122  }
123 
124  void
126  localIndex const esr,
127  localIndex const ei,
128  localIndex const targetNode,
129  real64 ( & force )[ 3 ] ) const override
130 
131  {
133 
134  localIndex const numQuadraturePoints = m_detJ[er][esr].size( 1 );
135 
136  // Loop over quadrature points
137  for( localIndex q = 0; q < numQuadraturePoints; ++q )
138  {
139  real64 totalStress[6] = LVARRAY_TENSOROPS_INIT_LOCAL_6 ( m_stress[er][esr][m_solidMaterialFullIndex[er]][ei][q] );
140  real64 const dNdX[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3 ( m_dNdX[er][esr][ei][q][targetNode] );
142  LvArray::tensorOps::symAddIdentity< 3 >( totalStress, -m_biotCoefficient[er][esr][m_porosityMaterialFullIndex[er]][ei] * m_pressure[er][esr][ei] );
143 
144  surfaceGenerationKernelsHelpers::computeNodalForce( totalStress, dNdX, m_detJ[er][esr][ei][q], force );
145  }
146 
147  //wu40: the nodal force need to be weighted by Young's modulus and possion's ratio.
148  surfaceGenerationKernelsHelpers::scaleNodalForce( m_bulkModulus[er][esr][m_solidMaterialFullIndex[er]][ei], m_shearModulus[er][esr][m_solidMaterialFullIndex[er]][ei], force );
149  }
150 
151 private:
152 
154 
156 
157  array1d< integer > m_porosityMaterialFullIndex;
158 
159 };
160 
161 template< typename LAMBDA >
162 void kernelSelector( ElementRegionManager const & elemManager,
163  constitutive::ConstitutiveManager const & constitutiveManager,
164  string const solidMaterialKey,
165  integer const isPoroelastic,
166  LAMBDA && lambda )
167 {
168  if( isPoroelastic == 0 )
169  {
170  lambda( NodalForceKernel( elemManager, constitutiveManager, solidMaterialKey ) );
171  }
172  else
173  {
174  string const porosityModelKey = constitutive::CoupledSolidBase::viewKeyStruct::porosityModelNameString();
175  lambda( PoroElasticNodalForceKernel( elemManager, constitutiveManager, solidMaterialKey, porosityModelKey ) );
176  }
177 
178 }
179 
180 } // namespace solidMechanicsLagrangianFEMKernels
181 
182 } // namespace geos
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
MaterialViewAccessor< LHS > constructFullMaterialViewAccessor(string const &viewName, constitutive::ConstitutiveManager const &cm) const
This is a const function to construct a MaterialViewAccessor to access the material data.
localIndex numRegions() const
Get number of the regions.
void forElementRegionsComplete(LAMBDA lambda) const
This const function is used to launch kernel function over all the types of element regions.
ElementViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > constructArrayViewAccessor(string const &name, string const &neighborName=string()) const
This is a function to construct a ElementViewAccessor to access array data registered on the mesh.
array1d< array1d< array1d< VIEWTYPE > > > MaterialViewAccessor
The MaterialViewAccessor at the ElementRegionManager level is a 3D array of VIEWTYPE.
array1d< array1d< VIEWTYPE > > ElementViewAccessor
The ElementViewAccessor at the ElementRegionManager level is an array of array of VIEWTYPE.
ElementViewAccessor< LHS > constructViewAccessor(string const &name, string const &neighborName=string()) const
This is a const function to construct a ElementViewAccessor to access the data registered on the mesh...
void calculateSingleNodalForce(localIndex const er, localIndex const esr, localIndex const ei, localIndex const targetNode, real64(&force)[3]) const override
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:191
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:207
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
Array< T, 4, PERMUTATION > array4d
Alias for 4D array.
Definition: DataTypes.hpp:223
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
Definition: DataTypes.hpp:227
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:195
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:211