20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELLCONSTRAINTKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELLCONSTRAINTKERNELS_HPP
23 #include "codingUtilities/Utilities.hpp"
24 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
25 #include "constitutive/fluid/singlefluid/SingleFluidFields.hpp"
28 #include "physicsSolvers/fluidFlow/wells/WellControls.hpp"
29 #include "physicsSolvers/fluidFlow/wells/WellBHPConstraints.hpp"
30 #include "physicsSolvers/fluidFlow/wells/WellVolumeRateConstraint.hpp"
36 namespace singlePhaseWellConstraintKernels
42 template<
integer IS_THERMAL >
45 template< BHPConstra
intTypeId I >
46 static void assembleConstraintEquation(
real64 const & time_n,
50 string const & wellDofKey,
69 using Deriv = constitutive::singlefluid::DerivativeOffsetC< IS_THERMAL >;
71 localIndex const eqnRowIndex = wellElemDofNumber[iwelemRef] + ROFFSET_WJ::CONTROL - rankOffset;
73 for(
integer i = 0; i < COFFSET_WJ::nDer; ++i )
75 dofColIndices[ i ] = wellElemDofNumber[iwelemRef] + i;
82 real64 const & currentBHP =
83 wellControls.
getReference<
real64 >( SinglePhaseWell::viewKeyStruct::currentBHPString() );
86 real64 controlEqn = currentBHP - targetBHP;
89 real64 dControlEqn[2+IS_THERMAL]{};
92 forAll< serialPolicy >( 1, [pres,
100 real64 const diffGravCoef = refGravCoef - wellElemGravCoef[iwelemRef];
101 dControlEqn[COFFSET_WJ::dP] = 1.0 + dDensity[iwelemRef][0][Deriv::dP] *diffGravCoef;
102 if constexpr ( IS_THERMAL )
104 dControlEqn[COFFSET_WJ::dT] = dDensity[iwelemRef][0][Deriv::dT] * diffGravCoef;
109 localRhs[eqnRowIndex] += controlEqn;
110 localMatrix.addToRowBinarySearchUnsorted< serialAtomic >( eqnRowIndex,
116 static void assembleConstraintEquation(
real64 const & time_n,
118 T< VolumeRateConstraint > & constraint,
120 string const & wellDofKey,
134 using Deriv = constitutive::singlefluid::DerivativeOffsetC< IS_THERMAL >;
136 localIndex const eqnRowIndex = wellElemDofNumber[iwelemRef] + ROFFSET_WJ::CONTROL - rankOffset;
138 for(
integer i = 0; i < COFFSET_WJ::nDer; ++i )
140 dofColIndices[ i ] = wellElemDofNumber[iwelemRef] + i;
153 wellControls.
getReference<
real64 >( WellControls::viewKeyStruct::currentVolRateString() );
158 real64 controlEqn = currentVolRate - targetVolRate;
161 real64 dControlEqn[2+IS_THERMAL]{};
164 forAll< serialPolicy >( 1, [currentVolRate,
168 &useSurfaceConditions,
172 real64 const densInv = 1.0 / density[iwelemRef][0];
174 dControlEqn[COFFSET_WJ::dP] = -( useSurfaceConditions == 0 ) * dDensity[iwelemRef][0][Deriv::dP] * currentVolRate * densInv;
175 dControlEqn[COFFSET_WJ::dQ] = densInv;
176 if constexpr ( IS_THERMAL )
178 dControlEqn[COFFSET_WJ::dT] = -( useSurfaceConditions == 0 ) * dDensity[iwelemRef][0][Deriv::dT] * currentVolRate * densInv;
184 localRhs[eqnRowIndex] += controlEqn;
185 localMatrix.addToRowBinarySearchUnsorted< serialAtomic >( eqnRowIndex,
This class describes a minimum pressure constraint used to control a injection well.
real64 getReferenceGravityCoef() const
Getter for the reference gravity coefficient.
GEOS_DECLTYPE_AUTO_RETURN getField() const
Get a view to the field associated with a trait from this ObjectManagerBase.
This class describes a volume rate constraint used to control a well.
real64 getConstraintValue(real64 const ¤tTime) const
Get the target bottom hole pressure value.
This class describes the controls used to operate a well.
This class describes a collection of local well elements and perforations.
localIndex getTopWellElementIndex() const
Get for the top element index.
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
integer useSurfaceConditions() const
Getter for the flag specifying whether we check rates at surface or reservoir conditions.
constitutive::SingleFluidBase & getSingleFluidSeparator()
Getter for single fluid separator.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
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.
Array< T, 1 > array1d
Alias for 1D array.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.