20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVE_SOURCEFLUXCOMPUTEKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVE_SOURCEFLUXCOMPUTEKERNELS_HPP
24 #include "common/GEOS_RAJA_Interface.hpp"
25 #include "constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp"
26 #include "constitutive/fluid/reactivefluid/ReactiveFluidLayouts.hpp"
27 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
28 #include "constitutive/fluid/singlefluid/SingleFluidUtils.hpp"
29 #include "codingUtilities/Utilities.hpp"
31 #include "physicsSolvers/fluidFlow/kernels/singlePhase/reactive/KernelLaunchSelectors.hpp"
36 namespace singlePhaseReactiveBaseKernels
45 template<
integer NUM_DOF,
integer NUM_SPECIES,
typename BASE_FLUID_TYPE >
60 using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
66 real64 const sizeScalingFactor,
67 constitutive::reactivefluid::ReactiveSinglePhaseFluid< BASE_FLUID_TYPE >
const & fluid,
70 RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd )
77 m_primarySpeciesAggregateConcentration( fluid.primarySpeciesAggregateConcentration() ),
78 m_dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations( fluid.dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations() ),
79 m_density( fluid.density() ),
80 m_dDensity( fluid.dDensity() ),
83 m_massProd( massProd )
106 real64 totalInflowMass = 0.0;
154 stack.
localSpeciesRhs[i] += m_primarySpeciesAggregateConcentration[ei][0][i] / m_density[ei][0] * scaledInflowMass;
155 stack.
localSpeciesJacobian[i][0] += -m_primarySpeciesAggregateConcentration[ei][0][i] * m_dDensity[ei][0][DerivOffset::dP] / (m_density[ei][0] * m_density[ei][0]) * scaledInflowMass;
159 stack.
localSpeciesJacobian[i][j+
numDof-
numSpecies] += m_dPrimarySpeciesAggregateConcentration_dLogPrimarySpeciesConcentrations[ei][0][i][j] / m_density[ei][0] * scaledInflowMass;
176 if( stack.totalInflowMass > 0.0 )
184 m_localMatrix.template addToRow< serialAtomic >( speciesRowBeginIndex+i,
199 template<
typename POLICY,
typename KERNEL_TYPE >
202 KERNEL_TYPE
const & kernelComponent )
211 if( kernelComponent.elemGhostRank( ei ) >= 0 )
216 typename KERNEL_TYPE::StackVariables stack;
218 kernelComponent.setup( ei, a, stack );
219 kernelComponent.computeSourceFlux( ei, stack );
220 kernelComponent.complete( ei, stack );
255 RAJA::ReduceSum< parallelDeviceReduce, real64 > m_massProd;
281 template<
typename POLICY,
typename BASE_FLUID_TYPE >
289 real64 const sizeScalingFactor,
290 constitutive::reactivefluid::ReactiveSinglePhaseFluid< BASE_FLUID_TYPE >
const & fluid,
293 RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd )
295 internal::kernelLaunchSelectorCompSwitch( numSpecies, [&] (
auto NS )
297 integer constexpr NUM_SPECIES = NS();
298 integer constexpr NUM_DOF = 1+NS();
300 SourceFluxComputeKernel< NUM_DOF, NUM_SPECIES, BASE_FLUID_TYPE > kernel( rankOffset, dofNumber, elemGhostRank, rhsContributionArrayView, sizeScalingFactor, fluid, localMatrix, localRhs,
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
static void createAndLaunch(integer const numSpecies, globalIndex const rankOffset, arrayView1d< globalIndex const > const dofNumber, arrayView1d< integer const > const elemGhostRank, SortedArrayView< localIndex const > const targetSet, arrayView1d< real64 const > const rhsContributionArrayView, real64 const sizeScalingFactor, constitutive::reactivefluid::ReactiveSinglePhaseFluid< BASE_FLUID_TYPE > const &fluid, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, RAJA::ReduceSum< parallelDeviceReduce, real64 > massProd)
Create a new kernel and launch.
Define the interface for the assembly kernel in charge of source flux.
static void launch(SortedArrayView< localIndex const > const targetSet, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
GEOS_HOST_DEVICE void setup(localIndex const ei, localIndex const a, StackVariables &stack) const
Performs the setup phase for the kernel.
GEOS_HOST_DEVICE void complete(localIndex const GEOS_UNUSED_PARAM(ei), StackVariables &stack) const
Performs the complete phase for the kernel.
GEOS_HOST_DEVICE void computeSourceFlux(localIndex const ei, StackVariables &stack) const
Compute the local source flux contributions to the residual and Jacobian.
arrayView1d< real64 const > const m_rhsContributionArrayView
View on the rhs contribution.
GEOS_HOST_DEVICE integer elemGhostRank(localIndex const ei) const
Getter for the ghost rank of an element.
arrayView1d< integer const > const m_elemGhostRank
View on the ghost ranks.
arrayView1d< globalIndex const > const m_dofNumber
View on the dof numbers.
static constexpr integer numSpecies
Compile time value for the number of primary species.
static constexpr integer numEqn
Compute time value for the number of equations.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
globalIndex const m_rankOffset
Offset for my MPI rank.
real64 const m_sizeScalingFactor
size scaling factor
arrayView1d< real64 > const m_localRhs
View on the local RHS.
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.
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
int integer
Signed integer type.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 localSpeciesRhs[numSpecies]
Storage for the element local residual vector for species rows.
globalIndex dofIndices[numDof]
Index of the matrix row/column corresponding to the dof in this element.
real64 localSpeciesJacobian[numSpecies][numDof]
Storage for the element local Jacobian matrix for species rows.
localIndex massRowIndex
Index of the local row corresponding to this element.