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 
25 #include "constitutive/ConstitutiveManager.hpp"
28 
29 namespace geos
30 {
31 
32 namespace surfaceGenerationKernels
33 {
34 
36 {
37 
38 public:
39 
40  NodalForceKernel( ElementRegionManager const & elemManager,
41  constitutive::ConstitutiveManager const & constitutiveManager,
42  string const solidMaterialKey ):
43  m_dNdX( elemManager.constructViewAccessor< array4d< real64 >, arrayView4d< real64 const > >( dataRepository::keys::dNdX ) ),
44  m_detJ( elemManager.constructViewAccessor< array2d< real64 >, arrayView2d< real64 const > >( dataRepository::keys::detJ ) ),
45  m_bulkModulus( elemManager.constructFullMaterialViewAccessor< array1d< real64 >, arrayView1d< real64 const > >( "bulkModulus", constitutiveManager ) ),
46  m_shearModulus( elemManager.constructFullMaterialViewAccessor< array1d< real64 >, arrayView1d< real64 const > >( "shearModulus", constitutiveManager ) ),
48  arrayView3d< real64 const, solid::STRESS_USD > >( constitutive::SolidBase::viewKeyStruct::stressString(),
49  constitutiveManager ) )
50  {
51  m_solidMaterialFullIndex.resize( elemManager.numRegions() );
52  elemManager.forElementRegionsComplete< CellElementRegion >( [&]( localIndex regionIndex,
53  CellElementRegion const & region )
54  {
55  string const & solidMaterialName = region.getSubRegion( 0 ).getReference< string >( solidMaterialKey );
56  constitutive::ConstitutiveBase const & solid = constitutiveManager.getConstitutiveRelation< constitutive::ConstitutiveBase >( solidMaterialName );
57  m_solidMaterialFullIndex[regionIndex] = solid.getIndexInParent();
58  } );
59  }
60 
61  virtual void
62  calculateSingleNodalForce( localIndex const er,
63  localIndex const esr,
64  localIndex const ei,
65  localIndex const targetNode,
66  real64 ( & force )[ 3 ] ) const
67  {
69 
70  localIndex const numQuadraturePoints = m_detJ[er][esr].size( 1 );
71 
72  // Loop over quadrature points
73  for( localIndex q = 0; q < numQuadraturePoints; ++q )
74  {
75  real64 const quadratureStress[6] = LVARRAY_TENSOROPS_INIT_LOCAL_6 ( m_stress[er][esr][m_solidMaterialFullIndex[er]][ei][q] );
76  real64 const dNdX[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3 ( m_dNdX[er][esr][ei][q][targetNode] );
77  surfaceGenerationKernelsHelpers::computeNodalForce( quadratureStress, dNdX, m_detJ[er][esr][ei][q], force );
78  }
79 
80  //wu40: the nodal force need to be weighted by Young's modulus and possion's ratio.
81  surfaceGenerationKernelsHelpers::scaleNodalForce( m_bulkModulus[er][esr][m_solidMaterialFullIndex[er]][ei], m_shearModulus[er][esr][m_solidMaterialFullIndex[er]][ei], force );
82  }
83 
84 protected:
85 
87 
89 
91 
93 
95 
96  array1d< integer > m_solidMaterialFullIndex;
97 };
98 
99 
101 {
102 
103 public:
105  constitutive::ConstitutiveManager const & constitutiveManager,
106  string const solidMaterialKey,
107  string const porosityModelKey ):
108  NodalForceKernel( elemManager, constitutiveManager, solidMaterialKey ),
109  m_pressure( elemManager.constructArrayViewAccessor< real64, 1 >( fields::flow::pressure::key() ) ),
110  m_biotCoefficient( elemManager.constructFullMaterialViewAccessor< array1d< real64 >, arrayView1d< real64 const > >( "biotCoefficient", constitutiveManager ) )
111  {
112  m_porosityMaterialFullIndex.resize( elemManager.numRegions() );
113  elemManager.forElementRegionsComplete< CellElementRegion >( [&]( localIndex regionIndex,
114  CellElementRegion const & region )
115  {
116  string const & porosityModelName = region.getSubRegion( 0 ).getReference< string >( porosityModelKey );
117  constitutive::ConstitutiveBase const & porosityModel = constitutiveManager.getConstitutiveRelation< constitutive::ConstitutiveBase >( porosityModelName );
118  m_porosityMaterialFullIndex[regionIndex] = porosityModel.getIndexInParent();
119  } );
120 
121  }
122 
123  void
125  localIndex const esr,
126  localIndex const ei,
127  localIndex const targetNode,
128  real64 ( & force )[ 3 ] ) const override
129 
130  {
132 
133  localIndex const numQuadraturePoints = m_detJ[er][esr].size( 1 );
134 
135  // Loop over quadrature points
136  for( localIndex q = 0; q < numQuadraturePoints; ++q )
137  {
138  real64 totalStress[6] = LVARRAY_TENSOROPS_INIT_LOCAL_6 ( m_stress[er][esr][m_solidMaterialFullIndex[er]][ei][q] );
139  real64 const dNdX[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3 ( m_dNdX[er][esr][ei][q][targetNode] );
141  LvArray::tensorOps::symAddIdentity< 3 >( totalStress, -m_biotCoefficient[er][esr][m_porosityMaterialFullIndex[er]][ei] * m_pressure[er][esr][ei] );
142 
143  surfaceGenerationKernelsHelpers::computeNodalForce( totalStress, dNdX, m_detJ[er][esr][ei][q], force );
144  }
145 
146  //wu40: the nodal force need to be weighted by Young's modulus and possion's ratio.
147  surfaceGenerationKernelsHelpers::scaleNodalForce( m_bulkModulus[er][esr][m_solidMaterialFullIndex[er]][ei], m_shearModulus[er][esr][m_solidMaterialFullIndex[er]][ei], force );
148  }
149 
150 private:
151 
153 
155 
156  array1d< integer > m_porosityMaterialFullIndex;
157 
158 };
159 
160 template< typename LAMBDA >
161 void kernelSelector( ElementRegionManager const & elemManager,
162  constitutive::ConstitutiveManager const & constitutiveManager,
163  string const solidMaterialKey,
164  integer const isPoroelastic,
165  LAMBDA && lambda )
166 {
167  if( isPoroelastic == 0 )
168  {
169  lambda( NodalForceKernel( elemManager, constitutiveManager, solidMaterialKey ) );
170  }
171  else
172  {
173  string const porosityModelKey = constitutive::CoupledSolidBase::viewKeyStruct::porosityModelNameString();
174  lambda( PoroElasticNodalForceKernel( elemManager, constitutiveManager, solidMaterialKey, porosityModelKey ) );
175  }
176 
177 }
178 
179 } // namespace solidMechanicsLagrangianFEMKernels
180 
181 } // 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:180
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:192
Array< T, 3, PERMUTATION > array3d
Alias for 3D array.
Definition: DataTypes.hpp:208
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
Array< T, 4, PERMUTATION > array4d
Alias for 4D array.
Definition: DataTypes.hpp:224
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
Definition: DataTypes.hpp:228
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Definition: DataTypes.hpp:212