20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_DIRICHLETFLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_DIRICHLETFLUXCOMPUTEKERNEL_HPP
25 #include "common/GEOS_RAJA_Interface.hpp"
26 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
32 #include "codingUtilities/Utilities.hpp"
37 namespace singlePhaseFVMKernels
47 template<
integer NUM_EQN,
integer NUM_DOF,
typename FLUIDWRAPPER >
49 BoundaryStencilWrapper >
52 using Deriv = constitutive::singlefluid::DerivativeOffset;
54 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
62 using AbstractBase::m_gravCoef;
65 using AbstractBase::m_dMob;
67 using AbstractBase::m_dDens;
69 using AbstractBase::m_dPerm_dPres;
99 FLUIDWRAPPER
const & fluidWrapper,
100 DofNumberAccessor
const & dofNumberAccessor,
110 singlePhaseFlowAccessors,
111 singlePhaseFluidAccessors,
112 permeabilityAccessors,
116 m_facePres( faceManager.getField< fields::flow::facePressure >() ),
117 m_faceGravCoef( faceManager.getField< fields::flow::gravityCoefficient >() ),
179 template<
typename FUNC = NoOpFunc >
183 FUNC && compFluxKernelOp = NoOpFunc{} )
const
192 localIndex const esr = m_sesri( iconn, Order::ELEM );
193 localIndex const ei = m_sei( iconn, Order::ELEM );
194 localIndex const kf = m_sei( iconn, Order::FACE );
197 real64 faceDens, faceVisc;
200 mobility[Order::ELEM] =
m_mob[er][esr][ei];
201 singlePhaseBaseKernels::MobilityKernel::compute( faceDens, faceVisc, mobility[Order::FACE] );
203 dMobility_dP[Order::ELEM] = m_dMob[er][esr][ei][Deriv::dP];
204 dMobility_dP[Order::FACE] = 0.0;
207 real64 const densMean = 0.5 * (
m_dens[er][esr][ei][0] + faceDens );
208 real64 const dDens_dP = 0.5 * m_dDens[er][esr][ei][0][Deriv::dP];
213 real64 const dPotDif_dP = 1.0 - dDens_dP * m_gravCoef[er][esr][ei];
217 real64 const dTrans_dPres = LvArray::tensorOps::AiBi< 3 >( dTrans_dPerm, m_dPerm_dPres[er][esr][ei][0] );
223 localIndex const k_up = ( potDif >= 0 ) ? Order::ELEM : Order::FACE;
224 real64 const mobility_up = mobility[k_up];
225 real64 const dMobility_dP_up = dMobility_dP[k_up];
228 real64 const dens_up = ( potDif >= 0 ) ?
m_dens[er][esr][ei][0] : faceDens;
229 real64 const dDens_dP_up = ( potDif >= 0 ) ? m_dDens[er][esr][ei][0][Deriv::dP] : 0.0;
234 compFluxKernelOp( er, esr, ei, kf, f, dF_dP, mobility_up, dMobility_dP_up, dens_up, dDens_dP_up );
249 template<
typename FUNC = NoOpFunc >
253 FUNC && assemblyKernelOp = NoOpFunc{} )
const
258 localIndex const esr = m_sesri( iconn, Order::ELEM );
259 localIndex const ei = m_sei( iconn, Order::ELEM );
275 assemblyKernelOp( localRow );
314 template<
typename POLICY >
317 string const & dofKey,
318 string const & solverName,
322 constitutive::SingleFluidBase & fluidBase,
327 constitutiveUpdatePassThru( fluidBase, [&](
auto & fluid )
329 using FluidType = TYPEOFREF( fluid );
330 typename FluidType::KernelWrapper fluidWrapper = fluid.createKernelWrapper();
339 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
341 typename kernelType::SinglePhaseFlowAccessors singlePhaseFlowAccessors( elemManager, solverName );
342 typename kernelType::SinglePhaseFluidAccessors singlePhaseFluidAccessors( elemManager, solverName );
343 typename kernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
345 kernelType kernel( rankOffset,
350 singlePhaseFlowAccessors,
351 singlePhaseFluidAccessors,
352 permeabilityAccessors,
357 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.
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.
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(globalIndex const rankOffset, string const &dofKey, string const &solverName, FaceManager const &faceManager, ElementRegionManager const &elemManager, BoundaryStencilWrapper const &stencilWrapper, constitutive::SingleFluidBase &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.
ElementViewConst< arrayView1d< real64 const > > const m_mob
Views on fluid mobility.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&assemblyKernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
ElementViewConst< arrayView1d< integer const > > const m_ghostRank
Views on ghost rank numbers and gravity coefficients.
FLUIDWRAPPER const m_fluidWrapper
Reference to the fluid wrapper.
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.
arrayView1d< real64 const > const m_faceGravCoef
View on the face gravity coefficient.
DirichletFluxComputeKernel(globalIndex const rankOffset, FaceManager const &faceManager, BoundaryStencilWrapper const &stencilWrapper, FLUIDWRAPPER const &fluidWrapper, DofNumberAccessor const &dofNumberAccessor, SinglePhaseFlowAccessors const &singlePhaseFlowAccessors, SinglePhaseFluidAccessors const &singlePhaseFluidAccessors, PermeabilityAccessors const &permeabilityAccessors, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Constructor for the kernel interface.
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.
ElementViewConst< arrayView3d< real64 const > > m_permeability
Views on permeability.
ElementViewConst< arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > > const m_dens
Views on fluid density.
globalIndex const m_rankOffset
Offset for my MPI rank.
GEOS_HOST_DEVICE void setup(localIndex const iconn, StackVariables &stack) const
Performs the setup phase for the kernel.
arrayView1d< real64 const > const m_facePres
Views on face pressure, temperature, and composition.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
ElementViewConst< arrayView1d< real64 const > > const m_mob
Views on fluid mobility.
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.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
ElementViewConst< arrayView3d< real64 const > > m_permeability
Views on permeability.
ElementViewConst< arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > > const m_dens
Views on fluid density.
globalIndex const m_rankOffset
Offset for my MPI rank.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
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).
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.
Defines the order of element/face in the stencil.
static constexpr localIndex ELEM
Order of element index in stencil.
static constexpr localIndex maxNumPointsInFlux
Maximum number of points the flux.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 transmissibility
Transmissibility.
real64 localFlux[numEqn]
Storage for the face local residual.
real64 localFluxJacobian[numEqn][numDof]
Storage for the face local Jacobian.
GEOS_HOST_DEVICE StackVariables(localIndex const GEOS_UNUSED_PARAM(size), localIndex GEOS_UNUSED_PARAM(numElems))
Constructor for the stack variables.
globalIndex dofColIndices[numDof]
Indices of the matrix rows/columns corresponding to the dofs in this face.