20 #ifndef GEOS_PHYSICSSOLVERS_MULTIPHYSICS_POROMECHANICSKERNELS_SINGLEPHASEPOROMECHANICS_IMPL_HPP_
21 #define GEOS_PHYSICSSOLVERS_MULTIPHYSICS_POROMECHANICSKERNELS_SINGLEPHASEPOROMECHANICS_IMPL_HPP_
23 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
24 #include "finiteElement/BilinearFormUtilities.hpp"
25 #include "finiteElement/LinearFormUtilities.hpp"
33 namespace poromechanicsKernels
36 template<
typename SUBREGION_TYPE,
37 typename CONSTITUTIVE_TYPE,
44 SUBREGION_TYPE
const & elementSubRegion,
45 FE_TYPE
const & finiteElementSpace,
46 CONSTITUTIVE_TYPE & inputConstitutiveType,
52 real64 const (&gravityVector)[3],
53 string const inputFlowDofKey,
54 integer const performStressInitialization,
55 string const fluidModelKey ):
62 inputConstitutiveType,
71 m_fluidDensity( elementSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( elementSubRegion.template getReference<
string >( fluidModelKey ) ).density() ),
72 m_fluidDensity_n( elementSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( elementSubRegion.template getReference<
string >( fluidModelKey ) ).density_n() ),
73 m_dFluidDensity_dPressure( elementSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( elementSubRegion.template getReference<
string >( fluidModelKey ) ).dDensity_dPressure() ),
74 m_performStressInitialization( performStressInitialization )
77 template<
typename SUBREGION_TYPE,
78 typename CONSTITUTIVE_TYPE,
89 real64 dPorosity_dVolStrain = 0.0;
90 real64 dPorosity_dPressure = 0.0;
91 real64 dPorosity_dTemperature = 0.0;
92 real64 dSolidDensity_dPressure = 0.0;
95 m_constitutiveUpdate.smallStrainUpdatePoromechanics( k, q,
100 stack.deltaTemperatureFromLastStep,
101 stack.strainIncrement,
103 stack.dTotalStress_dPressure,
104 stack.dTotalStress_dTemperature,
106 m_performStressInitialization,
109 dPorosity_dVolStrain,
111 dPorosity_dTemperature,
112 dSolidDensity_dPressure );
115 computeBodyForce( k, q,
117 dPorosity_dVolStrain,
119 dPorosity_dTemperature,
120 dSolidDensity_dPressure,
124 computeFluidIncrement( k, q,
127 dPorosity_dVolStrain,
129 dPorosity_dTemperature,
133 template<
typename SUBREGION_TYPE,
134 typename CONSTITUTIVE_TYPE,
142 real64 const & dPorosity_dVolStrain,
143 real64 const & dPorosity_dPressure,
144 real64 const & dPorosity_dTemperature,
145 real64 const & dSolidDensity_dPressure,
150 real64 const mixtureDensity = ( 1.0 - porosity ) * m_solidDensity( k, q ) + porosity * m_fluidDensity( k, q );
151 real64 const dMixtureDens_dVolStrainIncrement = dPorosity_dVolStrain * ( -m_solidDensity( k, q ) + m_fluidDensity( k, q ) );
152 real64 const dMixtureDens_dPressure = dPorosity_dPressure * ( -m_solidDensity( k, q ) + m_fluidDensity( k, q ) )
153 + ( 1.0 - porosity ) * dSolidDensity_dPressure
154 + porosity * m_dFluidDensity_dPressure( k, q );
156 LvArray::tensorOps::scaledCopy< 3 >( stack.bodyForce, m_gravityVector, mixtureDensity );
157 LvArray::tensorOps::scaledCopy< 3 >( stack.dBodyForce_dVolStrainIncrement, m_gravityVector, dMixtureDens_dVolStrainIncrement );
158 LvArray::tensorOps::scaledCopy< 3 >( stack.dBodyForce_dPressure, m_gravityVector, dMixtureDens_dPressure );
161 template<
typename SUBREGION_TYPE,
162 typename CONSTITUTIVE_TYPE,
170 real64 const & porosity_n,
171 real64 const & dPorosity_dVolStrain,
172 real64 const & dPorosity_dPressure,
173 real64 const & dPorosity_dTemperature,
178 stack.
fluidMassIncrement = porosity * m_fluidDensity( k, q ) - porosity_n * m_fluidDensity_n( k, q );
183 template<
typename SUBREGION_TYPE,
184 typename CONSTITUTIVE_TYPE,
190 real64 const ( &dNdX )[numNodesPerElem][3],
194 using namespace PDEUtilities;
196 constexpr FunctionSpace displacementTrialSpace = FE_TYPE::template getFunctionSpace< numDofPerTrialSupportPoint >();
197 constexpr FunctionSpace displacementTestSpace = displacementTrialSpace;
198 constexpr FunctionSpace pressureTrialSpace = FunctionSpace::P0;
201 LinearFormUtilities::compute< displacementTestSpace,
202 DifferentialOperator::SymmetricGradient >
204 stack.localResidualMomentum,
209 LinearFormUtilities::compute< displacementTestSpace,
210 DifferentialOperator::Identity >
212 stack.localResidualMomentum,
218 BilinearFormUtilities::compute< displacementTestSpace,
219 displacementTrialSpace,
220 DifferentialOperator::SymmetricGradient,
221 DifferentialOperator::SymmetricGradient >
223 stack.dLocalResidualMomentum_dDisplacement,
229 BilinearFormUtilities::compute< displacementTestSpace,
230 displacementTrialSpace,
231 DifferentialOperator::Identity,
232 DifferentialOperator::Divergence >
234 stack.dLocalResidualMomentum_dDisplacement,
236 stack.dBodyForce_dVolStrainIncrement,
241 BilinearFormUtilities::compute< displacementTestSpace,
243 DifferentialOperator::SymmetricGradient,
244 DifferentialOperator::Identity >
246 stack.dLocalResidualMomentum_dPressure,
248 stack.dTotalStress_dPressure,
252 BilinearFormUtilities::compute< displacementTestSpace,
254 DifferentialOperator::Identity,
255 DifferentialOperator::Identity >
257 stack.dLocalResidualMomentum_dPressure,
259 stack.dBodyForce_dPressure,
264 template<
typename SUBREGION_TYPE,
265 typename CONSTITUTIVE_TYPE,
274 using namespace PDEUtilities;
276 constexpr FunctionSpace displacementTrialSpace = FE_TYPE::template getFunctionSpace< numDofPerTrialSupportPoint >();
277 constexpr FunctionSpace pressureTrialSpace = FunctionSpace::P0;
278 constexpr FunctionSpace pressureTestSpace = pressureTrialSpace;
281 LinearFormUtilities::compute< pressureTestSpace,
282 DifferentialOperator::Identity >
290 BilinearFormUtilities::compute< pressureTestSpace,
291 displacementTrialSpace,
292 DifferentialOperator::Identity,
293 DifferentialOperator::Divergence >
302 BilinearFormUtilities::compute< pressureTestSpace,
304 DifferentialOperator::Identity,
305 DifferentialOperator::Identity >
314 template<
typename SUBREGION_TYPE,
315 typename CONSTITUTIVE_TYPE,
322 StackVariables & stack )
const
367 real64 N[numNodesPerElem]{};
368 real64 dNdX[numNodesPerElem][3]{};
369 FE_TYPE::calcN( q, stack.feStack, N );
370 real64 const detJxW = m_finiteElementSpace.template getGradN< FE_TYPE >( k, q, stack.xLocal,
371 stack.feStack, dNdX );
374 LvArray::tensorOps::fill< 6 >( stack.strainIncrement, 0.0 );
375 FE_TYPE::symmetricGradient( dNdX, stack.uhat_local, stack.strainIncrement );
380 smallStrainUpdate( k, q, stack );
384 assembleMomentumBalanceTerms( N, dNdX, detJxW, stack );
388 assembleElementBasedFlowTerms( dNdX, detJxW, stack );
391 template<
typename SUBREGION_TYPE,
392 typename CONSTITUTIVE_TYPE,
403 m_finiteElementSpace.template numSupportPoints< FE_TYPE >( stack.feStack );
404 integer numDisplacementDofs = numSupportPoints * numDofPerTestSupportPoint;
406 for(
int localNode = 0; localNode < numSupportPoints; ++localNode )
408 for(
int dim = 0; dim < numDofPerTestSupportPoint; ++dim )
411 localIndex const dof = LvArray::integerConversion< localIndex >( stack.localRowDofIndex[numDofPerTestSupportPoint*localNode + dim] - m_dofRankOffset );
414 if( dof < 0 || dof >= m_matrix.numRows() )
418 m_matrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( dof,
419 stack.localRowDofIndex,
420 stack.dLocalResidualMomentum_dDisplacement[numDofPerTestSupportPoint * localNode + dim],
421 numDisplacementDofs );
423 RAJA::atomicAdd< parallelDeviceAtomic >( &m_rhs[dof], stack.localResidualMomentum[numDofPerTestSupportPoint * localNode + dim] );
424 maxForce = fmax( maxForce, fabs( stack.localResidualMomentum[numDofPerTestSupportPoint * localNode + dim] ) );
425 m_matrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( dof,
426 &stack.localPressureDofIndex,
427 stack.dLocalResidualMomentum_dPressure[numDofPerTestSupportPoint * localNode + dim],
432 localIndex const dof = LvArray::integerConversion< localIndex >( stack.localPressureDofIndex - m_dofRankOffset );
435 if( 0 <= dof && dof < m_matrix.numRows() )
437 m_matrix.template addToRowBinarySearchUnsorted< serialAtomic >( dof,
438 stack.localRowDofIndex,
440 numDisplacementDofs );
441 m_matrix.template addToRow< serialAtomic >( dof,
442 &stack.localPressureDofIndex,
450 template<
typename SUBREGION_TYPE,
451 typename CONSTITUTIVE_TYPE,
453 template<
typename POLICY,
454 typename KERNEL_TYPE >
458 KERNEL_TYPE
const & kernelComponent )
463 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > maxResidual( 0 );
465 forAll< POLICY >( numElems,
468 typename KERNEL_TYPE::StackVariables stack;
470 kernelComponent.setup( k, stack );
471 for(
integer q=0; q<KERNEL_TYPE::numQuadraturePointsPerElem; ++q )
473 kernelComponent.quadraturePointKernel( k, q, stack );
475 maxResidual.max( kernelComponent.complete( k, stack ) );
477 return maxResidual.get();
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
#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.
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Implements kernels for solving quasi-static single-phase poromechanics.
GEOS_HOST_DEVICE void smallStrainUpdate(localIndex const k, localIndex const q, StackVariables &stack) const
Helper function to compute 1) the total stress, 2) the body force term, and 3) the fluidMassIncrement...
GEOS_HOST_DEVICE void computeFluidIncrement(localIndex const k, localIndex const q, real64 const &porosity, real64 const &porosity_n, real64 const &dPorosity_dVolStrain, real64 const &dPorosity_dPressure, real64 const &dPorosity_dTemperature, StackVariables &stack) const
Helper function to compute the fluid mass increment and its derivatives wrt primary variables.
static real64 kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Kernel Launcher.
GEOS_HOST_DEVICE void computeBodyForce(localIndex const k, localIndex const q, real64 const &porosity, real64 const &dPorosity_dVolStrain, real64 const &dPorosity_dPressure, real64 const &dPorosity_dTemperature, real64 const &dSolidDensity_dPressure, StackVariables &stack) const
Helper function to compute the body force term (\rho g) and its derivatives wrt primary variables.
GEOS_HOST_DEVICE void assembleElementBasedFlowTerms(real64 const (&dNdX)[numNodesPerElem][3], real64 const &detJxW, StackVariables &stack) const
Assemble the local mass balance residual and derivatives using fluid mass/energy increment.
SinglePhasePoromechanics(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 inputDispDofNumber, globalIndex const rankOffset, CRSMatrixView< real64, globalIndex const > const inputMatrix, arrayView1d< real64 > const inputRhs, real64 const inputDt, real64 const (&gravityVector)[3], string const inputFlowDofKey, integer const performStressInitialization, string const fluidModelKey)
Constructor.
GEOS_HOST_DEVICE real64 complete(localIndex const k, StackVariables &stack) const
Performs the complete phase for the kernel.
GEOS_HOST_DEVICE void assembleMomentumBalanceTerms(real64 const (&N)[numNodesPerElem], real64 const (&dNdX)[numNodesPerElem][3], real64 const &detJxW, StackVariables &stack) const
Assemble the local linear momentum balance residual and derivatives using total stress and body force...
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
std::string string
String type.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::int32_t integer
Signed integer type.
Kernel variables allocated on the stack.
real64 dFluidMassIncrement_dVolStrainIncrement
Derivative of mass accumulation wrt volumetric strain increment.
real64 fluidMassIncrement
Mass accumulation.
real64 localResidualMass[1]
Mass balance residual.
real64 dLocalResidualMass_dPressure[1][1]
Derivative of mass balance residual wrt pressure.
real64 dLocalResidualMass_dDisplacement[1][Base::StackVariables::numDispDofPerElem]
Derivative of mass balance residual wrt displacement.
real64 dFluidMassIncrement_dPressure
Derivative of mass accumulation wrt pressure.