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"
40 namespace isothermalCompositionalMultiphaseFVMKernels
52 template<
integer NUM_COMP,
integer NUM_DOF,
typename FLUIDWRAPPER >
55 BoundaryStencilWrapper >
65 template<
typename VIEWTYPE >
69 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
80 using AbstractBase::m_gravCoef;
83 using AbstractBase::m_dPhaseCompFrac;
87 using AbstractBase::m_kernelFlags;
95 using Base::m_dPhaseMob;
97 using Base::m_dPhaseMassDens;
99 using Base::m_dPerm_dPres;
125 FLUIDWRAPPER
const & fluidWrapper,
126 DofNumberAccessor
const & dofNumberAccessor,
134 BitFlags< KernelFlags > kernelFlags )
141 capPressureAccessors,
142 permeabilityAccessors,
147 m_facePres( faceManager.getField< fields::flow::facePressure >() ),
148 m_faceTemp( faceManager.getField< fields::flow::faceTemperature >() ),
149 m_faceCompFrac( faceManager.getField< fields::flow::faceGlobalCompFraction >() ),
150 m_faceGravCoef( faceManager.getField< fields::flow::gravityCoefficient >() ),
172 real64 transmissibility = 0.0;
222 template<
typename FUNC = NoOpFunc >
226 FUNC && compFluxKernelOp = NoOpFunc{} )
const
228 using Deriv = constitutive::multifluid::DerivativeOffset;
232 localIndex const esr = m_sesri( iconn, Order::ELEM );
233 localIndex const ei = m_sei( iconn, Order::ELEM );
234 localIndex const kf = m_sei( iconn, Order::FACE );
241 stack.transmissibility,
243 real64 const dTrans_dPres = LvArray::tensorOps::AiBi< 3 >( dTrans_dPerm, m_dPerm_dPres[er][esr][ei][0] );
255 StackArray<
real64, 4, constitutive::MultiFluidBase::MAX_NUM_PHASES * NUM_COMP,
256 constitutive::multifluid::LAYOUT_PHASE_COMP > facePhaseCompFrac( 1, 1,
m_numPhases, NUM_COMP );
257 real64 faceTotalDens = 0.0;
259 constitutive::MultiFluidBase::KernelWrapper::computeValues(
m_fluidWrapper,
265 facePhaseMassDens[0][0],
267 facePhaseEnthalpy[0][0],
268 facePhaseInternalEnergy[0][0],
269 facePhaseCompFrac[0][0],
283 real64 dPhaseFlux_dP = 0.0;
291 m_dPhaseMassDens[er][esr][ei][0][ip],
297 real64 const dDensMean_dP = 0.5 * m_dPhaseMassDens[er][esr][ei][0][ip][Deriv::dP];
300 dDensMean_dC[jc] = 0.5 * dProp_dC[jc];
308 real64 const f = stack.transmissibility * potDif;
309 real64 const dF_dP = stack.transmissibility * ( 1.0 - dDensMean_dP * gravTimesDz ) + dTrans_dPres * potDif;
312 dF_dC[jc] = -stack.transmissibility * dDensMean_dC[jc] * gravTimesDz;
328 real64 const facePhaseMob = ( facePhaseFrac[0][0][ip] > 0.0 )
329 ? facePhaseFrac[0][0][ip] * faceTotalDens / facePhaseVisc[0][0][ip]
341 dPhaseFlux_dP =
m_phaseMob[er][esr][ei][ip] * dF_dP + m_dPhaseMob[er][esr][ei][ip][Deriv::dP] * f;
345 m_phaseMob[er][esr][ei][ip] * dF_dC[jc] + m_dPhaseMob[er][esr][ei][ip][Deriv::dC+jc] * f;
349 arraySlice1d<
real64 const, constitutive::multifluid::USD_PHASE_COMP-3 > phaseCompFracSub =
351 arraySlice2d<
real64 const, constitutive::multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFracSub =
352 m_dPhaseCompFrac[er][esr][ei][0][ip];
357 real64 const ycp = phaseCompFracSub[ic];
358 stack.
compFlux[ic] += phaseFlux * ycp;
359 stack.
dCompFlux_dP[ic] += dPhaseFlux_dP * ycp + phaseFlux * dPhaseCompFracSub[ic][Deriv::dP];
363 dPhaseCompFracSub[ic],
368 stack.
dCompFlux_dC[ic][jc] += dPhaseFlux_dC[jc] * ycp + phaseFlux * dProp_dC[jc];
378 phaseFlux = facePhaseMob * f;
379 dPhaseFlux_dP = facePhaseMob * dF_dP;
382 dPhaseFlux_dC[jc] = facePhaseMob * dF_dC[jc];
388 real64 const ycp = facePhaseCompFrac[0][0][ip][ic];
389 stack.
compFlux[ic] += phaseFlux * ycp;
400 compFluxKernelOp( ip, er, esr, ei, kf, f,
401 facePhaseMob, facePhaseEnthalpy[0][0], facePhaseCompFrac[0][0],
402 phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC );
425 template<
typename FUNC = NoOpFunc >
429 FUNC && assemblyKernelOp = NoOpFunc{} )
const
431 using namespace compositionalMultiphaseUtilities;
434 if( AbstractBase::m_kernelFlags.isSet( KernelFlags::TotalMassEquation ) )
439 shiftElementsAheadByOneAndReplaceFirstElementWithSum(
numComp, stack.
localFlux );
445 if(
m_ghostRank[
m_seri( iconn, Order::ELEM )][m_sesri( iconn, Order::ELEM )][m_sei( iconn, Order::ELEM )] < 0 )
463 assemblyKernelOp( localRow );
506 template<
typename POLICY >
511 integer const useTotalMassEquation,
512 string const & dofKey,
513 string const & solverName,
517 constitutive::MultiFluidBase & fluidBase,
522 constitutive::constitutiveComponentUpdatePassThru( fluidBase, numComps, [&](
auto & fluid,
auto NC )
524 using FluidType = TYPEOFREF( fluid );
525 typename FluidType::KernelWrapper
const fluidWrapper = fluid.createKernelWrapper();
527 integer constexpr NUM_COMP = NC();
528 integer constexpr NUM_DOF = NC() + 1;
532 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
535 BitFlags< KernelFlags > kernelFlags;
536 if( useTotalMassEquation )
537 kernelFlags.set( KernelFlags::TotalMassEquation );
540 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName );
541 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName );
542 typename kernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName );
543 typename kernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
545 kernelType kernel( numPhases, rankOffset, faceManager, stencilWrapper, fluidWrapper,
546 dofNumberAccessor, compFlowAccessors, multiFluidAccessors, capPressureAccessors, permeabilityAccessors,
547 dt, localMatrix, localRhs, kernelFlags );
548 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, integer const useTotalMassEquation, 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.
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).
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.
std::int32_t integer
Signed integer type.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
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.