20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALDIFFUSIONDISPERSIONFLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALDIFFUSIONDISPERSIONFLUXCOMPUTEKERNEL_HPP
28 namespace thermalCompositionalMultiphaseFVMKernels
40 template<
integer NUM_COMP,
integer NUM_DOF,
typename STENCILWRAPPER >
52 template<
typename VIEWTYPE >
56 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
60 using AbstractBase::m_dPhaseCompFrac;
61 using AbstractBase::m_dPhaseVolFrac;
67 using Base::numFluxSupportPoints;
71 using Base::m_referencePorosity;
72 using Base::m_phaseVolFrac;
73 using Base::m_phaseDens;
74 using Base::m_dPhaseDens;
75 using Base::m_phaseDiffusivityMultiplier;
95 STENCILWRAPPER
const & stencilWrapper,
96 DofNumberAccessor
const & dofNumberAccessor,
105 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags )
127 : Base::StackVariables( size, numElems )
130 using Base::StackVariables::transmissibility;
131 using Base::StackVariables::localFlux;
132 using Base::StackVariables::localFluxJacobian;
146 using Deriv = constitutive::multifluid::DerivativeOffset;
152 Base::computeDiffusionFlux( iconn, stack, [&] (
integer const ip,
163 real64 const compFracGrad,
164 real64 const upwindCoefficient )
178 dCompFracGrad_dT[i] += stack.transmissibility[connectionIndex][i] * m_dPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dT];
184 dDiffusionFlux_dT[ke] += upwindCoefficient * dCompFracGrad_dT[ke];
188 real64 const dUpwindCoefficient_dT =
190 m_phaseDiffusivityMultiplier[er_up][esr_up][ei_up][0][ip] *
191 ( m_dPhaseDens[er_up][esr_up][ei_up][0][ip][Deriv::dT] *
m_phaseVolFrac[er_up][esr_up][ei_up][ip]
192 +
m_phaseDens[er_up][esr_up][ei_up][0][ip] * m_dPhaseVolFrac[er_up][esr_up][ei_up][ip][Deriv::dT] );
193 dDiffusionFlux_dT[k_up] += dUpwindCoefficient_dT * compFracGrad;
202 stack.localFluxJacobian[eqIndex0][localDofIndexTemp] +=
m_dt * dDiffusionFlux_dT[ke];
203 stack.localFluxJacobian[eqIndex1][localDofIndexTemp] -=
m_dt * dDiffusionFlux_dT[ke];
218 using Deriv = constitutive::multifluid::DerivativeOffset;
224 Base::computeDispersionFlux( iconn, stack, [&] (
integer const ip,
235 real64 const compFracGrad )
249 dCompFracGrad_dT[i] += stack.transmissibility[connectionIndex][i] * m_dPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dT];
255 dDispersionFlux_dT[ke] +=
m_phaseDens[er_up][esr_up][ei_up][0][ip] * dCompFracGrad_dT[ke];
259 dDispersionFlux_dT[k_up] += m_dPhaseDens[er_up][esr_up][ei_up][0][ip][Deriv::dT] * compFracGrad;
268 stack.localFluxJacobian[eqIndex0][localDofIndexTemp] +=
m_dt * dDispersionFlux_dT[ke];
269 stack.localFluxJacobian[eqIndex1][localDofIndexTemp] -=
m_dt * dDispersionFlux_dT[ke];
299 template<
typename POLICY,
typename STENCILWRAPPER >
304 string const & dofKey,
305 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags,
306 string const & solverName,
308 STENCILWRAPPER
const & stencilWrapper,
313 isothermalCompositionalMultiphaseBaseKernels::
314 internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
316 integer constexpr NUM_COMP = NC();
317 integer constexpr NUM_DOF = NC() + 2;
321 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
324 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName );
325 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName );
326 typename kernelType::DiffusionAccessors diffusionAccessors( elemManager, solverName );
327 typename kernelType::DispersionAccessors dispersionAccessors( elemManager, solverName );
328 typename kernelType::PorosityAccessors porosityAccessors( elemManager, solverName );
330 kernelType kernel( numPhases, rankOffset, stencilWrapper,
331 dofNumberAccessor, compFlowAccessors, multiFluidAccessors,
332 diffusionAccessors, dispersionAccessors, porosityAccessors,
333 dt, localMatrix, localRhs, kernelFlags );
334 kernelType::template launch< POLICY >( stencilWrapper.size(),
335 kernelFlags.isSet( isothermalCompositionalMultiphaseFVMKernels::KernelFlags::Diffusion ),
336 kernelFlags.isSet( isothermalCompositionalMultiphaseFVMKernels::KernelFlags::Dispersion ),
#define GEOS_HOST_DEVICE
Marks a host-device function.
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.
Define the interface for the assembly kernel in charge of diffusion/dispersion flux terms.
ElementViewConst< arrayView1d< real64 const > > const m_referencePorosity
View on the reference porosity.
ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > > const m_phaseDens
Views on phase densities.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
static constexpr integer numFluxSupportPoints
Number of flux support points (hard-coded for TFPA)
static constexpr integer numComp
Compile time value for the number of components.
static constexpr integer numEqn
Compute time value for the number of equations (all of them, except the volume balance equation)
ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_phaseVolFrac
Views on phase volume fraction.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
real64 const m_dt
Time step size.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
static void createAndLaunch(integer const numComps, integer const numPhases, globalIndex const rankOffset, string const &dofKey, BitFlags< isothermalCompositionalMultiphaseFVMKernels::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 diffusion/dispersion flux terms.
DiffusionDispersionFluxComputeKernel(integer const numPhases, globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, CompFlowAccessors const &compFlowAccessors, MultiFluidAccessors const &multiFluidAccessors, DiffusionAccessors const &diffusionAccessors, DispersionAccessors const &dispersionAccessors, PorosityAccessors const &porosityAccessors, real64 const dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags)
Constructor for the kernel interface.
real64 const m_dt
Time step size.
GEOS_HOST_DEVICE void computeDiffusionFlux(localIndex const iconn, StackVariables &stack) const
Compute the local diffusion flux contributions to the residual and Jacobian.
GEOS_HOST_DEVICE void computeDispersionFlux(localIndex const iconn, StackVariables &stack) const
Compute the local dispersion flux contributions to the residual and Jacobian.
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.