20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_DIRICHLETFLUXCOMPUTEKERNEL_HPP 
   21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_DIRICHLETFLUXCOMPUTEKERNEL_HPP 
   23 #include "codingUtilities/Utilities.hpp" 
   26 #include "common/GEOS_RAJA_Interface.hpp" 
   27 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp" 
   28 #include "constitutive/fluid/multifluid/MultiFluidSelector.hpp" 
   41 namespace isothermalCompositionalMultiphaseFVMKernels
 
   53 template< 
integer NUM_COMP, 
integer NUM_DOF, 
typename FLUIDWRAPPER >
 
   56                                                              BoundaryStencilWrapper >
 
   66   template< 
typename VIEWTYPE >
 
   70   using DofNumberAccessor = AbstractBase::DofNumberAccessor;
 
   81   using AbstractBase::m_gravCoef;
 
   84   using AbstractBase::m_dPhaseCompFrac;
 
   88   using AbstractBase::m_kernelFlags;
 
   96   using Base::m_dPhaseMob;
 
   98   using Base::m_dPhaseMassDens;
 
  100   using Base::m_dPerm_dPres;
 
  126                               FLUIDWRAPPER 
const & fluidWrapper,
 
  127                               DofNumberAccessor 
const & dofNumberAccessor,
 
  135                               BitFlags< KernelFlags > kernelFlags )
 
  142             capPressureAccessors,
 
  143             permeabilityAccessors,
 
  148     m_facePres( faceManager.getField< fields::flow::facePressure >() ),
 
  149     m_faceTemp( faceManager.getField< fields::flow::faceTemperature >() ),
 
  150     m_faceCompFrac( faceManager.getField< fields::flow::faceGlobalCompFraction >() ),
 
  151     m_faceGravCoef( faceManager.getField< fields::flow::gravityCoefficient >() ),
 
  173     real64 transmissibility = 0.0;
 
  223   template< 
typename FUNC = NoOpFunc >
 
  227                     FUNC && compFluxKernelOp = NoOpFunc{} ) 
const 
  229     using Deriv = constitutive::multifluid::DerivativeOffset;
 
  233     localIndex const esr = m_sesri( iconn, Order::ELEM );
 
  234     localIndex const ei  = m_sei( iconn, Order::ELEM );
 
  235     localIndex const kf  = m_sei( iconn, Order::FACE );
 
  242                                      stack.transmissibility,
 
  244     real64 const dTrans_dPres = LvArray::tensorOps::AiBi< 3 >( dTrans_dPerm, m_dPerm_dPres[er][esr][ei][0] );
 
  256     StackArray< 
real64, 4, constitutive::MultiFluidBase::MAX_NUM_PHASES * NUM_COMP,
 
  257                 constitutive::multifluid::LAYOUT_PHASE_COMP > facePhaseCompFrac( 1, 1, 
m_numPhases, NUM_COMP );
 
  258     real64 faceTotalDens = 0.0;
 
  260     constitutive::MultiFluidBase::KernelWrapper::computeValues( 
m_fluidWrapper,
 
  266                                                                 facePhaseMassDens[0][0],
 
  268                                                                 facePhaseEnthalpy[0][0],
 
  269                                                                 facePhaseInternalEnergy[0][0],
 
  270                                                                 facePhaseCompFrac[0][0],
 
  284       real64 dPhaseFlux_dP = 0.0;
 
  292                       m_dPhaseMassDens[er][esr][ei][0][ip],
 
  298       real64 const dDensMean_dP = 0.5 * m_dPhaseMassDens[er][esr][ei][0][ip][Deriv::dP];
 
  301         dDensMean_dC[jc] = 0.5 * dProp_dC[jc];
 
  309       real64 const f = stack.transmissibility * potDif;
 
  310       real64 const dF_dP = stack.transmissibility * ( 1.0 - dDensMean_dP * gravTimesDz ) + dTrans_dPres * potDif;
 
  313         dF_dC[jc] = -stack.transmissibility * dDensMean_dC[jc] * gravTimesDz;
 
  329       real64 const facePhaseMob = ( facePhaseFrac[0][0][ip] > 0.0 )
 
  330   ? facePhaseFrac[0][0][ip] * faceTotalDens / facePhaseVisc[0][0][ip]
 
  342         dPhaseFlux_dP = 
m_phaseMob[er][esr][ei][ip] * dF_dP + m_dPhaseMob[er][esr][ei][ip][Deriv::dP] * f;
 
  346             m_phaseMob[er][esr][ei][ip] * dF_dC[jc] + m_dPhaseMob[er][esr][ei][ip][Deriv::dC+jc] * f;
 
  350         arraySlice1d< 
real64 const, constitutive::multifluid::USD_PHASE_COMP-3 > phaseCompFracSub =
 
  352         arraySlice2d< 
real64 const, constitutive::multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFracSub =
 
  353           m_dPhaseCompFrac[er][esr][ei][0][ip];
 
  358           real64 const ycp = phaseCompFracSub[ic];
 
  359           stack.
compFlux[ic] += phaseFlux * ycp;
 
  360           stack.
dCompFlux_dP[ic] += dPhaseFlux_dP * ycp + phaseFlux * dPhaseCompFracSub[ic][Deriv::dP];
 
  364                           dPhaseCompFracSub[ic],
 
  369             stack.
dCompFlux_dC[ic][jc] += dPhaseFlux_dC[jc] * ycp + phaseFlux * dProp_dC[jc];
 
  379         phaseFlux = facePhaseMob * f;
 
  380         dPhaseFlux_dP = facePhaseMob * dF_dP;
 
  383           dPhaseFlux_dC[jc] = facePhaseMob * dF_dC[jc];
 
  389           real64 const ycp = facePhaseCompFrac[0][0][ip][ic];
 
  390           stack.
compFlux[ic] += phaseFlux * ycp;
 
  401       compFluxKernelOp( ip, er, esr, ei, kf, f,
 
  402                         facePhaseMob, facePhaseEnthalpy[0][0], facePhaseCompFrac[0][0],
 
  403                         phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC );
 
  426   template< 
typename FUNC = NoOpFunc >
 
  430                  FUNC && assemblyKernelOp = NoOpFunc{} ) 
const 
  432     using namespace compositionalMultiphaseUtilities;
 
  435     if( AbstractBase::m_kernelFlags.isSet( KernelFlags::TotalMassEquation ) )
 
  440       shiftElementsAheadByOneAndReplaceFirstElementWithSum( 
numComp, stack.
localFlux );
 
  446     if( 
m_ghostRank[
m_seri( iconn, Order::ELEM )][m_sesri( iconn, Order::ELEM )][m_sei( iconn, Order::ELEM )] < 0 )
 
  464       assemblyKernelOp( localRow );
 
  507   template< 
typename POLICY >
 
  512                    BitFlags< KernelFlags > kernelFlags,
 
  513                    string const & dofKey,
 
  514                    string const & solverName,
 
  518                    constitutive::MultiFluidBase & fluidBase,
 
  523     constitutive::constitutiveComponentUpdatePassThru( fluidBase, numComps, [&]( 
auto & fluid, 
auto NC )
 
  525       using FluidType = TYPEOFREF( fluid );
 
  526       typename FluidType::KernelWrapper 
const fluidWrapper = fluid.createKernelWrapper();
 
  528       integer constexpr NUM_COMP = NC();
 
  529       integer constexpr NUM_DOF = NC() + 1;
 
  533       dofNumberAccessor.setName( solverName + 
"/accessors/" + dofKey );
 
  536       typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName );
 
  537       typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName );
 
  538       typename kernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName );
 
  539       typename kernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
 
  541       kernelType kernel( numPhases, rankOffset, faceManager, stencilWrapper, fluidWrapper,
 
  542                          dofNumberAccessor, compFlowAccessors, multiFluidAccessors, capPressureAccessors, permeabilityAccessors,
 
  543                          dt, localMatrix, localRhs, kernelFlags );
 
  544       kernelType::template launch< POLICY >( stencilWrapper.
size(), kernel );
 
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
#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.
GEOS_HOST_DEVICE void computeWeights(localIndex const iconn, CoefficientAccessor< arrayView3d< real64 const > > const &coefficient, real64 &weight, real64(&dWeight_dCoef)[3]) const
Compute weights and derivatives w.r.t to the coefficient.
GEOS_HOST_DEVICE GEOS_FORCE_INLINE localIndex size() const
Give the number of stencil entries.
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...
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
static void createAndLaunch(integer const numComps, integer const numPhases, globalIndex const rankOffset, BitFlags< KernelFlags > kernelFlags, string const &dofKey, string const &solverName, FaceManager const &faceManager, ElementRegionManager const &elemManager, BoundaryStencilWrapper const &stencilWrapper, constitutive::MultiFluidBase &fluidBase, 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 Dirichlet face flux terms.
arrayView1d< real64 const > const m_faceGravCoef
View on the face gravity coefficient.
real64 const m_dt
Time step size.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&assemblyKernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
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 > const m_facePres
Views on face pressure, temperature, and composition.
ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const m_phaseCompFrac
Views on phase component fractions.
GEOS_HOST_DEVICE void setup(localIndex const iconn, StackVariables &stack) const
Performs the setup phase for the kernel.
globalIndex const m_rankOffset
Offset for my MPI rank.
DirichletFluxComputeKernel(integer const numPhases, globalIndex const rankOffset, FaceManager const &faceManager, BoundaryStencilWrapper const &stencilWrapper, FLUIDWRAPPER const &fluidWrapper, 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, compflow::USD_COMP_DC > > const m_dCompFrac_dCompDens
Views on derivatives of comp fractions.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&compFluxKernelOp=NoOpFunc{}) const
Compute the local Dirichlet face flux contributions to the residual and Jacobian.
integer const m_numPhases
Number of fluid phases.
FLUIDWRAPPER const m_fluidWrapper
Reference to the fluid wrapper.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
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.
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.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations (all of them, except the volume balance equation)
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 integer numDof
Compute time value for the number of degrees of freedom.
ElementViewConst< arrayView3d< real64 const > > const m_permeability
Views on permeability.
BoundaryStencilWrapper const m_stencilWrapper
Reference to the stencil wrapper.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZE > StackArray
Multidimensional stack-based array type. See LvArray:StackArray for details.
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
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.
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.
Defines the order of element/face in the stencil.
static constexpr localIndex ELEM
Order of element index in stencil.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 dCompFlux_dP[numComp]
Derivatives of component fluxes wrt pressure.
real64 localFluxJacobian[numEqn][numDof]
Storage for the face local Jacobian matrix.
real64 localFlux[numEqn]
Storage for the face local residual vector.
real64 dCompFlux_dC[numComp][numComp]
Derivatives of component fluxes wrt component densities.
globalIndex dofColIndices[numDof]
Indices of the matrix rows/columns corresponding to the dofs in this face.
GEOS_HOST_DEVICE StackVariables(localIndex const GEOS_UNUSED_PARAM(size), localIndex GEOS_UNUSED_PARAM(numElems))
Constructor for the stack variables.
real64 compFlux[numComp]
Component fluxes.