21 #ifndef GEOS_PHYSICSSOLVERS_MULTIPHYSICS_HYDROFRACTURESOLVERKERNELS_HPP_
22 #define GEOS_PHYSICSSOLVERS_MULTIPHYSICS_HYDROFRACTURESOLVERKERNELS_HPP_
29 namespace hydrofractureSolverKernels
35 template<
typename POLICY,
typename HYDRAULICAPERTURE_WRAPPER,
typename POROUS_WRAPPER >
36 static std::tuple< double, double, double, double, double, double >
38 HYDRAULICAPERTURE_WRAPPER
const & hydraulicApertureWrapper,
39 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,
69 if( elemsToFaces.sizeOfArray( kfe ) != 2 )
74 localIndex const numNodesPerFace = faceToNodeMap.sizeOfArray( kf0 );
78 LvArray::tensorOps::add< 3 >( temp, u[ faceToNodeMap( kf0, a ) ] );
79 LvArray::tensorOps::subtract< 3 >( temp, u[ faceToNodeMap( kf1, a ) ] );
83 real64 const normalJump = -LvArray::tensorOps::AiBi< 3 >( temp, faceNormal[kf0] ) / numNodesPerFace;
84 maxApertureChange.max( std::fabs( normalJump - aperture[kfe] ));
85 aperture[kfe] = normalJump;
86 minAperture.min( aperture[kfe] );
87 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],
94 dHydraulicAperture_dNormalJump,
95 dHydraulicAperture_dNormalTraction );
97 maxHydraulicApertureChange.max( std::fabs( newHydraulicAperture - hydraulicAperture[kfe] ));
98 real64 const oldHydraulicAperture = hydraulicAperture[kfe];
99 hydraulicAperture[kfe] = newHydraulicAperture;
100 minHydraulicAperture.min( hydraulicAperture[kfe] );
101 maxHydraulicAperture.max( hydraulicAperture[kfe] );
103 real64 const jump[3] = { normalJump, 0.0, 0.0 };
104 real64 const traction[3] = {0.0, 0.0, 0.0};
106 porousMaterialWrapper.updateStateFromPressureApertureJumpAndTraction( kfe, 0, 0.0,
107 oldHydraulicAperture, newHydraulicAperture,
108 dHydraulicAperture_dNormalJump,
111 #ifdef GEOS_USE_SEPARATION_COEFFICIENT
112 real64 const s = aperture[kfe] / apertureAtFailure[kfe];
113 if( separationCoeff0[kfe]<1.0 && s>separationCoeff0[kfe] )
117 separationCoeff[kfe] = 1.0;
118 dSeparationCoeff_dAper[kfe] = 0.0;
122 separationCoeff[kfe] = s;
123 dSeparationCoeff_dAper[kfe] = 1.0/apertureAtFailure[kfe];
127 deltaVolume[kfe] = hydraulicAperture[kfe] * area[kfe] - volume[kfe];
130 return std::make_tuple( maxApertureChange.get(), maxHydraulicApertureChange.get(), minAperture.get(), maxAperture.get(), minHydraulicAperture.get(), maxHydraulicAperture.get() );
136 template<
typename HYDRAULICAPERTURE_WRAPPER >
140 computeAccumulationDerivative( HYDRAULICAPERTURE_WRAPPER
const & hydraulicApertureWrapper,
145 real64 const (&Nbar)[ 3 ],
152 real64 dHydraulicAperture_dNormalJump = 0.0;
153 real64 dHydraulicAperture_dTraction = 0.0;
154 real64 fractureTraction = 0.0;
155 real64 const hydraulicAperture = hydraulicApertureWrapper.computeHydraulicAperture( aperture,
157 dHydraulicAperture_dNormalJump,
158 dHydraulicAperture_dTraction );
161 constexpr
integer kfSign[2] = { -1, 1 };
164 for(
localIndex a = 0; a < numNodesPerFace; ++a )
166 for(
int i = 0; i < 3; ++i )
168 nodeDOF[kf * 3 * numNodesPerFace + 3 * a + i] = dispDofNumber[faceToNodeMap( elemsToFaces[kf], a )] + i;
170 real64 const dNormalJump_dDisplacement = kfSign[kf] * Nbar[i] / numNodesPerFace;
171 real64 const dHydraulicAperture_dDisplacement = dHydraulicAperture_dNormalJump * dNormalJump_dDisplacement;
172 real64 const dVolume_dDisplacement = area * dHydraulicAperture_dDisplacement;
174 dRdU( kf * 3 * numNodesPerFace + 3 * a + i ) = dens * dVolume_dDisplacement;
190 real64 const (&Nbar)[ 3 ],
194 constexpr
integer kfSign[2] = { -1, 1 };
196 real64 const dR_dNormalJump = values[kfe2];
201 for(
localIndex a = 0; a < numNodesPerFace; ++a )
205 nodeDOF[kf * 3 * numNodesPerFace + 3 * a + i] = dispDofNumber[faceToNodeMap( elemsToFaces[ei2][kf], a )] + i;
207 real64 const dNormalJump_dDisplacement = kfSign[kf] * Nbar[i] / numNodesPerFace;
209 dRdU( kf * 3 * numNodesPerFace + 3 * a + i ) = dR_dNormalJump * dNormalJump_dDisplacement;
215 template<
typename POLICY,
typename HYDRAULICAPERTURE_WRAPPER >
219 HYDRAULICAPERTURE_WRAPPER
const & hydraulicApertureWrapper,
234 localIndex const numNodesPerFace = faceToNodeMap.sizeOfArray( elemsToFaces[ei][0] );
236 real64 Nbar[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( faceNormal[elemsToFaces[ei][0]] );
237 LvArray::tensorOps::subtract< 3 >( Nbar, faceNormal[elemsToFaces[ei][1]] );
238 LvArray::tensorOps::normalize< 3 >( Nbar );
240 globalIndex const rowNumber = presDofNumber[ei] - rankOffset;
244 computeAccumulationDerivative( hydraulicApertureWrapper,
256 if( rowNumber >= 0 && rowNumber < localMatrix.numRows() )
258 localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( rowNumber,
261 2 * numNodesPerFace * 3 );
264 if( useQuasiNewton == 0 )
266 localIndex const numColumns = dFluxResidual_dNormalJump.numNonZeros( ei );
270 for(
localIndex kfe2 = 0; kfe2 < numColumns; ++kfe2 )
272 computeFluxDerivative( kfe2,
283 if( rowNumber >= 0 && rowNumber < localMatrix.numRows() )
285 localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( rowNumber,
288 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.
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).
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.
std::int32_t integer
Signed integer type.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.