21 #ifndef GEOS_PHYSICSSOLVERS_MULTIPHYSICS_HYDROFRACTURESOLVERKERNELS_HPP_ 
   22 #define GEOS_PHYSICSSOLVERS_MULTIPHYSICS_HYDROFRACTURESOLVERKERNELS_HPP_ 
   28 namespace hydrofractureSolverKernels
 
   34   template< 
typename POLICY, 
typename HYDRAULICAPERTURE_WRAPPER, 
typename POROUS_WRAPPER >
 
   35   static std::tuple< double, double, double, double, double, double >
 
   37           HYDRAULICAPERTURE_WRAPPER 
const & hydraulicApertureWrapper,
 
   38           POROUS_WRAPPER 
const & porousMaterialWrapper,
 
   49 #ifdef GEOS_USE_SEPARATION_COEFFICIENT
 
   59     RAJA::ReduceMax< ReducePolicy< POLICY >, 
real64 > maxApertureChange( 0.0 );
 
   60     RAJA::ReduceMax< ReducePolicy< POLICY >, 
real64 > maxHydraulicApertureChange( 0.0 );
 
   61     RAJA::ReduceMin< ReducePolicy< POLICY >, 
real64 > minAperture( 1e10 );
 
   62     RAJA::ReduceMax< ReducePolicy< POLICY >, 
real64 > maxAperture( -1e10 );
 
   63     RAJA::ReduceMin< ReducePolicy< POLICY >, 
real64 > minHydraulicAperture( 1e10 );
 
   64     RAJA::ReduceMax< ReducePolicy< POLICY >, 
real64 > maxHydraulicAperture( -1e10 );
 
   66     forAll< POLICY >( size,
 
   72       localIndex const numNodesPerFace = faceToNodeMap.sizeOfArray( kf0 );
 
   76         LvArray::tensorOps::add< 3 >( temp, u[ faceToNodeMap( kf0, a ) ] );
 
   77         LvArray::tensorOps::subtract< 3 >( temp, u[ faceToNodeMap( kf1, a ) ] );
 
   81       real64 const normalJump = -LvArray::tensorOps::AiBi< 3 >( temp, faceNormal[kf0] ) / numNodesPerFace;
 
   82       maxApertureChange.max( std::fabs( normalJump - aperture[kfe] ));
 
   83       aperture[kfe] = normalJump;
 
   84       minAperture.min( aperture[kfe] );
 
   85       maxAperture.max( aperture[kfe] );
 
   89       real64 normalTraction = 0.0; 
 
   90       real64 dHydraulicAperture_dNormalTraction = 0.0;
 
   91       real64 dHydraulicAperture_dNormalJump = 0.0;
 
   92       real64 const newHydraulicAperture = hydraulicApertureWrapper.computeHydraulicAperture( aperture[kfe],
 
   95                                                                                              dHydraulicAperture_dNormalJump,
 
   96                                                                                              dHydraulicAperture_dNormalTraction );
 
   98       maxHydraulicApertureChange.max( std::fabs( newHydraulicAperture - hydraulicAperture[kfe] ));
 
   99       real64 const oldHydraulicAperture = hydraulicAperture[kfe];
 
  100       hydraulicAperture[kfe] = newHydraulicAperture;
 
  101       minHydraulicAperture.min( hydraulicAperture[kfe] );
 
  102       maxHydraulicAperture.max( hydraulicAperture[kfe] );
 
  104       real64 const jump[3] = { normalJump, 0.0, 0.0 };
 
  105       real64 const traction[3] = {0.0, 0.0, 0.0};
 
  107       porousMaterialWrapper.updateStateFromPressureApertureJumpAndTraction( kfe, 0, 0.0,
 
  108                                                                             oldHydraulicAperture, newHydraulicAperture,
 
  109                                                                             dHydraulicAperture_dNormalJump,
 
  112 #ifdef GEOS_USE_SEPARATION_COEFFICIENT 
  113       real64 const s = aperture[kfe] / apertureAtFailure[kfe];
 
  114       if( separationCoeff0[kfe]<1.0 && s>separationCoeff0[kfe] )
 
  118           separationCoeff[kfe] = 1.0;
 
  119           dSeparationCoeff_dAper[kfe] = 0.0;
 
  123           separationCoeff[kfe] = s;
 
  124           dSeparationCoeff_dAper[kfe] = 1.0/apertureAtFailure[kfe];
 
  128       deltaVolume[kfe] = hydraulicAperture[kfe] * area[kfe] - volume[kfe];
 
  131     return std::make_tuple( maxApertureChange.get(), maxHydraulicApertureChange.get(), minAperture.get(), maxAperture.get(), minHydraulicAperture.get(), maxHydraulicAperture.get() );
 
  137   template< 
typename HYDRAULICAPERTURE_WRAPPER >
 
  141   computeAccumulationDerivative( HYDRAULICAPERTURE_WRAPPER 
const & hydraulicApertureWrapper,
 
  146                                  real64 const (&Nbar)[ 3 ],
 
  154     real64 dHydraulicAperture_dNormalJump = 0.0;
 
  155     real64 dHydraulicAperture_dTraction = 0.0;
 
  156     real64 fractureTraction = 0.0;
 
  157     real64 const hydraulicAperture = hydraulicApertureWrapper.computeHydraulicAperture( aperture,
 
  160                                                                                         dHydraulicAperture_dNormalJump,
 
  161                                                                                         dHydraulicAperture_dTraction );
 
  164     constexpr 
integer kfSign[2] = { -1, 1 };
 
  167       for( 
localIndex a = 0; a < numNodesPerFace; ++a )
 
  169         for( 
int i = 0; i < 3; ++i )
 
  171           nodeDOF[kf * 3 * numNodesPerFace + 3 * a + i] = dispDofNumber[faceToNodeMap( elemsToFaces[kf], a )] + i;
 
  173           real64 const dNormalJump_dDisplacement = kfSign[kf] * Nbar[i] / numNodesPerFace;
 
  174           real64 const dHydraulicAperture_dDisplacement = dHydraulicAperture_dNormalJump * dNormalJump_dDisplacement;
 
  175           real64 const dVolume_dDisplacement = area * dHydraulicAperture_dDisplacement;
 
  177           dRdU( kf * 3 * numNodesPerFace + 3 * a + i ) = dens * dVolume_dDisplacement;
 
  193                          real64 const (&Nbar)[ 3 ],
 
  197     constexpr 
integer kfSign[2] = { -1, 1 };
 
  199     real64 const dR_dNormalJump = values[kfe2];
 
  204       for( 
localIndex a = 0; a < numNodesPerFace; ++a )
 
  208           nodeDOF[kf * 3 * numNodesPerFace + 3 * a + i] = dispDofNumber[faceToNodeMap( elemsToFaces[ei2][kf], a )] + i;
 
  210           real64 const dNormalJump_dDisplacement = kfSign[kf] * Nbar[i] / numNodesPerFace;
 
  212           dRdU( kf * 3 * numNodesPerFace + 3 * a + i ) = dR_dNormalJump * dNormalJump_dDisplacement;
 
  218   template< 
typename POLICY, 
typename HYDRAULICAPERTURE_WRAPPER >
 
  222           HYDRAULICAPERTURE_WRAPPER 
const & hydraulicApertureWrapper,
 
  238       localIndex const numNodesPerFace = faceToNodeMap.sizeOfArray( elemsToFaces[ei][0] );
 
  240       real64 Nbar[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( faceNormal[elemsToFaces[ei][0]] );
 
  241       LvArray::tensorOps::subtract< 3 >( Nbar, faceNormal[elemsToFaces[ei][1]] );
 
  242       LvArray::tensorOps::normalize< 3 >( Nbar );
 
  244       globalIndex const rowNumber = presDofNumber[ei] - rankOffset;
 
  248       computeAccumulationDerivative( hydraulicApertureWrapper,
 
  261       if( rowNumber >= 0  && rowNumber < localMatrix.numRows() )
 
  263         localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( rowNumber,
 
  266                                                                           2 * numNodesPerFace * 3 );
 
  269       if( useQuasiNewton == 0 ) 
 
  271         localIndex const numColumns = dFluxResidual_dNormalJump.numNonZeros( ei );
 
  275         for( 
localIndex kfe2 = 0; kfe2 < numColumns; ++kfe2 )
 
  277           computeFluxDerivative( kfe2,
 
  288           if( rowNumber >= 0 && rowNumber < localMatrix.numRows() )
 
  290             localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( rowNumber,
 
  293                                                                               2 * numNodesPerFace * 3 );
 
#define GEOS_HOST_DEVICE
Marks a host-device function.
 
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
 
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
 
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
 
StackArray< T, 1, MAXSIZE > stackArray1d
Alias for 1D stack array.
 
LvArray::ArrayOfArraysView< T, INDEX_TYPE const, CONST_SIZES, LvArray::ChaiBuffer > ArrayOfArraysView
View of array of variable-sized arrays. See LvArray::ArrayOfArraysView for details.
 
double real64
64-bit floating point type.
 
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
 
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
 
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
 
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
 
int integer
Signed integer type.