19 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_PERFORATIONFLUXLKERNELS_HPP
20 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_PERFORATIONFLUXLKERNELS_HPP
22 #include "codingUtilities/Utilities.hpp"
24 #include "common/GEOS_RAJA_Interface.hpp"
25 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
26 #include "constitutive/fluid/multifluid/MultiFluidFields.hpp"
27 #include "constitutive/relativePermeability/RelativePermeabilityBase.hpp"
28 #include "constitutive/relativePermeability/RelativePermeabilityFields.hpp"
49 namespace isothermalPerforationFluxKernels
56 template<
integer NC,
integer NP,
integer IS_THERMAL >
73 fields::flow::phaseVolumeFraction,
74 fields::flow::dPhaseVolumeFraction,
75 fields::flow::dGlobalCompFraction_dGlobalCompDensity >;
79 fields::multifluid::phaseDensity,
80 fields::multifluid::dPhaseDensity,
81 fields::multifluid::phaseViscosity,
82 fields::multifluid::dPhaseViscosity,
83 fields::multifluid::phaseCompFraction,
84 fields::multifluid::dPhaseCompFraction >;
88 fields::relperm::phaseRelPerm,
89 fields::relperm::dPhaseRelPerm_dPhaseVolFraction >;
99 template<
typename VIEWTYPE >
107 bool const disableReservoirToWellFlow ):
108 m_resPres( compFlowAccessors.get( fields::flow::pressure {} )),
109 m_resPhaseVolFrac( compFlowAccessors.get( fields::flow::phaseVolumeFraction {} )),
110 m_dResPhaseVolFrac( compFlowAccessors.get( fields::flow::dPhaseVolumeFraction {} )),
111 m_dResCompFrac_dCompDens( compFlowAccessors.get( fields::flow::dGlobalCompFraction_dGlobalCompDensity {} )),
112 m_resPhaseDens( multiFluidAccessors.get( fields::multifluid::phaseDensity {} )),
113 m_dResPhaseDens( multiFluidAccessors.get( fields::multifluid::dPhaseDensity {} )),
114 m_resPhaseVisc( multiFluidAccessors.get( fields::multifluid::phaseViscosity {} )),
115 m_dResPhaseVisc( multiFluidAccessors.get( fields::multifluid::dPhaseViscosity {} )),
116 m_resPhaseCompFrac( multiFluidAccessors.get( fields::multifluid::phaseCompFraction {} )),
117 m_dResPhaseCompFrac( multiFluidAccessors.get( fields::multifluid::dPhaseCompFraction {} )),
118 m_resPhaseRelPerm( relPermAccessors.get( fields::relperm::phaseRelPerm {} )),
119 m_dResPhaseRelPerm_dPhaseVolFrac( relPermAccessors.get( fields::relperm::dPhaseRelPerm_dPhaseVolFraction {} )),
120 m_wellElemGravCoef( subRegion.getField< fields::well::gravityCoefficient >()),
121 m_wellElemPres( subRegion.getField< fields::well::pressure >()),
122 m_wellElemCompDens( subRegion.getField< fields::well::globalCompDensity >()),
123 m_wellElemTotalMassDens( subRegion.getField< fields::well::totalMassDensity >()),
124 m_dWellElemTotalMassDens( subRegion.getField< fields::well::dTotalMassDensity >()),
125 m_wellElemCompFrac( subRegion.getField< fields::well::globalCompFraction >()),
126 m_dWellElemCompFrac_dCompDens( subRegion.getField< fields::well::dGlobalCompFraction_dGlobalCompDensity >()),
127 m_perfGravCoef( perforationData->getField< fields::well::gravityCoefficient >()),
128 m_perfWellElemIndex( perforationData->getField< fields::perforation::wellElementIndex >()),
129 m_perfTrans( perforationData->getField< fields::perforation::wellTransmissibility >()),
130 m_resElementRegion( perforationData->getField< fields::perforation::reservoirElementRegion >()),
131 m_resElementSubRegion( perforationData->getField< fields::perforation::reservoirElementSubRegion >()),
132 m_resElementIndex( perforationData->getField< fields::perforation::reservoirElementIndex >()),
133 m_compPerfRate( perforationData->getField< fields::well::compPerforationRate >()),
134 m_dCompPerfRate( perforationData->getField< fields::well::dCompPerforationRate >()),
135 m_disableReservoirToWellFlow( disableReservoirToWellFlow )
150 template<
typename FUNC = NoOpFunc >
154 computeFlux(
localIndex const iperf, FUNC && fluxKernelOp= NoOpFunc {} )
const
157 localIndex const er = m_resElementRegion[iperf];
158 localIndex const esr = m_resElementSubRegion[iperf];
159 localIndex const ei = m_resElementIndex[iperf];
162 localIndex const iwelem = m_perfWellElemIndex[iperf];
164 using Deriv = constitutive::multifluid::DerivativeOffset;
165 using CP_Deriv = constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
176 real64 dPres[2][CP_Deriv::nDer]{};
177 real64 dFlux[2][CP_Deriv::nDer]{};
178 real64 dMob[CP_Deriv::nDer]{};
179 real64 dPotDiff[2][CP_Deriv::nDer]{};
180 real64 dCompFrac[CP_Deriv::nDer]{};
183 for(
integer ic = 0; ic < NC; ++ic )
185 m_compPerfRate[iperf][ic] = 0.0;
186 for(
integer ke = 0; ke < 2; ++ke )
188 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
190 m_dCompPerfRate[iperf][ke][ic][jc] = 0.0;
199 pres[TAG::RES] = m_resPres[er][esr][ei];
200 dPres[TAG::RES][CP_Deriv::dP] = 1.0;
201 multiplier[TAG::RES] = 1.0;
209 pres[TAG::WELL] = m_wellElemPres[iwelem];
210 dPres[TAG::WELL][CP_Deriv::dP] = 1.0;
211 multiplier[TAG::WELL] = -1.0;
213 real64 const gravD = ( m_perfGravCoef[iperf] - m_wellElemGravCoef[iwelem] );
215 pres[TAG::WELL] += m_wellElemTotalMassDens[iwelem] * gravD;
217 dPres[TAG::WELL][CP_Deriv::dP] += m_dWellElemTotalMassDens[iwelem][Deriv::dP] * gravD;
218 if constexpr ( IS_THERMAL )
220 dPres[TAG::WELL][CP_Deriv::dT] += m_dWellElemTotalMassDens[iwelem][Deriv::dT] * gravD;
222 for(
integer ic = 0; ic < NC; ++ic )
224 dPres[TAG::WELL][CP_Deriv::dC+ic] += m_dWellElemTotalMassDens[iwelem][Deriv::dC+ic] * gravD;
230 for(
integer i = 0; i < 2; ++i )
232 potDiff += multiplier[i] * m_perfTrans[iperf] * pres[i];
234 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
236 dPotDiff[i][ic] += multiplier[i] * m_perfTrans[iperf] * dPres[i][ic];
247 for(
integer ip = 0; ip < NP; ++ip )
251 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
252 if( !phaseExists || m_disableReservoirToWellFlow )
260 real64 const resDens = m_resPhaseDens[er][esr][ei][0][ip];
261 real64 dDens[CP_Deriv::nDer]{};
263 dDens[CP_Deriv::dP] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dP];
264 if constexpr ( IS_THERMAL )
266 dDens[CP_Deriv::dT] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dT];
268 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
269 m_dResPhaseDens[er][esr][ei][0][ip],
270 &dDens[CP_Deriv::dC],
273 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
274 real64 dVisc[CP_Deriv::nDer]{};
275 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
276 if constexpr ( IS_THERMAL )
278 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
281 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
282 m_dResPhaseVisc[er][esr][ei][0][ip],
283 &dVisc[CP_Deriv::dC],
287 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
288 real64 dRelPerm[CP_Deriv::nDer]{};
289 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
293 for(
integer jp = 0; jp < NP; ++jp )
295 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
296 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
297 if constexpr ( IS_THERMAL )
299 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
301 for(
integer jc = 0; jc < NC; ++jc )
303 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
308 real64 const resPhaseMob = resDens * resRelPerm / resVisc;
311 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
313 dMob[jc] = dRelPerm[jc] * resDens / resVisc
314 + resPhaseMob * (dDens[jc] / resDens - dVisc[jc] / resVisc);
317 flux = resPhaseMob * potDiff;
319 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
321 dFlux[TAG::RES][jc] = dMob[jc] * potDiff + resPhaseMob * dPotDiff[TAG::RES][jc];
322 dFlux[TAG::WELL][jc] = resPhaseMob * dPotDiff[TAG::WELL][jc];
326 for(
integer ic = 0; ic < NC; ++ic )
329 m_compPerfRate[iperf][ic] += flux * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
330 dCompFrac[CP_Deriv::dP] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dP];
331 if constexpr (IS_THERMAL)
333 dCompFrac[CP_Deriv::dT] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dT];
337 m_dResCompFrac_dCompDens[er][esr][ei],
338 m_dResPhaseCompFrac[er][esr][ei][0][ip][ic],
339 &dCompFrac[CP_Deriv::dC],
342 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
344 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += dFlux[TAG::RES][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
345 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += flux * dCompFrac[jc];
346 m_dCompPerfRate[iperf][TAG::WELL][ic][jc] += dFlux[TAG::WELL][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
349 if constexpr ( IS_THERMAL )
351 fluxKernelOp( iwelem, er, esr, ei, ip, potDiff, flux, dFlux );
363 real64 wellElemTotalDens = 0;
364 for(
integer ic = 0; ic < NC; ++ic )
366 wellElemTotalDens += m_wellElemCompDens[iwelem][ic];
370 for(
integer ip = 0; ip < NP; ++ip )
374 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
381 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
382 real64 dVisc[CP_Deriv::nDer]{};
383 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
384 if constexpr ( IS_THERMAL )
386 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
389 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
390 m_dResPhaseVisc[er][esr][ei][0][ip],
391 &dVisc[CP_Deriv::dC],
396 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
397 real64 dRelPerm[CP_Deriv::nDer]{};
398 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
402 for(
integer jp = 0; jp < NP; ++jp )
404 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
405 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
406 if constexpr ( IS_THERMAL )
408 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
410 for(
integer jc = 0; jc < NC; ++jc )
412 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
416 resTotalMob += resRelPerm / resVisc;
418 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
420 dMob[jc] += (dRelPerm[jc] *resVisc - resRelPerm * dVisc[jc] )
421 / ( resVisc * resVisc);
427 real64 const mult = wellElemTotalDens * resTotalMob;
429 real64 dMult[2][CP_Deriv::nDer]{};
430 dMult[TAG::WELL][CP_Deriv::dP] = 0.0;
431 if constexpr ( IS_THERMAL )
433 dMult[TAG::WELL][CP_Deriv::dT] = 0.0;
435 for(
integer ic = 0; ic < NC; ++ic )
437 dMult[TAG::WELL][CP_Deriv::dC+ic] = resTotalMob;
439 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
441 dMult[TAG::RES][jc] = wellElemTotalDens * dMob[jc];
446 flux = mult * potDiff;
448 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
450 dFlux[TAG::RES][ic] = dMult[TAG::RES][ic] * potDiff + mult * dPotDiff[TAG::RES][ic];
451 dFlux[TAG::WELL][ic] = dMult[TAG::WELL][ic] * potDiff + mult * dPotDiff[TAG::WELL][ic];
454 for(
integer ic = 0; ic < NC; ++ic )
456 m_compPerfRate[iperf][ic] += m_wellElemCompFrac[iwelem][ic] * flux;
457 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
459 m_dCompPerfRate[iperf][TAG::RES][ic][jc] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::RES][jc];
462 for(
integer ic = 0; ic < NC; ++ic )
464 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dP] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dP];
465 if constexpr ( IS_THERMAL )
467 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dT] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dT];
469 for(
integer jc = 0; jc < NC; ++jc )
471 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dC+jc];
472 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_dWellElemCompFrac_dCompDens[iwelem][ic][jc] * flux;
475 if constexpr ( IS_THERMAL )
477 fluxKernelOp( iwelem, er, esr, ei, -1, potDiff, flux, dFlux );
488 template<
typename POLICY,
typename KERNEL_TYPE >
491 KERNEL_TYPE
const & kernelComponent )
497 kernelComponent.computeFlux( iperf );
503 StackVariables m_stackVariables;
506 ElementViewConst< arrayView1d< real64 const > >
const m_resPres;
507 ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > >
const m_resPhaseVolFrac;
508 ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > >
const m_dResPhaseVolFrac;
509 ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > >
const m_dResCompFrac_dCompDens;
510 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseDens;
511 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseDens;
512 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseVisc;
513 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseVisc;
514 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > >
const m_resPhaseCompFrac;
515 ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > >
const m_dResPhaseCompFrac;
516 ElementViewConst< arrayView3d< real64 const, constitutive::relperm::USD_RELPERM > >
const m_resPhaseRelPerm;
517 ElementViewConst< arrayView4d< real64 const, constitutive::relperm::USD_RELPERM_DS > >
const m_dResPhaseRelPerm_dPhaseVolFrac;
536 bool const m_disableReservoirToWellFlow;
561 template<
typename POLICY >
565 string const flowSolverName,
569 integer const disableReservoirToWellFlow )
571 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
573 integer constexpr NUM_COMP = NC();
574 integer constexpr NUM_PHASE = NP();
575 integer constexpr IS_THERMAL = 0;
578 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
579 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
580 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
582 kernelType kernel( perforationData, subRegion, compFlowAccessors, multiFluidAccessors, relPermAccessors, disableReservoirToWellFlow );
583 kernelType::template launch< POLICY >( perforationData->
size(), kernel );
590 namespace thermalPerforationFluxKernels
593 using namespace constitutive;
597 template<
integer NC,
integer NP,
integer IS_THERMAL >
604 using Base::m_resPhaseCompFrac;
605 using Base::m_dResCompFrac_dCompDens;
606 using Base::m_dWellElemCompFrac_dCompDens;
616 static constexpr
integer isThermal = IS_THERMAL;
629 fields::multifluid::phaseEnthalpy,
630 fields::multifluid::dPhaseEnthalpy >;
643 template<
typename VIEWTYPE >
648 MultiFluidBase
const & fluid,
652 bool const disableReservoirToWellFlow,
655 :
Base( perforationData,
660 disableReservoirToWellFlow ),
661 m_wellElemPhaseFrac( fluid.phaseFraction() ),
662 m_dPhaseFrac( fluid.dPhaseFraction() ),
663 m_wellElemPhaseEnthalpy( fluid.phaseEnthalpy()),
664 m_dWellElemPhaseEnthalpy( fluid.dPhaseEnthalpy()),
665 m_energyPerfFlux( perforationData->getField< fields::well::energyPerforationFlux >()),
666 m_dEnergyPerfFlux( perforationData->getField< fields::well::dEnergyPerforationFlux >()),
667 m_temp( thermalCompFlowAccessors.get( fields::flow::temperature {} ) ),
668 m_resPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::phaseEnthalpy {} ) ),
669 m_dResPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::dPhaseEnthalpy {} ) )
673 template<
typename FUNC = NoOpFunc >
679 using Deriv = constitutive::multifluid::DerivativeOffset;
680 using CP_Deriv =constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
682 m_energyPerfFlux[iperf]=0;
683 for(
integer ke = 0; ke < 2; ++ke )
685 for(
integer i = 0; i < CP_Deriv::nDer; ++i )
687 m_dEnergyPerfFlux[iperf][ke][i]=0;
697 real64 const res_enthalpy = m_resPhaseEnthalpy[er][esr][ei][0][ip];
699 m_energyPerfFlux[iperf] += flux * res_enthalpy;
702 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * res_enthalpy +
703 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dP];
704 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * res_enthalpy +
705 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dT];
707 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * res_enthalpy;
708 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * res_enthalpy;
712 real64 dProp_dC[numComp]{};
714 m_dResCompFrac_dCompDens[er][esr][ei],
715 m_dResPhaseEnthalpy[er][esr][ei][0][ip],
719 for(
integer jc = 0; jc < NC; ++jc )
721 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dC+jc] += flux * dProp_dC[jc];
726 for(
integer iphase = 0; iphase < NP; ++iphase )
728 bool const phaseExists = m_wellElemPhaseFrac[iwelem][0][iphase] > 0.0;
731 double pflux = m_wellElemPhaseFrac[iwelem][0][iphase]*flux;
732 real64 const wellelem_enthalpy = m_wellElemPhaseEnthalpy[iwelem][0][iphase];
733 m_energyPerfFlux[iperf] += pflux * wellelem_enthalpy;
736 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * wellelem_enthalpy;
737 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * wellelem_enthalpy;
739 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * wellelem_enthalpy
740 + pflux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dP]
741 + pflux * wellelem_enthalpy * m_dPhaseFrac[iwelem][0][iphase][Deriv::dP];
742 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * wellelem_enthalpy
743 + pflux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dT]
744 + pflux * wellelem_enthalpy * m_dPhaseFrac[iwelem][0][iphase][Deriv::dT];
747 real64 dPVF_dC[numComp]{};
749 m_dWellElemCompFrac_dCompDens[iwelem],
750 m_dPhaseFrac[iwelem][0][iphase],
753 for(
integer ic=0; ic<NC; ic++ )
755 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * dFlux[TAG::WELL][CP_Deriv::dC+ic] * m_wellElemPhaseFrac[iwelem][0][iphase];
756 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * pflux * dPVF_dC[ ic];
759 real64 dProp_dC[numComp]{};
761 m_dWellElemCompFrac_dCompDens[iwelem],
762 m_dWellElemPhaseEnthalpy[iwelem][0][iphase],
766 for(
integer jc = 0; jc < NC; ++jc )
768 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+jc] += pflux * dProp_dC[jc];
786 template<
typename POLICY,
typename KERNEL_TYPE >
789 KERNEL_TYPE
const & kernelComponent )
794 kernelComponent.computeFlux( iperf );
842 template<
typename POLICY >
846 string const flowSolverName,
849 MultiFluidBase
const & fluid,
851 integer const disableReservoirToWellFlow )
853 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
855 integer constexpr NUM_COMP = NC();
856 integer constexpr NUM_PHASE = NP();
857 integer constexpr IS_THERMAL = 1;
860 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
861 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
862 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
863 typename kernelType::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, flowSolverName );
864 typename kernelType::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, flowSolverName );
866 kernelType kernel( perforationData, subRegion, fluid, compFlowAccessors, multiFluidAccessors,
867 relPermAccessors, disableReservoirToWellFlow,
868 thermalCompFlowAccessors,
869 thermalMultiFluidAccessors );
870 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.
GEOS_HOST_DEVICE StackVariables()
Constructor for the stack variables.