20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_PERFORATIONFLUXLKERNELS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_PERFORATIONFLUXLKERNELS_HPP
23 #include "codingUtilities/Utilities.hpp"
25 #include "common/GEOS_RAJA_Interface.hpp"
26 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
27 #include "constitutive/fluid/multifluid/MultiFluidFields.hpp"
28 #include "constitutive/relativePermeability/RelativePermeabilityBase.hpp"
29 #include "constitutive/relativePermeability/RelativePermeabilityFields.hpp"
50 namespace isothermalPerforationFluxKernels
55 template<
integer NC,
integer NP,
integer IS_THERMAL >
72 fields::flow::phaseVolumeFraction,
73 fields::flow::dPhaseVolumeFraction,
74 fields::flow::dGlobalCompFraction_dGlobalCompDensity >;
78 fields::multifluid::phaseDensity,
79 fields::multifluid::dPhaseDensity,
80 fields::multifluid::phaseViscosity,
81 fields::multifluid::dPhaseViscosity,
82 fields::multifluid::phaseCompFraction,
83 fields::multifluid::dPhaseCompFraction >;
87 fields::relperm::phaseRelPerm,
88 fields::relperm::dPhaseRelPerm_dPhaseVolFraction >;
98 template<
typename VIEWTYPE >
106 bool const disableReservoirToWellFlow ):
107 m_resPres( compFlowAccessors.get( fields::flow::pressure {} )),
108 m_resPhaseVolFrac( compFlowAccessors.get( fields::flow::phaseVolumeFraction {} )),
109 m_dResPhaseVolFrac( compFlowAccessors.get( fields::flow::dPhaseVolumeFraction {} )),
110 m_dResCompFrac_dCompDens( compFlowAccessors.get( fields::flow::dGlobalCompFraction_dGlobalCompDensity {} )),
111 m_resPhaseDens( multiFluidAccessors.get( fields::multifluid::phaseDensity {} )),
112 m_dResPhaseDens( multiFluidAccessors.get( fields::multifluid::dPhaseDensity {} )),
113 m_resPhaseVisc( multiFluidAccessors.get( fields::multifluid::phaseViscosity {} )),
114 m_dResPhaseVisc( multiFluidAccessors.get( fields::multifluid::dPhaseViscosity {} )),
115 m_resPhaseCompFrac( multiFluidAccessors.get( fields::multifluid::phaseCompFraction {} )),
116 m_dResPhaseCompFrac( multiFluidAccessors.get( fields::multifluid::dPhaseCompFraction {} )),
117 m_resPhaseRelPerm( relPermAccessors.get( fields::relperm::phaseRelPerm {} )),
118 m_dResPhaseRelPerm_dPhaseVolFrac( relPermAccessors.get( fields::relperm::dPhaseRelPerm_dPhaseVolFraction {} )),
119 m_wellElemGravCoef( subRegion.getField< fields::well::gravityCoefficient >()),
120 m_wellElemPres( subRegion.getField< fields::well::pressure >()),
121 m_wellElemCompDens( subRegion.getField< fields::well::globalCompDensity >()),
122 m_wellElemTotalMassDens( subRegion.getField< fields::well::totalMassDensity >()),
123 m_dWellElemTotalMassDens( subRegion.getField< fields::well::dTotalMassDensity >()),
124 m_wellElemCompFrac( subRegion.getField< fields::well::globalCompFraction >()),
125 m_dWellElemCompFrac_dCompDens( subRegion.getField< fields::well::dGlobalCompFraction_dGlobalCompDensity >()),
126 m_perfGravCoef( perforationData->getField< fields::well::gravityCoefficient >()),
127 m_perfWellElemIndex( perforationData->getField< fields::perforation::wellElementIndex >()),
128 m_perfTrans( perforationData->getField< fields::perforation::wellTransmissibility >()),
129 m_resElementRegion( perforationData->getField< fields::perforation::reservoirElementRegion >()),
130 m_resElementSubRegion( perforationData->getField< fields::perforation::reservoirElementSubRegion >()),
131 m_resElementIndex( perforationData->getField< fields::perforation::reservoirElementIndex >()),
132 m_compPerfRate( perforationData->getField< fields::well::compPerforationRate >()),
133 m_dCompPerfRate( perforationData->getField< fields::well::dCompPerforationRate >()),
134 m_disableReservoirToWellFlow( disableReservoirToWellFlow )
137 template<
typename FUNC = NoOpFunc >
141 computeFlux(
localIndex const iperf, FUNC && fluxKernelOp= NoOpFunc {} )
const
144 localIndex const er = m_resElementRegion[iperf];
145 localIndex const esr = m_resElementSubRegion[iperf];
146 localIndex const ei = m_resElementIndex[iperf];
149 localIndex const iwelem = m_perfWellElemIndex[iperf];
151 using Deriv = constitutive::multifluid::DerivativeOffset;
152 using CP_Deriv = constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
163 real64 dPres[2][CP_Deriv::nDer]{};
164 real64 dFlux[2][CP_Deriv::nDer]{};
165 real64 dMob[CP_Deriv::nDer]{};
166 real64 dPotDiff[2][CP_Deriv::nDer]{};
167 real64 dCompFrac[CP_Deriv::nDer]{};
170 for(
integer ic = 0; ic < NC; ++ic )
172 m_compPerfRate[iperf][ic] = 0.0;
173 for(
integer ke = 0; ke < 2; ++ke )
175 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
177 m_dCompPerfRate[iperf][ke][ic][jc] = 0.0;
186 pres[TAG::RES] = m_resPres[er][esr][ei];
187 dPres[TAG::RES][CP_Deriv::dP] = 1.0;
188 multiplier[TAG::RES] = 1.0;
196 pres[TAG::WELL] = m_wellElemPres[iwelem];
197 dPres[TAG::WELL][CP_Deriv::dP] = 1.0;
198 multiplier[TAG::WELL] = -1.0;
200 real64 const gravD = ( m_perfGravCoef[iperf] - m_wellElemGravCoef[iwelem] );
202 pres[TAG::WELL] += m_wellElemTotalMassDens[iwelem] * gravD;
204 dPres[TAG::WELL][CP_Deriv::dP] += m_dWellElemTotalMassDens[iwelem][Deriv::dP] * gravD;
205 if constexpr ( IS_THERMAL )
207 dPres[TAG::WELL][CP_Deriv::dT] += m_dWellElemTotalMassDens[iwelem][Deriv::dT] * gravD;
209 for(
integer ic = 0; ic < NC; ++ic )
211 dPres[TAG::WELL][CP_Deriv::dC+ic] += m_dWellElemTotalMassDens[iwelem][Deriv::dC+ic] * gravD;
217 for(
integer i = 0; i < 2; ++i )
219 potDiff += multiplier[i] * m_perfTrans[iperf] * pres[i];
221 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
223 dPotDiff[i][ic] += multiplier[i] * m_perfTrans[iperf] * dPres[i][ic];
234 for(
integer ip = 0; ip < NP; ++ip )
238 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
239 if( !phaseExists || m_disableReservoirToWellFlow )
247 real64 const resDens = m_resPhaseDens[er][esr][ei][0][ip];
248 real64 dDens[CP_Deriv::nDer]{};
250 dDens[CP_Deriv::dP] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dP];
251 if constexpr ( IS_THERMAL )
253 dDens[CP_Deriv::dT] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dT];
255 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
256 m_dResPhaseDens[er][esr][ei][0][ip],
257 &dDens[CP_Deriv::dC],
260 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
261 real64 dVisc[CP_Deriv::nDer]{};
262 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
263 if constexpr ( IS_THERMAL )
265 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
268 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
269 m_dResPhaseVisc[er][esr][ei][0][ip],
270 &dVisc[CP_Deriv::dC],
274 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
275 real64 dRelPerm[CP_Deriv::nDer]{};
276 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
280 for(
integer jp = 0; jp < NP; ++jp )
282 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
283 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
284 if constexpr ( IS_THERMAL )
286 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
288 for(
integer jc = 0; jc < NC; ++jc )
290 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
295 real64 const resPhaseMob = resDens * resRelPerm / resVisc;
298 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
300 dMob[jc] = dRelPerm[jc] * resDens / resVisc
301 + resPhaseMob * (dDens[jc] / resDens - dVisc[jc] / resVisc);
304 flux = resPhaseMob * potDiff;
306 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
308 dFlux[TAG::RES][jc] = dMob[jc] * potDiff + resPhaseMob * dPotDiff[TAG::RES][jc];
309 dFlux[TAG::WELL][jc] = resPhaseMob * dPotDiff[TAG::WELL][jc];
313 for(
integer ic = 0; ic < NC; ++ic )
316 m_compPerfRate[iperf][ic] += flux * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
317 dCompFrac[CP_Deriv::dP] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dP];
318 if constexpr (IS_THERMAL)
320 dCompFrac[CP_Deriv::dT] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dT];
324 m_dResCompFrac_dCompDens[er][esr][ei],
325 m_dResPhaseCompFrac[er][esr][ei][0][ip][ic],
326 &dCompFrac[CP_Deriv::dC],
329 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
331 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += dFlux[TAG::RES][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
332 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += flux * dCompFrac[jc];
333 m_dCompPerfRate[iperf][TAG::WELL][ic][jc] += dFlux[TAG::WELL][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
336 if constexpr ( IS_THERMAL )
338 fluxKernelOp( iwelem, er, esr, ei, ip, potDiff, flux, dFlux );
350 real64 wellElemTotalDens = 0;
351 for(
integer ic = 0; ic < NC; ++ic )
353 wellElemTotalDens += m_wellElemCompDens[iwelem][ic];
357 for(
integer ip = 0; ip < NP; ++ip )
361 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
368 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
369 real64 dVisc[CP_Deriv::nDer]{};
370 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
371 if constexpr ( IS_THERMAL )
373 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
376 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
377 m_dResPhaseVisc[er][esr][ei][0][ip],
378 &dVisc[CP_Deriv::dC],
383 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
384 real64 dRelPerm[CP_Deriv::nDer]{};
385 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
389 for(
integer jp = 0; jp < NP; ++jp )
391 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
392 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
393 if constexpr ( IS_THERMAL )
395 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
397 for(
integer jc = 0; jc < NC; ++jc )
399 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
403 resTotalMob += resRelPerm / resVisc;
405 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
407 dMob[jc] += (dRelPerm[jc] *resVisc - resRelPerm * dVisc[jc] )
408 / ( resVisc * resVisc);
414 real64 const mult = wellElemTotalDens * resTotalMob;
416 real64 dMult[2][CP_Deriv::nDer]{};
417 dMult[TAG::WELL][CP_Deriv::dP] = 0.0;
418 if constexpr ( IS_THERMAL )
420 dMult[TAG::WELL][CP_Deriv::dT] = 0.0;
422 for(
integer ic = 0; ic < NC; ++ic )
424 dMult[TAG::WELL][CP_Deriv::dC+ic] = resTotalMob;
426 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
428 dMult[TAG::RES][jc] = wellElemTotalDens * dMob[jc];
433 flux = mult * potDiff;
435 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
437 dFlux[TAG::RES][ic] = dMult[TAG::RES][ic] * potDiff + mult * dPotDiff[TAG::RES][ic];
438 dFlux[TAG::WELL][ic] = dMult[TAG::WELL][ic] * potDiff + mult * dPotDiff[TAG::WELL][ic];
441 for(
integer ic = 0; ic < NC; ++ic )
443 m_compPerfRate[iperf][ic] += m_wellElemCompFrac[iwelem][ic] * flux;
444 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
446 m_dCompPerfRate[iperf][TAG::RES][ic][jc] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::RES][jc];
449 for(
integer ic = 0; ic < NC; ++ic )
451 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dP] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dP];
452 if constexpr ( IS_THERMAL )
454 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dT] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dT];
456 for(
integer jc = 0; jc < NC; ++jc )
458 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dC+jc];
459 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_dWellElemCompFrac_dCompDens[iwelem][ic][jc] * flux;
462 if constexpr ( IS_THERMAL )
464 fluxKernelOp( iwelem, er, esr, ei, -1, potDiff, flux, dFlux );
475 template<
typename POLICY,
typename KERNEL_TYPE >
478 KERNEL_TYPE
const & kernelComponent )
484 kernelComponent.computeFlux( iperf );
491 ElementViewConst< arrayView1d< real64 const > >
const m_resPres;
492 ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > >
const m_resPhaseVolFrac;
493 ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > >
const m_dResPhaseVolFrac;
494 ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > >
const m_dResCompFrac_dCompDens;
495 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseDens;
496 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseDens;
497 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseVisc;
498 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseVisc;
499 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > >
const m_resPhaseCompFrac;
500 ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > >
const m_dResPhaseCompFrac;
501 ElementViewConst< arrayView3d< real64 const, constitutive::relperm::USD_RELPERM > >
const m_resPhaseRelPerm;
502 ElementViewConst< arrayView4d< real64 const, constitutive::relperm::USD_RELPERM_DS > >
const m_dResPhaseRelPerm_dPhaseVolFrac;
521 bool const m_disableReservoirToWellFlow;
546 template<
typename POLICY >
550 string const flowSolverName,
554 integer const disableReservoirToWellFlow )
556 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
558 integer constexpr NUM_COMP = NC();
559 integer constexpr NUM_PHASE = NP();
560 integer constexpr IS_THERMAL = 0;
563 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
564 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
565 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
567 kernelType kernel( perforationData, subRegion, compFlowAccessors, multiFluidAccessors, relPermAccessors, disableReservoirToWellFlow );
568 kernelType::template launch< POLICY >( perforationData->
size(), kernel );
575 namespace thermalPerforationFluxKernels
578 using namespace constitutive;
582 template<
integer NC,
integer NP,
integer IS_THERMAL >
589 using Base::m_resPhaseCompFrac;
590 using Base::m_dResCompFrac_dCompDens;
591 using Base::m_dWellElemCompFrac_dCompDens;
601 static constexpr
integer isThermal = IS_THERMAL;
614 fields::multifluid::phaseEnthalpy,
615 fields::multifluid::dPhaseEnthalpy >;
628 template<
typename VIEWTYPE >
633 MultiFluidBase
const & fluid,
637 bool const disableReservoirToWellFlow,
640 :
Base( perforationData,
645 disableReservoirToWellFlow ),
646 m_wellElemPhaseFrac( fluid.phaseFraction() ),
647 m_dPhaseFrac( fluid.dPhaseFraction() ),
648 m_wellElemPhaseEnthalpy( fluid.phaseEnthalpy()),
649 m_dWellElemPhaseEnthalpy( fluid.dPhaseEnthalpy()),
650 m_energyPerfFlux( perforationData->getField< fields::well::energyPerforationFlux >()),
651 m_dEnergyPerfFlux( perforationData->getField< fields::well::dEnergyPerforationFlux >()),
652 m_temp( thermalCompFlowAccessors.get( fields::flow::temperature {} ) ),
653 m_resPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::phaseEnthalpy {} ) ),
654 m_dResPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::dPhaseEnthalpy {} ) )
658 template<
typename FUNC = NoOpFunc >
664 using Deriv = constitutive::multifluid::DerivativeOffset;
665 using CP_Deriv =constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
667 m_energyPerfFlux[iperf]=0;
668 for(
integer ke = 0; ke < 2; ++ke )
670 for(
integer i = 0; i < CP_Deriv::nDer; ++i )
672 m_dEnergyPerfFlux[iperf][ke][i]=0;
682 real64 const res_enthalpy = m_resPhaseEnthalpy[er][esr][ei][0][ip];
684 m_energyPerfFlux[iperf] += flux * res_enthalpy;
687 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * res_enthalpy +
688 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dP];
689 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * res_enthalpy +
690 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dT];
692 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * res_enthalpy;
693 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * res_enthalpy;
697 real64 dProp_dC[numComp]{};
699 m_dResCompFrac_dCompDens[er][esr][ei],
700 m_dResPhaseEnthalpy[er][esr][ei][0][ip],
704 for(
integer jc = 0; jc < NC; ++jc )
706 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dC+jc] += flux * dProp_dC[jc];
711 for(
integer iphase = 0; iphase < NP; ++iphase )
713 bool const phaseExists = m_wellElemPhaseFrac[iwelem][0][iphase] > 0.0;
716 double pflux = m_wellElemPhaseFrac[iwelem][0][iphase]*flux;
717 real64 const wellelem_enthalpy = m_wellElemPhaseEnthalpy[iwelem][0][iphase];
718 m_energyPerfFlux[iperf] += pflux * wellelem_enthalpy;
721 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * wellelem_enthalpy;
722 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * wellelem_enthalpy;
724 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * wellelem_enthalpy
725 + pflux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dP]
726 + pflux * wellelem_enthalpy * m_dPhaseFrac[iwelem][0][iphase][Deriv::dP];
727 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * wellelem_enthalpy
728 + pflux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dT]
729 + pflux * wellelem_enthalpy * m_dPhaseFrac[iwelem][0][iphase][Deriv::dT];
732 real64 dPVF_dC[numComp]{};
734 m_dWellElemCompFrac_dCompDens[iwelem],
735 m_dPhaseFrac[iwelem][0][iphase],
738 for(
integer ic=0; ic<NC; ic++ )
740 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * dFlux[TAG::WELL][CP_Deriv::dC+ic] * m_wellElemPhaseFrac[iwelem][0][iphase];
741 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * pflux * dPVF_dC[ ic];
744 real64 dProp_dC[numComp]{};
746 m_dWellElemCompFrac_dCompDens[iwelem],
747 m_dWellElemPhaseEnthalpy[iwelem][0][iphase],
751 for(
integer jc = 0; jc < NC; ++jc )
753 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+jc] += pflux * dProp_dC[jc];
771 template<
typename POLICY,
typename KERNEL_TYPE >
774 KERNEL_TYPE
const & kernelComponent )
779 kernelComponent.computeFlux( iperf );
827 template<
typename POLICY >
831 string const flowSolverName,
834 MultiFluidBase
const & fluid,
836 integer const disableReservoirToWellFlow )
838 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
840 integer constexpr NUM_COMP = NC();
841 integer constexpr NUM_PHASE = NP();
842 integer constexpr IS_THERMAL = 1;
845 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
846 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
847 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
848 typename kernelType::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, flowSolverName );
849 typename kernelType::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, flowSolverName );
851 kernelType kernel( perforationData, subRegion, fluid, compFlowAccessors, multiFluidAccessors,
852 relPermAccessors, disableReservoirToWellFlow,
853 thermalCompFlowAccessors,
854 thermalMultiFluidAccessors );
855 kernelType::template launch< POLICY >( perforationData->
size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
static void createAndLaunch(integer const numComp, integer const numPhases, string const flowSolverName, PerforationData *const perforationData, ElementSubRegionBase const &subRegion, ElementRegionManager &elemManager, integer const disableReservoirToWellFlow)
Create a new kernel and launch.
static constexpr integer numComp
Compile time value for the number of components.
static constexpr integer numPhase
Compile time value for the number of phases.
static constexpr integer isThermal
Compile time value for thermal option.
static void launch(localIndex const numElements, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based non-constitutive data parameters. Consists entirely of ArrayView's.
static void createAndLaunch(integer const numComp, integer const numPhases, string const flowSolverName, PerforationData *const perforationData, ElementSubRegionBase const &subRegion, MultiFluidBase const &fluid, ElementRegionManager &elemManager, integer const disableReservoirToWellFlow)
Create a new kernel and launch.
arrayView3d< real64 const, multifluid::USD_PHASE > const m_wellElemPhaseFrac
ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_resPhaseEnthalpy
Views on phase enthalpies.
arrayView1d< real64 > const m_energyPerfFlux
Views on energy flux.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based non-constitutive data parameters. Consists entirely of ArrayView's.
ElementViewConst< arrayView1d< real64 const > > const m_temp
Views on temperature.
static void launch(localIndex const numElements, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
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.