20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALDIRICHLETFLUXCOMPUTEKERNEL_IMPL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALDIRICHLETFLUXCOMPUTEKERNEL_IMPL_HPP
28 namespace thermalCompositionalMultiphaseFVMKernels
31 template<
typename FLUIDWRAPPER,
typename POLICY,
integer NUM_COMP,
integer NUM_DOF >
37 FLUIDWRAPPER
const & fluidWrapper,
38 DofNumberAccessor
const & dofNumberAccessor,
49 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags )
59 permeabilityAccessors,
64 m_temp( thermalCompFlowAccessors.get( fields::flow::temperature {} ) ),
65 m_phaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::phaseEnthalpy {} ) ),
66 m_dPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::dPhaseEnthalpy {} ) ),
67 m_thermalConductivity( thermalConductivityAccessors.get( fields::thermalconductivity::effectiveConductivity {} ) )
70 template<
typename FLUIDWRAPPER,
typename POLICY,
integer NUM_COMP,
integer NUM_DOF >
74 this->
template launch< POLICY >( numConnections, *
this );
77 template<
typename FLUIDWRAPPER,
typename POLICY,
integer NUM_COMP,
integer NUM_DOF >
84 using Deriv = constitutive::multifluid::DerivativeOffset;
94 Base::computeFlux( iconn, stack, [&] (
integer const ip,
100 real64 const facePhaseMob,
104 real64 const dPhaseFlux_dP,
105 real64 const (&dPhaseFlux_dC)[numComp] )
111 real64 const dDensMean_dT = 0.5 * m_dPhaseMassDens[er][esr][ei][0][ip][Deriv::dT];
116 real64 const dF_dT = -stack.transmissibility * dDensMean_dT * ( m_gravCoef[er][esr][ei] - m_faceGravCoef[kf] );
129 real64 const dPhaseFlux_dT = m_phaseMob[er][esr][ei][ip] * dF_dT + m_dPhaseMob[er][esr][ei][ip][Deriv::dT] * f;
134 arraySlice1d<
real64 const, constitutive::multifluid::USD_PHASE_COMP - 3 > phaseCompFracSub =
135 m_phaseCompFrac[er][esr][ei][0][ip];
136 arraySlice2d<
real64 const, constitutive::multifluid::USD_PHASE_COMP_DC - 3 > dPhaseCompFracSub =
137 m_dPhaseCompFrac[er][esr][ei][0][ip];
139 for(
integer ic = 0; ic < numComp; ++ic )
141 real64 const ycp = phaseCompFracSub[ic];
142 stack.
dCompFlux_dT[ic] += dPhaseFlux_dT * ycp + phaseFlux * dPhaseCompFracSub[ic][Deriv::dT];
147 real64 const enthalpy = m_phaseEnthalpy[er][esr][ei][0][ip];
149 stack.
dEnergyFlux_dP += dPhaseFlux_dP * enthalpy + phaseFlux * m_dPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dP];
150 stack.
dEnergyFlux_dT += dPhaseFlux_dT * enthalpy + phaseFlux * m_dPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dT];
152 real64 dProp_dC[numComp]{};
153 applyChainRule( numComp,
154 m_dCompFrac_dCompDens[er][esr][ei],
155 m_dPhaseEnthalpy[er][esr][ei][0][ip],
158 for(
integer jc = 0; jc < numComp; ++jc )
160 stack.
dEnergyFlux_dC[jc] += dPhaseFlux_dC[jc] * enthalpy + phaseFlux * dProp_dC[jc];
168 real64 const dPhaseFlux_dT = facePhaseMob * dF_dT;
172 for(
integer ic = 0; ic < numComp; ++ic )
174 real64 const ycp = facePhaseCompFrac[ip][ic];
180 real64 const enthalpy = facePhaseEnthalpy[ip];
184 for(
integer jc = 0; jc < numComp; ++jc )
202 real64 thermalTrans = 0.0;
203 real64 dThermalTrans_dPerm[3]{};
204 m_stencilWrapper.computeWeights( iconn,
205 m_thermalConductivity,
207 dThermalTrans_dPerm );
211 * ( m_temp[m_seri( iconn, Order::ELEM )][m_sesri( iconn, Order::ELEM )][m_sei( iconn, Order::ELEM )] - m_faceTemp[m_sei( iconn, Order::FACE )] );
222 for(
integer ic = 0; ic < numComp; ++ic )
228 integer const localRowIndexEnergy = numEqn-1;
233 for(
integer jc = 0; jc < numComp; ++jc )
239 template<
typename FLUIDWRAPPER,
typename POLICY,
integer NUM_COMP,
integer NUM_DOF >
247 Base::complete( iconn, stack, [&] (
localIndex const localRow )
250 RAJA::atomicAdd( parallelDeviceAtomic{}, &AbstractBase::m_localRhs[localRow + numEqn], stack.
localFlux[numEqn-1] );
251 AbstractBase::m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >
#define GEOS_HOST_DEVICE
Marks a host-device function.
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
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 Dirichlet face flux terms.
void launchKernel(localIndex const numConnections)
Launch the kernel for a given number of connections.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack) const
Performs the complete phase for the kernel.
DirichletFluxComputeKernel(integer const numPhases, globalIndex const rankOffset, FaceManager const &faceManager, BoundaryStencilWrapper const &stencilWrapper, FLUIDWRAPPER const &fluidWrapper, DofNumberAccessor const &dofNumberAccessor, CompFlowAccessors const &compFlowAccessors, ThermalCompFlowAccessors const &thermalCompFlowAccessors, MultiFluidAccessors const &multiFluidAccessors, ThermalMultiFluidAccessors const &thermalMultiFluidAccessors, CapPressureAccessors const &capPressureAccessors, PermeabilityAccessors const &permeabilityAccessors, ThermalConductivityAccessors const &thermalConductivityAccessors, real64 const dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags)
Constructor for the kernel interface.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack) const
Compute the local flux contributions to the residual and Jacobian.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D 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.
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
int integer
Signed integer type.
Defines the order of element/face in the stencil.
real64 localFlux[numEqn]
Storage for the face local residual vector.
real64 localFluxJacobian[numEqn][numDof]
Storage for the face local Jacobian matrix.
globalIndex dofColIndices[numDof]
Indices of the matrix rows/columns corresponding to the dofs in this face.
real64 dEnergyFlux_dT
Derivative of energy fluxes wrt temperature.
real64 dCompFlux_dT[numComp]
Derivatives of component fluxes wrt temperature.
real64 dEnergyFlux_dP
Derivative of energy fluxes wrt pressure.
real64 dEnergyFlux_dC[numComp]
Derivatives of energy fluxes wrt component densities.
real64 energyFlux
Energy fluxes.