20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_REACTIVE_FLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_REACTIVE_FLUXCOMPUTEKERNEL_HPP
23 #include "constitutive/diffusion/DiffusionFields.hpp"
24 #include "constitutive/diffusion/DiffusionBase.hpp"
25 #include "constitutive/solid/porosity/PorosityBase.hpp"
26 #include "constitutive/solid/porosity/PorosityFields.hpp"
27 #include "constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp"
28 #include "constitutive/fluid/reactivefluid/ReactiveFluidFields.hpp"
30 #include "physicsSolvers/fluidFlow/kernels/singlePhase/reactive/KernelLaunchSelectors.hpp"
36 namespace singlePhaseReactiveFVMKernels
48 template<
integer NUM_SPECIES,
integer NUM_EQN,
integer NUM_DOF,
typename STENCILWRAPPER,
typename BASE_FLUID_TYPE >
65 template<
typename VIEWTYPE >
69 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
77 using AbstractBase::m_gravCoef;
80 using AbstractBase::m_dDens;
95 fields::flow::dMobility_dLogPrimaryConc >;
99 fields::reactivefluid::primarySpeciesMobileAggregateConcentration,
100 fields::reactivefluid::dPrimarySpeciesMobileAggregateConcentration_dLogPrimarySpeciesConcentrations >;
104 fields::diffusion::diffusivity,
105 fields::diffusion::dDiffusivity_dTemperature >;
109 fields::porosity::referencePorosity >;
130 STENCILWRAPPER
const & stencilWrapper,
131 DofNumberAccessor
const & dofNumberAccessor,
147 singlePhaseFlowAccessors,
148 singlePhaseFluidAccessors,
149 permeabilityAccessors,
153 m_logPrimarySpeciesConc( reactiveSinglePhaseFlowAccessors.get( fields::flow::logPrimarySpeciesConcentration {} ) ),
154 m_dMob_dLogPrimaryConc( reactiveSinglePhaseFlowAccessors.get( fields::flow::dMobility_dLogPrimaryConc {} ) ),
157 fields::reactivefluid::dPrimarySpeciesMobileAggregateConcentration_dLogPrimarySpeciesConcentrations {} ) ),
158 m_diffusivity( diffusionAccessors.get( fields::diffusion::diffusivity {} ) ),
159 m_dDiffusivity_dTemp( diffusionAccessors.get( fields::diffusion::dDiffusivity_dTemperature {} ) ),
205 template<
typename FUNC = NoOpFunc >
209 FUNC && kernelOp = NoOpFunc{} )
const
211 using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
225 real64 const (&dFlux_dP)[2] )
240 localIndex const k_up = (potGrad >= 0) ? 0 : 1;
246 real64 const fluidDens_up =
m_dens[er_up][esr_up][ei_up][0];
247 real64 const dDens_dPres = m_dDens[er_up][esr_up][ei_up][0][DerivOffset::dP];
253 speciesFlux[is] = aggregateConc_i / fluidDens_up * fluxVal;
257 dSpeciesFlux_dP[ke][is] += aggregateConc_i / fluidDens_up * dFlux_dP[ke];
260 dSpeciesFlux_dP[k_up][is] += -aggregateConc_i * fluxVal * dDens_dPres / (fluidDens_up * fluidDens_up);
265 dSpeciesFlux_dLogConc[k_up][is][js] += dAggregateConc_i_dLogConc_j / fluidDens_up * fluxVal;
294 kernelOp( k, seri, sesri, sei, connectionIndex, alpha, mobility, potGrad, fluxVal, dFlux_dP, fluidDens_up );
305 template<
typename FUNC = NoOpFunc >
309 FUNC && kernelOp = NoOpFunc{} )
const
319 m_dDiffusivity_dTemp,
328 for( k[1] = k[0] + 1; k[1] < stack.
numFluxElems; ++k[1] )
359 speciesGrad[is] += diffusionTrans[ke] * aggregateConc_i;
365 dSpeciesGrad_i_dLogConc[ke][js] += diffusionTrans[ke] * dAggregateConc_i_dLogConc_j;
370 localIndex const k_up = (speciesGrad[is] >= 0) ? 0 : 1;
384 dDiffusionFlux_dLogConc[ke][is][js] +=
m_referencePorosity[er_up][esr_up][ei_up] * dSpeciesGrad_i_dLogConc[ke][js];
410 kernelOp( is, k, seri, sesri, sei, connectionIndex, k_up );
423 template<
typename FUNC = NoOpFunc >
427 FUNC && kernelOp = NoOpFunc{} )
const
447 kernelOp( i, localRow );
458 template<
typename POLICY,
typename KERNEL_TYPE >
461 KERNEL_TYPE
const & kernelComponent )
467 typename KERNEL_TYPE::StackVariables stack( kernelComponent.stencilSize( iconn ),
468 kernelComponent.numPointsInFlux( iconn ) );
470 kernelComponent.setup( iconn, stack );
471 kernelComponent.computeFlux( iconn, stack );
472 kernelComponent.computeDiffusion( iconn, stack );
473 kernelComponent.complete( iconn, stack );
528 template<
typename POLICY,
typename STENCILWRAPPER >
534 string const & dofKey,
535 string const & solverName,
537 STENCILWRAPPER
const & stencilWrapper,
542 singlePhaseReactiveBaseKernels::internal::kernelLaunchSelectorCompSwitch( numSpecies, [&](
auto NS )
544 integer constexpr NUM_SPECIES = NS();
545 integer constexpr NUM_DOF = 1+NS();
546 integer constexpr NUM_EQN = 1+NS();
550 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
553 typename KernelType::SinglePhaseFlowAccessors flowAccessors( elemManager, solverName );
554 typename KernelType::ReactiveSinglePhaseFlowAccessors reactiveFlowAccessors( elemManager, solverName );
555 typename KernelType::SinglePhaseFluidAccessors fluidAccessors( elemManager, solverName );
556 typename KernelType::ReactiveSinglePhaseFluidAccessors reactiveFluidAccessors( elemManager, solverName );
557 typename KernelType::PermeabilityAccessors permAccessors( elemManager, solverName );
558 typename KernelType::DiffusionAccessors diffusionAccessors( elemManager, solverName );
559 typename KernelType::PorosityAccessors porosityAccessors( elemManager, solverName );
561 KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor,
562 flowAccessors, reactiveFlowAccessors, fluidAccessors, reactiveFluidAccessors,
563 permAccessors, diffusionAccessors, porosityAccessors, hasDiffusion, mobilePrimarySpeciesFlags,
564 dt, localMatrix, localRhs );
565 KernelType::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.
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
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.
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< globalIndex const > > const m_dofNumber
Views on dof numbers.
real64 const m_dt
Time step size.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
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.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
static constexpr localIndex maxStencilSize
Maximum number of points in the stencil.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
static constexpr localIndex maxNumElems
Maximum number of elements at the face.
static void createAndLaunch(integer const numSpecies, integer const hasDiffusion, arrayView1d< integer const > const mobilePrimarySpeciesFlags, globalIndex const rankOffset, string const &dofKey, 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 flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
static constexpr integer numSpecies
Compile time value for the number of primary species.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
ElementViewConst< arrayView2d< real64 const, compflow::USD_FLUID_DC > > const m_dMob_dLogPrimaryConc
Views on derivatives of fluid mobilities.
ElementViewConst< arrayView3d< real64 const, constitutive::reactivefluid::USD_SPECIES > > const m_primarySpeciesMobileAggregateConc
Views on primary species aggregate concentration.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
integer const m_hasDiffusion
Flag of adding the diffusion term.
static constexpr integer numFluxSupportPoints
Number of flux support points (hard-coded for TFPA)
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
ElementViewConst< arrayView1d< real64 const > > const m_referencePorosity
View on the reference porosity.
arrayView1d< integer const > const m_mobilePrimarySpeciesFlags
Array of flags to indicate mobile primary species.
ElementViewConst< arrayView4d< real64 const, constitutive::reactivefluid::USD_SPECIES_DC > > const m_dPrimarySpeciesMobileAggregateConc_dLogPrimaryConc
Views on the derivative of primary species mobile aggregate concentration wrt log of primary concentr...
real64 const m_dt
Time step size.
FluxComputeKernel(globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, SinglePhaseFlowAccessors const &singlePhaseFlowAccessors, ReactiveSinglePhaseFlowAccessors const &reactiveSinglePhaseFlowAccessors, SinglePhaseFluidAccessors const &singlePhaseFluidAccessors, ReactiveSinglePhaseFluidAccessors const &reactiveSinglePhaseFluidAccessors, PermeabilityAccessors const &permeabilityAccessors, DiffusionAccessors const &diffusionAccessors, PorosityAccessors const &porosityAccessors, integer const &hasDiffusion, arrayView1d< integer const > const &mobilePrimarySpeciesFlags, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Constructor for the kernel interface.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
ElementViewConst< arrayView2d< real64 const, compflow::USD_COMP > > const m_logPrimarySpeciesConc
Views on log of primary species concentration.
GEOS_HOST_DEVICE void computeDiffusion(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local diffusion contributions to the residual and Jacobian.
ElementViewConst< arrayView3d< real64 const > > const m_diffusivity
Views on diffusivity.
ElementViewConst< arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > > const m_dens
Views on fluid density.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
static void launch(localIndex const numConnections, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
ArrayView< T, 1 > arrayView1d
Alias for 1D array 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).
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
int integer
Signed integer type.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 dTrans_dPres[maxNumConns][2]
Derivatives of transmissibility with respect to pressure.
real64 transmissibility[maxNumConns][2]
Transmissibility.
stackArray1d< globalIndex, maxNumElems *numDof > dofColIndices
Indices of the matrix rows/columns corresponding to the dofs in this face.
stackArray1d< real64, maxNumElems *numEqn > localFlux
Storage for the face local residual vector (all equations except volume balance)
localIndex const stencilSize
Stencil size for a given connection.
stackArray2d< real64, maxNumElems *numEqn *maxStencilSize *numDof > localFluxJacobian
Storage for the face local Jacobian matrix.
localIndex const numFluxElems
Number of elements for a given connection.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
GEOS_HOST_DEVICE StackVariables(localIndex const size, localIndex numElems)
Constructor for the stack variables.
real64 diffusionTransmissibility[maxNumConns][numFluxSupportPoints]
Diffusion transmissibility.
real64 dDiffusionTrans_dT[maxNumConns][numFluxSupportPoints]
Derivatives of diffusion transmissibility with respect to temperature.