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 static void assembleConstraintEquation(
real64 const & time_n,
49 string const & wellDofKey,
68 using Deriv = constitutive::singlefluid::DerivativeOffsetC< IS_THERMAL >;
70 localIndex const eqnRowIndex = wellElemDofNumber[iwelemRef] + ROFFSET_WJ::CONTROL - rankOffset;
72 for(
integer i = 0; i < COFFSET_WJ::nDer; ++i )
74 dofColIndices[ i ] = wellElemDofNumber[iwelemRef] + i;
81 real64 const & currentBHP =
82 wellControls.
getReference<
real64 >( SinglePhaseWell::viewKeyStruct::currentBHPString() );
85 real64 controlEqn = currentBHP - targetBHP;
88 real64 dControlEqn[2+IS_THERMAL]{};
91 forAll< serialPolicy >( 1, [pres,
99 real64 const diffGravCoef = refGravCoef - wellElemGravCoef[iwelemRef];
100 dControlEqn[COFFSET_WJ::dP] = 1.0 + dDensity[iwelemRef][0][Deriv::dP] *diffGravCoef;
101 if constexpr ( IS_THERMAL )
103 dControlEqn[COFFSET_WJ::dT] = dDensity[iwelemRef][0][Deriv::dT] * diffGravCoef;
108 localRhs[eqnRowIndex] += controlEqn;
109 localMatrix.addToRowBinarySearchUnsorted< serialAtomic >( eqnRowIndex,
115 static void assembleConstraintEquation(
real64 const & time_n,
117 T< VolumeRateConstraint > & constraint,
119 string const & wellDofKey,
133 using Deriv = constitutive::singlefluid::DerivativeOffsetC< IS_THERMAL >;
135 localIndex const eqnRowIndex = wellElemDofNumber[iwelemRef] + ROFFSET_WJ::CONTROL - rankOffset;
137 for(
integer i = 0; i < COFFSET_WJ::nDer; ++i )
139 dofColIndices[ i ] = wellElemDofNumber[iwelemRef] + i;
152 wellControls.
getReference<
real64 >( SinglePhaseWell::viewKeyStruct::currentVolRateString() );
157 real64 controlEqn = currentVolRate - targetVolRate;
160 real64 dControlEqn[2+IS_THERMAL]{};
163 forAll< serialPolicy >( 1, [currentVolRate,
167 &useSurfaceConditions,
171 real64 const densInv = 1.0 / density[iwelemRef][0];
173 dControlEqn[COFFSET_WJ::dP] = -( useSurfaceConditions == 0 ) * dDensity[iwelemRef][0][Deriv::dP] * currentVolRate * densInv;
174 dControlEqn[COFFSET_WJ::dQ] = densInv;
175 if constexpr ( IS_THERMAL )
177 dControlEqn[COFFSET_WJ::dT] = -( useSurfaceConditions == 0 ) * dDensity[iwelemRef][0][Deriv::dT] * currentVolRate * densInv;
183 localRhs[eqnRowIndex] += controlEqn;
184 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.
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.
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.
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.