20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELLKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELLKERNELS_HPP
23 #include "constitutive/fluid/singlefluid/SingleFluidFields.hpp"
24 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
26 #include "common/GEOS_RAJA_Interface.hpp"
30 #include "physicsSolvers/fluidFlow/wells/WellControls.hpp"
36 namespace singlePhaseWellKernels
42 static constexpr
integer RES = 0;
43 static constexpr
integer WELL = 1;
49 static constexpr
integer CURRENT = 0;
50 static constexpr
integer NEXT = 1;
56 static constexpr
integer DPRES = 0;
57 static constexpr
integer DRATE = 1;
63 static constexpr
integer CONTROL = 0;
64 static constexpr
integer MASSBAL = 1;
77 static constexpr
real64 EPS = 1e-15;
83 switchControl(
bool const isProducer,
88 real64 const & currentVolRate,
100 real64 const & dCurrentBHP_dPres,
101 real64 const & currentVolRate,
102 real64 const & dCurrentVolRate_dPres,
103 real64 const & dCurrentVolRate_dRate,
145 bool const isLocallyOwned,
148 real64 const & timeAtEndOfStep,
173 fields::singlefluid::density,
174 fields::singlefluid::dDensity_dPressure,
175 fields::singlefluid::viscosity,
176 fields::singlefluid::dViscosity_dPressure >;
185 template<
typename VIEWTYPE >
192 compute(
real64 const & resPressure,
193 real64 const & resDensity,
194 real64 const & dResDensity_dPres,
195 real64 const & resViscosity,
196 real64 const & dResViscosity_dPres,
197 real64 const & wellElemGravCoef,
198 real64 const & wellElemPressure,
199 real64 const & wellElemDensity,
200 real64 const & dWellElemDensity_dPres,
201 real64 const & wellElemViscosity,
202 real64 const & dWellElemViscosity_dPres,
203 real64 const & perfGravCoef,
264 fields::singlefluid::density >;
273 template<
typename VIEWTYPE >
281 real64 const & currentTime,
301 real64 const & currentTime,
328 constitutive::SingleFluidBase
const & fluid,
330 real64 const timeAtEndOfStep,
332 real64 const minNormalizer )
342 m_targetBHP( wellControls.
getTargetBHP( timeAtEndOfStep ) ),
350 LinfStackVariables & stack )
const override
355 if( idof == singlePhaseWellKernels::RowOffset::CONTROL )
363 normalizer = m_targetBHP;
368 normalizer = LvArray::math::max( LvArray::math::abs( m_targetRate ),
m_minNormalizer );
375 normalizer = m_targetBHP;
381 normalizer =
m_dt * LvArray::math::abs( m_targetRate ) *
m_density_n[iwelem][0];
389 if( val > stack.localValue[0] )
391 stack.localValue[0] = val;
399 L2StackVariables & stack )
const override
402 GEOS_ERROR(
"The L2 norm is not implemented for SinglePhaseWell" );
420 real64 const m_targetRate;
450 template<
typename POLICY >
453 string const & dofKey,
456 constitutive::SingleFluidBase
const & fluid,
458 real64 const timeAtEndOfStep,
460 real64 const minNormalizer,
461 real64 (& residualNorm)[1] )
466 ResidualNormKernel kernel( rankOffset, localResidual, dofNumber, ghostRank, subRegion, fluid, wellControls, timeAtEndOfStep, dt, minNormalizer );
467 ResidualNormKernel::launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
arrayView1d< real64 const > getElementVolume() const
Get the volume of each element in this subregion.
array1d< integer > const & ghostRank()
Get the ghost information of each object.
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
This class describes the controls used to operate a well.
Control getControl() const
Get the control type for the well.
real64 getTargetTotalRate(real64 const ¤tTime) const
Get the target total rate.
real64 getTargetBHP(real64 const ¤tTime) const
Get the target bottom hole pressure value.
This class describes a collection of local well elements and perforations.
bool isLocallyOwned() const
Check if well is owned by current rank.
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.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Define the base interface for the residual calculations.
real64 const m_minNormalizer
Value used to make sure that normalizers are never zero.
arrayView1d< globalIndex const > const m_dofNumber
View on the dof numbers.
GEOS_HOST_DEVICE integer ghostRank(localIndex const i) const
Getter for the ghost rank.
globalIndex const m_rankOffset
Offset for my MPI rank.
arrayView1d< real64 const > const m_localResidual
View on the local residual.
static void createAndLaunch(globalIndex const rankOffset, string const &dofKey, arrayView1d< real64 const > const &localResidual, WellElementSubRegion const &subRegion, constitutive::SingleFluidBase const &fluid, WellControls const &wellControls, real64 const timeAtEndOfStep, real64 const dt, real64 const minNormalizer, real64(&residualNorm)[1])
Create a new kernel and launch.
real64 const m_dt
Time step size.
arrayView2d< real64 const > const m_density_n
View on total density at the previous converged time step.
bool const m_isLocallyOwned
Flag indicating whether the well is locally owned or not.
arrayView1d< real64 const > const m_volume
View on the volume.
virtual GEOS_HOST_DEVICE void computeL2(localIndex const iwelem, L2StackVariables &stack) const override
Compute the local values and normalizer for the L2 norm.
virtual GEOS_HOST_DEVICE void computeLinf(localIndex const iwelem, LinfStackVariables &stack) const override
Compute the local values for the Linf norm.
localIndex const m_iwelemControl
Index of the element where the control is enforced.
WellControls::Control const m_currentControl
Controls.
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).
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.
Array< T, 1 > array1d
Alias for 1D array.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based non-constitutive data parameters. Consists entirely of ArrayView's.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based non-constitutive data parameters. Consists entirely of ArrayView's.