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 isInjector,
107 bool const isCrossflowEnabled ):
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_perfStatus( perforationData->getField< fields::perforation::perforationStatus >()),
136 m_isInjector( isInjector ),
137 m_isCrossflowEnabled( isCrossflowEnabled )
140 template<
typename FUNC = NoOpFunc >
144 computeFlux(
localIndex const iperf, FUNC && fluxKernelOp= NoOpFunc {} )
const
146 using CP_Deriv = constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
148 if( !m_perfStatus[iperf] )
150 for(
integer ic = 0; ic < NC; ++ic )
152 m_compPerfRate[iperf][ic] = 0.0;
153 for(
integer ke = 0; ke < 2; ++ke )
155 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
157 m_dCompPerfRate[iperf][ke][ic][jc] = 0.0;
164 localIndex const er = m_resElementRegion[iperf];
165 localIndex const esr = m_resElementSubRegion[iperf];
166 localIndex const ei = m_resElementIndex[iperf];
169 localIndex const iwelem = m_perfWellElemIndex[iperf];
171 using Deriv = constitutive::multifluid::DerivativeOffset;
183 real64 dPres[2][CP_Deriv::nDer]{};
184 real64 dFlux[2][CP_Deriv::nDer]{};
185 real64 dMob[CP_Deriv::nDer]{};
186 real64 dPotDiff[2][CP_Deriv::nDer]{};
187 real64 dCompFrac[CP_Deriv::nDer]{};
190 for(
integer ic = 0; ic < NC; ++ic )
192 m_compPerfRate[iperf][ic] = 0.0;
193 for(
integer ke = 0; ke < 2; ++ke )
195 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
197 m_dCompPerfRate[iperf][ke][ic][jc] = 0.0;
206 pres[TAG::RES] = m_resPres[er][esr][ei];
207 dPres[TAG::RES][CP_Deriv::dP] = 1.0;
208 multiplier[TAG::RES] = 1.0;
216 pres[TAG::WELL] = m_wellElemPres[iwelem];
217 dPres[TAG::WELL][CP_Deriv::dP] = 1.0;
218 multiplier[TAG::WELL] = -1.0;
220 real64 const gravD = ( m_perfGravCoef[iperf] - m_wellElemGravCoef[iwelem] );
222 pres[TAG::WELL] += m_wellElemTotalMassDens[iwelem] * gravD;
224 dPres[TAG::WELL][CP_Deriv::dP] += m_dWellElemTotalMassDens[iwelem][Deriv::dP] * gravD;
225 if constexpr ( IS_THERMAL )
227 dPres[TAG::WELL][CP_Deriv::dT] += m_dWellElemTotalMassDens[iwelem][Deriv::dT] * gravD;
229 for(
integer ic = 0; ic < NC; ++ic )
231 dPres[TAG::WELL][CP_Deriv::dC+ic] += m_dWellElemTotalMassDens[iwelem][Deriv::dC+ic] * gravD;
237 for(
integer i = 0; i < 2; ++i )
239 potDiff += multiplier[i] * m_perfTrans[iperf] * pres[i];
241 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
243 dPotDiff[i][ic] += multiplier[i] * m_perfTrans[iperf] * dPres[i][ic];
254 for(
integer ip = 0; ip < NP; ++ip )
258 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
259 if( !phaseExists || (m_isInjector && !m_isCrossflowEnabled) )
267 real64 const resDens = m_resPhaseDens[er][esr][ei][0][ip];
268 real64 dDens[CP_Deriv::nDer]{};
270 dDens[CP_Deriv::dP] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dP];
271 if constexpr ( IS_THERMAL )
273 dDens[CP_Deriv::dT] = m_dResPhaseDens[er][esr][ei][0][ip][Deriv::dT];
275 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
276 m_dResPhaseDens[er][esr][ei][0][ip],
277 &dDens[CP_Deriv::dC],
280 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
281 real64 dVisc[CP_Deriv::nDer]{};
282 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
283 if constexpr ( IS_THERMAL )
285 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
288 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
289 m_dResPhaseVisc[er][esr][ei][0][ip],
290 &dVisc[CP_Deriv::dC],
294 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
295 real64 dRelPerm[CP_Deriv::nDer]{};
296 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
300 for(
integer jp = 0; jp < NP; ++jp )
302 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
303 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
304 if constexpr ( IS_THERMAL )
306 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
308 for(
integer jc = 0; jc < NC; ++jc )
310 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
315 real64 const resPhaseMob = resDens * resRelPerm / resVisc;
318 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
320 dMob[jc] = dRelPerm[jc] * resDens / resVisc
321 + resPhaseMob * (dDens[jc] / resDens - dVisc[jc] / resVisc);
324 flux = resPhaseMob * potDiff;
326 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
328 dFlux[TAG::RES][jc] = dMob[jc] * potDiff + resPhaseMob * dPotDiff[TAG::RES][jc];
329 dFlux[TAG::WELL][jc] = resPhaseMob * dPotDiff[TAG::WELL][jc];
333 for(
integer ic = 0; ic < NC; ++ic )
336 m_compPerfRate[iperf][ic] += flux * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
337 dCompFrac[CP_Deriv::dP] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dP];
338 if constexpr (IS_THERMAL)
340 dCompFrac[CP_Deriv::dT] = m_dResPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dT];
344 m_dResCompFrac_dCompDens[er][esr][ei],
345 m_dResPhaseCompFrac[er][esr][ei][0][ip][ic],
346 &dCompFrac[CP_Deriv::dC],
349 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
351 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += dFlux[TAG::RES][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
352 m_dCompPerfRate[iperf][TAG::RES][ic][jc] += flux * dCompFrac[jc];
353 m_dCompPerfRate[iperf][TAG::WELL][ic][jc] += dFlux[TAG::WELL][jc] * m_resPhaseCompFrac[er][esr][ei][0][ip][ic];
356 if constexpr ( IS_THERMAL )
358 fluxKernelOp( iwelem, er, esr, ei, ip, potDiff, flux, dFlux );
370 real64 wellElemTotalDens = 0;
371 for(
integer ic = 0; ic < NC; ++ic )
373 wellElemTotalDens += m_wellElemCompDens[iwelem][ic];
377 for(
integer ip = 0; ip < NP; ++ip )
382 bool const phaseExists = (m_resPhaseVolFrac[er][esr][ei][ip] > 0);
383 if( !phaseExists || (!m_isInjector && !m_isCrossflowEnabled) )
389 real64 const resVisc = m_resPhaseVisc[er][esr][ei][0][ip];
390 real64 dVisc[CP_Deriv::nDer]{};
391 dVisc[CP_Deriv::dP] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dP];
392 if constexpr ( IS_THERMAL )
394 dVisc[CP_Deriv::dT] = m_dResPhaseVisc[er][esr][ei][0][ip][Deriv::dT];
397 applyChainRule( NC, m_dResCompFrac_dCompDens[er][esr][ei],
398 m_dResPhaseVisc[er][esr][ei][0][ip],
399 &dVisc[CP_Deriv::dC],
404 real64 const resRelPerm = m_resPhaseRelPerm[er][esr][ei][0][ip];
405 real64 dRelPerm[CP_Deriv::nDer]{};
406 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
410 for(
integer jp = 0; jp < NP; ++jp )
412 real64 const dResRelPerm_dS = m_dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0][ip][jp];
413 dRelPerm[CP_Deriv::dP] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dP];
414 if constexpr ( IS_THERMAL )
416 dRelPerm[CP_Deriv::dT] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dT];
418 for(
integer jc = 0; jc < NC; ++jc )
420 dRelPerm[CP_Deriv::dC+jc] += dResRelPerm_dS * m_dResPhaseVolFrac[er][esr][ei][jp][Deriv::dC+jc];
424 resTotalMob += resRelPerm / resVisc;
426 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
428 dMob[jc] += (dRelPerm[jc] *resVisc - resRelPerm * dVisc[jc] )
429 / ( resVisc * resVisc);
435 real64 const mult = wellElemTotalDens * resTotalMob;
437 real64 dMult[2][CP_Deriv::nDer]{};
438 dMult[TAG::WELL][CP_Deriv::dP] = 0.0;
439 if constexpr ( IS_THERMAL )
441 dMult[TAG::WELL][CP_Deriv::dT] = 0.0;
443 for(
integer ic = 0; ic < NC; ++ic )
445 dMult[TAG::WELL][CP_Deriv::dC+ic] = resTotalMob;
447 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
449 dMult[TAG::RES][jc] = wellElemTotalDens * dMob[jc];
454 flux = mult * potDiff;
456 for(
integer ic = 0; ic < CP_Deriv::nDer; ++ic )
458 dFlux[TAG::RES][ic] = dMult[TAG::RES][ic] * potDiff + mult * dPotDiff[TAG::RES][ic];
459 dFlux[TAG::WELL][ic] = dMult[TAG::WELL][ic] * potDiff + mult * dPotDiff[TAG::WELL][ic];
462 for(
integer ic = 0; ic < NC; ++ic )
464 m_compPerfRate[iperf][ic] += m_wellElemCompFrac[iwelem][ic] * flux;
465 for(
integer jc = 0; jc < CP_Deriv::nDer; ++jc )
467 m_dCompPerfRate[iperf][TAG::RES][ic][jc] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::RES][jc];
470 for(
integer ic = 0; ic < NC; ++ic )
472 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dP] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dP];
473 if constexpr ( IS_THERMAL )
475 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dT] = m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dT];
477 for(
integer jc = 0; jc < NC; ++jc )
479 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_wellElemCompFrac[iwelem][ic] * dFlux[TAG::WELL][CP_Deriv::dC+jc];
480 m_dCompPerfRate[iperf][TAG::WELL][ic][CP_Deriv::dC+jc] += m_dWellElemCompFrac_dCompDens[iwelem][ic][jc] * flux;
483 if constexpr ( IS_THERMAL )
485 fluxKernelOp( iwelem, er, esr, ei, -1, potDiff, flux, dFlux );
496 template<
typename POLICY,
typename KERNEL_TYPE >
499 KERNEL_TYPE
const & kernelComponent )
504 kernelComponent.computeFlux( iperf );
510 ElementViewConst< arrayView1d< real64 const > >
const m_resPres;
511 ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > >
const m_resPhaseVolFrac;
512 ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > >
const m_dResPhaseVolFrac;
513 ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > >
const m_dResCompFrac_dCompDens;
514 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseDens;
515 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseDens;
516 ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > >
const m_resPhaseVisc;
517 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > >
const m_dResPhaseVisc;
518 ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > >
const m_resPhaseCompFrac;
519 ElementViewConst< arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > >
const m_dResPhaseCompFrac;
520 ElementViewConst< arrayView3d< real64 const, constitutive::relperm::USD_RELPERM > >
const m_resPhaseRelPerm;
521 ElementViewConst< arrayView4d< real64 const, constitutive::relperm::USD_RELPERM_DS > >
const m_dResPhaseRelPerm_dPhaseVolFrac;
541 bool const m_isInjector;
542 bool const m_isCrossflowEnabled;
565 template<
typename POLICY >
569 string const flowSolverName,
573 bool const isInjector,
574 bool const isCrossflowEnabled )
576 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
578 integer constexpr NUM_COMP = NC();
579 integer constexpr NUM_PHASE = NP();
580 integer constexpr IS_THERMAL = 0;
583 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
584 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
585 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
587 kernelType kernel( perforationData, subRegion,
588 compFlowAccessors, multiFluidAccessors, relPermAccessors,
589 isInjector, isCrossflowEnabled );
590 kernelType::template launch< POLICY >( perforationData->
size(), kernel );
597 namespace thermalPerforationFluxKernels
600 using namespace constitutive;
604 template<
integer NC,
integer NP,
integer IS_THERMAL >
610 using Base::m_resPhaseCompFrac;
611 using Base::m_dResCompFrac_dCompDens;
612 using Base::m_dWellElemCompFrac_dCompDens;
621 static constexpr
integer isThermal = IS_THERMAL;
634 fields::multifluid::phaseEnthalpy,
635 fields::multifluid::dPhaseEnthalpy >;
644 template<
typename VIEWTYPE >
649 MultiFluidBase
const & wellFluid,
655 bool const isInjector,
656 bool const isCrossflowEnabled )
657 :
Base( perforationData,
663 isCrossflowEnabled ),
664 m_wellElemPhaseFrac( wellFluid.phaseFraction() ),
665 m_dWellElemPhaseFrac( wellFluid.dPhaseFraction() ),
666 m_wellElemPhaseEnthalpy( wellFluid.phaseEnthalpy()),
667 m_dWellElemPhaseEnthalpy( wellFluid.dPhaseEnthalpy()),
668 m_energyPerfFlux( perforationData->getField< fields::well::energyPerforationFlux >() ),
669 m_dEnergyPerfFlux( perforationData->getField< fields::well::dEnergyPerforationFlux >() ),
670 m_temp( thermalCompFlowAccessors.get( fields::flow::temperature {} ) ),
671 m_resPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::phaseEnthalpy {} ) ),
672 m_dResPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::dPhaseEnthalpy {} ) )
675 template<
typename FUNC = NoOpFunc >
681 using Deriv = constitutive::multifluid::DerivativeOffset;
682 using CP_Deriv =constitutive::multifluid::DerivativeOffsetC< NC, IS_THERMAL >;
684 m_energyPerfFlux[iperf]=0;
685 for(
integer ke = 0; ke < 2; ++ke )
687 for(
integer i = 0; i < CP_Deriv::nDer; ++i )
689 m_dEnergyPerfFlux[iperf][ke][i]=0;
699 real64 const res_enthalpy = m_resPhaseEnthalpy[er][esr][ei][0][ip];
701 m_energyPerfFlux[iperf] += flux * res_enthalpy;
704 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * res_enthalpy +
705 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dP];
706 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * res_enthalpy +
707 flux * m_dResPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dT];
709 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * res_enthalpy;
710 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * res_enthalpy;
714 real64 dProp_dC[numComp]{};
716 m_dResCompFrac_dCompDens[er][esr][ei],
717 m_dResPhaseEnthalpy[er][esr][ei][0][ip],
721 for(
integer jc = 0; jc < NC; ++jc )
723 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dC+jc] += flux * dProp_dC[jc];
728 for(
integer iphase = 0; iphase < NP; ++iphase )
730 bool const phaseExists = m_wellElemPhaseFrac[iwelem][0][iphase] > 0.0;
733 real64 const phaseFlux = m_wellElemPhaseFrac[iwelem][0][iphase] * flux;
734 real64 const wellelem_enthalpy = m_wellElemPhaseEnthalpy[iwelem][0][iphase];
735 m_energyPerfFlux[iperf] += phaseFlux * wellelem_enthalpy;
738 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dP] += dFlux[TAG::RES][CP_Deriv::dP] * wellelem_enthalpy;
739 m_dEnergyPerfFlux[iperf][TAG::RES][CP_Deriv::dT] += dFlux[TAG::RES][CP_Deriv::dT] * wellelem_enthalpy;
741 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dP] += dFlux[TAG::WELL][CP_Deriv::dP] * wellelem_enthalpy
742 + phaseFlux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dP]
743 + phaseFlux * wellelem_enthalpy * m_dWellElemPhaseFrac[iwelem][0][iphase][Deriv::dP];
744 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dT] += dFlux[TAG::WELL][CP_Deriv::dT] * wellelem_enthalpy
745 + phaseFlux * m_dWellElemPhaseEnthalpy[iwelem][0][iphase][Deriv::dT]
746 + phaseFlux * wellelem_enthalpy * m_dWellElemPhaseFrac[iwelem][0][iphase][Deriv::dT];
749 real64 dPVF_dC[numComp]{};
751 m_dWellElemCompFrac_dCompDens[iwelem],
752 m_dWellElemPhaseFrac[iwelem][0][iphase],
755 for(
integer ic=0; ic<NC; ic++ )
757 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * dFlux[TAG::WELL][CP_Deriv::dC+ic] * m_wellElemPhaseFrac[iwelem][0][iphase];
758 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+ic] += wellelem_enthalpy * phaseFlux * dPVF_dC[ic];
761 real64 dProp_dC[numComp]{};
763 m_dWellElemCompFrac_dCompDens[iwelem],
764 m_dWellElemPhaseEnthalpy[iwelem][0][iphase],
768 for(
integer jc = 0; jc < NC; ++jc )
770 m_dEnergyPerfFlux[iperf][TAG::WELL][CP_Deriv::dC+jc] += phaseFlux * dProp_dC[jc];
788 template<
typename POLICY,
typename KERNEL_TYPE >
791 KERNEL_TYPE
const & kernelComponent )
796 kernelComponent.computeFlux( iperf );
843 template<
typename POLICY >
847 string const flowSolverName,
850 MultiFluidBase
const & fluid,
852 bool const isInjector,
853 bool const isCrossflowEnabled )
855 geos::internal::kernelLaunchSelectorCompPhaseSwitch( numComp, numPhases, [&](
auto NC,
auto NP )
857 integer constexpr NUM_COMP = NC();
858 integer constexpr NUM_PHASE = NP();
859 integer constexpr IS_THERMAL = 1;
862 typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, flowSolverName );
863 typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, flowSolverName );
864 typename kernelType::RelPermAccessors relPermAccessors( elemManager, flowSolverName );
865 typename kernelType::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, flowSolverName );
866 typename kernelType::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, flowSolverName );
868 kernelType kernel( perforationData, subRegion, fluid, compFlowAccessors, multiFluidAccessors,
869 relPermAccessors, thermalCompFlowAccessors, thermalMultiFluidAccessors,
870 isInjector, isCrossflowEnabled );
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, bool const isInjector, bool const isCrossflowEnabled)
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, bool const isInjector, bool const isCrossflowEnabled)
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).
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.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.