20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_DISSIPATIONFLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_DISSIPATIONFLUXCOMPUTEKERNEL_HPP
25 #include "constitutive/solid/porosity/PorosityBase.hpp"
26 #include "constitutive/solid/porosity/PorosityFields.hpp"
31 namespace dissipationCompositionalMultiphaseFVMKernels
34 static constexpr
integer newtonContinuationCutoffIteration = 5;
35 static constexpr
real64 initialDirectionalCoef = 100;
36 static constexpr
real64 multiplierDirectionalCoef = 1000;
47 template<
integer NUM_COMP,
integer NUM_DOF,
typename STENCILWRAPPER >
58 template<
typename VIEWTYPE >
62 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
69 using AbstractBase::m_gravCoef;
78 using Base::m_dPerm_dPres;
82 fields::flow::globalCompDensity,
83 fields::flow::globalCompFraction,
89 using Deriv = constitutive::multifluid::DerivativeOffset;
116 STENCILWRAPPER
const & stencilWrapper,
117 DofNumberAccessor
const & dofNumberAccessor,
127 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags,
133 real64 const contMultiplier )
140 capPressureAccessors,
141 permeabilityAccessors,
146 m_pres_n( dissCompFlowAccessors.get( fields::flow::pressure_n {} ) ),
147 m_porosity_n( porosityAccessors.get( fields::porosity::porosity_n {} ) ),
148 m_volume( dissCompFlowAccessors.get( fields::elementVolume {} ) ),
149 m_compFrac( dissCompFlowAccessors.get( fields::flow::globalCompFraction {} ) ),
151 m_miscibleDBC( miscible )
158 if( curNewton >= newtonContinuationCutoffIteration )
160 m_kappaDBC = kappamin;
164 for(
int mp = 0; mp < curNewton; mp++ )
166 m_kappaDBC *= contMultiplier;
168 m_kappaDBC = std::max( m_kappaDBC, kappamin );
199 real64 const (&dPhaseFlux_dP)[2],
202 GEOS_UNUSED_VAR( k_up, potGrad, phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC, er_up, esr_up, ei_up );
210 real64 viscosityMult[3] = {1.0, 1.0, 1.0};
213 real64 poreVolume_n = 0.0;
216 poreVolume_n += m_volume[seri[ke]][sesri[ke]][sei[ke]] * m_porosity_n[seri[ke]][sesri[ke]][sei[ke]][0];
222 real64 pressure_gradient = 0;
224 pressure_gradient += fluxPointCoef[ke] *
m_pres_n[seri[ke]][sesri[ke]][sei[ke]];
226 real64 const potential_gradient = LvArray::math::abs( pressure_gradient );
231 grad_depth += fluxPointCoef[ke] * m_gravCoef[seri[ke]][sesri[ke]][sei[ke]];
239 real64 directional_coef = 1.0;
242 directional_coef = initialDirectionalCoef;
243 if( LvArray::math::abs( grad_depth ) > 0.0 )
245 real64 const d2 = LvArray::math::abs( grad_depth * grad_depth );
246 if( multiplierDirectionalCoef / d2 < initialDirectionalCoef )
247 directional_coef = multiplierDirectionalCoef / d2;
252 real64 const multiplier = m_kappaDBC * m_omegaDBC / poreVolume_n *
m_dt * potential_gradient * directional_coef;
265 dissFlux[ic] += coef * m_compFrac[er][esr][ei][ic];
267 dDissFlux_dP[ke][ic] = 0;
294 localIndex const localDofIndexComp = localDofIndexPres + jc + 1;
345 template<
typename POLICY,
typename STENCILWRAPPER >
350 string const & dofKey,
352 integer const useTotalMassEquation,
353 string const & solverName,
355 STENCILWRAPPER
const & stencilWrapper,
364 real64 const contMultiplier )
366 isothermalCompositionalMultiphaseBaseKernels::
367 internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
369 integer constexpr NUM_COMP = NC();
370 integer constexpr NUM_DOF = NC() + 1;
374 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
376 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags;
378 kernelFlags.set( isothermalCompositionalMultiphaseFVMKernels::KernelFlags::CapPressure );
379 if( useTotalMassEquation )
380 kernelFlags.set( isothermalCompositionalMultiphaseFVMKernels::KernelFlags::TotalMassEquation );
383 typename KERNEL_TYPE::CompFlowAccessors compFlowAccessors( elemManager, solverName );
384 typename KERNEL_TYPE::MultiFluidAccessors multiFluidAccessors( elemManager, solverName );
385 typename KERNEL_TYPE::CapPressureAccessors capPressureAccessors( elemManager, solverName );
386 typename KERNEL_TYPE::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
387 typename KERNEL_TYPE::PorosityAccessors porosityAccessors( elemManager, solverName );
388 typename KERNEL_TYPE::DissCompFlowAccessors dissCompFlowAccessors( elemManager, solverName );
390 KERNEL_TYPE kernel( numPhases, rankOffset, stencilWrapper, dofNumberAccessor, compFlowAccessors, dissCompFlowAccessors,
391 multiFluidAccessors, capPressureAccessors, permeabilityAccessors, porosityAccessors,
392 dt, localMatrix, localRhs, kernelFlags, omega, curNewton, continuation, miscible, kappamin, contMultiplier );
393 KERNEL_TYPE::template launch< POLICY >( stencilWrapper.size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
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.
static void createAndLaunch(integer const numComps, integer const numPhases, globalIndex const rankOffset, string const &dofKey, integer const hasCapPressure, integer const useTotalMassEquation, string const &solverName, ElementRegionManager const &elemManager, STENCILWRAPPER const &stencilWrapper, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, real64 const omega, integer const curNewton, integer const continuation, integer const miscible, real64 const kappamin, real64 const contMultiplier)
Create a new kernel and launch.
Define the interface for the assembly kernel in charge of flux terms.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
real64 const m_dt
Time step size.
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)
ElementViewConst< arrayView1d< real64 const > > const m_pres_n
Views on flow properties at the previous converged time step.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, typename Base::StackVariables &stack) const
Compute the local flux contributions to the residual and Jacobian, including dissipation.
static constexpr integer numComp
Compile time value for the number of components.
FluxComputeKernel(integer const numPhases, globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, CompFlowAccessors const &compFlowAccessors, DissCompFlowAccessors const &dissCompFlowAccessors, MultiFluidAccessors const &multiFluidAccessors, CapPressureAccessors const &capPressureAccessors, PermeabilityAccessors const &permeabilityAccessors, PorosityAccessors const &porosityAccessors, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags, real64 const omega, integer const curNewton, integer const continuation, integer const miscible, real64 const kappamin, real64 const contMultiplier)
Constructor for the kernel interface.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const m_dCompFrac_dCompDens
Views on derivatives of comp fractions.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
real64 const m_dt
Time step size.
ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const m_dCompFrac_dCompDens
Views on derivatives of comp fractions.
Define the interface for the assembly kernel in charge of flux terms.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&compFluxKernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
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)
static constexpr integer numComp
Compile time value for the number of components.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
ElementViewConst< arrayView3d< real64 const > > const m_permeability
Views on permeability.
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.
Trait struct for elementVolume data.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
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)
real64 transmissibility[maxNumConns][numFluxSupportPoints]
Transmissibility.