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"
25 #include "constitutive/fluid/singlefluid/SingleFluidLayouts.hpp"
27 #include "common/GEOS_RAJA_Interface.hpp"
31 #include "physicsSolvers/fluidFlow/wells/WellControls.hpp"
37 namespace singlePhaseWellKernels
43 static constexpr
integer RES = 0;
44 static constexpr
integer WELL = 1;
50 static constexpr
integer CURRENT = 0;
51 static constexpr
integer NEXT = 1;
57 static constexpr
integer DPRES = 0;
58 static constexpr
integer DRATE = 1;
64 static constexpr
integer CONTROL = 0;
65 static constexpr
integer MASSBAL = 1;
78 static constexpr
real64 EPS = 1e-15;
84 switchControl(
bool const isProducer,
89 real64 const & currentVolRate,
100 real64 const & currentBHP,
101 real64 const & dCurrentBHP_dPres,
102 real64 const & currentVolRate,
103 real64 const & dCurrentVolRate_dPres,
104 real64 const & dCurrentVolRate_dRate,
146 bool const isLocallyOwned,
149 real64 const & timeAtEndOfStep,
174 fields::singlefluid::density,
175 fields::singlefluid::dDensity,
176 fields::singlefluid::viscosity,
177 fields::singlefluid::dViscosity >;
186 template<
typename VIEWTYPE >
193 compute(
real64 const & resPressure,
194 real64 const & resDensity,
195 real64 const & dResDensity_dPres,
196 real64 const & resViscosity,
197 real64 const & dResViscosity_dPres,
198 real64 const & wellElemGravCoef,
199 real64 const & wellElemPressure,
200 real64 const & wellElemDensity,
201 real64 const & dWellElemDensity_dPres,
202 real64 const & wellElemViscosity,
203 real64 const & dWellElemViscosity_dPres,
204 real64 const & perfGravCoef,
265 fields::singlefluid::density >;
274 template<
typename VIEWTYPE >
282 real64 const & currentTime,
302 real64 const & currentTime,
329 constitutive::SingleFluidBase
const & fluid,
331 real64 const timeAtEndOfStep,
333 real64 const minNormalizer )
343 m_targetBHP( wellControls.
getTargetBHP( timeAtEndOfStep ) ),
351 LinfStackVariables & stack )
const override
356 if( idof == singlePhaseWellKernels::RowOffset::CONTROL )
364 normalizer = m_targetBHP;
369 normalizer = LvArray::math::max( LvArray::math::abs( m_targetRate ),
m_minNormalizer );
376 normalizer = m_targetBHP;
382 normalizer =
m_dt * LvArray::math::abs( m_targetRate ) *
m_density_n[iwelem][0];
390 if( val > stack.localValue[0] )
392 stack.localValue[0] = val;
400 L2StackVariables & stack )
const override
403 GEOS_ERROR(
"The L2 norm is not implemented for SinglePhaseWell" );
421 real64 const m_targetRate;
451 template<
typename POLICY >
454 string const & dofKey,
457 constitutive::SingleFluidBase
const & fluid,
459 real64 const timeAtEndOfStep,
461 real64 const minNormalizer,
462 real64 (& residualNorm)[1] )
467 ResidualNormKernel kernel( rankOffset, localResidual, dofNumber, ghostRank, subRegion, fluid, wellControls, timeAtEndOfStep, dt, minNormalizer );
468 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.
bool const m_isLocallyOwned
Flag indicating whether the well is locally owned or not.
arrayView1d< real64 const > const m_volume
View on the volume.
arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > const m_density_n
View on total density at the previous converged time step.
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.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
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.