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()),
180 m_isLocallyOwned( subRegion.isLocallyOwned() ),
181 m_iwelemControl( subRegion.getTopWellElementIndex() ),
182 m_isProducer( wellControls.isProducer() ),
183 m_currentControl( wellControls.getControl() ),
184 m_targetBHP( std::numeric_limits<
real64 >::max() ),
185 m_volume( subRegion.getElementVolume() ),
186 m_phaseDens_n( fluid.phaseDensity_n() ),
187 m_totalDens_n( fluid.totalDensity_n() ),
188 m_phaseVolFraction_n( subRegion.getField< fields::well::phaseVolumeFraction_n >()),
189 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n() )
208 void computeMassEnergyNormalizers(
localIndex const iwelem,
210 real64 & energyNormalizer )
const
212 massNormalizer = LvArray::math::max( m_minNormalizer, m_totalDens_n[iwelem][0] * m_volume[iwelem] );
214 for(
integer ip = 0; ip < m_numPhases; ++ip )
216 energyNormalizer += m_phaseInternalEnergy_n[iwelem][0][ip] * m_phaseDens_n[iwelem][0][ip] * m_phaseVolFraction_n[iwelem][ip] * m_volume[iwelem];
219 energyNormalizer = LvArray::math::max( m_minNormalizer, LvArray::math::abs( energyNormalizer ) );
224 LinfStackVariables & stack )
const override
227 for(
integer idof = 0; idof < WJ_ROFFSET::nEqn; ++idof )
233 if( idof == WJ_ROFFSET::CONTROL )
237 if( m_isLocallyOwned && iwelem == m_iwelemControl )
242 normalizer = m_targetBHP;
247 normalizer = LvArray::math::max( LvArray::math::abs( m_constraintValue ), m_minNormalizer );
252 normalizer = LvArray::math::max( LvArray::math::abs( m_constraintValue ), m_minNormalizer );
257 normalizer = LvArray::math::max( LvArray::math::abs( m_constraintValue ), m_minNormalizer );
263 normalizer = m_targetBHP;
267 else if( idof >= WJ_ROFFSET::MASSBAL && idof < WJ_ROFFSET::MASSBAL + numComp )
272 normalizer = m_dt * LvArray::math::abs( m_constraintValue ) * m_phaseDens_n[iwelem][0][m_targetPhaseIndex];
278 normalizer = m_dt * LvArray::math::abs( m_constraintValue );
283 normalizer = m_dt * LvArray::math::abs( m_constraintValue ) * m_totalDens_n[iwelem][0];
289 normalizer = LvArray::math::max( normalizer, m_volume[iwelem] * m_totalDens_n[iwelem][0] );
292 else if( idof == WJ_ROFFSET::VOLBAL )
297 normalizer = m_dt * LvArray::math::abs( m_constraintValue );
303 normalizer = m_dt * LvArray::math::abs( m_constraintValue/ m_totalDens_n[iwelem][0] );
307 normalizer = m_dt * LvArray::math::abs( m_constraintValue );
312 normalizer = LvArray::math::max( normalizer, m_volume[iwelem] );
315 if( idof == WJ_ROFFSET::ENERGYBAL )
317 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
318 computeMassEnergyNormalizers( iwelem, massNormalizer, energyNormalizer );
319 real64 const valEnergy = LvArray::math::abs( m_localResidual[stack.localRow + WJ_ROFFSET::ENERGYBAL] ) / energyNormalizer;
320 if( valEnergy > stack.localValue[1] )
322 stack.localValue[1] = valEnergy;
328 normalizer = LvArray::math::max( m_minNormalizer, normalizer );
330 real64 const val = LvArray::math::abs( m_localResidual[stack.localRow + idof] ) / normalizer;
331 if( val > stack.localValue[0] )
333 stack.localValue[0] = val;
341 L2StackVariables & stack )
const override
344 GEOS_ERROR(
"The L2 norm is not implemented for CompositionalMultiphaseWell" );
407 template<
typename POLICY >
411 string const & dofKey,
414 MultiFluidBase
const & fluid,
418 real64 const minNormalizer,
419 real64 (& residualNorm)[2] )
421 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch ( numComp, [&](
auto NC )
424 integer constexpr NUM_COMP = NC();
429 kernelType kernel( rankOffset, localResidual, dofNumber, ghostRank,
430 subRegion, fluid, wellControls, time, dt, minNormalizer );
431 kernelType::template launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
445 template< localIndex NUM_COMP >
450 using Base::m_dCompFrac_dCompDens;
451 using Base::m_dofNumber;
452 using Base::m_dPhaseCompFrac;
453 using Base::m_dPhaseDens;
454 using Base::m_dPhaseVolFrac;
455 using Base::m_dPoro_dPres;
456 using Base::m_elemGhostRank;
457 using Base::m_localMatrix;
458 using Base::m_localRhs;
459 using Base::m_numPhases;
460 using Base::m_phaseCompFrac;
461 using Base::m_phaseCompFrac_n;
462 using Base::m_phaseDens;
463 using Base::m_phaseDens_n;
464 using Base::m_phaseVolFrac;
465 using Base::m_phaseVolFrac_n;
466 using Base::m_porosity;
467 using Base::m_porosity_n;
468 using Base::m_rankOffset;
469 using Base::m_volume;
474 using FLUID_PROP_COFFSET = multifluid::DerivativeOffsetC< NUM_COMP, 1 >;
488 bool const thermalEffectsEnabled,
493 MultiFluidBase
const & fluid,
496 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags >
const kernelFlags )
497 :
Base( numPhases, thermalEffectsEnabled, isProducer, rankOffset, dofKey, subRegion, fluid, localMatrix, localRhs, kernelFlags ),
498 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n()),
499 m_phaseInternalEnergy( fluid.phaseInternalEnergy()),
500 m_dPhaseInternalEnergy( fluid.dPhaseInternalEnergy())
508 : Base::StackVariables()
510 using Base::StackVariables::eqnRowIndices;
511 using Base::StackVariables::dofColIndices;
512 using Base::StackVariables::localJacobian;
513 using Base::StackVariables::localResidual;
514 using Base::StackVariables::localRow;
515 using Base::StackVariables::volume;
529 Base::setup( ei, stack );
545 using Deriv = multifluid::DerivativeOffset;
547 Base::computeAccumulation( ei, stack, [&](
integer const ip
548 ,
real64 const & phaseAmount
549 ,
real64 const & phaseAmount_n
550 ,
real64 const (&dPhaseAmount)[FLUID_PROP_COFFSET::nDer] )
557 real64 dPhaseInternalEnergy_dC[numComp]{};
560 arraySlice2d<
real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei];
561 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy_n = m_phaseInternalEnergy_n[ei][0];
562 arraySlice1d<
real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy = m_phaseInternalEnergy[ei][0];
563 arraySlice2d<
real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseInternalEnergy = m_dPhaseInternalEnergy[ei][0];
567 real64 const phaseEnergy = phaseAmount * phaseInternalEnergy[ip];
568 real64 const phaseEnergy_n = phaseAmount_n * phaseInternalEnergy_n[ip];
569 real64 const dPhaseEnergy_dP = dPhaseAmount[FLUID_PROP_COFFSET::dP] * phaseInternalEnergy[ip]
570 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dP];
571 real64 const dPhaseEnergy_dT = dPhaseAmount[FLUID_PROP_COFFSET::dT] * phaseInternalEnergy[ip]
572 + phaseAmount * dPhaseInternalEnergy[ip][Deriv::dT];
574 stack.localResidual[numEqn-1] += phaseEnergy - phaseEnergy_n;
577 stack.localJacobian[numEqn-1][0] += dPhaseEnergy_dP;
578 stack.localJacobian[numEqn-1][numDof-1] += dPhaseEnergy_dT;
581 applyChainRule( numComp, dCompFrac_dCompDens, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC );
582 for(
integer jc = 0; jc < numComp; ++jc )
584 stack.localJacobian[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount[FLUID_PROP_COFFSET::dC+jc]
585 + dPhaseInternalEnergy_dC[jc] * phaseAmount;
602 Base::computeVolumeBalance( ei, stack );
612 Base::complete( ei, stack );
645 template<
typename POLICY >
649 integer const thermalEffectsEnabled,
652 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags,
655 MultiFluidBase
const & fluid,
659 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
664 kernel( numPhases, thermalEffectsEnabled, isProducer, rankOffset, dofKey, subRegion, fluid, localMatrix, localRhs, kernelFlags );
666 launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP > >( subRegion.
size(), kernel );
678 template<
integer NC >
682 static constexpr
integer IS_THERMAL = 1;
689 using CP_Deriv = multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
694 using Base::m_isProducer;
696 using Base::m_localRhs;
697 using Base::m_localMatrix;
698 using Base::m_rankOffset;
699 using Base::maxNumElems;
700 using Base::maxStencilSize;
701 using Base::m_useTotalMassEquation;
707 static constexpr
integer numDof = WJ_COFFSET::nDer;
710 static constexpr
integer numEqn = WJ_ROFFSET::nEqn - 2;
728 string const wellDofKey,
731 MultiFluidBase
const & fluid,
734 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags )
743 m_numPhases ( fluid.numFluidPhases()),
744 m_thermalEffectsEnabled( wellControls.thermalEffectsEnabled() ),
745 m_globalWellElementIndex( subRegion.getGlobalWellElementIndex() ),
746 m_phaseFraction( fluid.phaseFraction()),
747 m_dPhaseFraction( fluid.dPhaseFraction()),
748 m_phaseEnthalpy( fluid.phaseEnthalpy()),
749 m_dPhaseEnthalpy( fluid.dPhaseEnthalpy())
773 Base::setup ( iwelem, stack );
781 for(
integer j=0; j< stack.stencilSize * numDof; j++ )
790 Base::complete ( iwelem, stack );
792 if( !m_thermalEffectsEnabled )
return;
793 using namespace compositionalMultiphaseUtilities;
794 if( stack.numConnectedElems ==1 )
797 globalIndex oneSidedEqnRowIndices = stack.offsetUp + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
799 if( oneSidedEqnRowIndices >= 0 && oneSidedEqnRowIndices < m_localMatrix.numRows() )
802 if( !m_isProducer && m_globalWellElementIndex[iwelem] == 0 )
807 for(
integer i=0; i< CP_Deriv::nDer; i++ )
809 stack.localEnergyFluxJacobian[0][i] = 0.0;
811 stack.localEnergyFluxJacobian_dQ[0][0]=0;
812 stack.localEnergyFlux[0]=0;
817 globalIndex oneSidedDofColIndices_dRate = stack.offsetCurrent + WJ_COFFSET::dQ;
818 globalIndex oneSidedDofColIndices_dPresCompTempUp[CP_Deriv::nDer]{};
821 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dP;
822 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dT;
823 for(
integer jdof = 0; jdof < NC; ++jdof )
825 oneSidedDofColIndices_dPresCompTempUp[ioff++] = stack.offsetUp + WJ_COFFSET::dC+ jdof;
828 m_localMatrix.template addToRow< parallelDeviceAtomic >( oneSidedEqnRowIndices,
829 &oneSidedDofColIndices_dRate,
830 stack.localEnergyFluxJacobian_dQ[0],
832 m_localMatrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( oneSidedEqnRowIndices,
833 oneSidedDofColIndices_dPresCompTempUp,
834 stack.localEnergyFluxJacobian[0],
836 RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[oneSidedEqnRowIndices], stack.localEnergyFlux[0] );
841 globalIndex row_current = stack.offsetCurrent + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
842 globalIndex row_next = stack.offsetNext + WJ_ROFFSET::ENERGYBAL - m_rankOffset;
846 if( row_next >= 0 && row_next < m_localMatrix.numRows() )
848 if( m_globalWellElementIndex[stack.iwelemNext] == 0 )
850 for(
integer i=0; i<CP_Deriv::nDer; i++ )
851 stack.localEnergyFluxJacobian[TAG::NEXT][i] = 0.0;
852 stack.localEnergyFluxJacobian_dQ[TAG::NEXT][0] =0;
853 stack.localEnergyFlux[TAG::NEXT] =0;
863 eqnRowIndices[TAG::CURRENT ] = row_current;
864 eqnRowIndices[TAG::NEXT ] = row_next;
869 globalIndex dofColIndices_dRate = stack.offsetCurrent + WJ_COFFSET::dQ;
874 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dP;
876 if constexpr ( IS_THERMAL )
878 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dT;
880 for(
integer jdof = 0; jdof < NC; ++jdof )
882 dofColIndices[ioff++] = stack.offsetUp + WJ_COFFSET::dC+ jdof;
885 for(
integer i = 0; i < 2; ++i )
887 if( eqnRowIndices[i] >= 0 && eqnRowIndices[i] < m_localMatrix.numRows() )
889 m_localMatrix.template addToRow< parallelDeviceAtomic >( eqnRowIndices[i],
890 &dofColIndices_dRate,
891 stack.localEnergyFluxJacobian_dQ[i],
893 m_localMatrix.template addToRowBinarySearchUnsorted< parallelDeviceAtomic >( eqnRowIndices[i],
895 stack.localEnergyFluxJacobian[i],
897 RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[eqnRowIndices[i]], stack.localEnergyFlux[i] );
916 Base::computeFlux ( iwelem, stack, [&] (
localIndex const & iwelemNext
918 ,
real64 const & currentConnRate
919 ,
real64 const (&dCompFrac_dCompDens)[NC][NC] )
922 if( iwelemNext < 0 && !m_isProducer )
926 for(
integer ip = 0; ip < m_numPhases; ++ip )
928 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
929 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
931 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dP] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
932 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
933 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dT] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
934 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
936 real64 dProp1_dC[numComp]{};
937 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dProp1_dC, CP_Deriv::dC );
938 real64 dProp2_dC[numComp]{};
939 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dProp2_dC, CP_Deriv::dC );
940 for(
integer dof=0; dof < numComp; dof++ )
943 + dProp1_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
946 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
954 else if( ( iwelemNext < 0 && m_isProducer ) )
958 for(
integer ip = 0; ip < m_numPhases; ++ip )
960 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
961 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
962 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dP] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
963 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
964 stack.
localEnergyFluxJacobian[0] [CP_Deriv::dT] += m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
965 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
967 real64 dProp1_dC[numComp]{};
968 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dProp1_dC, CP_Deriv::dC );
969 real64 dProp2_dC[numComp]{};
970 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dProp2_dC, CP_Deriv::dC );
971 for(
integer dof=0; dof < numComp; dof++ )
974 + dProp1_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
979 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
990 for(
integer ip = 0; ip < m_numPhases; ++ip )
992 eflux += m_phaseEnthalpy[iwelemUp][0][ip]* m_phaseFraction[iwelemUp][0][ip];
993 eflux_dq += m_phaseEnthalpy[iwelemUp][0][ip] * m_phaseFraction[iwelemUp][0][ip];
995 real64 dprop_dp = m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dP]
996 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dP]*m_phaseFraction[iwelemUp][0][ip];
997 real64 dprop_dt = m_phaseEnthalpy[iwelemUp][0][ip]*m_dPhaseFraction[iwelemUp][0][ip][CP_Deriv::dT]
998 + m_dPhaseEnthalpy[iwelemUp][0][ip][CP_Deriv::dT]*m_phaseFraction[iwelemUp][0][ip];
1006 real64 dPE_dC[numComp]{};
1007 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseEnthalpy[iwelemUp][0][ip], dPE_dC, CP_Deriv::dC );
1008 real64 dPF_dC[numComp]{};
1009 applyChainRule( numComp, dCompFrac_dCompDens, m_dPhaseFraction[iwelemUp][0][ip], dPF_dC, CP_Deriv::dC );
1011 for(
integer dof=0; dof < numComp; dof++ )
1014 +dPE_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
1015 stack.
localEnergyFluxJacobian[TAG::CURRENT ][CP_Deriv::dC+dof] += m_phaseEnthalpy[iwelemUp][0][ip]*dPF_dC[dof]
1016 +dPE_dC[dof]*m_phaseFraction[iwelemUp][0][ip];
1020 stack.
localEnergyFlux[TAG::CURRENT ] = -m_dt * eflux * currentConnRate;
1023 for(
integer dof=0; dof < CP_Deriv::nDer; dof++ )
1043 template<
typename POLICY,
typename KERNEL_TYPE >
1046 KERNEL_TYPE
const & kernelComponent )
1051 typename KERNEL_TYPE::StackVariables stack( 1 );
1053 kernelComponent.setup( ie, stack );
1054 kernelComponent.computeFlux( ie, stack );
1055 kernelComponent.complete( ie, stack );
1099 template<
typename POLICY >
1104 BitFlags< isothermalCompositionalMultiphaseBaseKernels::KernelFlags > kernelFlags,
1105 string const dofKey,
1108 MultiFluidBase
const & fluid,
1112 isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&](
auto NC )
1114 integer constexpr NUM_COMP = NC();
1117 kernelType kernel( dt, rankOffset, dofKey, wellControls, subRegion, fluid, localMatrix, localRhs, kernelFlags );
1118 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.
WellConstraintBase * getCurrentConstraint()
Get the current consrtaint.
integer getConstraintPhaseIndex() const
Const accessor for the phase constraint index.
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.