20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_HYDROSTATICPRESSUREKERNEL_IMPL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_HYDROSTATICPRESSUREKERNEL_IMPL_HPP
25 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
30 namespace isothermalCompositionalMultiphaseBaseKernels
33 static real64 constexpr MIN_FOR_PHASE_PRESENCE = constitutive::MultiFluidConstants::minForSpeciesPresence;
34 static real64 constexpr MIN_FOR_COMP_PRESENCE = constitutive::MultiFluidConstants::minForSpeciesPresence;
36 template<
typename FLUID_WRAPPER >
37 typename HydrostaticPressureKernel< FLUID_WRAPPER >::ReturnType
38 HydrostaticPressureKernel< FLUID_WRAPPER >::
39 computeHydrostaticPressure(
integer const & numComps,
45 arrayView1d< real64 const >
const & phaseContacts,
46 arrayView1d< real64 const >
const & phaseMinVolumeFraction,
47 integer const maxNumEquilIterations,
48 real64 const & equilTolerance,
49 real64 const (&gravVector)[ 3 ],
50 FLUID_WRAPPER fluidWrapper,
51 arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers,
52 TableFunction::KernelWrapper tempTableWrapper,
53 real64 const & refElevation,
54 arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 >
const & refPres,
55 arraySlice1d< real64 const >
const & refPhaseMassDens,
56 real64 const & newElevation,
57 arraySlice1d< real64, constitutive::multifluid::USD_PHASE - 2 >
const & newPres,
58 arraySlice1d< real64 >
const & newPhaseMassDens,
59 arraySlice1d< real64, constitutive::multifluid::USD_PHASE - 2 >
const & newPhaseDens,
60 arraySlice2d< real64, constitutive::multifluid::USD_PHASE_COMP - 2 >
const & newPhaseCompFrac )
63 StackArray< real64, 2, constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, compflow::LAYOUT_COMP > inputComposition( 1, numComps );
64 StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, constitutive::multifluid::LAYOUT_PHASE > phaseFrac( 1, 1, numPhases );
65 StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, constitutive::multifluid::LAYOUT_PHASE > phaseDens( 1, 1, numPhases );
66 StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, constitutive::multifluid::LAYOUT_PHASE > phaseMassDens( 1, 1, numPhases );
67 StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, constitutive::multifluid::LAYOUT_PHASE > phaseVisc( 1, 1, numPhases );
68 StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, constitutive::multifluid::LAYOUT_PHASE > phaseEnthalpy( 1, 1, numPhases );
69 StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, constitutive::multifluid::LAYOUT_PHASE > phaseInternalEnergy( 1, 1, numPhases );
70 StackArray<
real64, 4, constitutive::MultiFluidBase::MAX_NUM_PHASES *constitutive::MultiFluidBase::MAX_NUM_COMPONENTS,
71 constitutive::multifluid::LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhases, numComps );
74 bool const isSinglePhaseInitialisation = phaseContacts.size() == 0;
76 bool isSinglePhaseFlow =
true;
80 real64 const gravCoef = gravVector[2] * ( refElevation - newElevation );
81 real64 const temperature = tempTableWrapper.compute( &newElevation );
82 for(
integer ic = 0; ic < numComps; ++ic )
84 inputComposition[0][ic] = compFracTableWrappers[ic].compute( &newElevation );
88 StackArray< real64, 2, 2*constitutive::MultiFluidBase::MAX_NUM_PHASES > phasePressures( 2, numPhases );
89 StackArray< real64, 2, constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, compflow::LAYOUT_COMP > compFrac( 1, numComps );
92 phasePressures[0][ip] = refPres[ip] - refPhaseMassDens[ip] * gravCoef;
96 integer const flashPhase = isSinglePhaseInitialisation ? ipInit :
97 evaluateFlashPhaseIndex( numPhases,
106 constitutive::MultiFluidBase::KernelWrapper::computeValues( fluidWrapper,
107 phasePressures[0][flashPhase],
115 phaseInternalEnergy[0][0],
120 if( isSinglePhaseInitialisation )
122 for(
integer ic = 0; ic < numComps; ++ic )
124 compFrac[0][ic] = inputComposition[0][ic];
129 phaseCorrection( numComps,
133 phaseMinVolumeFraction,
134 phasePressures[0][flashPhase],
141 for(
localIndex ip = 0; ip < numPhases; ++ip )
143 phasePressures[1][ip] = refPres[ip] - 0.5 * ( refPhaseMassDens[ip] + phaseMassDens[0][0][ip] ) * gravCoef;
147 bool equilHasConverged =
false;
148 for(
integer eqIter = 0; eqIter < maxNumEquilIterations; ++eqIter )
151 real64 pressureError = 0.0;
152 for(
integer ip = 0; ip < numPhases; ++ip )
154 real64 const dp = LvArray::math::abs( phasePressures[0][ip] - phasePressures[1][ip] );
155 pressureError = LvArray::math::max( pressureError, dp );
156 phasePressures[0][ip] = phasePressures[1][ip];
158 equilHasConverged = ( pressureError < equilTolerance );
161 if( equilHasConverged )
167 constitutive::MultiFluidBase::KernelWrapper::computeValues( fluidWrapper,
168 phasePressures[0][flashPhase],
176 phaseInternalEnergy[0][0],
179 for(
integer ip = 0; ip < numPhases; ++ip )
181 phasePressures[1][ip] = refPres[ip] - 0.5 * ( refPhaseMassDens[ip] + phaseMassDens[0][0][ip] ) * gravCoef;
188 for(
integer ip = 0; ip < numPhases; ++ip )
190 newPres[ip] = phasePressures[1][ip];
191 newPhaseMassDens[ip] = phaseMassDens[0][0][ip];
192 newPhaseDens[ip] = phaseDens[0][0][ip];
193 for(
integer ic = 0; ic < numComps; ++ic )
195 newPhaseCompFrac[ip][ic] = phaseCompFrac[0][0][ip][ic];
197 if( phaseFrac[0][0][ip] > MIN_FOR_PHASE_PRESENCE )
202 if( 1 < numberOfPhases )
204 isSinglePhaseFlow =
false;
207 if( !equilHasConverged )
209 return ReturnType::FAILED_TO_CONVERGE;
211 else if( !isSinglePhaseFlow )
213 return ReturnType::DETECTED_MULTIPHASE_FLOW;
217 return ReturnType::SUCCESS;
221 template<
typename FLUID_WRAPPER >
222 typename HydrostaticPressureKernel< FLUID_WRAPPER >::ReturnType
223 HydrostaticPressureKernel< FLUID_WRAPPER >::
224 computeHydrostaticPressureAtMultipleElevations(
localIndex const & startElevationIndex,
232 arrayView1d< real64 const >
const & phaseContacts,
233 arrayView1d< real64 const >
const & phaseMinVolumeFraction,
234 integer const & maxNumEquilIterations,
235 real64 const & equilTolerance,
236 real64 const (&gravVector)[ 3 ],
237 FLUID_WRAPPER fluidWrapper,
238 arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers,
239 TableFunction::KernelWrapper tempTableWrapper,
240 arrayView1d< arrayView1d< real64 >
const > elevationValues,
241 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & pressureValues,
242 arrayView2d< real64 >
const & phaseMassDens,
243 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & phaseDens,
244 arrayView4d< real64, constitutive::multifluid::USD_PHASE_COMP >
const & phaseCompFrac )
247 localIndex const numEntries = LvArray::math::abs( startElevationIndex - endElevationIndex );
248 localIndex const step = ( endElevationIndex >= startElevationIndex ) ? 1 : -1;
249 ReturnType returnVal = ReturnType::SUCCESS;
250 forAll< serialPolicy >( numEntries, [=, &returnVal] (
localIndex const i )
252 localIndex const ref = startElevationIndex + i * step;
254 ReturnType
const iReturnVal =
255 computeHydrostaticPressure( numComps,
262 phaseMinVolumeFraction,
263 maxNumEquilIterations,
267 compFracTableWrappers,
269 elevationValues[0][ref],
270 pressureValues[ref][0],
272 elevationValues[0][next],
273 pressureValues[next][0],
276 phaseCompFrac[next][0] );
277 if( iReturnVal == ReturnType::FAILED_TO_CONVERGE )
279 returnVal = ReturnType::FAILED_TO_CONVERGE;
281 else if( iReturnVal == ReturnType::DETECTED_MULTIPHASE_FLOW )
283 returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW;
290 template<
typename FLUID_WRAPPER >
291 typename HydrostaticPressureKernel< FLUID_WRAPPER >::ReturnType
292 HydrostaticPressureKernel< FLUID_WRAPPER >::
293 marchBetweenTwoElevations(
real64 const & startElevation,
294 real64 const & endElevation,
301 arrayView1d< real64 const >
const & phaseContacts,
302 arrayView1d< real64 const >
const & phaseMinVolumeFraction,
303 integer const maxNumEquilIterations,
304 real64 const & equilTolerance,
305 real64 const (&gravVector)[ 3 ],
306 FLUID_WRAPPER fluidWrapper,
307 arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers,
308 TableFunction::KernelWrapper tempTableWrapper,
309 arrayView1d< arrayView1d< real64 >
const > elevationValues,
310 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & pressureValues,
311 arrayView2d< real64 >
const & phaseMassDens,
312 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & phaseDens,
313 arrayView4d< real64, constitutive::multifluid::USD_PHASE_COMP >
const & phaseCompFrac )
318 evaluatePrimaryAndContactPhaseIndices( numPhases,
329 localIndex const iStart = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(),
330 elevationValues[0].size(),
333 localIndex const iEnd = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(),
334 elevationValues[0].size(),
337 ReturnType returnVal =
338 computeHydrostaticPressureAtMultipleElevations( iStart,
347 phaseMinVolumeFraction,
348 maxNumEquilIterations,
352 compFracTableWrappers,
361 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > endPressure( 1, 1, numPhases );
362 array3d< real64 > endPhaseMassDens( 1, 1, numPhases );
363 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > endPhaseDens( 1, 1, numPhases );
364 array4d< real64, constitutive::multifluid::LAYOUT_PHASE_COMP > endPhaseCompFrac( 1, 1, numPhases, numComps );
366 computeHydrostaticPressure( numComps,
373 phaseMinVolumeFraction,
374 maxNumEquilIterations,
378 compFracTableWrappers,
380 elevationValues[0][iEnd],
381 pressureValues[iEnd][0],
385 endPhaseMassDens[0][0],
387 endPhaseCompFrac[0][0] );
389 real64 err = LvArray::math::abs( endPressure[0][0][ipCP] - endPressure[0][0][ipPP] ) / endPressure[0][0][ipPP];
390 int constexpr maxMarchIterations = 10;
391 real64 constexpr pressureTolerance = 1.0e-5;
394 for(
int marchIter = 1; marchIter < maxMarchIterations; ++marchIter )
396 if( err < pressureTolerance )
401 endPressure[0][0][ipCP] = endPressure[0][0][ipPP];
402 real64 const iStartPrimaryPressure = pressureValues[iStart][0][ipPP];
405 computeHydrostaticPressure( numComps,
412 phaseMinVolumeFraction,
413 maxNumEquilIterations,
417 compFracTableWrappers,
421 endPhaseMassDens[0][0],
422 elevationValues[0][iStart],
423 pressureValues[iStart][0],
424 phaseMassDens[iStart],
425 phaseDens[iStart][0],
426 phaseCompFrac[iStart][0] );
427 pressureValues[iStart][0][ipPP] = iStartPrimaryPressure;
430 computeHydrostaticPressureAtMultipleElevations( iStart,
439 phaseMinVolumeFraction,
440 maxNumEquilIterations,
444 compFracTableWrappers,
453 computeHydrostaticPressure( numComps,
460 phaseMinVolumeFraction,
461 maxNumEquilIterations,
465 compFracTableWrappers,
467 elevationValues[0][iEnd],
468 pressureValues[iEnd][0],
472 endPhaseMassDens[0][0],
474 endPhaseCompFrac[0][0] );
475 err = LvArray::math::abs( endPressure[0][0][ipCP] - endPressure[0][0][ipPP] ) / endPressure[0][0][ipPP];
481 template<
typename FLUID_WRAPPER >
482 typename HydrostaticPressureKernel< FLUID_WRAPPER >::ReturnType
483 HydrostaticPressureKernel< FLUID_WRAPPER >::
491 integer const & maxNumEquilIterations,
492 arrayView1d< real64 const >
const & phaseContacts,
493 arrayView1d< real64 const >
const & phaseMinVolumeFraction,
494 real64 const equilTolerance,
495 real64 const (&gravVector)[ 3 ],
496 real64 const & datumElevation,
498 FLUID_WRAPPER fluidWrapper,
499 arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers,
500 TableFunction::KernelWrapper tempTableWrapper,
501 arrayView1d< arrayView1d< real64 >
const > elevationValues,
502 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & pressureValues,
503 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & phaseDens,
504 arrayView4d< real64, constitutive::multifluid::USD_PHASE_COMP >
const & phaseCompFrac )
506 ReturnType returnVal = ReturnType::SUCCESS;
509 int const numContacts = phaseContacts.size();
510 bool const isSinglePhase = (numContacts == 0);
514 if( numContacts > 1 )
518 if( LvArray::math::abs( phaseContacts[1] - datumElevation ) <=
519 LvArray::math::abs( phaseContacts[0] - datumElevation ) )
527 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPresInput( 1, 1, numPhases );
528 for(
localIndex ip = 0; ip < numPhases; ++ip )
530 datumPresInput[0][0][ip] = datumPres;
534 real64 const datumTemp = tempTableWrapper.compute( &datumElevation );
535 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPhaseMassDens( 1, 1, numPhases );
536 computeDatumPhaseMassDens( numComps,
540 phaseMinVolumeFraction,
545 compFracTableWrappers,
551 localIndex const iDatum = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(),
552 elevationValues[0].size(),
556 array2d< real64 > phaseMassDens( size, numPhases );
558 array1d< real64 > datumPhaseMassDensTmp( numPhases );
559 for(
integer ip = 0; ip < numPhases; ++ip )
561 datumPhaseMassDensTmp[ip] = datumPhaseMassDens[0][0][ip];
564 ReturnType
const iDatumReturnVal =
565 computeHydrostaticPressure( numComps,
572 phaseMinVolumeFraction,
573 maxNumEquilIterations,
577 compFracTableWrappers,
580 datumPresInput[0][0],
581 datumPhaseMassDensTmp,
582 elevationValues[0][iDatum],
583 pressureValues[iDatum][0],
584 phaseMassDens[iDatum],
585 phaseDens[iDatum][0],
586 phaseCompFrac[iDatum][0] );
587 if( iDatumReturnVal == ReturnType::FAILED_TO_CONVERGE )
589 return ReturnType::FAILED_TO_CONVERGE;
591 else if( iDatumReturnVal == ReturnType::DETECTED_MULTIPHASE_FLOW )
593 returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW;
599 returnVal = computeHydrostaticPressureAtMultipleElevations( iDatum,
608 phaseMinVolumeFraction,
609 maxNumEquilIterations,
613 compFracTableWrappers,
622 returnVal = computeHydrostaticPressureAtMultipleElevations( iDatum,
631 phaseMinVolumeFraction,
632 maxNumEquilIterations,
636 compFracTableWrappers,
646 integer iContactCloseIndex = iDatum;
648 integer iContactBottom = iDatum;
651 if( LvArray::math::abs( datumElevation - phaseContacts[iContactClose] ) > 1e-12 )
654 iContactCloseIndex = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(),
655 elevationValues[0].size(),
656 phaseContacts[iContactClose] );
659 returnVal = marchBetweenTwoElevations( datumElevation,
660 phaseContacts[iContactClose],
668 phaseMinVolumeFraction,
669 maxNumEquilIterations,
673 compFracTableWrappers,
682 integer iContactFarIndex = iContactCloseIndex;
684 if( iContactFar != -1 && LvArray::math::abs( phaseContacts[iContactClose] - phaseContacts[iContactFar] ) > 1e-12 )
687 iContactFarIndex = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(),
688 elevationValues[0].size(),
689 phaseContacts[iContactFar] );
692 returnVal = marchBetweenTwoElevations( phaseContacts[iContactClose],
693 phaseContacts[iContactFar],
701 phaseMinVolumeFraction,
702 maxNumEquilIterations,
706 compFracTableWrappers,
715 if( iContactFar == -1 )
717 iContactTop = iContactCloseIndex;
718 iContactBottom = iContactCloseIndex;
720 else if( phaseContacts[iContactClose] > phaseContacts[iContactFar] )
722 iContactTop = iContactCloseIndex;
723 iContactBottom = iContactFarIndex;
727 iContactTop = iContactFarIndex;
728 iContactBottom = iContactCloseIndex;
732 returnVal = computeHydrostaticPressureAtMultipleElevations( iContactTop,
741 phaseMinVolumeFraction,
742 maxNumEquilIterations,
746 compFracTableWrappers,
755 returnVal = computeHydrostaticPressureAtMultipleElevations( iContactBottom,
764 phaseMinVolumeFraction,
765 maxNumEquilIterations,
769 compFracTableWrappers,
780 template<
typename FLUID_WRAPPER >
781 typename HydrostaticPressureKernel< FLUID_WRAPPER >::ReturnType
782 HydrostaticPressureKernel< FLUID_WRAPPER >::
783 phaseCorrection(
integer const & numComps,
787 arrayView1d< real64 const >
const & phaseMinVolumeFraction,
790 arraySlice1d< real64 const, compflow::USD_COMP - 1 >
const & inputComposition,
791 arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 >
const & phaseFrac,
792 arraySlice1d< real64, compflow::USD_COMP - 1 >
const & compFrac,
793 FLUID_WRAPPER fluidWrapper )
796 StackArray< real64, 2, constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, compflow::LAYOUT_COMP > addedCompFrac( 1, numComps );
799 bool phaseCorrectionNeeded =
false;
800 if( ipGas >= 0 && LvArray::math::abs( phaseFrac[ipGas] ) < MIN_FOR_PHASE_PRESENCE
801 && LvArray::math::abs( phaseMinVolumeFraction[ipGas] ) > MIN_FOR_PHASE_PRESENCE )
803 addedCompFrac[0][0] = 1.0;
805 ip_otherPhase = ipWater;
806 phaseCorrectionNeeded =
true;
816 if( ipWater >= 0 && LvArray::math::abs( phaseFrac[ipWater] ) < MIN_FOR_PHASE_PRESENCE
817 && LvArray::math::abs( phaseMinVolumeFraction[ipWater] ) > MIN_FOR_PHASE_PRESENCE )
819 addedCompFrac[0][1] = 1.0;
821 ip_otherPhase = ipGas;
822 phaseCorrectionNeeded =
true;
825 if( phaseCorrectionNeeded )
827 return applyPhaseCorrection( numComps,
842 compFrac[ic] = inputComposition[ic];
844 return ReturnType::PHASE_CORRECTION_NOT_NEEDED;
849 template<
typename FLUID_WRAPPER >
850 typename HydrostaticPressureKernel< FLUID_WRAPPER >::ReturnType
851 HydrostaticPressureKernel< FLUID_WRAPPER >::
852 applyPhaseCorrection(
integer const & numComps,
858 arraySlice1d< real64 const, compflow::USD_COMP - 1 >
const & inputComposition,
859 arraySlice1d< real64 const, compflow::USD_COMP - 1 >
const & addedCompFrac,
860 arraySlice1d< real64, compflow::USD_COMP - 1 >
const & compFrac,
861 FLUID_WRAPPER fluidWrapper )
864 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > phaseFrac( 1, 1, numPhases );
865 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > phaseDens( 1, 1, numPhases );
866 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > phaseMassDens( 1, 1, numPhases );
867 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > phaseVisc( 1, 1, numPhases );
868 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > phaseEnthalpy( 1, 1, numPhases );
869 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > phaseInternalEnergy( 1, 1, numPhases );
870 array4d< real64, constitutive::multifluid::LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhases, numComps );
877 real64 targetPhaseFrac = 1e-4;
879 for(
int iter = 0; iter < maxIters; ++iter )
881 a = ( a_high + a_low ) * 0.5;
882 mixingStep( numComps,
887 constitutive::MultiFluidBase::KernelWrapper::computeValues( fluidWrapper,
896 phaseInternalEnergy[0][0],
899 err = ( phaseFrac[0][0][ip_phase] - targetPhaseFrac ) / targetPhaseFrac;
900 if( LvArray::math::abs( phaseFrac[0][0][ip_otherPhase] - 1.0 ) < MIN_FOR_PHASE_PRESENCE )
904 else if( LvArray::math::abs( phaseFrac[0][0][ip_phase] - 1.0 ) < MIN_FOR_PHASE_PRESENCE )
918 if( LvArray::math::abs( err ) < 1e-5 )
925 return ReturnType::SUCCESS;
928 template<
typename FLUID_WRAPPER >
930 HydrostaticPressureKernel< FLUID_WRAPPER >:: mixingStep(
integer const & numComps,
932 arraySlice1d< real64 const, compflow::USD_COMP - 1 >
const & inputComposition,
933 arraySlice1d< real64 const, compflow::USD_COMP - 1 >
const & addedCompFrac,
934 arraySlice1d< real64, compflow::USD_COMP - 1 >
const & compFrac )
939 compFrac[ic] = a * addedCompFrac[ic] + ( 1 - a ) * inputComposition[ic];
940 if( compFrac[ic] < MIN_FOR_COMP_PRESENCE )
952 template<
typename FLUID_WRAPPER >
954 HydrostaticPressureKernel< FLUID_WRAPPER >::
955 evaluateFlashPhaseIndex(
integer const & numPhases,
961 arrayView1d< real64 const >
const & phaseContacts )
972 ipFP = ( ipGas >= 0 ) ? ipGas :
973 ( ipOil >= 0 ) ? ipOil :
974 ( ipWater >= 0 ) ? ipWater : 0;
977 else if( ipGas >= 0 && ipOil >= 0 && ipWater >= 0 )
980 real64 const goc = phaseContacts[1];
981 real64 const owc = phaseContacts[0];
988 else if( elevation > goc
989 || LvArray::math::abs( elevation - goc ) < 1e-12 )
994 else if( ipGas >= 0 && ipWater >= 0 )
997 real64 const gwc = phaseContacts[0];
1000 || LvArray::math::abs( elevation - gwc ) < 1e-12 )
1005 else if( ipOil >= 0 && ipWater >= 0 )
1008 real64 const owc = phaseContacts[0];
1011 || LvArray::math::abs( elevation - owc ) < 1e-12 )
1016 else if( ipGas >= 0 && ipOil >= 0 )
1019 real64 const goc = phaseContacts[0];
1022 || LvArray::math::abs( elevation - goc ) < 1e-12 )
1030 template<
typename FLUID_WRAPPER >
1032 HydrostaticPressureKernel< FLUID_WRAPPER >::
1033 evaluatePrimaryAndContactPhaseIndices(
integer const & numPhases,
1037 real64 const & startElevation,
1038 real64 const & endElevation,
1039 arrayView1d< real64 const >
const & phaseContacts,
1047 if( ipGas >= 0 && ipOil >= 0 && ipWater >= 0 )
1050 real64 const goc = phaseContacts[1];
1051 real64 const owc = phaseContacts[0];
1054 if( LvArray::math::abs( endElevation - owc ) < 1e-12
1055 && startElevation > owc )
1060 else if( LvArray::math::abs( endElevation - goc ) < 1e-12 )
1062 if( startElevation < goc )
1074 else if( ipGas >= 0 && ipWater >= 0 )
1077 real64 const gwc = phaseContacts[0];
1080 if( startElevation > gwc )
1086 else if( ipOil >= 0 && ipWater >= 0 )
1089 real64 const owc = phaseContacts[0];
1092 if( startElevation > owc )
1098 else if( ipGas >= 0 && ipOil >= 0 )
1101 real64 const goc = phaseContacts[0];
1104 if( startElevation > goc )
1114 template<
typename FLUID_WRAPPER >
1116 HydrostaticPressureKernel< FLUID_WRAPPER >::
1117 computeDatumPhaseMassDens(
integer const & numComps,
1121 arrayView1d< real64 const >
const & phaseMinVolumeFraction,
1122 real64 const & datumElevation,
1123 real64 const & datumPres,
1124 real64 const & datumTemp,
1125 arrayView3d< real64, constitutive::multifluid::USD_PHASE >
const & datumPhaseMassDens,
1126 arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers,
1128 FLUID_WRAPPER fluidWrapper )
1131 array2d< real64, compflow::LAYOUT_COMP > datumInputComposition( 1, numComps );
1132 array2d< real64, compflow::LAYOUT_COMP > datumCompFrac( 1, numComps );
1133 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPhaseFrac( 1, 1, numPhases );
1134 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPhaseDens( 1, 1, numPhases );
1135 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPhaseVisc( 1, 1, numPhases );
1136 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPhaseEnthalpy( 1, 1, numPhases );
1137 array3d< real64, constitutive::multifluid::LAYOUT_PHASE > datumPhaseInternalEnergy( 1, 1, numPhases );
1138 array4d< real64, constitutive::multifluid::LAYOUT_PHASE_COMP > datumPhaseCompFrac( 1, 1, numPhases, numComps );
1139 real64 datumTotalDens = 0.0;
1140 for(
integer ic = 0; ic < numComps; ++ic )
1142 datumInputComposition[0][ic] = compFracTableWrappers[ic].compute( &datumElevation );
1144 constitutive::MultiFluidBase::KernelWrapper::computeValues( fluidWrapper,
1147 datumInputComposition[0],
1148 datumPhaseFrac[0][0],
1149 datumPhaseDens[0][0],
1150 datumPhaseMassDens[0][0],
1151 datumPhaseVisc[0][0],
1152 datumPhaseEnthalpy[0][0],
1153 datumPhaseInternalEnergy[0][0],
1154 datumPhaseCompFrac[0][0],
1162 ReturnType datumPhaseCorr = phaseCorrection( numComps,
1166 phaseMinVolumeFraction,
1169 datumInputComposition[0],
1170 datumPhaseFrac[0][0],
1173 if( datumPhaseCorr == ReturnType::SUCCESS )
1174 constitutive::MultiFluidBase::KernelWrapper::computeValues( fluidWrapper,
1178 datumPhaseFrac[0][0],
1179 datumPhaseDens[0][0],
1180 datumPhaseMassDens[0][0],
1181 datumPhaseVisc[0][0],
1182 datumPhaseEnthalpy[0][0],
1183 datumPhaseInternalEnergy[0][0],
1184 datumPhaseCompFrac[0][0],
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZE > StackArray
Multidimensional stack-based array type. See LvArray:StackArray for details.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
int integer
Signed integer type.