20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_THERMALCOMPOSITIONALMULTIPHASEWELLKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_THERMALCOMPOSITIONALMULTIPHASEWELLKERNELS_HPP
25 #include "physicsSolvers/fluidFlow/wells/WellConstraintsBase.hpp"
26 #include "physicsSolvers/fluidFlow/wells/WellPhaseVolumeRateConstraint.hpp"
31 namespace thermalCompositionalMultiphaseWellKernels
34 using namespace constitutive;
44 template<
integer NUM_COMP,
integer NUM_PHASE >
49 using Base::m_dCompFrac_dCompDens;
50 using Base::m_dPhaseMassDens;
51 using Base::m_dPhaseVolFrac;
52 using Base::m_dTotalMassDens;
53 using Base::m_phaseMassDens;
54 using Base::m_phaseVolFrac;
55 using Base::m_totalMassDens;
65 MultiFluidBase
const & fluid )
66 :
Base( subRegion, fluid )
77 using Deriv = multifluid::DerivativeOffset;
79 arraySlice1d<
real64 const, compflow::USD_PHASE - 1 > phaseVolFrac = m_phaseVolFrac[ei];
80 arraySlice2d<
real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac = m_dPhaseVolFrac[ei];
81 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseMassDens = m_phaseMassDens[ei][0];
82 arraySlice2d<
real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseMassDens = m_dPhaseMassDens[ei][0];
84 real64 & dTotalMassDens_dT = m_dTotalMassDens[ei][Deriv::dT];
87 return Base::compute( ei, [&](
localIndex const ip )
89 dTotalMassDens_dT += dPhaseVolFrac[ip][Deriv::dT] * phaseMassDens[ip] + phaseVolFrac[ip] * dPhaseMassDens[ip][Deriv::dT];
112 template<
typename POLICY >
117 MultiFluidBase
const & fluid )
121 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&](
auto NC )
123 integer constexpr NUM_COMP = NC();
128 else if( numPhase == 3 )
130 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&](
auto NC )
132 integer constexpr NUM_COMP = NC();
145 template< localIndex NUM_COMP >
157 using Base::m_minNormalizer;
158 using Base::m_rankOffset;
159 using Base::m_localResidual;
160 using Base::m_dofNumber;
168 MultiFluidBase
const & fluid,
172 real64 const minNormalizer )
178 m_numPhases( fluid.numFluidPhases()),
179 m_targetPhaseIndex( wellControls.isProducer() ? wellControls.getConstraintPhaseIndex() : -1 ),
181 m_isLocallyOwned( subRegion.isLocallyOwned() ),
182 m_iwelemControl( subRegion.getTopWellElementIndex() ),
183 m_isProducer( wellControls.isProducer() ),
184 m_currentControl( wellControls.getControl() ),
185 m_targetBHP( wellControls.getTargetBHP( time ) ),
186 m_volume( subRegion.getElementVolume() ),
187 m_phaseDens_n( fluid.phaseDensity_n() ),
188 m_totalDens_n( fluid.totalDensity_n() ),
189 m_phaseVolFraction_n( subRegion.getField< fields::well::phaseVolumeFraction_n >()),
190 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n() )
199 if( rateConstraint !=
nullptr )
201 m_constraintValue = rateConstraint->getConstraintValue( time );
214 void computeMassEnergyNormalizers(
localIndex const iwelem,
216 real64 & energyNormalizer )
const
218 massNormalizer = LvArray::math::max( m_minNormalizer, m_totalDens_n[iwelem][0] * m_volume[iwelem] );
220 for(
integer ip = 0; ip < m_numPhases; ++ip )
222 energyNormalizer += m_phaseInternalEnergy_n[iwelem][0][ip] * m_phaseDens_n[iwelem][0][ip] * m_phaseVolFraction_n[iwelem][ip] * m_volume[iwelem];
225 energyNormalizer = LvArray::math::max( m_minNormalizer, LvArray::math::abs( energyNormalizer ) );
230 LinfStackVariables & stack )
const override
233 for(
integer idof = 0; idof < WJ_ROFFSET::nEqn; ++idof )
239 if( idof == WJ_ROFFSET::CONTROL )
243 if( m_isLocallyOwned && iwelem == m_iwelemControl )
248 normalizer = m_targetBHP;
253 normalizer = LvArray::math::max( LvArray::math::abs( m_constraintValue ), m_minNormalizer );
258 normalizer = LvArray::math::max( LvArray::math::abs( m_constraintValue ), m_minNormalizer );
263 normalizer = LvArray::math::max( LvArray::math::abs( m_constraintValue ), m_minNormalizer );
269 normalizer = m_targetBHP;
273 else if( idof >= WJ_ROFFSET::MASSBAL && idof < WJ_ROFFSET::MASSBAL + numComp )
278 normalizer = m_dt * LvArray::math::abs( m_constraintValue ) * m_phaseDens_n[iwelem][0][m_targetPhaseIndex];
284 normalizer = m_dt * LvArray::math::abs( m_constraintValue );
289 normalizer = m_dt * LvArray::math::abs( m_constraintValue ) * m_totalDens_n[iwelem][0];
295 normalizer = LvArray::math::max( normalizer, m_volume[iwelem] * m_totalDens_n[iwelem][0] );
298 else if( idof == WJ_ROFFSET::VOLBAL )
303 normalizer = m_dt * LvArray::math::abs( m_constraintValue );
309 normalizer = m_dt * LvArray::math::abs( m_constraintValue/ m_totalDens_n[iwelem][0] );
313 normalizer = m_dt * LvArray::math::abs( m_constraintValue );
318 normalizer = LvArray::math::max( normalizer, m_volume[iwelem] );
321 if( idof == WJ_ROFFSET::ENERGYBAL )
323 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
324 computeMassEnergyNormalizers( iwelem, massNormalizer, energyNormalizer );
325 real64 const valEnergy = LvArray::math::abs( m_localResidual[stack.localRow + WJ_ROFFSET::ENERGYBAL] ) / energyNormalizer;
326 if( valEnergy > stack.localValue[1] )
328 stack.localValue[1] = valEnergy;
334 normalizer = LvArray::math::max( m_minNormalizer, normalizer );
336 real64 const val = LvArray::math::abs( m_localResidual[stack.localRow + idof] ) / normalizer;
337 if( val > stack.localValue[0] )
339 stack.localValue[0] = val;
347 L2StackVariables & stack )
const override
350 GEOS_ERROR(
"The L2 norm is not implemented for CompositionalMultiphaseWell" );
413 template<
typename POLICY >
417 string const & dofKey,
420 MultiFluidBase
const & fluid,
424 real64 const minNormalizer,
425 real64 (& residualNorm)[2] )
427 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch ( numComp, [&](
auto NC )
430 integer constexpr NUM_COMP = NC();
435 kernelType kernel( rankOffset, localResidual, dofNumber, ghostRank,
436 subRegion, fluid, wellControls, time, dt, minNormalizer );
437 kernelType::template launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
451 template< localIndex NUM_COMP >
456 using Base::m_dCompFrac_dCompDens;
457 using Base::m_dofNumber;
458 using Base::m_dPhaseCompFrac;
459 using Base::m_dPhaseDens;
460 using Base::m_dPhaseVolFrac;
461 using Base::m_dPoro_dPres;
462 using Base::m_elemGhostRank;
463 using Base::m_localMatrix;
464 using Base::m_localRhs;
465 using Base::m_numPhases;
466 using Base::m_phaseCompFrac;
467 using Base::m_phaseCompFrac_n;
468 using Base::m_phaseDens;
469 using Base::m_phaseDens_n;
470 using Base::m_phaseVolFrac;
471 using Base::m_phaseVolFrac_n;
472 using Base::m_porosity;
473 using Base::m_porosity_n;
474 using Base::m_rankOffset;
475 using Base::m_volume;
480 using FLUID_PROP_COFFSET = multifluid::DerivativeOffsetC< NUM_COMP, 1 >;
494 bool const thermalEffectsEnabled,
499 MultiFluidBase
const & fluid,
502 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags >
const kernelFlags )
503 :
Base( numPhases, thermalEffectsEnabled, isProducer, rankOffset, dofKey, subRegion, fluid, localMatrix, localRhs, kernelFlags ),
504 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n()),
505 m_phaseInternalEnergy( fluid.phaseInternalEnergy()),
506 m_dPhaseInternalEnergy( fluid.dPhaseInternalEnergy())
514 : Base::StackVariables()
516 using Base::StackVariables::eqnRowIndices;
517 using Base::StackVariables::dofColIndices;
518 using Base::StackVariables::localJacobian;
519 using Base::StackVariables::localResidual;
520 using Base::StackVariables::localRow;
521 using Base::StackVariables::volume;
535 Base::setup( ei, stack );
551 using Deriv = multifluid::DerivativeOffset;
553 Base::computeAccumulation( ei, stack, [&](
integer const ip
554 ,
real64 const & phaseAmount
555 ,
real64 const & phaseAmount_n
556 ,
real64 const (&dPhaseAmount)[FLUID_PROP_COFFSET::nDer] )
563 real64 dPhaseInternalEnergy_dC[numComp]{};
566 arraySlice2d<
real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei];
567 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy_n = m_phaseInternalEnergy_n[ei][0];
568 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy = m_phaseInternalEnergy[ei][0];
569 arraySlice2d<
real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseInternalEnergy = m_dPhaseInternalEnergy[ei][0];
573 real64 const phaseEnergy = phaseAmount * phaseInternalEnergy[ip];
574 real64 const phaseEnergy_n = phaseAmount_n * phaseInternalEnergy_n[ip];
575 real64 const dPhaseEnergy_dP = dPhaseAmount[FLUID_PROP_COFFSET::dP] * phaseInternalEnergy[ip]
576 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dP];
577 real64 const dPhaseEnergy_dT = dPhaseAmount[FLUID_PROP_COFFSET::dT] * phaseInternalEnergy[ip]
578 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dT];
580 stack.localResidual[numEqn-1] += phaseEnergy - phaseEnergy_n;
583 stack.localJacobian[numEqn-1][0] += dPhaseEnergy_dP;
584 stack.localJacobian[numEqn-1][numDof-1] += dPhaseEnergy_dT;
587 applyChainRule( numComp, dCompFrac_dCompDens, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC );
588 for(
integer jc = 0; jc < numComp; ++jc )
590 stack.localJacobian[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount[FLUID_PROP_COFFSET::dC+jc]
591 + dPhaseInternalEnergy_dC[jc] * phaseAmount;
608 Base::computeVolumeBalance( ei, stack );
618 Base::complete( ei, stack );
651 template<
typename POLICY >
655 integer const thermalEffectsEnabled,
658 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags,
661 MultiFluidBase
const & fluid,
665 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
670 kernel( numPhases, thermalEffectsEnabled, isProducer, rankOffset, dofKey, subRegion, fluid, localMatrix, localRhs, kernelFlags );
672 launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP > >( subRegion.
size(), kernel );
684 template<
integer NC >
688 static constexpr
integer IS_THERMAL = 1;
695 using CP_Deriv = multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
700 using Base::m_isProducer;
702 using Base::m_localRhs;
703 using Base::m_localMatrix;
704 using Base::m_rankOffset;
705 using Base::maxNumElems;
706 using Base::maxStencilSize;
707 using Base::m_useTotalMassEquation;
713 static constexpr
integer numDof = WJ_COFFSET::nDer;
716 static constexpr
integer numEqn = WJ_ROFFSET::nEqn - 2;
734 string const wellDofKey,
737 MultiFluidBase
const & fluid,
740 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags )
749 m_numPhases ( fluid.numFluidPhases()),
750 m_thermalEffectsEnabled( wellControls.thermalEffectsEnabled() ),
751 m_globalWellElementIndex( subRegion.getGlobalWellElementIndex() ),
752 m_phaseFraction( fluid.phaseFraction()),
753 m_dPhaseFraction( fluid.dPhaseFraction()),
754 m_phaseEnthalpy( fluid.phaseEnthalpy()),
755 m_dPhaseEnthalpy( fluid.dPhaseEnthalpy())
779 Base::setup ( iwelem, stack );
787 for(
integer j=0; j< stack.stencilSize * numDof; j++ )
796 Base::complete ( iwelem, stack );
798 if( !m_thermalEffectsEnabled )
return;
799 using namespace compositionalMultiphaseUtilities;
800 if( stack.numConnectedElems ==1 )
803 globalIndex oneSidedEqnRowIndices = stack.offsetUp + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
805 if( oneSidedEqnRowIndices >= 0 && oneSidedEqnRowIndices < m_localMatrix.numRows() )
808 if( !m_isProducer && m_globalWellElementIndex[iwelem] == 0 )
813 for(
integer i=0; i< CP_Deriv::nDer; i++ )
815 stack.localEnergyFluxJacobian[0][i] = 0.0;
817 stack.localEnergyFluxJacobian_dQ[0][0]=0;
818 stack.localEnergyFlux[0]=0;
823 globalIndex oneSidedDofColIndices_dRate = stack.offsetCurrent + WJ_COFFSET::dQ;
824 globalIndex oneSidedDofColIndices_dPresCompTempUp[CP_Deriv::nDer]{};
827 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dP;
828 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dT;
829 for(
integer jdof = 0; jdof < NC; ++jdof )
831 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dC+ jdof;
834 m_localMatrix.template addToRow< parallelDeviceAtomic >( oneSidedEqnRowIndices,
835 &oneSidedDofColIndices_dRate,
836 stack.localEnergyFluxJacobian_dQ[0],
838 m_localMatrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( oneSidedEqnRowIndices,
839 oneSidedDofColIndices_dPresCompTempUp,
840 stack.localEnergyFluxJacobian[0],
842 RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[oneSidedEqnRowIndices], stack.localEnergyFlux[0] );
847 globalIndex row_current = stack.offsetCurrent + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
848 globalIndex row_next = stack.offsetNext + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
852 if( row_next >= 0 && row_next < m_localMatrix.numRows() )
854 if( m_globalWellElementIndex[stack.iwelemNext] == 0 )
856 for(
integer i=0; i<CP_Deriv::nDer; i++ )
857 stack.localEnergyFluxJacobian[TAG::NEXT][i] = 0.0;
858 stack.localEnergyFluxJacobian_dQ[TAG::NEXT][0] =0;
859 stack.localEnergyFlux[TAG::NEXT] =0;
869 eqnRowIndices[TAG::CURRENT ] = row_current;
870 eqnRowIndices[TAG::NEXT ] = row_next;
875 globalIndex dofColIndices_dRate = stack.offsetCurrent + WJ_COFFSET::dQ;
880 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dP;
882 if constexpr ( IS_THERMAL )
884 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dT;
886 for(
integer jdof = 0; jdof < NC; ++jdof )
888 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dC+ jdof;
891 for(
integer i = 0; i < 2; ++i )
893 if( eqnRowIndices[i] >= 0 && eqnRowIndices[i] < m_localMatrix.numRows() )
895 m_localMatrix.template addToRow< parallelDeviceAtomic >( eqnRowIndices[i],
896 &dofColIndices_dRate,
897 stack.localEnergyFluxJacobian_dQ[i],
899 m_localMatrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( eqnRowIndices[i],
901 stack.localEnergyFluxJacobian[i],
903 RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[eqnRowIndices[i]], stack.localEnergyFlux[i] );
922 Base::computeFlux ( iwelem, stack, [&] (
localIndex const & iwelemNext
924 ,
real64 const & currentConnRate
925 ,
real64 const (&dCompFrac_dCompDens)[NC][NC] )
928 if( iwelemNext < 0 && !m_isProducer )
932 for(
integer ip = 0; ip < m_numPhases; ++ip )
934 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
935 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
937 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dP] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
938 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
939 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dT] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
940 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
942 real64 dProp1_dC[numComp]{};
943 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dProp1_dC, CP_Deriv::dC );
944 real64 dProp2_dC[numComp]{};
945 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dProp2_dC, CP_Deriv::dC );
946 for(
integer dof=0; dof < numComp; dof++ )
949 + dProp1_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
952 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
960 else if( ( iwelemNext < 0 && m_isProducer ) )
964 for(
integer ip = 0; ip < m_numPhases; ++ip )
966 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
967 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
968 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dP] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
969 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
970 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dT] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
971 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
973 real64 dProp1_dC[numComp]{};
974 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dProp1_dC, CP_Deriv::dC );
975 real64 dProp2_dC[numComp]{};
976 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dProp2_dC, CP_Deriv::dC );
977 for(
integer dof=0; dof < numComp; dof++ )
980 + dProp1_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
985 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
996 for(
integer ip = 0; ip < m_numPhases; ++ip )
998 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
999 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
1001 real64 dprop_dp = m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
1002 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
1003 real64 dprop_dt = m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
1004 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
1012 real64 dPE_dC[numComp]{};
1013 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dPE_dC, CP_Deriv::dC );
1014 real64 dPF_dC[numComp]{};
1015 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dPF_dC, CP_Deriv::dC );
1017 for(
integer dof=0; dof < numComp; dof++ )
1020 +dPE_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
1021 stack.
localEnergyFluxJacobian[TAG::CURRENT ][CP_Deriv::dC+dof] += m_phaseEnthalpy[iwelemUp][0][ip]*dPF_dC[dof]
1022 +dPE_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
1026 stack.
localEnergyFlux[TAG::CURRENT ] = -m_dt * eflux * currentConnRate;
1029 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
1049 template<
typename POLICY,
typename KERNEL_TYPE >
1052 KERNEL_TYPE
const & kernelComponent )
1057 typename KERNEL_TYPE::StackVariables stack( 1 );
1059 kernelComponent.setup( ie, stack );
1060 kernelComponent.computeFlux( ie, stack );
1061 kernelComponent.complete( ie, stack );
1105 template<
typename POLICY >
1110 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags,
1111 string const dofKey,
1114 MultiFluidBase
const & fluid,
1118 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
1120 integer constexpr NUM_COMP = NC();
1123 kernelType kernel( dt, rankOffset, dofKey, wellControls, subRegion, fluid, localMatrix, localRhs, kernelFlags );
1124 kernelType::template launch< POLICY >( subRegion.
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_ERROR(...)
Raise a hard error and terminate the program.
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
array1d< integer > const & ghostRank()
Get the ghost information of each object.
real64 getConstraintValue(real64 const ¤tTime) const
Get the target bottom hole pressure value.
This class describes the controls used to operate a well.
This class describes a collection of local well elements and perforations.
Define the interface for the assembly kernel in charge of accumulation and volume balance.
Define the interface for the assembly kernel in charge of flux terms.
Define the interface for the property kernel in charge of computing the total mass density.
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Define the base interface for the property update kernels.
Define the base interface for the residual calculations.
static void createAndLaunch(localIndex const numComps, localIndex const numPhases, integer const thermalEffectsEnabled, integer const isProducer, globalIndex const rankOffset, BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags, string const dofKey, WellElementSubRegion const &subRegion, MultiFluidBase const &fluid, 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.
arrayView2d< real64 const > const m_dPoro_dTemp
View on derivative of porosity w.r.t temperature.
GEOS_HOST_DEVICE void computeVolumeBalance(localIndex const ei, StackVariables &stack) const
Compute the local volume balance contributions to the residual and Jacobian.
ElementBasedAssemblyKernel(localIndex const numPhases, bool const thermalEffectsEnabled, integer const isProducer, globalIndex const rankOffset, string const dofKey, WellElementSubRegion const &subRegion, MultiFluidBase const &fluid, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > const kernelFlags)
Constructor.
arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseInternalEnergy_n
Views on phase internal energy.
GEOS_HOST_DEVICE void computeAccumulation(localIndex const ei, StackVariables &stack) 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.
static void createAndLaunch(integer const numComps, real64 const dt, globalIndex const rankOffset, BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags, string const dofKey, WellControls const &wellControls, WellElementSubRegion const &subRegion, MultiFluidBase const &fluid, 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.
integer const m_numPhases
Number of phases.
FaceBasedAssemblyKernel(real64 const dt, globalIndex const rankOffset, string const wellDofKey, WellControls const &wellControls, WellElementSubRegion const &subRegion, MultiFluidBase const &fluid, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags)
Constructor for the kernel interface.
bool const m_thermalEffectsEnabled
Flag specifying whether thermal effects are enabled.
arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseEnthalpy
Views on phase enthalpy.
GEOS_HOST_DEVICE void computeFlux(localIndex const iwelem, StackVariables &stack) const
Compute the local flux contributions to the residual and Jacobian.
arrayView1d< globalIndex const > m_globalWellElementIndex
Global index of local element.
arrayView3d< real64 const, multifluid::USD_PHASE > const m_phaseFraction
Element phase fraction.
static void launch(localIndex const numElements, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
static void createAndLaunch(integer const numComp, globalIndex const rankOffset, string const &dofKey, arrayView1d< real64 const > const &localResidual, WellElementSubRegion const &subRegion, MultiFluidBase const &fluid, WellControls const &wellControls, real64 const time, real64 const dt, real64 const minNormalizer, real64(&residualNorm)[2])
Create a new kernel and launch.
integer const m_numPhases
Number of fluid phases.
real64 const m_dt
Time step size.
integer m_targetPhaseIndex
Index of the target phase.
arrayView3d< real64 const, multifluid::USD_PHASE > const m_phaseDens_n
View on phase/total density at the previous converged time step.
localIndex const m_iwelemControl
Index of the element where the control is enforced.
ConstraintTypeId const m_currentControl
Controls.
virtual GEOS_HOST_DEVICE void computeLinf(localIndex const iwelem, LinfStackVariables &stack) const override
Compute the local values for the Linf norm.
arrayView1d< real64 const > const m_volume
View on the volume.
virtual GEOS_HOST_DEVICE void computeL2(localIndex const iwelem, L2StackVariables &stack) const override
Compute the local values and normalizer for the L2 norm.
bool const m_isProducer
Flag indicating whether the well is a producer or an injector.
bool const m_isLocallyOwned
Flag indicating whether the well is locally owned or not.
static void createAndLaunch(integer const numComp, integer const numPhase, ObjectManagerBase &subRegion, MultiFluidBase const &fluid)
Create a new kernel and launch.
Define the interface for the property kernel in charge of computing the total mass density.
GEOS_HOST_DEVICE void compute(localIndex const ei) const
Compute the total mass density in an element.
TotalMassDensityKernel(ObjectManagerBase &subRegion, MultiFluidBase const &fluid)
Constructor.
ConstraintTypeId getControl() const
Get the control type for the well.
stdVector< WellConstraintBase const * > getRateConstraints() const
Gets a list of rate constraints.
WellConstraintBase * getCurrentConstraint()
Get the current consrtaint.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
StackArray< T, 2, MAXSIZE > stackArray2d
Alias for 2D stack array.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
StackArray< T, 1, MAXSIZE > stackArray1d
Alias for 1D stack array.
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.
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.
Array< T, 1 > array1d
Alias for 1D array.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
localIndex numConnectedElems
Number of elements connected at a given connection.
stackArray1d< real64, maxNumElems > localEnergyFlux
Storage for the face local residual vector (energy equation)
stackArray2d< real64, maxNumElems *maxStencilSize > localEnergyFluxJacobian_dQ
Storage for the face local Jacobian matrix dQ only.
stackArray2d< real64, maxNumElems *maxStencilSize *CP_Deriv::nDer > localEnergyFluxJacobian
Storage for the face local energy Jacobian matrix dC dP dT.