20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_FLUXCOMPUTEKERNEL_HPP 
   21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_FLUXCOMPUTEKERNEL_HPP 
   25 #include "codingUtilities/Utilities.hpp" 
   28 #include "common/GEOS_RAJA_Interface.hpp" 
   29 #include "constitutive/fluid/multifluid/MultiFluidFields.hpp" 
   34 #include "physicsSolvers/fluidFlow/kernels/compositional/KernelLaunchSelectors.hpp" 
   38 #include "physicsSolvers/fluidFlow/kernels/compositional/HU2PhaseFlux.hpp" 
   44 namespace isothermalCompositionalMultiphaseFVMKernels
 
   54 template< 
integer NUM_COMP, 
integer NUM_DOF, 
typename STENCILWRAPPER >
 
   97                      STENCILWRAPPER 
const & stencilWrapper,
 
   98                      DofNumberAccessor 
const & dofNumberAccessor,
 
  106                      BitFlags< KernelFlags > kernelFlags )
 
  116     m_permeability( permeabilityAccessors.get( fields::permeability::permeability {} ) ),
 
  117     m_dPerm_dPres( permeabilityAccessors.get( fields::permeability::dPerm_dPressure {} ) ),
 
  118     m_phaseMob( compFlowAccessors.get( fields::flow::phaseMobility {} ) ),
 
  119     m_dPhaseMob( compFlowAccessors.get( fields::flow::dPhaseMobility {} ) ),
 
  120     m_phaseMassDens( multiFluidAccessors.get( fields::multifluid::phaseMassDensity {} ) ),
 
  121     m_dPhaseMassDens( multiFluidAccessors.get( fields::multifluid::dPhaseMassDensity {} ) ),
 
  122     m_phaseCapPressure( capPressureAccessors.get( fields::cappres::phaseCapPressure {} ) ),
 
  123     m_dPhaseCapPressure_dPhaseVolFrac( capPressureAccessors.get( fields::cappres::dPhaseCapPressure_dPhaseVolFraction {} ) ),
 
  125     m_seri( stencilWrapper.getElementRegionIndices() ),
 
  126     m_sesri( stencilWrapper.getElementSubRegionIndices() ),
 
  127     m_sei( stencilWrapper.getElementIndices() )
 
  226   template< 
typename FUNC = NoOpFunc >
 
  231                     FUNC && compFluxKernelOp = NoOpFunc{} ) 
const 
  233     using namespace isothermalCompositionalMultiphaseFVMKernelUtilities;
 
  275           real64 dPhaseFlux_dTrans = 0.0; 
 
  277           if( m_kernelFlags.isSet( KernelFlags::C1PPU ) )
 
  279             C1PPUPhaseFlux::compute< numComp, numFluxSupportPoints >
 
  282               m_kernelFlags.isSet( KernelFlags::CapPressure ),
 
  283               m_kernelFlags.isSet( KernelFlags::CheckPhasePresenceInGravity ),
 
  299           else if( m_kernelFlags.isSet( KernelFlags::IHU ) )
 
  301             IHUPhaseFlux::compute< numComp, numFluxSupportPoints >
 
  304               m_kernelFlags.isSet( KernelFlags::CapPressure ),
 
  305               m_kernelFlags.isSet( KernelFlags::CheckPhasePresenceInGravity ),
 
  321           else if( m_kernelFlags.isSet( KernelFlags::HU2PH ) )
 
  323             HU2PhaseFlux::compute< numComp, numFluxSupportPoints >
 
  326               m_kernelFlags.isSet( KernelFlags::CapPressure ),
 
  327               m_kernelFlags.isSet( KernelFlags::CheckPhasePresenceInGravity ),
 
  345             PPUPhaseFlux::compute< numComp, numFluxSupportPoints >
 
  348               m_kernelFlags.isSet( KernelFlags::CapPressure ),
 
  349               m_kernelFlags.isSet( KernelFlags::CheckPhasePresenceInGravity ),
 
  368           localIndex const k_up = (phaseFlux >= 0) ? 0 : 1;
 
  371           PhaseComponentFlux::compute( ip, k_up, seri, sesri, sei,
 
  373                                        phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC, dPhaseFlux_dTrans,
 
  374                                        compFlux, dCompFlux_dP, dCompFlux_dC, dCompFlux_dTrans );
 
  378           compFluxKernelOp( ip, m_kernelFlags.isSet( KernelFlags::CheckPhasePresenceInGravity ),
 
  379                             k, seri, sesri, sei, connectionIndex,
 
  380                             k_up, seri[k_up], sesri[k_up], sei[k_up], potGrad,
 
  381                             phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC );
 
  402               localIndex const localDofIndexComp = localDofIndexPres + jc + 1;
 
  419   template< 
typename FUNC = NoOpFunc >
 
  424                  FUNC && assemblyKernelOp = NoOpFunc{} ) 
const 
  426     using namespace compositionalMultiphaseUtilities;
 
  428     if( m_kernelFlags.isSet( KernelFlags::TotalMassEquation ) )
 
  443       if( 
m_ghostRank[
m_seri( iconn, i )][m_sesri( iconn, i )][m_sei( iconn, i )] < 0 )
 
  452           RAJA::atomicAdd( parallelDeviceAtomic{}, &
m_localRhs[localRow + ic],
 
  454           m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >
 
  462         assemblyKernelOp( i, localRow );
 
  474   template< 
typename POLICY, 
typename KERNEL_TYPE >
 
  477           KERNEL_TYPE 
const & kernelComponent )
 
  482       typename KERNEL_TYPE::StackVariables stack( kernelComponent.stencilSize( iconn ),
 
  483                                                   kernelComponent.numPointsInFlux( iconn ) );
 
  485       kernelComponent.setup( iconn, stack );
 
  486       kernelComponent.computeFlux( iconn, stack );
 
  487       kernelComponent.complete( iconn, stack );
 
  515   typename STENCILWRAPPER::IndexContainerViewConstType 
const m_seri;
 
  516   typename STENCILWRAPPER::IndexContainerViewConstType 
const m_sesri;
 
  517   typename STENCILWRAPPER::IndexContainerViewConstType 
const m_sei;
 
  544   template< 
typename POLICY, 
typename STENCILWRAPPER >
 
  549                    string const & dofKey,
 
  550                    BitFlags< KernelFlags > kernelFlags,
 
  551                    string const & solverName,
 
  553                    STENCILWRAPPER 
const & stencilWrapper,
 
  558     isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&]( 
auto NC )
 
  560       integer constexpr NUM_COMP = NC();
 
  561       integer constexpr NUM_DOF = NC() + 1;
 
  565       dofNumberAccessor.setName( solverName + 
"/accessors/" + dofKey );
 
  568       typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName );
 
  569       typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName );
 
  570       typename kernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName );
 
  571       typename kernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
 
  573       kernelType kernel( numPhases, rankOffset, stencilWrapper, dofNumberAccessor,
 
  574                          compFlowAccessors, multiFluidAccessors, capPressureAccessors, permeabilityAccessors,
 
  575                          dt, localMatrix, localRhs, kernelFlags );
 
  576       kernelType::template launch< POLICY >( stencilWrapper.size(), kernel );
 
#define GEOS_HOST_DEVICE
Marks a host-device function.
 
#define GEOS_ASSERT_GT(lhs, rhs)
Assert that one value compares greater than the other in debug builds.
 
#define GEOS_ASSERT_GE(lhs, rhs)
Assert that one value compares greater than or equal to the other in debug builds.
 
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
 
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.
 
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< arrayView2d< real64 const, compflow::USD_PHASE > > const m_phaseVolFrac
Views on phase volume fractions.
 
real64 const m_dt
Time step size.
 
ElementViewConst< arrayView1d< globalIndex const > > const m_dofNumber
Views on dof numbers.
 
ElementViewConst< arrayView1d< real64 const > > const m_pres
Views on pressure.
 
ElementViewConst< arrayView1d< integer const > > const m_ghostRank
Views on ghost rank numbers and gravity coefficients.
 
arrayView1d< real64 > const m_localRhs
View on the local RHS.
 
ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const m_phaseCompFrac
Views on phase component fractions.
 
globalIndex const m_rankOffset
Offset for my MPI rank.
 
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
 
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
 
ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const m_dCompFrac_dCompDens
Views on derivatives of comp fractions.
 
integer const m_numPhases
Number of fluid phases.
 
static void createAndLaunch(integer const numComps, integer const numPhases, globalIndex const rankOffset, string const &dofKey, BitFlags< KernelFlags > kernelFlags, 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 localIndex maxStencilSize
Maximum number of points in the stencil.
 
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&compFluxKernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
 
GEOS_HOST_DEVICE localIndex numPointsInFlux(localIndex const iconn) const
Getter for the number of elements at this connection.
 
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&assemblyKernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
 
static constexpr integer numFluxSupportPoints
Number of flux support points (hard-coded for TFPA)
 
static constexpr integer numEqn
Compute time value for the number of equations (all of them, except the volume balance equation)
 
GEOS_HOST_DEVICE localIndex stencilSize(localIndex const iconn) const
Getter for the stencil size at this connection.
 
static constexpr integer numComp
Compile time value for the number of components.
 
ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > > const m_phaseMassDens
Views on phase mass densities.
 
ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_phaseMob
Views on phase mobilities.
 
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
 
static constexpr localIndex maxNumElems
Maximum number of elements at the face.
 
FluxComputeKernel(integer const numPhases, globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, CompFlowAccessors const &compFlowAccessors, MultiFluidAccessors const &multiFluidAccessors, CapPressureAccessors const &capPressureAccessors, PermeabilityAccessors const &permeabilityAccessors, real64 const dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< KernelFlags > kernelFlags)
Constructor for the kernel interface.
 
ElementViewConst< arrayView3d< real64 const, constitutive::cappres::USD_CAPPRES > > const m_phaseCapPressure
Views on phase capillary pressure.
 
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
 
ElementViewConst< arrayView3d< real64 const > > const m_permeability
Views on permeability.
 
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
 
GEOS_HOST_DEVICE void setup(localIndex const iconn, StackVariables &stack) const
Performs the setup phase for the kernel.
 
static void launch(localIndex const numConnections, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
 
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
 
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
 
StackArray< T, 2, MAXSIZE > stackArray2d
Alias for 2D stack array.
 
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
 
StackArray< T, 1, MAXSIZE > stackArray1d
Alias for 1D stack array.
 
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.
 
int integer
Signed integer type.
 
Kernel variables (dof numbers, jacobian and residual) located on the stack.
 
real64 dTrans_dPres[maxNumConns][numFluxSupportPoints]
Derivatives of transmissibility with respect to pressure.
 
stackArray1d< globalIndex, maxNumElems *numDof > dofColIndices
Indices of the matrix rows/columns corresponding to the dofs in this face.
 
stackArray2d< real64, maxNumElems *numEqn *maxStencilSize *numDof > localFluxJacobian
Storage for the face local Jacobian matrix.
 
stackArray1d< real64, maxNumElems *numEqn > localFlux
Storage for the face local residual vector (all equations except volume balance)
 
localIndex const numConnectedElems
Number of elements connected at a given connection.
 
real64 transmissibility[maxNumConns][numFluxSupportPoints]
Transmissibility.
 
localIndex const stencilSize
Stencil size for a given connection.
 
GEOS_HOST_DEVICE StackVariables(localIndex const size, localIndex numElems)
Constructor for the stack variables.