20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_THERMALCOMPOSITIONALMULTIPHASEWELLKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_THERMALCOMPOSITIONALMULTIPHASEWELLKERNELS_HPP
29 namespace thermalCompositionalMultiphaseWellKernels
32 using namespace constitutive;
42 template<
integer NUM_COMP,
integer NUM_PHASE >
47 using Base::m_dCompFrac_dCompDens;
48 using Base::m_dPhaseMassDens;
49 using Base::m_dPhaseVolFrac;
50 using Base::m_dTotalMassDens;
51 using Base::m_phaseMassDens;
52 using Base::m_phaseVolFrac;
53 using Base::m_totalMassDens;
63 MultiFluidBase
const & fluid )
64 :
Base( subRegion, fluid )
75 using Deriv = multifluid::DerivativeOffset;
77 arraySlice1d<
real64 const, compflow::USD_PHASE - 1 > phaseVolFrac = m_phaseVolFrac[ei];
78 arraySlice2d<
real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac = m_dPhaseVolFrac[ei];
79 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseMassDens = m_phaseMassDens[ei][0];
80 arraySlice2d<
real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseMassDens = m_dPhaseMassDens[ei][0];
82 real64 & dTotalMassDens_dT = m_dTotalMassDens[ei][Deriv::dT];
85 return Base::compute( ei, [&](
localIndex const ip )
87 dTotalMassDens_dT += dPhaseVolFrac[ip][Deriv::dT] * phaseMassDens[ip] + phaseVolFrac[ip] * dPhaseMassDens[ip][Deriv::dT];
110 template<
typename POLICY >
115 MultiFluidBase
const & fluid )
119 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&](
auto NC )
121 integer constexpr NUM_COMP = NC();
126 else if( numPhase == 3 )
128 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&](
auto NC )
130 integer constexpr NUM_COMP = NC();
143 template< localIndex NUM_COMP >
155 using Base::m_minNormalizer;
156 using Base::m_rankOffset;
157 using Base::m_localResidual;
158 using Base::m_dofNumber;
164 integer const targetPhaseIndex,
166 MultiFluidBase
const & fluid,
168 real64 const timeAtEndOfStep,
170 real64 const minNormalizer )
176 m_numPhases( fluid.numFluidPhases()),
177 m_targetPhaseIndex( targetPhaseIndex ),
179 m_isLocallyOwned( subRegion.isLocallyOwned() ),
180 m_iwelemControl( subRegion.getTopWellElementIndex() ),
181 m_isProducer( wellControls.isProducer() ),
182 m_currentControl( wellControls.getControl() ),
183 m_targetBHP( wellControls.getTargetBHP( timeAtEndOfStep ) ),
184 m_targetTotalRate( wellControls.getTargetTotalRate( timeAtEndOfStep ) ),
185 m_targetPhaseRate( wellControls.getTargetPhaseRate( timeAtEndOfStep ) ),
186 m_targetMassRate( wellControls.getTargetMassRate( timeAtEndOfStep ) ),
187 m_volume( subRegion.getElementVolume() ),
188 m_phaseDens_n( fluid.phaseDensity_n() ),
189 m_totalDens_n( fluid.totalDensity_n() ),
190 m_phaseVolFraction_n( subRegion.getField< fields::well::phaseVolumeFraction_n >()),
191 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n() )
196 void computeMassEnergyNormalizers(
localIndex const iwelem,
198 real64 & energyNormalizer )
const
200 massNormalizer = LvArray::math::max( m_minNormalizer, m_totalDens_n[iwelem][0] * m_volume[iwelem] );
202 for(
integer ip = 0; ip < m_numPhases; ++ip )
204 energyNormalizer += m_phaseInternalEnergy_n[iwelem][0][ip] * m_phaseDens_n[iwelem][0][ip] * m_phaseVolFraction_n[iwelem][ip] * m_volume[iwelem];
207 energyNormalizer = LvArray::math::max( m_minNormalizer, LvArray::math::abs( energyNormalizer ) );
212 LinfStackVariables & stack )
const override
215 for(
integer idof = 0; idof < WJ_ROFFSET::nEqn; ++idof )
221 if( idof == WJ_ROFFSET::CONTROL )
225 if( m_isLocallyOwned && iwelem == m_iwelemControl )
230 normalizer = m_targetBHP;
235 normalizer = LvArray::math::max( LvArray::math::abs( m_targetTotalRate ), m_minNormalizer );
240 normalizer = LvArray::math::max( LvArray::math::abs( m_targetPhaseRate ), m_minNormalizer );
245 normalizer = LvArray::math::max( LvArray::math::abs( m_targetMassRate ), m_minNormalizer );
251 normalizer = m_targetBHP;
255 else if( idof >= WJ_ROFFSET::MASSBAL && idof < WJ_ROFFSET::MASSBAL + numComp )
260 normalizer = m_dt * LvArray::math::abs( m_targetPhaseRate ) * m_phaseDens_n[iwelem][0][m_targetPhaseIndex];
266 normalizer = m_dt * LvArray::math::abs( m_targetMassRate );
271 normalizer = m_dt * LvArray::math::abs( m_targetTotalRate ) * m_totalDens_n[iwelem][0];
277 normalizer = LvArray::math::max( normalizer, m_volume[iwelem] * m_totalDens_n[iwelem][0] );
280 else if( idof == WJ_ROFFSET::VOLBAL )
285 normalizer = m_dt * LvArray::math::abs( m_targetPhaseRate );
291 normalizer = m_dt * LvArray::math::abs( m_targetMassRate/ m_totalDens_n[iwelem][0] );
295 normalizer = m_dt * LvArray::math::abs( m_targetTotalRate );
300 normalizer = LvArray::math::max( normalizer, m_volume[iwelem] );
303 if( idof == WJ_ROFFSET::ENERGYBAL )
305 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
306 computeMassEnergyNormalizers( iwelem, massNormalizer, energyNormalizer );
307 real64 const valEnergy = LvArray::math::abs( m_localResidual[stack.localRow + WJ_ROFFSET::ENERGYBAL] ) / energyNormalizer;
308 if( valEnergy > stack.localValue[1] )
310 stack.localValue[1] = valEnergy;
316 normalizer = LvArray::math::max( m_minNormalizer, normalizer );
318 real64 const val = LvArray::math::abs( m_localResidual[stack.localRow + idof] ) / normalizer;
319 if( val > stack.localValue[0] )
321 stack.localValue[0] = val;
329 L2StackVariables & stack )
const override
332 GEOS_ERROR(
"The L2 norm is not implemented for CompositionalMultiphaseWell" );
359 real64 const m_targetTotalRate;
360 real64 const m_targetPhaseRate;
361 real64 const m_targetMassRate;
397 template<
typename POLICY >
400 integer const targetPhaseIndex,
402 string const & dofKey,
405 MultiFluidBase
const & fluid,
407 real64 const timeAtEndOfStep,
409 real64 const minNormalizer,
410 real64 (& residualNorm)[2] )
412 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch ( numComp, [&](
auto NC )
415 integer constexpr NUM_COMP = NC();
420 kernelType kernel( rankOffset, localResidual, dofNumber, ghostRank,
421 targetPhaseIndex, subRegion, fluid, wellControls, timeAtEndOfStep, dt, minNormalizer );
422 kernelType::template launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
436 template< localIndex NUM_COMP >
441 using Base::m_dCompFrac_dCompDens;
442 using Base::m_dofNumber;
443 using Base::m_dPhaseCompFrac;
444 using Base::m_dPhaseDens;
445 using Base::m_dPhaseVolFrac;
446 using Base::m_dPoro_dPres;
447 using Base::m_elemGhostRank;
448 using Base::m_localMatrix;
449 using Base::m_localRhs;
450 using Base::m_numPhases;
451 using Base::m_phaseCompFrac;
452 using Base::m_phaseCompFrac_n;
453 using Base::m_phaseDens;
454 using Base::m_phaseDens_n;
455 using Base::m_phaseVolFrac;
456 using Base::m_phaseVolFrac_n;
457 using Base::m_porosity;
458 using Base::m_porosity_n;
459 using Base::m_rankOffset;
460 using Base::m_volume;
465 using FLUID_PROP_COFFSET = multifluid::DerivativeOffsetC< NUM_COMP, 1 >;
483 MultiFluidBase
const & fluid,
486 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags >
const kernelFlags )
487 :
Base( numPhases, isProducer, rankOffset, dofKey, subRegion, fluid, localMatrix, localRhs, kernelFlags ),
488 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n()),
489 m_phaseInternalEnergy( fluid.phaseInternalEnergy()),
490 m_dPhaseInternalEnergy( fluid.dPhaseInternalEnergy())
498 : Base::StackVariables()
500 using Base::StackVariables::eqnRowIndices;
501 using Base::StackVariables::dofColIndices;
502 using Base::StackVariables::localJacobian;
503 using Base::StackVariables::localResidual;
504 using Base::StackVariables::localRow;
505 using Base::StackVariables::volume;
519 Base::setup( ei, stack );
535 using Deriv = multifluid::DerivativeOffset;
537 Base::computeAccumulation( ei, stack, [&](
integer const ip
538 ,
real64 const & phaseAmount
539 ,
real64 const & phaseAmount_n
540 ,
real64 const (&dPhaseAmount)[FLUID_PROP_COFFSET::nDer] )
547 real64 dPhaseInternalEnergy_dC[numComp]{};
550 arraySlice2d<
real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei];
551 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy_n = m_phaseInternalEnergy_n[ei][0];
552 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy = m_phaseInternalEnergy[ei][0];
553 arraySlice2d<
real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseInternalEnergy = m_dPhaseInternalEnergy[ei][0];
557 real64 const phaseEnergy = phaseAmount * phaseInternalEnergy[ip];
558 real64 const phaseEnergy_n = phaseAmount_n * phaseInternalEnergy_n[ip];
559 real64 const dPhaseEnergy_dP = dPhaseAmount[FLUID_PROP_COFFSET::dP] * phaseInternalEnergy[ip]
560 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dP];
561 real64 const dPhaseEnergy_dT = dPhaseAmount[FLUID_PROP_COFFSET::dT] * phaseInternalEnergy[ip]
562 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dT];
564 stack.localResidual[numEqn-1] += phaseEnergy - phaseEnergy_n;
567 stack.localJacobian[numEqn-1][0] += dPhaseEnergy_dP;
568 stack.localJacobian[numEqn-1][numDof-1] += dPhaseEnergy_dT;
571 applyChainRule( numComp, dCompFrac_dCompDens, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC );
572 for(
integer jc = 0; jc < numComp; ++jc )
574 stack.localJacobian[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount[FLUID_PROP_COFFSET::dC+jc]
575 + dPhaseInternalEnergy_dC[jc] * phaseAmount;
592 Base::computeVolumeBalance( ei, stack );
598 StackVariables & stack )
const
602 Base::complete( ei, stack );
635 template<
typename POLICY >
641 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags,
644 MultiFluidBase
const & fluid,
648 isothermalCompositionalMultiphaseBaseKernels::
649 internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
654 kernel( numPhases, isProducer, rankOffset, dofKey, subRegion, fluid, localMatrix, localRhs, kernelFlags );
656 launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP > >( subRegion.
size(), kernel );
665 template<
integer NC >
669 static constexpr
integer IS_THERMAL = 1;
676 using CP_Deriv = multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
681 using Base::m_isProducer;
683 using Base::m_localRhs;
684 using Base::m_localMatrix;
685 using Base::m_rankOffset;
686 using Base::maxNumElems;
687 using Base::maxStencilSize;
688 using Base::m_useTotalMassEquation;
694 static constexpr
integer numDof = WJ_COFFSET::nDer;
697 static constexpr
integer numEqn = WJ_ROFFSET::nEqn - 2;
715 string const wellDofKey,
718 MultiFluidBase
const & fluid,
721 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags )
730 m_numPhases ( fluid.numFluidPhases()),
731 m_globalWellElementIndex( subRegion.getGlobalWellElementIndex() ),
732 m_phaseFraction( fluid.phaseFraction()),
733 m_dPhaseFraction( fluid.dPhaseFraction()),
734 m_phaseEnthalpy( fluid.phaseEnthalpy()),
735 m_dPhaseEnthalpy( fluid.dPhaseEnthalpy())
759 Base::setup ( iwelem, stack );
767 for(
integer j=0; j< stack.stencilSize * numDof; j++ )
774 void complete(
localIndex const iwelem, StackVariables & stack )
const
776 Base::complete ( iwelem, stack );
778 using namespace compositionalMultiphaseUtilities;
779 if( stack.numConnectedElems ==1 )
782 globalIndex oneSidedEqnRowIndices = stack.offsetUp + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
784 if( oneSidedEqnRowIndices >= 0 && oneSidedEqnRowIndices < m_localMatrix.numRows() )
787 if( !m_isProducer && m_globalWellElementIndex[iwelem] == 0 )
792 for(
integer i=0; i< CP_Deriv::nDer; i++ )
794 stack.localEnergyFluxJacobian[0][i] = 0.0;
796 stack.localEnergyFluxJacobian_dQ[0][0]=0;
797 stack.localEnergyFlux[0]=0;
802 globalIndex oneSidedDofColIndices_dRate = stack.offsetCurrent + WJ_COFFSET::dQ;
803 globalIndex oneSidedDofColIndices_dPresCompTempUp[CP_Deriv::nDer]{};
806 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dP;
807 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dT;
808 for(
integer jdof = 0; jdof < NC; ++jdof )
810 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dC+ jdof;
813 m_localMatrix.template addToRow< parallelDeviceAtomic >( oneSidedEqnRowIndices,
814 &oneSidedDofColIndices_dRate,
815 stack.localEnergyFluxJacobian_dQ[0],
817 m_localMatrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( oneSidedEqnRowIndices,
818 oneSidedDofColIndices_dPresCompTempUp,
819 stack.localEnergyFluxJacobian[0],
821 RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[oneSidedEqnRowIndices], stack.localEnergyFlux[0] );
826 globalIndex row_current = stack.offsetCurrent + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
827 globalIndex row_next = stack.offsetNext + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
831 if( row_next >= 0 && row_next < m_localMatrix.numRows() )
833 if( m_globalWellElementIndex[stack.iwelemNext] == 0 )
835 for(
integer i=0; i<CP_Deriv::nDer; i++ )
836 stack.localEnergyFluxJacobian[TAG::NEXT][i] = 0.0;
837 stack.localEnergyFluxJacobian_dQ[TAG::NEXT][0] =0;
838 stack.localEnergyFlux[TAG::NEXT] =0;
848 eqnRowIndices[TAG::CURRENT ] = row_current;
849 eqnRowIndices[TAG::NEXT ] = row_next;
854 globalIndex dofColIndices_dRate = stack.offsetCurrent + WJ_COFFSET::dQ;
859 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dP;
861 if constexpr ( IS_THERMAL )
863 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dT;
865 for(
integer jdof = 0; jdof < NC; ++jdof )
867 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dC+ jdof;
870 for(
integer i = 0; i < 2; ++i )
872 if( eqnRowIndices[i] >= 0 && eqnRowIndices[i] < m_localMatrix.numRows() )
874 m_localMatrix.template addToRow< parallelDeviceAtomic >( eqnRowIndices[i],
875 &dofColIndices_dRate,
876 stack.localEnergyFluxJacobian_dQ[i],
878 m_localMatrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( eqnRowIndices[i],
880 stack.localEnergyFluxJacobian[i],
882 RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[eqnRowIndices[i]], stack.localEnergyFlux[i] );
901 Base::computeFlux ( iwelem, stack, [&] (
localIndex const & iwelemNext
903 ,
real64 const & currentConnRate
904 ,
real64 const (&dCompFrac_dCompDens)[NC][NC] )
907 if( iwelemNext < 0 && !m_isProducer )
911 for(
integer ip = 0; ip < m_numPhases; ++ip )
913 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
914 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
916 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dP] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
917 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
918 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dT] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
919 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
921 real64 dProp1_dC[numComp]{};
922 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dProp1_dC, CP_Deriv::dC );
923 real64 dProp2_dC[numComp]{};
924 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dProp2_dC, CP_Deriv::dC );
925 for(
integer dof=0; dof < numComp; dof++ )
928 + dProp1_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
931 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
939 else if( ( iwelemNext < 0 && m_isProducer ) || currentConnRate < 0 )
943 for(
integer ip = 0; ip < m_numPhases; ++ip )
945 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
946 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
947 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dP] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
948 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
949 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dT] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
950 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
952 real64 dProp1_dC[numComp]{};
953 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dProp1_dC, CP_Deriv::dC );
954 real64 dProp2_dC[numComp]{};
955 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dProp2_dC, CP_Deriv::dC );
956 for(
integer dof=0; dof < numComp; dof++ )
959 + dProp1_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
964 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
975 for(
integer ip = 0; ip < m_numPhases; ++ip )
977 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
978 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
980 real64 dprop_dp = m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
981 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
982 real64 dprop_dt = m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
983 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
992 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dPE_dC, CP_Deriv::dC );
994 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dPF_dC, CP_Deriv::dC );
996 for(
integer dof=0; dof < numComp; dof++ )
999 +dPE_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
1000 stack.
localEnergyFluxJacobian[TAG::CURRENT ][CP_Deriv::dC+dof] += m_phaseEnthalpy[iwelemUp][0][ip]*dPF_dC[dof]
1001 +dPE_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
1005 stack.
localEnergyFlux[TAG::CURRENT ] = -m_dt * eflux * currentConnRate;
1008 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
1028 template<
typename POLICY,
typename KERNEL_TYPE >
1031 KERNEL_TYPE
const & kernelComponent )
1036 typename KERNEL_TYPE::StackVariables stack( 1 );
1038 kernelComponent.setup( ie, stack );
1039 kernelComponent.computeFlux( ie, stack );
1040 kernelComponent.complete( ie, stack );
1082 template<
typename POLICY >
1087 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags,
1088 string const dofKey,
1091 MultiFluidBase
const & fluid,
1095 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
1097 integer constexpr NUM_COMP = NC();
1100 kernelType kernel( dt, rankOffset, dofKey, wellControls, subRegion, fluid, localMatrix, localRhs, kernelFlags );
1101 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(msg)
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.
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 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.
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.
ElementBasedAssemblyKernel(localIndex const numPhases, 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.
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.
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, integer const targetPhaseIndex, globalIndex const rankOffset, string const &dofKey, arrayView1d< real64 const > const &localResidual, WellElementSubRegion const &subRegion, MultiFluidBase const &fluid, WellControls const &wellControls, real64 const timeAtEndOfStep, real64 const dt, real64 const minNormalizer, real64(&residualNorm)[2])
Create a new kernel and launch.
integer const m_numPhases
Number of fluid phases.
WellControls::Control const m_currentControl
Controls.
real64 const m_dt
Time step size.
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.
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.
integer const m_targetPhaseIndex
Index of the target phase.
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.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
StackArray< T, 2, MAXSIZE > stackArray2d
Alias for 2D stack array.
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).
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.
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.
Array< T, 1 > array1d
Alias for 1D array.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.
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.