From c9282627bac3c640a1b927077b1565643f3f976d Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Tue, 15 Feb 2022 14:32:57 -0800 Subject: [PATCH 1/6] combined multifluid derivatives --- .../codingUtilities/Utilities.hpp | 19 +- .../constitutive/fluid/BlackOilFluid.hpp | 244 +++++------ .../fluid/CompositionalMultiphaseFluid.hpp | 50 ++- .../constitutive/fluid/DeadOilFluid.hpp | 30 +- .../constitutive/fluid/MultiFluidBase.cpp | 49 +-- .../constitutive/fluid/MultiFluidBase.hpp | 249 ++++------- .../fluid/MultiFluidExtrinsicData.hpp | 132 +----- .../constitutive/fluid/MultiFluidUtils.hpp | 26 +- .../fluid/MultiPhaseMultiComponentFluid.hpp | 95 ++--- .../fluid/PVTFunctions/BrineEnthalpy.hpp | 61 ++- .../PVTFunctions/BrineInternalEnergy.hpp | 38 +- .../fluid/PVTFunctions/CO2Enthalpy.hpp | 45 +- .../fluid/PVTFunctions/CO2InternalEnergy.hpp | 39 +- .../fluid/PVTFunctions/CO2Solubility.hpp | 116 +++-- .../PVTFunctions/EzrokhiBrineDensity.hpp | 39 +- .../PVTFunctions/EzrokhiBrineViscosity.hpp | 38 +- .../PVTFunctions/FenghourCO2Viscosity.hpp | 36 +- .../PVTFunctions/PhillipsBrineDensity.hpp | 73 ++-- .../PVTFunctions/PhillipsBrineViscosity.hpp | 35 +- .../PVTFunctions/SpanWagnerCO2Density.hpp | 41 +- .../constitutive/fluid/layouts.hpp | 12 + .../CompositionalMultiphaseBaseKernels.hpp | 60 ++- .../fluidFlow/CompositionalMultiphaseFVM.cpp | 6 +- .../CompositionalMultiphaseFVMKernels.cpp | 48 +-- .../CompositionalMultiphaseFVMKernels.hpp | 81 ++-- .../CompositionalMultiphaseHybridFVM.cpp | 30 +- ...ompositionalMultiphaseHybridFVMKernels.cpp | 206 ++++----- ...ompositionalMultiphaseHybridFVMKernels.hpp | 114 ++--- .../wells/CompositionalMultiphaseWell.cpp | 81 ++-- .../CompositionalMultiphaseWellKernels.cpp | 295 ++++++------- .../CompositionalMultiphaseWellKernels.hpp | 121 +++--- .../MultiphasePoromechanicsKernel.hpp | 40 +- .../schema/docs/BlackOilFluid_other.rst | 60 ++- .../docs/CO2BrineEzrokhiFluid_other.rst | 48 +-- .../docs/CO2BrinePhillipsFluid_other.rst | 48 +-- .../CompositionalMultiphaseFluid_other.rst | 48 +-- .../schema/docs/DeadOilFluid_other.rst | 58 +-- .../schema/docs/InternalMesh_other.rst | 11 +- .../schema/docs/InternalWell_other.rst | 1 - .../schema/docs/InternalWellbore_other.rst | 19 +- .../schema/docs/PAMELAMeshGenerator_other.rst | 11 +- .../schema/docs/VTKMeshGenerator_other.rst | 11 +- .../schema/docs/meshLevels_other.rst | 9 + src/coreComponents/schema/schema.xsd.other | 254 +++-------- .../testCO2BrinePVTModels.cpp | 402 +++++++++--------- src/docs/sphinx/CompleteXMLSchema.rst | 14 - 46 files changed, 1441 insertions(+), 2102 deletions(-) create mode 100644 src/coreComponents/schema/docs/meshLevels_other.rst diff --git a/src/coreComponents/codingUtilities/Utilities.hpp b/src/coreComponents/codingUtilities/Utilities.hpp index 06206dd1dc4..de243ac038b 100644 --- a/src/coreComponents/codingUtilities/Utilities.hpp +++ b/src/coreComponents/codingUtilities/Utilities.hpp @@ -188,11 +188,14 @@ void forEachArgInTuple( std::tuple< Ts ... > const & tuple, F && func ) template< typename VEC1, typename VEC2 > GEOSX_HOST_DEVICE -void copy( integer const N, VEC1 const & v1, VEC2 const & v2 ) +void copy( integer const N, + VEC1 const & v1, + VEC2 const & v2, + integer const firstDeriv = 0 ) { for( integer i = 0; i < N; ++i ) { - v2[i] = v1[i]; + v2[firstDeriv+i] = v1[i]; } } @@ -201,7 +204,8 @@ GEOSX_HOST_DEVICE void applyChainRule( integer const N, MATRIX const & dy_dx, VEC1 const & df_dy, - VEC2 && df_dx ) + VEC2 && df_dx, + integer const firstDeriv = 0 ) { // this could use some dense linear algebra for( integer i = 0; i < N; ++i ) @@ -209,7 +213,7 @@ void applyChainRule( integer const N, df_dx[i] = 0.0; for( integer j = 0; j < N; ++j ) { - df_dx[i] += df_dy[j] * dy_dx[j][i]; + df_dx[i] += df_dy[firstDeriv+j] * dy_dx[j][i]; } } } @@ -219,10 +223,11 @@ GEOSX_HOST_DEVICE void applyChainRuleInPlace( integer const N, MATRIX const & dy_dx, VEC1 && df_dxy, - VEC2 && work ) + VEC2 && work, + integer const firstDeriv = 0 ) { - applyChainRule( N, dy_dx, df_dxy, work ); - copy( N, work, df_dxy ); + applyChainRule( N, dy_dx, df_dxy, work, firstDeriv ); + copy( N, work, df_dxy, firstDeriv ); } } // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp index d2b8befcae0..7da3479837b 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp @@ -159,8 +159,7 @@ class BlackOilFluid : public BlackOilFluidBase * @param[out] phaseMassDensity phase mass densities (+ derivatives) in the cell * @param[out] phaseViscosity phase viscosities (+ derivatives) in the cell * @param[out] phaseMolecularWeight phase molecular weights in the cell - * @param[out] dPhaseMolecularWeight_dPres derivative of phase molecular weights wrt pressure - * @param[out] dPhaseMolecularWeight_dGlobalCompFrac derivative of phase molecular weights wrt comp fractions + * @param[out] dPhaseMolecularWeight derivative of phase molecular weights wrt pressure, temperature and comp fractions */ GEOSX_HOST_DEVICE void computeDensitiesViscosities( bool const needDerivs, @@ -171,8 +170,7 @@ class BlackOilFluid : public BlackOilFluidBase PhaseProp::SliceType const & phaseMassDens, PhaseProp::SliceType const & phaseVisc, real64 phaseMolecularWeight[NP_BO], - real64 dPhaseMolecularWeight_dPres[NP_BO], - real64 dPhaseMolecularWeight_dGlobalCompFrac[NP_BO][NC_BO] ) const; + real64 dPhaseMolecularWeight[NP_BO][NC_BO+2] ) const; /** * @brief Utility function to compute phase fractions and phase component fractions (no derivatives) @@ -282,8 +280,7 @@ class BlackOilFluid : public BlackOilFluidBase * @param[in] dBo_dPres derivative of oil formation volume factor wrt pressure * @param[in] dBo_dComp derivatives of oil formation volume factor wrt comp fractions * @param[out] dens oil density - * @param[out] dDens_dPres derivative of oil density wrt pressure - * @param[out] dDens_dC derivatives of oil density wrt comp fractions + * @param[out] dDens_dC derivatives of oil density wrt pressure, temperature, and comp fractions */ GEOSX_HOST_DEVICE void computeMassMoleDensity( bool const needDerivs, @@ -296,8 +293,7 @@ class BlackOilFluid : public BlackOilFluidBase real64 const dBo_dPres, real64 const dBo_dComp[], real64 & dens, - real64 & dDens_dPres, - arraySlice1d< real64, multifluid::USD_PHASE_DC - 3 > const & dDens_dC ) const; + arraySlice1d< real64, multifluid::USD_PHASE_DC - 3 > const & dDens ) const; /// Data needed to update the oil phase properties PVTOData::KernelWrapper m_PVTOView; @@ -452,9 +448,7 @@ BlackOilFluid::KernelWrapper:: real64 dCompMoleFrac_dCompMassFrac[NC_BO][NC_BO]{}; real64 phaseMolecularWeight[NP_BO]{}; - real64 dPhaseMolecularWeight_dPressure[NP_BO]{}; - real64 dPhaseMolecularWeight_dTemperature[NP_BO]{}; - real64 dPhaseMolecularWeight_dGlobalCompFraction[NP_BO][NC_BO]{}; + real64 dPhaseMolecularWeight[NP_BO][NC_BO+2]{}; // 1. Convert to mass if necessary @@ -490,8 +484,7 @@ BlackOilFluid::KernelWrapper:: phaseMassDensity, phaseViscosity, phaseMolecularWeight, - dPhaseMolecularWeight_dPressure, - dPhaseMolecularWeight_dGlobalCompFraction ); + dPhaseMolecularWeight ); // 4. If mass variables used instead of molar, perform the conversion @@ -499,13 +492,11 @@ BlackOilFluid::KernelWrapper:: { convertToMassFractions( dCompMoleFrac_dCompMassFrac, phaseMolecularWeight, - dPhaseMolecularWeight_dPressure, - dPhaseMolecularWeight_dTemperature, - dPhaseMolecularWeight_dGlobalCompFraction, + dPhaseMolecularWeight, phaseFraction, phaseCompFraction, - phaseDensity.dComp, - phaseViscosity.dComp ); + phaseDensity.derivs, + phaseViscosity.derivs ); } // 5. Compute total fluid mass/molar density and derivatives @@ -526,17 +517,15 @@ BlackOilFluid::KernelWrapper:: { using namespace multifluid; - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseFrac_dPres( 1, 1, NP_BO ); - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseFrac_dTemp( 1, 1, NP_BO ); - StackArray< real64, 4, NC_BO *NP_BO, LAYOUT_PHASE_DC > dPhaseFrac_dComp( 1, 1, NP_BO, NC_BO ); + integer constexpr NDERIV = NC_BO + 2; + + StackArray< real64, 4, NDERIV *NP_BO, LAYOUT_PHASE_DC > dPhaseFrac( 1, 1, NP_BO, NDERIV ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseFracAndDeriv { phaseFrac, dPhaseFrac_dPres[0][0], dPhaseFrac_dTemp[0][0], dPhaseFrac_dComp[0][0] }; + phaseFracAndDeriv { phaseFrac, dPhaseFrac[0][0] }; - StackArray< real64, 4, NC_BO *NP_BO, LAYOUT_PHASE_COMP > dPhaseCompFrac_dPres( 1, 1, NP_BO, NC_BO ); - StackArray< real64, 4, NC_BO *NP_BO, LAYOUT_PHASE_COMP > dPhaseCompFrac_dTemp( 1, 1, NP_BO, NC_BO ); - StackArray< real64, 5, NC_BO *NC_BO *NP_BO, LAYOUT_PHASE_COMP_DC > dPhaseCompFrac_dComp( 1, 1, NP_BO, NC_BO, NC_BO ); + StackArray< real64, 5, NDERIV *NC_BO *NP_BO, LAYOUT_PHASE_COMP_DC > dPhaseCompFrac( 1, 1, NP_BO, NC_BO, NDERIV ); MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > - phaseCompFracAndDeriv { phaseCompFrac, dPhaseCompFrac_dPres[0][0], dPhaseCompFrac_dTemp[0][0], dPhaseCompFrac_dComp[0][0] }; + phaseCompFracAndDeriv { phaseCompFrac, dPhaseCompFrac[0][0] }; computeEquilibrium( false, // no need to compute derivatives pressure, @@ -554,6 +543,7 @@ BlackOilFluid::KernelWrapper:: PhaseProp::SliceType const & phaseFraction, PhaseComp::SliceType const & phaseCompFraction ) const { + using namespace multifluid; using PT = BlackOilFluid::PhaseType; integer const ipOil = m_phaseOrder[PT::OIL]; @@ -570,36 +560,19 @@ BlackOilFluid::KernelWrapper:: // 1. Make everything zero first - for( integer ip = 0; ip < NP_BO; ++ip ) - { - phaseFraction.value[ip] = 0.; - if( needDerivs ) - { - phaseFraction.dPres[ip] = 0.0; - } - for( integer ic = 0; ic < NC_BO; ++ic ) - { - phaseCompFraction.value[ip][ic] = 0.0; - if( needDerivs ) - { - phaseFraction.dComp[ip][ic] = 0.; - phaseCompFraction.dPres[ip][ic] = 0.0; - for( integer jc = 0; jc < NC_BO; ++jc ) - { - phaseCompFraction.dComp[ip][ic][jc] = 0.0; - } - } - } - } + LvArray::forValuesInSlice( phaseFraction.value, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseFraction.derivs, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseCompFraction.value, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseCompFraction.derivs, []( real64 & val ){ val = 0.0; } ); // 2. Check feed first, and if only water is present (e.g., water inj), then skip - if( zw >= 1. - minForPhasePresence ) + if( zw >= 1.0 - minForPhasePresence ) { phaseFraction.value[ipWater] = zw; if( needDerivs ) { - phaseFraction.dComp[ipWater][icWater] = 1.; + phaseFraction.derivs[ipWater][Deriv::dC+icWater] = 1.0; } phaseCompFraction.value[ipWater][icWater] = 1.0; return; @@ -644,14 +617,14 @@ BlackOilFluid::KernelWrapper:: if( needDerivs ) { - phaseFraction.dPres[ipOil] = -dGasPhaseFraction_dP; - phaseFraction.dPres[ipGas] = dGasPhaseFraction_dP; - phaseFraction.dComp[ipOil][icOil] = -dGasPhaseFraction_dzo; - phaseFraction.dComp[ipOil][icGas] = -dGasPhaseFraction_dzg; - phaseFraction.dComp[ipOil][icWater] = -1.; - phaseFraction.dComp[ipGas][icOil] = dGasPhaseFraction_dzo; - phaseFraction.dComp[ipGas][icGas] = dGasPhaseFraction_dzg; - phaseFraction.dComp[ipWater][icWater] = 1.; + phaseFraction.derivs[ipOil][Deriv::dP] = -dGasPhaseFraction_dP; + phaseFraction.derivs[ipGas][Deriv::dP] = dGasPhaseFraction_dP; + phaseFraction.derivs[ipOil][Deriv::dC+icOil] = -dGasPhaseFraction_dzo; + phaseFraction.derivs[ipOil][Deriv::dC+icGas] = -dGasPhaseFraction_dzg; + phaseFraction.derivs[ipOil][Deriv::dC+icWater] = -1.0; + phaseFraction.derivs[ipGas][Deriv::dC+icOil] = dGasPhaseFraction_dzo; + phaseFraction.derivs[ipGas][Deriv::dC+icGas] = dGasPhaseFraction_dzg; + phaseFraction.derivs[ipWater][Deriv::dC+icWater] = 1.0; } // oil @@ -659,25 +632,25 @@ BlackOilFluid::KernelWrapper:: real64 const tmpOil = oilSurfaceMoleDensity / tmp; real64 const dTmpOil_dP = -oilSurfaceMoleDensity * gasSurfaceMoleDensity * dRsSat_dP / ( tmp * tmp ); phaseCompFraction.value[ipOil][icOil] = tmpOil; - phaseCompFraction.value[ipOil][icGas] = 1. - tmpOil; - phaseCompFraction.value[ipOil][icWater] = 0.; + phaseCompFraction.value[ipOil][icGas] = 1.0 - tmpOil; + phaseCompFraction.value[ipOil][icWater] = 0.0; if( needDerivs ) { - phaseCompFraction.dPres[ipOil][icOil] = dTmpOil_dP; - phaseCompFraction.dPres[ipOil][icGas] = -dTmpOil_dP; + phaseCompFraction.derivs[ipOil][icOil][Deriv::dP] = dTmpOil_dP; + phaseCompFraction.derivs[ipOil][icGas][Deriv::dP] = -dTmpOil_dP; } // gas real64 const tmpGas = gasSurfaceMoleDensity / ( gasSurfaceMoleDensity ); - phaseCompFraction.value[ipGas][icOil] = 1. - tmpGas; + phaseCompFraction.value[ipGas][icOil] = 1.0 - tmpGas; phaseCompFraction.value[ipGas][icGas] = tmpGas; - phaseCompFraction.value[ipGas][icWater] = 0.; + phaseCompFraction.value[ipGas][icWater] = 0.0; // water - phaseCompFraction.value[ipWater][icOil] = 0; - phaseCompFraction.value[ipWater][icGas] = 0; - phaseCompFraction.value[ipWater][icWater] = 1.; + phaseCompFraction.value[ipWater][icOil] = 0.0; + phaseCompFraction.value[ipWater][icGas] = 0.0; + phaseCompFraction.value[ipWater][icWater] = 1.0; } // 4.2 The gas phase is absent @@ -685,26 +658,26 @@ BlackOilFluid::KernelWrapper:: { // phase fractions - phaseFraction.value[ipOil] = 1. - zw; - phaseFraction.value[ipGas] = 0.; - phaseFraction.value[ipWater] = zw; + phaseFraction.value[ipOil] = 1.0 - zw; + phaseFraction.value[ipGas] = 0.0; + phaseFraction.value[ipWater] = zw; // oil phaseCompFraction.value[ipOil][icOil] = zo; phaseCompFraction.value[ipOil][icGas] = zg; - phaseCompFraction.value[ipOil][icWater] = 0.; + phaseCompFraction.value[ipOil][icWater] = 0.0; // gas - phaseCompFraction.value[ipWater][icOil] = 0; - phaseCompFraction.value[ipWater][icGas] = 0; - phaseCompFraction.value[ipWater][icWater] = 1.; + phaseCompFraction.value[ipWater][icOil] = 0.0; + phaseCompFraction.value[ipWater][icGas] = 0.0; + phaseCompFraction.value[ipWater][icWater] = 1.0; if( needDerivs ) { - phaseFraction.dComp[ipOil][icWater] = -1.; - phaseFraction.dComp[ipWater][icWater] = 1.; - phaseCompFraction.dComp[ipOil][icOil][icOil] = 1.; - phaseCompFraction.dComp[ipOil][icGas][icGas] = 1.; + phaseFraction.derivs[ipOil][Deriv::dC+icWater] = -1.0; + phaseFraction.derivs[ipWater][Deriv::dC+icWater] = 1.0; + phaseCompFraction.derivs[ipOil][icOil][Deriv::dC+icOil] = 1.0; + phaseCompFraction.derivs[ipOil][icGas][Deriv::dC+icGas] = 1.0; } } } @@ -722,26 +695,21 @@ BlackOilFluid::KernelWrapper:: { using namespace multifluid; - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseDensity_dPres( 1, 1, NP_BO ); - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseDensity_dTemp( 1, 1, NP_BO ); - StackArray< real64, 4, NC_BO *NP_BO, LAYOUT_PHASE_DC > dPhaseDensity_dComp( 1, 1, NP_BO, NC_BO ); + integer constexpr NDERIV = NC_BO + 2; + + StackArray< real64, 4, NDERIV *NP_BO, LAYOUT_PHASE_DC > dPhaseDensity( 1, 1, NP_BO, NDERIV ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseDensityAndDeriv { phaseDensity, dPhaseDensity_dPres[0][0], dPhaseDensity_dTemp[0][0], dPhaseDensity_dComp[0][0] }; + phaseDensityAndDeriv { phaseDensity, dPhaseDensity[0][0] }; - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseMassDensity_dPres( 1, 1, NP_BO ); - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseMassDensity_dTemp( 1, 1, NP_BO ); - StackArray< real64, 4, NC_BO *NP_BO, LAYOUT_PHASE_DC > dPhaseMassDensity_dComp( 1, 1, NP_BO, NC_BO ); + StackArray< real64, 4, NDERIV *NP_BO, LAYOUT_PHASE_DC > dPhaseMassDensity( 1, 1, NP_BO, NDERIV ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseMassDensityAndDeriv { phaseMassDensity, dPhaseMassDensity_dPres[0][0], dPhaseMassDensity_dTemp[0][0], dPhaseMassDensity_dComp[0][0] }; + phaseMassDensityAndDeriv { phaseMassDensity, dPhaseMassDensity[0][0] }; - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseViscosity_dPres( 1, 1, NP_BO ); - StackArray< real64, 3, NP_BO, LAYOUT_PHASE > dPhaseViscosity_dTemp( 1, 1, NP_BO ); - StackArray< real64, 4, NC_BO *NP_BO, LAYOUT_PHASE_DC > dPhaseViscosity_dComp( 1, 1, NP_BO, NC_BO ); + StackArray< real64, 4, NDERIV *NP_BO, LAYOUT_PHASE_DC > dPhaseViscosity( 1, 1, NP_BO, NDERIV ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseViscosityAndDeriv { phaseViscosity, dPhaseViscosity_dPres[0][0], dPhaseViscosity_dTemp[0][0], dPhaseViscosity_dComp[0][0] }; + phaseViscosityAndDeriv { phaseViscosity, dPhaseViscosity[0][0] }; - real64 dPhaseMolecularWeight_dPres[NP_BO]{}; - real64 dPhaseMolecularWeight_dGlobalCompFrac[NP_BO][NC_BO]{}; + real64 dPhaseMolecularWeight[NP_BO][NC_BO+2]{}; computeDensitiesViscosities( false, // no need to compute derivatives pressure, @@ -751,8 +719,7 @@ BlackOilFluid::KernelWrapper:: phaseMassDensityAndDeriv, phaseViscosityAndDeriv, phaseMolecularWeight, - dPhaseMolecularWeight_dPres, - dPhaseMolecularWeight_dGlobalCompFrac ); + dPhaseMolecularWeight ); } GEOSX_HOST_DEVICE @@ -766,9 +733,9 @@ BlackOilFluid::KernelWrapper:: PhaseProp::SliceType const & phaseMassDens, PhaseProp::SliceType const & phaseVisc, real64 phaseMolecularWeight[NP_BO], - real64 dPhaseMolecularWeight_dPres[NP_BO], - real64 dPhaseMolecularWeight_dGlobalCompFrac[NP_BO][NC_BO] ) const + real64 dPhaseMolecularWeight[NP_BO][NC_BO+2] ) const { + using namespace multifluid; using PT = BlackOilFluid::PhaseType; integer const ipOil = m_phaseOrder[PT::OIL]; @@ -782,21 +749,12 @@ BlackOilFluid::KernelWrapper:: bool const isGas = (ipGas >= 0 && phaseFrac[ipGas] > 0); bool const isOil = (ipOil >= 0 && phaseFrac[ipOil] > 0); - for( integer ip = 0; ip < NP_BO; ++ip ) - { - phaseMassDens.value[ip] = 0.; - phaseDens.value[ip] = 0.; - phaseVisc.value[ip] = 0.; - phaseDens.dPres[ip] = 0.; - phaseMassDens.dPres[ip] = 0.; - phaseVisc.dPres[ip] = 0.; - for( integer ic = 0; ic < NC_BO; ++ic ) - { - phaseDens.dComp[ip][ic] = 0.; - phaseMassDens.dComp[ip][ic] = 0.; - phaseVisc.dComp[ip][ic] = 0.; - } - } + LvArray::forValuesInSlice( phaseMassDens.value, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseMassDens.derivs, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseDens.value, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseDens.derivs, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseVisc.value, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( phaseVisc.derivs, []( real64 & val ){ val = 0.0; } ); // 1. Gas phase: look up in the formation vol factor tables @@ -816,18 +774,18 @@ BlackOilFluid::KernelWrapper:: if( needDerivs ) { - phaseMassDens.dPres[ipGas] = -derivative * phaseMassDens.value[ipGas] * fvfInv; - phaseDens.dPres[ipGas] = phaseMassDens.dPres[ipGas] * mult; - dPhaseMolecularWeight_dPres[ipGas] = 0.; + phaseMassDens.derivs[ipGas][Deriv::dP] = -derivative * phaseMassDens.value[ipGas] * fvfInv; + phaseDens.derivs[ipGas][Deriv::dP] = phaseMassDens.derivs[ipGas][Deriv::dP] * mult; + dPhaseMolecularWeight[ipGas][Deriv::dP] = 0.0; for( integer ic = 0; ic < NC_BO; ic++ ) { - phaseMassDens.dComp[ipGas][ic] = 0.; - phaseDens.dComp[ipGas][ic] = 0.; - dPhaseMolecularWeight_dGlobalCompFrac[ipGas][ic] = 0.; + phaseMassDens.derivs[ipGas][Deriv::dC+ic] = 0.0; + phaseDens.derivs[ipGas][Deriv::dC+ic] = 0.0; + dPhaseMolecularWeight[ipGas][Deriv::dC+ic] = 0.0; } } - phaseVisc.value[ipGas] = m_viscosityTables[0].compute( &pressure, &(phaseVisc.dPres)[ipGas] ); + phaseVisc.value[ipGas] = m_viscosityTables[0].compute( &pressure, &(phaseVisc.derivs)[ipGas][Deriv::dP] ); } // 2. Water phase: use the constant formation volume factor and compressibility provided by the user @@ -848,14 +806,14 @@ BlackOilFluid::KernelWrapper:: if( needDerivs ) { - phaseMassDens.dPres[ipWater] = -dDenom_dPres * phaseMassDens.value[ipWater] * denomInv; - phaseDens.dPres[ipWater] = phaseMassDens.dPres[ipWater] * mult; - dPhaseMolecularWeight_dPres[ipWater] = 0.; + phaseMassDens.derivs[ipWater][Deriv::dP] = -dDenom_dPres * phaseMassDens.value[ipWater] * denomInv; + phaseDens.derivs[ipWater][Deriv::dP] = phaseMassDens.derivs[ipWater][Deriv::dP] * mult; + dPhaseMolecularWeight[ipWater][Deriv::dP] = 0.0; for( integer ic = 0; ic < NC_BO; ic++ ) { - phaseMassDens.dComp[ipWater][ic] = 0.; - phaseDens.dComp[ipWater][ic] = 0.0; - dPhaseMolecularWeight_dGlobalCompFrac[ipWater][ic] = 0.; + phaseMassDens.derivs[ipWater][Deriv::dC+ic] = 0.0; + phaseDens.derivs[ipWater][Deriv::dC+ic] = 0.0; + dPhaseMolecularWeight[ipWater][Deriv::dC+ic] = 0.0; } } @@ -906,19 +864,18 @@ BlackOilFluid::KernelWrapper:: // compute densities computeMassMoleDensity( needDerivs, true, HNC_BO, Rs, dRs_dP, dRs_dC, Bo, dBo_dP, dBo_dC, - phaseMassDens.value[ipOil], phaseMassDens.dPres[ipOil], - phaseMassDens.dComp[ipOil] ); + phaseMassDens.value[ipOil], phaseMassDens.derivs[ipOil] ); computeMassMoleDensity( needDerivs, false, HNC_BO, Rs, dRs_dP, dRs_dC, Bo, dBo_dP, dBo_dC, - phaseDens.value[ipOil], phaseDens.dPres[ipOil], - phaseDens.dComp[ipOil] ); + phaseDens.value[ipOil], phaseDens.derivs[ipOil] ); phaseMolecularWeight[ipOil] = phaseMassDens.value[ipOil] / phaseDens.value[ipOil]; real64 const tmp = 1. / ( phaseDens.value[ipOil] * phaseDens.value[ipOil] ); - dPhaseMolecularWeight_dPres[ipOil] = ( phaseMassDens.dPres[ipOil] * phaseDens.value[ipOil] - phaseDens.dPres[ipOil] * phaseMassDens.value[ipOil] ) * tmp; + dPhaseMolecularWeight[ipOil][Deriv::dP] = tmp * + ( phaseMassDens.derivs[ipOil][Deriv::dP] * phaseDens.value[ipOil] - phaseDens.derivs[ipOil][Deriv::dP] * phaseMassDens.value[ipOil] ); for( integer ic = 0; ic < NC_BO; ++ic ) { - dPhaseMolecularWeight_dGlobalCompFrac[ipOil][ic] = - ( phaseMassDens.dComp[ipOil][ic] * phaseDens.value[ipOil] - phaseDens.dComp[ipOil][ic] * phaseMassDens.value[ipOil] ) * tmp; + dPhaseMolecularWeight[ipOil][Deriv::dC+ic] = tmp * + ( phaseMassDens.derivs[ipOil][Deriv::dC+ic] * phaseDens.value[ipOil] - phaseDens.derivs[ipOil][Deriv::dC+ic] * phaseMassDens.value[ipOil] ); } if( m_useMass ) @@ -926,23 +883,25 @@ BlackOilFluid::KernelWrapper:: phaseDens.value[ipOil] = phaseMassDens.value[ipOil]; if( needDerivs ) { - phaseDens.dPres[ipOil] = phaseMassDens.dPres[ipOil]; - for( integer i = 0; i < phaseMassDens.dComp[ipOil].size(); ++i ) + phaseDens.derivs[ipOil][Deriv::dP] = phaseMassDens.derivs[ipOil][Deriv::dP]; + for( integer ic = 0; ic < NC_BO; ++ic ) { - phaseDens.dComp[ipOil][i] = phaseMassDens.dComp[ipOil][i]; + phaseDens.derivs[ipOil][Deriv::dC+ic] = phaseMassDens.derivs[ipOil][Deriv::dC+ic]; } } } + /////// TODO FRANCOIS: DOUBLE CHECK THE DERIVATIVE BELOW /////////// + // copy viscosity into the final array // TODO: skip this step phaseVisc.value[ipOil] = visc; if( needDerivs ) { - phaseVisc.dPres[ipOil] = dVisc_dP; - for( integer i = 0; i < HNC_BO; ++i ) + phaseVisc.derivs[ipOil][Deriv::dP] = dVisc_dP; + for( integer ic = 0; ic < HNC_BO; ++ic ) { - phaseVisc.dComp[ipOil][i] = dVisc_dC[i]; + phaseVisc.derivs[ipOil][Deriv::dC+ic] = dVisc_dC[ic]; } } } @@ -1111,9 +1070,9 @@ BlackOilFluid::KernelWrapper:: real64 const dBo_dPres, real64 const dBo_dComp[], real64 & dens, - real64 & dDens_dPres, - arraySlice1d< real64, multifluid::USD_PHASE_DC - 3 > const & dDens_dComp ) const + arraySlice1d< real64, multifluid::USD_PHASE_DC - 3 > const & dDens ) const { + using namespace multifluid; using PT = BlackOilFluid::PhaseType; real64 const oilDens = (useMass)? m_PVTOView.m_surfaceMassDensity[PT::OIL]: @@ -1126,10 +1085,13 @@ BlackOilFluid::KernelWrapper:: dens = Binv * tmp; if( needDerivs ) { - dDens_dPres = Binv * Binv * (Bo * gasDens * dRs_dPres - tmp * dBo_dPres); - for( integer i = 0; i < numHydrocarbonComp; ++i ) + dDens[Deriv::dP] = Binv * Binv * (Bo * gasDens * dRs_dPres - tmp * dBo_dPres); + + /////// TODO FRANCOIS: DOUBLE CHECK THE DERIVATIVE BELOW /////////// + + for( integer ic = 0; ic < numHydrocarbonComp; ++ic ) { - dDens_dComp[i] = Binv * Binv * (Bo * gasDens * dRs_dComp[i] - tmp * dBo_dComp[i]); + dDens[Deriv::dC+ic] = Binv * Binv * (Bo * gasDens * dRs_dComp[ic] - tmp * dBo_dComp[ic]); } } } diff --git a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp index 9f60c01cde6..666590de7d0 100644 --- a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp @@ -261,6 +261,8 @@ CompositionalMultiphaseFluid::KernelWrapper:: GEOSX_ERROR( "This function cannot be used on GPU" ); #else + using namespace multifluid; + integer constexpr maxNumComp = MultiFluidBase::MAX_NUM_COMPONENTS; integer constexpr maxNumPhase = MultiFluidBase::MAX_NUM_PHASES; integer const numComp = numComponents(); @@ -307,36 +309,36 @@ CompositionalMultiphaseFluid::KernelWrapper:: auto const & massDens = props.getMassDensity( phaseType ); phaseFraction.value[ip] = frac.value; - phaseFraction.dPres[ip] = frac.dP; - phaseFraction.dTemp[ip] = frac.dT; + phaseFraction.derivs[ip][Deriv::dP] = frac.dP; + phaseFraction.derivs[ip][Deriv::dT] = frac.dT; phaseDensity.value[ip] = dens.value; - phaseDensity.dPres[ip] = dens.dP; - phaseDensity.dTemp[ip] = dens.dT; + phaseDensity.derivs[ip][Deriv::dP] = dens.dP; + phaseDensity.derivs[ip][Deriv::dT] = dens.dT; phaseMassDensity.value[ip] = massDens.value; - phaseMassDensity.dPres[ip] = massDens.dP; - phaseMassDensity.dTemp[ip] = massDens.dT; + phaseMassDensity.derivs[ip][Deriv::dP] = massDens.dP; + phaseMassDensity.derivs[ip][Deriv::dT] = massDens.dT; // TODO phaseViscosity.value[ip] = 0.001; - phaseViscosity.dPres[ip] = 0.0; - phaseViscosity.dTemp[ip] = 0.0; + phaseViscosity.derivs[ip][Deriv::dP] = 0.0; + phaseViscosity.derivs[ip][Deriv::dT] = 0.0; for( integer jc = 0; jc < numComp; ++jc ) { - phaseFraction.dComp[ip][jc] = frac.dz[jc]; - phaseDensity.dComp[ip][jc] = dens.dz[jc]; - phaseMassDensity.dComp[ip][ip] = massDens.dz[jc]; - phaseViscosity.dComp[ip][jc] = 0.0; // TODO + phaseFraction.derivs[ip][Deriv::dC+jc] = frac.dz[jc]; + phaseDensity.derivs[ip][Deriv::dC+jc] = dens.dz[jc]; + phaseMassDensity.derivs[ip][Deriv::dC+jc] = massDens.dz[jc]; + phaseViscosity.derivs[ip][Deriv::dC+jc] = 0.0; // TODO phaseCompFraction.value[ip][jc] = comp.value[jc]; - phaseCompFraction.dPres[ip][jc] = comp.dP[jc]; - phaseCompFraction.dTemp[ip][jc] = comp.dT[jc]; + phaseCompFraction.derivs[ip][jc][Deriv::dP] = comp.dP[jc]; + phaseCompFraction.derivs[ip][jc][Deriv::dT] = comp.dT[jc]; for( integer ic = 0; ic < numComp; ++ic ) { - phaseCompFraction.dComp[ip][ic][jc] = comp.dz[ic][jc]; + phaseCompFraction.derivs[ip][ic][Deriv::dC+jc] = comp.dz[ic][jc]; } } } @@ -347,30 +349,26 @@ CompositionalMultiphaseFluid::KernelWrapper:: // unfortunately here, we have to copy the molecular weight coming from PVT package... real64 phaseMolecularWeight[maxNumPhase]{}; - real64 dPhaseMolecularWeight_dPres[maxNumPhase]{}; - real64 dPhaseMolecularWeight_dTemp[maxNumPhase]{}; - real64 dPhaseMolecularWeight_dComp[maxNumPhase][maxNumComp]{}; + real64 dPhaseMolecularWeight[maxNumPhase][maxNumComp+2]{}; for( integer ip = 0; ip < numPhase; ++ip ) { phaseMolecularWeight[ip] = props.getMolecularWeight( m_phaseTypes[ip] ).value; - dPhaseMolecularWeight_dPres[ip] = props.getMolecularWeight( m_phaseTypes[ip] ).dP; - dPhaseMolecularWeight_dTemp[ip] = props.getMolecularWeight( m_phaseTypes[ip] ).dT; + dPhaseMolecularWeight[ip][Deriv::dP] = props.getMolecularWeight( m_phaseTypes[ip] ).dP; + dPhaseMolecularWeight[ip][Deriv::dT] = props.getMolecularWeight( m_phaseTypes[ip] ).dT; for( integer ic = 0; ic < numComp; ++ic ) { - dPhaseMolecularWeight_dComp[ip][ic] = props.getMolecularWeight( m_phaseTypes[ip] ).dz[ic]; + dPhaseMolecularWeight[ip][Deriv::dC+ic] = props.getMolecularWeight( m_phaseTypes[ip] ).dz[ic]; } } convertToMassFractions( dCompMoleFrac_dCompMassFrac, phaseMolecularWeight, - dPhaseMolecularWeight_dPres, - dPhaseMolecularWeight_dTemp, - dPhaseMolecularWeight_dComp, + dPhaseMolecularWeight, phaseFraction, phaseCompFraction, - phaseDensity.dComp, - phaseViscosity.dComp ); + phaseDensity.derivs, + phaseViscosity.derivs ); } // 5. Compute total fluid mass/molar density and derivatives diff --git a/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp index ad3fc210d54..e77fa2ee158 100644 --- a/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp @@ -209,7 +209,9 @@ DeadOilFluid::KernelWrapper:: computeDensities( real64 const pressure, PhaseProp::SliceType const & phaseMassDens ) const { - LvArray::forValuesInSlice( phaseMassDens.dComp, []( real64 & val ){ val = 0.0; } ); + using namespace multifluid; + + LvArray::forValuesInSlice( phaseMassDens.derivs, []( real64 & val ){ val = 0.0; } ); // 1. Hydrocarbon phases: look up in the formation vol factor tables @@ -224,7 +226,7 @@ DeadOilFluid::KernelWrapper:: // we are ready to update the densities real64 const fvfInv = 1.0 / fvf; phaseMassDens.value[ip] = m_surfacePhaseMassDensity[ip] * fvfInv; - phaseMassDens.dPres[ip] = -derivative * phaseMassDens.value[ip] * fvfInv; + phaseMassDens.derivs[ip][Deriv::dP] = -derivative * phaseMassDens.value[ip] * fvfInv; } // 2. Water phase: use the constant formation volume factor and compressibility provided by the user @@ -242,7 +244,7 @@ DeadOilFluid::KernelWrapper:: real64 const dDenom_dPres = m_waterParams.formationVolFactor * dExpCompDeltaPres_dPres; real64 const denomInv = 1.0 / denom; phaseMassDens.value[ipWater] = m_surfacePhaseMassDensity[ipWater] * denomInv; - phaseMassDens.dPres[ipWater] = -dDenom_dPres * phaseMassDens.value[ipWater] * denomInv; + phaseMassDens.derivs[ipWater][Deriv::dP] = -dDenom_dPres * phaseMassDens.value[ipWater] * denomInv; } } @@ -281,7 +283,9 @@ DeadOilFluid::KernelWrapper:: computeViscosities( real64 const pressure, PhaseProp::SliceType const & phaseVisc ) const { - LvArray::forValuesInSlice( phaseVisc.dComp, []( real64 & val ){ val = 0.0; } ); + using namespace multifluid; + + LvArray::forValuesInSlice( phaseVisc.derivs, []( real64 & val ){ val = 0.0; } ); // 1. Hydrocarbon phases: look up in the viscosity tables @@ -290,7 +294,7 @@ DeadOilFluid::KernelWrapper:: // get the phase index integer const ip = m_hydrocarbonPhaseOrder[iph]; // interpolate in the table to get the phase viscosity and derivatives - phaseVisc.value[ip] = m_viscosityTables[iph].compute( &pressure, &(phaseVisc.dPres)[ip] ); + phaseVisc.value[ip] = m_viscosityTables[iph].compute( &pressure, &(phaseVisc.derivs)[ip][Deriv::dP] ); } // 2. Water phase: use the constant viscosity provided by the user @@ -303,7 +307,7 @@ DeadOilFluid::KernelWrapper:: { // just assign the viscosity value phaseVisc.value[ipWater] = m_waterParams.viscosity; - phaseVisc.dPres[ipWater] = 0.0; + phaseVisc.derivs[ipWater][Deriv::dP] = 0.0; } } @@ -370,6 +374,8 @@ DeadOilFluid::KernelWrapper:: { GEOSX_UNUSED_VAR( temperature ); + using namespace multifluid; + integer const nComps = numComponents(); integer const nPhases = numPhases(); @@ -384,10 +390,10 @@ DeadOilFluid::KernelWrapper:: { real64 const mult = m_useMass ? 1.0 : 1.0 / m_componentMolarWeight[ip]; phaseDensity.value[ip] = phaseMassDensity.value[ip] * mult; - phaseDensity.dPres[ip] = phaseMassDensity.dPres[ip] * mult; + phaseDensity.derivs[ip][Deriv::dP] = phaseMassDensity.derivs[ip][Deriv::dP] * mult; for( integer ic = 0; ic < nComps; ++ic ) { - phaseDensity.dComp[ip][ic] = 0.0; + phaseDensity.derivs[ip][Deriv::dC+ic] = 0.0; } } @@ -395,16 +401,16 @@ DeadOilFluid::KernelWrapper:: for( integer ip = 0; ip < nPhases; ++ip ) { phaseFraction.value[ip] = composition[ip]; - phaseFraction.dPres[ip] = 0.0; + phaseFraction.derivs[ip][Deriv::dP] = 0.0; for( integer ic = 0; ic < nComps; ++ic ) { - phaseFraction.dComp[ip][ic] = (ip == ic) ? 1.0 : 0.0; + phaseFraction.derivs[ip][Deriv::dC+ic] = (ip == ic) ? 1.0 : 0.0; phaseCompFraction.value[ip][ic] = (ip == ic) ? 1.0 : 0.0; - phaseCompFraction.dPres[ip][ic] = 0.0; + phaseCompFraction.derivs[ip][ic][Deriv::dP] = 0.0; for( integer jc = 0; jc < nComps; ++jc ) { - phaseCompFraction.dComp[ip][ic][jc] = 0.0; + phaseCompFraction.derivs[ip][ic][Deriv::dC+jc] = 0.0; } } } diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index f32baa9fc9a..ef3975d0b1b 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -51,34 +51,22 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) setRestartFlags( RestartFlags::NO_WRITE ); registerExtrinsicData( extrinsicMeshData::multifluid::phaseFraction{}, &m_phaseFraction.value ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseFraction_dPressure{}, &m_phaseFraction.dPres ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseFraction_dTemperature{}, &m_phaseFraction.dTemp ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseFraction_dGlobalCompFraction{}, &m_phaseFraction.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseFraction{}, &m_phaseFraction.derivs ); registerExtrinsicData( extrinsicMeshData::multifluid::phaseDensity{}, &m_phaseDensity.value ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseDensity_dPressure{}, &m_phaseDensity.dPres ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseDensity_dTemperature{}, &m_phaseDensity.dTemp ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction{}, &m_phaseDensity.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseDensity{}, &m_phaseDensity.derivs ); registerExtrinsicData( extrinsicMeshData::multifluid::phaseMassDensity{}, &m_phaseMassDensity.value ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseMassDensity_dPressure{}, &m_phaseMassDensity.dPres ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseMassDensity_dTemperature{}, &m_phaseMassDensity.dTemp ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseMassDensity_dGlobalCompFraction{}, &m_phaseMassDensity.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseMassDensity{}, &m_phaseMassDensity.derivs ); registerExtrinsicData( extrinsicMeshData::multifluid::phaseViscosity{}, &m_phaseViscosity.value ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity_dPressure{}, &m_phaseViscosity.dPres ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity_dTemperature{}, &m_phaseViscosity.dTemp ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity_dGlobalCompFraction{}, &m_phaseViscosity.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseViscosity{}, &m_phaseViscosity.derivs ); registerExtrinsicData( extrinsicMeshData::multifluid::phaseCompFraction{}, &m_phaseCompFraction.value ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure{}, &m_phaseCompFraction.dPres ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction_dTemperature{}, &m_phaseCompFraction.dTemp ); - registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction{}, &m_phaseCompFraction.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseCompFraction{}, &m_phaseCompFraction.derivs ); registerExtrinsicData( extrinsicMeshData::multifluid::totalDensity{}, &m_totalDensity.value ); - registerExtrinsicData( extrinsicMeshData::multifluid::dTotalDensity_dPressure{}, &m_totalDensity.dPres ); - registerExtrinsicData( extrinsicMeshData::multifluid::dTotalDensity_dTemperature{}, &m_totalDensity.dTemp ); - registerExtrinsicData( extrinsicMeshData::multifluid::dTotalDensity_dGlobalCompFraction{}, &m_totalDensity.dComp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dTotalDensity{}, &m_totalDensity.derivs ); registerExtrinsicData( extrinsicMeshData::multifluid::initialTotalMassDensity{}, &m_initialTotalMassDensity ); @@ -88,36 +76,25 @@ void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPt { integer const numPhase = numFluidPhases(); integer const numComp = numFluidComponents(); + integer const numDeriv = numComp + 2; m_phaseFraction.value.resize( size, numPts, numPhase ); - m_phaseFraction.dPres.resize( size, numPts, numPhase ); - m_phaseFraction.dTemp.resize( size, numPts, numPhase ); - m_phaseFraction.dComp.resize( size, numPts, numPhase, numComp ); + m_phaseFraction.derivs.resize( size, numPts, numPhase, numDeriv ); m_phaseDensity.value.resize( size, numPts, numPhase ); - m_phaseDensity.dPres.resize( size, numPts, numPhase ); - m_phaseDensity.dTemp.resize( size, numPts, numPhase ); - m_phaseDensity.dComp.resize( size, numPts, numPhase, numComp ); + m_phaseDensity.derivs.resize( size, numPts, numPhase, numDeriv ); m_phaseMassDensity.value.resize( size, numPts, numPhase ); - m_phaseMassDensity.dPres.resize( size, numPts, numPhase ); - m_phaseMassDensity.dTemp.resize( size, numPts, numPhase ); - m_phaseMassDensity.dComp.resize( size, numPts, numPhase, numComp ); + m_phaseMassDensity.derivs.resize( size, numPts, numPhase, numDeriv ); m_phaseViscosity.value.resize( size, numPts, numPhase ); - m_phaseViscosity.dPres.resize( size, numPts, numPhase ); - m_phaseViscosity.dTemp.resize( size, numPts, numPhase ); - m_phaseViscosity.dComp.resize( size, numPts, numPhase, numComp ); + m_phaseViscosity.derivs.resize( size, numPts, numPhase, numDeriv ); m_phaseCompFraction.value.resize( size, numPts, numPhase, numComp ); - m_phaseCompFraction.dPres.resize( size, numPts, numPhase, numComp ); - m_phaseCompFraction.dTemp.resize( size, numPts, numPhase, numComp ); - m_phaseCompFraction.dComp.resize( size, numPts, numPhase, numComp, numComp ); + m_phaseCompFraction.derivs.resize( size, numPts, numPhase, numComp, numDeriv ); m_totalDensity.value.resize( size, numPts ); - m_totalDensity.dPres.resize( size, numPts ); - m_totalDensity.dTemp.resize( size, numPts ); - m_totalDensity.dComp.resize( size, numPts, numComp ); + m_totalDensity.derivs.resize( size, numPts, numDeriv ); m_initialTotalMassDensity.resize( size, numPts ); } diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 0a74668b182..850d6585d56 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -107,74 +107,38 @@ class MultiFluidBase : public ConstitutiveBase arrayView3d< real64 const, multifluid::USD_PHASE > phaseFraction() const { return m_phaseFraction.value; } - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseFraction_dPressure() const - { return m_phaseFraction.dPres; } - - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseFraction_dTemperature() const - { return m_phaseFraction.dTemp; } - - arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseFraction_dGlobalCompFraction() const - { return m_phaseFraction.dComp; } + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseFraction() const + { return m_phaseFraction.derivs; } arrayView3d< real64 const, multifluid::USD_PHASE > phaseDensity() const { return m_phaseDensity.value; } - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseDensity_dPressure() const - { return m_phaseDensity.dPres; } - - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseDensity_dTemperature() const - { return m_phaseDensity.dTemp; } - - arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseDensity_dGlobalCompFraction() const - { return m_phaseDensity.dComp; } + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseDensity() const + { return m_phaseDensity.derivs; } arrayView3d< real64 const, multifluid::USD_PHASE > phaseMassDensity() const { return m_phaseMassDensity.value; } - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseMassDensity_dPressure() const - { return m_phaseMassDensity.dPres; } - - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseMassDensity_dTemperature() const - { return m_phaseMassDensity.dTemp; } - - arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseMassDensity_dGlobalCompFraction() const - { return m_phaseMassDensity.dComp; } + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseMassDensity() const + { return m_phaseMassDensity.derivs; } arrayView3d< real64 const, multifluid::USD_PHASE > phaseViscosity() const { return m_phaseViscosity.value; } - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseViscosity_dPressure() const - { return m_phaseViscosity.dPres; } - - arrayView3d< real64 const, multifluid::USD_PHASE > dPhaseViscosity_dTemperature() const - { return m_phaseViscosity.dTemp; } - - arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseViscosity_dGlobalCompFraction() const - { return m_phaseViscosity.dComp; } + arrayView4d< real64 const, multifluid::USD_PHASE_DC > dPhaseViscosity() const + { return m_phaseViscosity.derivs; } arrayView4d< real64 const, multifluid::USD_PHASE_COMP > phaseCompFraction() const { return m_phaseCompFraction.value; } - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > dPhaseCompFraction_dPressure() const - { return m_phaseCompFraction.dPres; } - - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > dPhaseCompFraction_dTemperature() const - { return m_phaseCompFraction.dTemp; } - - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > dPhaseCompFraction_dGlobalCompFraction() const - { return m_phaseCompFraction.dComp; } + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > dPhaseCompFraction() const + { return m_phaseCompFraction.derivs; } arrayView2d< real64 const, multifluid::USD_FLUID > totalDensity() const { return m_totalDensity.value; } - arrayView2d< real64 const, multifluid::USD_FLUID > dTotalDensity_dPressure() const - { return m_totalDensity.dPres; } - - arrayView2d< real64 const, multifluid::USD_FLUID > dTotalDensity_dTemperature() const - { return m_totalDensity.dTemp; } - - arrayView3d< real64 const, multifluid::USD_FLUID_DC > dTotalDensity_dGlobalCompFraction() const - { return m_totalDensity.dComp; } + arrayView3d< real64 const, multifluid::USD_FLUID_DC > dTotalDensity() const + { return m_totalDensity.derivs; } arrayView2d< real64 const, multifluid::USD_FLUID > initialTotalMassDensity() const { return m_initialTotalMassDensity.toViewConst(); } @@ -314,13 +278,11 @@ class MultiFluidBase : public ConstitutiveBase * @tparam maxNumPhase the max number of phases * @param[in] dCompMoleFrac_dCompMassFrac the derivatives of mole fractions wrt mass fractions * @param[in] phaseMolecularWeight the phase molecular weight computed by the constitutive model - * @param[in] dPhaseMolecularWeight_dPres the derivatives of phase molecular weights wrt pressure - * @param[in] dPhaseMolecularWeight_dTemp the derivatives of phase molecular weights wrt temperature - * @param[in] dPhaseMolecularWeight_dGlobalCompFrac the derivatives of phase molecular weights wrt comp fractions + * @param[in] dPhaseMolecularWeight the derivatives of phase molecular weights wrt pressure, temperature, and comp fractions * @param[inout] phaseFrac the phase fractions in moles that will be converted to mass * @param[inout] phaseCompFrac the phase component fractions in moles that will be converted to mass - * @param[inout] dPhaseDens_dGlobalCompFrac the derivatives of phase densities wrt comp fractions - * @param[inout] dPhaseVisc_dGlobalCompFrac the derivatives of phase viscosities wrt comp fractions + * @param[inout] dPhaseDens the derivatives of phase densities wrt pressure, temperature, and comp fractions + * @param[inout] dPhaseVisc the derivatives of phase viscosities wrt pressure, temperature, and comp fractions * @detail This function performs three conversions * 1) Conversion of phase mass fractions into phase mole fractions * 2) Conversion of phase component mass fractions into phase component mole fractions @@ -330,13 +292,11 @@ class MultiFluidBase : public ConstitutiveBase GEOSX_HOST_DEVICE void convertToMassFractions( real64 const (&dCompMoleFrac_dCompMassFrac)[maxNumComp][maxNumComp], real64 const (&phaseMolecularWeight)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dPres)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dTemp)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dGlobalCompFrac)[maxNumPhase][maxNumComp], + real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumComp+2], PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens_dGlobalCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc_dGlobalCompFrac ) const; + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const; /** * @brief Utility function to convert mole fractions to mass fractions @@ -382,38 +342,30 @@ class MultiFluidBase : public ConstitutiveBase /** * @brief Utility function to convert phase mole fractions to phase mass fractions and keep derivatives - * @tparam maxNumComp the max number of components + * @tparam maxNumDof the max number of dofs * @tparam maxNumPhase the max number of phases * @param[in] phaseMolecularWeight the phase molecular weight computed by the constitutive model - * @param[in] dPhaseMolecularWeight_dPres the derivatives of phase molecular weights wrt pressure - * @param[in] dPhaseMolecularWeight_dTemp the derivatives of phase molecular weights wrt temperature - * @param[in] dPhaseMolecularWeight_dGlobalCompFrac the derivatives of phase molecular weights wrt comp fractions + * @param[in] dPhaseMolecularWeight the derivatives of phase molecular weights wrt pressure, temperature, and comp fractions * @param[inout] phaseFrac the phase fractions in moles that will be converted to mass */ - template< integer maxNumComp, integer maxNumPhase > + template< integer maxNumDof, integer maxNumPhase > GEOSX_HOST_DEVICE void convertToPhaseMassFractions( real64 const (&phaseMolecularWeight)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dPres)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dTemp)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dGlobalCompFrac)[maxNumPhase][maxNumComp], + real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumDof], PhaseProp::SliceType const phaseFrac ) const; /** * @brief Utility function to convert phase component mole fractions to phase component mass fractions and keep derivatives - * @tparam maxNumComp the max number of components + * @tparam maxNumDof the max number of dofs * @tparam maxNumPhase the max number of phases * @param[in] phaseMolecularWeight the phase molecular weight computed by the constitutive model - * @param[in] dPhaseMolecularWeight_dPres the derivatives of phase molecular weights wrt pressure - * @param[in] dPhaseMolecularWeight_dTemp the derivatives of phase molecular weights wrt temperature - * @param[in] dPhaseMolecularWeight_dGlobalCompFrac the derivatives of phase molecular weights wrt comp fractions + * @param[in] dPhaseMolecularWeight the derivatives of phase molecular weights wrt pressure, temperature, and comp fractions * @param[inout] phaseCompFrac the phase component fractions in moles that will be converted to mass */ - template< integer maxNumComp, integer maxNumPhase > + template< integer maxNumDof, integer maxNumPhase > GEOSX_HOST_DEVICE void convertToPhaseCompMassFractions( real64 const (&phaseMolecularWeight)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dPres)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dTemp)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dGlobalCompFrac)[maxNumPhase][maxNumComp], + real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumDof], PhaseComp::SliceType const phaseCompFrac ) const; /** @@ -422,16 +374,16 @@ class MultiFluidBase : public ConstitutiveBase * @param[in] dCompMoleFrac_dCompMassFrac the derivatives of mole fractions wrt mass fractions * @param[inout] phaseFrac the phase fractions in the cell * @param[inout] phaseCompFrac the phase component fractions in the cell - * @param[inout] dPhaseDens_dGlobalCompFrac the derivatives of phase densities wrt comp fractions - * @param[inout] dPhaseVisc_dGlobalCompFrac the derivatives of phase viscosities wrt comp fractions + * @param[inout] dPhaseDens the derivatives of phase densities wrt pressure, temperature, and comp fractions + * @param[inout] dPhaseVisc the derivatives of phase viscosities wrt pressure, temperature, and comp fractions */ template< integer maxNumComp > GEOSX_HOST_DEVICE void computeDerivativesWrtMassFractions( real64 const (&dCompMoleFrac_dCompMassFrac)[maxNumComp][maxNumComp], PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens_dGlobalCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc_dGlobalCompFrac ) const; + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const; /** @@ -594,34 +546,27 @@ MultiFluidBase::KernelWrapper:: { using namespace multifluid; + integer constexpr maxNumDof = maxNumComp + 2; integer const numPhase = numPhases(); integer const numComp = numComponents(); real64 dCompMoleFrac_dCompMassFrac[maxNumComp][maxNumComp]{}; - real64 dPhaseMolecularWeight_dPres[maxNumPhase]{}; - real64 dPhaseMolecularWeight_dTemp[maxNumPhase]{}; - real64 dPhaseMolecularWeight_dComp[maxNumPhase][maxNumComp]{}; + real64 dPhaseMolecularWeight[maxNumPhase][maxNumDof]{}; - StackArray< real64, 3, maxNumPhase, LAYOUT_PHASE > dPhaseFrac_dPres( 1, 1, numPhase ); - StackArray< real64, 3, maxNumPhase, LAYOUT_PHASE > dPhaseFrac_dTemp( 1, 1, numPhase ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseFrac_dComp( 1, 1, numPhase, numComp ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseFrac( 1, 1, numPhase, numComp+2 ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseFracAndDeriv { phaseFrac, dPhaseFrac_dPres[0][0], dPhaseFrac_dTemp[0][0], dPhaseFrac_dComp[0][0] }; + phaseFracAndDeriv { phaseFrac, dPhaseFrac[0][0] }; - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_COMP > dPhaseCompFrac_dPres( 1, 1, numPhase, numComp ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_COMP > dPhaseCompFrac_dTemp( 1, 1, numPhase, numComp ); - StackArray< real64, 5, maxNumComp *maxNumComp *maxNumPhase, LAYOUT_PHASE_COMP_DC > dPhaseCompFrac_dComp( 1, 1, numPhase, numComp, numComp ); + StackArray< real64, 5, maxNumDof *maxNumComp *maxNumPhase, LAYOUT_PHASE_COMP_DC > dPhaseCompFrac( 1, 1, numPhase, numComp, numComp+2 ); MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > - phaseCompFracAndDeriv { phaseCompFrac, dPhaseCompFrac_dPres[0][0], dPhaseCompFrac_dTemp[0][0], dPhaseCompFrac_dComp[0][0] }; + phaseCompFracAndDeriv { phaseCompFrac, dPhaseCompFrac[0][0] }; StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseDens_dComp( 1, 1, numPhase, numComp ); StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseVisc_dComp( 1, 1, numPhase, numComp ); convertToMassFractions( dCompMoleFrac_dCompMassFrac, phaseMolecularWeight, - dPhaseMolecularWeight_dPres, - dPhaseMolecularWeight_dTemp, - dPhaseMolecularWeight_dComp, + dPhaseMolecularWeight, phaseFracAndDeriv, phaseCompFracAndDeriv, dPhaseDens_dComp[0][0], @@ -634,50 +579,42 @@ void MultiFluidBase::KernelWrapper:: convertToMassFractions( real64 const (&dCompMoleFrac_dCompMassFrac)[maxNumComp][maxNumComp], real64 const (&phaseMolecularWeight)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dPres)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dTemp)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dGlobalCompFrac)[maxNumPhase][maxNumComp], + real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumComp+2], PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens_dGlobalCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc_dGlobalCompFrac ) const + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const { convertToPhaseMassFractions( phaseMolecularWeight, - dPhaseMolecularWeight_dPres, - dPhaseMolecularWeight_dTemp, - dPhaseMolecularWeight_dGlobalCompFrac, + dPhaseMolecularWeight, phaseFrac ); convertToPhaseCompMassFractions( phaseMolecularWeight, - dPhaseMolecularWeight_dPres, - dPhaseMolecularWeight_dTemp, - dPhaseMolecularWeight_dGlobalCompFrac, + dPhaseMolecularWeight, phaseCompFrac ); computeDerivativesWrtMassFractions( dCompMoleFrac_dCompMassFrac, phaseFrac, phaseCompFrac, - dPhaseDens_dGlobalCompFrac, - dPhaseVisc_dGlobalCompFrac ); + dPhaseDens, + dPhaseVisc ); } -template< integer maxNumComp, integer maxNumPhase > +template< integer maxNumDof, integer maxNumPhase > GEOSX_HOST_DEVICE void MultiFluidBase::KernelWrapper:: convertToPhaseMassFractions( real64 const (&phaseMolecularWeight)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dPres)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dTemp)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dGlobalCompFrac)[maxNumPhase][maxNumComp], + real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumDof], PhaseProp::SliceType const phaseFrac ) const { + using namespace multifluid; + integer const numPhase = numPhases(); integer const numComp = numComponents(); real64 totalMass{}; - real64 dTotalMass_dP{}; - real64 dTotalMass_dT{}; - real64 dTotalMass_dC[maxNumComp]{}; + real64 dTotalMass[maxNumDof]{}; // 1. Compute mass of each phase and total mass (on a 1-mole basis) for( integer ip = 0; ip < numPhase; ++ip ) @@ -686,18 +623,18 @@ MultiFluidBase::KernelWrapper:: real64 const nu = phaseFrac.value[ip]; phaseFrac.value[ip] *= phaseMolecularWeight[ip]; - phaseFrac.dPres[ip] = phaseFrac.dPres[ip] * phaseMolecularWeight[ip] + nu * dPhaseMolecularWeight_dPres[ip]; - phaseFrac.dTemp[ip] = phaseFrac.dTemp[ip] * phaseMolecularWeight[ip] + nu * dPhaseMolecularWeight_dTemp[ip]; + phaseFrac.derivs[ip][Deriv::dP] = phaseFrac.derivs[ip][Deriv::dP] * phaseMolecularWeight[ip] + nu * dPhaseMolecularWeight[ip][Deriv::dP]; + phaseFrac.derivs[ip][Deriv::dT] = phaseFrac.derivs[ip][Deriv::dT] * phaseMolecularWeight[ip] + nu * dPhaseMolecularWeight[ip][Deriv::dT]; totalMass += phaseFrac.value[ip]; - dTotalMass_dP += phaseFrac.dPres[ip]; - dTotalMass_dT += phaseFrac.dTemp[ip]; + dTotalMass[Deriv::dP] += phaseFrac.derivs[ip][Deriv::dP]; + dTotalMass[Deriv::dT] += phaseFrac.derivs[ip][Deriv::dT]; for( integer jc = 0; jc < numComp; ++jc ) { - phaseFrac.dComp[ip][jc] = - phaseFrac.dComp[ip][jc] * phaseMolecularWeight[ip] + nu * dPhaseMolecularWeight_dGlobalCompFrac[ip][jc]; - dTotalMass_dC[jc] += phaseFrac.dComp[ip][jc]; + phaseFrac.derivs[ip][Deriv::dC+jc] = + phaseFrac.derivs[ip][Deriv::dC+jc] * phaseMolecularWeight[ip] + nu * dPhaseMolecularWeight[ip][Deriv::dC+jc]; + dTotalMass[Deriv::dC+jc] += phaseFrac.derivs[ip][Deriv::dC+jc]; } } @@ -706,26 +643,26 @@ MultiFluidBase::KernelWrapper:: for( integer ip = 0; ip < numPhase; ++ip ) { phaseFrac.value[ip] *= totalMassInv; - phaseFrac.dPres[ip] = ( phaseFrac.dPres[ip] - phaseFrac.value[ip] * dTotalMass_dP ) * totalMassInv; - phaseFrac.dTemp[ip] = ( phaseFrac.dTemp[ip] - phaseFrac.value[ip] * dTotalMass_dT ) * totalMassInv; + phaseFrac.derivs[ip][Deriv::dP] = ( phaseFrac.derivs[ip][Deriv::dP] - phaseFrac.value[ip] * dTotalMass[Deriv::dP] ) * totalMassInv; + phaseFrac.derivs[ip][Deriv::dT] = ( phaseFrac.derivs[ip][Deriv::dT] - phaseFrac.value[ip] * dTotalMass[Deriv::dT] ) * totalMassInv; for( integer jc = 0; jc < numComp; ++jc ) { - phaseFrac.dComp[ip][jc] = ( phaseFrac.dComp[ip][jc] - phaseFrac.value[ip] * dTotalMass_dC[jc] ) * totalMassInv; + phaseFrac.derivs[ip][Deriv::dC+jc] = ( phaseFrac.derivs[ip][Deriv::dC+jc] - phaseFrac.value[ip] * dTotalMass[Deriv::dC+jc] ) * totalMassInv; } } } -template< integer maxNumComp, integer maxNumPhase > +template< integer maxNumDof, integer maxNumPhase > GEOSX_HOST_DEVICE void MultiFluidBase::KernelWrapper:: convertToPhaseCompMassFractions( real64 const (&phaseMolecularWeight)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dPres)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dTemp)[maxNumPhase], - real64 const (&dPhaseMolecularWeight_dGlobalCompFrac)[maxNumPhase][maxNumComp], + real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumDof], PhaseComp::SliceType const phaseCompFrac ) const { + using namespace multifluid; + integer const numPhase = numPhases(); integer const numComp = numComponents(); @@ -738,16 +675,16 @@ MultiFluidBase::KernelWrapper:: real64 const compMW = m_componentMolarWeight[ic]; phaseCompFrac.value[ip][ic] = phaseCompFrac.value[ip][ic] * compMW * phaseMolecularWeightInv; - phaseCompFrac.dPres[ip][ic] = - ( phaseCompFrac.dPres[ip][ic] * compMW - phaseCompFrac.value[ip][ic] * dPhaseMolecularWeight_dPres[ip] ) * phaseMolecularWeightInv; - phaseCompFrac.dTemp[ip][ic] = - ( phaseCompFrac.dTemp[ip][ic] * compMW - phaseCompFrac.value[ip][ic] * dPhaseMolecularWeight_dTemp[ip] ) * phaseMolecularWeightInv; + phaseCompFrac.derivs[ip][ic][Deriv::dP] = + ( phaseCompFrac.derivs[ip][ic][Deriv::dP] * compMW - phaseCompFrac.value[ip][ic] * dPhaseMolecularWeight[ip][Deriv::dP] ) * phaseMolecularWeightInv; + phaseCompFrac.derivs[ip][ic][Deriv::dT] = + ( phaseCompFrac.derivs[ip][ic][Deriv::dT] * compMW - phaseCompFrac.value[ip][ic] * dPhaseMolecularWeight[ip][Deriv::dT] ) * phaseMolecularWeightInv; for( integer jc = 0; jc < numComp; ++jc ) { - phaseCompFrac.dComp[ip][ic][jc] = + phaseCompFrac.derivs[ip][ic][Deriv::dC+jc] = phaseMolecularWeightInv * - ( phaseCompFrac.dComp[ip][ic][jc] * compMW - phaseCompFrac.value[ip][ic] * dPhaseMolecularWeight_dGlobalCompFrac[ip][jc] ); + ( phaseCompFrac.derivs[ip][ic][Deriv::dC+jc] * compMW - phaseCompFrac.value[ip][ic] * dPhaseMolecularWeight[ip][Deriv::dC+jc] ); } } } @@ -760,21 +697,23 @@ MultiFluidBase::KernelWrapper:: computeDerivativesWrtMassFractions( real64 const (&dCompMoleFrac_dCompMassFrac)[maxNumComp][maxNumComp], PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens_dGlobalCompFrac, - arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc_dGlobalCompFrac ) const + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, + arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const { + using namespace multifluid; + integer const numPhase = numPhases(); integer const numComp = numComponents(); real64 work[maxNumComp]{}; for( integer ip = 0; ip < numPhase; ++ip ) { - applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, phaseFrac.dComp[ip], work ); - applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseDens_dGlobalCompFrac[ip], work ); - applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseVisc_dGlobalCompFrac[ip], work ); + applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, phaseFrac.derivs[ip], work, Deriv::dC ); + applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseDens[ip], work, Deriv::dC ); + applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, dPhaseVisc[ip], work, Deriv::dC ); for( integer ic = 0; ic < numComp; ++ic ) { - applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, phaseCompFrac.dComp[ip][ic], work ); + applyChainRuleInPlace( numComp, dCompMoleFrac_dCompMassFrac, phaseCompFrac.derivs[ip][ic], work, Deriv::dC ); } } } @@ -789,26 +728,21 @@ MultiFluidBase::KernelWrapper:: { using namespace multifluid; + integer constexpr maxNumDof = maxNumComp + 2; integer const numPhase = numPhases(); integer const numComp = numComponents(); - StackArray< real64, 2, 1, LAYOUT_FLUID > dTotalDens_dPres( 1, 1 ); - StackArray< real64, 2, 1, LAYOUT_FLUID > dTotalDens_dTemp( 1, 1 ); - StackArray< real64, 3, maxNumComp, LAYOUT_FLUID_DC > dTotalDens_dComp( 1, 1, numComp ); + StackArray< real64, 3, maxNumDof, LAYOUT_FLUID_DC > dTotalDens( 1, 1, numComp+2 ); MultiFluidVarSlice< real64, 0, USD_FLUID - 2, USD_FLUID_DC - 2 > - totalDensAndDeriv { totalDens, dTotalDens_dPres[0][0], dTotalDens_dTemp[0][0], dTotalDens_dComp[0][0] }; + totalDensAndDeriv { totalDens, dTotalDens[0][0] }; - StackArray< real64, 3, maxNumPhase, LAYOUT_PHASE > dPhaseFrac_dPres( 1, 1, numPhase ); - StackArray< real64, 3, maxNumPhase, LAYOUT_PHASE > dPhaseFrac_dTemp( 1, 1, numPhase ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseFrac_dComp( 1, 1, numPhase, numComp ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseFrac( 1, 1, numPhase, numComp+2 ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseFracAndDeriv { phaseFrac, dPhaseFrac_dPres[0][0], dPhaseFrac_dTemp[0][0], dPhaseFrac_dComp[0][0] }; + phaseFracAndDeriv { phaseFrac, dPhaseFrac[0][0] }; - StackArray< real64, 3, maxNumPhase, LAYOUT_PHASE > dPhaseDens_dPres( 1, 1, numPhase ); - StackArray< real64, 3, maxNumPhase, LAYOUT_PHASE > dPhaseDens_dTemp( 1, 1, numPhase ); - StackArray< real64, 4, maxNumComp *maxNumPhase, LAYOUT_PHASE_DC > dPhaseDens_dComp( 1, 1, numPhase, numComp ); + StackArray< real64, 4, maxNumDof *maxNumPhase, LAYOUT_PHASE_DC > dPhaseDens( 1, 1, numPhase, numComp+2 ); MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > - phaseDensAndDeriv { phaseDens, dPhaseDens_dPres[0][0], dPhaseDens_dTemp[0][0], dPhaseDens_dComp[0][0] }; + phaseDensAndDeriv { phaseDens, dPhaseDens[0][0] }; computeTotalDensity( phaseFracAndDeriv, phaseDensAndDeriv, @@ -822,12 +756,13 @@ MultiFluidBase::KernelWrapper:: PhaseProp::SliceType const phaseDensity, FluidProp::SliceType const totalDensity ) const { + using namespace multifluid; + integer const numComp = numComponents(); integer const numPhase = numPhases(); totalDensity.value = 0.0; - totalDensity.dPres = 0.0; - LvArray::forValuesInSlice( totalDensity.dComp, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( totalDensity.derivs, []( real64 & val ){ val = 0.0; } ); // 1. Sum mass/molar fraction/density ratio over all phases to get the inverse of density for( integer ip = 0; ip < numPhase; ++ip ) @@ -842,20 +777,22 @@ MultiFluidBase::KernelWrapper:: real64 const value = phaseFraction.value[ip] * densInv; totalDensity.value += value; - totalDensity.dPres += ( phaseFraction.dPres[ip] - value * phaseDensity.dPres[ip] ) * densInv; + totalDensity.derivs[Deriv::dP] += ( phaseFraction.derivs[ip][Deriv::dP] - value * phaseDensity.derivs[ip][Deriv::dP] ) * densInv; + totalDensity.derivs[Deriv::dT] += ( phaseFraction.derivs[ip][Deriv::dT] - value * phaseDensity.derivs[ip][Deriv::dT] ) * densInv; for( integer ic = 0; ic < numComp; ++ic ) { - totalDensity.dComp[ic] += ( phaseFraction.dComp[ip][ic] - value * phaseDensity.dComp[ip][ic] ) * densInv; + totalDensity.derivs[Deriv::dC+ic] += ( phaseFraction.derivs[ip][Deriv::dC+ic] - value * phaseDensity.derivs[ip][Deriv::dC+ic] ) * densInv; } } // 2. Invert the previous quantity to get actual density totalDensity.value = 1.0 / totalDensity.value; real64 const minusDens2 = -totalDensity.value * totalDensity.value; - totalDensity.dPres *= minusDens2; + totalDensity.derivs[Deriv::dP] *= minusDens2; + totalDensity.derivs[Deriv::dT] *= minusDens2; for( integer ic = 0; ic < numComp; ++ic ) { - totalDensity.dComp[ic] *= minusDens2; + totalDensity.derivs[Deriv::dC+ic] *= minusDens2; } } diff --git a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp index 6bed4970a96..f032ac20e8b 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp @@ -46,29 +46,13 @@ EXTRINSIC_MESH_DATA_TRAIT( phaseFraction, WRITE_AND_READ, "Phase fraction" ); -EXTRINSIC_MESH_DATA_TRAIT( dPhaseFraction_dPressure, - "dPhaseFraction_dPressure", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase fraction with respect to pressure" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseFraction_dTemperature, - "dPhaseFraction_dTemperature", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase fraction with respect to temperature" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseFraction_dGlobalCompFraction, - "dPhaseFraction_dGlobalCompFraction", +EXTRINSIC_MESH_DATA_TRAIT( dPhaseFraction, + "dPhaseFraction", array4dLayoutPhase_dC, 0, NOPLOT, NO_WRITE, - "Derivative of phase fraction with respect to global component fraction" ); + "Derivative of phase fraction with respect to pressure, temperature, and global component fractions" ); EXTRINSIC_MESH_DATA_TRAIT( phaseDensity, "phaseDensity", @@ -78,29 +62,13 @@ EXTRINSIC_MESH_DATA_TRAIT( phaseDensity, WRITE_AND_READ, "Phase density" ); -EXTRINSIC_MESH_DATA_TRAIT( dPhaseDensity_dPressure, - "dPhaseDensity_dPressure", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase density with respect to pressure" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseDensity_dTemperature, - "dPhaseDensity_dTemperature", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase density with respect to temperature" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseDensity_dGlobalCompFraction, - "dPhaseDensity_dGlobalCompFraction", +EXTRINSIC_MESH_DATA_TRAIT( dPhaseDensity, + "dPhaseDensity", array4dLayoutPhase_dC, 0, NOPLOT, NO_WRITE, - "Derivative of phase density with respect to global component fraction" ); + "Derivative of phase density with respect to pressure, temperature, and global component fractions" ); EXTRINSIC_MESH_DATA_TRAIT( phaseMassDensity, "phaseMassDensity", @@ -110,29 +78,13 @@ EXTRINSIC_MESH_DATA_TRAIT( phaseMassDensity, WRITE_AND_READ, "Phase mass density" ); -EXTRINSIC_MESH_DATA_TRAIT( dPhaseMassDensity_dPressure, - "dPhaseMassDensity_dPressure", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase mass density with respect to pressure" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseMassDensity_dTemperature, - "dPhaseMassDensity_dTemperature", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase mass density with respect to temperature" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseMassDensity_dGlobalCompFraction, - "dPhaseMassDensity_dGlobalCompFraction", +EXTRINSIC_MESH_DATA_TRAIT( dPhaseMassDensity, + "dPhaseMassDensity", array4dLayoutPhase_dC, 0, NOPLOT, NO_WRITE, - "Derivative of phase mass density with respect to global component fraction" ); + "Derivative of phase mass density with respect to pressure, temperature, and global component fractions" ); EXTRINSIC_MESH_DATA_TRAIT( phaseViscosity, "phaseViscosity", @@ -142,29 +94,13 @@ EXTRINSIC_MESH_DATA_TRAIT( phaseViscosity, WRITE_AND_READ, "Phase viscosity" ); -EXTRINSIC_MESH_DATA_TRAIT( dPhaseViscosity_dPressure, - "dPhaseViscosity_dPressure", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase viscosity with respect to pressure" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseViscosity_dTemperature, - "dPhaseViscosity_dTemperature", - array3dLayoutPhase, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase viscosity with respect to temperature" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseViscosity_dGlobalCompFraction, - "dPhaseViscosity_dGlobalCompFraction", +EXTRINSIC_MESH_DATA_TRAIT( dPhaseViscosity, + "dPhaseViscosity", array4dLayoutPhase_dC, 0, NOPLOT, NO_WRITE, - "Derivative of phase viscosity with respect to global component fraction" ); + "Derivative of phase viscosity with respect to pressure, temperature, and global component fractions" ); EXTRINSIC_MESH_DATA_TRAIT( phaseCompFraction, "phaseCompFraction", @@ -174,29 +110,13 @@ EXTRINSIC_MESH_DATA_TRAIT( phaseCompFraction, WRITE_AND_READ, "Phase component fraction" ); -EXTRINSIC_MESH_DATA_TRAIT( dPhaseCompFraction_dPressure, - "dPhaseCompFraction_dPressure", - array4dLayoutPhaseComp, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase component fraction with respect to pressure" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseCompFraction_dTemperature, - "dPhaseCompFraction_dTemperature", - array4dLayoutPhaseComp, - 0, - NOPLOT, - NO_WRITE, - "Derivative of phase component fraction with respect to temperature" ); - -EXTRINSIC_MESH_DATA_TRAIT( dPhaseCompFraction_dGlobalCompFraction, - "dPhaseCompFraction_dGlobalCompFraction", +EXTRINSIC_MESH_DATA_TRAIT( dPhaseCompFraction, + "dPhaseCompFraction", array5dLayoutPhaseComp_dC, 0, NOPLOT, NO_WRITE, - "Derivative of phase component fraction with respect to global component fraction" ); + "Derivative of phase component fraction with respect to pressure, temperature, and global component fractions" ); EXTRINSIC_MESH_DATA_TRAIT( totalDensity, "totalDensity", @@ -214,29 +134,13 @@ EXTRINSIC_MESH_DATA_TRAIT( initialTotalMassDensity, WRITE_AND_READ, "Initial total mass density" ); -EXTRINSIC_MESH_DATA_TRAIT( dTotalDensity_dPressure, - "dTotalDensity_dPressure", - array2dLayoutFluid, - 0, - NOPLOT, - NO_WRITE, - "Derivative of total density with respect to pressure" ); - -EXTRINSIC_MESH_DATA_TRAIT( dTotalDensity_dTemperature, - "dTotalDensity_dTemperature", - array2dLayoutFluid, - 0, - NOPLOT, - NO_WRITE, - "Derivative of total density with respect to temperature" ); - -EXTRINSIC_MESH_DATA_TRAIT( dTotalDensity_dGlobalCompFraction, - "dTotalDensity_dGlobalCompFraction", +EXTRINSIC_MESH_DATA_TRAIT( dTotalDensity, + "dTotalDensity", array3dLayoutFluid_dC, 0, NOPLOT, NO_WRITE, - "Derivative of total density with respect to global component fraction" ); + "Derivative of total density with respect to pressure, temperature, and global component fractions" ); } diff --git a/src/coreComponents/constitutive/fluid/MultiFluidUtils.hpp b/src/coreComponents/constitutive/fluid/MultiFluidUtils.hpp index 7afb3277b37..ef5f2d0601d 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidUtils.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidUtils.hpp @@ -55,47 +55,41 @@ template< typename T, int DIM, int USD, int USD_DC > struct MultiFluidVarSlice { internal::ArraySliceOrRef< T, DIM, USD > value; /// variable value - internal::ArraySliceOrRef< T, DIM, USD > dPres; /// derivative w.r.t. pressure - internal::ArraySliceOrRef< T, DIM, USD > dTemp; /// derivative w.r.t. temperature - internal::ArraySliceOrRef< T, DIM + 1, USD_DC > dComp; /// derivative w.r.t. composition + internal::ArraySliceOrRef< T, DIM + 1, USD_DC > derivs; /// derivative w.r.t. pressure, temperature, compositions }; /** * @brief Struct holding views into fluid data, used to simplify parameter passing in kernel wrapper constructors. * @tparam NDIM number of dimensions - * @tparam USD unit-stride-dim of primary property and derivatives - * @tparam USD_DC unit-stride-dim of compositional derivatives + * @tparam USD unit-stride-dim of primary property + * @tparam USD_DC unit-stride-dim of derivatives */ template< typename T, int NDIM, int USD, int USD_DC > struct MultiFluidVarView { ArrayView< T, NDIM, USD > value; ///< View into property values - ArrayView< T, NDIM, USD > dPres; ///< View into property pressure derivatives - ArrayView< T, NDIM, USD > dTemp; ///< View into property temperature derivatives - ArrayView< T, NDIM + 1, USD_DC > dComp; ///< View into property compositional derivatives + ArrayView< T, NDIM + 1, USD_DC > derivs; ///< View into property derivatives w.r.t. pressure, temperature, compositions using SliceType = MultiFluidVarSlice< T, NDIM - 2, USD - 2, USD_DC - 2 >; GEOSX_HOST_DEVICE SliceType operator()( localIndex const k, localIndex const q ) const { - return { value[k][q], dPres[k][q], dTemp[k][q], dComp[k][q] }; + return { value[k][q], derivs[k][q] }; } }; /** * @brief Struct holding views into fluid data, used to simplify parameter passing in kernel wrapper constructors. * @tparam NDIM number of dimensions - * @tparam PERM unit-stride-dim of primary property and derivatives - * @tparam PERM_DC unit-stride-dim of compositional derivatives + * @tparam PERM unit-stride-dim of primary property + * @tparam PERM_DC unit-stride-dim of derivatives */ template< typename T, int NDIM, typename PERM, typename PERM_DC > struct MultiFluidVar { Array< real64, NDIM, PERM > value; ///< Property values - Array< real64, NDIM, PERM > dPres; ///< Property pressure derivatives - Array< real64, NDIM, PERM > dTemp; ///< Property temperature derivatives - Array< real64, NDIM + 1, PERM_DC > dComp; ///< Property compositional derivatives + Array< real64, NDIM + 1, PERM_DC > derivs; ///< Property derivatives w.r.t. pressure, temperature, compositions using ViewType = MultiFluidVarView< T, NDIM, getUSD< PERM >, getUSD< PERM_DC > >; using ViewTypeConst = MultiFluidVarView< T const, NDIM, getUSD< PERM >, getUSD< PERM_DC > >; @@ -105,12 +99,12 @@ struct MultiFluidVar ViewType toView() { - return { value.toView(), dPres.toView(), dTemp.toView(), dComp.toView() }; + return { value.toView(), derivs.toView() }; } ViewTypeConst toViewConst() const { - return { value.toViewConst(), dPres.toViewConst(), dTemp.toViewConst(), dComp.toViewConst() }; + return { value.toViewConst(), derivs.toViewConst() }; } }; diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index df920adbf43..7403ec1755d 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -368,40 +368,30 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr m_flash.compute( pressure, temperatureInCelsius, compMoleFrac.toSliceConst(), - phaseFraction.value, phaseFraction.dPres, phaseFraction.dTemp, phaseFraction.dComp, - phaseCompFraction.value, phaseCompFraction.dPres, phaseCompFraction.dTemp, phaseCompFraction.dComp ); + phaseFraction, + phaseCompFraction ); // 3. Compute phase densities and phase viscosities - // TODO: these compute functions should take PhaseProp::SliceType in input ... - m_p1Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseDensity.value[ip1], phaseDensity.dPres[ip1], - phaseDensity.dTemp[ip1], phaseDensity.dComp[ip1], + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseDensity.value[ip1], phaseDensity.derivs[ip1], m_useMass ); m_p1Viscosity.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseViscosity.value[ip1], phaseViscosity.dPres[ip1], - phaseViscosity.dTemp[ip1], phaseViscosity.dComp[ip1], + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseViscosity.value[ip1], phaseViscosity.derivs[ip1], m_useMass ); m_p2Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseDensity.value[ip2], phaseDensity.dPres[ip2], - phaseDensity.dTemp[ip2], phaseDensity.dComp[ip2], + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseDensity.value[ip2], phaseDensity.derivs[ip2], m_useMass ); m_p2Viscosity.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseViscosity.value[ip2], phaseViscosity.dPres[ip2], - phaseViscosity.dTemp[ip2], phaseViscosity.dComp[ip2], + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseViscosity.value[ip2], phaseViscosity.derivs[ip2], m_useMass ); // 4. Depending on the m_useMass flag, convert to mass variables or simply compute mass density @@ -413,66 +403,49 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr { // 4.1 Compute the phase molecular weights (ultimately, get that from the PVT function) + real64 phaseMolecularWeight[numPhase]{}; - real64 dPhaseMolecularWeight_dPres[numPhase]{}; - real64 dPhaseMolecularWeight_dTemp[numPhase]{}; - real64 dPhaseMolecularWeight_dComp[numPhase][numComp]{}; + real64 dPhaseMolecularWeight[numPhase][numComp+2]{}; real64 phaseMolarDens{}; - real64 dPhaseMolarDens_dPres{}; - real64 dPhaseMolarDens_dTemp{}; - stackArray1d< real64, numComp > dPhaseMolarDens_dComp( 2 ); + stackArray1d< real64, numComp+2 > dPhaseMolarDens( numComp+2 ); m_p2Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseMolarDens, dPhaseMolarDens_dPres, - dPhaseMolarDens_dTemp, dPhaseMolarDens_dComp.toSlice(), + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseMolarDens, dPhaseMolarDens.toSlice(), false ); - phaseMolecularWeight[ip2] = phaseDensity.value[ip2] / phaseMolarDens; - dPhaseMolecularWeight_dPres[ip2] = phaseDensity.dPres[ip2] / phaseMolarDens - phaseMolecularWeight[ip2] * dPhaseMolarDens_dPres / phaseMolarDens; - dPhaseMolecularWeight_dTemp[ip2] = phaseDensity.dTemp[ip2] / phaseMolarDens - phaseMolecularWeight[ip2] * dPhaseMolarDens_dTemp / phaseMolarDens; - for( integer ic = 0; ic < numComp; ++ic ) - { - dPhaseMolecularWeight_dComp[ip2][ic] = phaseDensity.dComp[ip2][ic] / phaseMolarDens - phaseMolecularWeight[ip2] * dPhaseMolarDens_dComp[ic] / phaseMolarDens; - } m_p1Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseMolarDens, dPhaseMolarDens_dPres, - dPhaseMolarDens_dTemp, dPhaseMolarDens_dComp.toSlice(), + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseMolarDens, dPhaseMolarDens.toSlice(), false ); - phaseMolecularWeight[ip1] = phaseDensity.value[ip1] / phaseMolarDens; - dPhaseMolecularWeight_dPres[ip1] = phaseDensity.dPres[ip1] / phaseMolarDens - phaseMolecularWeight[ip1] * dPhaseMolarDens_dPres / phaseMolarDens; - dPhaseMolecularWeight_dTemp[ip1] = phaseDensity.dTemp[ip1] / phaseMolarDens - phaseMolecularWeight[ip1] * dPhaseMolarDens_dTemp / phaseMolarDens; - for( integer ic = 0; ic < numComp; ++ic ) + for( integer ip = 0; ip < numPhase; ++ip ) { - dPhaseMolecularWeight_dComp[ip1][ic] = phaseDensity.dComp[ip1][ic] / phaseMolarDens - phaseMolecularWeight[ip1] * dPhaseMolarDens_dComp[ic] / phaseMolarDens; + phaseMolecularWeight[ip] = phaseDensity.value[ip] / phaseMolarDens; + for( integer idof = 0; idof < numComp+2; ++idof ) + { + dPhaseMolecularWeight[ip][idof] = phaseDensity.derivs[ip][idof] / phaseMolarDens - phaseMolecularWeight[ip] * dPhaseMolarDens[idof] / phaseMolarDens; + } } // 4.2 Convert the mole fractions to mass fractions convertToMassFractions( dCompMoleFrac_dCompMassFrac, phaseMolecularWeight, - dPhaseMolecularWeight_dPres, - dPhaseMolecularWeight_dTemp, - dPhaseMolecularWeight_dComp, + dPhaseMolecularWeight, phaseFraction, phaseCompFraction, - phaseDensity.dComp, - phaseViscosity.dComp ); + phaseDensity.derivs, + phaseViscosity.derivs ); // 4.3 Copy the phase densities into the phase mass densities for( integer ip = 0; ip < numPhase; ++ip ) { phaseMassDensity.value[ip] = phaseDensity.value[ip]; - phaseMassDensity.dPres[ip] = phaseDensity.dPres[ip]; - phaseMassDensity.dTemp[ip] = phaseDensity.dTemp[ip]; - for( integer ic = 0; ic < numComp; ++ic ) + for( integer idof = 0; idof < numComp+2; ++idof ) { - phaseMassDensity.dComp[ip][ic] = phaseDensity.dComp[ip][ic]; + phaseMassDensity.derivs[ip][idof] = phaseDensity.derivs[ip][idof]; } } } @@ -481,17 +454,13 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr // for now, we have to compute the phase mass density here m_p1Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.dPres[ip1].toSliceConst(), - phaseCompFraction.dTemp[ip1].toSliceConst(), phaseCompFraction.dComp[ip1].toSliceConst(), - phaseMassDensity.value[ip1], phaseMassDensity.dPres[ip1], - phaseMassDensity.dTemp[ip1], phaseMassDensity.dComp[ip1], + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseMassDensity.value[ip1], phaseMassDensity.derivs[ip1], true ); m_p2Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.dPres[ip2].toSliceConst(), - phaseCompFraction.dTemp[ip2].toSliceConst(), phaseCompFraction.dComp[ip2].toSliceConst(), - phaseMassDensity.value[ip2], phaseMassDensity.dPres[ip2], - phaseMassDensity.dTemp[ip2], phaseMassDensity.dComp[ip2], + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseMassDensity.value[ip2], phaseMassDensity.derivs[ip2], true ); } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp index 1e5dea1866e..802f213c263 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -57,18 +58,14 @@ class BrineEnthalpyUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -168,61 +165,59 @@ void BrineEnthalpyUpdate::compute( real64 const & pressure, } } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void BrineEnthalpyUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { + using namespace multifluid; + real64 const input[2] = { pressure, temperature }; - real64 brineEnthalpy_dTemperature; - real64 dvalue_dC; - real64 CO2EnthalpyDeriv[2]; + real64 brineEnthalpy_dTemperature = 0.0; + real64 dvalue_dC = 0.0; + real64 CO2EnthalpyDeriv[2]{}; real64 const brineEnthalpy = m_brineEnthalpyTable.compute( &temperature, &brineEnthalpy_dTemperature ); real64 const CO2Enthalpy = m_CO2EnthalpyTable.compute( input, CO2EnthalpyDeriv ); - //assume there are only CO2 and brine here. real64 const C = phaseComposition[m_waterIndex]; - - if( useMass ) { - value = (1.0 - C ) * CO2Enthalpy + C * brineEnthalpy; + value = (1.0 - C ) * CO2Enthalpy + + C * brineEnthalpy; dvalue_dC = brineEnthalpy - CO2Enthalpy; - dValue_dPressure = (1.0 - C ) * CO2EnthalpyDeriv[0] + - dvalue_dC * dPhaseComposition_dPressure[m_waterIndex]; - dValue_dTemperature = (1.0 - C ) * CO2EnthalpyDeriv[1] + C * brineEnthalpy_dTemperature + - dvalue_dC * dPhaseComposition_dTemperature[m_waterIndex];; + dValue[Deriv::dP] = (1.0 - C ) * CO2EnthalpyDeriv[0] + + dvalue_dC * dPhaseComposition[m_waterIndex][Deriv::dP]; + dValue[Deriv::dT] = (1.0 - C ) * CO2EnthalpyDeriv[1] + + C * brineEnthalpy_dTemperature + + dvalue_dC * dPhaseComposition[m_waterIndex][Deriv::dT]; } else { - real64 const waterMWInv = 1 / m_componentMolarWeight[m_waterIndex]; - real64 const CO2MWInv = 1 / m_componentMolarWeight[m_CO2Index]; + real64 const waterMWInv = 1.0 / m_componentMolarWeight[m_waterIndex]; + real64 const CO2MWInv = 1.0 / m_componentMolarWeight[m_CO2Index]; value = (1.0 - C ) * CO2Enthalpy * CO2MWInv + C * brineEnthalpy * waterMWInv; dvalue_dC = brineEnthalpy * waterMWInv - CO2Enthalpy * CO2MWInv; - dValue_dPressure = (1.0 - C ) * CO2EnthalpyDeriv[0] * CO2MWInv + - dvalue_dC * dPhaseComposition_dPressure[m_waterIndex]; - dValue_dTemperature = (1.0 - C ) * CO2EnthalpyDeriv[1] * CO2MWInv + C * brineEnthalpy_dTemperature * waterMWInv + - dvalue_dC * dPhaseComposition_dTemperature[m_waterIndex]; + dValue[Deriv::dP] = (1.0 - C ) * CO2EnthalpyDeriv[0] * CO2MWInv + + dvalue_dC * dPhaseComposition[m_waterIndex][Deriv::dP]; + dValue[Deriv::dT] = (1.0 - C ) * CO2EnthalpyDeriv[1] * CO2MWInv + + C * brineEnthalpy_dTemperature * waterMWInv + + dvalue_dC * dPhaseComposition[m_waterIndex][Deriv::dT]; } - dValue_dGlobalCompFraction[m_CO2Index] = dvalue_dC * dPhaseComposition_dGlobalCompFraction[m_waterIndex][m_CO2Index]; - dValue_dGlobalCompFraction[m_waterIndex] = dvalue_dC * dPhaseComposition_dGlobalCompFraction[m_waterIndex][m_waterIndex]; + dValue[Deriv::dC+m_CO2Index] = dvalue_dC * dPhaseComposition[m_waterIndex][Deriv::dC+m_CO2Index]; + dValue[Deriv::dC+m_waterIndex] = dvalue_dC * dPhaseComposition[m_waterIndex][Deriv::dC+m_waterIndex]; } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp index 458c006f5b9..e1e01245ed3 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -49,18 +50,14 @@ class BrineInternalEnergyUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -118,37 +115,30 @@ void BrineInternalEnergyUpdate::compute( real64 const & pressure, real64 & value, bool useMass ) const { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( useMass ); + GEOSX_UNUSED_VAR( phaseComposition, useMass ); value = 0.001 * pressure + 1.0 * temperature; } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void BrineInternalEnergyUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( dPhaseComposition_dPressure ); - GEOSX_UNUSED_VAR( dPhaseComposition_dTemperature ); - GEOSX_UNUSED_VAR( dPhaseComposition_dGlobalCompFraction ); - GEOSX_UNUSED_VAR( useMass ); + GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition, useMass ); + + using namespace multifluid; value = 0.001 * pressure + 1.0 * temperature; - dValue_dPressure = 0.001; - dValue_dTemperature = 1.0; + LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); + dValue[Deriv::dP] = 0.001; + dValue[Deriv::dT] = 1.0; - LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp index e34ed51283c..501dc34d5db 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -53,18 +54,14 @@ class CO2EnthalpyUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition_dGlobalCompFraction, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -143,44 +140,36 @@ void CO2EnthalpyUpdate::compute( real64 const & pressure, } } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void CO2EnthalpyUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( dPhaseComposition_dPressure ); - GEOSX_UNUSED_VAR( dPhaseComposition_dTemperature ); - GEOSX_UNUSED_VAR( dPhaseComposition_dGlobalCompFraction ); + GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition ); + using namespace multifluid; real64 const input[2] = { pressure, temperature }; - real64 CO2EnthalpyDeriv[2]; - + real64 CO2EnthalpyDeriv[2]{}; - dValue_dPressure = 0; value = m_CO2EnthalpyTable.compute( input, CO2EnthalpyDeriv ); - dValue_dPressure = CO2EnthalpyDeriv[0]; - dValue_dTemperature = CO2EnthalpyDeriv[1]; + + LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); + dValue[Deriv::dP] = CO2EnthalpyDeriv[0]; + dValue[Deriv::dT] = CO2EnthalpyDeriv[1]; if( !useMass ) { - real64 const CO2MWInv = 1 / m_componentMolarWeight[m_CO2Index]; + real64 const CO2MWInv = 1.0 / m_componentMolarWeight[m_CO2Index]; value *= CO2MWInv; - dValue_dPressure *= CO2MWInv; - dValue_dTemperature *= CO2MWInv; + dValue[Deriv::dP] *= CO2MWInv; + dValue[Deriv::dT] *= CO2MWInv; } - - LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp index 003006e0e2f..bdb259cfc8c 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -49,18 +50,14 @@ class CO2InternalEnergyUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -118,37 +115,31 @@ void CO2InternalEnergyUpdate::compute( real64 const & pressure, real64 & value, bool useMass ) const { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( useMass ); + GEOSX_UNUSED_VAR( phaseComposition, useMass ); value = 0.001 * pressure + 1.0 * temperature; } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void CO2InternalEnergyUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( dPhaseComposition_dPressure ); - GEOSX_UNUSED_VAR( dPhaseComposition_dTemperature ); - GEOSX_UNUSED_VAR( dPhaseComposition_dGlobalCompFraction ); - GEOSX_UNUSED_VAR( useMass ); + GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition, useMass ); + + using namespace multifluid; value = 0.001 * pressure + 1.0 * temperature; - dValue_dPressure = 0.001; - dValue_dTemperature = 1.0; - LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); + dValue[Deriv::dP] = 0.001; + dValue[Deriv::dT] = 1.0; + } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp index 6a1dfa87377..402c13f68cb 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp @@ -22,6 +22,8 @@ #include "FlashModelBase.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" +#include "constitutive/fluid/layouts.hpp" +#include "constitutive/fluid/MultiFluidUtils.hpp" #include "functions/TableFunction.hpp" namespace geosx @@ -39,6 +41,9 @@ class CO2SolubilityUpdate final : public FlashModelBaseUpdate { public: + using PhaseProp = MultiFluidVar< real64, 3, multifluid::LAYOUT_PHASE, multifluid::LAYOUT_PHASE_DC >; + using PhaseComp = MultiFluidVar< real64, 4, multifluid::LAYOUT_PHASE_COMP, multifluid::LAYOUT_PHASE_COMP_DC >; + CO2SolubilityUpdate( arrayView1d< real64 const > const & componentMolarWeight, TableFunction const & CO2SolubilityTable, integer const CO2Index, @@ -61,19 +66,13 @@ class CO2SolubilityUpdate final : public FlashModelBaseUpdate arraySlice1d< real64, USD2 > const & phaseFraction, arraySlice2d< real64, USD3 > const & phaseCompFraction ) const; - template< int USD1, int USD2, int USD3, int USD4, int USD5 > + template< int USD1 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & compFraction, - arraySlice1d< real64, USD2 > const & phaseFraction, - arraySlice1d< real64, USD2 > const & dPhaseFraction_dPressure, - arraySlice1d< real64, USD2 > const & dPhaseFraction_dTemperature, - arraySlice2d< real64, USD3 > const & dPhaseFraction_dCompFraction, - arraySlice2d< real64, USD4 > const & phaseCompFraction, - arraySlice2d< real64, USD4 > const & dPhaseCompFraction_dPressure, - arraySlice2d< real64, USD4 > const & dPhaseCompFraction_dTemperature, - arraySlice3d< real64, USD5 > const & dPhaseCompFraction_dCompFraction ) const; + PhaseProp::SliceType const phaseFraction, + PhaseComp::SliceType const phaseCompFraction ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override { @@ -212,24 +211,20 @@ CO2SolubilityUpdate::compute( real64 const & pressure, } } -template< int USD1, int USD2, int USD3, int USD4, int USD5 > +template< int USD1 > GEOSX_HOST_DEVICE inline void CO2SolubilityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & compFraction, - arraySlice1d< real64, USD2 > const & phaseFraction, - arraySlice1d< real64, USD2 > const & dPhaseFraction_dPressure, - arraySlice1d< real64, USD2 > const & dPhaseFraction_dTemperature, - arraySlice2d< real64, USD3 > const & dPhaseFraction_dCompFraction, - arraySlice2d< real64, USD4 > const & phaseCompFraction, - arraySlice2d< real64, USD4 > const & dPhaseCompFraction_dPressure, - arraySlice2d< real64, USD4 > const & dPhaseCompFraction_dTemperature, - arraySlice3d< real64, USD5 > const & dPhaseCompFraction_dCompFraction ) const + PhaseProp::SliceType const phaseFraction, + PhaseComp::SliceType const phaseCompFraction ) const { + using namespace multifluid; + // solubility mol/kg(water) X = Csat/W real64 const input[2] = { pressure, temperature }; - real64 solubilityDeriv[2]; + real64 solubilityDeriv[2]{}; real64 solubility = m_CO2SolubilityTable.compute( input, solubilityDeriv ); solubility *= m_componentMolarWeight[m_waterIndex]; @@ -239,8 +234,8 @@ CO2SolubilityUpdate::compute( real64 const & pressure, } // Y = C/W = z/(1-z) - real64 Y; - real64 dY_dCompFrac[2]; + real64 Y = 0.0; + real64 dY_dCompFrac[2]{}; if( compFraction[m_CO2Index] > 1.0 - minForDivision ) { @@ -264,28 +259,25 @@ CO2SolubilityUpdate::compute( real64 const & pressure, // 1) Compute phase fractions - phaseFraction[m_phaseLiquidIndex] = 1.0; - phaseFraction[m_phaseGasIndex] = 0.0; - LvArray::forValuesInSlice( dPhaseFraction_dPressure, setZero ); - LvArray::forValuesInSlice( dPhaseFraction_dTemperature, setZero ); - LvArray::forValuesInSlice( dPhaseFraction_dCompFraction, setZero ); + phaseFraction.value[m_phaseLiquidIndex] = 1.0; + phaseFraction.value[m_phaseGasIndex] = 0.0; + LvArray::forValuesInSlice( phaseFraction.derivs, setZero ); + LvArray::forValuesInSlice( phaseCompFraction.derivs, setZero ); // 2) Compute phase component fractions + phaseCompFraction.value[m_phaseGasIndex][m_CO2Index] = 1.0; + phaseCompFraction.value[m_phaseGasIndex][m_waterIndex] = 0.0; for( localIndex ic = 0; ic < 2; ++ic ) { - phaseCompFraction[m_phaseLiquidIndex][ic] = compFraction[ic]; - // the two following lines are not present in Yue's code, unclear if this will have some consequences - phaseCompFraction[m_phaseGasIndex][m_CO2Index] = 1.0; - phaseCompFraction[m_phaseGasIndex][m_waterIndex] = 0.0; + phaseCompFraction.value[m_phaseLiquidIndex][ic] = compFraction[ic]; + for( localIndex jc = 0; jc < 2; ++jc ) { - dPhaseCompFraction_dCompFraction[m_phaseLiquidIndex][ic][jc] = (ic == jc ) ? 1.0 : 0.0; - dPhaseCompFraction_dCompFraction[m_phaseGasIndex][ic][jc] = 0.0; + phaseCompFraction.derivs[m_phaseLiquidIndex][ic][Deriv::dC+jc] = (ic == jc ) ? 1.0 : 0.0; + phaseCompFraction.derivs[m_phaseGasIndex][ic][Deriv::dC+jc] = 0.0; } } - LvArray::forValuesInSlice( dPhaseCompFraction_dPressure, setZero ); - LvArray::forValuesInSlice( dPhaseCompFraction_dTemperature, setZero ); } else { @@ -295,43 +287,49 @@ CO2SolubilityUpdate::compute( real64 const & pressure, // liquid phase fraction = (Csat + W) / (C + W) = (Csat/W + 1) / (C/W + 1) real64 const onePlusYInv = 1.0 / ( 1.0 + Y ); - phaseFraction[m_phaseLiquidIndex] = (solubility + 1.0) * onePlusYInv; - dPhaseFraction_dPressure[m_phaseLiquidIndex] = solubilityDeriv[0] * onePlusYInv; - dPhaseFraction_dTemperature[m_phaseLiquidIndex] = solubilityDeriv[1] * onePlusYInv; - dPhaseFraction_dCompFraction[m_phaseLiquidIndex][m_CO2Index] = - -dY_dCompFrac[m_CO2Index] * phaseFraction[m_phaseLiquidIndex] * onePlusYInv; - dPhaseFraction_dCompFraction[m_phaseLiquidIndex][m_waterIndex] = - -dY_dCompFrac[m_waterIndex] * phaseFraction[m_phaseLiquidIndex] * onePlusYInv; + phaseFraction.value[m_phaseLiquidIndex] = (solubility + 1.0) * onePlusYInv; - phaseFraction[m_phaseGasIndex] = 1.0 - phaseFraction[m_phaseLiquidIndex]; - dPhaseFraction_dPressure[m_phaseGasIndex] = -dPhaseFraction_dPressure[m_phaseLiquidIndex]; - dPhaseFraction_dTemperature[m_phaseGasIndex] = -dPhaseFraction_dTemperature[m_phaseLiquidIndex]; - dPhaseFraction_dCompFraction[m_phaseGasIndex][m_CO2Index] = -dPhaseFraction_dCompFraction[m_phaseLiquidIndex][m_CO2Index]; - dPhaseFraction_dCompFraction[m_phaseGasIndex][m_waterIndex] = -dPhaseFraction_dCompFraction[m_phaseLiquidIndex][m_waterIndex]; + phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dP] = solubilityDeriv[0] * onePlusYInv; + phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dT] = solubilityDeriv[1] * onePlusYInv; + phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dC+m_CO2Index] = + -dY_dCompFrac[m_CO2Index] * phaseFraction.value[m_phaseLiquidIndex] * onePlusYInv; + phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dC+m_waterIndex] = + -dY_dCompFrac[m_waterIndex] * phaseFraction.value[m_phaseLiquidIndex] * onePlusYInv; + + phaseFraction.value[m_phaseGasIndex] = 1.0 - phaseFraction.value[m_phaseLiquidIndex]; + + phaseFraction.derivs[m_phaseGasIndex][Deriv::dP] = -phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dP]; + phaseFraction.derivs[m_phaseGasIndex][Deriv::dT] = -phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dT]; + phaseFraction.derivs[m_phaseGasIndex][Deriv::dC+m_CO2Index] = -phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dC+m_CO2Index]; + phaseFraction.derivs[m_phaseGasIndex][Deriv::dC+m_waterIndex] = -phaseFraction.derivs[m_phaseLiquidIndex][Deriv::dC+m_waterIndex]; // 2) Compute phase component fractions // liquid phase composition CO2 = Csat / (Csat + W) = (Csat/W) / (Csat/W + 1) real64 const onePlusSolubilityInv = 1.0 / ( 1.0 + solubility ); - phaseCompFraction[m_phaseLiquidIndex][m_CO2Index] = solubility * onePlusSolubilityInv; - dPhaseCompFraction_dPressure[m_phaseLiquidIndex][m_CO2Index] = solubilityDeriv[0] * (onePlusSolubilityInv*onePlusSolubilityInv); - dPhaseCompFraction_dTemperature[m_phaseLiquidIndex][m_CO2Index] = solubilityDeriv[1] * (onePlusSolubilityInv*onePlusSolubilityInv); + phaseCompFraction.value[m_phaseLiquidIndex][m_CO2Index] = solubility * onePlusSolubilityInv; - phaseCompFraction[m_phaseLiquidIndex][m_waterIndex] = 1.0 - phaseCompFraction[m_phaseLiquidIndex][m_CO2Index]; - dPhaseCompFraction_dPressure[m_phaseLiquidIndex][m_waterIndex] = -dPhaseCompFraction_dPressure[m_phaseLiquidIndex][m_CO2Index]; - dPhaseCompFraction_dTemperature[m_phaseLiquidIndex][m_waterIndex] = -dPhaseCompFraction_dTemperature[m_phaseLiquidIndex][m_CO2Index]; + phaseCompFraction.derivs[m_phaseLiquidIndex][m_CO2Index][Deriv::dP] = solubilityDeriv[0] * (onePlusSolubilityInv*onePlusSolubilityInv); + phaseCompFraction.derivs[m_phaseLiquidIndex][m_CO2Index][Deriv::dT] = solubilityDeriv[1] * (onePlusSolubilityInv*onePlusSolubilityInv); + + phaseCompFraction.value[m_phaseLiquidIndex][m_waterIndex] = 1.0 - phaseCompFraction.value[m_phaseLiquidIndex][m_CO2Index]; + + phaseCompFraction.derivs[m_phaseLiquidIndex][m_waterIndex][Deriv::dP] = -phaseCompFraction.derivs[m_phaseLiquidIndex][m_CO2Index][Deriv::dP]; + phaseCompFraction.derivs[m_phaseLiquidIndex][m_waterIndex][Deriv::dT] = -phaseCompFraction.derivs[m_phaseLiquidIndex][m_CO2Index][Deriv::dT]; // gas phase composition CO2 = 1.0 - phaseCompFraction[m_phaseGasIndex][m_CO2Index] = 1.0; - phaseCompFraction[m_phaseGasIndex][m_waterIndex] = 0.0; - dPhaseCompFraction_dPressure[m_phaseGasIndex][m_CO2Index] = 0.0; - dPhaseCompFraction_dPressure[m_phaseGasIndex][m_waterIndex] = 0.0; - dPhaseCompFraction_dTemperature[m_phaseGasIndex][m_CO2Index] = 0.0; - dPhaseCompFraction_dTemperature[m_phaseGasIndex][m_waterIndex] = 0.0; + LvArray::forValuesInSlice( phaseCompFraction.derivs, setZero ); + + phaseCompFraction.value[m_phaseGasIndex][m_CO2Index] = 1.0; + phaseCompFraction.value[m_phaseGasIndex][m_waterIndex] = 0.0; + phaseCompFraction.derivs[m_phaseGasIndex][m_CO2Index][Deriv::dP] = 0.0; + phaseCompFraction.derivs[m_phaseGasIndex][m_waterIndex][Deriv::dT] = 0.0; + phaseCompFraction.derivs[m_phaseGasIndex][m_CO2Index][Deriv::dP] = 0.0; + phaseCompFraction.derivs[m_phaseGasIndex][m_waterIndex][Deriv::dT] = 0.0; // phaseCompFraction does not depend on globalComponentFraction - LvArray::forValuesInSlice( dPhaseCompFraction_dCompFraction, setZero ); + } } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp index c2f5e692149..0a203cecafb 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "functions/TableFunction.hpp" namespace geosx @@ -64,18 +65,14 @@ class EzrokhiBrineDensityUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -191,22 +188,20 @@ void EzrokhiBrineDensityUpdate::compute( real64 const & pressure, } } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void EzrokhiBrineDensityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - real64 waterSatDensity_dTemperature; - real64 waterSatPressure_dTemperature; + using namespace multifluid; + + real64 waterSatDensity_dTemperature = 0.0; + real64 waterSatPressure_dTemperature = 0.0; real64 const waterSatDensity = m_waterSatDensityTable.compute( &temperature, &waterSatDensity_dTemperature ); real64 const waterSatPressure = m_waterSatPressureTable.compute( &temperature, &waterSatPressure_dTemperature ); @@ -228,8 +223,8 @@ void EzrokhiBrineDensityUpdate::compute( real64 const & pressure, real64 const exponent = coefPhaseComposition * massPhaseCompositionCO2; - real64 const exponent_dPressure = coefPhaseComposition * dPhaseComposition_dPressure[m_CO2Index]; - real64 const exponent_dTemperature = coefPhaseComposition * dPhaseComposition_dTemperature[m_CO2Index] + + real64 const exponent_dPressure = coefPhaseComposition * dPhaseComposition[m_CO2Index][Deriv::dP]; + real64 const exponent_dTemperature = coefPhaseComposition * dPhaseComposition[m_CO2Index][Deriv::dT] + ( m_coef1 + 2 * m_coef2 * temperature) * massPhaseCompositionCO2; // compute only common part of derivatives w.r.t. CO2 and water phase compositions // later to be multiplied by (phaseComposition[m_waterIndex]) and ( -phaseComposition[m_CO2Index] ) respectively @@ -241,12 +236,12 @@ void EzrokhiBrineDensityUpdate::compute( real64 const & pressure, real64 const dValueCoef = LvArray::math::log( 10 ) * value; real64 const dValue_dPhaseComp = dValueCoef * exponent_dPhaseComp; - dValue_dPressure = dValueCoef * exponent_dPressure + waterDensity_dPressure * exponentPowered; - dValue_dTemperature = dValueCoef * exponent_dTemperature + waterDensity_dTemperature * exponentPowered; + dValue[Deriv::dP] = dValueCoef * exponent_dPressure + waterDensity_dPressure * exponentPowered; + dValue[Deriv::dT] = dValueCoef * exponent_dTemperature + waterDensity_dTemperature * exponentPowered; // here, we multiply common part of derivatives by specific coefficients - dValue_dGlobalCompFraction[m_CO2Index] = dValue_dPhaseComp * phaseComposition[m_waterIndex] * dPhaseComposition_dGlobalCompFraction[m_CO2Index][m_CO2Index]; - dValue_dGlobalCompFraction[m_waterIndex] = dValue_dPhaseComp * ( -phaseComposition[m_CO2Index] ) * dPhaseComposition_dGlobalCompFraction[m_waterIndex][m_waterIndex]; + dValue[Deriv::dC+m_CO2Index] = dValue_dPhaseComp * phaseComposition[m_waterIndex] * dPhaseComposition[m_CO2Index][Deriv::dC+m_CO2Index]; + dValue[Deriv::dC+m_waterIndex] = dValue_dPhaseComp * ( -phaseComposition[m_CO2Index] ) * dPhaseComposition[m_waterIndex][Deriv::dC+m_waterIndex]; } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp index 2cac2f26297..baafd8075d3 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "functions/TableFunction.hpp" namespace geosx @@ -60,18 +61,14 @@ class EzrokhiBrineViscosityUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -170,22 +167,21 @@ void EzrokhiBrineViscosityUpdate::compute( real64 const & pressure, value = waterVisc * pow( 10, value ); } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void EzrokhiBrineViscosityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { GEOSX_UNUSED_VAR( pressure, useMass ); - real64 waterVisc_dTemperature; + + using namespace multifluid; + + real64 waterVisc_dTemperature = 0.0; real64 const waterVisc = m_waterViscosityTable.compute( &temperature, &waterVisc_dTemperature ); real64 const coefPhaseComposition = m_coef0 + temperature * ( m_coef1 + m_coef2 * temperature ); @@ -198,8 +194,8 @@ void EzrokhiBrineViscosityUpdate::compute( real64 const & pressure, real64 const exponent = coefPhaseComposition * massPhaseCompositionCO2; - real64 const exponent_dPressure = coefPhaseComposition * dPhaseComposition_dPressure[m_CO2Index]; - real64 const exponent_dTemperature = coefPhaseComposition * dPhaseComposition_dTemperature[m_CO2Index] + + real64 const exponent_dPressure = coefPhaseComposition * dPhaseComposition[m_CO2Index][Deriv::dP]; + real64 const exponent_dTemperature = coefPhaseComposition * dPhaseComposition[m_CO2Index][Deriv::dT] + ( m_coef1 + 2 * m_coef2 * temperature) * massPhaseCompositionCO2; // compute only common part of derivatives w.r.t. CO2 and water phase compositions @@ -212,12 +208,12 @@ void EzrokhiBrineViscosityUpdate::compute( real64 const & pressure, real64 const dValueCoef = LvArray::math::log( 10 ) * value; real64 const dValue_dPhaseComp = dValueCoef * exponent_dPhaseComp; - dValue_dPressure = dValueCoef * exponent_dPressure; - dValue_dTemperature = dValueCoef * exponent_dTemperature + waterVisc_dTemperature * exponentPowered; + dValue[Deriv::dP] = dValueCoef * exponent_dPressure; + dValue[Deriv::dT] = dValueCoef * exponent_dTemperature + waterVisc_dTemperature * exponentPowered; // here, we multiply common part of derivatives by specific coefficients - dValue_dGlobalCompFraction[m_CO2Index] = dValue_dPhaseComp * phaseComposition[m_waterIndex] * dPhaseComposition_dGlobalCompFraction[m_CO2Index][m_CO2Index]; - dValue_dGlobalCompFraction[m_waterIndex] = dValue_dPhaseComp * ( -phaseComposition[m_CO2Index] ) * dPhaseComposition_dGlobalCompFraction[m_waterIndex][m_waterIndex]; + dValue[Deriv::dC+m_CO2Index] = dValue_dPhaseComp * phaseComposition[m_waterIndex] * dPhaseComposition[m_CO2Index][Deriv::dC+m_CO2Index]; + dValue[Deriv::dC+m_waterIndex] = dValue_dPhaseComp * ( -phaseComposition[m_CO2Index] ) * dPhaseComposition[m_waterIndex][Deriv::dC+m_waterIndex]; } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp index 5ca9a1c55f2..4942e7f1346 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -51,18 +52,14 @@ class FenghourCO2ViscosityUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -128,33 +125,30 @@ void FenghourCO2ViscosityUpdate::compute( real64 const & pressure, value = m_CO2ViscosityTable.compute( input ); } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void FenghourCO2ViscosityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { GEOSX_UNUSED_VAR( phaseComposition, - dPhaseComposition_dPressure, - dPhaseComposition_dTemperature, - dPhaseComposition_dGlobalCompFraction, + dPhaseComposition, useMass ); + using namespace multifluid; + real64 const input[2] = { pressure, temperature }; - real64 densityDeriv[2]; + real64 densityDeriv[2]{}; value = m_CO2ViscosityTable.compute( input, densityDeriv ); - dValue_dPressure = densityDeriv[0]; - dValue_dTemperature = densityDeriv[1]; - LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); + LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); + dValue[Deriv::dP] = densityDeriv[0]; + dValue[Deriv::dT] = densityDeriv[1]; + } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp index 8d9cf1d3b25..1115fd9a454 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -55,18 +56,14 @@ class PhillipsBrineDensityUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -176,20 +173,18 @@ void PhillipsBrineDensityUpdate::compute( real64 const & pressure, } } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void PhillipsBrineDensityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { + using namespace multifluid; + // this method implements the method proposed by E. Garcia (2001) // these coefficients come from equation (2) from Garcia (2001) @@ -199,7 +194,7 @@ void PhillipsBrineDensityUpdate::compute( real64 const & pressure, constexpr real64 d = -5.044e-7; real64 const input[2] = { pressure, temperature }; - real64 densityDeriv[2]; + real64 densityDeriv[2]{}; real64 const density = m_brineDensityTable.compute( input, densityDeriv ); // equation (2) from Garcia (2001) @@ -217,11 +212,11 @@ void PhillipsBrineDensityUpdate::compute( real64 const & pressure, real64 const oneMinusCO2PhaseCompInv = 1.0 / ( 1.0 - phaseComposition[m_CO2Index] ); real64 const oneMinusCO2PhaseCompInvSquared = oneMinusCO2PhaseCompInv * oneMinusCO2PhaseCompInv; real64 const coef = wMwInv * phaseComposition[m_CO2Index] * oneMinusCO2PhaseCompInv; - real64 const dCoef_dPres = wMwInv * dPhaseComposition_dPressure[m_CO2Index] * oneMinusCO2PhaseCompInvSquared; - real64 const dCoef_dTemp = wMwInv * dPhaseComposition_dTemperature[m_CO2Index] * oneMinusCO2PhaseCompInvSquared; + real64 const dCoef_dPres = wMwInv * dPhaseComposition[m_CO2Index][Deriv::dP] * oneMinusCO2PhaseCompInvSquared; + real64 const dCoef_dTemp = wMwInv * dPhaseComposition[m_CO2Index][Deriv::dT] * oneMinusCO2PhaseCompInvSquared; real64 dCoef_dComp[2]{}; - dCoef_dComp[m_CO2Index] = wMwInv * dPhaseComposition_dGlobalCompFraction[m_CO2Index][m_CO2Index] * oneMinusCO2PhaseCompInvSquared; - dCoef_dComp[m_waterIndex] = wMwInv * dPhaseComposition_dGlobalCompFraction[m_CO2Index][m_waterIndex] * oneMinusCO2PhaseCompInvSquared; + dCoef_dComp[m_CO2Index] = wMwInv * dPhaseComposition[m_CO2Index][Deriv::dC+m_CO2Index] * oneMinusCO2PhaseCompInvSquared; + dCoef_dComp[m_waterIndex] = wMwInv * dPhaseComposition[m_CO2Index][Deriv::dC+m_waterIndex] * oneMinusCO2PhaseCompInvSquared; real64 const conc = coef * density; real64 const dConc_dPres = dCoef_dPres * density + coef * densityDeriv[0]; @@ -246,32 +241,32 @@ void PhillipsBrineDensityUpdate::compute( real64 const & pressure, value = density + m_componentMolarWeight[m_CO2Index] * conc - concDensVol; - dValue_dPressure = densityDeriv[0] - + m_componentMolarWeight[m_CO2Index] * dConc_dPres - - dConcDensVol_dPres; - dValue_dTemperature = densityDeriv[1] - + m_componentMolarWeight[m_CO2Index] * dConc_dTemp - - dConcDensVol_dTemp; - dValue_dGlobalCompFraction[m_CO2Index] = m_componentMolarWeight[m_CO2Index] * dConc_dComp[m_CO2Index] - - dConcDensVol_dComp[m_CO2Index]; - dValue_dGlobalCompFraction[m_waterIndex] = m_componentMolarWeight[m_CO2Index] * dConc_dComp[m_waterIndex] - - dConcDensVol_dComp[m_waterIndex]; + dValue[Deriv::dP] = densityDeriv[0] + + m_componentMolarWeight[m_CO2Index] * dConc_dPres + - dConcDensVol_dPres; + dValue[Deriv::dT] = densityDeriv[1] + + m_componentMolarWeight[m_CO2Index] * dConc_dTemp + - dConcDensVol_dTemp; + dValue[Deriv::dC+m_CO2Index] = m_componentMolarWeight[m_CO2Index] * dConc_dComp[m_CO2Index] + - dConcDensVol_dComp[m_CO2Index]; + dValue[Deriv::dC+m_waterIndex] = m_componentMolarWeight[m_CO2Index] * dConc_dComp[m_waterIndex] + - dConcDensVol_dComp[m_waterIndex]; } else { value = density / m_componentMolarWeight[m_waterIndex] + conc - concDensVol / m_componentMolarWeight[m_waterIndex]; - dValue_dPressure = densityDeriv[0] / m_componentMolarWeight[m_waterIndex] - + dConc_dPres - - dConcDensVol_dPres / m_componentMolarWeight[m_waterIndex]; - dValue_dTemperature = densityDeriv[1] / m_componentMolarWeight[m_waterIndex] - + dConc_dTemp - - dConcDensVol_dTemp / m_componentMolarWeight[m_waterIndex]; - dValue_dGlobalCompFraction[m_CO2Index] = dConc_dComp[m_CO2Index] - - dConcDensVol_dComp[m_CO2Index] / m_componentMolarWeight[m_waterIndex]; - dValue_dGlobalCompFraction[m_waterIndex] = dConc_dComp[m_waterIndex] - - dConcDensVol_dComp[m_waterIndex] / m_componentMolarWeight[m_waterIndex]; + dValue[Deriv::dP] = densityDeriv[0] / m_componentMolarWeight[m_waterIndex] + + dConc_dPres + - dConcDensVol_dPres / m_componentMolarWeight[m_waterIndex]; + dValue[Deriv::dT] = densityDeriv[1] / m_componentMolarWeight[m_waterIndex] + + dConc_dTemp + - dConcDensVol_dTemp / m_componentMolarWeight[m_waterIndex]; + dValue[Deriv::dC+m_CO2Index] = dConc_dComp[m_CO2Index] + - dConcDensVol_dComp[m_CO2Index] / m_componentMolarWeight[m_waterIndex]; + dValue[Deriv::dC+m_waterIndex] = dConc_dComp[m_waterIndex] + - dConcDensVol_dComp[m_waterIndex] / m_componentMolarWeight[m_waterIndex]; } } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp index c95924dd84f..98aeb0669d8 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "functions/TableFunction.hpp" namespace geosx @@ -54,18 +55,14 @@ class PhillipsBrineViscosityUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -145,40 +142,36 @@ void PhillipsBrineViscosityUpdate::compute( real64 const & pressure, value = pureWaterVisc * ( m_coef0 + m_coef1 * temperature ); } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void PhillipsBrineViscosityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { GEOSX_UNUSED_VAR( pressure, phaseComposition, - dPhaseComposition_dPressure, - dPhaseComposition_dTemperature, - dPhaseComposition_dGlobalCompFraction, + dPhaseComposition, useMass ); + using namespace multifluid; + // compute the viscosity of pure water as a function of temperature real64 dPureWaterVisc_dTemperature; real64 const pureWaterVisc = m_waterViscosityTable.compute( &temperature, &dPureWaterVisc_dTemperature ); // then compute the brine viscosity, accounting for the presence of salt + real64 const viscMultiplier = m_coef0 + m_coef1 * temperature; real64 const dViscMultiplier_dTemperature = m_coef1; value = pureWaterVisc * viscMultiplier; - dValue_dPressure = 0.0; - dValue_dTemperature = dPureWaterVisc_dTemperature * viscMultiplier + pureWaterVisc * dViscMultiplier_dTemperature; + LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); + dValue[Deriv::dP] = 0.0; + dValue[Deriv::dT] = dPureWaterVisc_dTemperature * viscMultiplier + pureWaterVisc * dViscMultiplier_dTemperature; - // finally, zero out the derivatives wrt global component fraction - LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp index bedc37a0d6a..b4a70516829 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp @@ -21,6 +21,7 @@ #include "PVTFunctionBase.hpp" +#include "constitutive/fluid/layouts.hpp" #include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" #include "functions/TableFunction.hpp" @@ -53,18 +54,14 @@ class SpanWagnerCO2DensityUpdate final : public PVTFunctionBaseUpdate real64 & value, bool useMass ) const; - template< int USD1, int USD2, int USD3, int USD4 > + template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const; virtual void move( LvArray::MemorySpace const space, bool const touch ) override @@ -145,39 +142,35 @@ void SpanWagnerCO2DensityUpdate::compute( real64 const & pressure, } } -template< int USD1, int USD2, int USD3, int USD4 > +template< int USD1, int USD2, int USD3 > GEOSX_HOST_DEVICE void SpanWagnerCO2DensityUpdate::compute( real64 const & pressure, real64 const & temperature, arraySlice1d< real64 const, USD1 > const & phaseComposition, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dPressure, - arraySlice1d< real64 const, USD2 > const & dPhaseComposition_dTemperature, - arraySlice2d< real64 const, USD3 > const & dPhaseComposition_dGlobalCompFraction, + arraySlice2d< real64 const, USD2 > const & dPhaseComposition, real64 & value, - real64 & dValue_dPressure, - real64 & dValue_dTemperature, - arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - GEOSX_UNUSED_VAR( phaseComposition, - dPhaseComposition_dPressure, - dPhaseComposition_dTemperature, - dPhaseComposition_dGlobalCompFraction ); + GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition ); + + using namespace multifluid; real64 const input[2] = { pressure, temperature }; - real64 densityDeriv[2]; + real64 densityDeriv[2]{}; value = m_CO2DensityTable.compute( input, densityDeriv ); - dValue_dPressure = densityDeriv[0]; - dValue_dTemperature = densityDeriv[1]; + + LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); + dValue[Deriv::dP] = densityDeriv[0]; + dValue[Deriv::dT] = densityDeriv[1]; if( !useMass ) { value /= m_componentMolarWeight[m_CO2Index]; - dValue_dPressure /= m_componentMolarWeight[m_CO2Index]; - dValue_dTemperature /= m_componentMolarWeight[m_CO2Index]; + dValue[Deriv::dP] /= m_componentMolarWeight[m_CO2Index]; + dValue[Deriv::dT] /= m_componentMolarWeight[m_CO2Index]; } - LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); } } // end namespace PVTProps diff --git a/src/coreComponents/constitutive/fluid/layouts.hpp b/src/coreComponents/constitutive/fluid/layouts.hpp index ea1d2ffd960..afcc0548855 100644 --- a/src/coreComponents/constitutive/fluid/layouts.hpp +++ b/src/coreComponents/constitutive/fluid/layouts.hpp @@ -19,6 +19,7 @@ #ifndef GEOSX_CONSTITUTIVE_FLUID_LAYOUTS_HPP #define GEOSX_CONSTITUTIVE_FLUID_LAYOUTS_HPP +#include "common/DataTypes.hpp" #include "common/GeosxConfig.hpp" #include "LvArray/src/typeManipulation.hpp" @@ -31,6 +32,17 @@ namespace constitutive namespace multifluid { +/// indices of pressure, temperature, and composition derivatives +struct Deriv +{ + /// index of derivative wrt pressure + static integer constexpr dP = 0; + /// index of derivative wrt temperature + static integer constexpr dT = 1; + /// index of first derivative wrt compositions + static integer constexpr dC = 2; +}; + #if defined( GEOSX_USE_CUDA ) /// Constitutive model phase property array layout diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp index 9116b51dd81..e6736c02dbb 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp @@ -280,11 +280,9 @@ class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > m_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >() ), m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ), m_phaseFrac( fluid.phaseFraction() ), - m_dPhaseFrac_dPres( fluid.dPhaseFraction_dPressure() ), - m_dPhaseFrac_dComp( fluid.dPhaseFraction_dGlobalCompFraction() ), + m_dPhaseFrac( fluid.dPhaseFraction() ), m_phaseDens( fluid.phaseDensity() ), - m_dPhaseDens_dPres( fluid.dPhaseDensity_dPressure() ), - m_dPhaseDens_dComp( fluid.dPhaseDensity_dGlobalCompFraction() ) + m_dPhaseDens( fluid.dPhaseDensity() ) {} /** @@ -298,15 +296,15 @@ class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > void compute( localIndex const ei, FUNC && phaseVolFractionKernelOp = NoOpFunc{} ) const { + using namespace multifluid; + arraySlice1d< real64 const, compflow::USD_COMP - 1 > const compDens = m_compDens[ei]; arraySlice1d< real64 const, compflow::USD_COMP - 1 > const dCompDens = m_dCompDens[ei]; arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseDens = m_phaseDens[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseDens_dPres = m_dPhaseDens_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseDens_dComp = m_dPhaseDens_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseDens = m_dPhaseDens[ei][0]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseFrac = m_phaseFrac[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseFrac_dPres = m_dPhaseFrac_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseFrac_dComp = m_dPhaseFrac_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseFrac = m_dPhaseFrac[ei][0]; arraySlice1d< real64, compflow::USD_PHASE - 1 > const phaseVolFrac = m_phaseVolFrac[ei]; arraySlice1d< real64, compflow::USD_PHASE - 1 > const dPhaseVolFrac_dPres = m_dPhaseVolFrac_dPres[ei]; arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac_dComp = m_dPhaseVolFrac_dComp[ei]; @@ -344,12 +342,12 @@ class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; dPhaseVolFrac_dPres[ip] = - (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; + (dPhaseFrac[ip][Deriv::dP] - phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dP]) * phaseDensInv; for( integer jc = 0; jc < numComp; ++jc ) { dPhaseVolFrac_dComp[ip][jc] = - (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; + (dPhaseFrac[ip][Deriv::dC+jc] - phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dC+jc]) * phaseDensInv; } // apply chain rule to convert derivatives from global component fractions to densities @@ -389,13 +387,11 @@ class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > /// Views on phase fractions arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseFrac; - arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseFrac_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseFrac_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseFrac; /// Views on phase densities arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseDens; - arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseDens_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseDens_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseDens; }; @@ -647,12 +643,10 @@ class ElementBasedAssemblyKernel m_dPhaseVolFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >() ), m_phaseDensOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseDensityOld >() ), m_phaseDens( fluid.phaseDensity() ), - m_dPhaseDens_dPres( fluid.dPhaseDensity_dPressure() ), - m_dPhaseDens_dComp( fluid.dPhaseDensity_dGlobalCompFraction() ), + m_dPhaseDens( fluid.dPhaseDensity() ), m_phaseCompFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseComponentFractionOld >() ), m_phaseCompFrac( fluid.phaseCompFraction() ), - m_dPhaseCompFrac_dPres( fluid.dPhaseCompFraction_dPressure() ), - m_dPhaseCompFrac_dComp( fluid.dPhaseCompFraction_dGlobalCompFraction() ), + m_dPhaseCompFrac( fluid.dPhaseCompFraction() ), m_localMatrix( localMatrix ), m_localRhs( localRhs ) {} @@ -737,6 +731,8 @@ class ElementBasedAssemblyKernel StackVariables & stack, FUNC && phaseAmountKernelOp = NoOpFunc{} ) const { + using namespace multifluid; + // construct the slices for variables accessed multiple times arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; @@ -747,13 +743,11 @@ class ElementBasedAssemblyKernel arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseDensOld = m_phaseDensOld[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > phaseDens = m_phaseDens[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseDens_dPres = m_dPhaseDens_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseDens_dComp = m_dPhaseDens_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseDens = m_dPhaseDens[ei][0]; arraySlice2d< real64 const, compflow::USD_PHASE_COMP-1 > phaseCompFracOld = m_phaseCompFracOld[ei]; arraySlice2d< real64 const, multifluid::USD_PHASE_COMP-2 > phaseCompFrac = m_phaseCompFrac[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP-2 > dPhaseCompFrac_dPres = m_dPhaseCompFrac_dPres[ei][0]; - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC-2 > dPhaseCompFrac_dComp = m_dPhaseCompFrac_dComp[ei][0]; + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC-2 > dPhaseCompFrac = m_dPhaseCompFrac[ei][0]; // temporary work arrays real64 dPhaseAmount_dC[numComp]{}; @@ -766,11 +760,11 @@ class ElementBasedAssemblyKernel real64 const phaseAmountOld = stack.poreVolumeOld * phaseVolFracOld[ip] * phaseDensOld[ip]; real64 const dPhaseAmount_dP = stack.dPoreVolume_dPres * phaseVolFrac[ip] * phaseDens[ip] - + stack.poreVolumeNew * (dPhaseVolFrac_dPres[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); + + stack.poreVolumeNew * ( dPhaseVolFrac_dPres[ip] * phaseDens[ip] + + phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dP] ); // assemble density dependence - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens[ip], dPhaseAmount_dC, Deriv::dC ); for( integer jc = 0; jc < numComp; ++jc ) { dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] @@ -786,7 +780,7 @@ class ElementBasedAssemblyKernel real64 const phaseCompAmountOld = phaseAmountOld * phaseCompFracOld[ip][ic]; real64 const dPhaseCompAmount_dP = dPhaseAmount_dP * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac_dPres[ip][ic]; + + phaseAmountNew * dPhaseCompFrac[ip][ic][Deriv::dP]; stack.localResidual[ic] += phaseCompAmountNew - phaseCompAmountOld; stack.localJacobian[ic][0] += dPhaseCompAmount_dP; @@ -795,7 +789,7 @@ class ElementBasedAssemblyKernel // (i.e. col number in local matrix) // assemble phase composition dependence - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseCompFrac_dComp[ip][ic], dPhaseCompFrac_dC ); + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseCompFrac[ip][ic], dPhaseCompFrac_dC, Deriv::dC ); for( integer jc = 0; jc < numComp; ++jc ) { real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew @@ -939,23 +933,21 @@ class ElementBasedAssemblyKernel /// Views on the derivatives of comp fractions wrt component density arrayView3d< real64 const, compflow::USD_COMP_DC > const m_dCompFrac_dCompDens; - /// Views on the phase volume fractions (excluding derivative wrt temperature) + /// Views on the phase volume fractions arrayView2d< real64 const, compflow::USD_PHASE > const m_phaseVolFracOld; arrayView2d< real64 const, compflow::USD_PHASE > const m_phaseVolFrac; arrayView2d< real64 const, compflow::USD_PHASE > const m_dPhaseVolFrac_dPres; arrayView3d< real64 const, compflow::USD_PHASE_DC > const m_dPhaseVolFrac_dCompDens; - /// Views on the phase densities (excluding derivative wrt temperature) + /// Views on the phase densities arrayView2d< real64 const, compflow::USD_PHASE > const m_phaseDensOld; arrayView3d< real64 const, multifluid::USD_PHASE > const m_phaseDens; - arrayView3d< real64 const, multifluid::USD_PHASE > const m_dPhaseDens_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const m_dPhaseDens_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const m_dPhaseDens; - /// Views on the phase component fraction (excluding derivative wrt temperature) + /// Views on the phase component fraction arrayView3d< real64 const, compflow::USD_PHASE_COMP > const m_phaseCompFracOld; arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const m_phaseCompFrac; - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const m_dPhaseCompFrac_dPres; - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const m_dPhaseCompFrac_dComp; + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const m_dPhaseCompFrac; /// View on the local CRS matrix CRSMatrixView< real64, globalIndex const > const m_localMatrix; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 8d4acb16400..610e5856595 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -603,11 +603,9 @@ void CompositionalMultiphaseFVM::applyAquiferBC( real64 const time, compFlowAccessors.get( extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity{} ), compFlowAccessors.get( extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity{} ), multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseDensity{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity_dPressure{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction{} ), + multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity{} ), multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseCompFraction{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction{} ), + multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction{} ), time, dt, localMatrix.toViewConstSizes(), diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp index b0ac49622bf..5ec100b981d 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp @@ -25,8 +25,6 @@ #include "finiteVolume/FaceElementToCellStencil.hpp" #include "mesh/utilities/MeshMapUtilities.hpp" - - namespace geosx { @@ -64,11 +62,9 @@ FaceBasedAssemblyKernelBase::FaceBasedAssemblyKernelBase( integer const numPhase m_dPhaseMob_dPres( compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dPressure {} ) ), m_dPhaseMob_dCompDens( compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity {} ) ), m_phaseMassDens( multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseMassDensity {} ) ), - m_dPhaseMassDens_dPres( multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity_dPressure {} ) ), - m_dPhaseMassDens_dComp( multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity_dGlobalCompFraction {} ) ), + m_dPhaseMassDens( multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity {} ) ), m_phaseCompFrac( multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseCompFraction {} ) ), - m_dPhaseCompFrac_dPres( multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure {} ) ), - m_dPhaseCompFrac_dComp( multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction {} ) ), + m_dPhaseCompFrac( multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction {} ) ), m_phaseCapPressure( capPressureAccessors.get( extrinsicMeshData::cappres::phaseCapPressure {} ) ), m_dPhaseCapPressure_dPhaseVolFrac( capPressureAccessors.get( extrinsicMeshData::cappres::dPhaseCapPressure_dPhaseVolFraction {} ) ), m_localMatrix( localMatrix ), @@ -199,13 +195,13 @@ CFLFluxKernel:: forAll< parallelDevicePolicy<> >( stencilWrapper.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iconn ) { // compute transmissibility - real64 transmissiblity[STENCILWRAPPER_TYPE::MAX_NUM_OF_CONNECTIONS][2]; + real64 transmissibility[STENCILWRAPPER_TYPE::MAX_NUM_OF_CONNECTIONS][2]; real64 dTrans_dPres[STENCILWRAPPER_TYPE::MAX_NUM_OF_CONNECTIONS][2]; stencilWrapper.computeWeights( iconn, permeability, dPerm_dPres, - transmissiblity, + transmissibility, dTrans_dPres ); localIndex const stencilSize = meshMapUtilities::size1( sei, iconn ); @@ -216,7 +212,7 @@ CFLFluxKernel:: seri[iconn], sesri[iconn], sei[iconn], - transmissiblity[0], + transmissibility[0], pres, gravCoef, phaseVolFrac, @@ -489,19 +485,19 @@ AquiferBCKernel:: real64 const & aquiferWaterPhaseDens, arrayView1d< real64 const > const & aquiferWaterPhaseCompFrac, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > phaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseDens_dCompFrac, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseDens, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dPres, arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac_dCompDens, arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > phaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > dPhaseCompFrac_dPres, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > dPhaseCompFrac_dCompFrac, + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > dPhaseCompFrac, arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens, real64 const & dt, real64 (& localFlux)[NC], real64 (& localFluxJacobian)[NC][NC+1] ) { + using namespace multifluid; + real64 dProp_dC[NC]{}; real64 dPhaseFlux_dCompDens[NC]{}; @@ -534,9 +530,9 @@ AquiferBCKernel:: real64 const phaseDensVolFrac = phaseDens[ip] * phaseVolFrac[ip]; real64 const phaseFlux = aquiferVolFlux * phaseDensVolFrac; real64 const dPhaseFlux_dPres = dAquiferVolFlux_dPres * phaseDensVolFrac - + aquiferVolFlux * ( dPhaseDens_dPres[ip] * phaseVolFrac[ip] + phaseDens[ip] * dPhaseVolFrac_dPres[ip] ); + + aquiferVolFlux * ( dPhaseDens[ip][Deriv::dP] * phaseVolFrac[ip] + phaseDens[ip] * dPhaseVolFrac_dPres[ip] ); - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dCompFrac[ip], dProp_dC ); + applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens[ip], dProp_dC, Deriv::dC ); for( integer ic = 0; ic < NC; ++ic ) { dPhaseFlux_dCompDens[ic] = aquiferVolFlux * ( dProp_dC[ic] * phaseVolFrac[ip] + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][ic] ); @@ -545,9 +541,9 @@ AquiferBCKernel:: for( integer ic = 0; ic < NC; ++ic ) { localFlux[ic] -= dt * phaseFlux * phaseCompFrac[ip][ic]; - localFluxJacobian[ic][0] -= dt * ( dPhaseFlux_dPres * phaseCompFrac[ip][ic] + phaseFlux * dPhaseCompFrac_dPres[ip][ic] ); + localFluxJacobian[ic][0] -= dt * ( dPhaseFlux_dPres * phaseCompFrac[ip][ic] + phaseFlux * dPhaseCompFrac[ip][ic][Deriv::dP] ); - applyChainRule( NC, dCompFrac_dCompDens, dPhaseCompFrac_dCompFrac[ip][ic], dProp_dC ); + applyChainRule( NC, dCompFrac_dCompDens, dPhaseCompFrac[ip][ic], dProp_dC, Deriv::dC ); for( integer jc = 0; jc < NC; ++jc ) { localFluxJacobian[ic][jc+1] -= dt * ( dPhaseFlux_dCompDens[jc] * phaseCompFrac[ip][ic] + phaseFlux * dProp_dC[jc] ); @@ -579,11 +575,9 @@ AquiferBCKernel:: ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, real64 const & timeAtBeginningOfStep, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, @@ -631,14 +625,12 @@ AquiferBCKernel:: aquiferWaterPhaseDens, aquiferWaterPhaseCompFrac, phaseDens[er][esr][ei][0], - dPhaseDens_dPres[er][esr][ei][0], - dPhaseDens_dCompFrac[er][esr][ei][0], + dPhaseDens[er][esr][ei][0], phaseVolFrac[er][esr][ei], dPhaseVolFrac_dPres[er][esr][ei], dPhaseVolFrac_dCompDens[er][esr][ei], phaseCompFrac[er][esr][ei][0], - dPhaseCompFrac_dPres[er][esr][ei][0], - dPhaseCompFrac_dCompFrac[er][esr][ei][0], + dPhaseCompFrac[er][esr][ei][0], dCompFrac_dCompDens[er][esr][ei], dt, localFlux, @@ -698,11 +690,9 @@ AquiferBCKernel:: ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dCompDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, \ real64 const & timeAtBeginningOfStep, \ real64 const & dt, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp index d6ec1eb6abb..9455d362d3e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp @@ -81,11 +81,9 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK m_dPhaseVolFrac_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >() ), m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ), m_phaseDens( fluid.phaseDensity() ), - m_dPhaseDens_dPres( fluid.dPhaseDensity_dPressure() ), - m_dPhaseDens_dComp( fluid.dPhaseDensity_dGlobalCompFraction() ), + m_dPhaseDens( fluid.dPhaseDensity() ), m_phaseVisc( fluid.phaseViscosity() ), - m_dPhaseVisc_dPres( fluid.dPhaseViscosity_dPressure() ), - m_dPhaseVisc_dComp( fluid.dPhaseViscosity_dGlobalCompFraction() ), + m_dPhaseVisc( fluid.dPhaseViscosity() ), m_phaseRelPerm( relperm.phaseRelPerm() ), m_dPhaseRelPerm_dPhaseVolFrac( relperm.dPhaseRelPerm_dPhaseVolFraction() ), m_phaseMob( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobility >() ), @@ -104,13 +102,13 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK void compute( localIndex const ei, FUNC && phaseMobilityKernelOp = CompositionalMultiphaseBaseKernels::NoOpFunc{} ) const { + using namespace multifluid; + arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseDens = m_phaseDens[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseDens_dPres = m_dPhaseDens_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseDens_dComp = m_dPhaseDens_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseDens = m_dPhaseDens[ei][0]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseVisc = m_phaseVisc[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseVisc_dPres = m_dPhaseVisc_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc_dComp = m_dPhaseVisc_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc = m_dPhaseVisc[ei][0]; arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const phaseRelPerm = m_phaseRelPerm[ei][0]; arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const dPhaseRelPerm_dPhaseVolFrac = m_dPhaseRelPerm_dPhaseVolFrac[ei][0]; arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const phaseVolFrac = m_phaseVolFrac[ei]; @@ -141,12 +139,12 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK } real64 const density = phaseDens[ip]; - real64 const dDens_dP = dPhaseDens_dPres[ip]; - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); + real64 const dDens_dP = dPhaseDens[ip][Deriv::dP]; + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens[ip], dDens_dC, Deriv::dC ); real64 const viscosity = phaseVisc[ip]; - real64 const dVisc_dP = dPhaseVisc_dPres[ip]; - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); + real64 const dVisc_dP = dPhaseVisc[ip][Deriv::dP]; + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseVisc[ip], dVisc_dC, Deriv::dC ); real64 const relPerm = phaseRelPerm[ip]; real64 dRelPerm_dP = 0.0; @@ -197,13 +195,11 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK /// Views on the phase densities arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseDens; - arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseDens_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseDens_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseDens; /// Views on the phase viscosities arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseVisc; - arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseVisc_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseVisc_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseVisc; /// Views on the phase relative permeabilities arrayView3d< real64 const, relperm::USD_RELPERM > m_phaseRelPerm; @@ -298,11 +294,9 @@ class FaceBasedAssemblyKernelBase using MultiFluidAccessors = StencilMaterialAccessors< MultiFluidBase, extrinsicMeshData::multifluid::phaseMassDensity, - extrinsicMeshData::multifluid::dPhaseMassDensity_dPressure, - extrinsicMeshData::multifluid::dPhaseMassDensity_dGlobalCompFraction, + extrinsicMeshData::multifluid::dPhaseMassDensity, extrinsicMeshData::multifluid::phaseCompFraction, - extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure, - extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction >; + extrinsicMeshData::multifluid::dPhaseCompFraction >; using CapPressureAccessors = StencilMaterialAccessors< CapillaryPressureBase, @@ -383,13 +377,11 @@ class FaceBasedAssemblyKernelBase /// Views on phase mass densities ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_phaseMassDens; - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_dPhaseMassDens_dPres; - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const m_dPhaseMassDens_dComp; + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const m_dPhaseMassDens; /// Views on phase component fractions ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const m_phaseCompFrac; - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const m_dPhaseCompFrac_dPres; - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const m_dPhaseCompFrac_dComp; + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const m_dPhaseCompFrac; /// Views on phase capillary pressure ElementViewConst< arrayView3d< real64 const, cappres::USD_CAPPRES > > const m_phaseCapPressure; @@ -596,6 +588,8 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase FUNC1 && phaseFluxKernelOp = CompositionalMultiphaseBaseKernels::NoOpFunc{}, FUNC2 && localFluxJacobianKernelOp = CompositionalMultiphaseBaseKernels::NoOpFunc{} ) const { + using namespace multifluid; + // first, compute the transmissibilities at this face m_stencilWrapper.computeWeights( iconn, m_permeability, @@ -638,12 +632,13 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase // density real64 const density = m_phaseMassDens[er][esr][ei][0][ip]; - real64 const dDens_dP = m_dPhaseMassDens_dPres[er][esr][ei][0][ip]; + real64 const dDens_dP = m_dPhaseMassDens[er][esr][ei][0][ip][Deriv::dP]; applyChainRule( numComp, m_dCompFrac_dCompDens[er][esr][ei], - m_dPhaseMassDens_dComp[er][esr][ei][0][ip], - dProp_dC ); + m_dPhaseMassDens[er][esr][ei][0][ip], + dProp_dC, + Deriv::dC ); // average density and derivatives densMean += 0.5 * density; @@ -780,10 +775,8 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase // slice some constitutive arrays to avoid too much indexing in component loop arraySlice1d< real64 const, multifluid::USD_PHASE_COMP-3 > phaseCompFracSub = m_phaseCompFrac[er_up][esr_up][ei_up][0][ip]; - arraySlice1d< real64 const, multifluid::USD_PHASE_COMP-3 > dPhaseCompFrac_dPresSub = - m_dPhaseCompFrac_dPres[er_up][esr_up][ei_up][0][ip]; - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFrac_dCompSub = - m_dPhaseCompFrac_dComp[er_up][esr_up][ei_up][0][ip]; + arraySlice2d< real64 const, multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFracSub = + m_dPhaseCompFrac[er_up][esr_up][ei_up][0][ip]; // compute component fluxes and derivatives using upstream cell composition for( integer ic = 0; ic < numComp; ++ic ) @@ -802,13 +795,14 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase } // additional derivatives stemming from upstream cell phase composition - stack.dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFrac_dPresSub[ic]; + stack.dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFracSub[ic][Deriv::dP]; // convert derivatives of comp fraction w.r.t. comp fractions to derivatives w.r.t. comp densities applyChainRule( numComp, m_dCompFrac_dCompDens[er_up][esr_up][ei_up], - dPhaseCompFrac_dCompSub[ic], - dProp_dC ); + dPhaseCompFracSub[ic], + dProp_dC, + Deriv::dC ); for( integer jc = 0; jc < numComp; ++jc ) { stack.dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; @@ -1158,11 +1152,9 @@ struct AquiferBCKernel using MultiFluidAccessors = StencilMaterialAccessors< MultiFluidBase, extrinsicMeshData::multifluid::phaseDensity, - extrinsicMeshData::multifluid::dPhaseDensity_dPressure, - extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction, + extrinsicMeshData::multifluid::dPhaseDensity, extrinsicMeshData::multifluid::phaseCompFraction, - extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure, - extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction >; + extrinsicMeshData::multifluid::dPhaseCompFraction >; template< integer NC > GEOSX_HOST_DEVICE @@ -1175,14 +1167,12 @@ struct AquiferBCKernel real64 const & aquiferWaterPhaseDens, arrayView1d< real64 const > const & aquiferWaterPhaseCompFrac, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > phaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseDens_dCompFrac, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseDens, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dPres, arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac_dCompDens, arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > phaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > dPhaseCompFrac_dPres, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > dPhaseCompFrac_dCompFrac, + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > dPhaseCompFrac, arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens, real64 const & dt, real64 ( &localFlux )[NC], @@ -1196,7 +1186,6 @@ struct AquiferBCKernel BoundaryStencil const & stencil, globalIndex const rankOffset, ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, - AquiferBoundaryCondition::KernelWrapper const & aquiferBCWrapper, real64 const & aquiferWaterPhaseDens, arrayView1d< real64 const > const & aquiferWaterPhaseCompFrac, @@ -1209,11 +1198,9 @@ struct AquiferBCKernel ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, real64 const & timeAtBeginningOfStep, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp index df4aff35467..9fafb2b4095 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp @@ -373,26 +373,23 @@ void CompositionalMultiphaseHybridFVM::assembleFluxTerms( real64 const dt, string const fluidName = subRegion.getReference< string >( viewKeyStruct::fluidNamesString() ); MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidName ); arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & phaseCompFrac = fluid.phaseCompFraction(); - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dPres = fluid.dPhaseCompFraction_dPressure(); - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dPhaseCompFrac_dComp = fluid.dPhaseCompFraction_dGlobalCompFraction(); + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dPhaseCompFrac = fluid.dPhaseCompFraction(); arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseMassDens = fluid.phaseMassDensity(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseMassDens_dPres = fluid.dPhaseMassDensity_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseMassDens_dComp = fluid.dPhaseMassDensity_dGlobalCompFraction(); + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseMassDens = fluid.dPhaseMassDensity(); arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens = fluid.phaseDensity(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens = fluid.dPhaseDensity(); forAll< parallelDevicePolicy<> >( subRegion.size(), - [phaseCompFrac, dPhaseCompFrac_dPres, dPhaseCompFrac_dComp, - phaseMassDens, dPhaseMassDens_dPres, dPhaseMassDens_dComp, - phaseDens, dPhaseDens_dPres, dPhaseDens_dComp] + [phaseCompFrac, dPhaseCompFrac, + phaseMassDens, dPhaseMassDens, + phaseDens, dPhaseDens] GEOSX_HOST_DEVICE ( localIndex const ) { - GEOSX_UNUSED_VAR( phaseCompFrac, dPhaseCompFrac_dPres, dPhaseCompFrac_dComp, - phaseMassDens, dPhaseMassDens_dPres, dPhaseMassDens_dComp, - phaseDens, dPhaseDens_dPres, dPhaseDens_dComp ); + GEOSX_UNUSED_VAR( phaseCompFrac, dPhaseCompFrac, + phaseMassDens, dPhaseMassDens, + phaseDens, dPhaseDens ); } ); } ); @@ -485,14 +482,11 @@ void CompositionalMultiphaseHybridFVM::assembleFluxTerms( real64 const dt, compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity{} ), compFlowAccessors.get( extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity{} ), multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseDensity{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity_dPressure{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction{} ), + multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity{} ), multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseMassDensity{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity_dPressure{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity_dGlobalCompFraction{} ), + multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity{} ), multiFluidAccessors.get( extrinsicMeshData::multifluid::phaseCompFraction{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure{} ), - multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction{} ), + multiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction{} ), elemDofNumber.toNestedViewConst(), dofManager.rankOffset(), lengthTolerance, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp index 683d8b8a540..0e774f9a985 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp @@ -40,15 +40,13 @@ UpwindingHelper:: upwindViscousCoefficient( localIndex const (&localIds)[ 3 ], localIndex const (&neighborIds)[ 3 ], ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, real64 const & oneSidedVolFlux, real64 ( & upwPhaseViscCoef )[ NP ][ NC ], @@ -56,6 +54,8 @@ UpwindingHelper:: real64 ( & dUpwPhaseViscCoef_dCompDens )[ NP ][ NC ][ NC ], globalIndex & upwViscDofNumber ) { + using namespace multifluid; + real64 dUpwMobRatio_dCompDens[ NC ]{}; real64 dUpwDensMobRatio_dCompDens[ NC ]{}; real64 dPhaseDens_dC[ NC ]{}; @@ -96,10 +96,11 @@ UpwindingHelper:: // 4) Multiply mobility ratio by phase density: \rho^{up}_{\ell} \frac{\lambda_{\ell}}{\lambda_T} applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], - dPhaseDens_dCompFrac[er][esr][ei][0][ip], - dPhaseDens_dC ); + dPhaseDens[er][esr][ei][0][ip], + dPhaseDens_dC, + Deriv::dC ); real64 const upwDensMobRatio = phaseDens[er][esr][ei][0][ip] * upwMobRatio; - real64 const dUpwDensMobRatio_dPres = dPhaseDens_dPres[er][esr][ei][0][ip] * upwMobRatio + real64 const dUpwDensMobRatio_dPres = dPhaseDens[er][esr][ei][0][ip][Deriv::dP] * upwMobRatio + phaseDens[er][esr][ei][0][ip] * dUpwMobRatio_dPres; for( integer ic = 0; ic < NC; ++ic ) { @@ -112,10 +113,11 @@ UpwindingHelper:: { applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], - dPhaseCompFrac_dCompFrac[er][esr][ei][0][ip][ic], - dPhaseCompFrac_dC ); + dPhaseCompFrac[er][esr][ei][0][ip][ic], + dPhaseCompFrac_dC, + Deriv::dC ); upwPhaseViscCoef[ip][ic] = phaseCompFrac[er][esr][ei][0][ip][ic] * upwDensMobRatio; - dUpwPhaseViscCoef_dPres[ip][ic] = dPhaseCompFrac_dPres[er][esr][ei][0][ip][ic] * upwDensMobRatio + dUpwPhaseViscCoef_dPres[ip][ic] = dPhaseCompFrac[er][esr][ei][0][ip][ic][Deriv::dP] * upwDensMobRatio + phaseCompFrac[er][esr][ei][0][ip][ic] * dUpwDensMobRatio_dPres; for( integer jc = 0; jc < NC; ++jc ) { @@ -137,18 +139,15 @@ UpwindingHelper:: localIndex const (&neighborIds)[ 3 ], real64 const & transGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, real64 ( & phaseGravTerm )[ NP ][ NP-1 ], real64 ( & dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], real64 ( & dPhaseGravTerm_dCompDens )[ NP ][ NP-1 ][ 2 ][ NC ], @@ -156,13 +155,14 @@ UpwindingHelper:: real64 ( & dUpwPhaseGravCoef_dPres )[ NP ][ NP-1 ][ NC ][ 2 ], real64 ( & dUpwPhaseGravCoef_dCompDens )[ NP ][ NP-1 ][ NC ][ 2 ][ NC ] ) { + using namespace multifluid; + // 1) Compute the driving force: T ( \rho^{avg}_{\ell} - \rho^{avg}_m ) g \Delta z computePhaseGravTerm( localIds, neighborIds, transGravCoef, phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dCompFrac, + dPhaseMassDens, dCompFrac_dCompDens, phaseGravTerm, dPhaseGravTerm_dPres, @@ -230,10 +230,11 @@ UpwindingHelper:: // 3.c) Compute mobility ratio multiplied by upwinded phase density \rho_l \frac{\lambda_l \lambda_m}{\lambda_T} applyChainRule( NC, dCompFrac_dCompDens[eru][esru][eiu], - dPhaseDens_dCompFrac[eru][esru][eiu][0][ip], - dPhaseDens_dC ); + dPhaseDens[eru][esru][eiu][0][ip], + dPhaseDens_dC, + Deriv::dC ); real64 const densMobRatio = phaseDens[eru][esru][eiu][0][ip] * mobRatio; - dDensMobRatio_dPres[posu] = dPhaseDens_dPres[eru][esru][eiu][0][ip] * mobRatio + dDensMobRatio_dPres[posu] = dPhaseDens[eru][esru][eiu][0][ip][Deriv::dP] * mobRatio + phaseDens[eru][esru][eiu][0][ip] * dMobRatio_dPres[posu]; dDensMobRatio_dPres[posd] = phaseDens[eru][esru][eiu][0][ip] * dMobRatio_dPres[posd]; for( integer ic = 0; ic < NC; ++ic ) @@ -248,10 +249,11 @@ UpwindingHelper:: { applyChainRule( NC, dCompFrac_dCompDens[eru][esru][eiu], - dPhaseCompFrac_dCompFrac[eru][esru][eiu][0][ip][ic], - dPhaseCompFrac_dC ); + dPhaseCompFrac[eru][esru][eiu][0][ip][ic], + dPhaseCompFrac_dC, + Deriv::dC ); upwPhaseGravCoef[ip][k][ic] = phaseCompFrac[eru][esru][eiu][0][ip][ic] * densMobRatio; - dUpwPhaseGravCoef_dPres[ip][k][ic][posu] = dPhaseCompFrac_dPres[eru][esru][eiu][0][ip][ic] * densMobRatio + dUpwPhaseGravCoef_dPres[ip][k][ic][posu] = dPhaseCompFrac[eru][esru][eiu][0][ip][ic][Deriv::dP] * densMobRatio + phaseCompFrac[eru][esru][eiu][0][ip][ic] * dDensMobRatio_dPres[posu]; dUpwPhaseGravCoef_dPres[ip][k][ic][posd] = phaseCompFrac[eru][esru][eiu][0][ip][ic] * dDensMobRatio_dPres[posd]; @@ -275,13 +277,14 @@ UpwindingHelper:: localIndex const (&neighborIds)[ 3 ], real64 const & transGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, real64 ( & phaseGravTerm )[ NP ][ NP-1 ], real64 ( & dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], real64 ( & dPhaseGravTerm_dCompDens )[ NP ][ NP-1 ][ 2 ][ NC ] ) { + using namespace multifluid; + localIndex const er = localIds[0]; localIndex const esr = localIds[1]; localIndex const ei = localIds[2]; @@ -297,12 +300,14 @@ UpwindingHelper:: { applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], - dPhaseMassDens_dCompFrac[er][esr][ei][0][ip], - dPhaseMassDens_dCLoc ); + dPhaseMassDens[er][esr][ei][0][ip], + dPhaseMassDens_dCLoc, + Deriv::dC ); applyChainRule( NC, dCompFrac_dCompDens[ern][esrn][ein], - dPhaseMassDens_dCompFrac[ern][esrn][ein][0][ip], - dPhaseMassDens_dCNeighbor ); + dPhaseMassDens[ern][esrn][ein][0][ip], + dPhaseMassDens_dCNeighbor, + Deriv::dC ); localIndex k = 0; for( integer jp = 0; jp < NP; ++jp ) @@ -316,10 +321,10 @@ UpwindingHelper:: phaseGravTerm[ip][k] += ( phaseMassDens[er][esr][ei][0][jp] + phaseMassDens[ern][esrn][ein][0][jp] ); phaseGravTerm[ip][k] *= 0.5 * transGravCoef; - dPhaseGravTerm_dPres[ip][k][Pos::LOCAL] = ( -dPhaseMassDens_dPres[er][esr][ei][0][ip] + dPhaseMassDens_dPres[er][esr][ei][0][jp] ); + dPhaseGravTerm_dPres[ip][k][Pos::LOCAL] = ( -dPhaseMassDens[er][esr][ei][0][ip][Deriv::dP] + dPhaseMassDens[er][esr][ei][0][jp][Deriv::dP] ); dPhaseGravTerm_dPres[ip][k][Pos::LOCAL] *= 0.5 * transGravCoef; - dPhaseGravTerm_dPres[ip][k][Pos::NEIGHBOR] = ( -dPhaseMassDens_dPres[ern][esrn][ein][0][ip] + dPhaseMassDens_dPres[ern][esrn][ein][0][jp] ); + dPhaseGravTerm_dPres[ip][k][Pos::NEIGHBOR] = ( -dPhaseMassDens[ern][esrn][ein][0][ip][Deriv::dP] + dPhaseMassDens[ern][esrn][ein][0][jp][Deriv::dP] ); dPhaseGravTerm_dPres[ip][k][Pos::NEIGHBOR] *= 0.5 * transGravCoef; for( integer ic = 0; ic < NC; ++ic ) @@ -329,17 +334,19 @@ UpwindingHelper:: } applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], - dPhaseMassDens_dCompFrac[er][esr][ei][0][jp], - dPhaseMassDens_dC ); + dPhaseMassDens[er][esr][ei][0][jp], + dPhaseMassDens_dC, + Deriv::dC ); for( integer ic = 0; ic < NC; ++ic ) { dPhaseGravTerm_dCompDens[ip][k][Pos::LOCAL][ic] += 0.5 * transGravCoef * dPhaseMassDens_dC[ic]; } applyChainRule( NC, dCompFrac_dCompDens[ern][esrn][ein], - dPhaseMassDens_dCompFrac[ern][esrn][ein][0][jp], - dPhaseMassDens_dC ); - for( localIndex ic = 0; ic < NC; ++ic ) + dPhaseMassDens[ern][esrn][ein][0][jp], + dPhaseMassDens_dC, + Deriv::dC ); + for( integer ic = 0; ic < NC; ++ic ) { dPhaseGravTerm_dCompDens[ip][k][Pos::NEIGHBOR][ic] += 0.5 * transGravCoef * dPhaseMassDens_dC[ic]; } @@ -463,8 +470,8 @@ UpwindingHelper:: for( integer ip = 0; ip < NP; ++ip ) { if( ( gravTerm[ip][0] >= 0 && gravTerm[ip][1] >= 0 ) || // includes the no-buoyancy case - ( ( fabs( gravTerm[ip][0] ) >= fabs( gravTerm[ip][1] ) ) && gravTerm[ip][1] >= 0 ) || - ( ( fabs( gravTerm[ip][1] ) >= fabs( gravTerm[ip][0] ) ) && gravTerm[ip][0] >= 0 ) ) + ( ( LvArray::math::abs( gravTerm[ip][0] ) >= LvArray::math::abs( gravTerm[ip][1] ) ) && gravTerm[ip][1] >= 0 ) || + ( ( LvArray::math::abs( gravTerm[ip][1] ) >= LvArray::math::abs( gravTerm[ip][0] ) ) && gravTerm[ip][0] >= 0 ) ) { totalMobIds[ip][0] = localIds[0]; totalMobIds[ip][1] = localIds[1]; @@ -490,15 +497,13 @@ UpwindingHelper:: upwindViscousCoefficient< NC, NP >( localIndex const (&localIds)[ 3 ], \ localIndex const (&neighborIds)[ 3 ], \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, \ ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, \ real64 const & oneSidedVolFlux, \ real64 ( &upwPhaseViscCoef )[ NP ][ NC ], \ @@ -512,18 +517,15 @@ UpwindingHelper:: localIndex const (&neighborIds)[ 3 ], \ real64 const & transGravCoef, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, \ real64 ( &phaseGravTerm )[ NP ][ NP-1 ], \ real64 ( &dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], \ real64 ( &dPhaseGravTerm_dCompDens )[ NP ][ NP-1 ][ 2 ][ NC ], \ @@ -537,8 +539,7 @@ UpwindingHelper:: localIndex const (&neighborIds)[ 3 ], \ real64 const & transGravCoef, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ real64 ( &phaseGravTerm )[ NP ][ NP-1 ], \ real64 ( &dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], \ @@ -599,8 +600,7 @@ AssemblerKernelHelper:: real64 const & dElemPres, real64 const & elemGravCoef, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & elemPhaseMassDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dElemPhaseMassDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dElemPhaseMassDens_dCompFrac, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dElemPhaseMassDens, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & elemPhaseMob, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dElemPhaseMob_dPres, arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dElemPhaseMob_dCompDens, @@ -611,6 +611,8 @@ AssemblerKernelHelper:: real64 ( & dOneSidedVolFlux_dFacePres )[ NF ][ NF ], real64 ( & dOneSidedVolFlux_dCompDens )[ NF ][ NC ] ) { + using namespace multifluid; + real64 dPhaseMassDens_dC[ NP ][ NC ]{}; real64 dPresDif_dCompDens[ NC ]{}; real64 dPhaseGravDif_dCompDens[ NC ]{}; @@ -621,8 +623,9 @@ AssemblerKernelHelper:: { applyChainRule( NC, dElemCompFrac_dCompDens, - dElemPhaseMassDens_dCompFrac[ip], - dPhaseMassDens_dC[ip] ); + dElemPhaseMassDens[ip], + dPhaseMassDens_dC[ip], + Deriv::dC ); } for( integer ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) @@ -655,7 +658,7 @@ AssemblerKernelHelper:: // gravity term real64 const phaseGravDif = elemPhaseMassDens[ip] * gravCoefDif; - real64 const dPhaseGravDif_dPres = dElemPhaseMassDens_dPres[ip] * gravCoefDif; + real64 const dPhaseGravDif_dPres = dElemPhaseMassDens[ip][Deriv::dP] * gravCoefDif; for( localIndex ic = 0; ic < NC; ++ic ) { dPhaseGravDif_dCompDens[ic] = dPhaseMassDens_dC[ip][ic] * gravCoefDif; @@ -706,18 +709,15 @@ AssemblerKernelHelper:: arraySlice1d< localIndex const > const & elemToFaces, real64 const & elemGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, arraySlice2d< real64 const > const & transMatrixGrav, real64 const (&oneSidedVolFlux)[ NF ], @@ -785,15 +785,13 @@ AssemblerKernelHelper:: UpwindingHelper::upwindViscousCoefficient< NC, NP >( localIds, neighborIds, phaseDens, - dPhaseDens_dPres, - dPhaseDens_dCompFrac, + dPhaseDens, phaseMob, dPhaseMob_dPres, dPhaseMob_dCompDens, dCompFrac_dCompDens, phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dCompFrac, + dPhaseCompFrac, elemDofNumber, oneSidedVolFlux[ifaceLoc], upwPhaseViscCoef, @@ -832,18 +830,15 @@ AssemblerKernelHelper:: neighborIds, transGravCoef, phaseDens, - dPhaseDens_dPres, - dPhaseDens_dCompFrac, + dPhaseDens, phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dCompFrac, + dPhaseMassDens, phaseMob, dPhaseMob_dPres, dPhaseMob_dCompDens, dCompFrac_dCompDens, phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dCompFrac, + dPhaseCompFrac, phaseGravTerm, dPhaseGravTerm_dPres, dPhaseGravTerm_dCompDens, @@ -1129,7 +1124,6 @@ AssemblerKernelHelper:: real64 const & dElemPres, \ real64 const & elemGravCoef, \ arraySlice1d< real64 const, multifluid::USD_PHASE-2 > const & elemPhaseMassDens, \ - arraySlice1d< real64 const, multifluid::USD_PHASE-2 > const & dElemPhaseMassDens_dPres, \ arraySlice2d< real64 const, multifluid::USD_PHASE_DC-2 > const & dElemPhaseMassDens_dCompFrac, \ arraySlice1d< real64 const, compflow::USD_PHASE-1 > const & elemPhaseMob, \ arraySlice1d< real64 const, compflow::USD_PHASE-1 > const & dElemPhaseMob_dPres, \ @@ -1154,18 +1148,15 @@ AssemblerKernelHelper:: arraySlice1d< localIndex const > const & elemToFaces, \ real64 const & elemGravCoef, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, \ ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, \ arraySlice2d< real64 const > const & transMatrixGrav, \ real64 const (&oneSidedVolFlux)[ NF ], \ @@ -1284,18 +1275,15 @@ AssemblerKernel:: real64 const & dElemPres, real64 const & elemGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, integer const elemGhostRank, globalIndex const rankOffset, @@ -1329,8 +1317,7 @@ AssemblerKernel:: dElemPres, elemGravCoef, phaseMassDens[er][esr][ei][0], - dPhaseMassDens_dPres[er][esr][ei][0], - dPhaseMassDens_dCompFrac[er][esr][ei][0], + dPhaseMassDens[er][esr][ei][0], phaseMob[er][esr][ei], dPhaseMob_dPres[er][esr][ei], dPhaseMob_dCompDens[er][esr][ei], @@ -1365,18 +1352,15 @@ AssemblerKernel:: elemToFaces, elemGravCoef, phaseDens, - dPhaseDens_dPres, - dPhaseDens_dCompFrac, + dPhaseDens, phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dCompFrac, + dPhaseMassDens, phaseMob, dPhaseMob_dPres, dPhaseMob_dCompDens, dCompFrac_dCompDens, phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dCompFrac, + dPhaseCompFrac, elemDofNumber, transMatrixGrav, oneSidedVolFlux, @@ -1424,18 +1408,15 @@ AssemblerKernel:: real64 const & dElemPres, \ real64 const & elemGravCoef, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, \ ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, \ ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, \ integer const elemGhostRank, \ globalIndex const rankOffset, \ @@ -1511,14 +1492,11 @@ FluxKernel:: ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, globalIndex const rankOffset, real64 const lengthTolerance, @@ -1606,18 +1584,15 @@ FluxKernel:: dElemPres[ei], elemGravCoef[ei], phaseDens, - dPhaseDens_dPres, - dPhaseDens_dCompFrac, + dPhaseDens, phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dCompFrac, + dPhaseMassDens, phaseMob, dPhaseMob_dPres, dPhaseMob_dCompDens, dCompFrac_dCompDens, phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dCompFrac, + dPhaseCompFrac, elemDofNumber, elemGhostRank[ei], rankOffset, @@ -1654,14 +1629,11 @@ FluxKernel:: ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, \ ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, \ globalIndex const rankOffset, \ real64 const lengthTolerance, \ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp index 045e6bb55fb..d6072c741c1 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp @@ -65,15 +65,14 @@ struct UpwindingHelper * @param[in] localIds region, subRegion, and element indices of the local element * @param[in] neighborIds region, subRegion, and element indices of the neigbhbor element * @param[in] phaseDens the phase densities in the domain (non-local) - * @param[in] dPhaseDens_dPres the derivatives of the phase densities in the domain wrt pressure (non-local) - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities in the domain wrt component fraction (non-local) + * @param[in] dPhaseDens the derivatives of the phase densities in the domain wrt pressure and component fractions (non-local) * @param[in] phaseMob the phase mobilities in the domain (non-local) * @param[in] dPhaseMob_dPres the derivatives of the phase mobilities in the domain wrt pressure (non-local) * @param[in] dPhaseMob_dCompDens the derivatives of the phase mobilities in the domain wrt component fraction (non-local) * @param[in] dCompFrac_dCompDens the derivatives of the component fraction in the domain wrt component density (non-local) * @param[in] phaseCompFrac the phase component fractions in the domain (non-local) - * @param[in] dPhaseCompFrac_dPres the derivatives of the phase component fractions in the domain wrt pressure (non-local) - * @param[in] dPhaseCompFrac_dCompFrac the derivatives of the phase component fractions in the domain wrt component fraction (non-local) + * @param[in] dPhaseCompFrac the derivatives of the phase component fractions in the domain wrt pressure and component fractions + *(non-local) * @param[in] elemDofNumber the dof number of the cell centered pressures (non-local) * @param[in] oneSidedVolFlux the total volumetric flux at this face * @param[out] upwPhaseViscCoef the upwind viscous transport coef at this face @@ -87,15 +86,13 @@ struct UpwindingHelper upwindViscousCoefficient( localIndex const (&localIds)[ 3 ], localIndex const (&neighborIds)[ 3 ], ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, real64 const & oneSidedVolFlux, real64 ( &upwPhaseViscCoef )[ NP ][ NC ], @@ -109,15 +106,16 @@ struct UpwindingHelper * @param[in] neighborIds region, subRegion, and element indices of the neigbhbor element * @param[in] transGravCoef * @param[in] phaseDens the phase densities in the domain (non-local) - * @param[in] dPhaseDens_dPres the derivatives of the phase densities in the domain wrt pressure (non-local) - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities in the domain wrt component fraction (non-local) + * @param[in] dPhaseDens the derivatives of the phase densities in the domain wrt pressure and component fractions (non-local) + * @param[in] phaseMassDens the phase mass densities in the domain (non-local) + * @param[in] dPhaseMassDens the derivatives of the phase mass densities in the domain wrt pressure and component fractions (non-local) * @param[in] phaseMob the phase mobilities in the domain (non-local) * @param[in] dPhaseMob_dPres the derivatives of the phase mobilities in the domain wrt pressure (non-local) * @param[in] dPhaseMob_dCompDens the derivatives of the phase mobilities in the domain wrt component fraction (non-local) * @param[in] dCompFrac_dCompDens the derivatives of the component fraction in the domain wrt component density (non-local) * @param[in] phaseCompFrac the phase component fractions in the domain (non-local) - * @param[in] dPhaseCompFrac_dPres the derivatives of the phase component fractions in the domain wrt pressure (non-local) - * @param[in] dPhaseCompFrac_dCompFrac the derivatives of the phase component fractions in the domain wrt component fraction (non-local) + * @param[in] dPhaseCompFrac the derivatives of the phase component fractions in the domain wrt pressure and component fractions + *(non-local) * @param[in] elemDofNumber the dof number of the cell centered pressures (non-local) * @param[inout] phaseGravTerm the gravCoef multiplied by the difference in phase densities * @param[inout] dPhaseGravTerm_dPres the derivatives of the gravCoef multiplied by the difference in phase densities wrt pressure @@ -134,18 +132,15 @@ struct UpwindingHelper localIndex const (&neighborIds)[ 3 ], real64 const & transGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, real64 ( &phaseGravTerm )[ NP ][ NP-1 ], real64 ( &dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], real64 ( &dPhaseGravTerm_dCompDens )[ NP ][ NP-1 ][ 2 ][ NC ], @@ -160,8 +155,7 @@ struct UpwindingHelper * @param[in] neighborIds region, subRegion, and element indices of the neigbhbor element * @param[in] transGravCoef * @param[in] phaseDens the phase densities in the domain (non-local) - * @param[in] dPhaseDens_dPres the derivatives of the phase densities in the domain wrt pressure (non-local) - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities in the domain wrt component fraction (non-local) + * @param[in] dPhaseDens the derivatives of the phase densities in the domain wrt pressure and component fractions (non-local) * @param[in] dCompFrac_dCompDens the derivatives of the component fraction in the domain wrt component density (non-local) * @param[inout] phaseGravTerm the gravCoef multiplied by the difference in phase densities * @param[inout] dPhaseGravTerm_dPres the derivatives of the gravCoef multiplied by the difference in phase densities wrt pressure @@ -175,8 +169,7 @@ struct UpwindingHelper localIndex const (&neighborIds)[ 3 ], real64 const & transGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, real64 ( &phaseGravTerm )[ NP ][ NP-1 ], real64 ( &dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], @@ -275,8 +268,7 @@ struct AssemblerKernelHelper * @param[in] dElemPres the accumulated pressure updates at this element's center * @param[in] elemGravCoef the depth at this element's center * @param[in] phaseDens the phase densities in the element - * @param[in] dPhaseDens_dPres the derivatives of the phase densities in the element wrt pressure - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities in the element wrt component fraction + * @param[in] dPhaseDens the derivatives of the phase densities in the element wrt pressure and component fractions * @param[in] phaseMob the phase mobilities in the element * @param[in] dPhaseMob_dPres the derivatives of the phase mobilities in the element wrt pressure * @param[in] dPhaseMob_dCompDens the derivatives of the phase mobilities in the element wrt component fraction @@ -298,8 +290,7 @@ struct AssemblerKernelHelper real64 const & dElemPres, real64 const & elemGravCoef, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & elemPhaseMassDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dElemPhaseMassDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dElemPhaseMassDens_dCompFrac, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dElemPhaseMassDens, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & elemPhaseMob, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dElemPhaseMob_dPres, arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dElemPhaseMob_dCompDens, @@ -321,15 +312,13 @@ struct AssemblerKernelHelper * @param[in] regionFilter set of target regions of the solver * @param[in] elemToFaces the map from one-sided face to face * @param[in] phaseDens phaseDens the phase densities in the domain - * @param[in] dPhaseDens_dPres the derivatives of the phase densities wrt pressure - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities wrt component fraction + * @param[in] dPhaseDens the derivatives of the phase densities wrt pressure and component fractions * @param[in] phaseMob the phase mobilities in the domain * @param[in] dPhaseMob_dPres the derivatives of the phase mobilities in the element wrt pressure * @param[in] dPhaseMob_dCompDens the derivatives of the phase mobilities in the element wrt component density * @param[in] dCompFrac_dCompDens the derivatives of the component fractions wrt component density * @param[in] phaseCompFrac the phase component fractions in the domain - * @param[in] dPhaseCompFrac_dPres the derivatives of the phase component fractions wrt pressure - * @param[in] dPhaseCompFrac_dCompFrac the derivatives of the phase component fractions wrt component fractions + * @param[in] dPhaseCompFrac the derivatives of the phase component fractions wrt pressure and component fractions * @param[in] elemDofNumber the dof numbers of the element in the domain * @param[in] oneSidedVolFlux the volumetric fluxes at this element's faces * @param[in] dOneSidedVolFlux_dPres the derivatives of the vol fluxes wrt to this element's cell centered pressure @@ -353,18 +342,15 @@ struct AssemblerKernelHelper arraySlice1d< localIndex const > const & elemToFaces, real64 const & elemGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, arraySlice2d< real64 const > const & transMatrixGrav, real64 const (&oneSidedVolFlux)[ NF ], @@ -513,15 +499,14 @@ struct AssemblerKernel * @param[in] dElemPres the accumulated pressure updates at this element's center * @param[in] elemGravCoef the depth at this element's center * @param[in] phaseDens the phase densities in the domain (non-local) - * @param[in] dPhaseDens_dPres the derivatives of the phase densities in the domain wrt pressure (non-local) - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities in the domain wrt component fraction (non-local) + * @param[in] dPhaseDens the derivatives of the phase densities in the domain wrt pressure and component fractions (non-local) * @param[in] phaseMob the phase mobilities in the domain (non-local) * @param[in] dPhaseMob_dPres the derivatives of the phase mobilities in the domain wrt pressure (non-local) * @param[in] dPhaseMob_dCompDens the derivatives of the phase mobilities in the domain wrt component fraction (non-local) * @param[in] dCompFrac_dCompDens the derivatives of the component fraction in the domain wrt component density (non-local) * @param[in] phaseCompFrac the phase component fractions in the domain (non-local) - * @param[in] dPhaseCompFrac_dPres the derivatives of the phase component fractions in the domain wrt pressure (non-local) - * @param[in] dPhaseCompFrac_dCompFrac the derivatives of the phase component fractions in the domain wrt component fraction (non-local) + * @param[in] dPhaseCompFrac the derivatives of the phase component fractions in the domain wrt pressure and component fractions + *(non-local) * @param[in] elemDofNumber the dof number of the cell centered pressures (non-local) * @param[in] elemGhostRank the ghost rank of the element in which we assemble the fluxes * @param[in] rankOffset the offset of this rank @@ -550,18 +535,15 @@ struct AssemblerKernel real64 const & dElemPres, real64 const & elemGravCoef, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, integer const elemGhostRank, globalIndex const rankOffset, @@ -597,14 +579,11 @@ struct FluxKernel using MultiFluidAccessors = StencilMaterialAccessors< MultiFluidBase, extrinsicMeshData::multifluid::phaseDensity, - extrinsicMeshData::multifluid::dPhaseDensity_dPressure, - extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction, + extrinsicMeshData::multifluid::dPhaseDensity, extrinsicMeshData::multifluid::phaseMassDensity, - extrinsicMeshData::multifluid::dPhaseMassDensity_dPressure, - extrinsicMeshData::multifluid::dPhaseMassDensity_dGlobalCompFraction, + extrinsicMeshData::multifluid::dPhaseMassDensity, extrinsicMeshData::multifluid::phaseCompFraction, - extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure, - extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction >; + extrinsicMeshData::multifluid::dPhaseCompFraction >; /** @@ -629,15 +608,14 @@ struct FluxKernel * @param[in] dElemPres the accumulated pressure updates at this element's center * @param[in] elemGravDepth the depth at this element's center * @param[in] phaseDens the phase densities in the domain (non-local) - * @param[in] dPhaseDens_dPres the derivatives of the phase densities in the domain wrt pressure (non-local) - * @param[in] dPhaseDens_dCompFrac the derivatives of the phase densities in the domain wrt component fraction (non-local) + * @param[in] dPhaseDens the derivatives of the phase densities in the domain wrt pressure and component fractions (non-local) * @param[in] phaseMob the phase mobilities in the domain (non-local) * @param[in] dPhaseMob_dPres the derivatives of the phase mobilities in the domain wrt pressure (non-local) * @param[in] dPhaseMob_dCompDens the derivatives of the phase mobilities in the domain wrt component fraction (non-local) * @param[in] dCompFrac_dCompDens the derivatives of the component fraction in the domain wrt component density (non-local) * @param[in] phaseCompFrac the phase component fractions in the domain (non-local) - * @param[in] dPhaseCompFrac_dPres the derivatives of the phase component fractions in the domain wrt pressure (non-local) - * @param[in] dPhaseCompFrac_dCompFrac the derivatives of the phase component fractions in the domain wrt component fraction (non-local) + * @param[in] dPhaseCompFrac the derivatives of the phase component fractions in the domain wrt pressure and component fractions + *(non-local) * @param[in] elemDofNumber the dof number of the cell centered pressures (non-local) * @param[in] rankOffset the offset of this rank * @param[in] lengthTolerance tolerance used in the transmissibility matrix computation @@ -668,14 +646,11 @@ struct FluxKernel ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dCompDens, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dCompFrac, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dCompFrac, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac, ElementViewConst< arrayView1d< globalIndex const > > const & elemDofNumber, globalIndex const rankOffset, real64 const lengthTolerance, @@ -720,8 +695,7 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK m_dPhaseVolFrac_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >() ), m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ), m_phaseVisc( fluid.phaseViscosity() ), - m_dPhaseVisc_dPres( fluid.dPhaseViscosity_dPressure() ), - m_dPhaseVisc_dComp( fluid.dPhaseViscosity_dGlobalCompFraction() ), + m_dPhaseVisc( fluid.dPhaseViscosity() ), m_phaseRelPerm( relperm.phaseRelPerm() ), m_dPhaseRelPerm_dPhaseVolFrac( relperm.dPhaseRelPerm_dPhaseVolFraction() ), m_phaseMob( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobility >() ), @@ -740,10 +714,11 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK void compute( localIndex const ei, FUNC && phaseMobilityKernelOp = CompositionalMultiphaseBaseKernels::NoOpFunc{} ) const { + using namespace multifluid; + arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseVisc = m_phaseVisc[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseVisc_dPres = m_dPhaseVisc_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc_dComp = m_dPhaseVisc_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc = m_dPhaseVisc[ei][0]; arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const phaseRelPerm = m_phaseRelPerm[ei][0]; arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const dPhaseRelPerm_dPhaseVolFrac = m_dPhaseRelPerm_dPhaseVolFrac[ei][0]; arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const phaseVolFrac = m_phaseVolFrac[ei]; @@ -772,8 +747,8 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK } real64 const viscosity = phaseVisc[ip]; - real64 const dVisc_dP = dPhaseVisc_dPres[ip]; - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); + real64 const dVisc_dP = dPhaseVisc[ip][Deriv::dP]; + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseVisc[ip], dVisc_dC, Deriv::dC ); real64 const relPerm = phaseRelPerm[ip]; real64 dRelPerm_dP = 0.0; @@ -825,8 +800,7 @@ class PhaseMobilityKernel : public CompositionalMultiphaseBaseKernels::PropertyK /// Views on the phase viscosities arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseVisc; - arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseVisc_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseVisc_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseVisc; /// Views on the phase relative permeabilities arrayView3d< real64 const, relperm::USD_RELPERM > m_phaseRelPerm; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp index 72164c194d2..e61a4319892 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp @@ -273,7 +273,7 @@ void compareMultiphaseModels( MODEL1_TYPE const & lhs, MODEL2_TYPE const & rhs ) GEOSX_FMT( "Mismatch in number of phases between constitutive models {} and {}", lhs.getName(), rhs.getName() ), InputError ); - for( localIndex ip = 0; ip < lhs.numFluidPhases(); ++ip ) + for( integer ip = 0; ip < lhs.numFluidPhases(); ++ip ) { GEOSX_THROW_IF_NE_MSG( lhs.phaseNames()[ip], rhs.phaseNames()[ip], GEOSX_FMT( "Mismatch in phase names between constitutive models {} and {}", lhs.getName(), rhs.getName() ), @@ -288,7 +288,7 @@ void compareMulticomponentModels( MODEL1_TYPE const & lhs, MODEL2_TYPE const & r GEOSX_FMT( "Mismatch in number of components between constitutive models {} and {}", lhs.getName(), rhs.getName() ), InputError ); - for( localIndex ic = 0; ic < lhs.numFluidComponents(); ++ic ) + for( integer ic = 0; ic < lhs.numFluidComponents(); ++ic ) { GEOSX_THROW_IF_NE_MSG( lhs.componentNames()[ic], rhs.componentNames()[ic], GEOSX_FMT( "Mismatch in component names between constitutive models {} and {}", lhs.getName(), rhs.getName() ), @@ -308,7 +308,7 @@ void CompositionalMultiphaseWell::validateInjectionStreams( WellElementSubRegion { arrayView1d< real64 const > const & injection = wellControls.getInjectionStream(); real64 compFracSum = 0; - for( localIndex ic = 0; ic < m_numComponents; ++ic ) + for( integer ic = 0; ic < m_numComponents; ++ic ) { real64 const compFrac = injection[ic]; GEOSX_THROW_IF( ( compFrac < 0.0 ) || ( compFrac > 1.0 ), @@ -373,7 +373,7 @@ void CompositionalMultiphaseWell::validateWellConstraints( WellElementSubRegion InputError ); // Find target phase index for phase rate constraint - for( localIndex ip = 0; ip < fluid.numFluidPhases(); ++ip ) + for( integer ip = 0; ip < fluid.numFluidPhases(); ++ip ) { if( fluid.phaseNames()[ip] == wellControls.getTargetPhaseName() ) { @@ -511,7 +511,7 @@ void CompositionalMultiphaseWell::updateBHPForConstraint( WellElementSubRegion & real64 const diffGravCoef = refGravCoef - wellElemGravCoef[iwelemRef]; currentBHP = pres[iwelemRef] + dPres[iwelemRef] + totalMassDens[iwelemRef] * diffGravCoef; dCurrentBHP_dPres = 1 + dTotalMassDens_dPres[iwelemRef] * diffGravCoef; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { dCurrentBHP_dCompDens[ic] = dTotalMassDens_dCompDens[iwelemRef][ic] * diffGravCoef; } @@ -522,6 +522,8 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg { GEOSX_MARK_FUNCTION; + using namespace multifluid; + // the rank that owns the reference well element is responsible for the calculations below. if( !subRegion.isLocallyOwned() ) { @@ -559,16 +561,13 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg MultiFluidBase & fluid = subRegion.getConstitutiveModel< MultiFluidBase >( fluidName ); arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseFrac = fluid.phaseFraction(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dPres = fluid.dPhaseFraction_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp = fluid.dPhaseFraction_dGlobalCompFraction(); + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseFrac = fluid.dPhaseFraction(); arrayView2d< real64 const, multifluid::USD_FLUID > const & totalDens = fluid.totalDensity(); - arrayView2d< real64 const, multifluid::USD_FLUID > const & dTotalDens_dPres = fluid.dTotalDensity_dPressure(); - arrayView3d< real64 const, multifluid::USD_FLUID_DC > const & dTotalDens_dComp = fluid.dTotalDensity_dGlobalCompFraction(); + arrayView3d< real64 const, multifluid::USD_FLUID_DC > const & dTotalDens = fluid.dTotalDensity(); arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens = fluid.phaseDensity(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens = fluid.dPhaseDensity(); // control data @@ -612,14 +611,11 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg connRate, dConnRate, totalDens, - dTotalDens_dPres, - dTotalDens_dComp, + dTotalDens, phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, + dPhaseDens, phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dComp, + dPhaseFrac, &useSurfaceConditions, &surfacePres, &surfaceTemp, @@ -658,11 +654,11 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg // Step 2.1: compute the inverse of the total density and derivatives real64 const totalDensInv = 1.0 / totalDens[iwelemRef][0]; - real64 const dTotalDensInv_dPres = -dTotalDens_dPres[iwelemRef][0] * totalDensInv * totalDensInv; + real64 const dTotalDensInv_dPres = -dTotalDens[iwelemRef][0][Deriv::dP] * totalDensInv * totalDensInv; stackArray1d< real64, maxNumComp > dTotalDensInv_dCompDens( numComp ); - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { - dTotalDensInv_dCompDens[ic] = -dTotalDens_dComp[iwelemRef][0][ic] * totalDensInv * totalDensInv; + dTotalDensInv_dCompDens[ic] = -dTotalDens[iwelemRef][0][Deriv::dC+ic] * totalDensInv * totalDensInv; } applyChainRuleInPlace( numComp, dCompFrac_dCompDens[iwelemRef], dTotalDensInv_dCompDens, work.data() ); @@ -670,13 +666,13 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg currentTotalVolRate = currentTotalRate * totalDensInv; dCurrentTotalVolRate_dPres = ( useSurfaceConditions == 0 ) * currentTotalRate * dTotalDensInv_dPres; dCurrentTotalVolRate_dRate = totalDensInv; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { dCurrentTotalVolRate_dCompDens[ic] = currentTotalRate * dTotalDensInv_dCompDens[ic]; } // Step 3: update the phase volume rate - for( localIndex ip = 0; ip < numPhase; ++ip ) + for( integer ip = 0; ip < numPhase; ++ip ) { // Step 3.1: compute the inverse of the (phase density * phase fraction) and derivatives @@ -690,18 +686,18 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg real64 const phaseDensInv = 1.0 / phaseDens[iwelemRef][0][ip]; real64 const phaseFracTimesPhaseDensInv = phaseFrac[iwelemRef][0][ip] * phaseDensInv; - real64 const dPhaseFracTimesPhaseDensInv_dPres = dPhaseFrac_dPres[iwelemRef][0][ip] * phaseDensInv - - dPhaseDens_dPres[iwelemRef][0][ip] * phaseFracTimesPhaseDensInv * phaseDensInv; + real64 const dPhaseFracTimesPhaseDensInv_dPres = dPhaseFrac[iwelemRef][0][ip][Deriv::dP] * phaseDensInv + - dPhaseDens[iwelemRef][0][ip][Deriv::dP] * phaseFracTimesPhaseDensInv * phaseDensInv; // Step 3.2: divide the total mass/molar rate by the (phase density * phase fraction) to get the phase volumetric rate currentPhaseVolRate[ip] = currentTotalRate * phaseFracTimesPhaseDensInv; dCurrentPhaseVolRate_dPres[ip] = ( useSurfaceConditions == 0 ) * currentTotalRate * dPhaseFracTimesPhaseDensInv_dPres; dCurrentPhaseVolRate_dRate[ip] = phaseFracTimesPhaseDensInv; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { - dCurrentPhaseVolRate_dCompDens[ip][ic] = -phaseFracTimesPhaseDensInv * dPhaseDens_dComp[iwelemRef][0][ip][ic] * phaseDensInv; - dCurrentPhaseVolRate_dCompDens[ip][ic] += dPhaseFrac_dComp[iwelemRef][0][ip][ic] * phaseDensInv; + dCurrentPhaseVolRate_dCompDens[ip][ic] = -phaseFracTimesPhaseDensInv * dPhaseDens[iwelemRef][0][ip][Deriv::dC+ic] * phaseDensInv; + dCurrentPhaseVolRate_dCompDens[ip][ic] += dPhaseFrac[iwelemRef][0][ip][Deriv::dC+ic] * phaseDensInv; dCurrentPhaseVolRate_dCompDens[ip][ic] *= currentTotalRate; } applyChainRuleInPlace( numComp, dCompFrac_dCompDens[iwelemRef], dCurrentPhaseVolRate_dCompDens[ip], work.data() ); @@ -1024,11 +1020,9 @@ void CompositionalMultiphaseWell::assembleAccumulationTerms( DomainPartition con string const & fluidName = subRegion.getReference< string >( viewKeyStruct::fluidNamesString() ); MultiFluidBase const & fluid = subRegion.getConstitutiveModel< MultiFluidBase >( fluidName ); arrayView3d< real64 const, multifluid::USD_PHASE > const & wellElemPhaseDens = fluid.phaseDensity(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens = fluid.dPhaseDensity(); arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & wellElemPhaseCompFrac = fluid.phaseCompFraction(); - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dWellElemPhaseCompFrac_dPres = fluid.dPhaseCompFraction_dPressure(); - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac_dComp = fluid.dPhaseCompFraction_dGlobalCompFraction(); + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac = fluid.dPhaseCompFraction(); CompositionalMultiphaseBaseKernels:: KernelLaunchSelector1< AccumulationKernel >( numFluidComponents(), @@ -1043,11 +1037,9 @@ void CompositionalMultiphaseWell::assembleAccumulationTerms( DomainPartition con dWellElemPhaseVolFrac_dComp, dWellElemCompFrac_dCompDens, wellElemPhaseDens, - dWellElemPhaseDens_dPres, - dWellElemPhaseDens_dComp, + dWellElemPhaseDens, wellElemPhaseCompFrac, - dWellElemPhaseCompFrac_dPres, - dWellElemPhaseCompFrac_dComp, + dWellElemPhaseCompFrac, wellElemPhaseVolFracOld, wellElemPhaseDensOld, wellElemPhaseCompFracOld, @@ -1384,14 +1376,11 @@ void CompositionalMultiphaseWell::computePerforationRates( MeshLevel const & mes resCompFlowAccessors.get( extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity{} ), resCompFlowAccessors.get( extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity{} ), resMultiFluidAccessors.get( extrinsicMeshData::multifluid::phaseDensity{} ), - resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity_dPressure{} ), - resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction{} ), + resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseDensity{} ), resMultiFluidAccessors.get( extrinsicMeshData::multifluid::phaseViscosity{} ), - resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseViscosity_dPressure{} ), - resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseViscosity_dGlobalCompFraction{} ), + resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseViscosity{} ), resMultiFluidAccessors.get( extrinsicMeshData::multifluid::phaseCompFraction{} ), - resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure{} ), - resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction{} ), + resMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction{} ), resRelPermAccessors.get( extrinsicMeshData::relperm::phaseRelPerm{} ), resRelPermAccessors.get( extrinsicMeshData::relperm::dPhaseRelPerm_dPhaseVolFraction{} ), wellElemGravCoef, @@ -1486,7 +1475,7 @@ void CompositionalMultiphaseWell::chopNegativeDensities( DomainPartition & domai { if( wellElemGhostRank[iwelem] < 0 ) { - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { // get the latest component density (i.e., after the update of dWellElemCompDens) real64 const newDens = wellElemCompDens[iwelem][ic] + dWellElemCompDens[iwelem][ic]; @@ -1533,7 +1522,7 @@ void CompositionalMultiphaseWell::resetStateToBeginningOfStep( DomainPartition & // extract solution and apply to dP dWellElemPressure[iwelem] = 0; dConnRate[iwelem] = 0; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { dWellElemGlobalCompDensity[iwelem][ic] = 0; } @@ -1588,12 +1577,12 @@ void CompositionalMultiphaseWell::backupFields( MeshLevel & mesh, arrayView1d< s wellElemTotalDensOld[ei] = wellElemTotalDens[ei][0]; - for( localIndex ip = 0; ip < numPhase; ++ip ) + for( integer ip = 0; ip < numPhase; ++ip ) { wellElemPhaseDensOld[ei][ip] = wellElemPhaseDens[ei][0][ip]; wellElemPhaseVolFracOld[ei][ip] = wellElemPhaseVolFrac[ei][ip]; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { wellElemPhaseCompFracOld[ei][ip][ic] = wellElemPhaseCompFrac[ei][0][ip][ic]; } @@ -1764,7 +1753,7 @@ void CompositionalMultiphaseWell::implicitStepComplete( real64 const & GEOSX_UNU forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { wellElemPressure[iwelem] += dWellElemPressure[iwelem]; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { wellElemGlobalCompDensity[iwelem][ic] += dWellElemGlobalCompDensity[iwelem][ic]; } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp index 344ac09aa04..a9c03cb2a6b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp @@ -35,7 +35,7 @@ void ControlEquationHelper:: switchControl( WellControls::Type const & wellType, WellControls::Control const & currentControl, - localIndex const phasePhaseIndex, + integer const phasePhaseIndex, real64 const & targetBHP, real64 const & targetPhaseRate, real64 const & targetTotalRate, @@ -108,13 +108,13 @@ ControlEquationHelper:: } } -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void ControlEquationHelper:: compute( globalIndex const rankOffset, WellControls::Control const currentControl, - localIndex const targetPhaseIndex, + integer const targetPhaseIndex, real64 const & targetBHP, real64 const & targetPhaseRate, real64 const & targetTotalRate, @@ -138,7 +138,7 @@ ControlEquationHelper:: globalIndex const rateDofColIndex = dofNumber + COFFSET::DCOMP + NC; globalIndex compDofColIndices[NC]{}; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compDofColIndices[ ic ] = presDofColIndex + ic + 1; } @@ -160,7 +160,7 @@ ControlEquationHelper:: // control equation is a difference between current BHP and target BHP controlEqn = currentBHP - targetBHP; dControlEqn_dPres = dCurrentBHP_dPres; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dControlEqn_dComp[ic] = dCurrentBHP_dCompDens[ic]; } @@ -171,7 +171,7 @@ ControlEquationHelper:: controlEqn = currentPhaseVolRate[targetPhaseIndex] - targetPhaseRate; dControlEqn_dPres = dCurrentPhaseVolRate_dPres[targetPhaseIndex]; dControlEqn_dRate = dCurrentPhaseVolRate_dRate[targetPhaseIndex]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dControlEqn_dComp[ic] = dCurrentPhaseVolRate_dCompDens[targetPhaseIndex][ic]; } @@ -182,7 +182,7 @@ ControlEquationHelper:: controlEqn = currentTotalVolRate - targetTotalRate; dControlEqn_dPres = dCurrentTotalVolRate_dPres; dControlEqn_dRate = dCurrentTotalVolRate_dRate; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dControlEqn_dComp[ic] = dCurrentTotalVolRate_dCompDens[ic]; } @@ -208,7 +208,7 @@ ControlEquationHelper:: /******************************** FluxKernel ********************************/ -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void FluxKernel:: @@ -221,7 +221,7 @@ FluxKernel:: real64 ( & oneSidedFluxJacobian_dRate )[NC][1], real64 ( & oneSidedFluxJacobian_dPresCompUp )[NC][NC + 1] ) { - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { oneSidedFlux[ic] = -dt * compFlux[ic]; @@ -232,14 +232,14 @@ FluxKernel:: oneSidedFluxJacobian_dPresCompUp[ic][0] = -dt * dCompFlux_dPresUp[ic]; // derivatives with respect to upstream component densities - for( localIndex jdof = 0; jdof < NC; ++jdof ) + for( integer jdof = 0; jdof < NC; ++jdof ) { oneSidedFluxJacobian_dPresCompUp[ic][jdof+1] = -dt * dCompFlux_dCompDensUp[ic][jdof]; } } } -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void FluxKernel:: @@ -253,7 +253,7 @@ FluxKernel:: real64 ( & localFluxJacobian_dPresCompUp )[2*NC][NC + 1] ) { // flux terms - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { localFlux[TAG::NEXT *NC+ic] = dt * compFlux[ic]; localFlux[TAG::CURRENT *NC+ic] = -dt * compFlux[ic]; @@ -267,7 +267,7 @@ FluxKernel:: localFluxJacobian_dPresCompUp[TAG::CURRENT *NC+ic][0] = -dt * dCompFlux_dPresUp[ic]; // derivatives with respect to upstream component densities - for( localIndex jdof = 0; jdof < NC; ++jdof ) + for( integer jdof = 0; jdof < NC; ++jdof ) { localFluxJacobian_dPresCompUp[TAG::NEXT *NC+ic][jdof+1] = dt * dCompFlux_dCompDensUp[ic][jdof]; localFluxJacobian_dPresCompUp[TAG::CURRENT *NC+ic][jdof+1] = -dt * dCompFlux_dCompDensUp[ic][jdof]; @@ -275,7 +275,7 @@ FluxKernel:: } } -template< localIndex NC > +template< integer NC > void FluxKernel:: launch( localIndex const size, @@ -328,10 +328,10 @@ FluxKernel:: iwelemUp = iwelem; // just copy the injection stream into compFrac - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compFracUp[ic] = injection[ic]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompFrac_dCompDensUp[ic][jc] = 0.0; } @@ -351,10 +351,10 @@ FluxKernel:: } // copy the vars of iwelemUp into compFrac - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compFracUp[ic] = wellElemCompFrac[iwelemUp][ic]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompFrac_dCompDensUp[ic][jc] = dWellElemCompFrac_dCompDens[iwelemUp][ic][jc]; } @@ -363,12 +363,12 @@ FluxKernel:: // Step 2) compute upstream transport coefficient - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compFlux[ic] = compFracUp[ic] * currentConnRate; dCompFlux_dRate[ic] = compFracUp[ic]; dCompFlux_dPresUp[ic] = 0.0; // none of these quantities depend on pressure - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompFlux_dCompDensUp[ic][jc] = dCompFrac_dCompDensUp[ic][jc] * currentConnRate; } @@ -400,7 +400,7 @@ FluxKernel:: globalIndex oneSidedDofColIndices_dRate = 0; // jacobian indices - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { // mass balance equations for all components oneSidedEqnRowIndices[ic] = offsetUp + ROFFSET::MASSBAL + ic - rankOffset; @@ -411,19 +411,19 @@ FluxKernel:: localIndex const dRateColOffset = COFFSET::DCOMP + NC; oneSidedDofColIndices_dRate = offsetCurrent + dRateColOffset; - for( localIndex jdof = 0; jdof < NC+1; ++jdof ) + for( integer jdof = 0; jdof < NC+1; ++jdof ) { // dofs are the **upstream** pressure and component densities oneSidedDofColIndices_dPresCompUp[jdof] = offsetUp + COFFSET::DPRES + jdof; } // Apply equation/variable change transformation(s) - real64 work[NC+1]; + real64 work[NC+1]{}; shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, 1, oneSidedFluxJacobian_dRate, work ); shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, NC + 1, oneSidedFluxJacobian_dPresCompUp, work ); shiftElementsAheadByOneAndReplaceFirstElementWithSum( NC, oneSidedFlux ); - for( localIndex i = 0; i < NC; ++i ) + for( integer i = 0; i < NC; ++i ) { if( oneSidedEqnRowIndices[i] >= 0 && oneSidedEqnRowIndices[i] < localMatrix.numRows() ) { @@ -462,7 +462,7 @@ FluxKernel:: globalIndex const offsetNext = wellElemDofNumber[iwelemNext]; // jacobian indices - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { // mass balance equations for all components eqnRowIndices[TAG::NEXT *NC+ic] = offsetNext + ROFFSET::MASSBAL + ic - rankOffset; @@ -474,19 +474,19 @@ FluxKernel:: localIndex const dRateColOffset = COFFSET::DCOMP + NC; dofColIndices_dRate = offsetCurrent + dRateColOffset; - for( localIndex jdof = 0; jdof < NC+1; ++jdof ) + for( integer jdof = 0; jdof < NC+1; ++jdof ) { // dofs are the **upstream** pressure and component densities dofColIndices_dPresCompUp[jdof] = offsetUp + COFFSET::DPRES + jdof; } // Apply equation/variable change transformation(s) - real64 work[NC+1]; + real64 work[NC+1]{}; shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, 1, 2, localFluxJacobian_dRate, work ); shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, NC + 1, 2, localFluxJacobian_dPresCompUp, work ); shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( NC, 2, localFlux ); - for( localIndex i = 0; i < 2*NC; ++i ) + for( integer i = 0; i < 2*NC; ++i ) { if( eqnRowIndices[i] >= 0 && eqnRowIndices[i] < localMatrix.numRows() ) { @@ -529,7 +529,7 @@ INST_FluxKernel( 5 ); /******************************** PressureRelationKernel ********************************/ -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void PressureRelationKernel:: @@ -556,7 +556,7 @@ PressureRelationKernel:: real64 const avgMassDens = 0.5 * ( totalMassDensNext + totalMassDens ); real64 const dAvgMassDens_dPresNext = 0.5 * dTotalMassDens_dPresNext; real64 const dAvgMassDens_dPresCurrent = 0.5 * dTotalMassDens_dPres; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dAvgMassDens_dCompNext[ic] = 0.5 * dTotalMassDens_dCompDensNext[ic]; dAvgMassDens_dCompCurrent[ic] = 0.5 * dTotalMassDens_dCompDens[ic]; @@ -571,21 +571,21 @@ PressureRelationKernel:: localPresRelJacobian[TAG::NEXT *(NC+1)] = ( 1 - dAvgMassDens_dPresNext * gravD ); localPresRelJacobian[TAG::CURRENT *(NC+1)] = ( -1 - dAvgMassDens_dPresCurrent * gravD ); - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { localPresRelJacobian[TAG::NEXT *(NC+1) + ic+1] = -dAvgMassDens_dCompNext[ic] * gravD; localPresRelJacobian[TAG::CURRENT *(NC+1) + ic+1] = -dAvgMassDens_dCompCurrent[ic] * gravD; } } -template< localIndex NC > +template< integer NC > void PressureRelationKernel:: launch( localIndex const size, globalIndex const rankOffset, bool const isLocallyOwned, localIndex const iwelemControl, - localIndex const targetPhaseIndex, + integer const targetPhaseIndex, WellControls const & wellControls, real64 const & timeAtEndOfStep, arrayView1d< globalIndex const > const & wellElemDofNumber, @@ -712,7 +712,7 @@ PressureRelationKernel:: dofColIndices[TAG::NEXT *(NC+1)] = wellElemDofNumber[iwelemNext] + COFFSET::DPRES; dofColIndices[TAG::CURRENT *(NC+1)] = wellElemDofNumber[iwelem] + COFFSET::DPRES; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dofColIndices[TAG::NEXT *(NC+1) + ic+1] = wellElemDofNumber[iwelemNext] + COFFSET::DCOMP + ic; dofColIndices[TAG::CURRENT *(NC+1) + ic+1] = wellElemDofNumber[iwelem] + COFFSET::DCOMP + ic; @@ -738,7 +738,7 @@ PressureRelationKernel:: globalIndex const rankOffset, \ bool const isLocallyOwned, \ localIndex const iwelemControl, \ - localIndex const targetPhaseIndex, \ + integer const targetPhaseIndex, \ WellControls const & wellControls, \ real64 const & timeAtEndOfStep, \ arrayView1d< globalIndex const > const & wellElemDofNumber, \ @@ -762,7 +762,7 @@ INST_PressureRelationKernel( 5 ); /******************************** PerforationKernel ********************************/ -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > GEOSX_HOST_DEVICE void PerforationKernel:: @@ -773,14 +773,11 @@ PerforationKernel:: arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dResPhaseVolFrac_dComp, arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dResCompFrac_dCompDens, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & resPhaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dResPhaseDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseDens_dComp, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseDens, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & resPhaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dResPhaseVisc_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseVisc_dComp, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseVisc, arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & resPhaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & dResPhaseCompFrac_dPres, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dResPhaseCompFrac_dComp, + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dResPhaseCompFrac, arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & resPhaseRelPerm, arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dResPhaseRelPerm_dPhaseVolFrac, real64 const & wellElemGravCoef, @@ -799,6 +796,7 @@ PerforationKernel:: arraySlice2d< real64 > const & dCompPerfRate_dPres, arraySlice3d< real64 > const & dCompPerfRate_dComp ) { + using namespace multifluid; // local working variables and arrays real64 pres[2]{}; @@ -822,13 +820,13 @@ PerforationKernel:: // Step 1: reset the perforation rates - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compPerfRate[ic] = 0.0; - for( localIndex ke = 0; ke < 2; ++ke ) + for( integer ke = 0; ke < 2; ++ke ) { dCompPerfRate_dPres[ke][ic] = 0.0; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompPerfRate_dComp[ke][ic][jc] = 0.0; } @@ -858,7 +856,7 @@ PerforationKernel:: pres[TAG::WELL] += wellElemTotalMassDens * gravD; dPres_dP[TAG::WELL] += dWellElemTotalMassDens_dPres * gravD; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dPres_dC[TAG::WELL][ic] += dWellElemTotalMassDens_dCompDens[ic] * gravD; } @@ -867,12 +865,12 @@ PerforationKernel:: // Step 3: compute potential difference real64 potDiff = 0.0; - for( localIndex i = 0; i < 2; ++i ) + for( integer i = 0; i < 2; ++i ) { potDiff += multiplier[i] * trans * pres[i]; dPotDiff_dP[i] += multiplier[i] * trans * dPres_dP[i]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dPotDiff_dC[i][ic] += multiplier[i] * trans * dPres_dC[i][ic]; } @@ -887,7 +885,7 @@ PerforationKernel:: // loop over phases, compute and upwind phase flux // and sum contributions to each component's perforation rate - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { // skip the rest of the calculation if the phase is absent @@ -901,32 +899,34 @@ PerforationKernel:: // density real64 const resDens = resPhaseDens[ip]; - real64 const dResDens_dP = dResPhaseDens_dPres[ip]; + real64 const dResDens_dP = dResPhaseDens[ip][Deriv::dP]; applyChainRule( NC, dResCompFrac_dCompDens, - dResPhaseDens_dComp[ip], - dDens_dC ); + dResPhaseDens[ip], + dDens_dC, + Deriv::dC ); // viscosity real64 const resVisc = resPhaseVisc[ip]; - real64 const dResVisc_dP = dResPhaseVisc_dPres[ip]; + real64 const dResVisc_dP = dResPhaseVisc[ip][Deriv::dP]; applyChainRule( NC, dResCompFrac_dCompDens, - dResPhaseVisc_dComp[ip], - dVisc_dC ); + dResPhaseVisc[ip], + dVisc_dC, + Deriv::dC ); // relative permeability real64 const resRelPerm = resPhaseRelPerm[ip]; real64 dResRelPerm_dP = 0.0; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dRelPerm_dC[jc] = 0; } - for( localIndex jp = 0; jp < NP; ++jp ) + for( integer jp = 0; jp < NP; ++jp ) { real64 const dResRelPerm_dS = dResPhaseRelPerm_dPhaseVolFrac[ip][jp]; dResRelPerm_dP += dResRelPerm_dS * dResPhaseVolFrac_dPres[jp]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dRelPerm_dC[jc] += dResRelPerm_dS * dResPhaseVolFrac_dComp[jp][jc]; } @@ -936,7 +936,7 @@ PerforationKernel:: real64 const resPhaseMob = resDens * resRelPerm / resVisc; real64 const dResPhaseMob_dPres = dResRelPerm_dP * resDens / resVisc + resPhaseMob * (dResDens_dP / resDens - dResVisc_dP / resVisc); - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dMob_dC[jc] = dRelPerm_dC[jc] * resDens / resVisc + resPhaseMob * (dDens_dC[jc] / resDens - dVisc_dC[jc] / resVisc); @@ -947,27 +947,28 @@ PerforationKernel:: dFlux_dP[TAG::RES] = dResPhaseMob_dPres * potDiff + resPhaseMob * dPotDiff_dP[TAG::RES]; dFlux_dP[TAG::WELL] = resPhaseMob * dPotDiff_dP[TAG::WELL]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dFlux_dC[TAG::RES][ic] = dMob_dC[ic] * potDiff + resPhaseMob * dPotDiff_dC[TAG::RES][ic]; dFlux_dC[TAG::WELL][ic] = resPhaseMob * dPotDiff_dC[TAG::WELL][ic]; } // increment component fluxes - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compPerfRate[ic] += flux * resPhaseCompFrac[ip][ic]; dCompPerfRate_dPres[TAG::RES][ic] += resPhaseCompFrac[ip][ic] * dFlux_dP[TAG::RES]; - dCompPerfRate_dPres[TAG::RES][ic] += dResPhaseCompFrac_dPres[ip][ic] * flux; + dCompPerfRate_dPres[TAG::RES][ic] += dResPhaseCompFrac[ip][ic][Deriv::dP] * flux; dCompPerfRate_dPres[TAG::WELL][ic] += resPhaseCompFrac[ip][ic] * dFlux_dP[TAG::WELL]; applyChainRule( NC, dResCompFrac_dCompDens, - dResPhaseCompFrac_dComp[ip][ic], - dCompFrac_dCompDens ); + dResPhaseCompFrac[ip][ic], + dCompFrac_dCompDens, + Deriv::dC ); - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompPerfRate_dComp[TAG::RES][ic][jc] += dFlux_dC[TAG::RES][jc] * resPhaseCompFrac[ip][ic]; dCompPerfRate_dComp[TAG::RES][ic][jc] += flux * dCompFrac_dCompDens[jc]; @@ -984,13 +985,13 @@ PerforationKernel:: // we re-compute here the total mass (when useMass == 1) or molar (when useMass == 0) density real64 wellElemTotalDens = 0; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { wellElemTotalDens += wellElemCompDens[ic] + dWellElemCompDens[ic]; } // first, compute the reservoir total mobility (excluding phase density) - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { // skip the rest of the calculation if the phase is absent @@ -1002,25 +1003,26 @@ PerforationKernel:: // viscosity real64 const resVisc = resPhaseVisc[ip]; - real64 const dResVisc_dP = dResPhaseVisc_dPres[ip]; + real64 const dResVisc_dP = dResPhaseVisc[ip][Deriv::dP]; applyChainRule( NC, dResCompFrac_dCompDens, - dResPhaseVisc_dComp[ip], - dVisc_dC ); + dResPhaseVisc[ip], + dVisc_dC, + Deriv::dC ); // relative permeability real64 const resRelPerm = resPhaseRelPerm[ip]; real64 dResRelPerm_dP = 0.0; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dRelPerm_dC[jc] = 0; } - for( localIndex jp = 0; jp < NP; ++jp ) + for( integer jp = 0; jp < NP; ++jp ) { real64 const dResRelPerm_dS = dResPhaseRelPerm_dPhaseVolFrac[ip][jp]; dResRelPerm_dP += dResRelPerm_dS * dResPhaseVolFrac_dPres[jp]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dRelPerm_dC[jc] += dResRelPerm_dS * dResPhaseVolFrac_dComp[jp][jc]; } @@ -1030,7 +1032,7 @@ PerforationKernel:: resTotalMob += resRelPerm / resVisc; dResTotalMob_dP += ( dResRelPerm_dP * resVisc - resRelPerm * dResVisc_dP ) / ( resVisc * resVisc ); - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dResTotalMob_dC[ic] += ( dRelPerm_dC[ic] * resVisc - resRelPerm * dVisc_dC[ic] ) / ( resVisc * resVisc ); @@ -1043,7 +1045,7 @@ PerforationKernel:: dMult_dP[TAG::RES] = wellElemTotalDens * dResTotalMob_dP; dMult_dP[TAG::WELL] = 0.0; // because totalDens does not depend on pressure - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dMult_dC[TAG::RES][ic] = wellElemTotalDens * dResTotalMob_dC[ic]; dMult_dC[TAG::WELL][ic] = resTotalMob; @@ -1054,20 +1056,20 @@ PerforationKernel:: dFlux_dP[TAG::RES] = dMult_dP[TAG::RES] * potDiff + mult * dPotDiff_dP[TAG::RES]; dFlux_dP[TAG::WELL] = dMult_dP[TAG::WELL] * potDiff + mult * dPotDiff_dP[TAG::WELL]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dFlux_dC[TAG::RES][ic] = dMult_dC[TAG::RES][ic] * potDiff + mult * dPotDiff_dC[TAG::RES][ic]; dFlux_dC[TAG::WELL][ic] = dMult_dC[TAG::WELL][ic] * potDiff + mult * dPotDiff_dC[TAG::WELL][ic]; } // compute component fluxes - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compPerfRate[ic] += wellElemCompFrac[ic] * flux; dCompPerfRate_dPres[TAG::RES][ic] = wellElemCompFrac[ic] * dFlux_dP[TAG::RES]; dCompPerfRate_dPres[TAG::WELL][ic] = wellElemCompFrac[ic] * dFlux_dP[TAG::WELL]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompPerfRate_dComp[TAG::RES][ic][jc] += wellElemCompFrac[ic] * dFlux_dC[TAG::RES][jc]; dCompPerfRate_dComp[TAG::WELL][ic][jc] += wellElemCompFrac[ic] * dFlux_dC[TAG::WELL][jc]; @@ -1077,7 +1079,7 @@ PerforationKernel:: } } -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > void PerforationKernel:: launch( localIndex const size, @@ -1088,14 +1090,11 @@ PerforationKernel:: ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dResPhaseVolFrac_dComp, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dResCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & resPhaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dResPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseDens_dComp, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & resPhaseVisc, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dResPhaseVisc_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseVisc_dComp, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseVisc, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & resPhaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dResPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dResPhaseCompFrac_dComp, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dResPhaseCompFrac, ElementViewConst< arrayView3d< real64 const, relperm::USD_RELPERM > > const & resPhaseRelPerm, ElementViewConst< arrayView4d< real64 const, relperm::USD_RELPERM_DS > > const & dResPhaseRelPerm_dPhaseVolFrac, arrayView1d< real64 const > const & wellElemGravCoef, @@ -1138,14 +1137,11 @@ PerforationKernel:: dResPhaseVolFrac_dComp[er][esr][ei], dResCompFrac_dCompDens[er][esr][ei], resPhaseDens[er][esr][ei][0], - dResPhaseDens_dPres[er][esr][ei][0], - dResPhaseDens_dComp[er][esr][ei][0], + dResPhaseDens[er][esr][ei][0], resPhaseVisc[er][esr][ei][0], - dResPhaseVisc_dPres[er][esr][ei][0], - dResPhaseVisc_dComp[er][esr][ei][0], + dResPhaseVisc[er][esr][ei][0], resPhaseCompFrac[er][esr][ei][0], - dResPhaseCompFrac_dPres[er][esr][ei][0], - dResPhaseCompFrac_dComp[er][esr][ei][0], + dResPhaseCompFrac[er][esr][ei][0], resPhaseRelPerm[er][esr][ei][0], dResPhaseRelPerm_dPhaseVolFrac[er][esr][ei][0], wellElemGravCoef[iwelem], @@ -1178,14 +1174,11 @@ PerforationKernel:: ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dResPhaseVolFrac_dComp, \ ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dResCompFrac_dCompDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & resPhaseDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dResPhaseDens_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseDens_dComp, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseDens, \ ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & resPhaseVisc, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dResPhaseVisc_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseVisc_dComp, \ + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseVisc, \ ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & resPhaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dResPhaseCompFrac_dPres, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dResPhaseCompFrac_dComp, \ + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dResPhaseCompFrac, \ ElementViewConst< arrayView3d< real64 const, relperm::USD_RELPERM > > const & resPhaseRelPerm, \ ElementViewConst< arrayView4d< real64 const, relperm::USD_RELPERM_DS > > const & dResPhaseRelPerm_dPhaseVolFrac, \ arrayView1d< real64 const > const & wellElemGravCoef, \ @@ -1221,54 +1214,54 @@ INST_PerforationKernel( 5, 3 ); /******************************** AccumulationKernel ********************************/ -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void AccumulationKernel:: - compute( localIndex const numPhases, + compute( integer const numPhases, real64 const & volume, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dCompDens, arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens, arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & phaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & dPhaseCompFrac_dPres, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dPhaseCompFrac_dComp, + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dPhaseCompFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFracOld, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseDensOld, arraySlice2d< real64 const, compflow::USD_PHASE_COMP - 1 > const & phaseCompFracOld, real64 ( & localAccum )[NC], real64 ( & localAccumJacobian )[NC][NC + 1] ) { + using namespace multifluid; + // temporary work arrays real64 dPhaseAmount_dC[NC]{}; real64 dPhaseCompFrac_dC[NC]{}; // reset the local values - for( localIndex i = 0; i < NC; ++i ) + for( integer i = 0; i < NC; ++i ) { localAccum[i] = 0.0; - for( localIndex j = 0; j < NC+1; ++j ) + for( integer j = 0; j < NC+1; ++j ) { localAccumJacobian[i][j] = 0.0; } } // sum contributions to component accumulation from each phase - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { real64 const phaseAmountNew = volume * phaseVolFrac[ip] * phaseDens[ip]; real64 const phaseAmountOld = volume * phaseVolFracOld[ip] * phaseDensOld[ip]; - real64 const dPhaseAmount_dP = volume * (dPhaseVolFrac_dPres[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); + real64 const dPhaseAmount_dP = volume * ( dPhaseVolFrac_dPres[ip] * phaseDens[ip] + + phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dP] ); // assemble density dependence - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) + applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens[ip], dPhaseAmount_dC, Deriv::dC ); + for( integer jc = 0; jc < NC; ++jc ) { dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][jc]; @@ -1277,13 +1270,13 @@ AccumulationKernel:: // ic - index of component whose conservation equation is assembled // (i.e. row number in local matrix) - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { real64 const phaseCompAmountNew = phaseAmountNew * phaseCompFrac[ip][ic]; real64 const phaseCompAmountOld = phaseAmountOld * phaseCompFracOld[ip][ic]; real64 const dPhaseCompAmount_dP = dPhaseAmount_dP * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac_dPres[ip][ic]; + + phaseAmountNew * dPhaseCompFrac[ip][ic][Deriv::dP]; localAccum[ic] += phaseCompAmountNew - phaseCompAmountOld; localAccumJacobian[ic][0] += dPhaseCompAmount_dP; @@ -1292,8 +1285,8 @@ AccumulationKernel:: // (i.e. col number in local matrix) // assemble phase composition dependence - applyChainRule( NC, dCompFrac_dCompDens, dPhaseCompFrac_dComp[ip][ic], dPhaseCompFrac_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) + applyChainRule( NC, dCompFrac_dCompDens, dPhaseCompFrac[ip][ic], dPhaseCompFrac_dC, Deriv::dC ); + for( integer jc = 0; jc < NC; ++jc ) { real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; @@ -1303,11 +1296,11 @@ AccumulationKernel:: } } -template< localIndex NC > +template< integer NC > void AccumulationKernel:: launch( localIndex const size, - localIndex const numPhases, + integer const numPhases, globalIndex const rankOffset, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, @@ -1317,11 +1310,9 @@ AccumulationKernel:: arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dWellElemPhaseVolFrac_dCompDens, arrayView3d< real64 const, compflow::USD_COMP_DC > const & dWellElemCompFrac_dCompDens, arrayView3d< real64 const, multifluid::USD_PHASE > const & wellElemPhaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens_dComp, + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens, arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & wellElemPhaseCompFrac, - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dWellElemPhaseCompFrac_dPres, - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac_dComp, + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac, arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseVolFracOld, arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseDensOld, arrayView3d< real64 const, compflow::USD_PHASE_COMP > const & wellElemPhaseCompFracOld, @@ -1349,11 +1340,9 @@ AccumulationKernel:: dWellElemPhaseVolFrac_dCompDens[iwelem], dWellElemCompFrac_dCompDens[iwelem], wellElemPhaseDens[iwelem][0], - dWellElemPhaseDens_dPres[iwelem][0], - dWellElemPhaseDens_dComp[iwelem][0], + dWellElemPhaseDens[iwelem][0], wellElemPhaseCompFrac[iwelem][0], - dWellElemPhaseCompFrac_dPres[iwelem][0], - dWellElemPhaseCompFrac_dComp[iwelem][0], + dWellElemPhaseCompFrac[iwelem][0], wellElemPhaseVolFracOld[iwelem], wellElemPhaseDensOld[iwelem], wellElemPhaseCompFracOld[iwelem], @@ -1362,14 +1351,14 @@ AccumulationKernel:: // set the equation row indices to be the mass balance equations for all components localIndex eqnRowIndices[NC]{}; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { eqnRowIndices[ic] = wellElemDofNumber[iwelem] + ROFFSET::MASSBAL + ic - rankOffset; } // set DOF col indices for this block globalIndex dofColIndices[NC+1]{}; - for( localIndex idof = 0; idof < NC+1; ++idof ) + for( integer idof = 0; idof < NC+1; ++idof ) { dofColIndices[idof] = wellElemDofNumber[iwelem] + COFFSET::DPRES + idof; } @@ -1380,7 +1369,7 @@ AccumulationKernel:: shiftElementsAheadByOneAndReplaceFirstElementWithSum( NC, localAccum ); // add contribution to residual and jacobian - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { localRhs[eqnRowIndices[ic]] += localAccum[ic]; localMatrix.addToRow< serialAtomic >( eqnRowIndices[ic], @@ -1395,7 +1384,7 @@ AccumulationKernel:: template \ void AccumulationKernel:: \ launch< NC >( localIndex const size, \ - localIndex const numPhases, \ + integer const numPhases, \ globalIndex const rankOffset, \ arrayView1d< globalIndex const > const & wellElemDofNumber, \ arrayView1d< integer const > const & wellElemGhostRank, \ @@ -1405,11 +1394,9 @@ AccumulationKernel:: arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dWellElemPhaseVolFrac_dCompDens, \ arrayView3d< real64 const, compflow::USD_COMP_DC > const & dWellElemCompFrac_dCompDens, \ arrayView3d< real64 const, multifluid::USD_PHASE > const & wellElemPhaseDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseDens_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens_dComp, \ + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens, \ arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & wellElemPhaseCompFrac, \ - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dWellElemPhaseCompFrac_dPres, \ - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac_dComp, \ + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac, \ arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseVolFracOld, \ arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseDensOld, \ arrayView3d< real64 const, compflow::USD_PHASE_COMP > const & wellElemPhaseCompFracOld, \ @@ -1424,11 +1411,11 @@ INST_AccumulationKernel( 5 ); /******************************** VolumeBalanceKernel ********************************/ -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void VolumeBalanceKernel:: - compute( localIndex const numPhases, + compute( integer const numPhases, real64 const & volume, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, @@ -1437,36 +1424,36 @@ VolumeBalanceKernel:: real64 ( & localVolBalanceJacobian )[NC+1] ) { localVolBalance = 1.0; - for( localIndex ic = 0; ic < NC+1; ++ic ) + for( integer ic = 0; ic < NC+1; ++ic ) { localVolBalanceJacobian[ic] = 0.0; } // sum contributions to component accumulation from each phase - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { localVolBalance -= phaseVolFrac[ip]; localVolBalanceJacobian[0] -= dPhaseVolFrac_dPres[ip]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { localVolBalanceJacobian[jc + 1] -= dPhaseVolFrac_dComp[ip][jc]; } } // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) - for( localIndex idof = 0; idof < NC+1; ++idof ) + for( integer idof = 0; idof < NC+1; ++idof ) { localVolBalanceJacobian[idof] *= volume; } localVolBalance *= volume; } -template< localIndex NC > +template< integer NC > void VolumeBalanceKernel:: launch( localIndex const size, - localIndex const numPhases, + integer const numPhases, globalIndex const rankOffset, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, @@ -1499,7 +1486,7 @@ VolumeBalanceKernel:: // get equation/dof indices localIndex const localVolBalanceEqnIndex = wellElemDofNumber[iwelem] - rankOffset + ROFFSET::MASSBAL + NC; globalIndex localVolBalanceDOF[NC+1]{}; - for( localIndex jdof = 0; jdof < NC+1; ++jdof ) + for( integer jdof = 0; jdof < NC+1; ++jdof ) { localVolBalanceDOF[jdof] = wellElemDofNumber[iwelem] + COFFSET::DPRES + jdof; } @@ -1516,7 +1503,7 @@ VolumeBalanceKernel:: template \ void VolumeBalanceKernel:: \ launch< NC >( localIndex const size, \ - localIndex const numPhases, \ + integer const numPhases, \ globalIndex const rankOffset, \ arrayView1d< globalIndex const > const & wellElemDofNumber, \ arrayView1d< integer const > const & wellElemGhostRank, \ @@ -1539,8 +1526,8 @@ void PresTempCompFracInitializationKernel:: launch( localIndex const perforationSize, localIndex const subRegionSize, - localIndex const numComps, - localIndex const numPhases, + integer const numComps, + integer const numPhases, localIndex const numPerforations, WellControls const & wellControls, real64 const & currentTime, @@ -1557,7 +1544,7 @@ PresTempCompFracInitializationKernel:: arrayView1d< real64 > const & wellElemTemp, arrayView2d< real64, compflow::USD_COMP > const & wellElemCompFrac ) { - localIndex constexpr MAX_NUM_COMP = constitutive::MultiFluidBase::MAX_NUM_COMPONENTS; + integer constexpr MAX_NUM_COMP = constitutive::MultiFluidBase::MAX_NUM_COMPONENTS; real64 const targetBHP = wellControls.getTargetBHP( currentTime ); real64 const refWellElemGravCoef = wellControls.getReferenceGravityCoef(); @@ -1583,7 +1570,7 @@ PresTempCompFracInitializationKernel:: sumTemp += resTemp[er][esr][ei]; // increment the average total mass density - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { sumTotalMassDens += resPhaseVolFrac[er][esr][ei][ip] * resPhaseMassDens[er][esr][ei][0][ip]; } @@ -1593,7 +1580,7 @@ PresTempCompFracInitializationKernel:: // I would like to define an array of RAJA::ReduceSum to be able to do sum[ic] += ... // and put back what is below in the previous kernel. stackArray1d< real64, MAX_NUM_COMP > sumCompFrac( numComps ); - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { RAJA::ReduceSum< parallelDeviceReduce, real64 > sum( 0.0 ); forAll< parallelDevicePolicy<> >( perforationSize, [=] GEOSX_HOST_DEVICE ( localIndex const iperf ) @@ -1604,7 +1591,7 @@ PresTempCompFracInitializationKernel:: localIndex const ei = resElementIndex[iperf]; real64 perfTotalDens = 0.0; - for( localIndex jc = 0; jc < numComps; ++jc ) + for( integer jc = 0; jc < numComps; ++jc ) { perfTotalDens += resCompDens[er][esr][ei][jc]; } @@ -1628,7 +1615,7 @@ PresTempCompFracInitializationKernel:: // use average comp frac from reservoir real64 compFracSum = 0; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { avgCompFrac[ic] = MpiWrapper::sum( sumCompFrac[ic] ) / numPerforations; compFracSum += avgCompFrac[ic]; @@ -1645,7 +1632,7 @@ PresTempCompFracInitializationKernel:: avgTemp = wellControls.getInjectionTemperature(); // use comp frac from XML file - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { avgCompFrac[ic] = wellControls.getInjectionStream()[ic]; } @@ -1655,7 +1642,7 @@ PresTempCompFracInitializationKernel:: forAll< parallelDevicePolicy<> >( subRegionSize, [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { wellElemTemp[iwelem] = avgTemp; - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { wellElemCompFrac[iwelem][ic] = avgCompFrac[ic]; } @@ -1697,14 +1684,14 @@ PresTempCompFracInitializationKernel:: void CompDensInitializationKernel:: launch( localIndex const subRegionSize, - localIndex const numComponents, + integer const numComponents, arrayView2d< real64 const, compflow::USD_COMP > const & wellElemCompFrac, arrayView2d< real64 const, multifluid::USD_FLUID > const & wellElemTotalDens, arrayView2d< real64, compflow::USD_COMP > const & wellElemCompDens ) { forAll< parallelDevicePolicy<> >( subRegionSize, [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { - for( localIndex ic = 0; ic < numComponents; ++ic ) + for( integer ic = 0; ic < numComponents; ++ic ) { wellElemCompDens[iwelem][ic] = wellElemCompFrac[iwelem][ic] * wellElemTotalDens[iwelem][0]; } @@ -1716,7 +1703,7 @@ CompDensInitializationKernel:: void RateInitializationKernel:: launch( localIndex const subRegionSize, - localIndex const targetPhaseIndex, + integer const targetPhaseIndex, WellControls const & wellControls, real64 const & currentTime, arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp index 9ef7820473b..206d860a6b6 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp @@ -84,7 +84,7 @@ struct ControlEquationHelper static void switchControl( WellControls::Type const & wellType, WellControls::Control const & currentControl, - localIndex const phasePhaseIndex, + integer const phasePhaseIndex, real64 const & targetBHP, real64 const & targetPhaseRate, real64 const & targetTotalRate, @@ -93,12 +93,12 @@ struct ControlEquationHelper real64 const & currentTotalVolRate, WellControls::Control & newControl ); - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void compute( globalIndex const rankOffset, WellControls::Control const currentControl, - localIndex const targetPhaseIndex, + integer const targetPhaseIndex, real64 const & targetBHP, real64 const & targetPhaseRate, real64 const & targetTotalRate, @@ -128,7 +128,7 @@ struct FluxKernel using ROFFSET = CompositionalMultiphaseWellKernels::RowOffset; using COFFSET = CompositionalMultiphaseWellKernels::ColOffset; - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void computeExit( real64 const & dt, @@ -140,7 +140,7 @@ struct FluxKernel real64 ( &oneSidedFluxJacobian_dRate )[NC][1], real64 ( &oneSidedFluxJacobian_dPresCompUp )[NC][NC + 1] ); - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void compute( real64 const & dt, @@ -152,7 +152,7 @@ struct FluxKernel real64 ( &localFluxJacobian_dRate )[2*NC][1], real64 ( &localFluxJacobian_dPresCompUp )[2*NC][NC + 1] ); - template< localIndex NC > + template< integer NC > static void launch( localIndex const size, globalIndex const rankOffset, @@ -178,7 +178,7 @@ struct PressureRelationKernel using ROFFSET = CompositionalMultiphaseWellKernels::RowOffset; using COFFSET = CompositionalMultiphaseWellKernels::ColOffset; - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void compute( real64 const & gravCoef, @@ -196,13 +196,13 @@ struct PressureRelationKernel real64 & localPresRel, real64 ( &localPresRelJacobian )[2*(NC+1)] ); - template< localIndex NC > + template< integer NC > static void launch( localIndex const size, globalIndex const rankOffset, bool const isLocallyOwned, localIndex const iwelemControl, - localIndex const targetPhaseIndex, + integer const targetPhaseIndex, WellControls const & wellControls, real64 const & timeAtEndOfStep, arrayView1d< globalIndex const > const & wellElemDofNumber, @@ -237,14 +237,11 @@ struct PerforationKernel using MultiFluidAccessors = StencilMaterialAccessors< MultiFluidBase, extrinsicMeshData::multifluid::phaseDensity, - extrinsicMeshData::multifluid::dPhaseDensity_dPressure, - extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction, + extrinsicMeshData::multifluid::dPhaseDensity, extrinsicMeshData::multifluid::phaseViscosity, - extrinsicMeshData::multifluid::dPhaseViscosity_dPressure, - extrinsicMeshData::multifluid::dPhaseViscosity_dGlobalCompFraction, + extrinsicMeshData::multifluid::dPhaseViscosity, extrinsicMeshData::multifluid::phaseCompFraction, - extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure, - extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction >; + extrinsicMeshData::multifluid::dPhaseCompFraction >; using RelPermAccessors = StencilMaterialAccessors< RelativePermeabilityBase, @@ -263,7 +260,7 @@ struct PerforationKernel using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >; - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > GEOSX_HOST_DEVICE static void compute( real64 const & resPres, @@ -273,14 +270,11 @@ struct PerforationKernel arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dResPhaseVolFrac_dComp, arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dResCompFrac_dCompDens, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & resPhaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dResPhaseDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseDens_dComp, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseDens, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & resPhaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dResPhaseVisc_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseVisc_dComp, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dResPhaseVisc, arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & resPhaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & dResPhaseCompFrac_dPres, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dResPhaseCompFrac_dComp, + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dResPhaseCompFrac, arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & resPhaseRelPerm, arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dResPhaseRelPerm_dPhaseVolFrac, real64 const & wellElemGravCoef, @@ -299,7 +293,7 @@ struct PerforationKernel arraySlice2d< real64 > const & dCompPerfRate_dPres, arraySlice3d< real64 > const & dCompPerfRate_dComp ); - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > static void launch( localIndex const size, ElementViewConst< arrayView1d< real64 const > > const & resPres, @@ -309,14 +303,11 @@ struct PerforationKernel ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dResPhaseVolFrac_dComp, ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dResCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & resPhaseDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dResPhaseDens_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseDens_dComp, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseDens, ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & resPhaseVisc, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dResPhaseVisc_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseVisc_dComp, + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dResPhaseVisc, ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & resPhaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dResPhaseCompFrac_dPres, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dResPhaseCompFrac_dComp, + ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dResPhaseCompFrac, ElementViewConst< arrayView3d< real64 const, relperm::USD_RELPERM > > const & resPhaseRelPerm, ElementViewConst< arrayView4d< real64 const, relperm::USD_RELPERM_DS > > const & dResPhaseRelPerm_dPhaseVolFrac, arrayView1d< real64 const > const & wellElemGravCoef, @@ -349,31 +340,29 @@ struct AccumulationKernel using ROFFSET = CompositionalMultiphaseWellKernels::RowOffset; using COFFSET = CompositionalMultiphaseWellKernels::ColOffset; - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void - compute( localIndex const numPhases, + compute( integer const numPhases, real64 const & volume, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dCompDens, arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens, arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & phaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & dPhaseCompFrac_dPres, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dPhaseCompFrac_dComp, + arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dPhaseCompFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFracOld, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseDensOld, arraySlice2d< real64 const, compflow::USD_PHASE_COMP - 1 > const & phaseCompFracOld, real64 ( &localAccum )[NC], real64 ( &localAccumJacobian )[NC][NC + 1] ); - template< localIndex NC > + template< integer NC > static void launch( localIndex const size, - localIndex const numPhases, + integer const numPhases, globalIndex const rankOffset, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, @@ -383,11 +372,9 @@ struct AccumulationKernel arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dWellElemPhaseVolFrac_dCompDens, arrayView3d< real64 const, compflow::USD_COMP_DC > const & dWellElemCompFrac_dCompDens, arrayView3d< real64 const, multifluid::USD_PHASE > const & wellElemPhaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens_dComp, + arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseDens, arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & wellElemPhaseCompFrac, - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dWellElemPhaseCompFrac_dPres, - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac_dComp, + arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dWellElemPhaseCompFrac, arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseVolFracOld, arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseDensOld, arrayView3d< real64 const, compflow::USD_PHASE_COMP > const & wellElemPhaseCompFracOld, @@ -404,10 +391,10 @@ struct VolumeBalanceKernel using ROFFSET = CompositionalMultiphaseWellKernels::RowOffset; using COFFSET = CompositionalMultiphaseWellKernels::ColOffset; - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void - compute( localIndex const numPhases, + compute( integer const numPhases, real64 const & volume, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, @@ -415,10 +402,10 @@ struct VolumeBalanceKernel real64 & localVolBalance, real64 ( &localVolBalanceJacobian )[NC+1] ); - template< localIndex NC > + template< integer NC > static void launch( localIndex const size, - localIndex const numPhases, + integer const numPhases, globalIndex const rankOffset, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, @@ -460,8 +447,8 @@ struct PresTempCompFracInitializationKernel static void launch( localIndex const perforationSize, localIndex const subRegionSize, - localIndex const numComponents, - localIndex const numPhases, + integer const numComponents, + integer const numPhases, localIndex const numPerforations, WellControls const & wellControls, real64 const & currentTime, @@ -487,7 +474,7 @@ struct CompDensInitializationKernel static void launch( localIndex const subRegionSize, - localIndex const numComponents, + integer const numComponents, arrayView2d< real64 const, compflow::USD_COMP > const & wellElemCompFrac, arrayView2d< real64 const, multifluid::USD_FLUID > const & wellElemTotalDens, arrayView2d< real64, compflow::USD_COMP > const & wellElemCompDens ); @@ -501,7 +488,7 @@ struct RateInitializationKernel static void launch( localIndex const subRegionSize, - localIndex const targetPhaseIndex, + integer const targetPhaseIndex, WellControls const & wellControls, real64 const & currentTime, arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, @@ -544,8 +531,7 @@ class TotalMassDensityKernel : public CompositionalMultiphaseBaseKernels::Proper m_dPhaseVolFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::well::dPhaseVolumeFraction_dGlobalCompDensity >() ), m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::well::dGlobalCompFraction_dGlobalCompDensity >() ), m_phaseMassDens( fluid.phaseMassDensity() ), - m_dPhaseMassDens_dPres( fluid.dPhaseMassDensity_dPressure() ), - m_dPhaseMassDens_dComp( fluid.dPhaseMassDensity_dGlobalCompFraction() ), + m_dPhaseMassDens( fluid.dPhaseMassDensity() ), m_totalMassDens( subRegion.getExtrinsicData< extrinsicMeshData::well::totalMassDensity >() ), m_dTotalMassDens_dPres( subRegion.getExtrinsicData< extrinsicMeshData::well::dTotalMassDensity_dPressure >() ), m_dTotalMassDens_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::well::dTotalMassDensity_dGlobalCompDensity >() ) @@ -562,13 +548,14 @@ class TotalMassDensityKernel : public CompositionalMultiphaseBaseKernels::Proper void compute( localIndex const ei, FUNC && totalMassDensityKernelOp = CompositionalMultiphaseBaseKernels::NoOpFunc{} ) const { + using namespace multifluid; + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFrac = m_phaseVolFrac[ei]; arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dPres = m_dPhaseVolFrac_dPres[ei]; arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > dPhaseVolFrac_dCompDens = m_dPhaseVolFrac_dCompDens[ei]; arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > phaseMassDens = m_phaseMassDens[ei][0]; - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseMassDens_dPres = m_dPhaseMassDens_dPres[ei][0]; - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseMassDens_dComp = m_dPhaseMassDens_dComp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseMassDens = m_dPhaseMassDens[ei][0]; real64 & totalMassDens = m_totalMassDens[ei]; real64 & dTotalMassDens_dPres = m_dTotalMassDens_dPres[ei]; arraySlice1d< real64, compflow::USD_FLUID_DC - 1 > dTotalMassDens_dCompDens = m_dTotalMassDens_dCompDens[ei]; @@ -585,10 +572,9 @@ class TotalMassDensityKernel : public CompositionalMultiphaseBaseKernels::Proper for( integer ip = 0; ip < numPhase; ++ip ) { totalMassDens += phaseVolFrac[ip] * phaseMassDens[ip]; - dTotalMassDens_dPres += dPhaseVolFrac_dPres[ip] * phaseMassDens[ip] - + phaseVolFrac[ip] * dPhaseMassDens_dPres[ip]; + dTotalMassDens_dPres += dPhaseVolFrac_dPres[ip] * phaseMassDens[ip] + phaseVolFrac[ip] * dPhaseMassDens[ip][Deriv::dP]; - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseMassDens_dComp[ip], dMassDens_dC ); + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseMassDens[ip], dMassDens_dC, Deriv::dC ); for( integer ic = 0; ic < numComp; ++ic ) { dTotalMassDens_dCompDens[ic] += dPhaseVolFrac_dCompDens[ip][ic] * phaseMassDens[ip] @@ -611,8 +597,7 @@ class TotalMassDensityKernel : public CompositionalMultiphaseBaseKernels::Proper /// Views on phase mass densities arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseMassDens; - arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseMassDens_dPres; - arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseMassDens_dComp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseMassDens; // outputs @@ -678,9 +663,9 @@ struct ResidualNormKernel globalIndex const rankOffset, bool const isLocallyOwned, localIndex const iwelemControl, - localIndex const numComponents, - localIndex const numDofPerWellElement, - localIndex const targetPhaseIndex, + integer const numComponents, + integer const numDofPerWellElement, + integer const targetPhaseIndex, WellControls const & wellControls, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, @@ -708,7 +693,7 @@ struct ResidualNormKernel if( wellElemGhostRank[iwelem] < 0 ) { real64 normalizer = 0.0; - for( localIndex idof = 0; idof < numDofPerWellElement; ++idof ) + for( integer idof = 0; idof < numDofPerWellElement; ++idof ) { // Step 1: compute a normalizer for the control or pressure equation @@ -792,7 +777,7 @@ struct SolutionScalingKernel static real64 launch( LOCAL_VECTOR const localSolution, globalIndex const rankOffset, - localIndex const numComponents, + integer const numComponents, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, arrayView1d< real64 const > const & wellElemPres, @@ -825,12 +810,12 @@ struct SolutionScalingKernel } real64 prevTotalDens = 0; - for( localIndex ic = 0; ic < numComponents; ++ic ) + for( integer ic = 0; ic < numComponents; ++ic ) { prevTotalDens += wellElemCompDens[iwelem][ic] + dWellElemCompDens[iwelem][ic]; } - for( localIndex ic = 0; ic < numComponents; ++ic ) + for( integer ic = 0; ic < numComponents; ++ic ) { localIndex const lid = wellElemDofNumber[iwelem] + ic + 1 - rankOffset; @@ -865,7 +850,7 @@ struct SolutionCheckKernel static localIndex launch( LOCAL_VECTOR const localSolution, globalIndex const rankOffset, - localIndex const numComponents, + integer const numComponents, arrayView1d< globalIndex const > const & wellElemDofNumber, arrayView1d< integer const > const & wellElemGhostRank, arrayView1d< real64 const > const & wellElemPressure, @@ -901,7 +886,7 @@ struct SolutionCheckKernel // will be chopped (i.e., set to zero) in applySystemSolution if( !allowCompDensChopping ) { - for( localIndex ic = 0; ic < numComponents; ++ic ) + for( integer ic = 0; ic < numComponents; ++ic ) { lid = wellElemDofNumber[iwelem] + ic + 1 - rankOffset; real64 const newDens = wellElemCompDens[iwelem][ic] + dWellElemCompDens[iwelem][ic] @@ -916,7 +901,7 @@ struct SolutionCheckKernel else { real64 totalDens = 0.0; - for( localIndex ic = 0; ic < numComponents; ++ic ) + for( integer ic = 0; ic < numComponents; ++ic ) { lid = wellElemDofNumber[iwelem] + ic + 1 - rankOffset; real64 const newDens = wellElemCompDens[iwelem][ic] + dWellElemCompDens[iwelem][ic] diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp index 74c2efa4ece..66e211ffc1f 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp @@ -130,12 +130,10 @@ class Multiphase : elementSubRegion.template getConstitutiveModel< constitutive::MultiFluidBase >( fluidModelName ); m_fluidPhaseDensity = fluid.phaseDensity(); - m_dFluidPhaseDensity_dPressure = fluid.dPhaseDensity_dPressure(); - m_dFluidPhaseDensity_dGlobalCompFraction = fluid.dPhaseDensity_dGlobalCompFraction(); + m_dFluidPhaseDensity = fluid.dPhaseDensity(); m_fluidPhaseCompFrac = fluid.phaseCompFraction(); - m_dFluidPhaseCompFrac_dPressure = fluid.dPhaseCompFraction_dPressure(); - m_dFluidPhaseCompFraction_dGlobalCompFraction = fluid.dPhaseCompFraction_dGlobalCompFraction(); + m_dFluidPhaseCompFrac = fluid.dPhaseCompFraction(); m_fluidPhaseMassDensity = fluid.phaseMassDensity(); m_initialFluidTotalMassDensity = fluid.initialTotalMassDensity(); @@ -368,10 +366,12 @@ class Multiphase : // --- Mass balance accumulation // --- --- sum contributions to component accumulation from each phase + using namespace constitutive::multifluid; + // --- --- temporary work arrays - real64 dPhaseAmount_dC[numMaxComponents]; - real64 dPhaseCompFrac_dC[numMaxComponents]; - real64 componentAmount[numMaxComponents] = { 0.0 }; + real64 dPhaseAmount_dC[numMaxComponents]{}; + real64 dPhaseCompFrac_dC[numMaxComponents]{}; + real64 componentAmount[numMaxComponents]{}; for( localIndex ip = 0; ip < NP; ++ip ) { @@ -380,13 +380,14 @@ class Multiphase : real64 const dPhaseAmount_dP = dPorosity_dPressure * m_fluidPhaseSaturation( k, ip ) * m_fluidPhaseDensity( k, q, ip ) + porosityNew * (m_dFluidPhaseSaturation_dPressure( k, ip ) * m_fluidPhaseDensity( k, q, ip ) - + m_fluidPhaseSaturation( k, ip ) * m_dFluidPhaseDensity_dPressure( k, q, ip ) ); + + m_fluidPhaseSaturation( k, ip ) * m_dFluidPhaseDensity( k, q, ip, Deriv::dP ) ); // assemble density dependence applyChainRule( NC, m_dGlobalCompFraction_dGlobalCompDensity[k], - m_dFluidPhaseDensity_dGlobalCompFraction[k][q][ip], - dPhaseAmount_dC ); + m_dFluidPhaseDensity[k][q][ip], + dPhaseAmount_dC, + Deriv::dC ); for( localIndex jc = 0; jc < NC; ++jc ) { @@ -404,7 +405,7 @@ class Multiphase : real64 const phaseCompAmountOld = phaseAmountOld * m_fluidPhaseCompFracOld( k, ip, ic ); real64 const dPhaseCompAmount_dP = dPhaseAmount_dP * m_fluidPhaseCompFrac( k, q, ip, ic ) - + phaseAmountNew * m_dFluidPhaseCompFrac_dPressure( k, q, ip, ic ); + + phaseAmountNew * m_dFluidPhaseCompFrac( k, q, ip, ic, Deriv::dP ); componentAmount[ic] += fluidPhaseDensityTimesFluidPhaseSaturation * m_fluidPhaseCompFrac( k, q, ip, ic ); @@ -417,8 +418,9 @@ class Multiphase : // assemble phase composition dependence applyChainRule( NC, m_dGlobalCompFraction_dGlobalCompDensity[k], - m_dFluidPhaseCompFraction_dGlobalCompFraction[k][q][ip][ic], - dPhaseCompFrac_dC ); + m_dFluidPhaseCompFrac[k][q][ip][ic], + dPhaseCompFrac_dC, + Deriv::dC ); for( localIndex jc = 0; jc < NC; ++jc ) { @@ -555,27 +557,25 @@ class Multiphase : arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_fluidPhaseDensity; arrayView2d< real64 const, compflow::USD_PHASE > m_fluidPhaseDensityOld; - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_dFluidPhaseDensity_dPressure; - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > m_dFluidPhaseDensity_dGlobalCompFraction; + arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > m_dFluidPhaseDensity; + arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > m_fluidPhaseCompFrac; arrayView3d< real64 const, compflow::USD_PHASE_COMP > m_fluidPhaseCompFracOld; - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > m_dFluidPhaseCompFrac_dPressure; + arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > m_dFluidPhaseCompFrac; arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_fluidPhaseMassDensity; - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > m_dFluidPhaseMassDensity_dPressure; - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > m_dFluidPhaseMassDensity_dGlobalCompFraction; + arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > m_dFluidPhaseMassDensity; arrayView2d< real64 const, constitutive::multifluid::USD_FLUID > m_initialFluidTotalMassDensity; arrayView2d< real64 const, compflow::USD_PHASE > m_fluidPhaseSaturation; arrayView2d< real64 const, compflow::USD_PHASE > m_fluidPhaseSaturationOld; arrayView2d< real64 const, compflow::USD_PHASE > m_dFluidPhaseSaturation_dPressure; - arrayView3d< real64 const, compflow::USD_PHASE_DC > m_dFluidPhaseSaturation_dGlobalCompFraction; arrayView3d< real64 const, compflow::USD_PHASE_DC > m_dFluidPhaseSaturation_dGlobalCompDensity; arrayView3d< real64 const, compflow::USD_COMP_DC > m_dGlobalCompFraction_dGlobalCompDensity; - arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > m_dFluidPhaseCompFraction_dGlobalCompFraction; + /// The global degree of freedom number arrayView1d< globalIndex const > m_flowDofNumber; diff --git a/src/coreComponents/schema/docs/BlackOilFluid_other.rst b/src/coreComponents/schema/docs/BlackOilFluid_other.rst index 19795673132..8f0d462d9a8 100644 --- a/src/coreComponents/schema/docs/BlackOilFluid_other.rst +++ b/src/coreComponents/schema/docs/BlackOilFluid_other.rst @@ -1,40 +1,28 @@ -====================================== ========================================================================================================= ================================================================================ -Name Type Description -====================================== ========================================================================================================= ================================================================================ -PVTO geosx_constitutive_PVTOData (no description available) -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -hydrocarbonPhaseOrder integer_array (no description available) -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -====================================== ========================================================================================================= ================================================================================ +=============================== ========================================================================================================= ============================================================================================================ +Name Type Description +=============================== ========================================================================================================= ============================================================================================================ +PVTO geosx_constitutive_PVTOData (no description available) +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +hydrocarbonPhaseOrder integer_array (no description available) +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseFraction real64_array3d Phase fraction +phaseMassDensity real64_array3d Phase mass density +phaseOrder integer_array (no description available) +phaseTypes integer_array (no description available) +phaseViscosity real64_array3d Phase viscosity +totalDensity real64_array2d Total density +useMass integer (no description available) +viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +=============================== ========================================================================================================= ============================================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst index 81781e92fc2..a7575d6b734 100644 --- a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst @@ -1,34 +1,22 @@ -====================================== ============================================================================================== ================================================================================ -Name Type Description -====================================== ============================================================================================== ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -====================================== ============================================================================================== ================================================================================ +======================= ============================================================================================== ============================================================================================================ +Name Type Description +======================= ============================================================================================== ============================================================================================================ +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseFraction real64_array3d Phase fraction +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +totalDensity real64_array2d Total density +useMass integer (no description available) +======================= ============================================================================================== ============================================================================================================ diff --git a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst index 81781e92fc2..a7575d6b734 100644 --- a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst @@ -1,34 +1,22 @@ -====================================== ============================================================================================== ================================================================================ -Name Type Description -====================================== ============================================================================================== ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -====================================== ============================================================================================== ================================================================================ +======================= ============================================================================================== ============================================================================================================ +Name Type Description +======================= ============================================================================================== ============================================================================================================ +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseFraction real64_array3d Phase fraction +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +totalDensity real64_array2d Total density +useMass integer (no description available) +======================= ============================================================================================== ============================================================================================================ diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst index 81781e92fc2..a7575d6b734 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst @@ -1,34 +1,22 @@ -====================================== ============================================================================================== ================================================================================ -Name Type Description -====================================== ============================================================================================== ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -====================================== ============================================================================================== ================================================================================ +======================= ============================================================================================== ============================================================================================================ +Name Type Description +======================= ============================================================================================== ============================================================================================================ +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseFraction real64_array3d Phase fraction +phaseMassDensity real64_array3d Phase mass density +phaseViscosity real64_array3d Phase viscosity +totalDensity real64_array2d Total density +useMass integer (no description available) +======================= ============================================================================================== ============================================================================================================ diff --git a/src/coreComponents/schema/docs/DeadOilFluid_other.rst b/src/coreComponents/schema/docs/DeadOilFluid_other.rst index 9538942463e..9b385f6c702 100644 --- a/src/coreComponents/schema/docs/DeadOilFluid_other.rst +++ b/src/coreComponents/schema/docs/DeadOilFluid_other.rst @@ -1,39 +1,27 @@ -====================================== ========================================================================================================= ================================================================================ -Name Type Description -====================================== ========================================================================================================= ================================================================================ -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to global component fraction -dPhaseCompFraction_dPressure real64_array4d Derivative of phase component fraction with respect to pressure -dPhaseCompFraction_dTemperature real64_array4d Derivative of phase component fraction with respect to temperature -dPhaseDensity_dGlobalCompFraction real64_array4d Derivative of phase density with respect to global component fraction -dPhaseDensity_dPressure real64_array3d Derivative of phase density with respect to pressure -dPhaseDensity_dTemperature real64_array3d Derivative of phase density with respect to temperature -dPhaseFraction_dGlobalCompFraction real64_array4d Derivative of phase fraction with respect to global component fraction -dPhaseFraction_dPressure real64_array3d Derivative of phase fraction with respect to pressure -dPhaseFraction_dTemperature real64_array3d Derivative of phase fraction with respect to temperature -dPhaseMassDensity_dGlobalCompFraction real64_array4d Derivative of phase mass density with respect to global component fraction -dPhaseMassDensity_dPressure real64_array3d Derivative of phase mass density with respect to pressure -dPhaseMassDensity_dTemperature real64_array3d Derivative of phase mass density with respect to temperature -dPhaseViscosity_dGlobalCompFraction real64_array4d Derivative of phase viscosity with respect to global component fraction -dPhaseViscosity_dPressure real64_array3d Derivative of phase viscosity with respect to pressure -dPhaseViscosity_dTemperature real64_array3d Derivative of phase viscosity with respect to temperature -dTotalDensity_dGlobalCompFraction real64_array3d Derivative of total density with respect to global component fraction -dTotalDensity_dPressure real64_array2d Derivative of total density with respect to pressure -dTotalDensity_dTemperature real64_array2d Derivative of total density with respect to temperature -formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -hydrocarbonPhaseOrder integer_array (no description available) -initialTotalMassDensity real64_array2d Initial total mass density -phaseCompFraction real64_array4d Phase component fraction -phaseDensity real64_array3d Phase density -phaseFraction real64_array3d Phase fraction -phaseMassDensity real64_array3d Phase mass density -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -phaseViscosity real64_array3d Phase viscosity -totalDensity real64_array2d Total density -useMass integer (no description available) -viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -====================================== ========================================================================================================= ================================================================================ +=============================== ========================================================================================================= ============================================================================================================ +Name Type Description +=============================== ========================================================================================================= ============================================================================================================ +dPhaseCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > Derivative of phase component fraction with respect to pressure, temperature, and global component fractions +dPhaseDensity real64_array4d Derivative of phase density with respect to pressure, temperature, and global component fractions +dPhaseFraction real64_array4d Derivative of phase fraction with respect to pressure, temperature, and global component fractions +dPhaseMassDensity real64_array4d Derivative of phase mass density with respect to pressure, temperature, and global component fractions +dPhaseViscosity real64_array4d Derivative of phase viscosity with respect to pressure, temperature, and global component fractions +dTotalDensity real64_array3d Derivative of total density with respect to pressure, temperature, and global component fractions +formationVolFactorTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +hydrocarbonPhaseOrder integer_array (no description available) +initialTotalMassDensity real64_array2d Initial total mass density +phaseCompFraction real64_array4d Phase component fraction +phaseDensity real64_array3d Phase density +phaseFraction real64_array3d Phase fraction +phaseMassDensity real64_array3d Phase mass density +phaseOrder integer_array (no description available) +phaseTypes integer_array (no description available) +phaseViscosity real64_array3d Phase viscosity +totalDensity real64_array2d Total density +useMass integer (no description available) +viscosityTableWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +=============================== ========================================================================================================= ============================================================================================================ diff --git a/src/coreComponents/schema/docs/InternalMesh_other.rst b/src/coreComponents/schema/docs/InternalMesh_other.rst index 82f309906a1..14257041f64 100644 --- a/src/coreComponents/schema/docs/InternalMesh_other.rst +++ b/src/coreComponents/schema/docs/InternalMesh_other.rst @@ -1,10 +1,9 @@ -=========== ==== ================================ -Name Type Description -=========== ==== ================================ -cellManager node :ref:`DATASTRUCTURE_cellManager` -meshLevels node :ref:`DATASTRUCTURE_meshLevels` -=========== ==== ================================ +========== ==== =============================== +Name Type Description +========== ==== =============================== +meshLevels node :ref:`DATASTRUCTURE_meshLevels` +========== ==== =============================== diff --git a/src/coreComponents/schema/docs/InternalWell_other.rst b/src/coreComponents/schema/docs/InternalWell_other.rst index 4824850a730..058e8b2e0db 100644 --- a/src/coreComponents/schema/docs/InternalWell_other.rst +++ b/src/coreComponents/schema/docs/InternalWell_other.rst @@ -4,7 +4,6 @@ Name Type Description =========== ==== ================================ Perforation node :ref:`DATASTRUCTURE_Perforation` -cellManager node :ref:`DATASTRUCTURE_cellManager` meshLevels node :ref:`DATASTRUCTURE_meshLevels` =========== ==== ================================ diff --git a/src/coreComponents/schema/docs/InternalWellbore_other.rst b/src/coreComponents/schema/docs/InternalWellbore_other.rst index 402187b4164..37368241205 100644 --- a/src/coreComponents/schema/docs/InternalWellbore_other.rst +++ b/src/coreComponents/schema/docs/InternalWellbore_other.rst @@ -1,14 +1,13 @@ -=========== ============= ============================================================ -Name Type Description -=========== ============= ============================================================ -nx integer_array Number of elements in the x-direction within each mesh block -ny integer_array Number of elements in the y-direction within each mesh block -xCoords real64_array x-coordinates of each mesh block vertex -yCoords real64_array y-coordinates of each mesh block vertex -cellManager node :ref:`DATASTRUCTURE_cellManager` -meshLevels node :ref:`DATASTRUCTURE_meshLevels` -=========== ============= ============================================================ +========== ============= ============================================================ +Name Type Description +========== ============= ============================================================ +nx integer_array Number of elements in the x-direction within each mesh block +ny integer_array Number of elements in the y-direction within each mesh block +xCoords real64_array x-coordinates of each mesh block vertex +yCoords real64_array y-coordinates of each mesh block vertex +meshLevels node :ref:`DATASTRUCTURE_meshLevels` +========== ============= ============================================================ diff --git a/src/coreComponents/schema/docs/PAMELAMeshGenerator_other.rst b/src/coreComponents/schema/docs/PAMELAMeshGenerator_other.rst index 82f309906a1..14257041f64 100644 --- a/src/coreComponents/schema/docs/PAMELAMeshGenerator_other.rst +++ b/src/coreComponents/schema/docs/PAMELAMeshGenerator_other.rst @@ -1,10 +1,9 @@ -=========== ==== ================================ -Name Type Description -=========== ==== ================================ -cellManager node :ref:`DATASTRUCTURE_cellManager` -meshLevels node :ref:`DATASTRUCTURE_meshLevels` -=========== ==== ================================ +========== ==== =============================== +Name Type Description +========== ==== =============================== +meshLevels node :ref:`DATASTRUCTURE_meshLevels` +========== ==== =============================== diff --git a/src/coreComponents/schema/docs/VTKMeshGenerator_other.rst b/src/coreComponents/schema/docs/VTKMeshGenerator_other.rst index 5db05054b1c..14257041f64 100644 --- a/src/coreComponents/schema/docs/VTKMeshGenerator_other.rst +++ b/src/coreComponents/schema/docs/VTKMeshGenerator_other.rst @@ -1,10 +1,9 @@ -========== ======= =========================== -Name Type Description -========== ======= =========================== -meshLevels integer (no description available) -Level0 node :ref:`DATASTRUCTURE_Level0` -========== ======= =========================== +========== ==== =============================== +Name Type Description +========== ==== =============================== +meshLevels node :ref:`DATASTRUCTURE_meshLevels` +========== ==== =============================== diff --git a/src/coreComponents/schema/docs/meshLevels_other.rst b/src/coreComponents/schema/docs/meshLevels_other.rst new file mode 100644 index 00000000000..ec43e922076 --- /dev/null +++ b/src/coreComponents/schema/docs/meshLevels_other.rst @@ -0,0 +1,9 @@ + + +====== ==== =========================== +Name Type Description +====== ==== =========================== +Level0 node :ref:`DATASTRUCTURE_Level0` +====== ==== =========================== + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 6ab79d4b85e..a861c37e89f 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -339,21 +339,18 @@ - - - @@ -367,16 +364,13 @@ - - + - - @@ -906,42 +900,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1006,42 +976,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1060,42 +1006,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1122,42 +1044,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1256,42 +1154,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -1688,12 +1562,6 @@ - - - - - - diff --git a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp index e2eab87ab4b..f06bb358c55 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp @@ -39,6 +39,7 @@ using namespace geosx::constitutive; using namespace geosx::dataRepository; using namespace geosx::stringutilities; using namespace geosx::constitutive::PVTProps; +using namespace geosx::constitutive::multifluid; /// Input tables written into temporary files during testing @@ -71,23 +72,20 @@ void testValuesAgainstPreviousImplementation( PVT_WRAPPER const & pvtFunctionWra bool const useMass, real64 const relTol ) { + integer constexpr numPhase = 2; + integer constexpr numComp = 2; + integer constexpr numDof = numComp + 2; + real64 value = 0.0; - real64 dValue_dPressure = 0.0; - real64 dValue_dTemperature = 0.0; - stackArray1d< real64, 2 > dPhaseComposition_dPressure( 2 ); - stackArray1d< real64, 2 > dPhaseComposition_dTemperature( 2 ); - stackArray2d< real64, 4 > dPhaseComposition_dGlobalCompFraction( 2, 2 ); - stackArray1d< real64, 2 > dValue_dGlobalCompFraction( 2 ); + stackArray1d< real64, numDof > dValue( numDof ); + stackArray2d< real64, numDof *numPhase > dPhaseComposition( numPhase, numDof ); + pvtFunctionWrapper.compute( pressure, temperature, phaseComposition, - dPhaseComposition_dPressure.toSliceConst(), - dPhaseComposition_dTemperature.toSliceConst(), - dPhaseComposition_dGlobalCompFraction.toSliceConst(), + dPhaseComposition.toSliceConst(), value, - dValue_dPressure, - dValue_dTemperature, - dValue_dGlobalCompFraction.toSlice(), + dValue.toSlice(), useMass ); checkRelativeError( value, oldImplValue, relTol ); @@ -102,32 +100,32 @@ void testValuesAgainstPreviousImplementation( FLASH_WRAPPER const & flashModelWr real64 const & savedWaterPhaseGasComp, real64 const relTol ) { - stackArray1d< real64, 2 > phaseFraction( 2 ); - stackArray1d< real64, 2 > dPhaseFraction_dPres( 2 ); - stackArray1d< real64, 2 > dPhaseFraction_dTemp( 2 ); - stackArray2d< real64, 4 > dPhaseFraction_dCompFraction( 2, 2 ); - stackArray2d< real64, 4 > phaseCompFraction( 2, 2 ); - stackArray2d< real64, 4 > dPhaseCompFraction_dPres( 2, 2 ); - stackArray2d< real64, 4 > dPhaseCompFraction_dTemp( 2, 2 ); - stackArray3d< real64, 8 > dPhaseCompFraction_dCompFraction( 2, 2, 2 ); + integer constexpr numPhase = 2; + integer constexpr numComp = 2; + integer constexpr numDof = numComp + 2; + + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseFrac( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseFrac( 1, 1, numPhase, numDof ); + MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > + phaseFracAndDeriv { phaseFrac[0][0], dPhaseFrac[0][0] }; + + StackArray< real64, 4, numComp *numPhase, LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhase, numComp ); + StackArray< real64, 5, numDof *numComp *numPhase, LAYOUT_PHASE_COMP_DC > dPhaseCompFrac( 1, 1, numPhase, numComp, numDof ); + MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > + phaseCompFracAndDeriv { phaseCompFrac[0][0], dPhaseCompFrac[0][0] }; + flashModelWrapper.compute( pressure, temperature, compFraction, - phaseFraction.toSlice(), - dPhaseFraction_dPres.toSlice(), - dPhaseFraction_dTemp.toSlice(), - dPhaseFraction_dCompFraction.toSlice(), - phaseCompFraction.toSlice(), - dPhaseCompFraction_dPres.toSlice(), - dPhaseCompFraction_dTemp.toSlice(), - dPhaseCompFraction_dCompFraction.toSlice() ); - - for( localIndex i = 0; i < 2; ++i ) + phaseFracAndDeriv, + phaseCompFracAndDeriv ); + + for( integer i = 0; i < numPhase; ++i ) { real64 const savedPhaseFrac = (i == 0) ? savedGasPhaseFrac : 1.0 - savedGasPhaseFrac; - checkRelativeError( phaseFraction[i], savedPhaseFrac, relTol ); + checkRelativeError( phaseFracAndDeriv.value[i], savedPhaseFrac, relTol ); - for( localIndex j = 0; j < 2; ++j ) + for( integer j = 0; j < numComp; ++j ) { real64 savedCompFrac = 0.0; if( i == 0 ) @@ -138,7 +136,7 @@ void testValuesAgainstPreviousImplementation( FLASH_WRAPPER const & flashModelWr { savedCompFrac = ( j == 0 ) ? savedWaterPhaseGasComp : 1 - savedWaterPhaseGasComp; } - checkRelativeError( phaseCompFraction[i][j], savedCompFrac, relTol ); + checkRelativeError( phaseCompFracAndDeriv.value[i][j], savedCompFrac, relTol ); } } } @@ -152,83 +150,67 @@ void testNumericalDerivatives( PVT_WRAPPER const & pvtFunctionWrapper, real64 const perturbParameter, real64 const relTol ) { + using namespace multifluid; + + integer constexpr numComp = 2; + integer constexpr numDof = numComp + 2; + // 1) First compute the unperturbed pressure real64 value = 0.0; - real64 dValue_dPressure = 0.0; - real64 dValue_dTemperature = 0.0; - stackArray1d< real64, 2 > dPhaseComposition_dPressure( 2 ); - stackArray1d< real64, 2 > dPhaseComposition_dTemperature( 2 ); - stackArray2d< real64, 4 > dPhaseComposition_dGlobalCompFraction( 2, 2 ); - stackArray1d< real64, 2 > dValue_dGlobalCompFraction( 2 ); - dPhaseComposition_dGlobalCompFraction[0][0] = 1.0; - dPhaseComposition_dGlobalCompFraction[1][1] = 1.0; + stackArray1d< real64, numDof > dValue( numDof ); + stackArray2d< real64, numDof *numComp > dPhaseComposition( numComp, numDof ); + + dPhaseComposition[0][Deriv::dC] = 1.0; + dPhaseComposition[1][Deriv::dC+1] = 1.0; pvtFunctionWrapper.compute( pressure, temperature, phaseComposition, - dPhaseComposition_dPressure.toSliceConst(), - dPhaseComposition_dTemperature.toSliceConst(), - dPhaseComposition_dGlobalCompFraction.toSliceConst(), + dPhaseComposition.toSliceConst(), value, - dValue_dPressure, - dValue_dTemperature, - dValue_dGlobalCompFraction.toSlice(), + dValue.toSlice(), useMass ); real64 perturbedValue = 0.0; - real64 dPerturbedValue_dPressure = 0.0; - real64 dPerturbedValue_dTemperature = 0.0; - stackArray1d< real64, 2 > dPerturbedValue_dGlobalCompFraction( 2 ); + stackArray1d< real64, numDof > dPerturbedValue( numDof ); // 2) Check derivative with respect to pressure real64 const dP = perturbParameter * (pressure + perturbParameter); pvtFunctionWrapper.compute( pressure + dP, temperature, phaseComposition, - dPhaseComposition_dPressure.toSliceConst(), - dPhaseComposition_dTemperature.toSliceConst(), - dPhaseComposition_dGlobalCompFraction.toSliceConst(), + dPhaseComposition.toSliceConst(), perturbedValue, - dPerturbedValue_dPressure, - dPerturbedValue_dTemperature, - dPerturbedValue_dGlobalCompFraction.toSlice(), + dPerturbedValue.toSlice(), useMass ); - checkRelativeError( (perturbedValue-value)/dP, dValue_dPressure, relTol ); + checkRelativeError( (perturbedValue-value)/dP, dValue[Deriv::dP], relTol ); // 3) Check derivative with respect to temperature real64 const dT = perturbParameter * (temperature + perturbParameter); pvtFunctionWrapper.compute( pressure, temperature + dT, phaseComposition, - dPhaseComposition_dPressure.toSliceConst(), - dPhaseComposition_dTemperature.toSliceConst(), - dPhaseComposition_dGlobalCompFraction.toSliceConst(), + dPhaseComposition.toSliceConst(), perturbedValue, - dPerturbedValue_dPressure, - dPerturbedValue_dTemperature, - dPerturbedValue_dGlobalCompFraction.toSlice(), + dPerturbedValue.toSlice(), useMass ); - checkRelativeError( (perturbedValue-value)/dT, dValue_dTemperature, relTol ); + checkRelativeError( (perturbedValue-value)/dT, dValue[Deriv::dT], relTol ); // 4) Check derivatives with respect to phaseComposition - for( localIndex i = 0; i < 2; ++i ) + for( integer i = 0; i < numComp; ++i ) { real64 const dC = perturbParameter * (phaseComposition[i] + perturbParameter); - stackArray1d< real64, 2 > perturbedPhaseComposition( 2 ); - for( localIndex j = 0; j < 2; ++j ) + stackArray1d< real64, numComp > perturbedPhaseComposition( numComp ); + for( integer j = 0; j < numComp; ++j ) { perturbedPhaseComposition[j] = phaseComposition[j] + ( (i == j) ? dC : 0.0 ); } pvtFunctionWrapper.compute( pressure, temperature, perturbedPhaseComposition.toSliceConst(), - dPhaseComposition_dPressure.toSliceConst(), - dPhaseComposition_dTemperature.toSliceConst(), - dPhaseComposition_dGlobalCompFraction.toSliceConst(), + dPhaseComposition.toSliceConst(), perturbedValue, - dPerturbedValue_dPressure, - dPerturbedValue_dTemperature, - dPerturbedValue_dGlobalCompFraction.toSlice(), + dPerturbedValue.toSlice(), useMass ); - checkRelativeError( (perturbedValue-value)/dC, dValue_dGlobalCompFraction[i], relTol ); + checkRelativeError( (perturbedValue-value)/dC, dValue[Deriv::dC+i], relTol ); } } @@ -240,54 +222,58 @@ void testNumericalDerivatives( FLASH_WRAPPER const & flashModelWrapper, real64 const perturbParameter, real64 const relTol ) { + using namespace multifluid; + + integer constexpr numPhase = 2; + integer constexpr numComp = 2; + integer constexpr numDof = numComp + 2; + // 1) First compute the unperturbed pressure - stackArray1d< real64, 2 > phaseFraction( 2 ); - stackArray1d< real64, 2 > dPhaseFraction_dPres( 2 ); - stackArray1d< real64, 2 > dPhaseFraction_dTemp( 2 ); - stackArray2d< real64, 4 > dPhaseFraction_dCompFraction( 2, 2 ); - stackArray2d< real64, 4 > phaseCompFraction( 2, 2 ); - stackArray2d< real64, 4 > dPhaseCompFraction_dPres( 2, 2 ); - stackArray2d< real64, 4 > dPhaseCompFraction_dTemp( 2, 2 ); - stackArray3d< real64, 8 > dPhaseCompFraction_dCompFraction( 2, 2, 2 ); + + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseFrac( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseFrac( 1, 1, numPhase, numDof ); + MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > + phaseFracAndDeriv { phaseFrac[0][0], dPhaseFrac[0][0] }; + + StackArray< real64, 4, numComp *numPhase, LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhase, numComp ); + StackArray< real64, 5, numDof *numComp *numPhase, LAYOUT_PHASE_COMP_DC > dPhaseCompFrac( 1, 1, numPhase, numComp, numDof ); + MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > + phaseCompFracAndDeriv { phaseCompFrac[0][0], dPhaseCompFrac[0][0] }; + flashModelWrapper.compute( pressure, temperature, compFraction, - phaseFraction.toSlice(), - dPhaseFraction_dPres.toSlice(), - dPhaseFraction_dTemp.toSlice(), - dPhaseFraction_dCompFraction.toSlice(), - phaseCompFraction.toSlice(), - dPhaseCompFraction_dPres.toSlice(), - dPhaseCompFraction_dTemp.toSlice(), - dPhaseCompFraction_dCompFraction.toSlice() ); - stackArray1d< real64, 2 > perturbedPhaseFraction( 2 ); - stackArray1d< real64, 2 > dPerturbedPhaseFraction_dPres( 2 ); - stackArray1d< real64, 2 > dPerturbedPhaseFraction_dTemp( 2 ); - stackArray2d< real64, 4 > dPerturbedPhaseFraction_dCompFraction( 2, 2 ); - stackArray2d< real64, 4 > perturbedPhaseCompFraction( 2, 2 ); - stackArray2d< real64, 4 > dPerturbedPhaseCompFraction_dPres( 2, 2 ); - stackArray2d< real64, 4 > dPerturbedPhaseCompFraction_dTemp( 2, 2 ); - stackArray3d< real64, 8 > dPerturbedPhaseCompFraction_dCompFraction( 2, 2, 2 ); + phaseFracAndDeriv, + phaseCompFracAndDeriv ); + + StackArray< real64, 3, numPhase, LAYOUT_PHASE > perturbedPhaseFrac( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPerturbedPhaseFrac( 1, 1, numPhase, numDof ); + MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > + perturbedPhaseFracAndDeriv { perturbedPhaseFrac[0][0], dPerturbedPhaseFrac[0][0] }; + + StackArray< real64, 4, numComp *numPhase, LAYOUT_PHASE_COMP > perturbedPhaseCompFrac( 1, 1, numPhase, numComp ); + StackArray< real64, 5, numDof *numComp *numPhase, LAYOUT_PHASE_COMP_DC > dPerturbedPhaseCompFrac( 1, 1, numPhase, numComp, numDof ); + MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > + perturbedPhaseCompFracAndDeriv { perturbedPhaseCompFrac[0][0], dPerturbedPhaseCompFrac[0][0] }; // 2) Check derivative with respect to pressure real64 const dP = perturbParameter * (pressure + perturbParameter); flashModelWrapper.compute( pressure + dP, temperature, compFraction, - perturbedPhaseFraction.toSlice(), - dPerturbedPhaseFraction_dPres.toSlice(), - dPerturbedPhaseFraction_dTemp.toSlice(), - dPerturbedPhaseFraction_dCompFraction.toSlice(), - perturbedPhaseCompFraction.toSlice(), - dPerturbedPhaseCompFraction_dPres.toSlice(), - dPerturbedPhaseCompFraction_dTemp.toSlice(), - dPerturbedPhaseCompFraction_dCompFraction.toSlice() ); - for( localIndex i = 0; i < 2; ++i ) + perturbedPhaseFracAndDeriv, + perturbedPhaseCompFracAndDeriv ); + + for( integer i = 0; i < numPhase; ++i ) { - checkRelativeError( (perturbedPhaseFraction[i]-phaseFraction[i])/dP, dPhaseFraction_dPres[i], relTol ); - for( localIndex j = 0; j < 2; ++j ) + checkRelativeError( (perturbedPhaseFracAndDeriv.value[i]-phaseFracAndDeriv.value[i])/dP, + phaseFracAndDeriv.derivs[i][Deriv::dP], + relTol ); + for( integer j = 0; j < numComp; ++j ) { - checkRelativeError( (perturbedPhaseCompFraction[i][j]-phaseCompFraction[i][j])/dP, dPhaseCompFraction_dPres[i][j], relTol ); + checkRelativeError( (perturbedPhaseCompFracAndDeriv.value[i][j]-phaseCompFracAndDeriv.value[i][j])/dP, + phaseCompFracAndDeriv.derivs[i][j][Deriv::dP], + relTol ); } } @@ -296,49 +282,45 @@ void testNumericalDerivatives( FLASH_WRAPPER const & flashModelWrapper, flashModelWrapper.compute( pressure, temperature + dT, compFraction, - perturbedPhaseFraction.toSlice(), - dPerturbedPhaseFraction_dPres.toSlice(), - dPerturbedPhaseFraction_dTemp.toSlice(), - dPerturbedPhaseFraction_dCompFraction.toSlice(), - perturbedPhaseCompFraction.toSlice(), - dPerturbedPhaseCompFraction_dPres.toSlice(), - dPerturbedPhaseCompFraction_dTemp.toSlice(), - dPerturbedPhaseCompFraction_dCompFraction.toSlice() ); - for( localIndex i = 0; i < 2; ++i ) + perturbedPhaseFracAndDeriv, + perturbedPhaseCompFracAndDeriv ); + for( integer i = 0; i < numPhase; ++i ) { - checkRelativeError( (perturbedPhaseFraction[i]-phaseFraction[i])/dT, dPhaseFraction_dTemp[i], relTol ); - for( localIndex j = 0; j < 2; ++j ) + checkRelativeError( (perturbedPhaseFracAndDeriv.value[i]-phaseFracAndDeriv.value[i])/dT, + phaseFracAndDeriv.derivs[i][Deriv::dT], + relTol ); + for( integer j = 0; j < numComp; ++j ) { - checkRelativeError( (perturbedPhaseCompFraction[i][j]-phaseCompFraction[i][j])/dT, dPhaseCompFraction_dTemp[i][j], relTol ); + checkRelativeError( (perturbedPhaseCompFracAndDeriv.value[i][j]-phaseCompFracAndDeriv.value[i][j])/dT, + phaseCompFracAndDeriv.derivs[i][j][Deriv::dT], + relTol ); } } // 4) Check derivatives with respect to phaseComposition - for( localIndex i = 0; i < 2; ++i ) + for( integer i = 0; i < numComp; ++i ) { real64 const dC = perturbParameter * (compFraction[i] + perturbParameter); - stackArray1d< real64, 2 > perturbedCompFraction( 2 ); - for( localIndex j = 0; j < 2; ++j ) + stackArray1d< real64, numComp > perturbedCompFraction( numComp ); + for( integer j = 0; j < numComp; ++j ) { perturbedCompFraction[j] = compFraction[j] + ( (i == j) ? dC : 0.0 ); } flashModelWrapper.compute( pressure, temperature, perturbedCompFraction.toSliceConst(), - perturbedPhaseFraction.toSlice(), - dPerturbedPhaseFraction_dPres.toSlice(), - dPerturbedPhaseFraction_dTemp.toSlice(), - dPerturbedPhaseFraction_dCompFraction.toSlice(), - perturbedPhaseCompFraction.toSlice(), - dPerturbedPhaseCompFraction_dPres.toSlice(), - dPerturbedPhaseCompFraction_dTemp.toSlice(), - dPerturbedPhaseCompFraction_dCompFraction.toSlice() ); - for( localIndex j = 0; j < 2; ++j ) + perturbedPhaseFracAndDeriv, + perturbedPhaseCompFracAndDeriv ); + for( integer j = 0; j < numPhase; ++j ) { - checkRelativeError( (perturbedPhaseFraction[j]-phaseFraction[j])/dC, dPhaseFraction_dCompFraction[j][i], relTol ); - for( localIndex k = 0; k < 2; ++k ) + checkRelativeError( (perturbedPhaseFracAndDeriv.value[j]-phaseFracAndDeriv.value[j])/dC, + phaseFracAndDeriv.derivs[j][Deriv::dC+i], + relTol ); + for( integer k = 0; k < numComp; ++k ) { - checkRelativeError( (perturbedPhaseCompFraction[j][k]-phaseCompFraction[j][k])/dC, dPhaseCompFraction_dCompFraction[j][k][i], relTol ); + checkRelativeError( (perturbedPhaseCompFracAndDeriv.value[j][k]-phaseCompFracAndDeriv.value[j][k])/dC, + phaseCompFracAndDeriv.derivs[j][k][Deriv::dC+i], + relTol ); } } } @@ -476,12 +458,12 @@ TEST_F( PhillipsBrineViscosityTest, brineViscosityValuesAndDeriv ) PhillipsBrineViscosity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -527,12 +509,12 @@ TEST_F( EzrokhiBrineViscosityTest, brineViscosityValuesAndDeriv ) EzrokhiBrineViscosity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, true, eps, relTol ); counter++; @@ -584,12 +566,12 @@ TEST_F( FenghourCO2ViscosityTest, fenghourCO2ViscosityValuesAndDeriv ) FenghourCO2Viscosity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -642,12 +624,12 @@ TEST_F( PhillipsBrineDensityTest, brineCO2DensityMassValuesAndDeriv ) PhillipsBrineDensity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -675,15 +657,13 @@ TEST_F( PhillipsBrineDensityTest, brineCO2DensityMolarValuesAndDeriv ) PhillipsBrineDensity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { - //testValuesAgainstPreviousImplementation( pvtFunctionWrapper, - // P[iPres], TC[iTemp], comp, savedValues[counter], false, relTol ); testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, false, eps, relTol ); counter++; } @@ -728,12 +708,12 @@ TEST_F( EzrokhiBrineDensityTest, brineCO2DensityMassValuesAndDeriv ) EzrokhiBrineDensity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, true, eps, relTol ); counter++; @@ -759,12 +739,12 @@ TEST_F( EzrokhiBrineDensityTest, brineCO2DensityMolarValuesAndDeriv ) EzrokhiBrineDensity::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, false, eps, relTol ); counter++; @@ -818,12 +798,12 @@ TEST_F( SpanWagnerCO2DensityTest, spanWagnerCO2DensityMassValuesAndDeriv ) SpanWagnerCO2Density::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTolPrevImpl ); @@ -857,12 +837,12 @@ TEST_F( SpanWagnerCO2DensityTest, spanWagnerCO2DensityMolarValuesAndDeriv ) SpanWagnerCO2Density::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], false, relTolPrevImpl ); @@ -922,12 +902,12 @@ TEST_F( CO2SolubilityTest, co2SolubilityValuesAndDeriv ) CO2Solubility::KernelWrapper flashModelWrapper = flashModel->createKernelWrapper(); - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( flashModelWrapper, P[iPres], TC[iTemp], comp, @@ -982,12 +962,12 @@ TEST_F( BrineEnthalpyTest, BrineEnthalpyMassValuesAndDeriv ) 174031.122202, 175899.343122, 177450.286494, 135147.894170, 136387.199707, 137419.018273, 121682.558928, 123001.503570, 124098.561778, 88756.649542, 90350.327221, 91670.592316 }; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -1021,12 +1001,12 @@ TEST_F( BrineEnthalpyTest, BrineEnthalpyMolarValuesAndDeriv ) 10823742.150877, 10903416.807419, 10969752.900309, 10288015.835964, 10372160.580672, 10442128.397178, 6850772.616574, 6903815.290194, 6947985.177129, 6544742.270173, 6599594.923452, 6645247.529535, 5796426.147754, 5857522.733710, 5908248.223573}; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], false, relTol ); @@ -1083,12 +1063,12 @@ TEST_F( CO2EnthalpyTest, CO2EnthalpyMassValuesAndDeriv ) 10779.101555, -37449.569995, -36262.216311, -35283.355068, 28447.084306, 29131.068469, 29700.204529, 9320.187656, 10117.295548, 10779.101555, -37449.569995, -36262.216311, -35283.355068}; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -1122,12 +1102,12 @@ TEST_F( CO2EnthalpyTest, CO2EnthalpyMolarValuesAndDeriv ) 211822.446731, 229938.535180, 244979.580788, -851126.590796, -824141.279795, -801894.433361, 646524.643323, 662069.737939, 675004.648394, 211822.446731, 229938.535180, 244979.580788, -851126.590796, -824141.279795, -801894.433361 }; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], false, relTol ); @@ -1184,12 +1164,12 @@ TEST_F( BrineInternalEnergyTest, BrineInternalEnergyMassValuesAndDeriv ) 12984.500000, 12985.100000, 12985.600000}; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -1223,12 +1203,12 @@ TEST_F( BrineInternalEnergyTest, BrineInternalEnergyMolarValuesAndDeriv ) 7640.500000, 7641.100000, 7641.600000, 12984.500000, 12985.100000, 12985.600000, 5106.500000, 5107.100000, 5107.600000, 7640.500000, 7641.100000, 7641.600000, 12984.500000, 12985.100000, 12985.600000}; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], false, relTol ); @@ -1285,12 +1265,12 @@ TEST_F( CO2InternalEnergyTest, CO2InternalEnergyMassValuesAndDeriv ) 12984.500000, 12985.100000, 12985.600000}; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); @@ -1324,12 +1304,12 @@ TEST_F( CO2InternalEnergyTest, CO2InternalEnergyMolarValuesAndDeriv ) 7640.500000, 7641.100000, 7641.600000, 12984.500000, 12985.100000, 12985.600000, 5106.500000, 5107.100000, 5107.600000, 7640.500000, 7641.100000, 7641.600000, 12984.500000, 12985.100000, 12985.600000}; - localIndex counter = 0; - for( localIndex iComp = 0; iComp < 3; ++iComp ) + integer counter = 0; + for( integer iComp = 0; iComp < 3; ++iComp ) { - for( localIndex iPres = 0; iPres < 3; ++iPres ) + for( integer iPres = 0; iPres < 3; ++iPres ) { - for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + for( integer iTemp = 0; iTemp < 3; ++iTemp ) { testValuesAgainstPreviousImplementation( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, savedValues[counter], false, relTol ); diff --git a/src/docs/sphinx/CompleteXMLSchema.rst b/src/docs/sphinx/CompleteXMLSchema.rst index 2e6e0655a42..5c06aa25849 100644 --- a/src/docs/sphinx/CompleteXMLSchema.rst +++ b/src/docs/sphinx/CompleteXMLSchema.rst @@ -2007,20 +2007,6 @@ Datastructure: WellElementRegionuniqueSubRegion .. include:: ../../coreComponents/schema/docs/WellElementRegionuniqueSubRegion_other.rst -.. _DATASTRUCTURE_cellBlocks: - -Datastructure: cellBlocks -========================= -.. include:: ../../coreComponents/schema/docs/cellBlocks_other.rst - - -.. _DATASTRUCTURE_cellManager: - -Datastructure: cellManager -========================== -.. include:: ../../coreComponents/schema/docs/cellManager_other.rst - - .. _DATASTRUCTURE_commandLine: Datastructure: commandLine From 73e01aa0d046b30122c95301cfee6e2989347ebf Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 16 Feb 2022 16:14:51 -0800 Subject: [PATCH 2/6] fixed the testMultiFluid unit test --- .../fluid/MultiPhaseMultiComponentFluid.hpp | 23 ++- .../fluid/PVTFunctions/CO2Solubility.hpp | 2 - .../constitutiveTests/testMultiFluid.cpp | 191 ++++++++---------- 3 files changed, 94 insertions(+), 122 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index 7403ec1755d..cb0b1ec753c 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -409,24 +409,27 @@ MultiPhaseMultiComponentFluid< P1DENS, P1VISC, P2DENS, P2VISC, FLASH >::KernelWr real64 phaseMolarDens{}; stackArray1d< real64, numComp+2 > dPhaseMolarDens( numComp+2 ); - m_p2Density.compute( pressure, + + m_p1Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), + phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), phaseMolarDens, dPhaseMolarDens.toSlice(), false ); + phaseMolecularWeight[ip1] = phaseDensity.value[ip1] / phaseMolarDens; + for( integer idof = 0; idof < numComp+2; ++idof ) + { + dPhaseMolecularWeight[ip1][idof] = phaseDensity.derivs[ip1][idof] / phaseMolarDens - phaseMolecularWeight[ip1] * dPhaseMolarDens[idof] / phaseMolarDens; + } - m_p1Density.compute( pressure, + m_p2Density.compute( pressure, temperatureInCelsius, - phaseCompFraction.value[ip1].toSliceConst(), phaseCompFraction.derivs[ip1].toSliceConst(), + phaseCompFraction.value[ip2].toSliceConst(), phaseCompFraction.derivs[ip2].toSliceConst(), phaseMolarDens, dPhaseMolarDens.toSlice(), false ); - for( integer ip = 0; ip < numPhase; ++ip ) + phaseMolecularWeight[ip2] = phaseDensity.value[ip2] / phaseMolarDens; + for( integer idof = 0; idof < numComp+2; ++idof ) { - phaseMolecularWeight[ip] = phaseDensity.value[ip] / phaseMolarDens; - for( integer idof = 0; idof < numComp+2; ++idof ) - { - dPhaseMolecularWeight[ip][idof] = phaseDensity.derivs[ip][idof] / phaseMolarDens - phaseMolecularWeight[ip] * dPhaseMolarDens[idof] / phaseMolarDens; - } + dPhaseMolecularWeight[ip2][idof] = phaseDensity.derivs[ip2][idof] / phaseMolarDens - phaseMolecularWeight[ip2] * dPhaseMolarDens[idof] / phaseMolarDens; } // 4.2 Convert the mole fractions to mass fractions diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp index 402c13f68cb..afebf8fb7e9 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp @@ -319,8 +319,6 @@ CO2SolubilityUpdate::compute( real64 const & pressure, // gas phase composition CO2 = 1.0 - LvArray::forValuesInSlice( phaseCompFraction.derivs, setZero ); - phaseCompFraction.value[m_phaseGasIndex][m_CO2Index] = 1.0; phaseCompFraction.value[m_phaseGasIndex][m_waterIndex] = 0.0; diff --git a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp index d85015135b8..20d137c464b 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp @@ -120,12 +120,13 @@ void testNumericalDerivatives( MultiFluidBase & fluid, real64 const relTol, real64 const absTol = std::numeric_limits< real64 >::max() ) { - localIndex const NC = fluid.numFluidComponents(); - localIndex const NP = fluid.numFluidPhases(); + integer const NC = fluid.numFluidComponents(); + integer const NP = fluid.numFluidPhases(); + integer const NDOF = NC+2; // Copy input values into an array with expected layout array2d< real64, compflow::LAYOUT_COMP > compositionValues( 1, NC ); - for( localIndex i = 0; i < NC; ++i ) + for( integer i = 0; i < NC; ++i ) { compositionValues[0][i] = compositionInput[i]; } @@ -147,37 +148,27 @@ void testNumericalDerivatives( MultiFluidBase & fluid, MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > phaseFrac { GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::phaseFraction ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseFraction_dPressure ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseFraction_dTemperature ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseFraction_dGlobalCompFraction ) + GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseFraction ) }; MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > phaseDens { GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::phaseDensity ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseDensity_dPressure ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseDensity_dTemperature ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseDensity_dGlobalCompFraction ) + GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseDensity ) }; MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > phaseVisc { GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::phaseViscosity ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseViscosity_dPressure ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseViscosity_dTemperature ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseViscosity_dGlobalCompFraction ) + GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseViscosity ) }; MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > phaseCompFrac { GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::phaseCompFraction ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseCompFraction_dPressure ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseCompFraction_dTemperature ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseCompFraction_dGlobalCompFraction ) + GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dPhaseCompFraction ) }; MultiFluidVarSlice< real64, 0, USD_FLUID - 2, USD_FLUID_DC - 2 > totalDens { GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::totalDensity ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dTotalDensity_dPressure ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dTotalDensity_dTemperature ), - GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dTotalDensity_dGlobalCompFraction ) + GET_FLUID_DATA( fluid, extrinsicMeshData::multifluid::dTotalDensity ) }; auto const & phaseFracCopy = GET_FLUID_DATA( fluidCopy, extrinsicMeshData::multifluid::phaseFraction ); @@ -200,20 +191,27 @@ void testNumericalDerivatives( MultiFluidBase & fluid, { typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); + // to be able to use the checkDerivative utility function, we have to invert the layout + auto dPhaseFrac = invertLayout( phaseFrac.derivs.toSliceConst(), NP, NDOF ); + auto dPhaseDens = invertLayout( phaseDens.derivs.toSliceConst(), NP, NDOF ); + auto dPhaseVisc = invertLayout( phaseVisc.derivs.toSliceConst(), NP, NDOF ); + auto dTotalDens = invertLayout( totalDens.derivs.toSliceConst(), NDOF ); + auto dPhaseCompFrac = invertLayout( phaseCompFrac.derivs.toSliceConst(), NP, NC, NDOF ); + // update pressure and check derivatives { real64 const dP = perturbParameter * (P + perturbParameter); fluidWrapper.update( 0, 0, P + dP, T, composition ); - checkDerivative( phaseFracCopy.toSliceConst(), phaseFrac.value.toSliceConst(), phaseFrac.dPres.toSliceConst(), + checkDerivative( phaseFracCopy.toSliceConst(), phaseFrac.value.toSliceConst(), dPhaseFrac[Deriv::dP].toSliceConst(), dP, relTol, absTol, "phaseFrac", "Pres", phases ); - checkDerivative( phaseDensCopy.toSliceConst(), phaseDens.value.toSliceConst(), phaseDens.dPres.toSliceConst(), + checkDerivative( phaseDensCopy.toSliceConst(), phaseDens.value.toSliceConst(), dPhaseDens[Deriv::dP].toSliceConst(), dP, relTol, absTol, "phaseDens", "Pres", phases ); - checkDerivative( phaseViscCopy.toSliceConst(), phaseVisc.value.toSliceConst(), phaseVisc.dPres.toSliceConst(), + checkDerivative( phaseViscCopy.toSliceConst(), phaseVisc.value.toSliceConst(), dPhaseVisc[Deriv::dP].toSliceConst(), dP, relTol, absTol, "phaseVisc", "Pres", phases ); - checkDerivative( totalDensCopy, totalDens.value, totalDens.dPres, + checkDerivative( totalDensCopy, totalDens.value, dTotalDens[Deriv::dP], dP, relTol, absTol, "totalDens", "Pres" ); - checkDerivative( phaseCompFracCopy.toSliceConst(), phaseCompFrac.value.toSliceConst(), phaseCompFrac.dPres.toSliceConst(), + checkDerivative( phaseCompFracCopy.toSliceConst(), phaseCompFrac.value.toSliceConst(), dPhaseCompFrac[Deriv::dP].toSliceConst(), dP, relTol, absTol, "phaseCompFrac", "Pres", phases, components ); } @@ -222,30 +220,23 @@ void testNumericalDerivatives( MultiFluidBase & fluid, real64 const dT = perturbParameter * (T + perturbParameter); fluidWrapper.update( 0, 0, P, T + dT, composition ); - checkDerivative( phaseFracCopy.toSliceConst(), phaseFrac.value.toSliceConst(), phaseFrac.dTemp.toSliceConst(), + checkDerivative( phaseFracCopy.toSliceConst(), phaseFrac.value.toSliceConst(), dPhaseFrac[Deriv::dT].toSliceConst(), dT, relTol, absTol, "phaseFrac", "Temp", phases ); - checkDerivative( phaseDensCopy.toSliceConst(), phaseDens.value.toSliceConst(), phaseDens.dTemp.toSliceConst(), + checkDerivative( phaseDensCopy.toSliceConst(), phaseDens.value.toSliceConst(), dPhaseDens[Deriv::dT].toSliceConst(), dT, relTol, absTol, "phaseDens", "Temp", phases ); - checkDerivative( phaseViscCopy.toSliceConst(), phaseVisc.value.toSliceConst(), phaseVisc.dTemp.toSliceConst(), + checkDerivative( phaseViscCopy.toSliceConst(), phaseVisc.value.toSliceConst(), dPhaseVisc[Deriv::dT].toSliceConst(), dT, relTol, absTol, "phaseVisc", "Temp", phases ); - checkDerivative( totalDensCopy, totalDens.value, totalDens.dTemp, + checkDerivative( totalDensCopy, totalDens.value, dTotalDens[Deriv::dT], dT, relTol, absTol, "totalDens", "Temp" ); - checkDerivative( phaseCompFracCopy.toSliceConst(), phaseCompFrac.value.toSliceConst(), phaseCompFrac.dTemp.toSliceConst(), + checkDerivative( phaseCompFracCopy.toSliceConst(), phaseCompFrac.value.toSliceConst(), dPhaseCompFrac[Deriv::dT].toSliceConst(), dT, relTol, absTol, "phaseCompFrac", "Temp", phases, components ); } - // update composition and check derivatives - auto dPhaseFrac_dC = invertLayout( phaseFrac.dComp.toSliceConst(), NP, NC ); - auto dPhaseDens_dC = invertLayout( phaseDens.dComp.toSliceConst(), NP, NC ); - auto dPhaseVisc_dC = invertLayout( phaseVisc.dComp.toSliceConst(), NP, NC ); - auto dTotalDens_dC = invertLayout( totalDens.dComp.toSliceConst(), NC ); - auto dPhaseCompFrac_dC = invertLayout( phaseCompFrac.dComp.toSliceConst(), NP, NC, NC ); - array2d< real64, compflow::LAYOUT_COMP > compNew( 1, NC ); - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { real64 const dC = perturbParameter * ( composition[jc] + perturbParameter ); - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compNew[0][ic] = composition[ic]; } @@ -265,11 +256,11 @@ void testNumericalDerivatives( MultiFluidBase & fluid, { // renormalize real64 sum = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { sum += compNew[0][ic]; } - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { compNew[0][ic] /= sum; } @@ -278,15 +269,15 @@ void testNumericalDerivatives( MultiFluidBase & fluid, fluidWrapper.update( 0, 0, P, T, compNew[0] ); string const var = "compFrac[" + components[jc] + "]"; - checkDerivative( phaseFracCopy.toSliceConst(), phaseFrac.value.toSliceConst(), dPhaseFrac_dC[jc].toSliceConst(), + checkDerivative( phaseFracCopy.toSliceConst(), phaseFrac.value.toSliceConst(), dPhaseFrac[Deriv::dC+jc].toSliceConst(), dC, relTol, absTol, "phaseFrac", var, phases ); - checkDerivative( phaseDensCopy.toSliceConst(), phaseDens.value.toSliceConst(), dPhaseDens_dC[jc].toSliceConst(), + checkDerivative( phaseDensCopy.toSliceConst(), phaseDens.value.toSliceConst(), dPhaseDens[Deriv::dC+jc].toSliceConst(), dC, relTol, absTol, "phaseDens", var, phases ); - checkDerivative( phaseViscCopy.toSliceConst(), phaseVisc.value.toSliceConst(), dPhaseVisc_dC[jc].toSliceConst(), + checkDerivative( phaseViscCopy.toSliceConst(), phaseVisc.value.toSliceConst(), dPhaseVisc[Deriv::dC+jc].toSliceConst(), dC, relTol, absTol, "phaseVisc", var, phases ); - checkDerivative( totalDensCopy, totalDens.value, dTotalDens_dC[jc], + checkDerivative( totalDensCopy, totalDens.value, dTotalDens[Deriv::dC+jc], dC, relTol, absTol, "totalDens", var ); - checkDerivative( phaseCompFracCopy.toSliceConst(), phaseCompFrac.value.toSliceConst(), dPhaseCompFrac_dC[jc].toSliceConst(), + checkDerivative( phaseCompFracCopy.toSliceConst(), phaseCompFrac.value.toSliceConst(), dPhaseCompFrac[Deriv::dC+jc].toSliceConst(), dC, relTol, absTol, "phaseCompFrac", var, phases, components ); } } ); @@ -308,79 +299,59 @@ void testValuesAgainstPreviousImplementation( CO2BrinePhillipsFluid::KernelWrapp real64 const & savedWaterPhaseWaterComp, real64 const relTol ) { + integer constexpr numPhase = 2; + integer constexpr numComp = 2; + integer constexpr numDof = numComp + 2; + // Copy input values into an array with expected layout - array2d< real64, compflow::LAYOUT_COMP > compositionValues( 1, 2 ); - for( localIndex i = 0; i < 2; ++i ) + array2d< real64, compflow::LAYOUT_COMP > compositionValues( 1, numComp ); + for( integer i = 0; i < numComp; ++i ) { compositionValues[0][i] = compositionInput[i]; } arraySlice1d< real64 const, compflow::USD_COMP - 1 > const composition = compositionValues[0]; - StackArray< real64, 3, 2, LAYOUT_PHASE > phaseFraction( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseFraction_dPressure( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseFraction_dTemperature( 1, 1, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseFraction_dGlobalCompFraction( 1, 1, 2, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > phaseDensity( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseDensity_dPressure( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseDensity_dTemperature( 1, 1, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseDensity_dGlobalCompFraction( 1, 1, 2, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > phaseMassDensity( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseMassDensity_dPressure( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseMassDensity_dTemperature( 1, 1, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseMassDensity_dGlobalCompFraction( 1, 1, 2, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > phaseViscosity( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseViscosity_dPressure( 1, 1, 2 ); - StackArray< real64, 3, 2, LAYOUT_PHASE > dPhaseViscosity_dTemperature( 1, 1, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_DC > dPhaseViscosity_dGlobalCompFraction( 1, 1, 2, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_COMP > phaseCompFraction( 1, 1, 2, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_COMP > dPhaseCompFraction_dPressure( 1, 1, 2, 2 ); - StackArray< real64, 4, 4, LAYOUT_PHASE_COMP > dPhaseCompFraction_dTemperature( 1, 1, 2, 2 ); - StackArray< real64, 5, 8, LAYOUT_PHASE_COMP_DC > dPhaseCompFraction_dGlobalCompFraction( 1, 1, 2, 2, 2 ); + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseFraction( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseFraction( 1, 1, numPhase, numDof ); + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseDensity( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseDensity( 1, 1, numPhase, numDof ); + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseMassDensity( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseMassDensity( 1, 1, numPhase, numDof ); + StackArray< real64, 3, numPhase, LAYOUT_PHASE > phaseViscosity( 1, 1, numPhase ); + StackArray< real64, 4, numDof *numPhase, LAYOUT_PHASE_DC > dPhaseViscosity( 1, 1, numPhase, numDof ); + StackArray< real64, 4, numComp *numPhase, LAYOUT_PHASE_COMP > phaseCompFraction( 1, 1, numPhase, numComp ); + StackArray< real64, 5, numDof *numComp *numPhase, LAYOUT_PHASE_COMP_DC > dPhaseCompFraction( 1, 1, numPhase, numComp, numDof ); StackArray< real64, 2, 1, LAYOUT_FLUID > totalDensity( 1, 1 ); - StackArray< real64, 2, 1, LAYOUT_FLUID > dTotalDensity_dPressure( 1, 1 ); - StackArray< real64, 2, 1, LAYOUT_FLUID > dTotalDensity_dTemperature( 1, 1 ); - StackArray< real64, 3, 2, LAYOUT_FLUID_DC > dTotalDensity_dGlobalCompFraction( 1, 1, 2 ); + StackArray< real64, 3, numDof, LAYOUT_FLUID_DC > dTotalDensity( 1, 1, numDof ); wrapper.compute( P, T, composition, { phaseFraction[0][0], - dPhaseFraction_dPressure[0][0], - dPhaseFraction_dTemperature[0][0], - dPhaseFraction_dGlobalCompFraction[0][0] + dPhaseFraction[0][0] }, { phaseDensity[0][0], - dPhaseDensity_dPressure[0][0], - dPhaseDensity_dTemperature[0][0], - dPhaseDensity_dGlobalCompFraction[0][0] + dPhaseDensity[0][0] }, { phaseMassDensity[0][0], - dPhaseMassDensity_dPressure[0][0], - dPhaseMassDensity_dTemperature[0][0], - dPhaseMassDensity_dGlobalCompFraction[0][0] + dPhaseMassDensity[0][0] }, { phaseViscosity[0][0], - dPhaseViscosity_dPressure[0][0], - dPhaseViscosity_dTemperature[0][0], - dPhaseViscosity_dGlobalCompFraction[0][0] + dPhaseViscosity[0][0] }, { phaseCompFraction[0][0], - dPhaseCompFraction_dPressure[0][0], - dPhaseCompFraction_dTemperature[0][0], - dPhaseCompFraction_dGlobalCompFraction[0][0] + dPhaseCompFraction[0][0] }, { totalDensity[0][0], - dTotalDensity_dPressure[0][0], - dTotalDensity_dTemperature[0][0], - dTotalDensity_dGlobalCompFraction[0][0] + dTotalDensity[0][0] } ); checkRelativeError( totalDensity[0][0], savedTotalDensity, relTol ); - for( localIndex ip = 0; ip < 2; ++ip ) + for( integer ip = 0; ip < numPhase; ++ip ) { real64 const savedPhaseFrac = ( ip == 0 ) ? savedGasPhaseFrac : 1 - savedGasPhaseFrac; checkRelativeError( phaseFraction[0][0][ip], savedPhaseFrac, relTol ); @@ -390,7 +361,7 @@ void testValuesAgainstPreviousImplementation( CO2BrinePhillipsFluid::KernelWrapp checkRelativeError( phaseMassDensity[0][0][ip], savedPhaseMassDens, relTol ); real64 const savedPhaseVisc = ( ip == 0 ) ? savedGasVisc : savedWaterVisc; checkRelativeError( phaseViscosity[0][0][ip], savedPhaseVisc, relTol ); - for( localIndex ic = 0; ic < 2; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { real64 savedCompFrac = 0.0; if( ip == 0 ) @@ -566,8 +537,8 @@ MultiFluidBase & makeDeadOilFluidFromTable( string const & name, Group * parent // 1) First, define the tables (PVDO, PVDG) // 1D table with linear interpolation - localIndex const NaxisPVDO = 21; - localIndex const NaxisPVDG = 13; + integer const NaxisPVDO = 21; + integer const NaxisPVDG = 13; array1d< real64_array > coordinatesPVDO; real64_array valuesPVDO_Bo( NaxisPVDO ); @@ -730,7 +701,7 @@ TEST_F( LiveOilFluidTest, numericalDerivativesMolar ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-12; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { testNumericalDerivatives( *fluid, parent, P[i], T, comp, eps, false, relTol ); } @@ -748,7 +719,7 @@ TEST_F( LiveOilFluidTest, numericalDerivativesMass ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-12; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { testNumericalDerivatives( *fluid, parent, P[i], T, comp, eps, false, relTol ); } @@ -791,7 +762,7 @@ TEST_F( DeadOilFluidTest, numericalDerivativesMolar ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-4; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { testNumericalDerivatives( *fluid, parent, P[i], T, comp, eps, false, relTol ); } @@ -810,7 +781,7 @@ TEST_F( DeadOilFluidTest, numericalDerivativesMass ) real64 const relTol = 1e-4; real64 const absTol = 1e-14; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { testNumericalDerivatives( *fluid, parent, P[i], T, comp, eps, false, relTol, absTol ); } @@ -842,7 +813,7 @@ TEST_F( DeadOilFluidFromTableTest, numericalDerivativesMolar ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-4; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { testNumericalDerivatives( *fluid, parent, P[i], T, comp, eps, false, relTol ); } @@ -950,10 +921,10 @@ TEST_F( CO2BrinePhillipsFluidTest, checkAgainstPreviousImplementationMolar ) { 0.99169371576101794652, 0.9917227252632633272, 0.99175665845994742664, 0.98861693470973388553, 0.98865078280193963156, 0.98869031763719927852, 0.98461764703062204518, 0.98464956836357520054, 0.98468678194258063563 }; - localIndex counter = 0; - for( localIndex i = 0; i < 3; ++i ) + integer counter = 0; + for( integer i = 0; i < 3; ++i ) { - for( localIndex j = 0; j < 3; ++j ) + for( integer j = 0; j < 3; ++j ) { testValuesAgainstPreviousImplementation( wrapper, P[i], T[j], comp, @@ -1015,10 +986,10 @@ TEST_F( CO2BrinePhillipsFluidTest, checkAgainstPreviousImplementationMass ) { 0.9797478006656266114, 0.97981828292617156873, 0.97990072673671935188, 0.97227194517798976037, 0.97235397979974458327, 0.97244979317916002692, 0.9625743441996873484, 0.9626514061444874093, 0.962741233539301966 }; - localIndex counter = 0; - for( localIndex i = 0; i < 3; ++i ) + integer counter = 0; + for( integer i = 0; i < 3; ++i ) { - for( localIndex j = 0; j < 3; ++j ) + for( integer j = 0; j < 3; ++j ) { testValuesAgainstPreviousImplementation( wrapper, P[i], T[j], comp, @@ -1046,9 +1017,9 @@ TEST_F( CO2BrinePhillipsFluidTest, numericalDerivativesMolar ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-4; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { - for( localIndex j = 0; j < 3; ++j ) + for( integer j = 0; j < 3; ++j ) { testNumericalDerivatives( *fluid, parent, P[i], T[j], comp, eps, false, relTol ); } @@ -1068,9 +1039,9 @@ TEST_F( CO2BrinePhillipsFluidTest, numericalDerivativesMass ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-8; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { - for( localIndex j = 0; j < 3; ++j ) + for( integer j = 0; j < 3; ++j ) { testNumericalDerivatives( *fluid, parent, P[i], T[j], comp, eps, false, relTol ); } @@ -1143,9 +1114,9 @@ TEST_F( CO2BrineEzrokhiFluidTest, numericalDerivativesMolar ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-4; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { - for( localIndex j = 0; j < 3; ++j ) + for( integer j = 0; j < 3; ++j ) { testNumericalDerivatives( *fluid, parent, P[i], T[j], comp, eps, false, relTol ); } @@ -1165,9 +1136,9 @@ TEST_F( CO2BrineEzrokhiFluidTest, numericalDerivativesMass ) real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); real64 const relTol = 1e-8; - for( localIndex i = 0; i < 3; ++i ) + for( integer i = 0; i < 3; ++i ) { - for( localIndex j = 0; j < 3; ++j ) + for( integer j = 0; j < 3; ++j ) { testNumericalDerivatives( *fluid, parent, P[i], T[j], comp, eps, false, relTol ); } From 1609e7cb2cf45c434843c678b8500a538c145867 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Fri, 18 Feb 2022 09:38:20 -0800 Subject: [PATCH 3/6] addressed review comments; no numerical diffs in integratedTests --- .../codingUtilities/Utilities.hpp | 39 +++++++- .../constitutive/fluid/BlackOilFluid.hpp | 97 +++++++++---------- .../fluid/CompositionalMultiphaseFluid.hpp | 2 +- .../constitutive/fluid/DeadOilFluid.hpp | 6 +- .../constitutive/fluid/MultiFluidBase.hpp | 8 +- .../fluid/PVTFunctions/BrineEnthalpy.hpp | 2 +- .../PVTFunctions/BrineInternalEnergy.hpp | 2 +- .../fluid/PVTFunctions/CO2Enthalpy.hpp | 2 +- .../fluid/PVTFunctions/CO2InternalEnergy.hpp | 2 +- .../fluid/PVTFunctions/CO2Solubility.hpp | 6 +- .../PVTFunctions/EzrokhiBrineDensity.hpp | 2 +- .../PVTFunctions/EzrokhiBrineViscosity.hpp | 2 +- .../PVTFunctions/FenghourCO2Viscosity.hpp | 2 +- .../PVTFunctions/PhillipsBrineDensity.hpp | 2 +- .../PVTFunctions/PhillipsBrineViscosity.hpp | 2 +- .../PVTFunctions/SpanWagnerCO2Density.hpp | 2 +- .../constitutive/fluid/layouts.hpp | 2 +- .../CompositionalMultiphaseBaseKernels.hpp | 4 +- .../CompositionalMultiphaseFVMKernels.cpp | 2 +- .../CompositionalMultiphaseFVMKernels.hpp | 4 +- ...ompositionalMultiphaseHybridFVMKernels.cpp | 8 +- ...ompositionalMultiphaseHybridFVMKernels.hpp | 2 +- .../wells/CompositionalMultiphaseWell.cpp | 2 +- .../CompositionalMultiphaseWellKernels.cpp | 4 +- .../CompositionalMultiphaseWellKernels.hpp | 2 +- .../MultiphasePoromechanicsKernel.hpp | 2 +- .../testCO2BrinePVTModels.cpp | 3 +- .../constitutiveTests/testMultiFluid.cpp | 2 + 28 files changed, 123 insertions(+), 92 deletions(-) diff --git a/src/coreComponents/codingUtilities/Utilities.hpp b/src/coreComponents/codingUtilities/Utilities.hpp index de243ac038b..4a8e096b8ee 100644 --- a/src/coreComponents/codingUtilities/Utilities.hpp +++ b/src/coreComponents/codingUtilities/Utilities.hpp @@ -186,26 +186,46 @@ void forEachArgInTuple( std::tuple< Ts ... > const & tuple, F && func ) // The code below should work with any subscriptable vector/matrix types +/** + * @brief Utility function to copy a vector into another vector + * @tparam VEC1 the type of the source vector + * @tparam VEC2 the type of the destination vector + * @param[in] N the number of values to copy + * @param[in] v1 the source vector + * @param[out] v2 the destination vector + * @param[in] offset the first index of v2 at which we start copying values + */ template< typename VEC1, typename VEC2 > GEOSX_HOST_DEVICE void copy( integer const N, VEC1 const & v1, VEC2 const & v2, - integer const firstDeriv = 0 ) + integer const offset = 0 ) { for( integer i = 0; i < N; ++i ) { - v2[firstDeriv+i] = v1[i]; + v2[offset+i] = v1[i]; } } +/** + * @brief Utility function to apply the chain rule to compute df_dx as a function of df_dy and dy_dx + * @tparam MATRIX the type of the matrix of derivatives + * @tparam VEC1 the type of the source vector + * @tparam VEC2 the type of the destination vector + * @param[in] N the number of derivative values + * @param[in] dy_dx the matrix of derivatives of y(x) wrt x + * @param[in] df_dy the derivatives of f wrt y + * @param[out] df_dx the computed derivatives of f wrt x + * @param[in] firstDerivativeOffset the first derivative offset in df_dy + */ template< typename MATRIX, typename VEC1, typename VEC2 > GEOSX_HOST_DEVICE void applyChainRule( integer const N, MATRIX const & dy_dx, VEC1 const & df_dy, VEC2 && df_dx, - integer const firstDeriv = 0 ) + integer const firstDerivativeOffset = 0 ) { // this could use some dense linear algebra for( integer i = 0; i < N; ++i ) @@ -213,11 +233,22 @@ void applyChainRule( integer const N, df_dx[i] = 0.0; for( integer j = 0; j < N; ++j ) { - df_dx[i] += df_dy[firstDeriv+j] * dy_dx[j][i]; + df_dx[i] += df_dy[firstDerivativeOffset+j] * dy_dx[j][i]; } } } +/** + * @brief Utility function to apply the chain rule to compute df_dxy in place + * @tparam MATRIX the type of the matrix of derivatives + * @tparam VEC1 the type of the source vector + * @tparam VEC2 the type of the utility vector + * @param[in] N the number of derivative values + * @param[in] dy_dx the matrix of derivatives of y(x) wrt x + * @param[out] df_dxy the derivatives of f wrt y + * @param[out] work utility array + * @param[in] offset the first derivative offset in df_dy + */ template< typename MATRIX, typename VEC1, typename VEC2 > GEOSX_HOST_DEVICE void applyChainRuleInPlace( integer const N, diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp index 7da3479837b..89021fd9bfe 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp @@ -231,7 +231,6 @@ class BlackOilFluid : public BlackOilFluidBase /** * @brief Utility function to compute Bo and Visc (and derivatives) as a function of Rs in the undersaturated case * @param[in] needDerivs flag to decide whether derivatives are computed or not - * @param[in] numHydrocarbonComp number of hydrocarbon components * @param[in] pres pressure in the cell * @param[in] Rs ratio of volume of gas to the volume of oil at standard conditions * @param[in] dRs_dComp derivatives of the ratio of volume of gas to the volume of oil at standard conditions wrt comp fractions @@ -244,7 +243,6 @@ class BlackOilFluid : public BlackOilFluidBase */ GEOSX_HOST_DEVICE void computeUndersaturatedBoViscosity( bool const needDerivs, - integer const numHydrocarbonComp, real64 const pres, real64 const Rs, real64 const dRs_dComp[], @@ -272,7 +270,6 @@ class BlackOilFluid : public BlackOilFluidBase * @brief Utility function to compute the mass and molar densities as a function of Rs and Bo * @param[in] needDerivs flag to decide whether derivatives are computed or not * @param[in] useMass flag to decide whether we return mass or molar densities - * @param[in] numHydrocarbonComp number of hydrocarbon components * @param[in] Rs ratio of volume of gas to the volume of oil at standard conditions * @param[in] dRs_dPres derivative of the ratio of volume of gas to the volume of oil at standard conditions wrt pressure * @param[in] dRs_dComp derivatives of the ratio of volume of gas to the volume of oil at standard conditions wrt comp fractions @@ -285,7 +282,6 @@ class BlackOilFluid : public BlackOilFluidBase GEOSX_HOST_DEVICE void computeMassMoleDensity( bool const needDerivs, bool const useMass, - integer const numHydrocarbonComp, real64 const Rs, real64 const dRs_dPres, real64 const dRs_dComp[], @@ -543,7 +539,7 @@ BlackOilFluid::KernelWrapper:: PhaseProp::SliceType const & phaseFraction, PhaseComp::SliceType const & phaseCompFraction ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; using PT = BlackOilFluid::PhaseType; integer const ipOil = m_phaseOrder[PT::OIL]; @@ -560,10 +556,11 @@ BlackOilFluid::KernelWrapper:: // 1. Make everything zero first - LvArray::forValuesInSlice( phaseFraction.value, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseFraction.derivs, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseCompFraction.value, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseCompFraction.derivs, []( real64 & val ){ val = 0.0; } ); + auto setZero = []( real64 & val ){ val = 0.0; }; + LvArray::forValuesInSlice( phaseFraction.value, setZero ); + LvArray::forValuesInSlice( phaseFraction.derivs, setZero ); + LvArray::forValuesInSlice( phaseCompFraction.value, setZero ); + LvArray::forValuesInSlice( phaseCompFraction.derivs, setZero ); // 2. Check feed first, and if only water is present (e.g., water inj), then skip @@ -585,33 +582,32 @@ BlackOilFluid::KernelWrapper:: real64 RsSat = 0.0; real64 dRsSat_dP = 0.0; computeRs( pressure, RsSat, dRsSat_dP ); - - // gas - real64 const & gasSurfaceMoleDensity = m_PVTOView.m_surfaceMoleDensity[PT::GAS]; - if( RsSat < minForPhasePresence ) { RsSat = minForPhasePresence; } + // gas + real64 const & gasSurfaceMoleDensity = m_PVTOView.m_surfaceMoleDensity[PT::GAS]; + // 4. Use the saturated Rs and density to compute the gas phase fraction // Note : we assume the oil component cannot enter the gas phase real64 const Kg = ( oilSurfaceMoleDensity + gasSurfaceMoleDensity * RsSat ) / ( RsSat * gasSurfaceMoleDensity ); real64 const dKg_dP = -oilSurfaceMoleDensity / gasSurfaceMoleDensity * dRsSat_dP / ( RsSat * RsSat ); - real64 const gasPhaseFraction = zo / ( 1. - Kg ) + zg; - real64 const dGasPhaseFraction_dP = zo / ( ( 1. - Kg ) * ( 1. - Kg ) ) * dKg_dP; - real64 const dGasPhaseFraction_dzo = 1. / ( 1. - Kg ); - real64 const dGasPhaseFraction_dzg = 1.; + real64 const gasPhaseFraction = zo / ( 1.0 - Kg ) + zg; + real64 const dGasPhaseFraction_dP = zo / ( ( 1.0 - Kg ) * ( 1.0 - Kg ) ) * dKg_dP; + real64 const dGasPhaseFraction_dzo = 1.0 / ( 1.0 - Kg ); + real64 const dGasPhaseFraction_dzg = 1.0; // 4. Update phase fraction and phase component fractions // 4.1 The gas phase is present - if( ( gasPhaseFraction > 0 ) && ( gasPhaseFraction < 1 ) ) + if( ( gasPhaseFraction > 0.0 ) && ( gasPhaseFraction < 1.0 ) ) { // phase fractions - phaseFraction.value[ipOil] = 1. - gasPhaseFraction - zw; + phaseFraction.value[ipOil] = 1.0 - gasPhaseFraction - zw; phaseFraction.value[ipGas] = gasPhaseFraction; phaseFraction.value[ipWater] = zw; @@ -735,7 +731,7 @@ BlackOilFluid::KernelWrapper:: real64 phaseMolecularWeight[NP_BO], real64 dPhaseMolecularWeight[NP_BO][NC_BO+2] ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; using PT = BlackOilFluid::PhaseType; integer const ipOil = m_phaseOrder[PT::OIL]; @@ -749,12 +745,13 @@ BlackOilFluid::KernelWrapper:: bool const isGas = (ipGas >= 0 && phaseFrac[ipGas] > 0); bool const isOil = (ipOil >= 0 && phaseFrac[ipOil] > 0); - LvArray::forValuesInSlice( phaseMassDens.value, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseMassDens.derivs, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseDens.value, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseDens.derivs, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseVisc.value, []( real64 & val ){ val = 0.0; } ); - LvArray::forValuesInSlice( phaseVisc.derivs, []( real64 & val ){ val = 0.0; } ); + auto setZero = []( real64 & val ){ val = 0.0; }; + LvArray::forValuesInSlice( phaseMassDens.value, setZero ); + LvArray::forValuesInSlice( phaseMassDens.derivs, setZero ); + LvArray::forValuesInSlice( phaseDens.value, setZero ); + LvArray::forValuesInSlice( phaseDens.derivs, setZero ); + LvArray::forValuesInSlice( phaseVisc.value, setZero ); + LvArray::forValuesInSlice( phaseVisc.derivs, setZero ); // 1. Gas phase: look up in the formation vol factor tables @@ -825,14 +822,14 @@ BlackOilFluid::KernelWrapper:: { real64 Rs = 0.0; - real64 dRs_dC[2]{}; + real64 dRs_dC[HNC_BO]{}; real64 dRs_dP = 0.0; real64 Bo = 0.0; real64 dBo_dP = 0.0; - real64 dBo_dC[2]{}; + real64 dBo_dC[HNC_BO]{}; real64 visc = 0.0; real64 dVisc_dP = 0.0; - real64 dVisc_dC[2]{}; + real64 dVisc_dC[HNC_BO]{}; // saturated conditions if( isGas ) @@ -852,30 +849,30 @@ BlackOilFluid::KernelWrapper:: // compute Rs as a function of composition real64 const densRatio = m_PVTOView.m_surfaceMoleDensity[PT::OIL] / m_PVTOView.m_surfaceMoleDensity[PT::GAS]; Rs = densRatio * composition[icGas] / composition[icOil]; - dRs_dC[icOil] = -densRatio * composition[icGas] / (composition[icOil] * composition[icOil]); - dRs_dC[icGas] = densRatio / composition[icOil]; + dRs_dC[PT::OIL] = -densRatio * composition[icGas] / (composition[icOil] * composition[icOil]); + dRs_dC[PT::GAS] = densRatio / composition[icOil]; // compute undersaturated properties (Bo, viscosity) by two-step interpolation in undersaturated tables // this part returns numerical derivatives - computeUndersaturatedBoViscosity( needDerivs, HNC_BO, pressure, Rs, dRs_dC, Bo, dBo_dP, dBo_dC, + computeUndersaturatedBoViscosity( needDerivs, pressure, Rs, dRs_dC, Bo, dBo_dP, dBo_dC, visc, dVisc_dP, dVisc_dC ); } // compute densities - computeMassMoleDensity( needDerivs, true, HNC_BO, Rs, dRs_dP, dRs_dC, Bo, dBo_dP, dBo_dC, + computeMassMoleDensity( needDerivs, true, Rs, dRs_dP, dRs_dC, Bo, dBo_dP, dBo_dC, phaseMassDens.value[ipOil], phaseMassDens.derivs[ipOil] ); - computeMassMoleDensity( needDerivs, false, HNC_BO, Rs, dRs_dP, dRs_dC, Bo, dBo_dP, dBo_dC, + computeMassMoleDensity( needDerivs, false, Rs, dRs_dP, dRs_dC, Bo, dBo_dP, dBo_dC, phaseDens.value[ipOil], phaseDens.derivs[ipOil] ); phaseMolecularWeight[ipOil] = phaseMassDens.value[ipOil] / phaseDens.value[ipOil]; real64 const tmp = 1. / ( phaseDens.value[ipOil] * phaseDens.value[ipOil] ); - dPhaseMolecularWeight[ipOil][Deriv::dP] = tmp * - ( phaseMassDens.derivs[ipOil][Deriv::dP] * phaseDens.value[ipOil] - phaseDens.derivs[ipOil][Deriv::dP] * phaseMassDens.value[ipOil] ); + dPhaseMolecularWeight[ipOil][Deriv::dP] = + tmp * ( phaseMassDens.derivs[ipOil][Deriv::dP] * phaseDens.value[ipOil] - phaseDens.derivs[ipOil][Deriv::dP] * phaseMassDens.value[ipOil] ); for( integer ic = 0; ic < NC_BO; ++ic ) { - dPhaseMolecularWeight[ipOil][Deriv::dC+ic] = tmp * - ( phaseMassDens.derivs[ipOil][Deriv::dC+ic] * phaseDens.value[ipOil] - phaseDens.derivs[ipOil][Deriv::dC+ic] * phaseMassDens.value[ipOil] ); + dPhaseMolecularWeight[ipOil][Deriv::dC+ic] = + tmp * ( phaseMassDens.derivs[ipOil][Deriv::dC+ic] * phaseDens.value[ipOil] - phaseDens.derivs[ipOil][Deriv::dC+ic] * phaseMassDens.value[ipOil] ); } if( m_useMass ) @@ -891,16 +888,17 @@ BlackOilFluid::KernelWrapper:: } } - /////// TODO FRANCOIS: DOUBLE CHECK THE DERIVATIVE BELOW /////////// - // copy viscosity into the final array // TODO: skip this step phaseVisc.value[ipOil] = visc; if( needDerivs ) { phaseVisc.derivs[ipOil][Deriv::dP] = dVisc_dP; - for( integer ic = 0; ic < HNC_BO; ++ic ) + for( integer ich = 0; ich < HNC_BO; ++ich ) { + // get the phase index + integer const ic = m_hydrocarbonPhaseOrder[ich]; + // fill the vector phaseVisc.derivs[ipOil][Deriv::dC+ic] = dVisc_dC[ic]; } } @@ -961,7 +959,6 @@ GEOSX_HOST_DEVICE inline void BlackOilFluid::KernelWrapper:: computeUndersaturatedBoViscosity( bool const needDerivs, - integer const numHydrocarbonComp, real64 const P, real64 const Rs, real64 const dRs_dComp[], @@ -995,7 +992,7 @@ BlackOilFluid::KernelWrapper:: real64 const dVisc_dRs = (visc_eps - visc) * inv_eps; // 3. chainrule to dComp - for( integer i = 0; i < numHydrocarbonComp; ++i ) + for( integer i = 0; i < HNC_BO; ++i ) { dBo_dComp[i] = dBo_dRs * dRs_dComp[i]; dVisc_dComp[i] = dVisc_dRs * dRs_dComp[i]; @@ -1062,17 +1059,16 @@ inline void BlackOilFluid::KernelWrapper:: computeMassMoleDensity( bool const needDerivs, bool const useMass, - integer const numHydrocarbonComp, real64 const Rs, real64 const dRs_dPres, - real64 const dRs_dComp[], + real64 const dRs_dComp[HNC_BO], real64 const Bo, real64 const dBo_dPres, - real64 const dBo_dComp[], + real64 const dBo_dComp[HNC_BO], real64 & dens, arraySlice1d< real64, multifluid::USD_PHASE_DC - 3 > const & dDens ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; using PT = BlackOilFluid::PhaseType; real64 const oilDens = (useMass)? m_PVTOView.m_surfaceMassDensity[PT::OIL]: @@ -1087,10 +1083,11 @@ BlackOilFluid::KernelWrapper:: { dDens[Deriv::dP] = Binv * Binv * (Bo * gasDens * dRs_dPres - tmp * dBo_dPres); - /////// TODO FRANCOIS: DOUBLE CHECK THE DERIVATIVE BELOW /////////// - - for( integer ic = 0; ic < numHydrocarbonComp; ++ic ) + for( integer ich = 0; ich < HNC_BO; ++ich ) { + // get the phase index + integer const ic = m_hydrocarbonPhaseOrder[ich]; + // fill the vector dDens[Deriv::dC+ic] = Binv * Binv * (Bo * gasDens * dRs_dComp[ic] - tmp * dBo_dComp[ic]); } } diff --git a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp index 666590de7d0..c3bb78d5928 100644 --- a/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/CompositionalMultiphaseFluid.hpp @@ -261,7 +261,7 @@ CompositionalMultiphaseFluid::KernelWrapper:: GEOSX_ERROR( "This function cannot be used on GPU" ); #else - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer constexpr maxNumComp = MultiFluidBase::MAX_NUM_COMPONENTS; integer constexpr maxNumPhase = MultiFluidBase::MAX_NUM_PHASES; diff --git a/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp index e77fa2ee158..d82a22af5b0 100644 --- a/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/DeadOilFluid.hpp @@ -209,7 +209,7 @@ DeadOilFluid::KernelWrapper:: computeDensities( real64 const pressure, PhaseProp::SliceType const & phaseMassDens ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; LvArray::forValuesInSlice( phaseMassDens.derivs, []( real64 & val ){ val = 0.0; } ); @@ -283,7 +283,7 @@ DeadOilFluid::KernelWrapper:: computeViscosities( real64 const pressure, PhaseProp::SliceType const & phaseVisc ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; LvArray::forValuesInSlice( phaseVisc.derivs, []( real64 & val ){ val = 0.0; } ); @@ -374,7 +374,7 @@ DeadOilFluid::KernelWrapper:: { GEOSX_UNUSED_VAR( temperature ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer const nComps = numComponents(); integer const nPhases = numPhases(); diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 014aefe853d..d00f1f48ae5 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -609,7 +609,7 @@ MultiFluidBase::KernelWrapper:: real64 const (&dPhaseMolecularWeight)[maxNumPhase][maxNumDof], PhaseProp::SliceType const phaseFrac ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer const numPhase = numPhases(); integer const numComp = numComponents(); @@ -663,7 +663,7 @@ MultiFluidBase::KernelWrapper:: PhaseProp::SliceType const phaseFrac, PhaseComp::SliceType const phaseCompFrac ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer const numPhase = numPhases(); integer const numComp = numComponents(); @@ -711,7 +711,7 @@ MultiFluidBase::KernelWrapper:: arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseDens, arraySlice2d< real64, multifluid::USD_PHASE_DC - 2 > const dPhaseVisc ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer const numPhase = numPhases(); integer const numComp = numComponents(); @@ -767,7 +767,7 @@ MultiFluidBase::KernelWrapper:: PhaseProp::SliceType const phaseDensity, FluidProp::SliceType const totalDensity ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer const numComp = numComponents(); integer const numPhase = numPhases(); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp index 802f213c263..965b4171077 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp @@ -175,7 +175,7 @@ void BrineEnthalpyUpdate::compute( real64 const & pressure, arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 const input[2] = { pressure, temperature }; real64 brineEnthalpy_dTemperature = 0.0; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp index e1e01245ed3..e2c45db4edd 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp @@ -132,7 +132,7 @@ void BrineInternalEnergyUpdate::compute( real64 const & pressure, { GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition, useMass ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; value = 0.001 * pressure + 1.0 * temperature; LvArray::forValuesInSlice( dValue, []( real64 & val ){ val = 0.0; } ); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp index 501dc34d5db..cb5c3db2d11 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp @@ -152,7 +152,7 @@ void CO2EnthalpyUpdate::compute( real64 const & pressure, { GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 const input[2] = { pressure, temperature }; real64 CO2EnthalpyDeriv[2]{}; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp index bdb259cfc8c..b766ef0f898 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp @@ -132,7 +132,7 @@ void CO2InternalEnergyUpdate::compute( real64 const & pressure, { GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition, useMass ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; value = 0.001 * pressure + 1.0 * temperature; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp index afebf8fb7e9..e930a8480f8 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Solubility.hpp @@ -220,7 +220,7 @@ CO2SolubilityUpdate::compute( real64 const & pressure, PhaseProp::SliceType const phaseFraction, PhaseComp::SliceType const phaseCompFraction ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // solubility mol/kg(water) X = Csat/W real64 const input[2] = { pressure, temperature }; @@ -252,6 +252,8 @@ CO2SolubilityUpdate::compute( real64 const & pressure, } auto setZero = []( real64 & val ){ val = 0.0; }; + LvArray::forValuesInSlice( phaseFraction.derivs, setZero ); + LvArray::forValuesInSlice( phaseCompFraction.derivs, setZero ); if( Y < solubility ) { @@ -261,8 +263,6 @@ CO2SolubilityUpdate::compute( real64 const & pressure, phaseFraction.value[m_phaseLiquidIndex] = 1.0; phaseFraction.value[m_phaseGasIndex] = 0.0; - LvArray::forValuesInSlice( phaseFraction.derivs, setZero ); - LvArray::forValuesInSlice( phaseCompFraction.derivs, setZero ); // 2) Compute phase component fractions diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp index 0a203cecafb..f88ae70f75f 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp @@ -198,7 +198,7 @@ void EzrokhiBrineDensityUpdate::compute( real64 const & pressure, arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 waterSatDensity_dTemperature = 0.0; real64 waterSatPressure_dTemperature = 0.0; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp index baafd8075d3..4485985dda0 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp @@ -179,7 +179,7 @@ void EzrokhiBrineViscosityUpdate::compute( real64 const & pressure, { GEOSX_UNUSED_VAR( pressure, useMass ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 waterVisc_dTemperature = 0.0; real64 const waterVisc = m_waterViscosityTable.compute( &temperature, &waterVisc_dTemperature ); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp index 4942e7f1346..e8137d73784 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/FenghourCO2Viscosity.hpp @@ -139,7 +139,7 @@ void FenghourCO2ViscosityUpdate::compute( real64 const & pressure, dPhaseComposition, useMass ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 const input[2] = { pressure, temperature }; real64 densityDeriv[2]{}; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp index 1115fd9a454..2ef52bd1ce7 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp @@ -183,7 +183,7 @@ void PhillipsBrineDensityUpdate::compute( real64 const & pressure, arraySlice1d< real64, USD3 > const & dValue, bool useMass ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // this method implements the method proposed by E. Garcia (2001) diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp index 98aeb0669d8..2c3f48d3fea 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PhillipsBrineViscosity.hpp @@ -157,7 +157,7 @@ void PhillipsBrineViscosityUpdate::compute( real64 const & pressure, dPhaseComposition, useMass ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // compute the viscosity of pure water as a function of temperature real64 dPureWaterVisc_dTemperature; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp index b4a70516829..16a6776203a 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp @@ -154,7 +154,7 @@ void SpanWagnerCO2DensityUpdate::compute( real64 const & pressure, { GEOSX_UNUSED_VAR( phaseComposition, dPhaseComposition ); - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 const input[2] = { pressure, temperature }; real64 densityDeriv[2]{}; diff --git a/src/coreComponents/constitutive/fluid/layouts.hpp b/src/coreComponents/constitutive/fluid/layouts.hpp index afcc0548855..31c1176ed5a 100644 --- a/src/coreComponents/constitutive/fluid/layouts.hpp +++ b/src/coreComponents/constitutive/fluid/layouts.hpp @@ -33,7 +33,7 @@ namespace multifluid { /// indices of pressure, temperature, and composition derivatives -struct Deriv +struct DerivativeOffset { /// index of derivative wrt pressure static integer constexpr dP = 0; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp index 43bbec6630d..1f6cf80de00 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseKernels.hpp @@ -296,7 +296,7 @@ class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > void compute( localIndex const ei, FUNC && phaseVolFractionKernelOp = NoOpFunc{} ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; arraySlice1d< real64 const, compflow::USD_COMP - 1 > const compDens = m_compDens[ei]; arraySlice1d< real64 const, compflow::USD_COMP - 1 > const dCompDens = m_dCompDens[ei]; @@ -731,7 +731,7 @@ class ElementBasedAssemblyKernel StackVariables & stack, FUNC && phaseAmountKernelOp = NoOpFunc{} ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // construct the slices for variables accessed multiple times arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp index eabfe5f65ed..edd95063add 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.cpp @@ -496,7 +496,7 @@ AquiferBCKernel:: real64 (& localFlux)[NC], real64 (& localFluxJacobian)[NC][NC+1] ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 dProp_dC[NC]{}; real64 dPhaseFlux_dCompDens[NC]{}; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp index cba29f5a9cc..b88a7a93dc3 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVMKernels.hpp @@ -102,7 +102,7 @@ class PhaseMobilityKernel : public compositionalMultiphaseBaseKernels::PropertyK void compute( localIndex const ei, FUNC && phaseMobilityKernelOp = compositionalMultiphaseBaseKernels::NoOpFunc{} ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseDens = m_phaseDens[ei][0]; @@ -588,7 +588,7 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase FUNC1 && phaseFluxKernelOp = compositionalMultiphaseBaseKernels::NoOpFunc{}, FUNC2 && localFluxJacobianKernelOp = compositionalMultiphaseBaseKernels::NoOpFunc{} ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // first, compute the transmissibilities at this face m_stencilWrapper.computeWeights( iconn, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp index 367b9e674bf..0cb758884d4 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp @@ -54,7 +54,7 @@ UpwindingHelper:: real64 ( & dUpwPhaseViscCoef_dCompDens )[ NP ][ NC ][ NC ], globalIndex & upwViscDofNumber ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 dUpwMobRatio_dCompDens[ NC ]{}; real64 dUpwDensMobRatio_dCompDens[ NC ]{}; @@ -155,7 +155,7 @@ UpwindingHelper:: real64 ( & dUpwPhaseGravCoef_dPres )[ NP ][ NP-1 ][ NC ][ 2 ], real64 ( & dUpwPhaseGravCoef_dCompDens )[ NP ][ NP-1 ][ NC ][ 2 ][ NC ] ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // 1) Compute the driving force: T ( \rho^{avg}_{\ell} - \rho^{avg}_m ) g \Delta z computePhaseGravTerm( localIds, @@ -283,7 +283,7 @@ UpwindingHelper:: real64 ( & dPhaseGravTerm_dPres )[ NP ][ NP-1 ][ 2 ], real64 ( & dPhaseGravTerm_dCompDens )[ NP ][ NP-1 ][ 2 ][ NC ] ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; localIndex const er = localIds[0]; localIndex const esr = localIds[1]; @@ -611,7 +611,7 @@ AssemblerKernelHelper:: real64 ( & dOneSidedVolFlux_dFacePres )[ NF ][ NF ], real64 ( & dOneSidedVolFlux_dCompDens )[ NF ][ NC ] ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; real64 dPhaseMassDens_dC[ NP ][ NC ]{}; real64 dPresDif_dCompDens[ NC ]{}; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp index e49064f2560..ed2d10731ef 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp @@ -714,7 +714,7 @@ class PhaseMobilityKernel : public compositionalMultiphaseBaseKernels::PropertyK void compute( localIndex const ei, FUNC && phaseMobilityKernelOp = compositionalMultiphaseBaseKernels::NoOpFunc{} ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseVisc = m_phaseVisc[ei][0]; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp index 35f498d8102..5fce0ade3a6 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp @@ -626,7 +626,7 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg dCurrentPhaseVolRate_dRate, &iwelemRef] ( localIndex const ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; stackArray1d< real64, maxNumComp > work( numComp ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp index 74956b0c51d..8d2565598d0 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp @@ -797,7 +797,7 @@ PerforationKernel:: arraySlice2d< real64 > const & dCompPerfRate_dPres, arraySlice3d< real64 > const & dCompPerfRate_dComp ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // local working variables and arrays real64 pres[2]{}; @@ -1239,7 +1239,7 @@ AccumulationKernel:: real64 ( & localAccum )[NC], real64 ( & localAccumJacobian )[NC][NC + 1] ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; // temporary work arrays real64 dPhaseAmount_dC[NC]{}; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp index 568132eb040..f49bf82101e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp @@ -550,7 +550,7 @@ class TotalMassDensityKernel : public compositionalMultiphaseBaseKernels::Proper void compute( localIndex const ei, FUNC && totalMassDensityKernelOp = compositionalMultiphaseBaseKernels::NoOpFunc{} ) const { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFrac = m_phaseVolFrac[ei]; arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dPres = m_dPhaseVolFrac_dPres[ei]; diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp index 9104f006990..f75b936b369 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp @@ -366,7 +366,7 @@ class Multiphase : // --- Mass balance accumulation // --- --- sum contributions to component accumulation from each phase - using namespace constitutive::multifluid; + using Deriv = constitutive::multifluid::DerivativeOffset; // --- --- temporary work arrays real64 dPhaseAmount_dC[numMaxComponents]{}; diff --git a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp index f06bb358c55..4cf476752e1 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp @@ -150,7 +150,7 @@ void testNumericalDerivatives( PVT_WRAPPER const & pvtFunctionWrapper, real64 const perturbParameter, real64 const relTol ) { - using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer constexpr numComp = 2; integer constexpr numDof = numComp + 2; @@ -223,6 +223,7 @@ void testNumericalDerivatives( FLASH_WRAPPER const & flashModelWrapper, real64 const relTol ) { using namespace multifluid; + using Deriv = multifluid::DerivativeOffset; integer constexpr numPhase = 2; integer constexpr numComp = 2; diff --git a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp index 20d137c464b..57ef5ee9319 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp @@ -120,6 +120,8 @@ void testNumericalDerivatives( MultiFluidBase & fluid, real64 const relTol, real64 const absTol = std::numeric_limits< real64 >::max() ) { + using Deriv = multifluid::DerivativeOffset; + integer const NC = fluid.numFluidComponents(); integer const NP = fluid.numFluidPhases(); integer const NDOF = NC+2; From a5b5bd9a7f6d8810248d7321f967d0379a536a35 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Fri, 18 Feb 2022 15:26:52 -0800 Subject: [PATCH 4/6] fixed unit test --- .../constitutive/fluid/BlackOilFluid.cpp | 3 +-- .../constitutive/fluid/BlackOilFluid.hpp | 22 ++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp b/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp index 06aa4f4275c..32f666acd7c 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.cpp @@ -73,7 +73,7 @@ void BlackOilFluid::readInputDataFromPVTFiles() fillWaterData( data ); // gas data - fillHydrocarbonData( PT::GAS, boTables.getGasTable() ); + fillHydrocarbonData( m_phaseOrder[PT::GAS], boTables.getGasTable() ); // for the Black-Oil model, the oil PVT is treated differently from gas fillPVTOData( boTables.getOilTable(), @@ -110,7 +110,6 @@ void BlackOilFluid::fillPVTOData( array1d< array1d< real64 > > const & oilTable, // if oilTable.size() == 4 (saturated case): Rs, bubble point pressure, Bo, viscosity // if ollTable.size() == 3 (unsaturated case): unsaturated pressure, Bo, viscosity - // Step 1: count the number of saturated points by looping through oilTable, and resize tables accordingly integer numSaturatedPoints = 0; diff --git a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp index 89021fd9bfe..33b0dcbdd96 100644 --- a/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/BlackOilFluid.hpp @@ -894,13 +894,8 @@ BlackOilFluid::KernelWrapper:: if( needDerivs ) { phaseVisc.derivs[ipOil][Deriv::dP] = dVisc_dP; - for( integer ich = 0; ich < HNC_BO; ++ich ) - { - // get the phase index - integer const ic = m_hydrocarbonPhaseOrder[ich]; - // fill the vector - phaseVisc.derivs[ipOil][Deriv::dC+ic] = dVisc_dC[ic]; - } + phaseVisc.derivs[ipOil][Deriv::dC+icOil] = dVisc_dC[PT::OIL]; + phaseVisc.derivs[ipOil][Deriv::dC+icGas] = dVisc_dC[PT::GAS]; } } } @@ -1081,15 +1076,12 @@ BlackOilFluid::KernelWrapper:: dens = Binv * tmp; if( needDerivs ) { - dDens[Deriv::dP] = Binv * Binv * (Bo * gasDens * dRs_dPres - tmp * dBo_dPres); + integer const icOil = m_phaseOrder[PT::OIL]; + integer const icGas = m_phaseOrder[PT::GAS]; - for( integer ich = 0; ich < HNC_BO; ++ich ) - { - // get the phase index - integer const ic = m_hydrocarbonPhaseOrder[ich]; - // fill the vector - dDens[Deriv::dC+ic] = Binv * Binv * (Bo * gasDens * dRs_dComp[ic] - tmp * dBo_dComp[ic]); - } + dDens[Deriv::dP] = Binv * Binv * (Bo * gasDens * dRs_dPres - tmp * dBo_dPres); + dDens[Deriv::dC+icOil] = Binv * Binv * (Bo * gasDens * dRs_dComp[PT::OIL] - tmp * dBo_dComp[PT::OIL]); + dDens[Deriv::dC+icGas] = Binv * Binv * (Bo * gasDens * dRs_dComp[PT::GAS] - tmp * dBo_dComp[PT::GAS]); } } From 3e72aadf62b7083dd7f434052f3d90c8f3470230 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Fri, 18 Feb 2022 17:40:26 -0800 Subject: [PATCH 5/6] fixed debug output --- .../linearAlgebra/interfaces/hypre/HypreMatrix.cpp | 2 +- .../linearAlgebra/interfaces/hypre/HypreVector.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMatrix.cpp b/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMatrix.cpp index c0c14aaad8d..1536f156736 100644 --- a/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMatrix.cpp +++ b/src/coreComponents/linearAlgebra/interfaces/hypre/HypreMatrix.cpp @@ -1311,7 +1311,7 @@ void HypreMatrix::write( string const & filename, for( HYPRE_Int k = csr.rowptr[i]; k < csr.rowptr[i + 1]; k++ ) { // MatrixMarket row/col indices are 1-based - GEOSX_FMT_TO( str, sizeof( str ), "{} {} {.16e}\n", i + 1, csr.colind[k] + 1, csr.values[k] ); + GEOSX_FMT_TO( str, sizeof( str ), "{} {} {:>28.16e}\n", i + 1, csr.colind[k] + 1, csr.values[k] ); os << str; } } diff --git a/src/coreComponents/linearAlgebra/interfaces/hypre/HypreVector.cpp b/src/coreComponents/linearAlgebra/interfaces/hypre/HypreVector.cpp index d11fb4019e8..e8a770ac604 100644 --- a/src/coreComponents/linearAlgebra/interfaces/hypre/HypreVector.cpp +++ b/src/coreComponents/linearAlgebra/interfaces/hypre/HypreVector.cpp @@ -379,7 +379,7 @@ void HypreVector::write( string const & filename, for( HYPRE_Int i = 0; i < size; i++ ) { - GEOSX_FMT_TO( str, sizeof( str ), "{.16e}\n", data[i] ); + GEOSX_FMT_TO( str, sizeof( str ), "{:>28.16e}\n", data[i] ); os << str; } } From b9b88e319c17ce3421a36c8fdeeef69d57df774a Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Tue, 22 Feb 2022 21:39:37 -0800 Subject: [PATCH 6/6] updated integratedTests submodule --- integratedTests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integratedTests b/integratedTests index 2e4590814e4..25a0699c802 160000 --- a/integratedTests +++ b/integratedTests @@ -1 +1 @@ -Subproject commit 2e4590814e4438effaddd4a96242ab9add011811 +Subproject commit 25a0699c80216c8f6bf6b6766cdc008168b0ff95