20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALACCUMULATIONKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALACCUMULATIONKERNEL_HPP
23 #include "physicsSolvers/fluidFlow/kernels/compositional/AccumulationKernel.hpp"
28 namespace thermalCompositionalMultiphaseBaseKernels
39 template< localIndex NUM_COMP, localIndex NUM_DOF >
54 using Base::m_dPoro_dPres;
57 using Base::m_dPhaseVolFrac;
59 using Base::m_dPhaseDens;
61 using Base::m_dPhaseCompFrac;
80 constitutive::MultiFluidBase
const & fluid,
81 constitutive::CoupledSolidBase
const & solid,
84 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags >
const kernelFlags )
85 :
Base( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs, kernelFlags ),
88 m_dPhaseInternalEnergy( fluid.dPhaseInternalEnergy() ),
90 m_dRockInternalEnergy_dTemp( solid.getDinternalEnergy_dTemperature() ),
91 m_energy_n( subRegion.getField< fields::flow::energy_n >() )
109 real64 dPoreVolume_dTemp = 0.0;
140 real64 const dSolidVolume_dPres = -
m_volume[ei] * m_dPoro_dPres[ei][0];
141 real64 const dSolidVolume_dTemp = -stack.dPoreVolume_dTemp;
160 using Deriv = constitutive::multifluid::DerivativeOffset;
166 real64 const & phaseAmount,
167 real64 const & dPhaseAmount_dP,
180 arraySlice2d<
real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac = m_dPhaseVolFrac[ei];
182 arraySlice2d<
real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > dPhaseDens = m_dPhaseDens[ei][0];
184 arraySlice3d<
real64 const, constitutive::multifluid::USD_PHASE_COMP_DC - 2 > dPhaseCompFrac = m_dPhaseCompFrac[ei][0];
186 arraySlice2d<
real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > dPhaseInternalEnergy = m_dPhaseInternalEnergy[ei][0];
190 real64 const dPhaseAmount_dT = stack.dPoreVolume_dTemp * phaseVolFrac[ip] * phaseDens[ip]
191 + stack.
poreVolume * (dPhaseVolFrac[ip][Deriv::dT] * phaseDens[ip] + phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dT] );
195 + phaseAmount * dPhaseCompFrac[ip][ic][Deriv::dT];
200 real64 const phaseEnergy = phaseAmount * phaseInternalEnergy[ip];
201 real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip]
202 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dP];
203 real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip]
204 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dT];
214 applyChainRule(
numComp, dCompFrac_dCompDens, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC );
218 + dPhaseInternalEnergy_dC[jc] * phaseAmount;
241 using Deriv = constitutive::multifluid::DerivativeOffset;
247 arraySlice2d<
real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac = m_dPhaseVolFrac[ei];
258 StackVariables & stack )
const
267 stack.localJacobian[
numEqn-1],
309 template<
typename POLICY >
314 integer const useTotalMassEquation,
317 constitutive::MultiFluidBase
const & fluid,
318 constitutive::CoupledSolidBase
const & solid,
322 isothermalCompositionalMultiphaseBaseKernels::
323 internal::kernelLaunchSelectorCompSwitch( numComps, [&] (
auto NC )
328 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags;
329 if( useTotalMassEquation )
330 kernelFlags.set( isothermalCompositionalMultiphaseBaseKernels::KernelFlags::TotalMassEquation );
333 fluid, solid, localMatrix, localRhs, kernelFlags );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Define the interface for the assembly kernel in charge of accumulation and volume balance.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
arrayView2d< real64 const, compflow::USD_PHASE > const m_phaseVolFrac
Views on the phase volume fractions.
GEOS_HOST_DEVICE void complete(localIndex const GEOS_UNUSED_PARAM(ei), StackVariables &stack) const
Performs the complete phase for the kernel.
arrayView1d< integer const > const m_elemGhostRank
View on the ghost ranks.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const m_phaseCompFrac
Views on the phase component fraction.
static constexpr integer numEqn
Compute time value for the number of equations.
GEOS_HOST_DEVICE void computeVolumeBalance(localIndex const ei, StackVariables &stack, FUNC &&phaseVolFractionSumKernelOp=NoOpFunc{}) const
Compute the local volume balance contributions to the residual and Jacobian.
arrayView3d< real64 const, compflow::USD_COMP_DC > const m_dCompFrac_dCompDens
Views on the derivatives of comp fractions wrt component density.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const m_phaseDens
Views on the phase densities.
arrayView2d< real64 const > const m_porosity
Views on the porosity.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
GEOS_HOST_DEVICE void computeAccumulation(localIndex const ei, StackVariables &stack, FUNC &&phaseAmountKernelOp=NoOpFunc{}) const
Compute the local accumulation contributions to the residual and Jacobian.
GEOS_HOST_DEVICE void setup(localIndex const ei, StackVariables &stack) const
Performs the setup phase for the kernel.
arrayView1d< real64 const > const m_volume
View on the element volumes.
integer const m_numPhases
Number of fluid phases.
static constexpr integer numComp
Compile time value for the number of components.
globalIndex const m_rankOffset
Offset for my MPI rank.
arrayView1d< globalIndex const > const m_dofNumber
View on the dof numbers.
static void createAndLaunch(localIndex const numComps, localIndex const numPhases, globalIndex const rankOffset, integer const useTotalMassEquation, string const dofKey, ElementSubRegionBase const &subRegion, constitutive::MultiFluidBase const &fluid, constitutive::CoupledSolidBase const &solid, 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 thermal accumulation and volume balance.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
arrayView2d< real64 const, compflow::USD_PHASE > const m_phaseVolFrac
Views on the phase volume fractions.
arrayView2d< real64 const > m_rockInternalEnergy
Views on rock internal energy.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
arrayView1d< real64 const > m_energy_n
Views on energy.
arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const m_phaseCompFrac
Views on the phase component fraction.
static constexpr integer numEqn
Compute time value for the number of equations.
AccumulationKernel(localIndex const numPhases, globalIndex const rankOffset, string const dofKey, ElementSubRegionBase const &subRegion, constitutive::MultiFluidBase const &fluid, constitutive::CoupledSolidBase const &solid, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > const kernelFlags)
Constructor.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_phaseInternalEnergy
Views on phase internal energy.
GEOS_HOST_DEVICE void computeVolumeBalance(localIndex const ei, StackVariables &stack) const
Compute the local volume balance contributions to the residual and Jacobian.
arrayView3d< real64 const, compflow::USD_COMP_DC > const m_dCompFrac_dCompDens
Views on the derivatives of comp fractions wrt component density.
arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const m_phaseDens
Views on the phase densities.
arrayView2d< real64 const > const m_porosity
Views on the porosity.
GEOS_HOST_DEVICE void computeAccumulation(localIndex const ei, StackVariables &stack) const
Compute the local accumulation contributions to the residual and Jacobian.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
arrayView1d< real64 const > const m_volume
View on the element volumes.
GEOS_HOST_DEVICE void setup(localIndex const ei, StackVariables &stack) const
Performs the setup phase for the kernel.
integer const m_numPhases
Number of fluid phases.
arrayView2d< real64 const > const m_dPoro_dTemp
View on derivative of porosity w.r.t temperature.
static constexpr integer numComp
Compile time value for the number of components.
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).
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
ArraySlice< T, 3, USD > arraySlice3d
Alias for 3D array slice.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
std::int32_t integer
Signed integer type.
ArrayView< T, 4, USD > arrayView4d
Alias for 4D array view.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
globalIndex dofIndices[numDof]
Indices of the matrix rows/columns corresponding to the dofs in this element.
localIndex localRow
Index of the local row corresponding to this element.
real64 poreVolume
Pore volume at time n+1.
real64 localJacobian[numEqn][numDof]
C-array storage for the element local Jacobian matrix (all equations except volume balance,...
real64 localResidual[numEqn]
C-array storage for the element local residual vector (all equations except volume balance)
real64 dSolidEnergy_dPres
Derivative of solid internal energy with respect to pressure.
real64 dSolidEnergy_dTemp
Derivative of solid internal energy with respect to temperature.
real64 solidEnergy
Solid energy at time n+1.