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
57 template<
integer NC,
integer NP,
integer IS_THERMAL >
74 fields::flow::phaseVolumeFraction,
75 fields::flow::dPhaseVolumeFraction,
76 fields::flow::dGlobalCompFraction_dGlobalCompDensity >;
80 fields::multifluid::phaseDensity,
81 fields::multifluid::dPhaseDensity,
82 fields::multifluid::phaseViscosity,
83 fields::multifluid::dPhaseViscosity,
84 fields::multifluid::phaseCompFraction,
85 fields::multifluid::dPhaseCompFraction >;
89 fields::relperm::phaseRelPerm,
90 fields::relperm::dPhaseRelPerm_dPhaseVolFraction >;
100 template<
typename VIEWTYPE >
108 bool const disableReservoirToWellFlow ):
109 m_resPres( compFlowAccessors.get( fields::flow::pressure {} )),
110 m_resPhaseVolFrac( compFlowAccessors.get( fields::flow::phaseVolumeFraction {} )),
111 m_dResPhaseVolFrac( compFlowAccessors.get( fields::flow::dPhaseVolumeFraction {} )),
112 m_dResCompFrac_dCompDens( compFlowAccessors.get( fields::flow::dGlobalCompFraction_dGlobalCompDensity {} )),
113 m_resPhaseDens( multiFluidAccessors.get( fields::multifluid::phaseDensity {} )),
114 m_dResPhaseDens( multiFluidAccessors.get( fields::multifluid::dPhaseDensity {} )),
115 m_resPhaseVisc( multiFluidAccessors.get( fields::multifluid::phaseViscosity {} )),
116 m_dResPhaseVisc( multiFluidAccessors.get( fields::multifluid::dPhaseViscosity {} )),
117 m_resPhaseCompFrac( multiFluidAccessors.get( fields::multifluid::phaseCompFraction {} )),
118 m_dResPhaseCompFrac( multiFluidAccessors.get( fields::multifluid::dPhaseCompFraction {} )),
119 m_resPhaseRelPerm( relPermAccessors.get( fields::relperm::phaseRelPerm {} )),
120 m_dResPhaseRelPerm_dPhaseVolFrac( relPermAccessors.get( fields::relperm::dPhaseRelPerm_dPhaseVolFraction {} )),
121 m_wellElemGravCoef( subRegion.getField< fields::well::gravityCoefficient >()),
122 m_wellElemPres( subRegion.getField< fields::well::pressure >()),
123 m_wellElemCompDens( subRegion.getField< fields::well::globalCompDensity >()),
124 m_wellElemTotalMassDens( subRegion.getField< fields::well::totalMassDensity >()),
125 m_dWellElemTotalMassDens( subRegion.getField< fields::well::dTotalMassDensity >()),
126 m_wellElemCompFrac( subRegion.getField< fields::well::globalCompFraction >()),
127 m_dWellElemCompFrac_dCompDens( subRegion.getField< fields::well::dGlobalCompFraction_dGlobalCompDensity >()),
128 m_perfGravCoef( perforationData->getField< fields::well::gravityCoefficient >()),
129 m_perfWellElemIndex( perforationData->getField< fields::perforation::wellElementIndex >()),
130 m_perfTrans( perforationData->getField< fields::perforation::wellTransmissibility >()),
131 m_resElementRegion( perforationData->getField< fields::perforation::reservoirElementRegion >()),
132 m_resElementSubRegion( perforationData->getField< fields::perforation::reservoirElementSubRegion >()),
133 m_resElementIndex( perforationData->getField< fields::perforation::reservoirElementIndex >()),
134 m_compPerfRate( perforationData->getField< fields::well::compPerforationRate >()),
135 m_dCompPerfRate( perforationData->getField< fields::well::dCompPerforationRate >()),
136 m_disableReservoirToWellFlow( disableReservoirToWellFlow )
151 template<
typename FUNC = NoOpFunc >
155 computeFlux(
localIndex const iperf, FUNC && fluxKernelOp= NoOpFunc {} )
const
158 localIndex const er = m_resElementRegion[iperf];
159 localIndex const esr = m_resElementSubRegion[iperf];
160 localIndex const ei = m_resElementIndex[iperf];
163 localIndex const iwelem = m_perfWellElemIndex[iperf];
165 using Deriv = constitutive::multifluid::DerivativeOffset;
166 using CP_Deriv = constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
177 real64 dPres[2][CP_Deriv::nDer]{};
178 real64 dFlux[2][CP_Deriv::nDer]{};
179 real64 dMob[CP_Deriv::nDer]{};
180 real64 dPotDiff[2][CP_Deriv::nDer]{};
181 real64 dCompFrac[CP_Deriv::nDer]{};
184 for(
integer ic = 0; ic < NC; ++ic )
186 m_compPerfRate[iperf][ic] = 0.0;
187 for(
integer ke = 0; ke < 2; ++ke )
189 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
191 m_dCompPerfRate[iperf][ke][ic][jc] = 0.0;
200 pres[TAG::RES] = m_resPres[er][esr][ei];
201 dPres[TAG::RES][CP_Deriv::dP] = 1.0;
202 multiplier[TAG::RES] = 1.0;
210 pres[TAG::WELL] = m_wellElemPres[iwelem];
211 dPres[TAG::WELL][CP_Deriv::dP] = 1.0;
212 multiplier[TAG::WELL] = -1.0;
214 real64 const gravD = ( m_perfGravCoef[iperf] - m_wellElemGravCoef[iwelem] );
216 pres[TAG::WELL] += m_wellElemTotalMassDens[iwelem] * gravD;
218 dPres[TAG::WELL][CP_Deriv::dP] += m_dWellElemTotalMassDens[iwelem][Deriv::dP] * gravD;
219 if constexpr ( IS_THERMAL )
221 dPres[TAG::WELL][CP_Deriv::dT] += m_dWellElemTotalMassDens[iwelem][Deriv::dT] * gravD;
223 for(
integer ic = 0; ic < NC; ++ic )
225 dPres[TAG::WELL][CP_Deriv::dC+ic] += m_dWellElemTotalMassDens[iwelem][Deriv::dC+ic] * gravD;
231 for(
integer i = 0; i < 2; ++i )
233 potDiff += multiplier[i] * m_perfTrans[iperf] * pres[i];
235 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
237 dPotDiff[i][ic] += multiplier[i] * m_perfTrans[iperf] * dPres[i][ic];
248 for(
integer ip = 0; ip < NP; ++ip )
252 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
253 if( !phaseExists || m_disableReservoirToWellFlow )
261 real64 const resDens = m_resPhaseDens[er][esr][ei][0][ip];
262 real64 dDens[CP_Deriv::nDer]{};
264 dDens[CP_Deriv::dP] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dP];
265 if constexpr ( IS_THERMAL )
267 dDens[CP_Deriv::dT] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dT];
269 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
270 m_dResPhaseDens[er][esr][ei][0][ip],
271 &dDens[CP_Deriv::dC],
274 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
275 real64 dVisc[CP_Deriv::nDer]{};
276 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
277 if constexpr ( IS_THERMAL )
279 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
282 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
283 m_dResPhaseVisc[er][esr][ei][0][ip],
284 &dVisc[CP_Deriv::dC],
288 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
289 real64 dRelPerm[CP_Deriv::nDer]{};
290 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
294 for(
integer jp = 0; jp < NP; ++jp )
296 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
297 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
298 if constexpr ( IS_THERMAL )
300 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
302 for(
integer jc = 0; jc < NC; ++jc )
304 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
309 real64 const resPhaseMob = resDens * resRelPerm / resVisc;
312 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
314 dMob[jc] = dRelPerm[jc] * resDens / resVisc
315 + resPhaseMob * (dDens[jc] / resDens - dVisc[jc] / resVisc);
318 flux = resPhaseMob * potDiff;
320 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
322 dFlux[TAG::RES][jc] = dMob[jc] * potDiff + resPhaseMob * dPotDiff[TAG::RES][jc];
323 dFlux[TAG::WELL][jc] = resPhaseMob * dPotDiff[TAG::WELL][jc];
327 for(
integer ic = 0; ic < NC; ++ic )
330 m_compPerfRate[iperf][ic] += flux * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
331 dCompFrac[CP_Deriv::dP] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dP];
332 if constexpr (IS_THERMAL)
334 dCompFrac[CP_Deriv::dT] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dT];
338 m_dResCompFrac_dCompDens[er][esr][ei],
339 m_dResPhaseCompFrac[er][esr][ei][0][ip][ic],
340 &dCompFrac[CP_Deriv::dC],
343 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
345 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += dFlux[TAG::RES][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
346 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += flux * dCompFrac[jc];
347 m_dCompPerfRate[iperf][TAG::WELL][ic][jc] += dFlux[TAG::WELL][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
350 if constexpr ( IS_THERMAL )
352 fluxKernelOp( iwelem, er, esr, ei, ip, potDiff, flux, dFlux );
364 real64 wellElemTotalDens = 0;
365 for(
integer ic = 0; ic < NC; ++ic )
367 wellElemTotalDens += m_wellElemCompDens[iwelem][ic];
371 for(
integer ip = 0; ip < NP; ++ip )
375 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
382 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
383 real64 dVisc[CP_Deriv::nDer]{};
384 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
385 if constexpr ( IS_THERMAL )
387 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
390 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
391 m_dResPhaseVisc[er][esr][ei][0][ip],
392 &dVisc[CP_Deriv::dC],
397 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
398 real64 dRelPerm[CP_Deriv::nDer]{};
399 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
403 for(
integer jp = 0; jp < NP; ++jp )
405 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
406 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
407 if constexpr ( IS_THERMAL )
409 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
411 for(
integer jc = 0; jc < NC; ++jc )
413 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
417 resTotalMob += resRelPerm / resVisc;
419 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
421 dMob[jc] += (dRelPerm[jc] *resVisc - resRelPerm * dVisc[jc] )
422 / ( resVisc * resVisc);
428 real64 const mult = wellElemTotalDens * resTotalMob;
430 real64 dMult[2][CP_Deriv::nDer]{};
431 dMult[TAG::WELL][CP_Deriv::dP] = 0.0;
432 if constexpr ( IS_THERMAL )
434 dMult[TAG::WELL][CP_Deriv::dT] = 0.0;
436 for(
integer ic = 0; ic < NC; ++ic )
438 dMult[TAG::WELL][CP_Deriv::dC+ic] = resTotalMob;
440 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
442 dMult[TAG::RES][jc] = wellElemTotalDens * dMob[jc];
447 flux = mult * potDiff;
449 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
451 dFlux[TAG::RES][ic] = dMult[TAG::RES][ic] * potDiff + mult * dPotDiff[TAG::RES][ic];
452 dFlux[TAG::WELL][ic] = dMult[TAG::WELL][ic] * potDiff + mult * dPotDiff[TAG::WELL][ic];
455 for(
integer ic = 0; ic < NC; ++ic )
457 m_compPerfRate[iperf][ic] += m_wellElemCompFrac[iwelem][ic] * flux;
458 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
460 m_dCompPerfRate[iperf][TAG::RES][ic][jc] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::RES][jc];
463 for(
integer ic = 0; ic < NC; ++ic )
465 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dP] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dP];
466 if constexpr ( IS_THERMAL )
468 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dT] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dT];
470 for(
integer jc = 0; jc < NC; ++jc )
472 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dC+jc];
473 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_dWellElemCompFrac_dCompDens[iwelem][ic][jc] * flux;
476 if constexpr ( IS_THERMAL )
478 fluxKernelOp( iwelem, er, esr, ei, -1, potDiff, flux, dFlux );
489 template<
typename POLICY,
typename KERNEL_TYPE >
492 KERNEL_TYPE
const & kernelComponent )
498 kernelComponent.computeFlux( iperf );
504 StackVariables m_stackVariables;
507 ElementViewConst< arrayView1d< real64 const > >
const m_resPres;
508 ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > >
const m_resPhaseVolFrac;
509 ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > >
const m_dResPhaseVolFrac;
510 ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > >
const m_dResCompFrac_dCompDens;
511 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseDens;
512 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseDens;
513 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseVisc;
514 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseVisc;
515 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > >
const m_resPhaseCompFrac;
516 ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > >
const m_dResPhaseCompFrac;
517 ElementViewConst< arrayView3d< real64 const, constitutive::relperm::USD_RELPERM > >
const m_resPhaseRelPerm;
518 ElementViewConst< arrayView4d< real64 const, constitutive::relperm::USD_RELPERM_DS > >
const m_dResPhaseRelPerm_dPhaseVolFrac;
537 bool const m_disableReservoirToWellFlow;
562 template<
typename POLICY >
566 string const flowSolverName,
570 integer const disableReservoirToWellFlow )
572 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
574 integer constexpr NUM_COMP = NC();
575 integer constexpr NUM_PHASE = NP();
576 integer constexpr IS_THERMAL = 0;
579 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
580 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
581 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
583 kernelType kernel( perforationData, subRegion, compFlowAccessors, multiFluidAccessors, relPermAccessors, disableReservoirToWellFlow );
584 kernelType::template launch< POLICY >( perforationData->
size(), kernel );
591 namespace thermalPerforationFluxKernels
594 using namespace constitutive;
598 template<
integer NC,
integer NP,
integer IS_THERMAL >
605 using Base::m_resPhaseCompFrac;
606 using Base::m_dResCompFrac_dCompDens;
607 using Base::m_dWellElemCompFrac_dCompDens;
617 static constexpr
integer isThermal = IS_THERMAL;
630 fields::multifluid::phaseEnthalpy,
631 fields::multifluid::dPhaseEnthalpy >;
644 template<
typename VIEWTYPE >
649 MultiFluidBase
const & fluid,
653 bool const disableReservoirToWellFlow,
656 :
Base( perforationData,
661 disableReservoirToWellFlow ),
662 m_wellElemPhaseFrac( fluid.phaseFraction() ),
663 m_dPhaseFrac( fluid.dPhaseFraction() ),
664 m_wellElemPhaseEnthalpy( fluid.phaseEnthalpy()),
665 m_dWellElemPhaseEnthalpy( fluid.dPhaseEnthalpy()),
666 m_energyPerfFlux( perforationData->getField< fields::well::energyPerforationFlux >()),
667 m_dEnergyPerfFlux( perforationData->getField< fields::well::dEnergyPerforationFlux >()),
668 m_temp( thermalCompFlowAccessors.get( fields::flow::temperature {} ) ),
669 m_resPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::phaseEnthalpy {} ) ),
670 m_dResPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::dPhaseEnthalpy {} ) )
674 template<
typename FUNC = NoOpFunc >
680 using Deriv = constitutive::multifluid::DerivativeOffset;
681 using CP_Deriv =constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
683 m_energyPerfFlux[iperf]=0;
684 for(
integer ke = 0; ke < 2; ++ke )
686 for(
integer i = 0; i < CP_Deriv::nDer; ++i )
688 m_dEnergyPerfFlux[iperf][ke][i]=0;
698 real64 const res_enthalpy = m_resPhaseEnthalpy[er][esr][ei][0][ip];
700 m_energyPerfFlux[iperf] += flux * res_enthalpy;
703 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * res_enthalpy +
704 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dP];
705 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * res_enthalpy +
706 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dT];
708 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * res_enthalpy;
709 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * res_enthalpy;
713 real64 dProp_dC[numComp]{};
715 m_dResCompFrac_dCompDens[er][esr][ei],
716 m_dResPhaseEnthalpy[er][esr][ei][0][ip],
720 for(
integer jc = 0; jc < NC; ++jc )
722 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dC+jc] += flux * dProp_dC[jc];
727 for(
integer iphase = 0; iphase < NP; ++iphase )
729 bool const phaseExists = m_wellElemPhaseFrac[iwelem][0][iphase] > 0.0;
732 double pflux = m_wellElemPhaseFrac[iwelem][0][iphase]*flux;
733 real64 const wellelem_enthalpy = m_wellElemPhaseEnthalpy[iwelem][0][iphase];
734 m_energyPerfFlux[iperf] += pflux * wellelem_enthalpy;
737 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * wellelem_enthalpy;
738 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * wellelem_enthalpy;
740 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * wellelem_enthalpy
741 + pflux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dP]
742 + pflux * wellelem_enthalpy * m_dPhaseFrac[iwelem][0][iphase][Deriv::dP];
743 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * wellelem_enthalpy
744 + pflux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dT]
745 + pflux * wellelem_enthalpy * m_dPhaseFrac[iwelem][0][iphase][Deriv::dT];
748 real64 dPVF_dC[numComp]{};
750 m_dWellElemCompFrac_dCompDens[iwelem],
751 m_dPhaseFrac[iwelem][0][iphase],
754 for(
integer ic=0; ic<NC; ic++ )
756 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * dFlux[TAG::WELL][CP_Deriv::dC+ic] * m_wellElemPhaseFrac[iwelem][0][iphase];
757 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * pflux * dPVF_dC[ ic];
760 real64 dProp_dC[numComp]{};
762 m_dWellElemCompFrac_dCompDens[iwelem],
763 m_dWellElemPhaseEnthalpy[iwelem][0][iphase],
767 for(
integer jc = 0; jc < NC; ++jc )
769 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+jc] += pflux * dProp_dC[jc];
787 template<
typename POLICY,
typename KERNEL_TYPE >
790 KERNEL_TYPE
const & kernelComponent )
795 kernelComponent.computeFlux( iperf );
843 template<
typename POLICY >
847 string const flowSolverName,
850 MultiFluidBase
const & fluid,
852 integer const disableReservoirToWellFlow )
854 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
856 integer constexpr NUM_COMP = NC();
857 integer constexpr NUM_PHASE = NP();
858 integer constexpr IS_THERMAL = 1;
861 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
862 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
863 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
864 typename kernelType::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, flowSolverName );
865 typename kernelType::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, flowSolverName );
867 kernelType kernel( perforationData, subRegion, fluid, compFlowAccessors, multiFluidAccessors,
868 relPermAccessors, disableReservoirToWellFlow,
869 thermalCompFlowAccessors,
870 thermalMultiFluidAccessors );
871 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.