20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_STABILIZEDFLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_STABILIZEDFLUXCOMPUTEKERNEL_HPP
28 namespace stabilizedSinglePhaseFVMKernels
39 template<
integer NUM_EQN,
integer NUM_DOF,
typename STENCILWRAPPER >
44 template<
typename VIEWTYPE >
48 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
55 fields::flow::elementStabConstant,
56 fields::flow::pressure_n >;
60 fields::singlefluid::density_n >;
66 using AbstractBase::m_gravCoef;
95 STENCILWRAPPER
const & stencilWrapper,
96 DofNumberAccessor
const & dofNumberAccessor,
108 singlePhaseFlowAccessors,
109 singlePhaseFluidAccessors,
110 permeabilityAccessors,
114 m_pres_n( stabSinglePhaseFlowAccessors.get( fields::flow::pressure_n {} ) ),
115 m_dens_n( stabSinglePhaseFluidAccessors.get( fields::singlefluid::density_n {} ) ),
116 m_macroElementIndex( stabSinglePhaseFlowAccessors.get( fields::flow::macroElementIndex {} ) ),
117 m_elementStabConstant( stabSinglePhaseFlowAccessors.get( fields::flow::elementStabConstant {} ) )
168 real64 const (&dFlux_dP)[2] )
181 real64 dPresGradStab = 0.0;
182 integer stencilMacroElements[2]{};
194 dPresGradStab += m_elementStabConstant[er][esr][ei] * stabTrans[ke] * (
m_pres[er][esr][ei] -
m_pres_n[er][esr][ei]);
198 integer const k_up_stab = (dPresGradStab >= 0) ? 0 : 1;
200 localIndex const er_up_stab = seri[k_up_stab];
201 localIndex const esr_up_stab = sesri[k_up_stab];
204 bool const areInSameMacroElement = stencilMacroElements[0] == stencilMacroElements[1];
205 bool const isStabilizationActive = stencilMacroElements[0] >= 0 && stencilMacroElements[1] >= 0;
206 if( isStabilizationActive && areInSameMacroElement )
209 real64 const laggedUpwindCoef = m_dens_n[er_up_stab][esr_up_stab][ei_up_stab][0];
210 stabFlux += dPresGradStab * laggedUpwindCoef;
214 real64 const tauStab = m_elementStabConstant[seri[ke]][sesri[ke]][sei[ke]];
215 dStabFlux_dP[ke] += tauStab * stabTrans[ke] * laggedUpwindCoef;
240 ElementViewConst< arrayView1d< real64 const > >
const m_pres_n;
241 ElementViewConst< arrayView2d< real64 const > >
const m_dens_n;
245 ElementViewConst< arrayView1d< real64 const > >
const m_elementStabConstant;
269 template<
typename POLICY,
typename STENCILWRAPPER >
272 string const & dofKey,
273 string const & solverName,
275 STENCILWRAPPER
const & stencilWrapper,
286 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
289 typename KERNEL_TYPE::SinglePhaseFlowAccessors singlePhaseFlowAccessors( elemManager, solverName );
290 typename KERNEL_TYPE::SinglePhaseFluidAccessors singlePhaseFluidAccessors( elemManager, solverName );
291 typename KERNEL_TYPE::StabSinglePhaseFlowAccessors stabSinglePhaseFlowAccessors( elemManager, solverName );
292 typename KERNEL_TYPE::StabSinglePhaseFluidAccessors stabSinglePhaseFluidAccessors( elemManager, solverName );
293 typename KERNEL_TYPE::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
295 KERNEL_TYPE kernel( rankOffset, stencilWrapper, dofNumberAccessor,
296 singlePhaseFlowAccessors, stabSinglePhaseFlowAccessors, singlePhaseFluidAccessors, stabSinglePhaseFluidAccessors,
297 permeabilityAccessors,
298 dt, localMatrix, localRhs );
299 KERNEL_TYPE::template launch< POLICY >( stencilWrapper.size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
ElementViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > constructArrayViewAccessor(string const &name, string const &neighborName=string()) const
This is a function to construct a ElementViewAccessor to access array data registered on the mesh.
array1d< array1d< VIEWTYPE > > ElementViewAccessor
The ElementViewAccessor at the ElementRegionManager level is an array of array of VIEWTYPE.
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
ElementViewConst< arrayView1d< integer const > > const m_ghostRank
Views on ghost rank numbers and gravity coefficients.
ElementViewConst< arrayView1d< globalIndex const > > const m_dofNumber
Views on dof numbers.
ElementViewConst< arrayView1d< real64 const > > const m_pres
Views on pressure.
real64 const m_dt
Time step size.
globalIndex const m_rankOffset
Offset for my MPI rank.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
static constexpr localIndex maxStencilSize
Maximum number of points in the stencil.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
static constexpr localIndex maxNumElems
Maximum number of elements at the face.
static void createAndLaunch(globalIndex const rankOffset, string const &dofKey, string const &solverName, ElementRegionManager const &elemManager, STENCILWRAPPER const &stencilWrapper, real64 const dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Create a new kernel and launch.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
ElementViewConst< arrayView1d< integer const > > const m_macroElementIndex
Views on the macroelement indices and stab constant.
FluxComputeKernel(globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, SinglePhaseFlowAccessors const &singlePhaseFlowAccessors, StabSinglePhaseFlowAccessors const &stabSinglePhaseFlowAccessors, SinglePhaseFluidAccessors const &singlePhaseFluidAccessors, StabSinglePhaseFluidAccessors const &stabSinglePhaseFluidAccessors, PermeabilityAccessors const &permeabilityAccessors, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Constructor for the kernel interface.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
ElementViewConst< arrayView1d< real64 const > > const m_pres
Views on pressure.
ElementViewConst< arrayView1d< real64 const > > const m_pres_n
Views on flow properties at the previous converged time step.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack) const
Compute the local flux contributions to the residual and Jacobian, including stabilization.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
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).
std::int32_t integer
Signed integer type.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 dTrans_dPres[maxNumConns][2]
Derivatives of transmissibility with respect to pressure.
real64 transmissibility[maxNumConns][2]
Transmissibility.
stackArray1d< globalIndex, maxNumElems *numDof > dofColIndices
Indices of the matrix rows/columns corresponding to the dofs in this face.
stackArray1d< real64, maxNumElems *numEqn > localFlux
Storage for the face local residual vector (all equations except volume balance)
localIndex const stencilSize
Stencil size for a given connection.
stackArray2d< real64, maxNumElems *numEqn *maxStencilSize *numDof > localFluxJacobian
Storage for the face local Jacobian matrix.
localIndex const numFluxElems
Number of elements for a given connection.
real64 stabTransmissibility[maxNumConns][2]
Stabilization transmissibility.