From abfd5fe04f3490ea8ec0ab9eaac7335f2a555ea5 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Wed, 4 Nov 2020 14:29:29 -0800 Subject: [PATCH 01/34] Initial commit --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 17 +++++++++++++++-- .../fluidFlow/CompositionalMultiphaseFlow.hpp | 12 ++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index 90e47036f91..befb86b086f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -59,9 +59,14 @@ CompositionalMultiphaseFlow::CompositionalMultiphaseFlow( const string & name, m_allowCompDensChopping( 1 ) { //START_SPHINX_INCLUDE_00 - this->registerWrapper( viewKeyStruct::temperatureString, &m_temperature )-> + this->registerWrapper( viewKeyStruct::temperatureString, &m_uniformTemperature )-> setInputFlag( InputFlags::REQUIRED )-> - setDescription( "Temperature" ); + setDescription( "Uniform temperature for isothermal simulations." ); + + this->registerWrapper(viewKeyStruct::isothermalFlagString, &m_isothermalFlag)-> + setApplyDefaultValue( 1 )-> + setInputFlag( InputFlags::OPTIONAL )-> + setDescription("Flag indicating whether the problem is isothermal or not."); this->registerWrapper( viewKeyStruct::useMassFlagString, &m_useMass )-> setApplyDefaultValue( 0 )-> @@ -154,6 +159,14 @@ void CompositionalMultiphaseFlow::RegisterDataOnMesh( Group * const MeshBodies ) elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::phaseDensityOldString ); elementSubRegion.registerWrapper< array3d< real64 > >( viewKeyStruct::phaseComponentFractionOldString ); elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::porosityOldString ); + + if (m_isothermalFlag == 0) + { + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString )->setPlotLevel( PlotLevel::LEVEL_0 ); + + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString )-> + setRestartFlags( RestartFlags::NO_WRITE ); + } } ); } } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp index 192165548ac..91a402d75ad 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp @@ -278,8 +278,13 @@ class CompositionalMultiphaseFlow : public FlowSolverBase { static constexpr auto dofFieldString = "compositionalVariables"; - // inputs static constexpr auto temperatureString = "temperature"; + static constexpr auto deltaTemperatureString = "deltaTemperature"; + + // inputs + static constexpr auto uniformTemperatureString = "uniformTemperature"; + static constexpr auto isothermalFlagString = "isothermal"; + static constexpr auto useMassFlagString = "useMass"; static constexpr auto relPermNamesString = "relPermNames"; @@ -415,7 +420,7 @@ class CompositionalMultiphaseFlow : public FlowSolverBase localIndex m_numComponents; /// the (uniform) temperature - real64 m_temperature; + real64 m_uniformTemperature; /// flag indicating whether mass or molar formulation should be used integer m_useMass; @@ -442,6 +447,9 @@ class CompositionalMultiphaseFlow : public FlowSolverBase ElementRegionManager::ElementViewAccessor< arrayView1d< real64 const > > m_pressure; ElementRegionManager::ElementViewAccessor< arrayView1d< real64 const > > m_deltaPressure; + ElementRegionManager::ElementViewAccessor< arrayView1d< real64 const > > m_temperature; + ElementRegionManager::ElementViewAccessor< arrayView1d< real64 const > > m_deltaTemperature; + ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dCompFrac_dCompDens; ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_dPhaseVolFrac_dPres; From e747d605baec072dd9e5b4e8cefa4b8a903dc6e1 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Thu, 5 Nov 2020 17:24:20 -0800 Subject: [PATCH 02/34] thermalKernels --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 407 +++-- .../fluidFlow/CompositionalMultiphaseFlow.hpp | 66 + .../CompositionalMultiphaseFlowKernels.hpp | 18 +- ...rmalCompositionalMultiphaseFlowKernels.cpp | 1314 +++++++++++++++++ ...rmalCompositionalMultiphaseFlowKernels.hpp | 447 ++++++ 5 files changed, 2130 insertions(+), 122 deletions(-) create mode 100644 src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp create mode 100644 src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index befb86b086f..1c41b522e42 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -33,6 +33,7 @@ #include "mpiCommunications/CommunicationTools.hpp" #include "mpiCommunications/MpiWrapper.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp" #if defined( __INTEL_COMPILER ) #pragma GCC optimize "O0" @@ -43,7 +44,6 @@ namespace geosx using namespace dataRepository; using namespace constitutive; -using namespace CompositionalMultiphaseFlowKernels; static constexpr real64 minDensForDivision = 1e-10; @@ -251,7 +251,16 @@ void CompositionalMultiphaseFlow::InitializePreSubGroups( Group * const rootGrou MultiFluidBase const & fluid0 = *cm.GetConstitutiveRelation< MultiFluidBase >( m_fluidModelNames[0] ); m_numPhases = fluid0.numFluidPhases(); m_numComponents = fluid0.numFluidComponents(); - m_numDofPerCell = m_numComponents + 1; + if ( m_isothermalFlag ) + { + // Nc + pressure + m_numDofPerCell = m_numComponents + 1; + } + else + { + // Nc + pressure + tempertature + m_numDofPerCell = m_numComponents + 2; + } // 2. Validate various models against each other (must have same phases and components) ValidateConstitutiveModels( cm ); @@ -318,14 +327,31 @@ void CompositionalMultiphaseFlow::UpdateComponentFraction( Group & dataGroup ) c arrayView2d< real64 const > const dCompDens = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); - KernelLaunchSelector1< ComponentFractionKernel >( m_numComponents, - dataGroup.size(), - compDens, - dCompDens, - compFrac, - dCompFrac_dCompDens ); -} + if ( m_isoThermalFlag ) + { + KernelLaunchSelector1 + < IsothermalCompositionalMultiphaseFlowKernels::ComponentFractionKernel >( m_numComponents, + dataGroup.size(), + compDens, + dCompDens, + compFrac, + dCompFrac_dCompDens ); + } else + { + // Get thermal views + KernelLaunchSelector1 + < CompositionalMultiphaseFlowKernels::ComponentFractionKernel >( m_numComponents, + dataGroup.size(), + compDens, + dCompDens, + temperature, + dtemperature, + compFrac, + dCompFrac_dCompDens, + dCompFrac_dTemperature ); + } +} void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, localIndex const targetIndex ) const { @@ -363,20 +389,43 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, arrayView3d< real64 const > const & dPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); arrayView4d< real64 const > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); - KernelLaunchSelector2< PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, - dataGroup.size(), - compDens, - dCompDens, - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp ); + if ( m_isoThermalFlag ) + { + KernelLaunchSelector2 + < IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >(m_numComponents, m_numPhases, + dataGroup.size(), + compDens, + dCompDens, + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseFrac, + dPhaseFrac_dPres, + dPhaseFrac_dComp, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp ); + } else + { + // Get thermal views + KernelLaunchSelector2 + < CompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, + dataGroup.size(), + compDens, + dCompDens, + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseFrac, + dPhaseFrac_dPres, + dPhaseFrac_dComp, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp ); + + } } void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localIndex const targetIndex ) const @@ -420,22 +469,46 @@ void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localI arrayView3d< real64 const > const & phaseRelPerm = relperm.phaseRelPerm(); arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac = relperm.dPhaseRelPerm_dPhaseVolFraction(); - KernelLaunchSelector2< PhaseMobilityKernel >( m_numComponents, m_numPhases, - dataGroup.size(), - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseVisc, - dPhaseVisc_dPres, - dPhaseVisc_dComp, - phaseRelPerm, - dPhaseRelPerm_dPhaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dComp ); + if (m_isothermalFlag) + { + KernelLaunchSelector2 + < IsothermalCompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, + dataGroup.size(), + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseVisc, + dPhaseVisc_dPres, + dPhaseVisc_dComp, + phaseRelPerm, + dPhaseRelPerm_dPhaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp, + phaseMob, + dPhaseMob_dPres, + dPhaseMob_dComp ); + }else + { + KernelLaunchSelector2 + < CompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, + dataGroup.size(), + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseVisc, + dPhaseVisc_dPres, + dPhaseVisc_dComp, + phaseRelPerm, + dPhaseRelPerm_dPhaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp, + phaseMob, + dPhaseMob_dPres, + dPhaseMob_dComp ); + } + } void CompositionalMultiphaseFlow::UpdateFluidModel( Group & dataGroup, localIndex const targetIndex ) const @@ -453,12 +526,28 @@ void CompositionalMultiphaseFlow::UpdateFluidModel( Group & dataGroup, localInde typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); // MultiFluid models are not thread-safe or device-capable yet - FluidUpdateKernel::Launch< serialPolicy >( dataGroup.size(), - fluidWrapper, - pres, - dPres, - m_temperature, - compFrac ); + if ( m_isothermalFlag ) + { + IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( dataGroup.size(), + fluidWrapper, + pres, + dPres, + m_uniformTemperature, + compFrac ); + } else + { + arrayView1d< real64 const > const temperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); + arrayView1d< real64 const > const dTemperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + + CompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( dataGroup.size(), + fluidWrapper, + pres, + dPres, + temperature, + dTemperature, + compFrac ); + } + } ); } @@ -488,7 +577,7 @@ void CompositionalMultiphaseFlow::UpdateRelPermModel( Group & dataGroup, localIn { typename TYPEOFREF( castedRelPerm ) ::KernelWrapper relPermWrapper = castedRelPerm.createKernelWrapper(); - RelativePermeabilityUpdateKernel::Launch< parallelDevicePolicy<> >( dataGroup.size(), + CompositionalMultiphaseFlowKernels::RelativePermeabilityUpdateKernel::Launch< parallelDevicePolicy<> >( dataGroup.size(), relPermWrapper, phaseVolFrac ); } ); @@ -508,7 +597,7 @@ void CompositionalMultiphaseFlow::UpdateCapPressureModel( Group & dataGroup, loc { typename TYPEOFREF( castedCapPres ) ::KernelWrapper capPresWrapper = castedCapPres.createKernelWrapper(); - CapillaryPressureUpdateKernel::Launch< parallelDevicePolicy<> >( dataGroup.size(), + CompositionalMultiphaseFlowKernels::CapillaryPressureUpdateKernel::Launch< parallelDevicePolicy<> >( dataGroup.size(), capPresWrapper, phaseVolFrac ); } ); @@ -777,32 +866,66 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con arrayView4d< real64 const > const & dPhaseCompFrac_dPres = fluid.dPhaseCompFraction_dPressure(); arrayView5d< real64 const > const & dPhaseCompFrac_dComp = fluid.dPhaseCompFraction_dGlobalCompFraction(); - KernelLaunchSelector1< AccumulationKernel >( m_numComponents, - m_numPhases, - subRegion.size(), - dofManager.rankOffset(), - dofNumber, - elemGhostRank, - volume, - porosityOld, - porosityRef, - pvMult, - dPvMult_dPres, - dCompFrac_dCompDens, - phaseVolFracOld, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dCompDens, - phaseDensOld, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseCompFracOld, - phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dComp, - localMatrix, - localRhs ); + if ( m_istothermalFlag ) + { + KernelLaunchSelector1 + < IsothermalCompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, + m_numPhases, + subRegion.size(), + dofManager.rankOffset(), + dofNumber, + elemGhostRank, + volume, + porosityOld, + porosityRef, + pvMult, + dPvMult_dPres, + dCompFrac_dCompDens, + phaseVolFracOld, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dCompDens, + phaseDensOld, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseCompFracOld, + phaseCompFrac, + dPhaseCompFrac_dPres, + dPhaseCompFrac_dComp, + localMatrix, + localRhs ); + }else + { + KernelLaunchSelector1 + < CompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, + m_numPhases, + subRegion.size(), + dofManager.rankOffset(), + dofNumber, + elemGhostRank, + volume, + porosityOld, + porosityRef, + pvMult, + dPvMult_dPres, + dCompFrac_dCompDens, + phaseVolFracOld, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dCompDens, + phaseDensOld, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseCompFracOld, + phaseCompFrac, + dPhaseCompFrac_dPres, + dPhaseCompFrac_dComp, + localMatrix, + localRhs ); + } + } ); } @@ -861,33 +984,68 @@ void CompositionalMultiphaseFlow::AssembleFluxTerms( real64 const dt, fluxApprox.forAllStencils( mesh, [&] ( auto const & stencil ) { - KernelLaunchSelector1< FluxKernel >( m_numComponents, - m_numPhases, - stencil, - dofManager.rankOffset(), - elemDofNumber.toNestedViewConst(), - m_elemGhostRank.toNestedViewConst(), - m_pressure.toNestedViewConst(), - m_deltaPressure.toNestedViewConst(), - m_gravCoef.toNestedViewConst(), - m_phaseMob.toNestedViewConst(), - m_dPhaseMob_dPres.toNestedViewConst(), - m_dPhaseMob_dCompDens.toNestedViewConst(), - m_dPhaseVolFrac_dPres.toNestedViewConst(), - m_dPhaseVolFrac_dCompDens.toNestedViewConst(), - m_dCompFrac_dCompDens.toNestedViewConst(), - m_phaseDens.toNestedViewConst(), - m_dPhaseDens_dPres.toNestedViewConst(), - m_dPhaseDens_dComp.toNestedViewConst(), - m_phaseCompFrac.toNestedViewConst(), - m_dPhaseCompFrac_dPres.toNestedViewConst(), - m_dPhaseCompFrac_dComp.toNestedViewConst(), - m_phaseCapPressure.toNestedViewConst(), - m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), - m_capPressureFlag, - dt, - localMatrix.toViewConstSizes(), - localRhs.toView() ); + if ( m_isothermalFlag ) + { + KernelLaunchSelector1 + < IsothermalCompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, + m_numPhases, + stencil, + dofManager.rankOffset(), + elemDofNumber.toNestedViewConst(), + m_elemGhostRank.toNestedViewConst(), + m_pressure.toNestedViewConst(), + m_deltaPressure.toNestedViewConst(), + m_gravCoef.toNestedViewConst(), + m_phaseMob.toNestedViewConst(), + m_dPhaseMob_dPres.toNestedViewConst(), + m_dPhaseMob_dCompDens.toNestedViewConst(), + m_dPhaseVolFrac_dPres.toNestedViewConst(), + m_dPhaseVolFrac_dCompDens.toNestedViewConst(), + m_dCompFrac_dCompDens.toNestedViewConst(), + m_phaseDens.toNestedViewConst(), + m_dPhaseDens_dPres.toNestedViewConst(), + m_dPhaseDens_dComp.toNestedViewConst(), + m_phaseCompFrac.toNestedViewConst(), + m_dPhaseCompFrac_dPres.toNestedViewConst(), + m_dPhaseCompFrac_dComp.toNestedViewConst(), + m_phaseCapPressure.toNestedViewConst(), + m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), + m_capPressureFlag, + dt, + localMatrix.toViewConstSizes(), + localRhs.toView() ); + }else + { + KernelLaunchSelector1 + < CompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, + m_numPhases, + stencil, + dofManager.rankOffset(), + elemDofNumber.toNestedViewConst(), + m_elemGhostRank.toNestedViewConst(), + m_pressure.toNestedViewConst(), + m_deltaPressure.toNestedViewConst(), + m_gravCoef.toNestedViewConst(), + m_phaseMob.toNestedViewConst(), + m_dPhaseMob_dPres.toNestedViewConst(), + m_dPhaseMob_dCompDens.toNestedViewConst(), + m_dPhaseVolFrac_dPres.toNestedViewConst(), + m_dPhaseVolFrac_dCompDens.toNestedViewConst(), + m_dCompFrac_dCompDens.toNestedViewConst(), + m_phaseDens.toNestedViewConst(), + m_dPhaseDens_dPres.toNestedViewConst(), + m_dPhaseDens_dComp.toNestedViewConst(), + m_phaseCompFrac.toNestedViewConst(), + m_dPhaseCompFrac_dPres.toNestedViewConst(), + m_dPhaseCompFrac_dComp.toNestedViewConst(), + m_phaseCapPressure.toNestedViewConst(), + m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), + m_capPressureFlag, + dt, + localMatrix.toViewConstSizes(), + localRhs.toView() ); + } + } ); } @@ -923,20 +1081,41 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co arrayView2d< real64 const > const & dPvMult_dPres = solid.getReference< array2d< real64 > >( ConstitutiveBase::viewKeyStruct::dPVMult_dPresString ); - KernelLaunchSelector2< VolumeBalanceKernel >( m_numComponents, m_numPhases, - subRegion.size(), - dofManager.rankOffset(), - dofNumber, - elemGhostRank, - volume, - porosityRef, - pvMult, - dPvMult_dPres, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dCompDens, - localMatrix.toViewConstSizes(), - localRhs.toView() ); + if ( m_isothermalFlag ) + { + KernelLaunchSelector2 + < IsothermalCompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, + subRegion.size(), + dofManager.rankOffset(), + dofNumber, + elemGhostRank, + volume, + porosityRef, + pvMult, + dPvMult_dPres, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dCompDens, + localMatrix.toViewConstSizes(), + localRhs.toView() ); + }else + { + KernelLaunchSelector2 + < CompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, + subRegion.size(), + dofManager.rankOffset(), + dofNumber, + elemGhostRank, + volume, + porosityRef, + pvMult, + dPvMult_dPres, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dCompDens, + localMatrix.toViewConstSizes(), + localRhs.toView() ); + } } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp index 91a402d75ad..edb2ca24b96 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp @@ -383,6 +383,13 @@ class CompositionalMultiphaseFlow : public FlowSolverBase */ void ChopNegativeDensities( DomainPartition & domain ); + + template< typename KERNELWRAPPER, typename ... ARGS > + void CompositionalMultiphaseFlow::KernelLaunchSelector1( localIndex numComp, ARGS && ... args ); + + template< typename KERNELWRAPPER, typename ... ARGS > + void CompositionalMultiphaseFlow::KernelLaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ); + protected: virtual void PostProcessInput() override; @@ -422,6 +429,9 @@ class CompositionalMultiphaseFlow : public FlowSolverBase /// the (uniform) temperature real64 m_uniformTemperature; + /// flag indicating if the problem is isothermal + integer m_isothermalFlag; + /// flag indicating whether mass or molar formulation should be used integer m_useMass; @@ -472,6 +482,62 @@ class CompositionalMultiphaseFlow : public FlowSolverBase }; +/******************************** Kernel launch machinery ********************************/ + +namespace internal +{ + +template< typename T, typename LAMBDA > +void KernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) +{ + static_assert( std::is_integral< T >::value, "KernelLaunchSelectorCompSwitch: type should be integral" ); + + switch( value ) + { + case 1: + { lambda( std::integral_constant< T, 1 >() ); return; } + case 2: + { lambda( std::integral_constant< T, 2 >() ); return; } + case 3: + { lambda( std::integral_constant< T, 3 >() ); return; } + case 4: + { lambda( std::integral_constant< T, 4 >() ); return; } + case 5: + { lambda( std::integral_constant< T, 5 >() ); return; } + default: + { GEOSX_ERROR( "Unsupported number of components: " << value ); } + } +} + +} // namespace helpers + +template< typename KERNELWRAPPER, typename ... ARGS > +void CompositionalMultiphaseFlow::KernelLaunchSelector1( localIndex numComp, ARGS && ... args ) +{ + internal::KernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + KERNELWRAPPER::template Launch< NC() >( std::forward< ARGS >( args )... ); + } ); +} + +template< typename KERNELWRAPPER, typename ... ARGS > +void CompositionalMultiphaseFlow::KernelLaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ) +{ + internal::KernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + switch( numPhase ) + { + case 2: + { KERNELWRAPPER::template Launch< NC(), 2 >( std::forward< ARGS >( args )... ); return; } + case 3: + { KERNELWRAPPER::template Launch< NC(), 3 >( std::forward< ARGS >( args )... ); return; } + default: + { GEOSX_ERROR( "Unsupported number of phases: " << numPhase ); } + } + } ); +} + + } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index d8f2d043a6e..43b7f4d4bdd 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -191,14 +191,14 @@ struct FluidUpdateKernel Launch( localIndex const size, FLUID_WRAPPER const & fluidWrapper, arrayView1d< real64 const > const & pres, - real64 const temp, + arrayView1d< real64 const > const & temp, arrayView2d< real64 const > const & compFrac ) { forAll< POLICY >( size, [=] ( localIndex const k ) { for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k], temp, compFrac[k] ); + fluidWrapper.Update( k, q, pres[k], temp[k], compFrac[k] ); } } ); } @@ -209,14 +209,15 @@ struct FluidUpdateKernel FLUID_WRAPPER const & fluidWrapper, arrayView1d< real64 const > const & pres, arrayView1d< real64 const > const & dPres, - real64 const temp, + arrayView1d< real64 const > const & temp, + arrayView1d< real64 const > const & dTemp, arrayView2d< real64 const > const & compFrac ) { forAll< POLICY >( size, [=] ( localIndex const k ) { for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); + fluidWrapper.Update( k, q, pres[k] + dPres[k], temp[k] + dTemp[k], compFrac[k] ); } } ); } @@ -227,7 +228,8 @@ struct FluidUpdateKernel FLUID_WRAPPER const & fluidWrapper, arrayView1d< real64 const > const & pres, arrayView1d< real64 const > const & dPres, - real64 const temp, + arrayView1d< real64 const > const & temp, + arrayView1d< real64 const > const & dTemp, arrayView2d< real64 const > const & compFrac ) { forAll< POLICY >( targetSet.size(), [=] ( localIndex const a ) @@ -235,7 +237,7 @@ struct FluidUpdateKernel localIndex const k = targetSet[a]; for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); + fluidWrapper.Update( k, q, pres[k] + dPres[k], temp[k] + dTemp[k], compFrac[k] ); } } ); } @@ -245,7 +247,7 @@ struct FluidUpdateKernel Launch( SortedArrayView< localIndex const > const & targetSet, FLUID_WRAPPER const & fluidWrapper, arrayView1d< real64 const > const & pres, - real64 const temp, + arrayView1d< real64 const > const & temp, arrayView2d< real64 const > const & compFrac ) { forAll< POLICY >( targetSet.size(), [=] ( localIndex const a ) @@ -253,7 +255,7 @@ struct FluidUpdateKernel localIndex const k = targetSet[a]; for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k], temp, compFrac[k] ); + fluidWrapper.Update( k, q, pres[k], temp[k], compFrac[k] ); } } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp new file mode 100644 index 00000000000..b7ff59b6a57 --- /dev/null +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp @@ -0,0 +1,1314 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file IsothermalCompositionalMultiphaseFlowKernels.cpp + */ + +#include "IsothermalCompositionalMultiphaseFlowKernels.hpp" + +#include "finiteVolume/CellElementStencilTPFA.hpp" +#include "finiteVolume/FaceElementStencil.hpp" + +namespace geosx +{ + +namespace IsothermalCompositionalMultiphaseFlowKernels +{ + +/******************************** ComponentFractionKernel ********************************/ + +template< localIndex NC > +GEOSX_HOST_DEVICE +GEOSX_FORCE_INLINE +void +ComponentFractionKernel:: + Compute( arraySlice1d< real64 const > const compDens, + arraySlice1d< real64 const > const dCompDens, + arraySlice1d< real64 > const compFrac, + arraySlice2d< real64 > const dCompFrac_dCompDens ) +{ + real64 totalDensity = 0.0; + + for( localIndex ic = 0; ic < NC; ++ic ) + { + totalDensity += compDens[ic] + dCompDens[ic]; + } + + real64 const totalDensityInv = 1.0 / totalDensity; + + for( localIndex ic = 0; ic < NC; ++ic ) + { + compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; + } + dCompFrac_dCompDens[ic][ic] += totalDensityInv; + } +} + +template< localIndex NC > +void +ComponentFractionKernel:: + Launch( localIndex const size, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView2d< real64 > const & compFrac, + arrayView3d< real64 > const & dCompFrac_dCompDens ) +{ + forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) + { + Compute< NC >( compDens[a], + dCompDens[a], + compFrac[a], + dCompFrac_dCompDens[a] ); + } ); +} + +template< localIndex NC > +void +ComponentFractionKernel:: + Launch( SortedArrayView< localIndex const > const & targetSet, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView2d< real64 > const & compFrac, + arrayView3d< real64 > const & dCompFrac_dCompDens ) +{ + forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + Compute< NC >( compDens[a], + dCompDens[a], + compFrac[a], + dCompFrac_dCompDens[a] ); + } ); +} + +#define INST_ComponentFractionKernel( NC ) \ + template \ + void ComponentFractionKernel:: \ + Launch< NC >( localIndex const size, \ + arrayView2d< real64 const > const & compDens, \ + arrayView2d< real64 const > const & dCompDens, \ + arrayView2d< real64 > const & compFrac, \ + arrayView3d< real64 > const & dCompFrac_dCompDens ); \ + template \ + void ComponentFractionKernel:: \ + Launch< NC >( SortedArrayView< localIndex const > const & targetSet, \ + arrayView2d< real64 const > const & compDens, \ + arrayView2d< real64 const > const & dCompDens, \ + arrayView2d< real64 > const & compFrac, \ + arrayView3d< real64 > const & dCompFrac_dCompDens ) + +INST_ComponentFractionKernel( 1 ); +INST_ComponentFractionKernel( 2 ); +INST_ComponentFractionKernel( 3 ); +INST_ComponentFractionKernel( 4 ); +INST_ComponentFractionKernel( 5 ); + +#undef INST_ComponentFractionKernel + +/******************************** PhaseVolumeFractionKernel ********************************/ + +template< localIndex NC, localIndex NP > +GEOSX_HOST_DEVICE +GEOSX_FORCE_INLINE +void +PhaseVolumeFractionKernel:: + Compute( arraySlice1d< real64 const > const & compDens, + arraySlice1d< real64 const > const & dCompDens, + arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice1d< real64 const > const & phaseFrac, + arraySlice1d< real64 const > const & dPhaseFrac_dPres, + arraySlice2d< real64 const > const & dPhaseFrac_dComp, + arraySlice1d< real64 > const & phaseVolFrac, + arraySlice1d< real64 > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 > const & dPhaseVolFrac_dComp ) +{ + real64 work[NC]; + + // compute total density from component partial densities + real64 totalDensity = 0.0; + real64 const dTotalDens_dCompDens = 1.0; + for( localIndex ic = 0; ic < NC; ++ic ) + { + totalDensity += compDens[ic] + dCompDens[ic]; + } + + for( localIndex ip = 0; ip < NP; ++ip ) + { + // Expression for volume fractions: S_p = (nu_p / rho_p) * rho_t + real64 const phaseDensInv = 1.0 / phaseDens[ip]; + + // compute saturation and derivatives except multiplying by the total density + phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; + + dPhaseVolFrac_dPres[ip] = + (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; + + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] = + (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; + } + + // apply chain rule to convert derivatives from global component fractions to densities + applyChainRuleInPlace( NC, dCompFrac_dCompDens, dPhaseVolFrac_dComp[ip], work ); + + // now finalize the computation by multiplying by total density + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] *= totalDensity; + dPhaseVolFrac_dComp[ip][jc] += phaseVolFrac[ip] * dTotalDens_dCompDens; + } + + phaseVolFrac[ip] *= totalDensity; + dPhaseVolFrac_dPres[ip] *= totalDensity; + } +} + +template< localIndex NC, localIndex NP > +void PhaseVolumeFractionKernel:: + Launch( localIndex const size, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseFrac, + arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView4d< real64 const > const & dPhaseFrac_dComp, + arrayView2d< real64 > const & phaseVolFrac, + arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView3d< real64 > const & dPhaseVolFrac_dComp ) +{ + forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) + { + Compute< NC, NP >( compDens[a], + dCompDens[a], + dCompFrac_dCompDens[a], + phaseDens[a][0], + dPhaseDens_dPres[a][0], + dPhaseDens_dComp[a][0], + phaseFrac[a][0], + dPhaseFrac_dPres[a][0], + dPhaseFrac_dComp[a][0], + phaseVolFrac[a], + dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dComp[a] ); + } ); +} + +template< localIndex NC, localIndex NP > +void PhaseVolumeFractionKernel:: + Launch( SortedArrayView< localIndex const > const & targetSet, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseFrac, + arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView4d< real64 const > const & dPhaseFrac_dComp, + arrayView2d< real64 > const & phaseVolFrac, + arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView3d< real64 > const & dPhaseVolFrac_dComp ) +{ + forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + Compute< NC, NP >( compDens[a], + dCompDens[a], + dCompFrac_dCompDens[a], + phaseDens[a][0], + dPhaseDens_dPres[a][0], + dPhaseDens_dComp[a][0], + phaseFrac[a][0], + dPhaseFrac_dPres[a][0], + dPhaseFrac_dComp[a][0], + phaseVolFrac[a], + dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dComp[a] ); + } ); +} + +#define INST_PhaseVolumeFractionKernel( NC, NP ) \ + template \ + void \ + PhaseVolumeFractionKernel:: \ + Launch< NC, NP >( localIndex const size, \ + arrayView2d< real64 const > const & compDens, \ + arrayView2d< real64 const > const & dCompDens, \ + arrayView3d< real64 const > const & dCompFrac_dCompDens, \ + arrayView3d< real64 const > const & phaseDens, \ + arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView4d< real64 const > const & dPhaseDens_dComp, \ + arrayView3d< real64 const > const & phaseFrac, \ + arrayView3d< real64 const > const & dPhaseFrac_dPres, \ + arrayView4d< real64 const > const & dPhaseFrac_dComp, \ + arrayView2d< real64 > const & phaseVolFrac, \ + arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ + arrayView3d< real64 > const & dPhaseVolFrac_dComp ); \ + template \ + void \ + PhaseVolumeFractionKernel:: \ + Launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ + arrayView2d< real64 const > const & compDens, \ + arrayView2d< real64 const > const & dCompDens, \ + arrayView3d< real64 const > const & dCompFrac_dCompDens, \ + arrayView3d< real64 const > const & phaseDens, \ + arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView4d< real64 const > const & dPhaseDens_dComp, \ + arrayView3d< real64 const > const & phaseFrac, \ + arrayView3d< real64 const > const & dPhaseFrac_dPres, \ + arrayView4d< real64 const > const & dPhaseFrac_dComp, \ + arrayView2d< real64 > const & phaseVolFrac, \ + arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ + arrayView3d< real64 > const & dPhaseVolFrac_dComp ) + +INST_PhaseVolumeFractionKernel( 1, 1 ); +INST_PhaseVolumeFractionKernel( 2, 1 ); +INST_PhaseVolumeFractionKernel( 3, 1 ); +INST_PhaseVolumeFractionKernel( 4, 1 ); +INST_PhaseVolumeFractionKernel( 5, 1 ); + +INST_PhaseVolumeFractionKernel( 1, 2 ); +INST_PhaseVolumeFractionKernel( 2, 2 ); +INST_PhaseVolumeFractionKernel( 3, 2 ); +INST_PhaseVolumeFractionKernel( 4, 2 ); +INST_PhaseVolumeFractionKernel( 5, 2 ); + +INST_PhaseVolumeFractionKernel( 1, 3 ); +INST_PhaseVolumeFractionKernel( 2, 3 ); +INST_PhaseVolumeFractionKernel( 3, 3 ); +INST_PhaseVolumeFractionKernel( 4, 3 ); +INST_PhaseVolumeFractionKernel( 5, 3 ); + +#undef INST_PhaseVolumeFractionKernel + +/******************************** PhaseMobilityKernel ********************************/ + +template< localIndex NC, localIndex NP > +GEOSX_HOST_DEVICE +GEOSX_FORCE_INLINE +void +PhaseMobilityKernel:: + Compute( arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice1d< real64 const > const & phaseVisc, + arraySlice1d< real64 const > const & dPhaseVisc_dPres, + arraySlice2d< real64 const > const & dPhaseVisc_dComp, + arraySlice1d< real64 const > const & phaseRelPerm, + arraySlice2d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 const > const & dPhaseVolFrac_dComp, + arraySlice1d< real64 > const & phaseMob, + arraySlice1d< real64 > const & dPhaseMob_dPres, + arraySlice2d< real64 > const & dPhaseMob_dComp ) +{ + real64 dRelPerm_dC[NC]; + real64 dDens_dC[NC]; + real64 dVisc_dC[NC]; + + for( localIndex ip = 0; ip < NP; ++ip ) + { + real64 const density = phaseDens[ip]; + real64 const dDens_dP = dPhaseDens_dPres[ip]; + applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); + + real64 const viscosity = phaseVisc[ip]; + real64 const dVisc_dP = dPhaseVisc_dPres[ip]; + applyChainRule( NC, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); + + real64 const relPerm = phaseRelPerm[ip]; + real64 dRelPerm_dP = 0.0; + for( localIndex ic = 0; ic < NC; ++ic ) + { + dRelPerm_dC[ic] = 0.0; + } + + for( localIndex jp = 0; jp < NP; ++jp ) + { + real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; + dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; + + for( localIndex jc = 0; jc < NC; ++jc ) + { + dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; + } + } + + real64 const mobility = relPerm * density / viscosity; + + phaseMob[ip] = mobility; + dPhaseMob_dPres[ip] = dRelPerm_dP * density / viscosity + + mobility * (dDens_dP / density - dVisc_dP / viscosity); + + // compositional derivatives + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] * density / viscosity + + mobility * (dDens_dC[jc] / density - dVisc_dC[jc] / viscosity); + } + } +} + +template< localIndex NC, localIndex NP > +void PhaseMobilityKernel:: + Launch( localIndex const size, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseVisc, + arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView4d< real64 const > const & dPhaseVisc_dComp, + arrayView3d< real64 const > const & phaseRelPerm, + arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dComp, + arrayView2d< real64 > const & phaseMob, + arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView3d< real64 > const & dPhaseMob_dComp ) +{ + forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) + { + Compute< NC, NP >( dCompFrac_dCompDens[a], + phaseDens[a][0], + dPhaseDens_dPres[a][0], + dPhaseDens_dComp[a][0], + phaseVisc[a][0], + dPhaseVisc_dPres[a][0], + dPhaseVisc_dComp[a][0], + phaseRelPerm[a][0], + dPhaseRelPerm_dPhaseVolFrac[a][0], + dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dComp[a], + phaseMob[a], + dPhaseMob_dPres[a], + dPhaseMob_dComp[a] ); + } ); +} + +template< localIndex NC, localIndex NP > +void PhaseMobilityKernel:: + Launch( SortedArrayView< localIndex const > const & targetSet, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseVisc, + arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView4d< real64 const > const & dPhaseVisc_dComp, + arrayView3d< real64 const > const & phaseRelPerm, + arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dComp, + arrayView2d< real64 > const & phaseMob, + arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView3d< real64 > const & dPhaseMob_dComp ) +{ + forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) + { + localIndex const a = targetSet[ i ]; + Compute< NC, NP >( dCompFrac_dCompDens[a], + phaseDens[a][0], + dPhaseDens_dPres[a][0], + dPhaseDens_dComp[a][0], + phaseVisc[a][0], + dPhaseVisc_dPres[a][0], + dPhaseVisc_dComp[a][0], + phaseRelPerm[a][0], + dPhaseRelPerm_dPhaseVolFrac[a][0], + dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dComp[a], + phaseMob[a], + dPhaseMob_dPres[a], + dPhaseMob_dComp[a] ); + } ); +} + +#define INST_PhaseMobilityKernel( NC, NP ) \ + template \ + void \ + PhaseMobilityKernel:: \ + Launch< NC, NP >( localIndex const size, \ + arrayView3d< real64 const > const & dCompFrac_dCompDens, \ + arrayView3d< real64 const > const & phaseDens, \ + arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView4d< real64 const > const & dPhaseDens_dComp, \ + arrayView3d< real64 const > const & phaseVisc, \ + arrayView3d< real64 const > const & dPhaseVisc_dPres, \ + arrayView4d< real64 const > const & dPhaseVisc_dComp, \ + arrayView3d< real64 const > const & phaseRelPerm, \ + arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ + arrayView2d< real64 > const & phaseMob, \ + arrayView2d< real64 > const & dPhaseMob_dPres, \ + arrayView3d< real64 > const & dPhaseMob_dComp ); \ + template \ + void \ + PhaseMobilityKernel:: \ + Launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ + arrayView3d< real64 const > const & dCompFrac_dCompDens, \ + arrayView3d< real64 const > const & phaseDens, \ + arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView4d< real64 const > const & dPhaseDens_dComp, \ + arrayView3d< real64 const > const & phaseVisc, \ + arrayView3d< real64 const > const & dPhaseVisc_dPres, \ + arrayView4d< real64 const > const & dPhaseVisc_dComp, \ + arrayView3d< real64 const > const & phaseRelPerm, \ + arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ + arrayView2d< real64 > const & phaseMob, \ + arrayView2d< real64 > const & dPhaseMob_dPres, \ + arrayView3d< real64 > const & dPhaseMob_dComp ) + +INST_PhaseMobilityKernel( 1, 1 ); +INST_PhaseMobilityKernel( 2, 1 ); +INST_PhaseMobilityKernel( 3, 1 ); +INST_PhaseMobilityKernel( 4, 1 ); +INST_PhaseMobilityKernel( 5, 1 ); + +INST_PhaseMobilityKernel( 1, 2 ); +INST_PhaseMobilityKernel( 2, 2 ); +INST_PhaseMobilityKernel( 3, 2 ); +INST_PhaseMobilityKernel( 4, 2 ); +INST_PhaseMobilityKernel( 5, 2 ); + +INST_PhaseMobilityKernel( 1, 3 ); +INST_PhaseMobilityKernel( 2, 3 ); +INST_PhaseMobilityKernel( 3, 3 ); +INST_PhaseMobilityKernel( 4, 3 ); +INST_PhaseMobilityKernel( 5, 3 ); + +#undef INST_PhaseMobilityKernel + +/******************************** AccumulationKernel ********************************/ + +template< localIndex NC > +GEOSX_HOST_DEVICE +GEOSX_FORCE_INLINE +void +AccumulationKernel:: + Compute( localIndex const numPhases, + real64 const & volume, + real64 const & porosityOld, + real64 const & porosityRef, + real64 const & pvMult, + real64 const & dPvMult_dPres, + arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseVolFracOld, + arraySlice1d< real64 const > const & phaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDensOld, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice2d< real64 const > const & phaseCompFracOld, + arraySlice2d< real64 const > const & phaseCompFrac, + arraySlice2d< real64 const > const & dPhaseCompFrac_dPres, + arraySlice3d< real64 const > const & dPhaseCompFrac_dComp, + real64 ( & localAccum )[NC], + real64 ( & localAccumJacobian )[NC][NC + 1] ) +{ + localIndex constexpr NDOF = NC + 1; + localIndex const NP = numPhases; + + // temporary work arrays + real64 dPhaseAmount_dC[NC]; + real64 dPhaseCompFrac_dC[NC]; + + // reset the local values + for( localIndex i = 0; i < NC; ++i ) + { + localAccum[i] = 0.0; + for( localIndex j = 0; j < NDOF; ++j ) + { + localAccumJacobian[i][j] = 0.0; + } + } + + // compute fluid-independent (pore volume) part + real64 const volNew = volume; + real64 const volOld = volume; + real64 const dVol_dP = 0.0; // used in poroelastic solver + + real64 const poroNew = porosityRef * pvMult; + real64 const poroOld = porosityOld; + real64 const dPoro_dP = porosityRef * dPvMult_dPres; + + real64 const poreVolNew = volNew * poroNew; + real64 const poreVolOld = volOld * poroOld; + real64 const dPoreVol_dP = dVol_dP * poroNew + volNew * dPoro_dP; + + // sum contributions to component accumulation from each phase + for( localIndex ip = 0; ip < NP; ++ip ) + { + real64 const phaseAmountNew = poreVolNew * phaseVolFrac[ip] * phaseDens[ip]; + real64 const phaseAmountOld = poreVolOld * phaseVolFracOld[ip] * phaseDensOld[ip]; + + real64 const dPhaseAmount_dP = dPoreVol_dP * phaseVolFrac[ip] * phaseDens[ip] + + poreVolNew * (dPhaseVolFrac_dPres[ip] * phaseDens[ip] + + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); + + // assemble density dependence + applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] + + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][jc]; + dPhaseAmount_dC[jc] *= poreVolNew; + } + + // ic - index of component whose conservation equation is assembled + // (i.e. row number in local matrix) + for( localIndex 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]; + + localAccum[ic] += phaseCompAmountNew - phaseCompAmountOld; + localAccumJacobian[ic][0] += dPhaseCompAmount_dP; + + // jc - index of component w.r.t. whose compositional var the derivative is being taken + // (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 ) + { + real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew + + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; + localAccumJacobian[ic][jc + 1] += dPhaseCompAmount_dC; + } + } + } +} + +template< localIndex NC > +void +AccumulationKernel:: + Launch( localIndex const numPhases, + localIndex const size, + globalIndex const rankOffset, + arrayView1d< globalIndex const > const & dofNumber, + arrayView1d< integer const > const & elemGhostRank, + arrayView1d< real64 const > const & volume, + arrayView1d< real64 const > const & porosityOld, + arrayView1d< real64 const > const & porosityRef, + arrayView2d< real64 const > const & pvMult, + arrayView2d< real64 const > const & dPvMult_dPres, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView2d< real64 const > const & phaseVolFracOld, + arrayView2d< real64 const > const & phaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, + arrayView2d< real64 const > const & phaseDensOld, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseCompFracOld, + arrayView4d< real64 const > const & phaseCompFrac, + arrayView4d< real64 const > const & dPhaseCompFrac_dPres, + arrayView5d< real64 const > const & dPhaseCompFrac_dComp, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) +{ + forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( elemGhostRank[ei] >= 0 ) + return; + + localIndex constexpr NDOF = NC + 1; + + real64 localAccum[NC]; + real64 localAccumJacobian[NC][NDOF]; + + Compute< NC >( numPhases, + volume[ei], + porosityOld[ei], + porosityRef[ei], + pvMult[ei][0], + dPvMult_dPres[ei][0], + dCompFrac_dCompDens[ei], + phaseVolFracOld[ei], + phaseVolFrac[ei], + dPhaseVolFrac_dPres[ei], + dPhaseVolFrac_dCompDens[ei], + phaseDensOld[ei], + phaseDens[ei][0], + dPhaseDens_dPres[ei][0], + dPhaseDens_dComp[ei][0], + phaseCompFracOld[ei], + phaseCompFrac[ei][0], + dPhaseCompFrac_dPres[ei][0], + dPhaseCompFrac_dComp[ei][0], + localAccum, + localAccumJacobian ); + + // set DOF indices for this block + localIndex const localRow = dofNumber[ei] - rankOffset; + globalIndex dofIndices[NDOF]; + for( localIndex idof = 0; idof < NDOF; ++idof ) + { + dofIndices[idof] = dofNumber[ei] + idof; + } + + // TODO: apply equation/variable change transformation(s) + + // add contribution to residual and jacobian + for( localIndex i = 0; i < NC; ++i ) + { + localRhs[localRow + i] += localAccum[i]; + localMatrix.addToRow< serialAtomic >( localRow + i, + dofIndices, + localAccumJacobian[i], + NDOF ); + } + } ); +} + +#define INST_AccumulationKernel( NC ) \ + template \ + void \ + AccumulationKernel:: \ + Launch< NC >( localIndex const numPhases, \ + localIndex const size, \ + globalIndex const rankOffset, \ + arrayView1d< globalIndex const > const & dofNumber, \ + arrayView1d< integer const > const & elemGhostRank, \ + arrayView1d< real64 const > const & volume, \ + arrayView1d< real64 const > const & porosityOld, \ + arrayView1d< real64 const > const & porosityRef, \ + arrayView2d< real64 const > const & pvMult, \ + arrayView2d< real64 const > const & dPvMult_dPres, \ + arrayView3d< real64 const > const & dCompFrac_dCompDens, \ + arrayView2d< real64 const > const & phaseVolFracOld, \ + arrayView2d< real64 const > const & phaseVolFrac, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ + arrayView2d< real64 const > const & phaseDensOld, \ + arrayView3d< real64 const > const & phaseDens, \ + arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView4d< real64 const > const & dPhaseDens_dComp, \ + arrayView3d< real64 const > const & phaseCompFracOld, \ + arrayView4d< real64 const > const & phaseCompFrac, \ + arrayView4d< real64 const > const & dPhaseCompFrac_dPres, \ + arrayView5d< real64 const > const & dPhaseCompFrac_dComp, \ + CRSMatrixView< real64, globalIndex const > const & localMatrix, \ + arrayView1d< real64 > const & localRhs ) + +INST_AccumulationKernel( 1 ); +INST_AccumulationKernel( 2 ); +INST_AccumulationKernel( 3 ); +INST_AccumulationKernel( 4 ); +INST_AccumulationKernel( 5 ); + +#undef INST_AccumulationKernel + +/******************************** VolumeBalanceKernel ********************************/ + +template< localIndex NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL > +GEOSX_HOST_DEVICE +GEOSX_FORCE_INLINE +void +FluxKernel:: + Compute( localIndex const numPhases, + localIndex const stencilSize, + arraySlice1d< localIndex const > const seri, + arraySlice1d< localIndex const > const sesri, + arraySlice1d< localIndex const > const sei, + arraySlice1d< real64 const > const stencilWeights, + ElementViewConst< arrayView1d< real64 const > > const & pres, + ElementViewConst< arrayView1d< real64 const > > const & dPres, + ElementViewConst< arrayView1d< real64 const > > const & gravCoef, + ElementViewConst< arrayView2d< real64 const > > const & phaseMob, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, + ElementViewConst< arrayView3d< real64 const > > const & phaseDens, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseDens_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseDens_dComp, + ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + integer const capPressureFlag, + real64 const dt, + arraySlice1d< real64 > const localFlux, + arraySlice2d< real64 > const localFluxJacobian ) +{ + localIndex constexpr NDOF = NC + 1; + localIndex const NP = numPhases; + + real64 compFlux[NC]{}; + real64 dCompFlux_dP[MAX_STENCIL][NC]{}; + real64 dCompFlux_dC[MAX_STENCIL][NC][NC]{}; + + // loop over phases, compute and upwind phase flux and sum contributions to each component's flux + for( localIndex ip = 0; ip < NP; ++ip ) + { + // clear working arrays + real64 densMean{}; + real64 dDensMean_dP[NUM_ELEMS]{}; + real64 dDensMean_dC[NUM_ELEMS][NC]{}; + + // create local work arrays + real64 phaseFlux{}; + real64 dPhaseFlux_dP[MAX_STENCIL]{}; + real64 dPhaseFlux_dC[MAX_STENCIL][NC]{}; + + real64 presGrad{}; + real64 dPresGrad_dP[MAX_STENCIL]{}; + real64 dPresGrad_dC[MAX_STENCIL][NC]{}; + + real64 gravHead{}; + real64 dGravHead_dP[NUM_ELEMS]{}; + real64 dGravHead_dC[NUM_ELEMS][NC]{}; + + real64 dCapPressure_dC[NC]{}; + + // Working array + real64 dProp_dC[NC]{}; + + // calculate quantities on primary connected cells + for( localIndex i = 0; i < NUM_ELEMS; ++i ) + { + localIndex const er = seri[i]; + localIndex const esr = sesri[i]; + localIndex const ei = sei[i]; + + // density + real64 const density = phaseDens[er][esr][ei][0][ip]; + real64 const dDens_dP = dPhaseDens_dPres[er][esr][ei][0][ip]; + + applyChainRule( NC, + dCompFrac_dCompDens[er][esr][ei], + dPhaseDens_dComp[er][esr][ei][0][ip], + dProp_dC ); + + // average density and derivatives + densMean += 0.5 * density; + dDensMean_dP[i] = 0.5 * dDens_dP; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dDensMean_dC[i][jc] = 0.5 * dProp_dC[jc]; + } + } + + //***** calculation of flux ***** + + // compute potential difference MPFA-style + for( localIndex i = 0; i < stencilSize; ++i ) + { + localIndex const er = seri[i]; + localIndex const esr = sesri[i]; + localIndex const ei = sei[i]; + real64 const weight = stencilWeights[i]; + + // capillary pressure + real64 capPressure = 0.0; + real64 dCapPressure_dP = 0.0; + + for( localIndex ic = 0; ic < NC; ++ic ) + { + dCapPressure_dC[ic] = 0.0; + } + + if( capPressureFlag ) + { + capPressure = phaseCapPressure[er][esr][ei][0][ip]; + + for( localIndex jp = 0; jp < NP; ++jp ) + { + real64 const dCapPressure_dS = dPhaseCapPressure_dPhaseVolFrac[er][esr][ei][0][ip][jp]; + dCapPressure_dP += dCapPressure_dS * dPhaseVolFrac_dPres[er][esr][ei][jp]; + + for( localIndex jc = 0; jc < NC; ++jc ) + { + dCapPressure_dC[jc] += dCapPressure_dS * dPhaseVolFrac_dComp[er][esr][ei][jp][jc]; + } + } + } + + presGrad += weight * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); + dPresGrad_dP[i] += weight * (1 - dCapPressure_dP); + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPresGrad_dC[i][jc] += -weight * dCapPressure_dC[jc]; + } + + real64 const gravD = weight * gravCoef[er][esr][ei]; + gravHead += densMean * gravD; + + // need to add contributions from both cells the mean density depends on + for( localIndex j = 0; j < NUM_ELEMS; ++j ) + { + dGravHead_dP[j] += dDensMean_dP[j] * gravD; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dGravHead_dC[j][jc] += dDensMean_dC[j][jc] * gravD; + } + } + } + + // *** upwinding *** + + // use PPU currently; advanced stuff like IHU would go here + // TODO isolate into a kernel? + + // compute phase potential gradient + real64 const potGrad = presGrad - gravHead; + + // choose upstream cell + localIndex const k_up = (potGrad >= 0) ? 0 : 1; + + localIndex er_up = seri[k_up]; + localIndex esr_up = sesri[k_up]; + localIndex ei_up = sei[k_up]; + + real64 const mobility = phaseMob[er_up][esr_up][ei_up][ip]; + + // skip the phase flux if phase not present or immobile upstream + if( std::fabs( mobility ) < 1e-20 ) // TODO better constant + { + continue; + } + + // pressure gradient depends on all points in the stencil + for( localIndex ke = 0; ke < stencilSize; ++ke ) + { + dPhaseFlux_dP[ke] += dPresGrad_dP[ke]; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseFlux_dC[ke][jc] += dPresGrad_dC[ke][jc]; + } + + } + + // gravitational head depends only on the two cells connected (same as mean density) + for( localIndex ke = 0; ke < NUM_ELEMS; ++ke ) + { + dPhaseFlux_dP[ke] -= dGravHead_dP[ke]; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseFlux_dC[ke][jc] -= dGravHead_dC[ke][jc]; + } + } + + // compute the phase flux and derivatives using upstream cell mobility + phaseFlux = mobility * potGrad; + for( localIndex ke = 0; ke < stencilSize; ++ke ) + { + dPhaseFlux_dP[ke] *= mobility; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseFlux_dC[ke][jc] *= mobility; + } + } + + real64 const dMob_dP = dPhaseMob_dPres[er_up][esr_up][ei_up][ip]; + arraySlice1d< real64 const > dPhaseMob_dCompSub = dPhaseMob_dComp[er_up][esr_up][ei_up][ip]; + + // add contribution from upstream cell mobility derivatives + dPhaseFlux_dP[k_up] += dMob_dP * potGrad; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dPhaseFlux_dC[k_up][jc] += dPhaseMob_dCompSub[jc] * potGrad; + } + + // slice some constitutive arrays to avoid too much indexing in component loop + arraySlice1d< real64 const > phaseCompFracSub = phaseCompFrac[er_up][esr_up][ei_up][0][ip]; + arraySlice1d< real64 const > dPhaseCompFrac_dPresSub = dPhaseCompFrac_dPres[er_up][esr_up][ei_up][0][ip]; + arraySlice2d< real64 const > dPhaseCompFrac_dCompSub = dPhaseCompFrac_dComp[er_up][esr_up][ei_up][0][ip]; + + // compute component fluxes and derivatives using upstream cell composition + for( localIndex ic = 0; ic < NC; ++ic ) + { + real64 const ycp = phaseCompFracSub[ic]; + compFlux[ic] += phaseFlux * ycp; + + // derivatives stemming from phase flux + for( localIndex ke = 0; ke < stencilSize; ++ke ) + { + dCompFlux_dP[ke][ic] += dPhaseFlux_dP[ke] * ycp; + for( localIndex jc = 0; jc < NC; ++jc ) + { + dCompFlux_dC[ke][ic][jc] += dPhaseFlux_dC[ke][jc] * ycp; + } + } + + // additional derivatives stemming from upstream cell phase composition + dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFrac_dPresSub[ic]; + + // convert derivatives of component fraction w.r.t. component fractions to derivatives w.r.t. component + // densities + applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseCompFrac_dCompSub[ic], dProp_dC ); + for( localIndex jc = 0; jc < NC; ++jc ) + { + dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; + } + } + } + + // *** end of upwinding + + // populate local flux vector and derivatives + for( localIndex ic = 0; ic < NC; ++ic ) + { + localFlux[ic] = dt * compFlux[ic]; + localFlux[NC + ic] = -dt * compFlux[ic]; + + for( localIndex ke = 0; ke < stencilSize; ++ke ) + { + localIndex const localDofIndexPres = ke * NDOF; + localFluxJacobian[ic][localDofIndexPres] = dt * dCompFlux_dP[ke][ic]; + localFluxJacobian[NC + ic][localDofIndexPres] = -dt * dCompFlux_dP[ke][ic]; + + for( localIndex jc = 0; jc < NC; ++jc ) + { + localIndex const localDofIndexComp = localDofIndexPres + jc + 1; + localFluxJacobian[ic][localDofIndexComp] = dt * dCompFlux_dC[ke][ic][jc]; + localFluxJacobian[NC + ic][localDofIndexComp] = -dt * dCompFlux_dC[ke][ic][jc]; + } + } + } +} + +template< localIndex NC, typename STENCIL_TYPE > +void +FluxKernel:: + Launch( localIndex const numPhases, + STENCIL_TYPE const & stencil, + globalIndex const rankOffset, + ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, + ElementViewConst< arrayView1d< integer const > > const & ghostRank, + ElementViewConst< arrayView1d< real64 const > > const & pres, + ElementViewConst< arrayView1d< real64 const > > const & dPres, + ElementViewConst< arrayView1d< real64 const > > const & gravCoef, + ElementViewConst< arrayView2d< real64 const > > const & phaseMob, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, + ElementViewConst< arrayView3d< real64 const > > const & phaseDens, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseDens_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseDens_dComp, + ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + integer const capPressureFlag, + real64 const dt, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) +{ + typename STENCIL_TYPE::IndexContainerViewConstType const & seri = stencil.getElementRegionIndices(); + typename STENCIL_TYPE::IndexContainerViewConstType const & sesri = stencil.getElementSubRegionIndices(); + typename STENCIL_TYPE::IndexContainerViewConstType const & sei = stencil.getElementIndices(); + typename STENCIL_TYPE::WeightContainerViewConstType const & weights = stencil.getWeights(); + + localIndex constexpr NUM_ELEMS = STENCIL_TYPE::NUM_POINT_IN_FLUX; + localIndex constexpr MAX_STENCIL = STENCIL_TYPE::MAX_STENCIL_SIZE; + + forAll< parallelDevicePolicy<> >( stencil.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iconn ) + { + // TODO: hack! for MPFA, etc. must obtain proper size from e.g. seri + localIndex const stencilSize = MAX_STENCIL; + localIndex constexpr NDOF = NC + 1; + + stackArray1d< real64, NUM_ELEMS * NC > localFlux( NUM_ELEMS * NC ); + stackArray2d< real64, NUM_ELEMS * NC * MAX_STENCIL * NDOF > localFluxJacobian( NUM_ELEMS * NC, stencilSize * NDOF ); + + FluxKernel::Compute< NC, NUM_ELEMS, MAX_STENCIL >( numPhases, + stencilSize, + seri[iconn], + sesri[iconn], + sei[iconn], + weights[iconn], + pres, + dPres, + gravCoef, + phaseMob, + dPhaseMob_dPres, + dPhaseMob_dComp, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp, + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseCompFrac, + dPhaseCompFrac_dPres, + dPhaseCompFrac_dComp, + phaseCapPressure, + dPhaseCapPressure_dPhaseVolFrac, + capPressureFlag, + dt, + localFlux, + localFluxJacobian ); + + // populate dof indices + globalIndex dofColIndices[ MAX_STENCIL * NDOF ]; + for( localIndex i = 0; i < stencilSize; ++i ) + { + globalIndex const offset = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; + + for( localIndex jdof = 0; jdof < NDOF; ++jdof ) + { + dofColIndices[i * NDOF + jdof] = offset + jdof; + } + } + + // TODO: apply equation/variable change transformation(s) + + // Add to residual/jacobian + for( localIndex i = 0; i < NUM_ELEMS; ++i ) + { + if( ghostRank[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )] < 0 ) + { + globalIndex const globalRow = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; + localIndex const localRow = LvArray::integerConversion< localIndex >( globalRow - rankOffset ); + GEOSX_ASSERT_GE( localRow, 0 ); + GEOSX_ASSERT_GT( localMatrix.numRows(), localRow + NC ); + + for( localIndex ic = 0; ic < NC; ++ic ) + { + RAJA::atomicAdd( parallelDeviceAtomic{}, &localRhs[localRow + ic], localFlux[i * NC + ic] ); + localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( localRow + ic, + dofColIndices, + localFluxJacobian[i * NC + ic].dataIfContiguous(), + stencilSize * NDOF ); + } + } + } + } ); +} + +#define INST_FluxKernel( NC, STENCIL_TYPE ) \ + template \ + void FluxKernel:: \ + Launch< NC, STENCIL_TYPE >( localIndex const numPhases, \ + STENCIL_TYPE const & stencil, \ + globalIndex const rankOffset, \ + ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, \ + ElementViewConst< arrayView1d< integer const > > const & ghostRank, \ + ElementViewConst< arrayView1d< real64 const > > const & pres, \ + ElementViewConst< arrayView1d< real64 const > > const & dPres, \ + ElementViewConst< arrayView1d< real64 const > > const & gravCoef, \ + ElementViewConst< arrayView2d< real64 const > > const & phaseMob, \ + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, \ + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, \ + ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, \ + ElementViewConst< arrayView3d< real64 const > > const & phaseDens, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseDens_dPres, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseDens_dComp, \ + ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, \ + ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, \ + ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, \ + integer const capPressureFlag, \ + real64 const dt, \ + CRSMatrixView< real64, globalIndex const > const & localMatrix, \ + arrayView1d< real64 > const & localRhs ) + +INST_FluxKernel( 1, CellElementStencilTPFA ); +INST_FluxKernel( 2, CellElementStencilTPFA ); +INST_FluxKernel( 3, CellElementStencilTPFA ); +INST_FluxKernel( 4, CellElementStencilTPFA ); +INST_FluxKernel( 5, CellElementStencilTPFA ); + +INST_FluxKernel( 1, FaceElementStencil ); +INST_FluxKernel( 2, FaceElementStencil ); +INST_FluxKernel( 3, FaceElementStencil ); +INST_FluxKernel( 4, FaceElementStencil ); +INST_FluxKernel( 5, FaceElementStencil ); + +#undef INST_FluxKernel + +/******************************** VolumeBalanceKernel ********************************/ + +template< localIndex NC, localIndex NP > +GEOSX_HOST_DEVICE +GEOSX_FORCE_INLINE +void +VolumeBalanceKernel:: + Compute( real64 const & volume, + real64 const & porosityRef, + real64 const & pvMult, + real64 const & dPvMult_dPres, + arraySlice1d< real64 const > const & phaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, + real64 & localVolBalance, + real64 * const localVolBalanceJacobian ) +{ + localIndex constexpr NDOF = NC + 1; + + real64 const poro = porosityRef * pvMult; + real64 const dPoro_dP = porosityRef * dPvMult_dPres; + + real64 const poreVol = volume * poro; + real64 const dPoreVol_dP = volume * dPoro_dP; + + localVolBalance = 1.0; + for( localIndex i = 0; i < NDOF; ++i ) + { + localVolBalanceJacobian[i] = 0.0; + } + + // sum contributions to component accumulation from each phase + for( localIndex ip = 0; ip < NP; ++ip ) + { + localVolBalance -= phaseVolFrac[ip]; + localVolBalanceJacobian[0] -= dPhaseVolFrac_dPres[ip]; + + for( localIndex jc = 0; jc < NC; ++jc ) + { + localVolBalanceJacobian[jc+1] -= dPhaseVolFrac_dCompDens[ip][jc]; + } + } + + // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) + for( localIndex idof = 0; idof < NDOF; ++idof ) + { + localVolBalanceJacobian[idof] *= poreVol; + } + localVolBalanceJacobian[0] += dPoreVol_dP * localVolBalance; + localVolBalance *= poreVol; +} + +template< localIndex NC, localIndex NP > +void +VolumeBalanceKernel:: + Launch( localIndex const size, + globalIndex const rankOffset, + arrayView1d< globalIndex const > const & dofNumber, + arrayView1d< integer const > const & elemGhostRank, + arrayView1d< real64 const > const & volume, + arrayView1d< real64 const > const & porosityRef, + arrayView2d< real64 const > const & pvMult, + arrayView2d< real64 const > const & dPvMult_dPres, + arrayView2d< real64 const > const & phaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) +{ + forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( elemGhostRank[ei] >= 0 ) + return; + + localIndex constexpr NDOF = NC + 1; + + real64 localVolBalance; + real64 localVolBalanceJacobian[NDOF]; + + Compute< NC, NP >( volume[ei], + porosityRef[ei], + pvMult[ei][0], + dPvMult_dPres[ei][0], + phaseVolFrac[ei], + dPhaseVolFrac_dPres[ei], + dPhaseVolFrac_dCompDens[ei], + localVolBalance, + localVolBalanceJacobian ); + + // get equation/dof indices + localIndex const localRow = dofNumber[ei] + NC - rankOffset; + globalIndex dofIndices[NDOF]; + for( localIndex jdof = 0; jdof < NDOF; ++jdof ) + { + dofIndices[jdof] = dofNumber[ei] + jdof; + } + + // TODO: apply equation/variable change transformation(s) + + // add contribution to residual and jacobian + localRhs[localRow] += localVolBalance; + localMatrix.addToRow< serialAtomic >( localRow, + dofIndices, + localVolBalanceJacobian, + NDOF ); + } ); +} + +#define INST_VolumeBalanceKernel( NC, NP ) \ + template \ + void VolumeBalanceKernel:: \ + Launch< NC, NP >( localIndex const size, \ + globalIndex const rankOffset, \ + arrayView1d< globalIndex const > const & dofNumber, \ + arrayView1d< integer const > const & elemGhostRank, \ + arrayView1d< real64 const > const & volume, \ + arrayView1d< real64 const > const & porosityRef, \ + arrayView2d< real64 const > const & pvMult, \ + arrayView2d< real64 const > const & dPvMult_dPres, \ + arrayView2d< real64 const > const & phaseVolFrac, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ + CRSMatrixView< real64, globalIndex const > const & localMatrix, \ + arrayView1d< real64 > const & localRhs ) + +INST_VolumeBalanceKernel( 1, 1 ); +INST_VolumeBalanceKernel( 2, 1 ); +INST_VolumeBalanceKernel( 3, 1 ); +INST_VolumeBalanceKernel( 4, 1 ); +INST_VolumeBalanceKernel( 5, 1 ); + +INST_VolumeBalanceKernel( 1, 2 ); +INST_VolumeBalanceKernel( 2, 2 ); +INST_VolumeBalanceKernel( 3, 2 ); +INST_VolumeBalanceKernel( 4, 2 ); +INST_VolumeBalanceKernel( 5, 2 ); + +INST_VolumeBalanceKernel( 1, 3 ); +INST_VolumeBalanceKernel( 2, 3 ); +INST_VolumeBalanceKernel( 3, 3 ); +INST_VolumeBalanceKernel( 4, 3 ); +INST_VolumeBalanceKernel( 5, 3 ); + +#undef INST_VolumeBalanceKernel + +} // namespace IsothermalCompositionalMultiphaseFlowKernels + +} // namespace geosx + + + + diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp new file mode 100644 index 00000000000..8947efac727 --- /dev/null +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp @@ -0,0 +1,447 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file IsothermalCompositionalMultiphaseFlowKernels.hpp + */ + +#ifndef GEOSX_PHYSICSSOLVERS_FINITEVOLUME_ISOTHERMALCOMPOSITIONALMULTIPHASEFLOWKERNELS_HPP +#define GEOSX_PHYSICSSOLVERS_FINITEVOLUME_ISOTHERMALCOMPOSITIONALMULTIPHASEFLOWKERNELS_HPP + +#include "common/DataTypes.hpp" +#include "mesh/ElementRegionManager.hpp" +#include "rajaInterface/GEOS_RAJA_Interface.hpp" + +namespace geosx +{ + +namespace IsothermalCompositionalMultiphaseFlowKernels +{ + +/******************************** ComponentFractionKernel ********************************/ + +/** + * @brief Functions to compute component fractions from global component densities (mass or molar) + */ +struct ComponentFractionKernel +{ + template< localIndex NC > + GEOSX_HOST_DEVICE + GEOSX_FORCE_INLINE + static void + Compute( arraySlice1d< real64 const > compDens, + arraySlice1d< real64 const > dCompDens, + arraySlice1d< real64 > compFrac, + arraySlice2d< real64 > dCompFrac_dCompDens ); + + template< localIndex NC > + static void + Launch( localIndex const size, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView2d< real64 > const & compFrac, + arrayView3d< real64 > const & dCompFrac_dCompDens ); + + template< localIndex NC > + static void + Launch( SortedArrayView< localIndex const > const & targetSet, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView2d< real64 > const & compFrac, + arrayView3d< real64 > const & dCompFrac_dCompDens ); +}; + +/******************************** PhaseVolumeFractionKernel ********************************/ + +/** + * @brief Functions to compute phase volume fractions (saturations) and derivatives + */ +struct PhaseVolumeFractionKernel +{ + template< localIndex NC, localIndex NP > + GEOSX_HOST_DEVICE + GEOSX_FORCE_INLINE + static void + Compute( arraySlice1d< real64 const > const & compDens, + arraySlice1d< real64 const > const & dCompDens, + arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice1d< real64 const > const & phaseFrac, + arraySlice1d< real64 const > const & dPhaseFrac_dPres, + arraySlice2d< real64 const > const & dPhaseFrac_dComp, + arraySlice1d< real64 > const & phaseVolFrac, + arraySlice1d< real64 > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 > const & dPhaseVolFrac_dComp ); + + template< localIndex NC, localIndex NP > + static void + Launch( localIndex const size, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseFrac, + arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView4d< real64 const > const & dPhaseFrac_dComp, + arrayView2d< real64 > const & phaseVolFrac, + arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView3d< real64 > const & dPhaseVolFrac_dComp ); + + template< localIndex NC, localIndex NP > + static void + Launch( SortedArrayView< localIndex const > const & targetSet, + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseFrac, + arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView4d< real64 const > const & dPhaseFrac_dComp, + arrayView2d< real64 > const & phaseVolFrac, + arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView3d< real64 > const & dPhaseVolFrac_dComp ); +}; + +/******************************** PhaseMobilityKernel ********************************/ + +/** + * @brief Functions to compute phase mobilities and derivatives from density, viscosity and relperm + */ +struct PhaseMobilityKernel +{ + template< localIndex NC, localIndex NP > + GEOSX_HOST_DEVICE + GEOSX_FORCE_INLINE + static void + Compute( arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice1d< real64 const > const & phaseVisc, + arraySlice1d< real64 const > const & dPhaseVisc_dPres, + arraySlice2d< real64 const > const & dPhaseVisc_dComp, + arraySlice1d< real64 const > const & phaseRelPerm, + arraySlice2d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 const > const & dPhaseVolFrac_dComp, + arraySlice1d< real64 > const & phaseMob, + arraySlice1d< real64 > const & dPhaseMob_dPres, + arraySlice2d< real64 > const & dPhaseMob_dComp ); + + template< localIndex NC, localIndex NP > + static void + Launch( localIndex const size, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseVisc, + arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView4d< real64 const > const & dPhaseVisc_dComp, + arrayView3d< real64 const > const & phaseRelPerm, + arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dComp, + arrayView2d< real64 > const & phaseMob, + arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView3d< real64 > const & dPhaseMob_dComp ); + + template< localIndex NC, localIndex NP > + static void + Launch( SortedArrayView< localIndex const > const & targetSet, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseVisc, + arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView4d< real64 const > const & dPhaseVisc_dComp, + arrayView3d< real64 const > const & phaseRelPerm, + arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dComp, + arrayView2d< real64 > const & phaseMob, + arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView3d< real64 > const & dPhaseMob_dComp ); +}; + +/******************************** FluidUpdateKernel ********************************/ + +struct FluidUpdateKernel +{ + template< typename POLICY, typename FLUID_WRAPPER > + static void + Launch( localIndex const size, + FLUID_WRAPPER const & fluidWrapper, + arrayView1d< real64 const > const & pres, + real64 const temp, + arrayView2d< real64 const > const & compFrac ) + { + forAll< POLICY >( size, [=] ( localIndex const k ) + { + for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) + { + fluidWrapper.Update( k, q, pres[k], temp, compFrac[k] ); + } + } ); + } + + template< typename POLICY, typename FLUID_WRAPPER > + static void + Launch( localIndex const size, + FLUID_WRAPPER const & fluidWrapper, + arrayView1d< real64 const > const & pres, + arrayView1d< real64 const > const & dPres, + real64 const temp, + arrayView2d< real64 const > const & compFrac ) + { + forAll< POLICY >( size, [=] ( localIndex const k ) + { + for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) + { + fluidWrapper.Update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); + } + } ); + } + + template< typename POLICY, typename FLUID_WRAPPER > + static void + Launch( SortedArrayView< localIndex const > const & targetSet, + FLUID_WRAPPER const & fluidWrapper, + arrayView1d< real64 const > const & pres, + arrayView1d< real64 const > const & dPres, + real64 const temp, + arrayView2d< real64 const > const & compFrac ) + { + forAll< POLICY >( targetSet.size(), [=] ( localIndex const a ) + { + localIndex const k = targetSet[a]; + for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) + { + fluidWrapper.Update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); + } + } ); + } + + template< typename POLICY, typename FLUID_WRAPPER > + static void + Launch( SortedArrayView< localIndex const > const & targetSet, + FLUID_WRAPPER const & fluidWrapper, + arrayView1d< real64 const > const & pres, + real64 const temp, + arrayView2d< real64 const > const & compFrac ) + { + forAll< POLICY >( targetSet.size(), [=] ( localIndex const a ) + { + localIndex const k = targetSet[a]; + for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) + { + fluidWrapper.Update( k, q, pres[k], temp, compFrac[k] ); + } + } ); + } +}; + +/******************************** AccumulationKernel ********************************/ + +/** + * @brief Functions to assemble accumulation term contributions to residual and Jacobian + */ +struct AccumulationKernel +{ + template< localIndex NC > + GEOSX_HOST_DEVICE + GEOSX_FORCE_INLINE + static void + Compute( localIndex const numPhases, + real64 const & volume, + real64 const & porosityOld, + real64 const & porosityRef, + real64 const & pvMult, + real64 const & dPvMult_dPres, + arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseVolFracOld, + arraySlice1d< real64 const > const & phaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDensOld, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice2d< real64 const > const & phaseCompFracOld, + arraySlice2d< real64 const > const & phaseCompFrac, + arraySlice2d< real64 const > const & dPhaseCompFrac_dPres, + arraySlice3d< real64 const > const & dPhaseCompFrac_dComp, + real64 ( &localAccum )[NC], + real64 ( &localAccumJacobian )[NC][NC+1] ); + + template< localIndex NC > + static void + Launch( localIndex const numPhases, + localIndex const size, + globalIndex const rankOffset, + arrayView1d< globalIndex const > const & dofNumber, + arrayView1d< integer const > const & elemGhostRank, + arrayView1d< real64 const > const & volume, + arrayView1d< real64 const > const & porosityOld, + arrayView1d< real64 const > const & porosityRef, + arrayView2d< real64 const > const & pvMult, + arrayView2d< real64 const > const & dPvMult_dPres, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView2d< real64 const > const & phaseVolFracOld, + arrayView2d< real64 const > const & phaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, + arrayView2d< real64 const > const & phaseDensOld, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseCompFracOld, + arrayView4d< real64 const > const & phaseCompFrac, + arrayView4d< real64 const > const & dPhaseCompFrac_dPres, + arrayView5d< real64 const > const & dPhaseCompFrac_dComp, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ); +}; + +/******************************** FluxKernel ********************************/ + +/** + * @brief Functions to assemble flux term contributions to residual and Jacobian + */ +struct FluxKernel +{ + + /** + * @brief The type for element-based data. Consists entirely of ArrayView's. + * + * Can be converted from ElementRegionManager::ElementViewConstAccessor + * by calling .toView() or .toViewConst() on an accessor instance + */ + template< typename VIEWTYPE > + using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >; + + template< localIndex NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL > + GEOSX_HOST_DEVICE + GEOSX_FORCE_INLINE + static void + Compute( localIndex const stencilSize, + localIndex const numPhases, + arraySlice1d< localIndex const > const seri, + arraySlice1d< localIndex const > const sesri, + arraySlice1d< localIndex const > const sei, + arraySlice1d< real64 const > const stencilWeights, + ElementViewConst< arrayView1d< real64 const > > const & pres, + ElementViewConst< arrayView1d< real64 const > > const & dPres, + ElementViewConst< arrayView1d< real64 const > > const & gravCoef, + ElementViewConst< arrayView2d< real64 const > > const & phaseMob, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, + ElementViewConst< arrayView3d< real64 const > > const & phaseDens, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseDens_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseDens_dComp, + ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + integer const capPressureFlag, + real64 const dt, + arraySlice1d< real64 > const localFlux, + arraySlice2d< real64 > const localFluxJacobian ); + + template< localIndex NC, typename STENCIL_TYPE > + static void + Launch( localIndex const numPhases, + STENCIL_TYPE const & stencil, + globalIndex const rankOffset, + ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, + ElementViewConst< arrayView1d< integer const > > const & ghostRank, + ElementViewConst< arrayView1d< real64 const > > const & pres, + ElementViewConst< arrayView1d< real64 const > > const & dPres, + ElementViewConst< arrayView1d< real64 const > > const & gravCoef, + ElementViewConst< arrayView2d< real64 const > > const & phaseMob, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, + ElementViewConst< arrayView3d< real64 const > > const & phaseDens, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseDens_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseDens_dComp, + ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, + ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + integer const capPressureFlag, + real64 const dt, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ); +}; + +/******************************** VolumeBalanceKernel ********************************/ + +/** + * @brief Functions to assemble volume balance contributions to residual and Jacobian + */ +struct VolumeBalanceKernel +{ + template< localIndex NC, localIndex NP > + GEOSX_HOST_DEVICE + GEOSX_FORCE_INLINE + static void + Compute( real64 const & volume, + real64 const & porosityRef, + real64 const & pvMult, + real64 const & dPvMult_dPres, + arraySlice1d< real64 const > const & phaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, + real64 & localVolBalance, + real64 * const localVolBalanceJacobian ); + + template< localIndex NC, localIndex NP > + static void + Launch( localIndex const size, + globalIndex const rankOffset, + arrayView1d< globalIndex const > const & dofNumber, + arrayView1d< integer const > const & elemGhostRank, + arrayView1d< real64 const > const & volume, + arrayView1d< real64 const > const & porosityRef, + arrayView2d< real64 const > const & pvMult, + arrayView2d< real64 const > const & dPvMult_dPres, + arrayView2d< real64 const > const & phaseVolFrac, + arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ); +}; + + +} // namespace IsotherCompositionalMultiphaseFlowKernels + +} // namespace geosx + + +#endif //GEOSX_PHYSICSSOLVERS_FINITEVOLUME_ISOTHERMALCOMPOSITIONALMULTIPHASEFLOWKERNELS_HPP From 74010fabb22ab8e12b6ddf8dad3a3e60729ed632 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Wed, 16 Dec 2020 16:58:48 -0800 Subject: [PATCH 03/34] Assembly up to accumulation is done. --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 88 ++++++--- .../fluidFlow/CompositionalMultiphaseFlow.hpp | 2 + .../CompositionalMultiphaseFlowKernels.cpp | 177 ++++++++++++++++-- .../CompositionalMultiphaseFlowKernels.hpp | 32 ++-- ...rmalCompositionalMultiphaseFlowKernels.cpp | 91 --------- ...rmalCompositionalMultiphaseFlowKernels.hpp | 33 ---- 6 files changed, 251 insertions(+), 172 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index 1c41b522e42..f1b018b4733 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -162,10 +162,17 @@ void CompositionalMultiphaseFlow::RegisterDataOnMesh( Group * const MeshBodies ) if (m_isothermalFlag == 0) { - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString )->setPlotLevel( PlotLevel::LEVEL_0 ); + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString )-> + setPlotLevel( PlotLevel::LEVEL_0 ); elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString )-> setRestartFlags( RestartFlags::NO_WRITE ); + + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString )-> + setRestartFlags( RestartFlags::NO_WRITE ); + + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString )-> + setRestartFlags( RestartFlags::NO_WRITE ); } } ); } @@ -305,6 +312,15 @@ void CompositionalMultiphaseFlow::ResizeFields( MeshLevel & meshLevel ) const subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseDensityOldString ).resizeDimension< 1 >( NP ); subRegion.getReference< array3d< real64 > >( viewKeyStruct::phaseComponentFractionOldString ).resizeDimension< 1, 2 >( NP, NC ); } ); + + if (m_isothermalFlag == 0) + { + forTargetSubRegions( meshLevel, [&]( localIndex const, ElementSubRegionBase & subRegion ) + { + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ).resizeDimension<1>( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ).resizeDimension<1>( NP ); + }); + } } void CompositionalMultiphaseFlow::UpdateComponentFraction( Group & dataGroup ) const @@ -327,30 +343,13 @@ void CompositionalMultiphaseFlow::UpdateComponentFraction( Group & dataGroup ) c arrayView2d< real64 const > const dCompDens = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); - if ( m_isoThermalFlag ) - { - KernelLaunchSelector1 - < IsothermalCompositionalMultiphaseFlowKernels::ComponentFractionKernel >( m_numComponents, - dataGroup.size(), - compDens, - dCompDens, - compFrac, - dCompFrac_dCompDens ); - } else - { - // Get thermal views KernelLaunchSelector1 - < CompositionalMultiphaseFlowKernels::ComponentFractionKernel >( m_numComponents, - dataGroup.size(), - compDens, - dCompDens, - temperature, - dtemperature, - compFrac, - dCompFrac_dCompDens, - dCompFrac_dTemperature ); - - } + < CompositionalMultiphaseFlowKernels::ComponentFractionKernel >( m_numComponents, + dataGroup.size(), + compDens, + dCompDens, + compFrac, + dCompFrac_dCompDens ); } void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, localIndex const targetIndex ) const @@ -409,6 +408,12 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, } else { // Get thermal views + arrayView3d< real64 const > const & dPhaseFrac_dTemp = fluid.dPhaseFraction_dTemperature(); + arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); + + arrayView2d< real64 > const dPhaseVolFrac_dTemp = + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, dataGroup.size(), @@ -417,12 +422,15 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, dCompFrac_dCompDens, phaseDens, dPhaseDens_dPres, + dPhaseDens_dTemp, dPhaseDens_dComp, phaseFrac, dPhaseFrac_dPres, + dPhaseFrac_dTemp, dPhaseFrac_dComp, phaseVolFrac, dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, dPhaseVolFrac_dComp ); } @@ -897,6 +905,26 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con localRhs ); }else { + + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + + arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); + arrayView4d< real64 const > const & dPhaseCompFrac_dTemp = fluid.dPhaseCompFraction_dTemperature(); + + arrayView2d< real64 const > const & phaseInternalEnergyOld = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); + arrayView3d< real64 const > const & phaseInternalEnergy = fluid.phaseInternalEnergy(); + arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres = fluid.dPhaseInternalEnergy_dPressure(); + arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp = fluid.dPhaseInternalEnergy_dTemperature(); + arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp = fluid.dPhaseInternalEnergy_dGlobalCompFraction(); + + arrayView1d< real64 const > const & rockInternalEnergyOld = + subRegion.getReference< array1d< real64 > >(viewKeyStruct::rockInternalEnergyOldString ); + arrayView1d< real64 const > const & rockInternalEnergy = solid.internalEnergy(); + arrayView1d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); + arrayView1d< real64 const > const & rockDensity = solid.density(); + KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, m_numPhases, @@ -913,15 +941,27 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con phaseVolFracOld, phaseVolFrac, dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, dPhaseVolFrac_dCompDens, phaseDensOld, phaseDens, dPhaseDens_dPres, + dPhaseDens_dTemp, dPhaseDens_dComp, phaseCompFracOld, phaseCompFrac, dPhaseCompFrac_dPres, + dPhaseCompFrac_dTemp, dPhaseCompFrac_dComp, + phaseInternalEnergyOld[ei], + phaseInternalEnergy, + dPhaseInternalEnergy_dPres, + dPhaseInternalEnergy_dTemp, + dPhaseInternalEnergy_dComp, + rockInternalEnergyOld, + rockInternalEnergy, + dRockInternalEnergy_dTemp, + rockDensity, localMatrix, localRhs ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp index edb2ca24b96..34e19154d85 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp @@ -307,11 +307,13 @@ class CompositionalMultiphaseFlow : public FlowSolverBase static constexpr auto phaseVolumeFractionString = "phaseVolumeFraction"; static constexpr auto dPhaseVolumeFraction_dPressureString = "dPhaseVolumeFraction_dPressure"; static constexpr auto dPhaseVolumeFraction_dGlobalCompDensityString = "dPhaseVolumeFraction_dGlobalCompDensity"; + static constexpr auto dPhaseVolumeFraction_dTemperatureString = "dPhaseVolumeFraction_dTemperature" // intermediate values for mobilities static constexpr auto phaseMobilityString = "phaseMobility"; static constexpr auto dPhaseMobility_dPressureString = "dPhaseMobility_dPressure"; static constexpr auto dPhaseMobility_dGlobalCompDensityString = "dPhaseMobility_dGlobalCompDensity"; + static constexpr auto dPhaseMobility_dTemperatureString = "dPhaseMobility_dTemperature"; // these are used to store last converged time step values static constexpr auto phaseVolumeFractionOldString = "phaseVolumeFractionOld"; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index 3a43100497c..2e3079276ec 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -132,12 +132,15 @@ PhaseVolumeFractionKernel:: arraySlice2d< real64 const > const & dCompFrac_dCompDens, arraySlice1d< real64 const > const & phaseDens, arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice1d< real64 const > const & dPhaseDens_dTemp, arraySlice2d< real64 const > const & dPhaseDens_dComp, arraySlice1d< real64 const > const & phaseFrac, arraySlice1d< real64 const > const & dPhaseFrac_dPres, + arraySlice1d< real64 const > const & dPhaseFrac_dTemp, arraySlice2d< real64 const > const & dPhaseFrac_dComp, arraySlice1d< real64 > const & phaseVolFrac, arraySlice1d< real64 > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 > const & dPhaseVolFrac_dComp ) { real64 work[NC]; @@ -161,6 +164,9 @@ PhaseVolumeFractionKernel:: dPhaseVolFrac_dPres[ip] = (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; + dPhaseVolFrac_dTemp[ip] = + (dPhaseFrac_dTemp[ip] - phaseVolFrac[ip] * dPhaseDens_dTemp[ip]) * phaseDensInv; + for( localIndex jc = 0; jc < NC; ++jc ) { dPhaseVolFrac_dComp[ip][jc] = @@ -179,6 +185,7 @@ PhaseVolumeFractionKernel:: phaseVolFrac[ip] *= totalDensity; dPhaseVolFrac_dPres[ip] *= totalDensity; + dPhaseVolFrac_dTemp[ip] *= totalDensity; } } @@ -190,12 +197,14 @@ void PhaseVolumeFractionKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseFrac, arrayView3d< real64 const > const & dPhaseFrac_dPres, arrayView4d< real64 const > const & dPhaseFrac_dComp, arrayView2d< real64 > const & phaseVolFrac, arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, arrayView3d< real64 > const & dPhaseVolFrac_dComp ) { forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) @@ -205,12 +214,15 @@ void PhaseVolumeFractionKernel:: dCompFrac_dCompDens[a], phaseDens[a][0], dPhaseDens_dPres[a][0], + dPhaseDens_dTemp[a][0], dPhaseDens_dComp[a][0], phaseFrac[a][0], dPhaseFrac_dPres[a][0], + dPhaseDens_dTemp[a][0], dPhaseFrac_dComp[a][0], phaseVolFrac[a], dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dTemp[a], dPhaseVolFrac_dComp[a] ); } ); } @@ -223,12 +235,15 @@ void PhaseVolumeFractionKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseFrac, arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView3d< real64 const > const & dPhaseFrac_dTemp, arrayView4d< real64 const > const & dPhaseFrac_dComp, arrayView2d< real64 > const & phaseVolFrac, arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, arrayView3d< real64 > const & dPhaseVolFrac_dComp ) { forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) @@ -239,12 +254,15 @@ void PhaseVolumeFractionKernel:: dCompFrac_dCompDens[a], phaseDens[a][0], dPhaseDens_dPres[a][0], + dPhaseDens_dTemp[a][0], dPhaseDens_dComp[a][0], phaseFrac[a][0], dPhaseFrac_dPres[a][0], + dPhaseFrac_dTemp[a][0], dPhaseFrac_dComp[a][0], phaseVolFrac[a], dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dTemp[a], dPhaseVolFrac_dComp[a] ); } ); } @@ -259,12 +277,15 @@ void PhaseVolumeFractionKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseFrac, \ arrayView3d< real64 const > const & dPhaseFrac_dPres, \ + arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ arrayView4d< real64 const > const & dPhaseFrac_dComp, \ arrayView2d< real64 > const & phaseVolFrac, \ - arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 > const & dPhaseVolFrac_dPres,\ + arrayView2d< real64 > const & dPhaseVolFrac_dTemp,\ arrayView3d< real64 > const & dPhaseVolFrac_dComp ); \ template \ void \ @@ -275,12 +296,15 @@ void PhaseVolumeFractionKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseFrac, \ arrayView3d< real64 const > const & dPhaseFrac_dPres, \ + arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ arrayView4d< real64 const > const & dPhaseFrac_dComp, \ arrayView2d< real64 > const & phaseVolFrac, \ arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 > const & dPhaseVolFrac_dComp ) INST_PhaseVolumeFractionKernel( 1, 1 ); @@ -313,16 +337,20 @@ PhaseMobilityKernel:: Compute( arraySlice2d< real64 const > const & dCompFrac_dCompDens, arraySlice1d< real64 const > const & phaseDens, arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice1d< real64 const > const & dPhaseDens_dTemp, arraySlice2d< real64 const > const & dPhaseDens_dComp, arraySlice1d< real64 const > const & phaseVisc, arraySlice1d< real64 const > const & dPhaseVisc_dPres, + arraySlice1d< real64 const > const & dPhaseVisc_dTemp, arraySlice2d< real64 const > const & dPhaseVisc_dComp, arraySlice1d< real64 const > const & phaseRelPerm, arraySlice2d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dComp, arraySlice1d< real64 > const & phaseMob, arraySlice1d< real64 > const & dPhaseMob_dPres, + arraySlice1d< real64 > const & dPhaseMob_dTemp, arraySlice2d< real64 > const & dPhaseMob_dComp ) { real64 dRelPerm_dC[NC]; @@ -333,14 +361,17 @@ PhaseMobilityKernel:: { real64 const density = phaseDens[ip]; real64 const dDens_dP = dPhaseDens_dPres[ip]; + real64 const dDens_dT = dPhaseDens_dTemp[ip]; applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); real64 const viscosity = phaseVisc[ip]; real64 const dVisc_dP = dPhaseVisc_dPres[ip]; + real64 const dVisc_dT = dPhaseVisc_dTemp[ip]; applyChainRule( NC, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); real64 const relPerm = phaseRelPerm[ip]; real64 dRelPerm_dP = 0.0; + real64 dRelPerm_dT = 0.0; for( localIndex ic = 0; ic < NC; ++ic ) { dRelPerm_dC[ic] = 0.0; @@ -350,6 +381,7 @@ PhaseMobilityKernel:: { real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; + dRelPerm_dT += dRelPerm_dS * dPhaseVolFrac_dTemp[jp]; for( localIndex jc = 0; jc < NC; ++jc ) { @@ -363,6 +395,9 @@ PhaseMobilityKernel:: dPhaseMob_dPres[ip] = dRelPerm_dP * density / viscosity + mobility * (dDens_dP / density - dVisc_dP / viscosity); + dPhaseMob_dTemp[ip] = dRelPerm_dT * density / viscosity + + mobility * (dDens_dT / density - dVisc_dT / viscosity); + // compositional derivatives for( localIndex jc = 0; jc < NC; ++jc ) { @@ -378,16 +413,20 @@ void PhaseMobilityKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseVisc, arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView3d< real64 const > const & dPhaseVisc_dTemp, arrayView4d< real64 const > const & dPhaseVisc_dComp, arrayView3d< real64 const > const & phaseRelPerm, arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dComp, arrayView2d< real64 > const & phaseMob, arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView2d< real64 > const & dPhaseMob_dTemp, arrayView3d< real64 > const & dPhaseMob_dComp ) { forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) @@ -395,16 +434,20 @@ void PhaseMobilityKernel:: Compute< NC, NP >( dCompFrac_dCompDens[a], phaseDens[a][0], dPhaseDens_dPres[a][0], + dPhaseDens_dTemp[a][0], dPhaseDens_dComp[a][0], phaseVisc[a][0], dPhaseVisc_dPres[a][0], + dPhaseVisc_dTemp[a][0], dPhaseVisc_dComp[a][0], phaseRelPerm[a][0], dPhaseRelPerm_dPhaseVolFrac[a][0], dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dTemp[a], dPhaseVolFrac_dComp[a], phaseMob[a], dPhaseMob_dPres[a], + dPhaseMob_dTemp[a], dPhaseMob_dComp[a] ); } ); } @@ -415,16 +458,20 @@ void PhaseMobilityKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseVisc, arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView3d< real64 const > const & dPhaseVisc_dTemp, arrayView4d< real64 const > const & dPhaseVisc_dComp, arrayView3d< real64 const > const & phaseRelPerm, arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dComp, arrayView2d< real64 > const & phaseMob, arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView2d< real64 > const & dPhaseMob_dTemp, arrayView3d< real64 > const & dPhaseMob_dComp ) { forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) @@ -433,16 +480,20 @@ void PhaseMobilityKernel:: Compute< NC, NP >( dCompFrac_dCompDens[a], phaseDens[a][0], dPhaseDens_dPres[a][0], + dPhaseDens_dTemp[a][0], dPhaseDens_dComp[a][0], phaseVisc[a][0], dPhaseVisc_dPres[a][0], + dPhaseVisc_dTemp[a][0], dPhaseVisc_dComp[a][0], phaseRelPerm[a][0], dPhaseRelPerm_dPhaseVolFrac[a][0], dPhaseVolFrac_dPres[a], + dPhaseVolFrac_dTemp[a], dPhaseVolFrac_dComp[a], phaseMob[a], dPhaseMob_dPres[a], + dPhaseMob_dTemp[a], dPhaseMob_dComp[a] ); } ); } @@ -455,16 +506,20 @@ void PhaseMobilityKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseVisc, \ arrayView3d< real64 const > const & dPhaseVisc_dPres, \ + arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ arrayView4d< real64 const > const & dPhaseVisc_dComp, \ arrayView3d< real64 const > const & phaseRelPerm, \ arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp,\ arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ arrayView2d< real64 > const & phaseMob, \ arrayView2d< real64 > const & dPhaseMob_dPres, \ + arrayView2d< real64 > const & dPhaseMob_dTemp, \ arrayView3d< real64 > const & dPhaseMob_dComp ); \ template \ void \ @@ -473,16 +528,20 @@ void PhaseMobilityKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseVisc, \ arrayView3d< real64 const > const & dPhaseVisc_dPres, \ + arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ arrayView4d< real64 const > const & dPhaseVisc_dComp, \ arrayView3d< real64 const > const & phaseRelPerm, \ arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp,\ arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ arrayView2d< real64 > const & phaseMob, \ arrayView2d< real64 > const & dPhaseMob_dPres, \ + arrayView2d< real64 > const & dPhaseMob_dTemp, \ arrayView3d< real64 > const & dPhaseMob_dComp ) INST_PhaseMobilityKernel( 1, 1 ); @@ -522,27 +581,42 @@ AccumulationKernel:: arraySlice1d< real64 const > const & phaseVolFracOld, arraySlice1d< real64 const > const & phaseVolFrac, arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, arraySlice1d< real64 const > const & phaseDensOld, arraySlice1d< real64 const > const & phaseDens, arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice1d< real64 const > const & dPhaseDens_dTemp, arraySlice2d< real64 const > const & dPhaseDens_dComp, arraySlice2d< real64 const > const & phaseCompFracOld, arraySlice2d< real64 const > const & phaseCompFrac, arraySlice2d< real64 const > const & dPhaseCompFrac_dPres, + arraySlice2d< real64 const > const & dPhaseCompFrac_dTemp, arraySlice3d< real64 const > const & dPhaseCompFrac_dComp, - real64 ( & localAccum )[NC], - real64 ( & localAccumJacobian )[NC][NC + 1] ) + arraySlice1d< real64 const > const & phaseInternalEnergyOld, + arraySlice1d< real64 const > const & phaseInternalEnergy, + arraySlice1d< real64 const > const & dPhaseInternalEnergy_dPres, + arraySlice1d< real64 const > const & dPhaseInternalEnergy_dTemp, + arraySlice2d< real64 const > const & dPhaseInternalEnergy_dComp, + real64 const & rockInternalEnergyOld, + real64 const & rockInternalEnergy, + real64 const & dRockInternalEnergy_dTemp, + real64 const & rockDensity, + real64 ( & localAccum )[NC + 1], + real64 ( & localAccumJacobian )[NC + 1][NC + 2] ) { - localIndex constexpr NDOF = NC + 1; + + // pressure, NC component densities, temperature + localIndex constexpr NDOF = NC + 2; localIndex const NP = numPhases; // temporary work arrays - real64 dPhaseAmount_dC[NC]; - real64 dPhaseCompFrac_dC[NC]; + real64 dPhaseAmount_dC[NC]; // Derivative rho_ph * phi * S_ph w.r.t. comp densities + real64 dPhaseCompFrac_dC[NC]; // Derivative of phase component fractions w.r.t. comp densities + real64 dPhaseInternalEnergy_dC[NC]; // Derivative of phase internal energy w.r.t. comp densities // reset the local values - for( localIndex i = 0; i < NC; ++i ) + for( localIndex i = 0; i < NC+1; ++i ) { localAccum[i] = 0.0; for( localIndex j = 0; j < NDOF; ++j ) @@ -563,10 +637,13 @@ AccumulationKernel:: real64 const poreVolNew = volNew * poroNew; real64 const poreVolOld = volOld * poroOld; real64 const dPoreVol_dP = dVol_dP * poroNew + volNew * dPoro_dP; + real64 const dPoreVol_dT = 0.0; // sum contributions to component accumulation from each phase for( localIndex ip = 0; ip < NP; ++ip ) { + // 1. Mass balance equations + real64 const phaseAmountNew = poreVolNew * phaseVolFrac[ip] * phaseDens[ip]; real64 const phaseAmountOld = poreVolOld * phaseVolFracOld[ip] * phaseDensOld[ip]; @@ -574,6 +651,10 @@ AccumulationKernel:: + poreVolNew * (dPhaseVolFrac_dPres[ip] * phaseDens[ip] + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); + real64 const dPhaseAmount_dT = dPoreVol_dT * phaseVolFrac[ip] * phaseDens[ip] + + poreVolNew * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] + + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); + // assemble density dependence applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); for( localIndex jc = 0; jc < NC; ++jc ) @@ -593,8 +674,12 @@ AccumulationKernel:: real64 const dPhaseCompAmount_dP = dPhaseAmount_dP * phaseCompFrac[ip][ic] + phaseAmountNew * dPhaseCompFrac_dPres[ip][ic]; + real64 const dPhaseCompAmount_dT = dPhaseAmount_dT * phaseCompFrac[ip][ic] + + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; + localAccum[ic] += phaseCompAmountNew - phaseCompAmountOld; localAccumJacobian[ic][0] += dPhaseCompAmount_dP; + localAccumJacobian[ic][NC+1] += dPhaseCompAmount_dT; // jc - index of component w.r.t. whose compositional var the derivative is being taken // (i.e. col number in local matrix) @@ -608,6 +693,37 @@ AccumulationKernel:: localAccumJacobian[ic][jc + 1] += dPhaseCompAmount_dC; } } + + // 2. Energy balance equation + real64 const phaseEnergyNew = phaseAmountNew * phaseInternalEnergy[ip]; + real64 const phaseEnergyOld = phaseAmountOld * phaseInternalEnergyOld[ip]; + + real64 const solidEnergyNew = (1 - poroNew) * volNew * rockInternalEnergy * rockDensity; + real64 const solidEnergyOld = (1 - poroOld) * volOld * rockInternalEnergyOld * rockDensity; + + // local accumulation + localAccum[NC+1] = phaseEnergyNew - phaseEnergyOld + solidEnergyNew - solidEnergyOld; + + real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dP[ip]; + real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dT[ip]; + + real64 const dSolidInternalEnergy_dP = -dPoro_dP * volNew * rockInternalEnergyNew * rockDensity; + // TODO porosity and volume may depend on temperature + real64 const dSolidInternalEnergy_dT = (1 - poroNew) * volNew * dRockInternalEnergy_dTemp; + + // derivatives w.r.t. pressure and temperature + localAccumJacobian[NC+1][0] += dPhaseEnergy_dP; + localAccumJacobian[NC+1][NC+2] += dPhaseEnergy_dT + dSolidInternalEnergy_dT; + + // derivatives w.r.t. component densities + applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseIntenalEnergy_dC ); + for ( localIndex jc = 0; jc < NC; ++jc ) + { + real64 const dPhaseEnergy_dC = phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; + + localAccumJacobian[NC+1][jc + 1] += dPhaseEnergy_dC; + } } } @@ -628,15 +744,27 @@ AccumulationKernel:: arrayView2d< real64 const > const & phaseVolFracOld, arrayView2d< real64 const > const & phaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, arrayView2d< real64 const > const & phaseDensOld, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseCompFracOld, arrayView4d< real64 const > const & phaseCompFrac, arrayView4d< real64 const > const & dPhaseCompFrac_dPres, + arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, arrayView5d< real64 const > const & dPhaseCompFrac_dComp, + arrayView2d< real64 const > const & phaseInternalEnergyOld, + arrayView3d< real64 const > const & phaseInternalEnergy, + arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, + arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, + arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, + arrayView1d< real64 const > const & rockInternalEnergyOld, + arrayView1d< real64 const > const & rockInternalEnergy, + arrayView1d< real64 const > const & dRockInternalEnergy_dTemp, + arrayView1d< real64 const > const & rockDensity, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { @@ -645,10 +773,11 @@ AccumulationKernel:: if( elemGhostRank[ei] >= 0 ) return; - localIndex constexpr NDOF = NC + 1; + localIndex constexpr NDOF = NC + 2; // number of dofs + localIndex constexpr NBEQ = NC + 1; // number of balance equations - real64 localAccum[NC]; - real64 localAccumJacobian[NC][NDOF]; + real64 localAccum[NBEQ]; + real64 localAccumJacobian[NBEQ][NDOF]; Compute< NC >( numPhases, volume[ei], @@ -660,15 +789,27 @@ AccumulationKernel:: phaseVolFracOld[ei], phaseVolFrac[ei], dPhaseVolFrac_dPres[ei], + dPhaseVolFrac_dTemp[ei], dPhaseVolFrac_dCompDens[ei], phaseDensOld[ei], phaseDens[ei][0], dPhaseDens_dPres[ei][0], + dPhaseDens_dTemp[ei][0], dPhaseDens_dComp[ei][0], phaseCompFracOld[ei], phaseCompFrac[ei][0], dPhaseCompFrac_dPres[ei][0], + dPhaseCompFrac_dTemp[ei][0], dPhaseCompFrac_dComp[ei][0], + phaseInternalEnergyOld[ei], + phaseInternalEnergy[ei][0], + dPhaseInternalEnergy_dPres[ei][0], + dPhaseInternalEnergy_dTemp[ei][0], + dPhaseInternalEnergy_dComp[ei][0], + rockInternalEnergyOld[ei], + rockInternalEnergy[ei][0], + dRockInternalEnergy_dTemp[ei][0], + rockDensity[ei], localAccum, localAccumJacobian ); @@ -680,10 +821,8 @@ AccumulationKernel:: dofIndices[idof] = dofNumber[ei] + idof; } - // TODO: apply equation/variable change transformation(s) - // add contribution to residual and jacobian - for( localIndex i = 0; i < NC; ++i ) + for( localIndex i = 0; i < NBEQ + 1; ++i ) { localRhs[localRow + i] += localAccum[i]; localMatrix.addToRow< serialAtomic >( localRow + i, @@ -712,15 +851,27 @@ AccumulationKernel:: arrayView2d< real64 const > const & phaseVolFracOld, \ arrayView2d< real64 const > const & phaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ arrayView2d< real64 const > const & phaseDensOld, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseCompFracOld, \ arrayView4d< real64 const > const & phaseCompFrac, \ arrayView4d< real64 const > const & dPhaseCompFrac_dPres, \ + arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, \ arrayView5d< real64 const > const & dPhaseCompFrac_dComp, \ + arrayView2d< real64 const > const & phaseInternalEnergyOld, \ + arrayView2d< real64 const > const & phaseInternalEnergy, \ + arrayView2d< real64 const > const & dPhaseInternalEnergy_dPres, \ + arrayView2d< real64 const > const & dPhaseInternalEnergy_dTemp, \ + arrayView3d< real64 const > const & dPhaseInternalEnergy_dComp, \ + arrayView1d< real64 const > const & rockInternalEnergyOld, \ + arrayView1d< real64 const > const & rockInternalEnergy, \ + arrayView1d< real64 const > const & dRockInternalEnergy_dTemp, \ + arrayView1d< real64 const > const & rockDensity, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ arrayView1d< real64 > const & localRhs ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index 43b7f4d4bdd..dfc6f557f31 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -74,17 +74,21 @@ struct PhaseVolumeFractionKernel GEOSX_FORCE_INLINE static void Compute( arraySlice1d< real64 const > const & compDens, - arraySlice1d< real64 const > const & dCompDens, - arraySlice2d< real64 const > const & dCompFrac_dCompDens, - arraySlice1d< real64 const > const & phaseDens, - arraySlice1d< real64 const > const & dPhaseDens_dPres, - arraySlice2d< real64 const > const & dPhaseDens_dComp, - arraySlice1d< real64 const > const & phaseFrac, - arraySlice1d< real64 const > const & dPhaseFrac_dPres, - arraySlice2d< real64 const > const & dPhaseFrac_dComp, - arraySlice1d< real64 > const & phaseVolFrac, - arraySlice1d< real64 > const & dPhaseVolFrac_dPres, - arraySlice2d< real64 > const & dPhaseVolFrac_dComp ); + arrayView2d< real64 const > const & compDens, + arrayView2d< real64 const > const & dCompDens, + arrayView3d< real64 const > const & dCompFrac_dCompDens, + arrayView3d< real64 const > const & phaseDens, + arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, + arrayView4d< real64 const > const & dPhaseDens_dComp, + arrayView3d< real64 const > const & phaseFrac, + arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView3d< real64 const > const & dPhaseFrac_dTemp, + arrayView4d< real64 const > const & dPhaseFrac_dComp, + arrayView2d< real64 > const & phaseVolFrac, + arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, + arrayView3d< real64 > const & dPhaseVolFrac_dComp ); template< localIndex NC, localIndex NP > static void @@ -94,12 +98,15 @@ struct PhaseVolumeFractionKernel arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseFrac, arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView3d< real64 const > const & dPhaseFrac_dTemp, arrayView4d< real64 const > const & dPhaseFrac_dComp, arrayView2d< real64 > const & phaseVolFrac, arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, arrayView3d< real64 > const & dPhaseVolFrac_dComp ); template< localIndex NC, localIndex NP > @@ -110,12 +117,15 @@ struct PhaseVolumeFractionKernel arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseFrac, arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView3d< real64 const > const & dPhaseFrac_dTemp, arrayView4d< real64 const > const & dPhaseFrac_dComp, arrayView2d< real64 > const & phaseVolFrac, arrayView2d< real64 > const & dPhaseVolFrac_dPres, + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, arrayView3d< real64 > const & dPhaseVolFrac_dComp ); }; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp index b7ff59b6a57..944f6b7b5f2 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp @@ -27,98 +27,7 @@ namespace geosx namespace IsothermalCompositionalMultiphaseFlowKernels { -/******************************** ComponentFractionKernel ********************************/ -template< localIndex NC > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -ComponentFractionKernel:: - Compute( arraySlice1d< real64 const > const compDens, - arraySlice1d< real64 const > const dCompDens, - arraySlice1d< real64 > const compFrac, - arraySlice2d< real64 > const dCompFrac_dCompDens ) -{ - real64 totalDensity = 0.0; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - real64 const totalDensityInv = 1.0 / totalDensity; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; - } - dCompFrac_dCompDens[ic][ic] += totalDensityInv; - } -} - -template< localIndex NC > -void -ComponentFractionKernel:: - Launch( localIndex const size, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView2d< real64 > const & compFrac, - arrayView3d< real64 > const & dCompFrac_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - Compute< NC >( compDens[a], - dCompDens[a], - compFrac[a], - dCompFrac_dCompDens[a] ); - } ); -} - -template< localIndex NC > -void -ComponentFractionKernel:: - Launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView2d< real64 > const & compFrac, - arrayView3d< real64 > const & dCompFrac_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - Compute< NC >( compDens[a], - dCompDens[a], - compFrac[a], - dCompFrac_dCompDens[a] ); - } ); -} - -#define INST_ComponentFractionKernel( NC ) \ - template \ - void ComponentFractionKernel:: \ - Launch< NC >( localIndex const size, \ - arrayView2d< real64 const > const & compDens, \ - arrayView2d< real64 const > const & dCompDens, \ - arrayView2d< real64 > const & compFrac, \ - arrayView3d< real64 > const & dCompFrac_dCompDens ); \ - template \ - void ComponentFractionKernel:: \ - Launch< NC >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView2d< real64 const > const & compDens, \ - arrayView2d< real64 const > const & dCompDens, \ - arrayView2d< real64 > const & compFrac, \ - arrayView3d< real64 > const & dCompFrac_dCompDens ) - -INST_ComponentFractionKernel( 1 ); -INST_ComponentFractionKernel( 2 ); -INST_ComponentFractionKernel( 3 ); -INST_ComponentFractionKernel( 4 ); -INST_ComponentFractionKernel( 5 ); - -#undef INST_ComponentFractionKernel /******************************** PhaseVolumeFractionKernel ********************************/ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp index 8947efac727..a6f40952216 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp @@ -29,39 +29,6 @@ namespace geosx namespace IsothermalCompositionalMultiphaseFlowKernels { -/******************************** ComponentFractionKernel ********************************/ - -/** - * @brief Functions to compute component fractions from global component densities (mass or molar) - */ -struct ComponentFractionKernel -{ - template< localIndex NC > - GEOSX_HOST_DEVICE - GEOSX_FORCE_INLINE - static void - Compute( arraySlice1d< real64 const > compDens, - arraySlice1d< real64 const > dCompDens, - arraySlice1d< real64 > compFrac, - arraySlice2d< real64 > dCompFrac_dCompDens ); - - template< localIndex NC > - static void - Launch( localIndex const size, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView2d< real64 > const & compFrac, - arrayView3d< real64 > const & dCompFrac_dCompDens ); - - template< localIndex NC > - static void - Launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView2d< real64 > const & compFrac, - arrayView3d< real64 > const & dCompFrac_dCompDens ); -}; - /******************************** PhaseVolumeFractionKernel ********************************/ /** From 48186356f95fa4d1c6fdd7adf4eae9a8e6853f90 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Thu, 17 Dec 2020 18:06:13 -0800 Subject: [PATCH 04/34] Added all views. Modified input for FluxKernels. --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 123 ++++++++++++++++-- .../fluidFlow/CompositionalMultiphaseFlow.hpp | 12 ++ .../CompositionalMultiphaseFlowKernels.cpp | 37 +++++- .../CompositionalMultiphaseFlowKernels.hpp | 22 +++- 4 files changed, 177 insertions(+), 17 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index eda2ccc8e1a..3c12db8d3eb 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -173,6 +173,12 @@ void CompositionalMultiphaseFlow::RegisterDataOnMesh( Group * const MeshBodies ) elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString )-> setRestartFlags( RestartFlags::NO_WRITE ); + + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString )-> + setRestartFlags( RestartFlags::NO_WRITE ); + + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString )-> + setRestartFlags( RestartFlags::NO_WRITE ); } } ); } @@ -319,6 +325,7 @@ void CompositionalMultiphaseFlow::ResizeFields( MeshLevel & meshLevel ) const { subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ).resizeDimension<1>( NP ); subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ).resizeDimension<1>( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ).resizeDimension< 1 >( NP ); }); } } @@ -498,22 +505,33 @@ void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localI dPhaseMob_dComp ); }else { + // get thermal views + arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); + arrayView3d< real64 const > const & dPhaseVisc_dTemp = fluid.dPhaseViscosity_dTemperature(); + + arrayView2d< real64 > const dPhaseMob_dTemp = + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, dataGroup.size(), dCompFrac_dCompDens, phaseDens, dPhaseDens_dPres, + dPhaseDens_dTemp, dPhaseDens_dComp, phaseVisc, dPhaseVisc_dPres, + dPhaseVisc_dTemp, dPhaseVisc_dComp, phaseRelPerm, dPhaseRelPerm_dPhaseVolFrac, dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, dPhaseVolFrac_dComp, phaseMob, dPhaseMob_dPres, + dPhaseMob_dTemp, dPhaseMob_dComp ); } @@ -537,23 +555,23 @@ void CompositionalMultiphaseFlow::UpdateFluidModel( Group & dataGroup, localInde if ( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( dataGroup.size(), - fluidWrapper, - pres, - dPres, - m_uniformTemperature, - compFrac ); + fluidWrapper, + pres, + dPres, + m_uniformTemperature, + compFrac ); } else { arrayView1d< real64 const > const temperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); arrayView1d< real64 const > const dTemperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); CompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( dataGroup.size(), - fluidWrapper, - pres, - dPres, - temperature, - dTemperature, - compFrac ); + fluidWrapper, + pres, + dPres, + temperature, + dTemperature, + compFrac ); } } ); @@ -586,8 +604,8 @@ void CompositionalMultiphaseFlow::UpdateRelPermModel( Group & dataGroup, localIn typename TYPEOFREF( castedRelPerm ) ::KernelWrapper relPermWrapper = castedRelPerm.createKernelWrapper(); CompositionalMultiphaseFlowKernels::RelativePermeabilityUpdateKernel::Launch< parallelDevicePolicy<> >( dataGroup.size(), - relPermWrapper, - phaseVolFrac ); + relPermWrapper, + phaseVolFrac ); } ); } @@ -1076,18 +1094,29 @@ void CompositionalMultiphaseFlow::AssembleFluxTerms( real64 const dt, m_gravCoef.toNestedViewConst(), m_phaseMob.toNestedViewConst(), m_dPhaseMob_dPres.toNestedViewConst(), + m_dPhaseMob_dTemp.toNestedViewConst(), m_dPhaseMob_dCompDens.toNestedViewConst(), + m_phaseVolFrac.toNestedViewConst(), m_dPhaseVolFrac_dPres.toNestedViewConst(), + m_dPhaseVolFrac_dTemp.toNestedViewConst(), m_dPhaseVolFrac_dCompDens.toNestedViewConst(), m_dCompFrac_dCompDens.toNestedViewConst(), m_phaseMassDens.toNestedViewConst(), m_dPhaseMassDens_dPres.toNestedViewConst(), + m_dPhaseMassDens_dTemp.toNestedViewConst(), m_dPhaseMassDens_dComp.toNestedViewConst(), m_phaseCompFrac.toNestedViewConst(), m_dPhaseCompFrac_dPres.toNestedViewConst(), + m_dPhaseCompFrac_dTemp.toNestedViewConst(), m_dPhaseCompFrac_dComp.toNestedViewConst(), m_phaseCapPressure.toNestedViewConst(), m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), + m_temperature.toNestedViewConst(), + m_deltaTemperature.toNestedViewConst(), + m_phaseEnthalpy.toNestedViewConst(), + m_dPhaseEnthalpy_dPres.toNestedViewConst(), + m_dPhaseEnthalpy_dTemp.toNestedViewConst(), + m_dPhaseEnthalpy_dComp.toNestedViewConst(), m_capPressureFlag, dt, localMatrix.toViewConstSizes(), @@ -1742,6 +1771,10 @@ void CompositionalMultiphaseFlow::ResetViews( MeshLevel & mesh ) m_dCompFrac_dCompDens = elemManager.ConstructArrayViewAccessor< real64, 3 >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString ); m_dCompFrac_dCompDens.setName( getName() + "/accessors/" + viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString ); + m_phaseVolFrac.clear(); + m_phaseVolFrac = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::phaseVolumeFractionString ); + m_phaseVolFrac.setName( getName() + "/accessors/" + viewKeyStruct::phaseVolumeFractionString ); + m_dPhaseVolFrac_dPres.clear(); m_dPhaseVolFrac_dPres = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseVolumeFraction_dPressureString ); m_dPhaseVolFrac_dPres.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseVolumeFraction_dPressureString ); @@ -1816,6 +1849,70 @@ void CompositionalMultiphaseFlow::ResetViews( MeshLevel & mesh ) targetRegionNames(), capPresModelNames() ); m_dPhaseCapPressure_dPhaseVolFrac.setName( getName() + "/accessors/" + keys::dPhaseCapPressure_dPhaseVolFractionString ); + } + if (m_isothermalFlag == 0) + { + using keys = MultiFluidBase::viewKeyStruct; + + m_temperature.clear(); + m_temperature = elemManager.ConstructArrayViewAccessor< real64, 1 >( viewKeyStruct::temperatureString ); + m_temperature.setName( getName() + "/accessors/" + viewKeyStruct::temperatureString ); + + m_deltaTemperature.clear(); + m_deltaTemperature = elemManager.ConstructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaTemperatureString ); + m_deltaTemperature.setName( getName() + "/accessors/" + viewKeyStruct::deltaTemperatureString ); + + m_dPhaseVolFrac_dTemp.clear(); + m_dPhaseVolFrac_dTemp = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + m_dPhaseVolFrac_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + + m_dPhaseMob_dTemp.clear(); + m_dPhaseMob_dTemp = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + m_dPhaseMob_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMobility_dTemperatureString ); + + m_dPhaseMassDens_dTemp.clear(); + m_dPhaseMassDens_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseMassDensity_dTemperatureString, + targetRegionNames(), + fluidModelNames() ); + m_dPhaseMassDens_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMassDensity_dTemperatureString ); + + m_dPhaseCompFrac_dTemp.clear(); + m_dPhaseCompFrac_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseCompFraction_dTemperatureString, + targetRegionNames(), + fluidModelNames() ); + m_dPhaseCompFrac_dTemp.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dTemperatureString ); + + m_dPhaseMob_dTemp.clear(); + m_dPhaseMob_dTemp = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + m_dPhaseMob_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMobility_dTemperatureString ); + + + m_phaseEnthalpy.clear(); + m_phaseEnthalpy = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::phaseEnthalpyString, + targetRegionNames(), + fluidModelNames() ); + m_phaseEnthalpy.setName( getName() + "/accessors/" + keys::phaseEnthalpyString ); + + m_dPhaseEnthalpy_dPres.clear(); + m_dPhaseEnthalpy_dPres = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dPressureString, + targetRegionNames(), + fluidModelNames() ); + m_dPhaseEnthalpy_dPres.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dPressureString ); + + m_dPhaseEnthalpy_dTemp.clear(); + m_dPhaseEnthalpy_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dTemperatureString, + targetRegionNames(), + fluidModelNames() ); + m_dPhaseEnthalpy_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseEnthalpy_dTemperatureString ); + + m_dPhaseEnthalpy_dComp.clear(); + m_dPhaseEnthalpy_dComp = elemManager.ConstructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseEnthalpy_dGlobalCompFractionString, + targetRegionNames(), + fluidModelNames() ); + m_dPhaseEnthalpy_dComp.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dGlobalCompFractionString ); + + + } } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp index db3a914b4f2..c3d0d919699 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp @@ -320,6 +320,8 @@ class CompositionalMultiphaseFlow : public FlowSolverBase static constexpr auto phaseDensityOldString = "phaseDensityOld"; static constexpr auto phaseComponentFractionOldString = "phaseComponentFractionOld"; static constexpr auto porosityOldString = "porosityOld"; + static constexpr auto phaseInternalEnergyOldString = "phaseInternalEnergyOld"; + static constexpr auto rockInternalEnergyOldString = "rockInternalEnergyOld"; // these are allocated on faces for BC application until we can get constitutive models on faces static constexpr auto phaseViscosityString = "phaseViscosity"; @@ -464,24 +466,34 @@ class CompositionalMultiphaseFlow : public FlowSolverBase ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dCompFrac_dCompDens; + ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_phaseVolFrac; ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_dPhaseVolFrac_dPres; + ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_dPhaseVolFrac_dTemp; ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dPhaseVolFrac_dCompDens; ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_phaseMob; ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_dPhaseMob_dPres; + ElementRegionManager::ElementViewAccessor< arrayView2d< real64 const > > m_dPhaseMob_dTemp; ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dPhaseMob_dCompDens; ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_phaseMassDens; ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dPhaseMassDens_dPres; + ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dPhaseMassDens_dTemp; ElementRegionManager::ElementViewAccessor< arrayView4d< real64 const > > m_dPhaseMassDens_dComp; ElementRegionManager::ElementViewAccessor< arrayView4d< real64 const > > m_phaseCompFrac; ElementRegionManager::ElementViewAccessor< arrayView4d< real64 const > > m_dPhaseCompFrac_dPres; + ElementRegionManager::ElementViewAccessor< arrayView4d< real64 const > > m_dPhaseCompFrac_dTemp; ElementRegionManager::ElementViewAccessor< arrayView5d< real64 const > > m_dPhaseCompFrac_dComp; ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_phaseCapPressure; ElementRegionManager::ElementViewAccessor< arrayView4d< real64 const > > m_dPhaseCapPressure_dPhaseVolFrac; + ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_phaseEnthalpy; + ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dPhaseEnthalpy_dPres; + ElementRegionManager::ElementViewAccessor< arrayView3d< real64 const > > m_dPhaseEnthalpy_dTemp; + ElementRegionManager::ElementViewAccessor< arrayView4d< real64 const > > m_dPhaseEnthalpy_dComp; + }; /******************************** Kernel launch machinery ********************************/ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index 0e8e57cf7aa..50efeb7b70d 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -901,24 +901,35 @@ FluxKernel:: ElementViewConst< arrayView1d< real64 const > > const & gravCoef, ElementViewConst< arrayView2d< real64 const > > const & phaseMob, ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + ElementViewConst< arrayView1d< real64 const > > const & temp, + ElementViewConst< arrayView1d< real64 const > > const & dTemp, + ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, integer const capPressureFlag, real64 const dt, arraySlice1d< real64 > const localFlux, arraySlice2d< real64 > const localFluxJacobian ) { - localIndex constexpr NDOF = NC + 1; + localIndex constexpr NDOF = NC + 2; localIndex const NP = numPhases; real64 compFlux[NC]{}; @@ -1165,25 +1176,34 @@ FluxKernel:: Launch( localIndex const numPhases, STENCIL_TYPE const & stencil, globalIndex const rankOffset, - ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, - ElementViewConst< arrayView1d< integer const > > const & ghostRank, ElementViewConst< arrayView1d< real64 const > > const & pres, ElementViewConst< arrayView1d< real64 const > > const & dPres, ElementViewConst< arrayView1d< real64 const > > const & gravCoef, ElementViewConst< arrayView2d< real64 const > > const & phaseMob, ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + ElementViewConst< arrayView1d< real64 const > > const & temp, + ElementViewConst< arrayView1d< real64 const > > const & dTemp, + ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, integer const capPressureFlag, real64 const dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, @@ -1217,18 +1237,29 @@ FluxKernel:: gravCoef, phaseMob, dPhaseMob_dPres, + dPhaseMob_dPres, dPhaseMob_dComp, + phaseVolFrac, dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, dPhaseVolFrac_dComp, dCompFrac_dCompDens, phaseMassDens, dPhaseMassDens_dPres, + dPhaseMassDens_dTemp, dPhaseMassDens_dComp, phaseCompFrac, dPhaseCompFrac_dPres, + dPhaseCompFrac_dTemp, dPhaseCompFrac_dComp, phaseCapPressure, dPhaseCapPressure_dPhaseVolFrac, + temp, + dTemp, + phaseEnthalpy, + dPhaseEnthalpy_dPres, + dPhaseEnthalpy_dTemp, + dPhaseEnthalpy_dComp, capPressureFlag, dt, localFlux, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index dc9343c91fa..132c45df486 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -437,18 +437,29 @@ struct FluxKernel ElementViewConst< arrayView1d< real64 const > > const & gravCoef, ElementViewConst< arrayView2d< real64 const > > const & phaseMob, ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + ElementViewConst< arrayView1d< real64 const > > const & temp, + ElementViewConst< arrayView1d< real64 const > > const & dTemp, + ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, integer const capPressureFlag, real64 const dt, arraySlice1d< real64 > const localFlux, @@ -467,17 +478,26 @@ struct FluxKernel ElementViewConst< arrayView2d< real64 const > > const & phaseMob, ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, + ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, + ElementViewConst< arrayView1d< real64 const > > const & temp, + ElementViewConst< arrayView1d< real64 const > > const & dTemp, + ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, + ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, integer const capPressureFlag, real64 const dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, From fe9f9161b946350f42851b26ea7ce15cdcec0633 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Fri, 18 Dec 2020 20:30:29 -0800 Subject: [PATCH 05/34] done kernels and solver. --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 106 +++++++++++++++++- .../CompositionalMultiphaseFlowKernels.cpp | 102 +++++++++++++++-- .../CompositionalMultiphaseFlowKernels.hpp | 2 + 3 files changed, 196 insertions(+), 14 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index 3c12db8d3eb..537b0d21344 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -1176,6 +1176,9 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co localRhs.toView() ); }else { + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, subRegion.size(), @@ -1188,6 +1191,7 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co dPvMult_dPres, phaseVolFrac, dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, dPhaseVolFrac_dCompDens, localMatrix.toViewConstSizes(), localRhs.toView() ); @@ -1429,14 +1433,17 @@ real64 CompositionalMultiphaseFlow::CalculateResidualNorm( DomainPartition const DofManager const & dofManager, arrayView1d< real64 const > const & localRhs ) { - localIndex const NDOF = m_numComponents + 1; - MeshLevel const & mesh = *domain.getMeshBody( 0 )->getMeshLevel( 0 ); - real64 localResidualNorm = 0.0; globalIndex const rankOffset = dofManager.rankOffset(); string const dofKey = dofManager.getKey( viewKeyStruct::dofFieldString ); + if ( m_isothermalFlag ) + { + localIndex const NDOF = m_numComponents + 1; + + real64 localResidualNorm = 0.0; + forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase const & subRegion ) { MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); @@ -1476,6 +1483,57 @@ real64 CompositionalMultiphaseFlow::CalculateResidualNorm( DomainPartition const sprintf( output, " ( Rfluid ) = (%4.2e) ; ", residual ); std::cout<( subRegion, m_fluidModelNames[targetIndex] ); + + arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); + arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); + arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); + arrayView1d< real64 const > const & refPoro = subRegion.getReference< array1d< real64 > >( viewKeyStruct::referencePorosityString ); + arrayView2d< real64 const > const & totalDens = fluid.totalDensity(); + + RAJA::ReduceSum< parallelDeviceReduce, real64 > localFlowSum( 0.0 ); + RAJA::ReduceSum< parallelDeviceReduce, real64 > localEnergySum( 0.0 ); + + forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( elemGhostRank[ei] < 0 ) + { + localIndex const localRow = dofNumber[ei] - rankOffset; + real64 const normalizer = totalDens[ei][0] * refPoro[ei] * volume[ei]; + + for( localIndex idof = 0; idof < numFlowDOF; ++idof ) + { + real64 const val = localRhs[localRow + idof] / normalizer; + localFlowSum += val * val; + } + real64 const val = localRhs[localRow + numFlowDOF]; + localEnergySum += val*val; + } + } ); + localFlowResidualNorm += localFlowSum.get(); + localEnergyResidualNorm += localEnergySum.get(); + } ); + + // compute global residual norm + real64 const flowResidual = std::sqrt( MpiWrapper::Sum( localFlowResidualNorm ) ); + real64 const energyResidual = std::sqrt( MpiWrapper::Sum( localEnergyResidualNorm ) ); + + if( getLogLevel() >= 1 && logger::internal::rank==0 ) + { + char output[200] = {0}; + sprintf( output, " ( Rflow ) = (%4.2e) - ( Renergy ) = (%4.2e) ; ", flowResidual, energyResidual ); + std::cout< fieldNames; fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaPressureString ) ); fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaGlobalCompDensityString ) ); + + if (m_isothermalFlag == 0) + { + fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaTemperatureString ) ); + } + CommunicationTools::SynchronizeFields( fieldNames, &mesh, domain.getNeighbors(), true ); forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) @@ -1709,6 +1773,8 @@ void CompositionalMultiphaseFlow::ResetStateToBeginningOfStep( DomainPartition & { MeshLevel & mesh = *domain.getMeshBody( 0 )->getMeshLevel( 0 ); + if ( m_isothermalFlag ) + { forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { arrayView1d< real64 > const & dPres = @@ -1721,6 +1787,24 @@ void CompositionalMultiphaseFlow::ResetStateToBeginningOfStep( DomainPartition & UpdateState( subRegion, targetIndex ); } ); + }else + { + forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) + { + arrayView1d< real64 > const & dPres = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString ); + arrayView2d< real64 > const & dCompDens = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); + arrayView1d< real64 > const & dTemp = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + + dPres.setValues< parallelDevicePolicy<> >( 0.0 ); + dCompDens.setValues< parallelDevicePolicy<> >( 0.0 ); + dTemp.setValues< parallelDevicePolicy<> >(0.0); + + UpdateState( subRegion, targetIndex ); + } ); + } } void CompositionalMultiphaseFlow::ImplicitStepComplete( real64 const & GEOSX_UNUSED_PARAM( time ), @@ -1752,6 +1836,22 @@ void CompositionalMultiphaseFlow::ImplicitStepComplete( real64 const & GEOSX_UNU } } ); } ); + + if (m_isothermalFlag == 0) + { + forTargetSubRegions( mesh, [&]( localIndex const, ElementSubRegionBase & subRegion ) + { + arrayView1d< real64 const > const dTemp = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + arrayView1d< real64 > const temp = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); + + forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + temp[ei] += dTemp[ei]; + } ); + } ); + } } void CompositionalMultiphaseFlow::ResetViews( MeshLevel & mesh ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index 50efeb7b70d..74e91743ce6 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -934,7 +934,12 @@ FluxKernel:: real64 compFlux[NC]{}; real64 dCompFlux_dP[MAX_STENCIL][NC]{}; + real64 dCompFlux_dT[MAX_STENCIL][NC]{}; real64 dCompFlux_dC[MAX_STENCIL][NC][NC]{}; + real64 enthalpyFlux = 0.0; + real64 dEnthalpyFlux_dP[MAX_STENCIL]{}; + real64 dEnthalpyFlux_dT[MAX_STENCIL]{}; + real64 dEnthalpyFlux_dC[MAX_STENCIL][NC]{}; // loop over phases, compute and upwind phase flux and sum contributions to each component's flux for( localIndex ip = 0; ip < NP; ++ip ) @@ -942,19 +947,23 @@ FluxKernel:: // clear working arrays real64 densMean{}; real64 dDensMean_dP[NUM_ELEMS]{}; + real64 dDensMean_dT[NUM_ELEMS]{}; real64 dDensMean_dC[NUM_ELEMS][NC]{}; // create local work arrays real64 phaseFlux{}; real64 dPhaseFlux_dP[MAX_STENCIL]{}; + real64 dPhaseFlux_dT[MAX_STENCIL]{}; real64 dPhaseFlux_dC[MAX_STENCIL][NC]{}; real64 presGrad{}; real64 dPresGrad_dP[MAX_STENCIL]{}; + real64 dPresGrad_dT[MAX_STENCIL]{}; real64 dPresGrad_dC[MAX_STENCIL][NC]{}; real64 gravHead{}; real64 dGravHead_dP[NUM_ELEMS]{}; + real64 dGravHead_dT[NUM_ELEMS]{}; real64 dGravHead_dC[NUM_ELEMS][NC]{}; real64 dCapPressure_dC[NC]{}; @@ -972,6 +981,7 @@ FluxKernel:: // density real64 const density = phaseMassDens[er][esr][ei][0][ip]; real64 const dDens_dP = dPhaseMassDens_dPres[er][esr][ei][0][ip]; + real64 const dDens_dT = dPhaseMassDens_dT[er][esr][ei][0][ip]; applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], @@ -981,6 +991,7 @@ FluxKernel:: // average density and derivatives densMean += 0.5 * density; dDensMean_dP[i] = 0.5 * dDens_dP; + dDensMean_dT[i] = 0.5 * dDens_dT; for( localIndex jc = 0; jc < NC; ++jc ) { dDensMean_dC[i][jc] = 0.5 * dProp_dC[jc]; @@ -1000,6 +1011,7 @@ FluxKernel:: // capillary pressure real64 capPressure = 0.0; real64 dCapPressure_dP = 0.0; + real64 dCapPressure_dT = 0.0; for( localIndex ic = 0; ic < NC; ++ic ) { @@ -1014,6 +1026,7 @@ FluxKernel:: { real64 const dCapPressure_dS = dPhaseCapPressure_dPhaseVolFrac[er][esr][ei][0][ip][jp]; dCapPressure_dP += dCapPressure_dS * dPhaseVolFrac_dPres[er][esr][ei][jp]; + dCapPressure_dT += dCapPressure_dS * dPhaseVolFrac_dTemp[er][esr][ei][jp]; for( localIndex jc = 0; jc < NC; ++jc ) { @@ -1024,6 +1037,7 @@ FluxKernel:: presGrad += weight * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); dPresGrad_dP[i] += weight * (1 - dCapPressure_dP); + dPresGrad_dT[i] += weight * (1 - dCapPressure_dT); for( localIndex jc = 0; jc < NC; ++jc ) { dPresGrad_dC[i][jc] += -weight * dCapPressure_dC[jc]; @@ -1040,6 +1054,7 @@ FluxKernel:: for( localIndex j = 0; j < NUM_ELEMS; ++j ) { dGravHead_dP[j] += dDensMean_dP[j] * gravD; + dGravHead_dT[j] += dDensMean_dT[j] * gravD; for( localIndex jc = 0; jc < NC; ++jc ) { dGravHead_dC[j][jc] += dDensMean_dC[j][jc] * gravD; @@ -1074,6 +1089,7 @@ FluxKernel:: for( localIndex ke = 0; ke < stencilSize; ++ke ) { dPhaseFlux_dP[ke] += dPresGrad_dP[ke]; + dPhaseFlux_dT[ke] += dPresGrad_dT[ke]; for( localIndex jc = 0; jc < NC; ++jc ) { dPhaseFlux_dC[ke][jc] += dPresGrad_dC[ke][jc]; @@ -1085,6 +1101,7 @@ FluxKernel:: for( localIndex ke = 0; ke < NUM_ELEMS; ++ke ) { dPhaseFlux_dP[ke] -= dGravHead_dP[ke]; + dPhaseFlux_dT[ke] -= dGravHead_dT[ke]; for( localIndex jc = 0; jc < NC; ++jc ) { dPhaseFlux_dC[ke][jc] -= dGravHead_dC[ke][jc]; @@ -1107,6 +1124,7 @@ FluxKernel:: // add contribution from upstream cell mobility derivatives dPhaseFlux_dP[k_up] += dMob_dP * potGrad; + dPhaseFlux_dT[k_up] += dMob_dT * potGrad; for( localIndex jc = 0; jc < NC; ++jc ) { dPhaseFlux_dC[k_up][jc] += dPhaseMob_dCompSub[jc] * potGrad; @@ -1115,6 +1133,7 @@ FluxKernel:: // slice some constitutive arrays to avoid too much indexing in component loop arraySlice1d< real64 const > phaseCompFracSub = phaseCompFrac[er_up][esr_up][ei_up][0][ip]; arraySlice1d< real64 const > dPhaseCompFrac_dPresSub = dPhaseCompFrac_dPres[er_up][esr_up][ei_up][0][ip]; + arraySlice1d< real64 const > dPhaseCompFrac_dTempSub = dPhaseCompFrac_dTemp[er_up][esr_up][ei_up][0][ip]; arraySlice2d< real64 const > dPhaseCompFrac_dCompSub = dPhaseCompFrac_dComp[er_up][esr_up][ei_up][0][ip]; // compute component fluxes and derivatives using upstream cell composition @@ -1127,6 +1146,7 @@ FluxKernel:: for( localIndex ke = 0; ke < stencilSize; ++ke ) { dCompFlux_dP[ke][ic] += dPhaseFlux_dP[ke] * ycp; + dCompFlux_dT[ke][ic] += dPhaseFlux_dT[ke] * ycp; for( localIndex jc = 0; jc < NC; ++jc ) { dCompFlux_dC[ke][ic][jc] += dPhaseFlux_dC[ke][jc] * ycp; @@ -1135,6 +1155,7 @@ FluxKernel:: // additional derivatives stemming from upstream cell phase composition dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFrac_dPresSub[ic]; + dCompFlux_dT[k_up][ic] += phaseFlux * dPhaseCompFrac_dTempSub[ic]; // convert derivatives of component fraction w.r.t. component fractions to derivatives w.r.t. component // densities @@ -1144,6 +1165,22 @@ FluxKernel:: dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; } } + // compute enthalpy fluxes and derivatives + enthalpyFlux += phaseFlux * phaseEnthalpy[ip]; + + // derivatives stemming from phase flux + for( localIndex ke = 0; ke < stencilSize; ++ke ) + { + dEnthalpyFlux_dP[ke] += dPhaseFlux_dP[ke] * phaseEnthalpy[ip] + phaseFlux[ke] * dPhaseEnthalpy_dPres[ip]; + dEnthalpyFlux_dT[ke] += dPhaseFlux_dT[ke] * phaseEnthalpy[ip] + phaseFlux[ke] * dPhaseEnthalpy_dTemp[ip]; + + applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseEnthalpy_dComp[er_up][esr_up][ei_up][0][ip], dProp_dC ); + for( localIndex jc = 0; jc < NC; ++jc ) + { + dEnthalpyFlux_dC[ke][jc] += dPhaseFlux_dC[ke][jc] * phaseEnthalpy[ip] + phaseFlux[ke] * dProp_dC[jc]; + } + } + } // *** end of upwinding @@ -1151,23 +1188,50 @@ FluxKernel:: // populate local flux vector and derivatives for( localIndex ic = 0; ic < NC; ++ic ) { - localFlux[ic] = dt * compFlux[ic]; - localFlux[NC + ic] = -dt * compFlux[ic]; + // mass/mole flux + localFlux[ic] = dt * compFlux[ic]; + localFlux[NC + 1 + ic] = -dt * compFlux[ic]; for( localIndex ke = 0; ke < stencilSize; ++ke ) { + // mass flux derivativex localIndex const localDofIndexPres = ke * NDOF; localFluxJacobian[ic][localDofIndexPres] = dt * dCompFlux_dP[ke][ic]; - localFluxJacobian[NC + ic][localDofIndexPres] = -dt * dCompFlux_dP[ke][ic]; + localFluxJacobian[NC + 1 + ic][localDofIndexPres] = -dt * dCompFlux_dP[ke][ic]; + localIndex const localDofIndexTemp = localDofIndexPres + NC; + localFluxJacobian[ic][localDofIndexTemp] = dt * dCompFlux_dT[ke][ic]; + localFluxJacobian[NC + 1 + ic][localDofIndexTemp] = -dt * dCompFlux_dT[ke][ic]; for( localIndex jc = 0; jc < NC; ++jc ) { localIndex const localDofIndexComp = localDofIndexPres + jc + 1; localFluxJacobian[ic][localDofIndexComp] = dt * dCompFlux_dC[ke][ic][jc]; - localFluxJacobian[NC + ic][localDofIndexComp] = -dt * dCompFlux_dC[ke][ic][jc]; + localFluxJacobian[NC + 1 + ic][localDofIndexComp] = -dt * dCompFlux_dC[ke][ic][jc]; } } } + + // enthalpy flux + localFlux[NC] = dt * enthalpyFlux; + localFlux[2 * NC - 1] = -dt * enthalpyFlux; + + for( localIndex ke = 0; ke < stencilSize; ++ke ) + { + localIndex const localDofIndexPres = ke * NDOF; + localFluxJacobian[NC][localDofIndexPres] = dt * dEnthalpyFlux_dP[ke][ic]; + localFluxJacobian[2*NC - 1][localDofIndexPres] = -dt * dEnthalpyFlux_dP[ke][ic]; + localIndex const localDofIndexTemp = localDofIndexPres + NC; + localFluxJacobian[NC][localDofIndexTemp] = dt * dCompFlux_dT[ke][ic]; + localFluxJacobian[2*NC - 1][localDofIndexTemp] = -dt * dEnthalpyFlux_dT[ke][ic]; + + for( localIndex jc = 0; jc < NC; ++jc ) + { + localIndex const localDofIndexComp = localDofIndexPres + jc + 1; + localFluxJacobian[NC][localDofIndexComp] = dt * dEnthalpyFlux_dC[ke][jc]; + localFluxJacobian[2*NC - 1][localDofIndexComp] = -dt * dEnthalpyFlux_dC[ke][jc]; + } + } + } template< localIndex NC, typename STENCIL_TYPE > @@ -1221,10 +1285,10 @@ FluxKernel:: { // TODO: hack! for MPFA, etc. must obtain proper size from e.g. seri localIndex const stencilSize = MAX_STENCIL; - localIndex constexpr NDOF = NC + 1; + localIndex constexpr NDOF = NC + 2; - stackArray1d< real64, NUM_ELEMS * NC > localFlux( NUM_ELEMS * NC ); - stackArray2d< real64, NUM_ELEMS * NC * MAX_STENCIL * NDOF > localFluxJacobian( NUM_ELEMS * NC, stencilSize * NDOF ); + stackArray1d< real64, NUM_ELEMS * NC > localFlux( NUM_ELEMS * ( NC + 1 ) ); + stackArray2d< real64, NUM_ELEMS * NC * MAX_STENCIL * NDOF > localFluxJacobian( NUM_ELEMS * ( NC + 1 ), stencilSize * NDOF ); FluxKernel::Compute< NC, NUM_ELEMS, MAX_STENCIL >( numPhases, stencilSize, @@ -1315,18 +1379,29 @@ FluxKernel:: ElementViewConst< arrayView1d< real64 const > > const & gravCoef, \ ElementViewConst< arrayView2d< real64 const > > const & phaseMob, \ ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, \ + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, \ ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, \ + ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, \ ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, \ + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, \ ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, \ ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, \ ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, \ ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, \ ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, \ ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, \ ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, \ ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, \ ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, \ + ElementViewConst< arrayView1d< real64 const > > const & temp, \ + ElementViewConst< arrayView1d< real64 const > > const & dTemp, \ + ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, \ integer const capPressureFlag, \ real64 const dt, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ @@ -1359,11 +1434,12 @@ VolumeBalanceKernel:: real64 const & dPvMult_dPres, arraySlice1d< real64 const > const & phaseVolFrac, arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, real64 & localVolBalance, - real64 * const localVolBalanceJacobian ) + real64 (& localVolBalanceJacobian)[NC+2] ) { - localIndex constexpr NDOF = NC + 1; + localIndex constexpr NDOF = NC + 2; real64 const poro = porosityRef * pvMult; real64 const dPoro_dP = porosityRef * dPvMult_dPres; @@ -1382,6 +1458,7 @@ VolumeBalanceKernel:: { localVolBalance -= phaseVolFrac[ip]; localVolBalanceJacobian[0] -= dPhaseVolFrac_dPres[ip]; + localVolBalanceJacobian[NC+1] -= dPhaseVolFrac_dTemp[ip]; for( localIndex jc = 0; jc < NC; ++jc ) { @@ -1411,6 +1488,7 @@ VolumeBalanceKernel:: arrayView2d< real64 const > const & dPvMult_dPres, arrayView2d< real64 const > const & phaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -1420,7 +1498,7 @@ VolumeBalanceKernel:: if( elemGhostRank[ei] >= 0 ) return; - localIndex constexpr NDOF = NC + 1; + localIndex constexpr NDOF = NC + 2; real64 localVolBalance; real64 localVolBalanceJacobian[NDOF]; @@ -1431,12 +1509,13 @@ VolumeBalanceKernel:: dPvMult_dPres[ei][0], phaseVolFrac[ei], dPhaseVolFrac_dPres[ei], + dPhaseVolFrac_dTemp[ei], dPhaseVolFrac_dCompDens[ei], localVolBalance, localVolBalanceJacobian ); // get equation/dof indices - localIndex const localRow = dofNumber[ei] + NC - rankOffset; + localIndex const localRow = dofNumber[ei] + NC + 1 - rankOffset; globalIndex dofIndices[NDOF]; for( localIndex jdof = 0; jdof < NDOF; ++jdof ) { @@ -1467,6 +1546,7 @@ VolumeBalanceKernel:: arrayView2d< real64 const > const & dPvMult_dPres, \ arrayView2d< real64 const > const & phaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ arrayView1d< real64 > const & localRhs ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index 132c45df486..ccd462ccf34 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -521,6 +521,7 @@ struct VolumeBalanceKernel real64 const & dPvMult_dPres, arraySlice1d< real64 const > const & phaseVolFrac, arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, real64 & localVolBalance, real64 * const localVolBalanceJacobian ); @@ -537,6 +538,7 @@ struct VolumeBalanceKernel arrayView2d< real64 const > const & dPvMult_dPres, arrayView2d< real64 const > const & phaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + rrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ); From e68e82a97f425667144d78b9021bed0955b1a89f Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Fri, 18 Dec 2020 21:22:59 -0800 Subject: [PATCH 06/34] FluidModels: added enthalpy and internalEnergy --- .../constitutive/fluid/MultiFluidBase.hpp | 118 +++++++++++++----- .../fluid/MultiFluidPVTPackageWrapper.hpp | 30 ++++- .../fluid/MultiPhaseMultiComponentFluid.hpp | 30 ++++- 3 files changed, 141 insertions(+), 37 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 7319255e63c..129d21ad7c9 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -86,7 +86,15 @@ class MultiFluidBaseUpdate arrayView2d< real64 > const & totalDensity, arrayView2d< real64 > const & dTotalDensity_dPressure, arrayView2d< real64 > const & dTotalDensity_dTemperature, - arrayView3d< real64 > const & dTotalDensity_dGlobalCompFraction ) + arrayView3d< real64 > const & dTotalDensity_dGlobalCompFraction, + arrayView3d< real64 > const & phaseEnthalpy, + arrayView3d< real64 > const & dPhaseEnthalpy_dPressure, + arrayView3d< real64 > const & dPhaseEnthalpy_dTemperature, + arrayView4d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, + arrayView3d< real64 > const & phaseInternalEnergy, + arrayView3d< real64 > const & dPhaseInternalEnergy_dPressure, + arrayView3d< real64 > const & dPhaseInternalEnergy_dTemperature, + arrayView4d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) : m_componentMolarWeight( componentMolarWeight ), m_useMass( useMass ), m_phaseFraction( phaseFraction ), @@ -112,7 +120,15 @@ class MultiFluidBaseUpdate m_totalDensity( totalDensity ), m_dTotalDensity_dPressure( dTotalDensity_dPressure ), m_dTotalDensity_dTemperature( dTotalDensity_dTemperature ), - m_dTotalDensity_dGlobalCompFraction( dTotalDensity_dGlobalCompFraction ) + m_dTotalDensity_dGlobalCompFraction( dTotalDensity_dGlobalCompFraction ), + m_phaseEnthalpy( phaseEnthalpy ), + m_dPhaseEnthalpy_dPressure(dPhaseEnthalpy_dPressure), + m_dPhaseEnthalpy_dTemperature( dPhaseEnthalpy_dTemperature ), + m_dPhaseEnthalpy_dGlobalCompFraction( dPhaseEnthalpy_dGlobalCompFraction ), + m_phaseInternalEnergy( phaseInternalEnergy ), + m_dPhaseInternalEnergy_dPressure( dPhaseInternalEnergy_dPressure ), + m_dPhaseInternalEnergy_dTemperature( dPhaseInternalEnergy_dTemperature ), + m_dPhaseInternalEnergy_dGlobalCompFraction( dPhaseInternalEnergy_dGlobalCompFraction ) {} /// Default copy constructor @@ -161,6 +177,16 @@ class MultiFluidBaseUpdate arrayView2d< real64 > m_dTotalDensity_dTemperature; arrayView3d< real64 > m_dTotalDensity_dGlobalCompFraction; + arrayView3d< real64 > m_phaseEnthalpy; + arrayView3d< real64 > m_dPhaseEnthalpy_dPressure; + arrayView3d< real64 > m_dPhaseEnthalpy_dTemperature; + arrayView4d< real64 > m_dPhaseEnthalpy_dGlobalCompFraction; + + arrayView3d< real64 > m_phaseInternalEnergy; + arrayView3d< real64 > m_dPhaseInternalEnergy_dPressure; + arrayView3d< real64 > m_dPhaseInternalEnergy_dTemperature; + arrayView4d< real64 > m_dPhaseInternalEnergy_dGlobalCompFraction; + private: virtual void Compute( real64 const pressure, @@ -303,6 +329,16 @@ class MultiFluidBase : public ConstitutiveBase arrayView2d< real64 const > dTotalDensity_dTemperature() const { return m_dTotalDensity_dTemperature; } arrayView3d< real64 const > dTotalDensity_dGlobalCompFraction() const { return m_dTotalDensity_dGlobalCompFraction; } + arrayView2d< real64 const > phaseEnthalpy() const { return m_phaseEnthalpy; } + arrayView2d< real64 const > dPhaseEnthalpy_dPressure() const { return m_dPhaseEnthalpy_dPressure; } + arrayView2d< real64 const > dPhaseEnthalpy_dTemperature() const { return m_dPhaseEnthalpy_dTemperature; } + arrayView3d< real64 const > dPhaseEnthalpy_dGlobalCompFraction() const { return m_dPhaseEnthalpy_dGlobalCompFraction; } + + arrayView2d< real64 const > phaseInternalEnergy() const { return m_phaseInternalEnergy; } + arrayView2d< real64 const > dPhaseInternalEnergy_dPressure() const { return m_dPhaseInternalEnergy_dPressure; } + arrayView2d< real64 const > dPhaseInternalEnergy_dTemperature() const { return m_dPhaseInternalEnergy_dTemperature; } + arrayView3d< real64 const > dPhaseInternalEnergy_dGlobalCompFraction() const { return m_dPhaseInternalEnergy_dGlobalCompFraction; } + struct viewKeyStruct : ConstitutiveBase::viewKeyStruct { static constexpr auto componentNamesString = "componentNames"; @@ -310,35 +346,45 @@ class MultiFluidBase : public ConstitutiveBase static constexpr auto phaseNamesString = "phaseNames"; - static constexpr auto phaseFractionString = "phaseFraction"; // xi_p - static constexpr auto dPhaseFraction_dPressureString = "dPhaseFraction_dPressure"; // dXi_p/dP - static constexpr auto dPhaseFraction_dTemperatureString = "dPhaseFraction_dTemperature"; // dXi_p/dT - static constexpr auto dPhaseFraction_dGlobalCompFractionString = "dPhaseFraction_dGlobalCompFraction"; // dXi_p/dz - - static constexpr auto phaseDensityString = "phaseDensity"; // rho_p - static constexpr auto dPhaseDensity_dPressureString = "dPhaseDensity_dPressure"; // dRho_p/dP - static constexpr auto dPhaseDensity_dTemperatureString = "dPhaseDensity_dTemperature"; // dRho_p/dT - static constexpr auto dPhaseDensity_dGlobalCompFractionString = "dPhaseDensity_dGlobalCompFraction"; // dRho_p/dz - - static constexpr auto phaseMassDensityString = "phaseMassDensity"; // rho_p - static constexpr auto dPhaseMassDensity_dPressureString = "dPhaseMassDensity_dPressure"; // dRho_p/dP - static constexpr auto dPhaseMassDensity_dTemperatureString = "dPhaseMassDensity_dTemperature"; // dRho_p/dT - static constexpr auto dPhaseMassDensity_dGlobalCompFractionString = "dPhaseMassDensity_dGlobalCompFraction"; // dRho_p/dz - - static constexpr auto phaseViscosityString = "phaseViscosity"; // mu_p - static constexpr auto dPhaseViscosity_dPressureString = "dPhaseViscosity_dPressure"; // dMu_p/dP - static constexpr auto dPhaseViscosity_dTemperatureString = "dPhaseViscosity_dTemperature"; // dMu_p/dT - static constexpr auto dPhaseViscosity_dGlobalCompFractionString = "dPhaseViscosity_dGlobalCompFraction"; // dMu_p/dz - - static constexpr auto phaseCompFractionString = "phaseCompFraction"; // x_cp - static constexpr auto dPhaseCompFraction_dPressureString = "dPhaseCompFraction_dPressure"; // dx_cp/dP - static constexpr auto dPhaseCompFraction_dTemperatureString = "dPhaseCompFraction_dTemperature"; // dx_cp/dT - static constexpr auto dPhaseCompFraction_dGlobalCompFractionString = "dPhaseCompFraction_dGlobalCompFraction"; // dx_cp/dz - - static constexpr auto totalDensityString = "totalDensity"; // rho_t - static constexpr auto dTotalDensity_dPressureString = "dTotalDensity_dPressure"; // dRho_t/dP - static constexpr auto dTotalDensity_dTemperatureString = "dTotalDensity_dTemperature"; // dRho_t/dT - static constexpr auto dTotalDensity_dGlobalCompFractionString = "dTotalDensity_dGlobalCompFraction"; // dRho_t/dz + static constexpr auto phaseFractionString = "phaseFraction"; // xi_p + static constexpr auto dPhaseFraction_dPressureString = "dPhaseFraction_dPressure"; // dXi_p/dP + static constexpr auto dPhaseFraction_dTemperatureString = "dPhaseFraction_dTemperature"; // dXi_p/dT + static constexpr auto dPhaseFraction_dGlobalCompFractionString = "dPhaseFraction_dGlobalCompFraction"; // dXi_p/dz + + static constexpr auto phaseDensityString = "phaseDensity"; // rho_p + static constexpr auto dPhaseDensity_dPressureString = "dPhaseDensity_dPressure"; // dRho_p/dP + static constexpr auto dPhaseDensity_dTemperatureString = "dPhaseDensity_dTemperature"; // dRho_p/dT + static constexpr auto dPhaseDensity_dGlobalCompFractionString = "dPhaseDensity_dGlobalCompFraction"; // dRho_p/dz + + static constexpr auto phaseMassDensityString = "phaseMassDensity"; // rho_p + static constexpr auto dPhaseMassDensity_dPressureString = "dPhaseMassDensity_dPressure"; // dRho_p/dP + static constexpr auto dPhaseMassDensity_dTemperatureString = "dPhaseMassDensity_dTemperature"; // dRho_p/dT + static constexpr auto dPhaseMassDensity_dGlobalCompFractionString = "dPhaseMassDensity_dGlobalCompFraction"; // dRho_p/dz + + static constexpr auto phaseViscosityString = "phaseViscosity"; // mu_p + static constexpr auto dPhaseViscosity_dPressureString = "dPhaseViscosity_dPressure"; // dMu_p/dP + static constexpr auto dPhaseViscosity_dTemperatureString = "dPhaseViscosity_dTemperature"; // dMu_p/dT + static constexpr auto dPhaseViscosity_dGlobalCompFractionString = "dPhaseViscosity_dGlobalCompFraction"; // dMu_p/dz + + static constexpr auto phaseCompFractionString = "phaseCompFraction"; // x_cp + static constexpr auto dPhaseCompFraction_dPressureString = "dPhaseCompFraction_dPressure"; // dx_cp/dP + static constexpr auto dPhaseCompFraction_dTemperatureString = "dPhaseCompFraction_dTemperature"; // dx_cp/dT + static constexpr auto dPhaseCompFraction_dGlobalCompFractionString = "dPhaseCompFraction_dGlobalCompFraction"; // dx_cp/dz + + static constexpr auto totalDensityString = "totalDensity"; // rho_t + static constexpr auto dTotalDensity_dPressureString = "dTotalDensity_dPressure"; // dRho_t/dP + static constexpr auto dTotalDensity_dTemperatureString = "dTotalDensity_dTemperature"; // dRho_t/dT + static constexpr auto dTotalDensity_dGlobalCompFractionString = "dTotalDensity_dGlobalCompFraction"; // dRho_t/dz + + static constexpr auto phaseEnthalpyString = "phaseEnthalpy"; // h_p + static constexpr auto dPhaseEnthalpy_dPressureString = "dPhaseEnthalpy_dPressure"; // dH_p/dP + static constexpr auto dPhaseEnthalpy_dTemperatureString = "dPhaseEnthalpy_dTemperature"; // dH_p/dT + static constexpr auto dPhaseEnthalpy_dGlobalCompFractionString = "dPhaseEnthalpy_dGlobalCompFraction"; // dH_p/dz + + static constexpr auto phaseInternalEnergyString = "phaseInternalEnergy"; // u_p + static constexpr auto dPhaseInternalEnergy_dPressureString = "dPhaseInternalEnergy_dPressure"; // dU_p/dP + static constexpr auto dPhaseInternalEnergy_dTemperatureString = "dPhaseInternalEnergy_dTemperature"; // dU_p/dT + static constexpr auto dPhaseInternalEnergy_dGlobalCompFractionString = "dPhaseInternalEnergy_dGlobalCompFraction"; // dU_p/dz static constexpr auto useMassString = "useMass"; } viewKeysMultiFluidBase; @@ -395,6 +441,16 @@ class MultiFluidBase : public ConstitutiveBase array2d< real64 > m_dTotalDensity_dTemperature; array3d< real64 > m_dTotalDensity_dGlobalCompFraction; + array3d< real64 > m_phaseEnthalpy; + array3d< real64 > m_dPhaseEnthalpy_dPressure; + array3d< real64 > m_dPhaseEnthalpy_dTemperature; + array4d< real64 > m_dPhaseEnthalpy_dGlobalCompFraction; + + array3d< real64 > m_phaseInternalEnergy; + array3d< real64 > m_dPhaseInternalEnergy_dPressure; + array3d< real64 > m_dPhaseInternalEnergy_dTemperature; + array4d< real64 > m_dPhaseInternalEnergy_dGlobalCompFraction; + }; } //namespace constitutive diff --git a/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp b/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp index a23fdbbd2db..b32dee8982b 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp @@ -74,7 +74,15 @@ class MultiFluidPVTPackageWrapperUpdate final : public MultiFluidBaseUpdate arrayView2d< real64 > const & totalDensity, arrayView2d< real64 > const & dTotalDensity_dPressure, arrayView2d< real64 > const & dTotalDensity_dTemperature, - arrayView3d< real64 > const & dTotalDensity_dGlobalCompFraction ) + arrayView3d< real64 > const & dTotalDensity_dGlobalCompFraction, + arrayView3d< real64 > const & phaseEnthalpy, + arrayView3d< real64 > const & dPhaseEnthalpy_dPressure, + arrayView3d< real64 > const & dPhaseEnthalpy_dTemperature, + arrayView4d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, + arrayView3d< real64 > const & phaseInternalEnergy, + arrayView3d< real64 > const & dPhaseInternalEnergy_dPressure, + arrayView3d< real64 > const & dPhaseInternalEnergy_dTemperature, + arrayView4d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) : MultiFluidBaseUpdate( componentMolarWeight, useMass, phaseFraction, @@ -100,7 +108,15 @@ class MultiFluidPVTPackageWrapperUpdate final : public MultiFluidBaseUpdate totalDensity, dTotalDensity_dPressure, dTotalDensity_dTemperature, - dTotalDensity_dGlobalCompFraction ), + dTotalDensity_dGlobalCompFraction, + phaseEnthalpy, + dPhaseEnthalpy_dPressure, + dPhaseEnthalpy_dTemperature, + dPhaseEnthalpy_dGlobalCompFraction, + phaseInternalEnergy, + dPhaseInternalEnergy_dPressure, + dPhaseInternalEnergy_dTemperature, + dPhaseInternalEnergy_dGlobalCompFraction ), m_fluid( fluid ), m_phaseTypes( phaseTypes ) {} @@ -247,7 +263,15 @@ class MultiFluidPVTPackageWrapper : public MultiFluidBase m_totalDensity, m_dTotalDensity_dPressure, m_dTotalDensity_dTemperature, - m_dTotalDensity_dGlobalCompFraction ); + m_dTotalDensity_dGlobalCompFraction, + m_phaseEnthalpy, + m_dPhaseEnthalpy_dPressure, + m_dPhaseEnthalpy_dTemperature, + m_dPhaseEnthalpy_dGlobalCompFraction, + m_phaseInternalEnergy, + m_dPhaseInternalEnergy_dPressure, + m_dPhaseInternalEnergy_dTemperature, + m_dPhaseInternalEnergy_dGlobalCompFraction ); } protected: diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index 78c1ce230e3..e64b4e62f6e 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -80,7 +80,15 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate arrayView2d< real64 > const & totalDensity, arrayView2d< real64 > const & dTotalDensity_dPressure, arrayView2d< real64 > const & dTotalDensity_dTemperature, - arrayView3d< real64 > const & dTotalDensity_dGlobalCompFraction ) + arrayView3d< real64 > const & dTotalDensity_dGlobalCompFraction, + arrayView3d< real64 > const & phaseEnthalpy, + arrayView3d< real64 > const & dPhaseEnthalpy_dPressure, + arrayView3d< real64 > const & dPhaseEnthalpy_dTemperature, + arrayView4d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, + arrayView3d< real64 > const & phaseInternalEnergy, + arrayView3d< real64 > const & dPhaseInternalEnergy_dPressure, + arrayView3d< real64 > const & dPhaseInternalEnergy_dTemperature, + arrayView4d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction) : MultiFluidBaseUpdate( componentMolarWeight, useMass, phaseFraction, @@ -106,7 +114,15 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate totalDensity, dTotalDensity_dPressure, dTotalDensity_dTemperature, - dTotalDensity_dGlobalCompFraction ), + dTotalDensity_dGlobalCompFraction, + phaseEnthalpy, + dPhaseEnthalpy_dPressure, + dPhaseEnthalpy_dTemperature, + dPhaseEnthalpy_dGlobalCompFraction, + phaseInternalEnergy, + dPhaseInternalEnergy_dPressure, + dPhaseInternalEnergy_dTemperature, + dPhaseInternalEnergy_dGlobalCompFraction ), m_phaseDensityFuns( phaseDensityFuns ), m_phaseViscosityFuns( phaseViscosityFuns ), m_flashModel( flashModel ) @@ -260,7 +276,15 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase m_totalDensity, m_dTotalDensity_dPressure, m_dTotalDensity_dTemperature, - m_dTotalDensity_dGlobalCompFraction ); + m_dTotalDensity_dGlobalCompFraction, + m_phaseEnthalpy, + m_dPhaseEnthalpy_dPressure, + m_dPhaseEnthalpy_dTemperature, + m_dPhaseEnthalpy_dGlobalCompFraction, + m_phaseInternalEnergy, + m_dPhaseInternalEnergy_dPressure, + m_dPhaseInternalEnergy_dTemperature, + m_dPhaseInternalEnergy_dGlobalCompFraction ); } struct viewKeyStruct : MultiFluidBase::viewKeyStruct From b26299ec4667cb4f91f9c2c1afb46401aca0e5bb Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Mon, 21 Dec 2020 14:26:49 -0800 Subject: [PATCH 07/34] Enthalpy and Internal energy functions --- .../constitutive/CMakeLists.txt | 10 ++- .../fluid/MultiPhaseMultiComponentFluid.cpp | 51 ++++++++++++++- .../fluid/MultiPhaseMultiComponentFluid.hpp | 27 +++++++- .../PVTFunctions/BrineEnthalpyFunction.cpp | 43 ++++++++++++ .../PVTFunctions/BrineEnthalpyFunction.hpp | 64 ++++++++++++++++++ .../BrineInternalEnergyFunction.cpp | 43 ++++++++++++ .../BrineInternalEnergyFunction.hpp | 64 ++++++++++++++++++ .../PVTFunctions/CO2EnthalpyFunction.cpp | 43 ++++++++++++ .../PVTFunctions/CO2EnthalpyFunction.hpp | 65 +++++++++++++++++++ .../CO2InternalEnergyFunction.cpp | 43 ++++++++++++ .../CO2InternalEnergyFunction.hpp | 65 +++++++++++++++++++ .../fluid/PVTFunctions/PVTFunctionBase.hpp | 2 +- 12 files changed, 514 insertions(+), 6 deletions(-) create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp diff --git a/src/coreComponents/constitutive/CMakeLists.txt b/src/coreComponents/constitutive/CMakeLists.txt index c8a3f1b4450..e1d1460b1bf 100644 --- a/src/coreComponents/constitutive/CMakeLists.txt +++ b/src/coreComponents/constitutive/CMakeLists.txt @@ -18,6 +18,10 @@ set( constitutive_headers fluid/PVTFunctions/BrineViscosityFunction.hpp fluid/PVTFunctions/CO2SolubilityFunction.hpp fluid/PVTFunctions/FenghourCO2ViscosityFunction.hpp + fluid/PVTFunctions/BrineEnthalpyFunction.hpp + fluid/PVTFunctions/BrineInternalEnergyFunction.hpp + fluid/PVTFunctions/CO2EnthalpyFunction.hpp + fluid/PVTFunctions/CO2InternalEnergyFunction.hpp fluid/PVTFunctions/FlashModelBase.hpp fluid/PVTFunctions/PVTFunctionBase.hpp fluid/PVTFunctions/SpanWagnerCO2DensityFunction.hpp @@ -71,7 +75,11 @@ set( constitutive_sources fluid/PVTFunctions/BrineViscosityFunction.cpp fluid/PVTFunctions/CO2SolubilityFunction.cpp fluid/PVTFunctions/FenghourCO2ViscosityFunction.cpp - fluid/PVTFunctions/SpanWagnerCO2DensityFunction.cpp + fluid/PVTFunctions/SpanWagnerCO2DensityFunction.cpp + fluid/PVTFunctions/BrineEnthalpyFunction.cpp + fluid/PVTFunctions/BrineInternalEnergyFunction.cpp + fluid/PVTFunctions/CO2EnthalpyFunction.cpp + fluid/PVTFunctions/CO2InternalEnergyFunction.cpp fluid/PVTFunctions/UtilityFunctions.cpp fluid/SingleFluidBase.cpp fluid/MultiFluidBase.cpp diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp index 9d91365daf8..1e4cab54832 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp @@ -46,7 +46,7 @@ MultiPhaseMultiComponentFluid::MultiPhaseMultiComponentFluid( std::string const registerWrapper( viewKeyStruct::flashModelParaFileString, &m_flashModelParaFile )-> setInputFlag( InputFlags::REQUIRED )-> setRestartFlags( RestartFlags::NO_WRITE )-> - setDescription( "name of the filen including flash calculation function parameters" ); + setDescription( "name of the file including flash calculation function parameters" ); } @@ -133,6 +133,20 @@ void MultiPhaseMultiComponentFluid::CreatePVTModels() m_componentNames, m_componentMolarWeight ) ); } + else if (strs[0] == "EnthalpyFun") + { + m_phaseEnthalpyFuns.emplace_back( PVTFunction::CatalogInterface::Factory( strs[ 1 ], + strs, + m_componentNames, + m_componentMolarWeight ) ); + } + else if (strs[0] == "InternalEnergyFun") + { + m_phaseInternalEnergyFuns.emplace_back( PVTFunction::CatalogInterface::Factory( strs[ 1 ], + strs, + m_componentNames, + m_componentMolarWeight ) ); + } else { GEOSX_ERROR( "Error: Invalid PVT function: " << strs[0] << "." ); @@ -221,7 +235,13 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, real64 & totalDensity, real64 & dTotalDensity_dPressure, real64 & dTotalDensity_dTemperature, - arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction ) const + arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseEnthalpy, + arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, + arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice1d< real64 > const & phaseInternalEnergy, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature ) const { CompositionalVarContainer< 1 > phaseFrac { phaseFraction, @@ -265,6 +285,20 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, dTotalDensity_dGlobalCompFraction }; + CompositionalVarContainer< 1 > phaseEnt { + phaseEnthalpy, + dPhaseEnthalpy_dPressure, + dPhaseEnthalpy_dTemperature, + dPhaseEnthalpy_dGlobalCompFraction + }; + + CompositionalVarContainer< 1 > phaseIntEner { + phaseInternalEnergy, + dPhaseInternalEnergy_dPressure, + dPhaseInternalEnergy_dTemperature, + dPhaseInternalEnergy_dGlobalCompFraction + }; + #if defined(__CUDACC__) // For some reason nvcc thinks these aren't used. GEOSX_UNUSED_VAR( phaseFrac, phaseDens, phaseMassDens, phaseVisc, phaseCompFrac, totalDens ); @@ -321,12 +355,17 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, stackArray1d< EvalVarArgs, maxNumPhase > phaseDensityTemp( NP ); stackArray1d< EvalVarArgs, maxNumPhase > phaseMassDensityTemp( NP ); stackArray1d< EvalVarArgs, maxNumPhase > phaseViscosityTemp( NP ); + stackArray1d< EvalVarArgs, maxNumPhase > phaseEnthalpyTemp( NP ); + stackArray1d< EvalVarArgs, maxNumPhase > phaseInternalEnergyTemp( NP ); for( localIndex ip = 0; ip < NP; ++ip ) { // molarDensity or massDensity (useMass) m_phaseDensityFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseDensityTemp[ip], m_useMass ); m_phaseViscosityFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseViscosityTemp[ip] ); + // molar or mass Enthalpy and Internal Energy + m_phaseEnthalpyFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseEnthalpyTemp[ip], m_useMass ); + m_phaseInternalEnergyFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseInternalEnergyTemp[ip], m_useMass ); } if( m_useMass ) @@ -406,6 +445,14 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseVisc.dPres[ip] = phaseViscosityTemp[ip].m_der[0]; phaseVisc.dTemp[ip] = 0.0; + phaseEnt.value[ip] = phaseEnthapyTemp[ip].m_var; + phaseEnt.dPres[ip] = phaseEnthapyTemp[ip].m_der[0]; + phaseEnt.dTemp[ip] = phaseEnthapyTemp[ip].m_der[1]; + + phaseIntEner.value[ip] = phaseInternalEnergyTemp[ip].m_var; + phaseIntEner.dPres[ip] = phaseInternalEnergyTemp[ip].m_der[0]; + phaseIntEner.dTemp[ip] = phaseInternalEnergyTemp[ip].m_der[1]; + for( localIndex ic = 0; ic < NC; ++ic ) { phaseFrac.dComp[ip][ic] = phaseFractionTemp[ip].m_der[ic+1]; diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index e64b4e62f6e..4aee1249a50 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -54,6 +54,8 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate MultiPhaseMultiComponentFluidUpdate( std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseDensityFuns, std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseViscosityFuns, + std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseEnthalpyFuns, + std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseInternalEnergyFuns, std::shared_ptr< PVTProps::FlashModel const > const & flashModel, arrayView1d< real64 const > const & componentMolarWeight, bool useMass, @@ -125,6 +127,8 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate dPhaseInternalEnergy_dGlobalCompFraction ), m_phaseDensityFuns( phaseDensityFuns ), m_phaseViscosityFuns( phaseViscosityFuns ), + m_phaseEnthalpyFuns( phaseEnthalpyFuns ), + m_phaseInternalEnergyFuns( phaseInternalEnergyFuns ), m_flashModel( flashModel ) {} @@ -176,7 +180,14 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate real64 & totalDensity, real64 & dTotalDensity_dPressure, real64 & dTotalDensity_dTemperature, - arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction ) const override; + arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, + arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseEnthalpy, + arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, + arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice1d< real64 > const & phaseInternalEnergy, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature ) const override; GEOSX_FORCE_INLINE virtual void Update( localIndex const k, @@ -211,13 +222,23 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate m_totalDensity[k][q], m_dTotalDensity_dPressure[k][q], m_dTotalDensity_dTemperature[k][q], - m_dTotalDensity_dGlobalCompFraction[k][q] ); + m_dTotalDensity_dGlobalCompFraction[k][q], + m_phaseEnthalpy[k][q], + m_dPhaseEnthalpy_dPressure[k][q], + m_dPhaseEnthalpy_dTemperature[k][q], + m_dPhaseEnthalpy_dGlobalCompFraction[k][q], + m_phaseInternalEnergy[k][q], + m_dPhaseInternalEnergy_dPressure[k][q], + m_dPhaseInternalEnergy_dTemperature[k][q], + m_dPhaseInternalEnergy_dGlobalCompFraction[k][q] ); } private: std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseDensityFuns; std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseViscosityFuns; + std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseEnthalpyFuns; + std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseInternalEnergyFuns; std::shared_ptr< PVTProps::FlashModel const > m_flashModel; }; @@ -311,6 +332,8 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase // number of entries corrosponds to number of phases std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseDensityFuns; std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseViscosityFuns; + std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseEnthalpyFuns; + std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseInternalEnergyFuns; std::shared_ptr< PVTProps::FlashModel const > m_flashModel; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp new file mode 100644 index 00000000000..ddf2de21fda --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp @@ -0,0 +1,43 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file BrineEnthalpyFunction.cpp + */ + +#include "constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp" + +namespace geosx +{ + +using namespace stringutilities; + +namespace PVTProps +{ + +void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, + arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +{ + GEOSX_UNUSED_VAR(phaseComposition); + GEOSX_UNUSED_VAR(useMass); +} + + + +REGISTER_CATALOG_ENTRY( PVTFunction, + BrineEnthalpyFunction, + string_array const &, string_array const &, real64_array const & ) + +} // namespace PVTProps +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp new file mode 100644 index 00000000000..befe10b65c7 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp @@ -0,0 +1,64 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPYFUNCTION_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPYFUNCTION_HPP_ + + +#include "PVTFunctionBase.hpp" + +namespace geosx +{ + +namespace PVTProps +{ + +class BrineEnthalpyFunction : public PVTFunction +{ +public: + + + BrineEnthalpyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ); + + ~BrineEnthalpyFunction() override {} + + + static constexpr auto m_catalogName = "BrineEnthalpy"; + static string CatalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return CatalogName(); } + + + virtual PVTFuncType FunctionType() const override + { + return PVTFuncType::ENTHALPY; + } + + virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + EvalVarArgs & value, bool useMass = 0 ) const override; + + static void CalculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & enthalpy ); + +private: + +}; + +} + +} + + +#endif /* GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPYFUNCTION_HPP_ */ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp new file mode 100644 index 00000000000..5098bcb7934 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp @@ -0,0 +1,43 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file BrineInternalEnergyFunction.cpp + */ + +#include "constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp" + +namespace geosx +{ + +using namespace stringutilities; + +namespace PVTProps +{ + +void BrineInternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, + arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +{ + GEOSX_UNUSED_VAR(phaseComposition); + GEOSX_UNUSED_VAR(useMass); +} + + + +REGISTER_CATALOG_ENTRY( PVTFunction, + BrineInternalEnergyFunction, + string_array const &, string_array const &, real64_array const & ) + +} // namespace PVTProps +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp new file mode 100644 index 00000000000..ee326397fde --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp @@ -0,0 +1,64 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGYFUNCTION_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGYFUNCTION_HPP_ + + +#include "PVTFunctionBase.hpp" + +namespace geosx +{ + +namespace PVTProps +{ + +class BrineInternalEnergyFunction : public PVTFunction +{ +public: + + + BrineInternalEnergyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ); + + ~BrineInternalEnergyFunction() override {} + + + static constexpr auto m_catalogName = "BrineInternalEnergy"; + static string CatalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return CatalogName(); } + + + virtual PVTFuncType FunctionType() const override + { + return PVTFuncType::INTERNALENR; + } + + virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + EvalVarArgs & value, bool useMass = 0 ) const override; + + static void CalculateBrineInternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); + +private: + +}; + +} + +} + + +#endif /* GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGYFUNCTION_HPP_ */ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp new file mode 100644 index 00000000000..915b57b74e1 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp @@ -0,0 +1,43 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CO2EnthalpyFunction.cpp + */ + +#include "constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp" + +namespace geosx +{ + +using namespace stringutilities; + +namespace PVTProps +{ + +void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, + arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +{ + GEOSX_UNUSED_VAR(phaseComposition); + GEOSX_UNUSED_VAR(useMass); +} + + + +REGISTER_CATALOG_ENTRY( PVTFunction, + CO2EnthalpyFunction, + string_array const &, string_array const &, real64_array const & ) + +} // namespace PVTProps +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp new file mode 100644 index 00000000000..d8d37fe9397 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp @@ -0,0 +1,65 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2ENTHALPYFUNCTION_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2ENTHALPYFUNCTION_HPP_ + + +#include "PVTFunctionBase.hpp" + +namespace geosx +{ + +namespace PVTProps +{ + +class CO2EnthalpyFunction : public PVTFunction +{ +public: + + + CO2EnthalpyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ); + + ~CO2EnthalpyFunction() override {} + + + static constexpr auto m_catalogName = "CO2Enthalpy"; + static string CatalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return CatalogName(); } + + + virtual PVTFuncType FunctionType() const override + { + return PVTFuncType::ENTHALPY; + } + + virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + EvalVarArgs & value, bool useMass = 0 ) const override; + + static void CalculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & enthalpy ); + +private: + + +}; + +} + +} + + +#endif /* GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2ENTHALPYFUNCTION_HPP_ */ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp new file mode 100644 index 00000000000..fd97dd94034 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp @@ -0,0 +1,43 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CO2InternalEnergyFunction.cpp + */ + +#include "constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp" + +namespace geosx +{ + +using namespace stringutilities; + +namespace PVTProps +{ + +void CO2InternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, + arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +{ + GEOSX_UNUSED_VAR(phaseComposition); + GEOSX_UNUSED_VAR(useMass); + +} + + +REGISTER_CATALOG_ENTRY( PVTFunction, + CO2InternalEnergyFunction, + string_array const &, string_array const &, real64_array const & ) + +} // namespace PVTProps +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp new file mode 100644 index 00000000000..91916ce7a1e --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp @@ -0,0 +1,65 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 Total, S.A + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2INTERNALENERGYFUNCTION_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2INTERNALENERGYFUNCTION_HPP_ + + +#include "PVTFunctionBase.hpp" + +namespace geosx +{ + +namespace PVTProps +{ + +class CO2InternalEnergyFunction : public PVTFunction +{ +public: + + + CO2InternalEnergyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ); + + ~CO2InternalEnergyFunction() override {} + + + static constexpr auto m_catalogName = "CO2InternalEnergy"; + static string CatalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return CatalogName(); } + + + virtual PVTFuncType FunctionType() const override + { + return PVTFuncType::INTERNALENR; + } + + virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + EvalVarArgs & value, bool useMass = 0 ) const override; + + static void CalculateCO2InternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); + +private: + + +}; + +} + +} + + +#endif /* GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2INTERNALENERGYFUNCTION_HPP_ */ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp index 9e79584a742..827b26a26f7 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp @@ -28,7 +28,7 @@ namespace geosx namespace PVTProps { -enum class PVTFuncType {UNKNOWN, DENSITY, VISCOSITY}; +enum class PVTFuncType {UNKNOWN, DENSITY, VISCOSITY, ENTHALPY, INTERNALENR}; class PVTFunction { From e664d8f36c8690f451cccf14bef6d06811d90df0 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Mon, 21 Dec 2020 14:57:59 -0800 Subject: [PATCH 08/34] dummy functions and derivatives for enthalpy and internalEnergy. --- .../constitutive/fluid/MultiPhaseMultiComponentFluid.cpp | 7 +++++-- .../fluid/PVTFunctions/BrineEnthalpyFunction.cpp | 8 ++++++++ .../fluid/PVTFunctions/BrineInternalEnergyFunction.cpp | 9 +++++++++ .../fluid/PVTFunctions/CO2EnthalpyFunction.cpp | 8 ++++++++ .../fluid/PVTFunctions/CO2InternalEnergyFunction.cpp | 8 ++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp index 1e4cab54832..cad9edefd49 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp @@ -447,11 +447,11 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseEnt.value[ip] = phaseEnthapyTemp[ip].m_var; phaseEnt.dPres[ip] = phaseEnthapyTemp[ip].m_der[0]; - phaseEnt.dTemp[ip] = phaseEnthapyTemp[ip].m_der[1]; + phaseEnt.dTemp[ip] = phaseEnthapyTemp[ip].m_der[NC+1]; phaseIntEner.value[ip] = phaseInternalEnergyTemp[ip].m_var; phaseIntEner.dPres[ip] = phaseInternalEnergyTemp[ip].m_der[0]; - phaseIntEner.dTemp[ip] = phaseInternalEnergyTemp[ip].m_der[1]; + phaseIntEner.dTemp[ip] = phaseInternalEnergyTemp[ip].m_der[NC+1]; for( localIndex ic = 0; ic < NC; ++ic ) { @@ -464,6 +464,9 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseCompFrac.dPres[ip][ic] = phaseCompFractionTemp[ip][ic].m_der[0]; phaseCompFrac.dTemp[ip][ic] = 0.0; + phaseEnt.dComp[ip] = 0.0; // phaseEnthapyTemp[ip].m_der[ic+1]; + phaseIntEner.dComp[ip] = 0.0; // phaseInternalEnergyTemp[ip].m_der[ic+1]; + for( localIndex jc = 0; jc < NC; ++jc ) { phaseCompFrac.dComp[ip][ic][jc] = phaseCompFractionTemp[ip][ic].m_der[jc+1]; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp index ddf2de21fda..372172444bc 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp @@ -31,6 +31,14 @@ void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArg { GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); + + numComponents = phaseComposition.size(); + + value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; + // pressure derivative + value.m_der[0] = 0.001; + // temperature derivative + value.m_der[numComponents+1] = 1.0; } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp index 5098bcb7934..beee935b3cf 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp @@ -31,6 +31,15 @@ void BrineInternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, Eval { GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); + + numComponents = phaseComposition.size(); + + value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; + // pressure derivative + value.m_der[0] = 0.001; + // temperature derivative + value.m_der[numComponents+1] = 1.0; + } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp index 915b57b74e1..357bc6ab9fd 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp @@ -31,6 +31,14 @@ void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs { GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); + + numComponents = phaseComposition.size(); + + value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; + // pressure derivative + value.m_der[0] = 0.001; + // temperature derivative + value.m_der[numComponents+1] = 1.0; } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp index fd97dd94034..dc5026a79bc 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp @@ -32,6 +32,14 @@ void CO2InternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVa GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); + numComponents = phaseComposition.size(); + + value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; + // pressure derivative + value.m_der[0] = 0.001; + // temperature derivative + value.m_der[numComponents+1] = 1.0; + } From f673df484a24645df2cfc3d2016278d84ad4dbe3 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Tue, 22 Dec 2020 14:51:10 -0800 Subject: [PATCH 09/34] fixed comp errors for const. model. --- .../constitutive/fluid/MultiFluidBase.hpp | 26 +++++--- .../fluid/MultiFluidPVTPackageWrapper.cpp | 19 +++++- .../fluid/MultiFluidPVTPackageWrapper.hpp | 20 +++++- .../fluid/MultiPhaseMultiComponentFluid.cpp | 14 ++-- .../fluid/MultiPhaseMultiComponentFluid.hpp | 7 +- .../PVTFunctions/BrineEnthalpyFunction.cpp | 2 +- .../BrineInternalEnergyFunction.cpp | 2 +- .../PVTFunctions/CO2EnthalpyFunction.cpp | 2 +- .../CO2InternalEnergyFunction.cpp | 2 +- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 3 +- .../fluidFlow/CompositionalMultiphaseFlow.hpp | 65 +------------------ .../CompositionalMultiphaseFlowKernels.hpp | 3 +- 12 files changed, 74 insertions(+), 91 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 129d21ad7c9..50f084eb199 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -225,7 +225,15 @@ class MultiFluidBaseUpdate real64 & totalDensity, real64 & dTotalDensity_dPressure, real64 & dTotalDensity_dTemperature, - arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction ) const = 0; + arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseEnthalpy, + arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, + arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice2d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseInternalEnergy, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature, + arraySlice2d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) const = 0; virtual void Update( localIndex const k, localIndex const q, @@ -329,15 +337,15 @@ class MultiFluidBase : public ConstitutiveBase arrayView2d< real64 const > dTotalDensity_dTemperature() const { return m_dTotalDensity_dTemperature; } arrayView3d< real64 const > dTotalDensity_dGlobalCompFraction() const { return m_dTotalDensity_dGlobalCompFraction; } - arrayView2d< real64 const > phaseEnthalpy() const { return m_phaseEnthalpy; } - arrayView2d< real64 const > dPhaseEnthalpy_dPressure() const { return m_dPhaseEnthalpy_dPressure; } - arrayView2d< real64 const > dPhaseEnthalpy_dTemperature() const { return m_dPhaseEnthalpy_dTemperature; } - arrayView3d< real64 const > dPhaseEnthalpy_dGlobalCompFraction() const { return m_dPhaseEnthalpy_dGlobalCompFraction; } + arrayView3d< real64 const > phaseEnthalpy() const { return m_phaseEnthalpy; } + arrayView3d< real64 const > dPhaseEnthalpy_dPressure() const { return m_dPhaseEnthalpy_dPressure; } + arrayView3d< real64 const > dPhaseEnthalpy_dTemperature() const { return m_dPhaseEnthalpy_dTemperature; } + arrayView4d< real64 const > dPhaseEnthalpy_dGlobalCompFraction() const { return m_dPhaseEnthalpy_dGlobalCompFraction; } - arrayView2d< real64 const > phaseInternalEnergy() const { return m_phaseInternalEnergy; } - arrayView2d< real64 const > dPhaseInternalEnergy_dPressure() const { return m_dPhaseInternalEnergy_dPressure; } - arrayView2d< real64 const > dPhaseInternalEnergy_dTemperature() const { return m_dPhaseInternalEnergy_dTemperature; } - arrayView3d< real64 const > dPhaseInternalEnergy_dGlobalCompFraction() const { return m_dPhaseInternalEnergy_dGlobalCompFraction; } + arrayView3d< real64 const > phaseInternalEnergy() const { return m_phaseInternalEnergy; } + arrayView3d< real64 const > dPhaseInternalEnergy_dPressure() const { return m_dPhaseInternalEnergy_dPressure; } + arrayView3d< real64 const > dPhaseInternalEnergy_dTemperature() const { return m_dPhaseInternalEnergy_dTemperature; } + arrayView4d< real64 const > dPhaseInternalEnergy_dGlobalCompFraction() const { return m_dPhaseInternalEnergy_dGlobalCompFraction; } struct viewKeyStruct : ConstitutiveBase::viewKeyStruct { diff --git a/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.cpp b/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.cpp index ff5de5ee126..387ffff421f 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.cpp @@ -223,7 +223,15 @@ void MultiFluidPVTPackageWrapperUpdate::Compute( real64 pressure, real64 & totalDensity, real64 & dTotalDensity_dPressure, real64 & dTotalDensity_dTemperature, - arraySlice1d< real64, 0 > const & dTotalDensity_dGlobalCompFraction ) const + arraySlice1d< real64, 0 > const & dTotalDensity_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseEnthalpy, + arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, + arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice2d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseInternalEnergy, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature, + arraySlice2d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) const { // 0. make shortcut structs to avoid long names (TODO maybe remove) CompositionalVarContainer< 1 > phaseFrac{ @@ -268,6 +276,15 @@ void MultiFluidPVTPackageWrapperUpdate::Compute( real64 pressure, dTotalDensity_dGlobalCompFraction }; + GEOSX_UNUSED_VAR( phaseEnthalpy ); + GEOSX_UNUSED_VAR( dPhaseEnthalpy_dPressure ); + GEOSX_UNUSED_VAR( dPhaseEnthalpy_dTemperature ); + GEOSX_UNUSED_VAR( dPhaseEnthalpy_dGlobalCompFraction ); + GEOSX_UNUSED_VAR( phaseInternalEnergy ); + GEOSX_UNUSED_VAR( dPhaseInternalEnergy_dPressure ); + GEOSX_UNUSED_VAR( dPhaseInternalEnergy_dTemperature ); + GEOSX_UNUSED_VAR( dPhaseInternalEnergy_dGlobalCompFraction ); + #if defined(__CUDACC__) // For some reason nvcc thinks these aren't used. GEOSX_UNUSED_VAR( phaseFrac, phaseDens, phaseMassDens, phaseVisc, phaseCompFrac, totalDens ); diff --git a/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp b/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp index b32dee8982b..e4a956294cc 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidPVTPackageWrapper.hpp @@ -169,7 +169,15 @@ class MultiFluidPVTPackageWrapperUpdate final : public MultiFluidBaseUpdate real64 & totalDensity, real64 & dTotalDensity_dPressure, real64 & dTotalDensity_dTemperature, - arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction ) const override; + arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseEnthalpy, + arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, + arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice2d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, + arraySlice1d< real64 > const & phaseInternalEnergy, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature, + arraySlice2d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) const override; GEOSX_FORCE_INLINE virtual void Update( localIndex const k, @@ -204,7 +212,15 @@ class MultiFluidPVTPackageWrapperUpdate final : public MultiFluidBaseUpdate m_totalDensity[k][q], m_dTotalDensity_dPressure[k][q], m_dTotalDensity_dTemperature[k][q], - m_dTotalDensity_dGlobalCompFraction[k][q] ); + m_dTotalDensity_dGlobalCompFraction[k][q], + m_phaseEnthalpy[k][q], + m_dPhaseEnthalpy_dPressure[k][q], + m_dPhaseEnthalpy_dTemperature[k][q], + m_dPhaseEnthalpy_dGlobalCompFraction[k][q], + m_phaseInternalEnergy[k][q], + m_dPhaseInternalEnergy_dPressure[k][q], + m_dPhaseInternalEnergy_dTemperature[k][q], + m_dPhaseInternalEnergy_dGlobalCompFraction[k][q] ); } private: diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp index cad9edefd49..4ecf862ad91 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp @@ -239,9 +239,11 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, arraySlice1d< real64 > const & phaseEnthalpy, arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice2d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, arraySlice1d< real64 > const & phaseInternalEnergy, arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, - arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature ) const + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature, + arraySlice2d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) const { CompositionalVarContainer< 1 > phaseFrac { phaseFraction, @@ -445,9 +447,9 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseVisc.dPres[ip] = phaseViscosityTemp[ip].m_der[0]; phaseVisc.dTemp[ip] = 0.0; - phaseEnt.value[ip] = phaseEnthapyTemp[ip].m_var; - phaseEnt.dPres[ip] = phaseEnthapyTemp[ip].m_der[0]; - phaseEnt.dTemp[ip] = phaseEnthapyTemp[ip].m_der[NC+1]; + phaseEnt.value[ip] = phaseEnthalpyTemp[ip].m_var; + phaseEnt.dPres[ip] = phaseEnthalpyTemp[ip].m_der[0]; + phaseEnt.dTemp[ip] = phaseEnthalpyTemp[ip].m_der[NC+1]; phaseIntEner.value[ip] = phaseInternalEnergyTemp[ip].m_var; phaseIntEner.dPres[ip] = phaseInternalEnergyTemp[ip].m_der[0]; @@ -464,8 +466,8 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseCompFrac.dPres[ip][ic] = phaseCompFractionTemp[ip][ic].m_der[0]; phaseCompFrac.dTemp[ip][ic] = 0.0; - phaseEnt.dComp[ip] = 0.0; // phaseEnthapyTemp[ip].m_der[ic+1]; - phaseIntEner.dComp[ip] = 0.0; // phaseInternalEnergyTemp[ip].m_der[ic+1]; + phaseEnt.dComp[ip][ic] = 0.0; // phaseEnthapyTemp[ip].m_der[ic+1]; + phaseIntEner.dComp[ip][ic] = 0.0; // phaseInternalEnergyTemp[ip].m_der[ic+1]; for( localIndex jc = 0; jc < NC; ++jc ) { diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index 4aee1249a50..a31ca61b8fd 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -181,13 +181,14 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate real64 & dTotalDensity_dPressure, real64 & dTotalDensity_dTemperature, arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, - arraySlice1d< real64 > const & dTotalDensity_dGlobalCompFraction, arraySlice1d< real64 > const & phaseEnthalpy, arraySlice1d< real64 > const & dPhaseEnthalpy_dPressure, arraySlice1d< real64 > const & dPhaseEnthalpy_dTemperature, + arraySlice2d< real64 > const & dPhaseEnthalpy_dGlobalCompFraction, arraySlice1d< real64 > const & phaseInternalEnergy, arraySlice1d< real64 > const & dPhaseInternalEnergy_dPressure, - arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature ) const override; + arraySlice1d< real64 > const & dPhaseInternalEnergy_dTemperature, + arraySlice2d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) const override; GEOSX_FORCE_INLINE virtual void Update( localIndex const k, @@ -271,6 +272,8 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase { return KernelWrapper( m_phaseDensityFuns, m_phaseViscosityFuns, + m_phaseEnthalpyFuns, + m_phaseInternalEnergyFuns, m_flashModel, m_componentMolarWeight.toViewConst(), m_useMass, diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp index 372172444bc..bd57576ba68 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp @@ -32,7 +32,7 @@ void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArg GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); - numComponents = phaseComposition.size(); + localIndex const numComponents = phaseComposition.size(); value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; // pressure derivative diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp index beee935b3cf..b612bc59587 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp @@ -32,7 +32,7 @@ void BrineInternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, Eval GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); - numComponents = phaseComposition.size(); + localIndex const numComponents = phaseComposition.size(); value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; // pressure derivative diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp index 357bc6ab9fd..fcd25dcceab 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp @@ -32,7 +32,7 @@ void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); - numComponents = phaseComposition.size(); + localIndex const numComponents = phaseComposition.size(); value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; // pressure derivative diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp index dc5026a79bc..114cec77e0f 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp @@ -32,7 +32,7 @@ void CO2InternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVa GEOSX_UNUSED_VAR(phaseComposition); GEOSX_UNUSED_VAR(useMass); - numComponents = phaseComposition.size(); + localIndex const numComponents = phaseComposition.size(); value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; // pressure derivative diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index 537b0d21344..fda93b45b83 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -44,6 +44,7 @@ namespace geosx using namespace dataRepository; using namespace constitutive; +using namespace CompositionalMultiphaseFlowKernels; static constexpr real64 minDensForDivision = 1e-10; @@ -395,7 +396,7 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, arrayView3d< real64 const > const & dPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); arrayView4d< real64 const > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); - if ( m_isoThermalFlag ) + if ( m_isothermalFlag ) { KernelLaunchSelector2 < IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >(m_numComponents, m_numPhases, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp index c3d0d919699..9b1cf29fd11 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp @@ -307,7 +307,7 @@ class CompositionalMultiphaseFlow : public FlowSolverBase static constexpr auto phaseVolumeFractionString = "phaseVolumeFraction"; static constexpr auto dPhaseVolumeFraction_dPressureString = "dPhaseVolumeFraction_dPressure"; static constexpr auto dPhaseVolumeFraction_dGlobalCompDensityString = "dPhaseVolumeFraction_dGlobalCompDensity"; - static constexpr auto dPhaseVolumeFraction_dTemperatureString = "dPhaseVolumeFraction_dTemperature" + static constexpr auto dPhaseVolumeFraction_dTemperatureString = "dPhaseVolumeFraction_dTemperature"; // intermediate values for mobilities static constexpr auto phaseMobilityString = "phaseMobility"; @@ -387,13 +387,6 @@ class CompositionalMultiphaseFlow : public FlowSolverBase */ void ChopNegativeDensities( DomainPartition & domain ); - - template< typename KERNELWRAPPER, typename ... ARGS > - void CompositionalMultiphaseFlow::KernelLaunchSelector1( localIndex numComp, ARGS && ... args ); - - template< typename KERNELWRAPPER, typename ... ARGS > - void CompositionalMultiphaseFlow::KernelLaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ); - protected: virtual void PostProcessInput() override; @@ -496,62 +489,6 @@ class CompositionalMultiphaseFlow : public FlowSolverBase }; -/******************************** Kernel launch machinery ********************************/ - -namespace internal -{ - -template< typename T, typename LAMBDA > -void KernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) -{ - static_assert( std::is_integral< T >::value, "KernelLaunchSelectorCompSwitch: type should be integral" ); - - switch( value ) - { - case 1: - { lambda( std::integral_constant< T, 1 >() ); return; } - case 2: - { lambda( std::integral_constant< T, 2 >() ); return; } - case 3: - { lambda( std::integral_constant< T, 3 >() ); return; } - case 4: - { lambda( std::integral_constant< T, 4 >() ); return; } - case 5: - { lambda( std::integral_constant< T, 5 >() ); return; } - default: - { GEOSX_ERROR( "Unsupported number of components: " << value ); } - } -} - -} // namespace helpers - -template< typename KERNELWRAPPER, typename ... ARGS > -void CompositionalMultiphaseFlow::KernelLaunchSelector1( localIndex numComp, ARGS && ... args ) -{ - internal::KernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - KERNELWRAPPER::template Launch< NC() >( std::forward< ARGS >( args )... ); - } ); -} - -template< typename KERNELWRAPPER, typename ... ARGS > -void CompositionalMultiphaseFlow::KernelLaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ) -{ - internal::KernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - switch( numPhase ) - { - case 2: - { KERNELWRAPPER::template Launch< NC(), 2 >( std::forward< ARGS >( args )... ); return; } - case 3: - { KERNELWRAPPER::template Launch< NC(), 3 >( std::forward< ARGS >( args )... ); return; } - default: - { GEOSX_ERROR( "Unsupported number of phases: " << numPhase ); } - } - } ); -} - - } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index ccd462ccf34..df9389cb151 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -74,7 +74,6 @@ struct PhaseVolumeFractionKernel GEOSX_FORCE_INLINE static void Compute( arraySlice1d< real64 const > const & compDens, - arrayView2d< real64 const > const & compDens, arrayView2d< real64 const > const & dCompDens, arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, @@ -538,7 +537,7 @@ struct VolumeBalanceKernel arrayView2d< real64 const > const & dPvMult_dPres, arrayView2d< real64 const > const & phaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, - rrayView2d< real64 const > const & dPhaseVolFrac_dTemp, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ); From 104e987dd57dfb2f772430926c6ce5070bde27bb Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Tue, 22 Dec 2020 15:35:54 -0800 Subject: [PATCH 10/34] Fixed some errors. --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 29 ++++---- .../CompositionalMultiphaseFlowKernels.cpp | 35 +++++----- .../CompositionalMultiphaseFlowKernels.hpp | 68 ++++++++++++++----- ...rmalCompositionalMultiphaseFlowKernels.hpp | 56 +++++++++++++++ .../wells/CompositionalMultiphaseWell.cpp | 7 +- 5 files changed, 144 insertions(+), 51 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index fda93b45b83..d0581876d65 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -44,7 +44,6 @@ namespace geosx using namespace dataRepository; using namespace constitutive; -using namespace CompositionalMultiphaseFlowKernels; static constexpr real64 minDensForDivision = 1e-10; @@ -351,7 +350,7 @@ void CompositionalMultiphaseFlow::UpdateComponentFraction( Group & dataGroup ) c arrayView2d< real64 const > const dCompDens = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); - KernelLaunchSelector1 + CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::ComponentFractionKernel >( m_numComponents, dataGroup.size(), compDens, @@ -398,7 +397,7 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, if ( m_isothermalFlag ) { - KernelLaunchSelector2 + IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >(m_numComponents, m_numPhases, dataGroup.size(), compDens, @@ -422,7 +421,7 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, arrayView2d< real64 > const dPhaseVolFrac_dTemp = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); - KernelLaunchSelector2 + CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, dataGroup.size(), compDens, @@ -487,7 +486,7 @@ void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localI if (m_isothermalFlag) { - KernelLaunchSelector2 + IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < IsothermalCompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, dataGroup.size(), dCompFrac_dCompDens, @@ -513,7 +512,7 @@ void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localI arrayView2d< real64 > const dPhaseMob_dTemp = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ); - KernelLaunchSelector2 + CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, dataGroup.size(), dCompFrac_dCompDens, @@ -893,9 +892,9 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con arrayView4d< real64 const > const & dPhaseCompFrac_dPres = fluid.dPhaseCompFraction_dPressure(); arrayView5d< real64 const > const & dPhaseCompFrac_dComp = fluid.dPhaseCompFraction_dGlobalCompFraction(); - if ( m_istothermalFlag ) + if ( m_isothermalFlag ) { - KernelLaunchSelector1 + IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < IsothermalCompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, m_numPhases, subRegion.size(), @@ -944,7 +943,7 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con arrayView1d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); arrayView1d< real64 const > const & rockDensity = solid.density(); - KernelLaunchSelector1 + CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, m_numPhases, subRegion.size(), @@ -1053,7 +1052,7 @@ void CompositionalMultiphaseFlow::AssembleFluxTerms( real64 const dt, { if ( m_isothermalFlag ) { - KernelLaunchSelector1 + IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < IsothermalCompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, m_numPhases, stencil, @@ -1083,7 +1082,7 @@ void CompositionalMultiphaseFlow::AssembleFluxTerms( real64 const dt, localRhs.toView() ); }else { - KernelLaunchSelector1 + CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, m_numPhases, stencil, @@ -1160,7 +1159,7 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co if ( m_isothermalFlag ) { - KernelLaunchSelector2 + IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < IsothermalCompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, subRegion.size(), dofManager.rankOffset(), @@ -1180,7 +1179,7 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); - KernelLaunchSelector2 + CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, subRegion.size(), dofManager.rankOffset(), @@ -1975,7 +1974,7 @@ void CompositionalMultiphaseFlow::ResetViews( MeshLevel & mesh ) m_dPhaseMassDens_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseMassDensity_dTemperatureString, targetRegionNames(), fluidModelNames() ); - m_dPhaseMassDens_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMassDensity_dTemperatureString ); + m_dPhaseMassDens_dTemp.setName( getName() + "/accessors/" + keys::dPhaseMassDensity_dTemperatureString ); m_dPhaseCompFrac_dTemp.clear(); m_dPhaseCompFrac_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseCompFraction_dTemperatureString, @@ -2004,7 +2003,7 @@ void CompositionalMultiphaseFlow::ResetViews( MeshLevel & mesh ) m_dPhaseEnthalpy_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dTemperatureString, targetRegionNames(), fluidModelNames() ); - m_dPhaseEnthalpy_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseEnthalpy_dTemperatureString ); + m_dPhaseEnthalpy_dTemp.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dTemperatureString ); m_dPhaseEnthalpy_dComp.clear(); m_dPhaseEnthalpy_dComp = elemManager.ConstructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseEnthalpy_dGlobalCompFractionString, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index 74e91743ce6..fb03678f426 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -201,6 +201,7 @@ void PhaseVolumeFractionKernel:: arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseFrac, arrayView3d< real64 const > const & dPhaseFrac_dPres, + arrayView3d< real64 const > const & dPhaseFrac_dTemp, arrayView4d< real64 const > const & dPhaseFrac_dComp, arrayView2d< real64 > const & phaseVolFrac, arrayView2d< real64 > const & dPhaseVolFrac_dPres, @@ -218,7 +219,7 @@ void PhaseVolumeFractionKernel:: dPhaseDens_dComp[a][0], phaseFrac[a][0], dPhaseFrac_dPres[a][0], - dPhaseDens_dTemp[a][0], + dPhaseFrac_dTemp[a][0], dPhaseFrac_dComp[a][0], phaseVolFrac[a], dPhaseVolFrac_dPres[a], @@ -704,19 +705,19 @@ AccumulationKernel:: // local accumulation localAccum[NC+1] = phaseEnergyNew - phaseEnergyOld + solidEnergyNew - solidEnergyOld; - real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dP[ip]; - real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dT[ip]; + real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dPres[ip]; + real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dTemp[ip]; - real64 const dSolidInternalEnergy_dP = -dPoro_dP * volNew * rockInternalEnergyNew * rockDensity; + real64 const dSolidInternalEnergy_dP = -dPoro_dP * volNew * rockInternalEnergy * rockDensity; // TODO porosity and volume may depend on temperature real64 const dSolidInternalEnergy_dT = (1 - poroNew) * volNew * dRockInternalEnergy_dTemp; // derivatives w.r.t. pressure and temperature - localAccumJacobian[NC+1][0] += dPhaseEnergy_dP; + localAccumJacobian[NC+1][0] += dPhaseEnergy_dP + dSolidInternalEnergy_dP; localAccumJacobian[NC+1][NC+2] += dPhaseEnergy_dT + dSolidInternalEnergy_dT; // derivatives w.r.t. component densities - applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseIntenalEnergy_dC ); + applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); for ( localIndex jc = 0; jc < NC; ++jc ) { real64 const dPhaseEnergy_dC = phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + @@ -762,9 +763,9 @@ AccumulationKernel:: arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, arrayView1d< real64 const > const & rockInternalEnergyOld, - arrayView1d< real64 const > const & rockInternalEnergy, - arrayView1d< real64 const > const & dRockInternalEnergy_dTemp, - arrayView1d< real64 const > const & rockDensity, + arrayView2d< real64 const > const & rockInternalEnergy, + arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, + arrayView2d< real64 const > const & rockDensity, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { @@ -809,7 +810,7 @@ AccumulationKernel:: rockInternalEnergyOld[ei], rockInternalEnergy[ei][0], dRockInternalEnergy_dTemp[ei][0], - rockDensity[ei], + rockDensity[ei][0], localAccum, localAccumJacobian ); @@ -864,14 +865,14 @@ AccumulationKernel:: arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, \ arrayView5d< real64 const > const & dPhaseCompFrac_dComp, \ arrayView2d< real64 const > const & phaseInternalEnergyOld, \ - arrayView2d< real64 const > const & phaseInternalEnergy, \ - arrayView2d< real64 const > const & dPhaseInternalEnergy_dPres, \ - arrayView2d< real64 const > const & dPhaseInternalEnergy_dTemp, \ - arrayView3d< real64 const > const & dPhaseInternalEnergy_dComp, \ + arrayView3d< real64 const > const & phaseInternalEnergy, \ + arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, \ + arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, \ + arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, \ arrayView1d< real64 const > const & rockInternalEnergyOld, \ - arrayView1d< real64 const > const & rockInternalEnergy, \ - arrayView1d< real64 const > const & dRockInternalEnergy_dTemp, \ - arrayView1d< real64 const > const & rockDensity, \ + arrayView2d< real64 const > const & rockInternalEnergy, \ + arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, \ + arrayView2d< real64 const > const & rockDensity, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ arrayView1d< real64 > const & localRhs ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index df9389cb151..f4016ad363c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -74,20 +74,20 @@ struct PhaseVolumeFractionKernel GEOSX_FORCE_INLINE static void Compute( arraySlice1d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView3d< real64 const > const & dCompFrac_dCompDens, - arrayView3d< real64 const > const & phaseDens, - arrayView3d< real64 const > const & dPhaseDens_dPres, - arrayView3d< real64 const > const & dPhaseDens_dTemp, - arrayView4d< real64 const > const & dPhaseDens_dComp, - arrayView3d< real64 const > const & phaseFrac, - arrayView3d< real64 const > const & dPhaseFrac_dPres, - arrayView3d< real64 const > const & dPhaseFrac_dTemp, - arrayView4d< real64 const > const & dPhaseFrac_dComp, - arrayView2d< real64 > const & phaseVolFrac, - arrayView2d< real64 > const & dPhaseVolFrac_dPres, - arrayView2d< real64 > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 > const & dPhaseVolFrac_dComp ); + arraySlice1d< real64 const > const & dCompDens, + arraySlice2d< real64 const > const & dCompFrac_dCompDens, + arraySlice1d< real64 const > const & phaseDens, + arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice1d< real64 const > const & dPhaseDens_dTemp, + arraySlice2d< real64 const > const & dPhaseDens_dComp, + arraySlice1d< real64 const > const & phaseFrac, + arraySlice1d< real64 const > const & dPhaseFrac_dPres, + arraySlice1d< real64 const > const & dPhaseFrac_dTemp, + arraySlice2d< real64 const > const & dPhaseFrac_dComp, + arraySlice1d< real64 > const & phaseVolFrac, + arraySlice1d< real64 > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 > const & dPhaseVolFrac_dTemp, + arraySlice2d< real64 > const & dPhaseVolFrac_dComp ); template< localIndex NC, localIndex NP > static void @@ -142,16 +142,20 @@ struct PhaseMobilityKernel Compute( arraySlice2d< real64 const > const & dCompFrac_dCompDens, arraySlice1d< real64 const > const & phaseDens, arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice1d< real64 const > const & dPhaseDens_dTemp, arraySlice2d< real64 const > const & dPhaseDens_dComp, arraySlice1d< real64 const > const & phaseVisc, arraySlice1d< real64 const > const & dPhaseVisc_dPres, + arraySlice1d< real64 const > const & dPhaseVisc_dTemp, arraySlice2d< real64 const > const & dPhaseVisc_dComp, arraySlice1d< real64 const > const & phaseRelPerm, arraySlice2d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dComp, arraySlice1d< real64 > const & phaseMob, arraySlice1d< real64 > const & dPhaseMob_dPres, + arraySlice1d< real64 > const & dPhaseMob_dTemp, arraySlice2d< real64 > const & dPhaseMob_dComp ); template< localIndex NC, localIndex NP > @@ -160,16 +164,20 @@ struct PhaseMobilityKernel arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseVisc, arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView3d< real64 const > const & dPhaseVisc_dTemp, arrayView4d< real64 const > const & dPhaseVisc_dComp, arrayView3d< real64 const > const & phaseRelPerm, arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dComp, arrayView2d< real64 > const & phaseMob, arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView2d< real64 > const & dPhaseMob_dTemp, arrayView3d< real64 > const & dPhaseMob_dComp ); template< localIndex NC, localIndex NP > @@ -178,16 +186,20 @@ struct PhaseMobilityKernel arrayView3d< real64 const > const & dCompFrac_dCompDens, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseVisc, arrayView3d< real64 const > const & dPhaseVisc_dPres, + arrayView3d< real64 const > const & dPhaseVisc_dTemp, arrayView4d< real64 const > const & dPhaseVisc_dComp, arrayView3d< real64 const > const & phaseRelPerm, arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dComp, arrayView2d< real64 > const & phaseMob, arrayView2d< real64 > const & dPhaseMob_dPres, + arrayView2d< real64 > const & dPhaseMob_dTemp, arrayView3d< real64 > const & dPhaseMob_dComp ); }; @@ -363,17 +375,29 @@ struct AccumulationKernel arraySlice1d< real64 const > const & phaseVolFracOld, arraySlice1d< real64 const > const & phaseVolFrac, arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, arraySlice1d< real64 const > const & phaseDensOld, arraySlice1d< real64 const > const & phaseDens, arraySlice1d< real64 const > const & dPhaseDens_dPres, + arraySlice1d< real64 const > const & dPhaseDens_dTemp, arraySlice2d< real64 const > const & dPhaseDens_dComp, arraySlice2d< real64 const > const & phaseCompFracOld, arraySlice2d< real64 const > const & phaseCompFrac, arraySlice2d< real64 const > const & dPhaseCompFrac_dPres, + arraySlice2d< real64 const > const & dPhaseCompFrac_dTemp, arraySlice3d< real64 const > const & dPhaseCompFrac_dComp, - real64 ( &localAccum )[NC], - real64 ( &localAccumJacobian )[NC][NC+1] ); + arraySlice1d< real64 const > const & phaseInternalEnergyOld, + arraySlice1d< real64 const > const & phaseInternalEnergy, + arraySlice1d< real64 const > const & dPhaseInternalEnergy_dPres, + arraySlice1d< real64 const > const & dPhaseInternalEnergy_dTemp, + arraySlice2d< real64 const > const & dPhaseInternalEnergy_dComp, + real64 const & rockInternalEnergyOld, + real64 const & rockInternalEnergy, + real64 const & dRockInternalEnergy_dTemp, + real64 const & rockDensity, + real64 ( & localAccum )[NC + 1], + real64 ( & localAccumJacobian )[NC + 1][NC + 2] ); template< localIndex NC > static void @@ -391,15 +415,27 @@ struct AccumulationKernel arrayView2d< real64 const > const & phaseVolFracOld, arrayView2d< real64 const > const & phaseVolFrac, arrayView2d< real64 const > const & dPhaseVolFrac_dPres, + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, arrayView2d< real64 const > const & phaseDensOld, arrayView3d< real64 const > const & phaseDens, arrayView3d< real64 const > const & dPhaseDens_dPres, + arrayView3d< real64 const > const & dPhaseDens_dTemp, arrayView4d< real64 const > const & dPhaseDens_dComp, arrayView3d< real64 const > const & phaseCompFracOld, arrayView4d< real64 const > const & phaseCompFrac, arrayView4d< real64 const > const & dPhaseCompFrac_dPres, + arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, arrayView5d< real64 const > const & dPhaseCompFrac_dComp, + arrayView2d< real64 const > const & phaseInternalEnergyOld, + arrayView3d< real64 const > const & phaseInternalEnergy, + arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, + arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, + arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, + arrayView1d< real64 const > const & rockInternalEnergyOld, + arrayView2d< real64 const > const & rockInternalEnergy, + arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, + arrayView2d< real64 const > const & rockDensity, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ); }; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp index a6f40952216..38f9c3f37cc 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp @@ -406,6 +406,62 @@ struct VolumeBalanceKernel }; +/******************************** Kernel launch machinery ********************************/ + +namespace internal +{ + +template< typename T, typename LAMBDA > +void KernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) +{ + static_assert( std::is_integral< T >::value, "KernelLaunchSelectorCompSwitch: type should be integral" ); + + switch( value ) + { + case 1: + { lambda( std::integral_constant< T, 1 >() ); return; } + case 2: + { lambda( std::integral_constant< T, 2 >() ); return; } + case 3: + { lambda( std::integral_constant< T, 3 >() ); return; } + case 4: + { lambda( std::integral_constant< T, 4 >() ); return; } + case 5: + { lambda( std::integral_constant< T, 5 >() ); return; } + default: + { GEOSX_ERROR( "Unsupported number of components: " << value ); } + } +} + +} // namespace helpers + +template< typename KERNELWRAPPER, typename ... ARGS > +void KernelLaunchSelector1( localIndex numComp, ARGS && ... args ) +{ + internal::KernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + KERNELWRAPPER::template Launch< NC() >( std::forward< ARGS >( args )... ); + } ); +} + +template< typename KERNELWRAPPER, typename ... ARGS > +void KernelLaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ) +{ + internal::KernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + switch( numPhase ) + { + case 2: + { KERNELWRAPPER::template Launch< NC(), 2 >( std::forward< ARGS >( args )... ); return; } + case 3: + { KERNELWRAPPER::template Launch< NC(), 3 >( std::forward< ARGS >( args )... ); return; } + default: + { GEOSX_ERROR( "Unsupported number of phases: " << numPhase ); } + } + } ); +} + + } // namespace IsotherCompositionalMultiphaseFlowKernels } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp index e0e4cebff37..ddb56b139ed 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp @@ -32,6 +32,7 @@ #include "mesh/MeshForLoopInterface.hpp" #include "meshUtilities/PerforationData.hpp" #include "meshUtilities/ComputationalGeometry.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp" #include "physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp" #include "physicsSolvers/fluidFlow/wells/SinglePhaseWellKernels.hpp" @@ -357,7 +358,7 @@ void CompositionalMultiphaseWell::UpdateFluidModel( WellElementSubRegion & subRe { typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); - CompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( subRegion.size(), + IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( subRegion.size(), fluidWrapper, pres, dPres, @@ -398,7 +399,7 @@ void CompositionalMultiphaseWell::UpdatePhaseVolumeFraction( WellElementSubRegio arrayView3d< real64 const > const & dPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); arrayView4d< real64 const > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); - CompositionalMultiphaseFlowKernels::KernelLaunchSelector2< CompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel + IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2< IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( NumFluidComponents(), NumFluidPhases(), subRegion.size(), compDens, @@ -542,7 +543,7 @@ void CompositionalMultiphaseWell::InitializeWells( DomainPartition & domain ) { typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); - CompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( subRegion.size(), + IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( subRegion.size(), fluidWrapper, wellElemPressure, m_temperature, From 2d4d8604e2669ae6d6bc6d98b2473658b91e1656 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Wed, 23 Dec 2020 11:42:30 -0800 Subject: [PATCH 11/34] missing only intEnergy for solid material. --- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 26 ++- .../CompositionalMultiphaseFlowKernels.cpp | 52 +++-- .../CompositionalMultiphaseFlowKernels.hpp | 4 +- .../integratedTests/CO2Thermal.xml | 209 ++++++++++++++++++ 4 files changed, 263 insertions(+), 28 deletions(-) create mode 100644 src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index d0581876d65..e0519b062cd 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -512,6 +512,9 @@ void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localI arrayView2d< real64 > const dPhaseMob_dTemp = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + arrayView2d< real64 const > const dPhaseVolFrac_dTemp = + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, dataGroup.size(), @@ -939,9 +942,9 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con arrayView1d< real64 const > const & rockInternalEnergyOld = subRegion.getReference< array1d< real64 > >(viewKeyStruct::rockInternalEnergyOldString ); - arrayView1d< real64 const > const & rockInternalEnergy = solid.internalEnergy(); - arrayView1d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); - arrayView1d< real64 const > const & rockDensity = solid.density(); + arrayView2d< real64 const > const & rockInternalEnergy = solid.internalEnergy(); + arrayView2d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); + arrayView2d< real64 const > const & rockDensity = solid.density(); CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, @@ -971,7 +974,7 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con dPhaseCompFrac_dPres, dPhaseCompFrac_dTemp, dPhaseCompFrac_dComp, - phaseInternalEnergyOld[ei], + phaseInternalEnergyOld, phaseInternalEnergy, dPhaseInternalEnergy_dPres, dPhaseInternalEnergy_dTemp, @@ -1387,11 +1390,11 @@ void CompositionalMultiphaseFlow::ApplyDirichletBC( real64 const time, typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); // MultiFluid models are not thread-safe or device-capable yet - FluidUpdateKernel::Launch< serialPolicy >( targetSet, - fluidWrapper, - bcPres, - m_temperature, - compFrac ); + IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( targetSet, + fluidWrapper, + bcPres, + m_uniformTemperature, + compFrac ); } ); forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) @@ -1438,6 +1441,8 @@ real64 CompositionalMultiphaseFlow::CalculateResidualNorm( DomainPartition const globalIndex const rankOffset = dofManager.rankOffset(); string const dofKey = dofManager.getKey( viewKeyStruct::dofFieldString ); + real64 residual; + if ( m_isothermalFlag ) { localIndex const NDOF = m_numComponents + 1; @@ -1475,7 +1480,7 @@ real64 CompositionalMultiphaseFlow::CalculateResidualNorm( DomainPartition const } ); // compute global residual norm - real64 const residual = std::sqrt( MpiWrapper::Sum( localResidualNorm ) ); + residual = std::sqrt( MpiWrapper::Sum( localResidualNorm ) ); if( getLogLevel() >= 1 && logger::internal::rank==0 ) { @@ -1527,6 +1532,7 @@ real64 CompositionalMultiphaseFlow::CalculateResidualNorm( DomainPartition const real64 const flowResidual = std::sqrt( MpiWrapper::Sum( localFlowResidualNorm ) ); real64 const energyResidual = std::sqrt( MpiWrapper::Sum( localEnergyResidualNorm ) ); + residual = ( flowResidual + energyResidual ) / 2; if( getLogLevel() >= 1 && logger::internal::rank==0 ) { char output[200] = {0}; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index fb03678f426..990e8157df3 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -703,7 +703,7 @@ AccumulationKernel:: real64 const solidEnergyOld = (1 - poroOld) * volOld * rockInternalEnergyOld * rockDensity; // local accumulation - localAccum[NC+1] = phaseEnergyNew - phaseEnergyOld + solidEnergyNew - solidEnergyOld; + localAccum[NC] = phaseEnergyNew - phaseEnergyOld + solidEnergyNew - solidEnergyOld; real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dPres[ip]; real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dTemp[ip]; @@ -713,8 +713,8 @@ AccumulationKernel:: real64 const dSolidInternalEnergy_dT = (1 - poroNew) * volNew * dRockInternalEnergy_dTemp; // derivatives w.r.t. pressure and temperature - localAccumJacobian[NC+1][0] += dPhaseEnergy_dP + dSolidInternalEnergy_dP; - localAccumJacobian[NC+1][NC+2] += dPhaseEnergy_dT + dSolidInternalEnergy_dT; + localAccumJacobian[NC][0] += dPhaseEnergy_dP + dSolidInternalEnergy_dP; + localAccumJacobian[NC][NC+1] += dPhaseEnergy_dT + dSolidInternalEnergy_dT; // derivatives w.r.t. component densities applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); @@ -723,7 +723,7 @@ AccumulationKernel:: real64 const dPhaseEnergy_dC = phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; - localAccumJacobian[NC+1][jc + 1] += dPhaseEnergy_dC; + localAccumJacobian[NC][jc + 1] += dPhaseEnergy_dC; } } } @@ -933,6 +933,11 @@ FluxKernel:: localIndex constexpr NDOF = NC + 2; localIndex const NP = numPhases; + // they will be useful for conduction + GEOSX_UNUSED_VAR( temp ); + GEOSX_UNUSED_VAR( dTemp ); + GEOSX_UNUSED_VAR( phaseVolFrac ); + real64 compFlux[NC]{}; real64 dCompFlux_dP[MAX_STENCIL][NC]{}; real64 dCompFlux_dT[MAX_STENCIL][NC]{}; @@ -982,7 +987,7 @@ FluxKernel:: // density real64 const density = phaseMassDens[er][esr][ei][0][ip]; real64 const dDens_dP = dPhaseMassDens_dPres[er][esr][ei][0][ip]; - real64 const dDens_dT = dPhaseMassDens_dT[er][esr][ei][0][ip]; + real64 const dDens_dT = dPhaseMassDens_dTemp[er][esr][ei][0][ip]; applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], @@ -1121,6 +1126,7 @@ FluxKernel:: } real64 const dMob_dP = dPhaseMob_dPres[er_up][esr_up][ei_up][ip]; + real64 const dMob_dT = dPhaseMob_dTemp[er_up][esr_up][ei_up][ip]; arraySlice1d< real64 const > dPhaseMob_dCompSub = dPhaseMob_dComp[er_up][esr_up][ei_up][ip]; // add contribution from upstream cell mobility derivatives @@ -1166,22 +1172,32 @@ FluxKernel:: dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; } } + // compute enthalpy fluxes and derivatives - enthalpyFlux += phaseFlux * phaseEnthalpy[ip]; + real64 const enthalpy = phaseEnthalpy[er_up][esr_up][ei_up][0][ip]; + enthalpyFlux = phaseFlux * enthalpy; - // derivatives stemming from phase flux + // derivatives stemming from phase flux (it was upwinded previously) for( localIndex ke = 0; ke < stencilSize; ++ke ) { - dEnthalpyFlux_dP[ke] += dPhaseFlux_dP[ke] * phaseEnthalpy[ip] + phaseFlux[ke] * dPhaseEnthalpy_dPres[ip]; - dEnthalpyFlux_dT[ke] += dPhaseFlux_dT[ke] * phaseEnthalpy[ip] + phaseFlux[ke] * dPhaseEnthalpy_dTemp[ip]; + dEnthalpyFlux_dP[ke] = dPhaseFlux_dP[ke] * enthalpy; + dEnthalpyFlux_dT[ke] = dPhaseFlux_dT[ke] * enthalpy; - applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseEnthalpy_dComp[er_up][esr_up][ei_up][0][ip], dProp_dC ); for( localIndex jc = 0; jc < NC; ++jc ) { - dEnthalpyFlux_dC[ke][jc] += dPhaseFlux_dC[ke][jc] * phaseEnthalpy[ip] + phaseFlux[ke] * dProp_dC[jc]; + dEnthalpyFlux_dC[ke][jc] = dPhaseFlux_dC[ke][jc] * enthalpy; } } + // add contribution from upstream cell enthalpy derivatives + dEnthalpyFlux_dP[k_up] += phaseFlux * dPhaseEnthalpy_dPres[er_up][esr_up][ei_up][0][ip]; + dEnthalpyFlux_dT[k_up] += phaseFlux * dPhaseEnthalpy_dTemp[er_up][esr_up][ei_up][0][ip]; + + applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseEnthalpy_dComp[er_up][esr_up][ei_up][0][ip], dProp_dC ); + for( localIndex jc = 0; jc < NC; ++jc ) + { + dEnthalpyFlux_dC[k_up][jc] += phaseFlux * dProp_dC[jc]; + } } // *** end of upwinding @@ -1213,17 +1229,17 @@ FluxKernel:: } // enthalpy flux - localFlux[NC] = dt * enthalpyFlux; + localFlux[NC] = dt * enthalpyFlux; localFlux[2 * NC - 1] = -dt * enthalpyFlux; for( localIndex ke = 0; ke < stencilSize; ++ke ) { localIndex const localDofIndexPres = ke * NDOF; - localFluxJacobian[NC][localDofIndexPres] = dt * dEnthalpyFlux_dP[ke][ic]; - localFluxJacobian[2*NC - 1][localDofIndexPres] = -dt * dEnthalpyFlux_dP[ke][ic]; + localFluxJacobian[NC][localDofIndexPres] = dt * dEnthalpyFlux_dP[ke]; + localFluxJacobian[2*NC - 1][localDofIndexPres] = -dt * dEnthalpyFlux_dP[ke]; localIndex const localDofIndexTemp = localDofIndexPres + NC; - localFluxJacobian[NC][localDofIndexTemp] = dt * dCompFlux_dT[ke][ic]; - localFluxJacobian[2*NC - 1][localDofIndexTemp] = -dt * dEnthalpyFlux_dT[ke][ic]; + localFluxJacobian[NC][localDofIndexTemp] = dt * dEnthalpyFlux_dT[ke]; + localFluxJacobian[2*NC - 1][localDofIndexTemp] = -dt * dEnthalpyFlux_dT[ke]; for( localIndex jc = 0; jc < NC; ++jc ) { @@ -1241,6 +1257,8 @@ FluxKernel:: Launch( localIndex const numPhases, STENCIL_TYPE const & stencil, globalIndex const rankOffset, + ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, + ElementViewConst< arrayView1d< integer const > > const & ghostRank, ElementViewConst< arrayView1d< real64 const > > const & pres, ElementViewConst< arrayView1d< real64 const > > const & dPres, ElementViewConst< arrayView1d< real64 const > > const & gravCoef, @@ -1302,7 +1320,7 @@ FluxKernel:: gravCoef, phaseMob, dPhaseMob_dPres, - dPhaseMob_dPres, + dPhaseMob_dTemp, dPhaseMob_dComp, phaseVolFrac, dPhaseVolFrac_dPres, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index f4016ad363c..bdeed51055e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -512,6 +512,7 @@ struct FluxKernel ElementViewConst< arrayView1d< real64 const > > const & gravCoef, ElementViewConst< arrayView2d< real64 const > > const & phaseMob, ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, @@ -522,6 +523,7 @@ struct FluxKernel ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, + ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, @@ -559,7 +561,7 @@ struct VolumeBalanceKernel arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, real64 & localVolBalance, - real64 * const localVolBalanceJacobian ); + real64 (& localVolBalanceJacobian)[NC+2] ); template< localIndex NC, localIndex NP > static void diff --git a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml new file mode 100644 index 00000000000..f4476f34d9d --- /dev/null +++ b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 75293642849e6f1614483b782b79e0c5643a35f1 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Wed, 23 Dec 2020 18:31:41 -0800 Subject: [PATCH 12/34] down to 1 linking error. --- .../constitutive/solid/SolidBase.cpp | 4 ++ .../constitutive/solid/SolidBase.hpp | 22 +++++++++- .../physicsSolvers/CMakeLists.txt | 2 + .../fluidFlow/CompositionalMultiphaseFlow.cpp | 40 ++++++++++++++++++- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/coreComponents/constitutive/solid/SolidBase.cpp b/src/coreComponents/constitutive/solid/SolidBase.cpp index 6be8fa827ad..24e4cb29e51 100644 --- a/src/coreComponents/constitutive/solid/SolidBase.cpp +++ b/src/coreComponents/constitutive/solid/SolidBase.cpp @@ -63,6 +63,10 @@ void SolidBase::allocateConstitutiveData( dataRepository::Group * const parent, { m_density.resize( 0, numConstitutivePointsPerParentIndex ); m_stress.resize( 0, numConstitutivePointsPerParentIndex, 6 ); + m_internalEnergy.resize( parent->size(), numConstitutivePointsPerParentIndex ); + m_dInternalEnergy_dTemperature.resize( parent->size(), numConstitutivePointsPerParentIndex ); + m_internalEnergy.setValues< serialPolicy >(0.0); + m_dInternalEnergy_dTemperature.setValues< serialPolicy >(0.0); ConstitutiveBase::allocateConstitutiveData( parent, numConstitutivePointsPerParentIndex ); } diff --git a/src/coreComponents/constitutive/solid/SolidBase.hpp b/src/coreComponents/constitutive/solid/SolidBase.hpp index 0d7f76f3d7b..71ea2133d00 100644 --- a/src/coreComponents/constitutive/solid/SolidBase.hpp +++ b/src/coreComponents/constitutive/solid/SolidBase.hpp @@ -208,6 +208,8 @@ class SolidBase : public constitutive::ConstitutiveBase static constexpr auto defaultDensityString = "defaultDensity"; static constexpr auto densityString = "density"; static constexpr auto stressString = "stress"; + static constexpr auto internalEnergyString = "internalEnergy"; + static constexpr auto dInternalEnergy_dTemperatureString = "dInternalEnergy_dTemperature"; }; /** @@ -245,6 +247,19 @@ class SolidBase : public constitutive::ConstitutiveBase /// Const/non-mutable accessor for stress arrayView3d< real64 const, solid::STRESS_USD > getStress() const { return m_stress; } + /// Non-const/Mutable accessor for internal energy. + arrayView2d< real64 > internalEnergy() { return m_internalEnergy; } + + /// Const/non-mutable accessor for internal energy + arrayView2d< real64 const > internalEnergy() const { return m_internalEnergy; } + + /// Non-const/Mutable accessor for internal energy. + arrayView2d< real64 > dInternalEnergy_dTemperature() { return m_dInternalEnergy_dTemperature; } + + /// Const/non-mutable accessor for internal energy + arrayView2d< real64 const > dInternalEnergy_dTemperature() const { return m_dInternalEnergy_dTemperature; } + + ///@} protected: @@ -257,8 +272,13 @@ class SolidBase : public constitutive::ConstitutiveBase array2d< real64 > m_density; /// The material stress at a quadrature point. - array3d< real64, solid::STRESS_PERMUTATION > m_stress; + + /// The material internal energy + array2d< real64 > m_internalEnergy; + + /// The material internal Energy as a function of the temperature + array2d< real64 > m_dInternalEnergy_dTemperature; }; } // namespace constitutive diff --git a/src/coreComponents/physicsSolvers/CMakeLists.txt b/src/coreComponents/physicsSolvers/CMakeLists.txt index fd898ec8fc8..232f9cc4250 100644 --- a/src/coreComponents/physicsSolvers/CMakeLists.txt +++ b/src/coreComponents/physicsSolvers/CMakeLists.txt @@ -12,6 +12,7 @@ set( physicsSolvers_headers SolverBase.hpp fluidFlow/CompositionalMultiphaseFlow.hpp fluidFlow/CompositionalMultiphaseFlowKernels.hpp + fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp fluidFlow/FlowSolverBase.hpp fluidFlow/ProppantTransport.hpp fluidFlow/ProppantTransportKernels.hpp @@ -65,6 +66,7 @@ set( physicsSolvers_sources SolverBase.cpp fluidFlow/CompositionalMultiphaseFlow.cpp fluidFlow/CompositionalMultiphaseFlowKernels.cpp + fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp fluidFlow/FlowSolverBase.cpp fluidFlow/ProppantTransport.cpp fluidFlow/ProppantTransportKernels.cpp diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index e0519b062cd..505ca3dd786 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -34,6 +34,7 @@ #include "mpiCommunications/MpiWrapper.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp" +#include "constitutive/solid/SolidBase.hpp" #if defined( __INTEL_COMPILER ) #pragma GCC optimize "O0" @@ -783,6 +784,41 @@ void CompositionalMultiphaseFlow::BackupFields( MeshLevel & mesh ) const poroOld[ei] = poroRef[ei] * pvMult[ei][0]; } ); } ); + + // backup thermal fields + if ( m_isothermalFlag == 0 ) + { + forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) + { + MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, fluidModelNames()[targetIndex] ); + SolidBase const & solid = GetConstitutiveModel< SolidBase >( subRegion, solidModelNames()[targetIndex] ); + + arrayView1d< integer const > const elemGhostRank = subRegion.ghostRank(); + + arrayView3d< real64 const > const phaseInternalEnergy = fluid.phaseInternalEnergy(); + arrayView2d< real64 const > const rockInternalEnergy = solid.internalEnergy(); + + arrayView2d< real64 > const phaseInternalEnergyOld = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); + arrayView1d< real64 > rockInternalEnergyOld = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString ); + + localIndex const NP = m_numPhases; + + forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( elemGhostRank[ei] >= 0 ) + return; + + for( localIndex ip = 0; ip < NP; ++ip ) + { + phaseInternalEnergyOld[ei][ip] = phaseInternalEnergy[ei][0][ip]; + rockInternalEnergyOld[ei] = rockInternalEnergy[ei][0]; + } + + } ); + } ); + } } void @@ -881,7 +917,7 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con arrayView3d< real64 const > const & phaseCompFracOld = subRegion.getReference< array3d< real64 > >( viewKeyStruct::phaseComponentFractionOldString ); - ConstitutiveBase const & solid = GetConstitutiveModel( subRegion, solidModelNames()[targetIndex] ); + SolidBase const & solid = GetConstitutiveModel< SolidBase >( subRegion, solidModelNames()[targetIndex] ); arrayView2d< real64 const > const & pvMult = solid.getReference< array2d< real64 > >( ConstitutiveBase::viewKeyStruct::poreVolumeMultiplierString ); arrayView2d< real64 const > const & dPvMult_dPres = @@ -944,7 +980,7 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con subRegion.getReference< array1d< real64 > >(viewKeyStruct::rockInternalEnergyOldString ); arrayView2d< real64 const > const & rockInternalEnergy = solid.internalEnergy(); arrayView2d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); - arrayView2d< real64 const > const & rockDensity = solid.density(); + arrayView2d< real64 const > const & rockDensity = solid.getDensity(); CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, From 86d65994a9e053ca8dcdeebe0223492c1c079290 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Sat, 26 Dec 2020 12:49:36 -0800 Subject: [PATCH 13/34] Finally builds. --- .../constitutive/fluid/MultiFluidBase.hpp | 2 +- .../fluid/MultiPhaseMultiComponentFluid.cpp | 24 +- .../fluid/MultiPhaseMultiComponentFluid.hpp | 2 +- .../PVTFunctions/BrineEnthalpyFunction.cpp | 10 +- .../BrineInternalEnergyFunction.cpp | 10 +- .../PVTFunctions/CO2EnthalpyFunction.cpp | 10 +- .../CO2InternalEnergyFunction.cpp | 10 +- .../constitutive/solid/SolidBase.cpp | 4 +- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 600 +++++++++--------- .../CompositionalMultiphaseFlowKernels.cpp | 94 +-- .../CompositionalMultiphaseFlowKernels.hpp | 24 +- ...rmalCompositionalMultiphaseFlowKernels.cpp | 4 - .../wells/CompositionalMultiphaseWell.cpp | 46 +- 13 files changed, 434 insertions(+), 406 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index 50f084eb199..468f30660ec 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -122,7 +122,7 @@ class MultiFluidBaseUpdate m_dTotalDensity_dTemperature( dTotalDensity_dTemperature ), m_dTotalDensity_dGlobalCompFraction( dTotalDensity_dGlobalCompFraction ), m_phaseEnthalpy( phaseEnthalpy ), - m_dPhaseEnthalpy_dPressure(dPhaseEnthalpy_dPressure), + m_dPhaseEnthalpy_dPressure( dPhaseEnthalpy_dPressure ), m_dPhaseEnthalpy_dTemperature( dPhaseEnthalpy_dTemperature ), m_dPhaseEnthalpy_dGlobalCompFraction( dPhaseEnthalpy_dGlobalCompFraction ), m_phaseInternalEnergy( phaseInternalEnergy ), diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp index 4ecf862ad91..004dd8f16e6 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp @@ -133,14 +133,14 @@ void MultiPhaseMultiComponentFluid::CreatePVTModels() m_componentNames, m_componentMolarWeight ) ); } - else if (strs[0] == "EnthalpyFun") + else if( strs[0] == "EnthalpyFun" ) { m_phaseEnthalpyFuns.emplace_back( PVTFunction::CatalogInterface::Factory( strs[ 1 ], strs, m_componentNames, m_componentMolarWeight ) ); } - else if (strs[0] == "InternalEnergyFun") + else if( strs[0] == "InternalEnergyFun" ) { m_phaseInternalEnergyFuns.emplace_back( PVTFunction::CatalogInterface::Factory( strs[ 1 ], strs, @@ -288,18 +288,18 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, }; CompositionalVarContainer< 1 > phaseEnt { - phaseEnthalpy, - dPhaseEnthalpy_dPressure, - dPhaseEnthalpy_dTemperature, - dPhaseEnthalpy_dGlobalCompFraction - }; + phaseEnthalpy, + dPhaseEnthalpy_dPressure, + dPhaseEnthalpy_dTemperature, + dPhaseEnthalpy_dGlobalCompFraction + }; CompositionalVarContainer< 1 > phaseIntEner { - phaseInternalEnergy, - dPhaseInternalEnergy_dPressure, - dPhaseInternalEnergy_dTemperature, - dPhaseInternalEnergy_dGlobalCompFraction - }; + phaseInternalEnergy, + dPhaseInternalEnergy_dPressure, + dPhaseInternalEnergy_dTemperature, + dPhaseInternalEnergy_dGlobalCompFraction + }; #if defined(__CUDACC__) // For some reason nvcc thinks these aren't used. diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index a31ca61b8fd..3cb65536417 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -90,7 +90,7 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate arrayView3d< real64 > const & phaseInternalEnergy, arrayView3d< real64 > const & dPhaseInternalEnergy_dPressure, arrayView3d< real64 > const & dPhaseInternalEnergy_dTemperature, - arrayView4d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction) + arrayView4d< real64 > const & dPhaseInternalEnergy_dGlobalCompFraction ) : MultiFluidBaseUpdate( componentMolarWeight, useMass, phaseFraction, diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp index bd57576ba68..fab8fc5bc3c 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp @@ -26,11 +26,17 @@ using namespace stringutilities; namespace PVTProps { +BrineEnthalpyFunction::BrineEnthalpyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ): + PVTFunction( inputPara[1], componentNames, componentMolarWeight ) +{} + void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { - GEOSX_UNUSED_VAR(phaseComposition); - GEOSX_UNUSED_VAR(useMass); + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( useMass ); localIndex const numComponents = phaseComposition.size(); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp index b612bc59587..aa2d9ff7646 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp @@ -26,11 +26,17 @@ using namespace stringutilities; namespace PVTProps { +BrineInternalEnergyFunction::BrineInternalEnergyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ): + PVTFunction( inputPara[1], componentNames, componentMolarWeight ) +{} + void BrineInternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { - GEOSX_UNUSED_VAR(phaseComposition); - GEOSX_UNUSED_VAR(useMass); + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( useMass ); localIndex const numComponents = phaseComposition.size(); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp index fcd25dcceab..30b3386a90c 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp @@ -26,11 +26,17 @@ using namespace stringutilities; namespace PVTProps { +CO2EnthalpyFunction::CO2EnthalpyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ): + PVTFunction( inputPara[1], componentNames, componentMolarWeight ) +{} + void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { - GEOSX_UNUSED_VAR(phaseComposition); - GEOSX_UNUSED_VAR(useMass); + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( useMass ); localIndex const numComponents = phaseComposition.size(); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp index 114cec77e0f..59d9009e7ca 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp @@ -26,11 +26,17 @@ using namespace stringutilities; namespace PVTProps { +CO2InternalEnergyFunction::CO2InternalEnergyFunction( string_array const & inputPara, + string_array const & componentNames, + real64_array const & componentMolarWeight ): + PVTFunction( inputPara[1], componentNames, componentMolarWeight ) +{} + void CO2InternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { - GEOSX_UNUSED_VAR(phaseComposition); - GEOSX_UNUSED_VAR(useMass); + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( useMass ); localIndex const numComponents = phaseComposition.size(); diff --git a/src/coreComponents/constitutive/solid/SolidBase.cpp b/src/coreComponents/constitutive/solid/SolidBase.cpp index 24e4cb29e51..a967b0e3ff8 100644 --- a/src/coreComponents/constitutive/solid/SolidBase.cpp +++ b/src/coreComponents/constitutive/solid/SolidBase.cpp @@ -65,8 +65,8 @@ void SolidBase::allocateConstitutiveData( dataRepository::Group * const parent, m_stress.resize( 0, numConstitutivePointsPerParentIndex, 6 ); m_internalEnergy.resize( parent->size(), numConstitutivePointsPerParentIndex ); m_dInternalEnergy_dTemperature.resize( parent->size(), numConstitutivePointsPerParentIndex ); - m_internalEnergy.setValues< serialPolicy >(0.0); - m_dInternalEnergy_dTemperature.setValues< serialPolicy >(0.0); + m_internalEnergy.setValues< serialPolicy >( 0.0 ); + m_dInternalEnergy_dTemperature.setValues< serialPolicy >( 0.0 ); ConstitutiveBase::allocateConstitutiveData( parent, numConstitutivePointsPerParentIndex ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index 505ca3dd786..71623439b0b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -64,10 +64,10 @@ CompositionalMultiphaseFlow::CompositionalMultiphaseFlow( const string & name, setInputFlag( InputFlags::REQUIRED )-> setDescription( "Uniform temperature for isothermal simulations." ); - this->registerWrapper(viewKeyStruct::isothermalFlagString, &m_isothermalFlag)-> - setApplyDefaultValue( 1 )-> - setInputFlag( InputFlags::OPTIONAL )-> - setDescription("Flag indicating whether the problem is isothermal or not."); + this->registerWrapper( viewKeyStruct::isothermalFlagString, &m_isothermalFlag )-> + setApplyDefaultValue( 1 )-> + setInputFlag( InputFlags::OPTIONAL )-> + setDescription( "Flag indicating whether the problem is isothermal or not." ); this->registerWrapper( viewKeyStruct::useMassFlagString, &m_useMass )-> setApplyDefaultValue( 0 )-> @@ -161,25 +161,25 @@ void CompositionalMultiphaseFlow::RegisterDataOnMesh( Group * const MeshBodies ) elementSubRegion.registerWrapper< array3d< real64 > >( viewKeyStruct::phaseComponentFractionOldString ); elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::porosityOldString ); - if (m_isothermalFlag == 0) + if( m_isothermalFlag == 0 ) { - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString )-> - setPlotLevel( PlotLevel::LEVEL_0 ); + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString )-> + setPlotLevel( PlotLevel::LEVEL_0 ); - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString )-> - setRestartFlags( RestartFlags::NO_WRITE ); + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString )-> + setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString )-> - setRestartFlags( RestartFlags::NO_WRITE ); + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString )-> + setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString )-> - setRestartFlags( RestartFlags::NO_WRITE ); + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString )-> + setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString )-> - setRestartFlags( RestartFlags::NO_WRITE ); + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString )-> + setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString )-> - setRestartFlags( RestartFlags::NO_WRITE ); + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString )-> + setRestartFlags( RestartFlags::NO_WRITE ); } } ); } @@ -265,7 +265,7 @@ void CompositionalMultiphaseFlow::InitializePreSubGroups( Group * const rootGrou MultiFluidBase const & fluid0 = *cm.GetConstitutiveRelation< MultiFluidBase >( m_fluidModelNames[0] ); m_numPhases = fluid0.numFluidPhases(); m_numComponents = fluid0.numFluidComponents(); - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { // Nc + pressure m_numDofPerCell = m_numComponents + 1; @@ -320,14 +320,14 @@ void CompositionalMultiphaseFlow::ResizeFields( MeshLevel & meshLevel ) const subRegion.getReference< array3d< real64 > >( viewKeyStruct::phaseComponentFractionOldString ).resizeDimension< 1, 2 >( NP, NC ); } ); - if (m_isothermalFlag == 0) + if( m_isothermalFlag == 0 ) { forTargetSubRegions( meshLevel, [&]( localIndex const, ElementSubRegionBase & subRegion ) { - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ).resizeDimension<1>( NP ); - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ).resizeDimension<1>( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ).resizeDimension< 1 >( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ).resizeDimension< 1 >( NP ); subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ).resizeDimension< 1 >( NP ); - }); + } ); } } @@ -396,31 +396,32 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, arrayView3d< real64 const > const & dPhaseDens_dPres = fluid.dPhaseDensity_dPressure(); arrayView4d< real64 const > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2 - < IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >(m_numComponents, m_numPhases, - dataGroup.size(), - compDens, - dCompDens, - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp ); - } else + < IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, + dataGroup.size(), + compDens, + dCompDens, + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseFrac, + dPhaseFrac_dPres, + dPhaseFrac_dComp, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp ); + } + else { // Get thermal views arrayView3d< real64 const > const & dPhaseFrac_dTemp = fluid.dPhaseFraction_dTemperature(); arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); arrayView2d< real64 > const dPhaseVolFrac_dTemp = - dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, @@ -439,7 +440,7 @@ void CompositionalMultiphaseFlow::UpdatePhaseVolumeFraction( Group & dataGroup, phaseVolFrac, dPhaseVolFrac_dPres, dPhaseVolFrac_dTemp, - dPhaseVolFrac_dComp ); + dPhaseVolFrac_dComp ); } } @@ -485,58 +486,59 @@ void CompositionalMultiphaseFlow::UpdatePhaseMobility( Group & dataGroup, localI arrayView3d< real64 const > const & phaseRelPerm = relperm.phaseRelPerm(); arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac = relperm.dPhaseRelPerm_dPhaseVolFraction(); - if (m_isothermalFlag) + if( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < IsothermalCompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, - dataGroup.size(), - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseVisc, - dPhaseVisc_dPres, - dPhaseVisc_dComp, - phaseRelPerm, - dPhaseRelPerm_dPhaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dComp ); - }else + dataGroup.size(), + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseVisc, + dPhaseVisc_dPres, + dPhaseVisc_dComp, + phaseRelPerm, + dPhaseRelPerm_dPhaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dComp, + phaseMob, + dPhaseMob_dPres, + dPhaseMob_dComp ); + } + else { // get thermal views arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); arrayView3d< real64 const > const & dPhaseVisc_dTemp = fluid.dPhaseViscosity_dTemperature(); arrayView2d< real64 > const dPhaseMob_dTemp = - dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ); arrayView2d< real64 const > const dPhaseVolFrac_dTemp = - dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, - dataGroup.size(), - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dTemp, - dPhaseDens_dComp, - phaseVisc, - dPhaseVisc_dPres, - dPhaseVisc_dTemp, - dPhaseVisc_dComp, - phaseRelPerm, - dPhaseRelPerm_dPhaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dTemp, - dPhaseVolFrac_dComp, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dTemp, - dPhaseMob_dComp ); + dataGroup.size(), + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dTemp, + dPhaseDens_dComp, + phaseVisc, + dPhaseVisc_dPres, + dPhaseVisc_dTemp, + dPhaseVisc_dComp, + phaseRelPerm, + dPhaseRelPerm_dPhaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, + dPhaseVolFrac_dComp, + phaseMob, + dPhaseMob_dPres, + dPhaseMob_dTemp, + dPhaseMob_dComp ); } } @@ -556,7 +558,7 @@ void CompositionalMultiphaseFlow::UpdateFluidModel( Group & dataGroup, localInde typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); // MultiFluid models are not thread-safe or device-capable yet - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( dataGroup.size(), fluidWrapper, @@ -564,7 +566,8 @@ void CompositionalMultiphaseFlow::UpdateFluidModel( Group & dataGroup, localInde dPres, m_uniformTemperature, compFrac ); - } else + } + else { arrayView1d< real64 const > const temperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); arrayView1d< real64 const > const dTemperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); @@ -628,8 +631,8 @@ void CompositionalMultiphaseFlow::UpdateCapPressureModel( Group & dataGroup, loc typename TYPEOFREF( castedCapPres ) ::KernelWrapper capPresWrapper = castedCapPres.createKernelWrapper(); CompositionalMultiphaseFlowKernels::CapillaryPressureUpdateKernel::Launch< parallelDevicePolicy<> >( dataGroup.size(), - capPresWrapper, - phaseVolFrac ); + capPresWrapper, + phaseVolFrac ); } ); } } @@ -786,7 +789,7 @@ void CompositionalMultiphaseFlow::BackupFields( MeshLevel & mesh ) const } ); // backup thermal fields - if ( m_isothermalFlag == 0 ) + if( m_isothermalFlag == 0 ) { forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { @@ -799,9 +802,9 @@ void CompositionalMultiphaseFlow::BackupFields( MeshLevel & mesh ) const arrayView2d< real64 const > const rockInternalEnergy = solid.internalEnergy(); arrayView2d< real64 > const phaseInternalEnergyOld = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); arrayView1d< real64 > rockInternalEnergyOld = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString ); localIndex const NP = m_numPhases; @@ -817,7 +820,7 @@ void CompositionalMultiphaseFlow::BackupFields( MeshLevel & mesh ) const } } ); - } ); + } ); } } @@ -931,96 +934,97 @@ void CompositionalMultiphaseFlow::AssembleAccumulationTerms( DomainPartition con arrayView4d< real64 const > const & dPhaseCompFrac_dPres = fluid.dPhaseCompFraction_dPressure(); arrayView5d< real64 const > const & dPhaseCompFrac_dComp = fluid.dPhaseCompFraction_dGlobalCompFraction(); - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < IsothermalCompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, - m_numPhases, - subRegion.size(), - dofManager.rankOffset(), - dofNumber, - elemGhostRank, - volume, - porosityOld, - porosityRef, - pvMult, - dPvMult_dPres, - dCompFrac_dCompDens, - phaseVolFracOld, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dCompDens, - phaseDensOld, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseCompFracOld, - phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dComp, - localMatrix, - localRhs ); - }else + m_numPhases, + subRegion.size(), + dofManager.rankOffset(), + dofNumber, + elemGhostRank, + volume, + porosityOld, + porosityRef, + pvMult, + dPvMult_dPres, + dCompFrac_dCompDens, + phaseVolFracOld, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dCompDens, + phaseDensOld, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseCompFracOld, + phaseCompFrac, + dPhaseCompFrac_dPres, + dPhaseCompFrac_dComp, + localMatrix, + localRhs ); + } + else { arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); arrayView4d< real64 const > const & dPhaseCompFrac_dTemp = fluid.dPhaseCompFraction_dTemperature(); arrayView2d< real64 const > const & phaseInternalEnergyOld = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); arrayView3d< real64 const > const & phaseInternalEnergy = fluid.phaseInternalEnergy(); arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres = fluid.dPhaseInternalEnergy_dPressure(); arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp = fluid.dPhaseInternalEnergy_dTemperature(); arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp = fluid.dPhaseInternalEnergy_dGlobalCompFraction(); arrayView1d< real64 const > const & rockInternalEnergyOld = - subRegion.getReference< array1d< real64 > >(viewKeyStruct::rockInternalEnergyOldString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString ); arrayView2d< real64 const > const & rockInternalEnergy = solid.internalEnergy(); arrayView2d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); arrayView2d< real64 const > const & rockDensity = solid.getDensity(); CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 < CompositionalMultiphaseFlowKernels::AccumulationKernel >( m_numComponents, - m_numPhases, - subRegion.size(), - dofManager.rankOffset(), - dofNumber, - elemGhostRank, - volume, - porosityOld, - porosityRef, - pvMult, - dPvMult_dPres, - dCompFrac_dCompDens, - phaseVolFracOld, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dTemp, - dPhaseVolFrac_dCompDens, - phaseDensOld, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dTemp, - dPhaseDens_dComp, - phaseCompFracOld, - phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dTemp, - dPhaseCompFrac_dComp, - phaseInternalEnergyOld, - phaseInternalEnergy, - dPhaseInternalEnergy_dPres, - dPhaseInternalEnergy_dTemp, - dPhaseInternalEnergy_dComp, - rockInternalEnergyOld, - rockInternalEnergy, - dRockInternalEnergy_dTemp, - rockDensity, - localMatrix, - localRhs ); + m_numPhases, + subRegion.size(), + dofManager.rankOffset(), + dofNumber, + elemGhostRank, + volume, + porosityOld, + porosityRef, + pvMult, + dPvMult_dPres, + dCompFrac_dCompDens, + phaseVolFracOld, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dTemp, + dPhaseVolFrac_dCompDens, + phaseDensOld, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dTemp, + dPhaseDens_dComp, + phaseCompFracOld, + phaseCompFrac, + dPhaseCompFrac_dPres, + dPhaseCompFrac_dTemp, + dPhaseCompFrac_dComp, + phaseInternalEnergyOld, + phaseInternalEnergy, + dPhaseInternalEnergy_dPres, + dPhaseInternalEnergy_dTemp, + dPhaseInternalEnergy_dComp, + rockInternalEnergyOld, + rockInternalEnergy, + dRockInternalEnergy_dTemp, + rockDensity, + localMatrix, + localRhs ); } } ); @@ -1089,77 +1093,78 @@ void CompositionalMultiphaseFlow::AssembleFluxTerms( real64 const dt, fluxApprox.forAllStencils( mesh, [&] ( auto const & stencil ) { - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector1 - < IsothermalCompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, - m_numPhases, - stencil, - dofManager.rankOffset(), - elemDofNumber.toNestedViewConst(), - m_elemGhostRank.toNestedViewConst(), - m_pressure.toNestedViewConst(), - m_deltaPressure.toNestedViewConst(), - m_gravCoef.toNestedViewConst(), - m_phaseMob.toNestedViewConst(), - m_dPhaseMob_dPres.toNestedViewConst(), - m_dPhaseMob_dCompDens.toNestedViewConst(), - m_dPhaseVolFrac_dPres.toNestedViewConst(), - m_dPhaseVolFrac_dCompDens.toNestedViewConst(), - m_dCompFrac_dCompDens.toNestedViewConst(), - m_phaseMassDens.toNestedViewConst(), - m_dPhaseMassDens_dPres.toNestedViewConst(), - m_dPhaseMassDens_dComp.toNestedViewConst(), - m_phaseCompFrac.toNestedViewConst(), - m_dPhaseCompFrac_dPres.toNestedViewConst(), - m_dPhaseCompFrac_dComp.toNestedViewConst(), - m_phaseCapPressure.toNestedViewConst(), - m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), - m_capPressureFlag, - dt, - localMatrix.toViewConstSizes(), - localRhs.toView() ); - }else + < IsothermalCompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, + m_numPhases, + stencil, + dofManager.rankOffset(), + elemDofNumber.toNestedViewConst(), + m_elemGhostRank.toNestedViewConst(), + m_pressure.toNestedViewConst(), + m_deltaPressure.toNestedViewConst(), + m_gravCoef.toNestedViewConst(), + m_phaseMob.toNestedViewConst(), + m_dPhaseMob_dPres.toNestedViewConst(), + m_dPhaseMob_dCompDens.toNestedViewConst(), + m_dPhaseVolFrac_dPres.toNestedViewConst(), + m_dPhaseVolFrac_dCompDens.toNestedViewConst(), + m_dCompFrac_dCompDens.toNestedViewConst(), + m_phaseMassDens.toNestedViewConst(), + m_dPhaseMassDens_dPres.toNestedViewConst(), + m_dPhaseMassDens_dComp.toNestedViewConst(), + m_phaseCompFrac.toNestedViewConst(), + m_dPhaseCompFrac_dPres.toNestedViewConst(), + m_dPhaseCompFrac_dComp.toNestedViewConst(), + m_phaseCapPressure.toNestedViewConst(), + m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), + m_capPressureFlag, + dt, + localMatrix.toViewConstSizes(), + localRhs.toView() ); + } + else { CompositionalMultiphaseFlowKernels::KernelLaunchSelector1 - < CompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, - m_numPhases, - stencil, - dofManager.rankOffset(), - elemDofNumber.toNestedViewConst(), - m_elemGhostRank.toNestedViewConst(), - m_pressure.toNestedViewConst(), - m_deltaPressure.toNestedViewConst(), - m_gravCoef.toNestedViewConst(), - m_phaseMob.toNestedViewConst(), - m_dPhaseMob_dPres.toNestedViewConst(), - m_dPhaseMob_dTemp.toNestedViewConst(), - m_dPhaseMob_dCompDens.toNestedViewConst(), - m_phaseVolFrac.toNestedViewConst(), - m_dPhaseVolFrac_dPres.toNestedViewConst(), - m_dPhaseVolFrac_dTemp.toNestedViewConst(), - m_dPhaseVolFrac_dCompDens.toNestedViewConst(), - m_dCompFrac_dCompDens.toNestedViewConst(), - m_phaseMassDens.toNestedViewConst(), - m_dPhaseMassDens_dPres.toNestedViewConst(), - m_dPhaseMassDens_dTemp.toNestedViewConst(), - m_dPhaseMassDens_dComp.toNestedViewConst(), - m_phaseCompFrac.toNestedViewConst(), - m_dPhaseCompFrac_dPres.toNestedViewConst(), - m_dPhaseCompFrac_dTemp.toNestedViewConst(), - m_dPhaseCompFrac_dComp.toNestedViewConst(), - m_phaseCapPressure.toNestedViewConst(), - m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), - m_temperature.toNestedViewConst(), - m_deltaTemperature.toNestedViewConst(), - m_phaseEnthalpy.toNestedViewConst(), - m_dPhaseEnthalpy_dPres.toNestedViewConst(), - m_dPhaseEnthalpy_dTemp.toNestedViewConst(), - m_dPhaseEnthalpy_dComp.toNestedViewConst(), - m_capPressureFlag, - dt, - localMatrix.toViewConstSizes(), - localRhs.toView() ); + < CompositionalMultiphaseFlowKernels::FluxKernel >( m_numComponents, + m_numPhases, + stencil, + dofManager.rankOffset(), + elemDofNumber.toNestedViewConst(), + m_elemGhostRank.toNestedViewConst(), + m_pressure.toNestedViewConst(), + m_deltaPressure.toNestedViewConst(), + m_gravCoef.toNestedViewConst(), + m_phaseMob.toNestedViewConst(), + m_dPhaseMob_dPres.toNestedViewConst(), + m_dPhaseMob_dTemp.toNestedViewConst(), + m_dPhaseMob_dCompDens.toNestedViewConst(), + m_phaseVolFrac.toNestedViewConst(), + m_dPhaseVolFrac_dPres.toNestedViewConst(), + m_dPhaseVolFrac_dTemp.toNestedViewConst(), + m_dPhaseVolFrac_dCompDens.toNestedViewConst(), + m_dCompFrac_dCompDens.toNestedViewConst(), + m_phaseMassDens.toNestedViewConst(), + m_dPhaseMassDens_dPres.toNestedViewConst(), + m_dPhaseMassDens_dTemp.toNestedViewConst(), + m_dPhaseMassDens_dComp.toNestedViewConst(), + m_phaseCompFrac.toNestedViewConst(), + m_dPhaseCompFrac_dPres.toNestedViewConst(), + m_dPhaseCompFrac_dTemp.toNestedViewConst(), + m_dPhaseCompFrac_dComp.toNestedViewConst(), + m_phaseCapPressure.toNestedViewConst(), + m_dPhaseCapPressure_dPhaseVolFrac.toNestedViewConst(), + m_temperature.toNestedViewConst(), + m_deltaTemperature.toNestedViewConst(), + m_phaseEnthalpy.toNestedViewConst(), + m_dPhaseEnthalpy_dPres.toNestedViewConst(), + m_dPhaseEnthalpy_dTemp.toNestedViewConst(), + m_dPhaseEnthalpy_dComp.toNestedViewConst(), + m_capPressureFlag, + dt, + localMatrix.toViewConstSizes(), + localRhs.toView() ); } } ); } @@ -1196,7 +1201,7 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co arrayView2d< real64 const > const & dPvMult_dPres = solid.getReference< array2d< real64 > >( ConstitutiveBase::viewKeyStruct::dPVMult_dPresString ); - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < IsothermalCompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, @@ -1213,10 +1218,11 @@ void CompositionalMultiphaseFlow::AssembleVolumeBalanceTerms( DomainPartition co dPhaseVolFrac_dCompDens, localMatrix.toViewConstSizes(), localRhs.toView() ); - }else + } + else { arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, @@ -1479,52 +1485,53 @@ real64 CompositionalMultiphaseFlow::CalculateResidualNorm( DomainPartition const real64 residual; - if ( m_isothermalFlag ) + if( m_isothermalFlag ) { - localIndex const NDOF = m_numComponents + 1; + localIndex const NDOF = m_numComponents + 1; - real64 localResidualNorm = 0.0; + real64 localResidualNorm = 0.0; - forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase const & subRegion ) - { - MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); + forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase const & subRegion ) + { + MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); - arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); - arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); - arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & refPoro = subRegion.getReference< array1d< real64 > >( viewKeyStruct::referencePorosityString ); - arrayView2d< real64 const > const & totalDens = fluid.totalDensity(); + arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); + arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); + arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); + arrayView1d< real64 const > const & refPoro = subRegion.getReference< array1d< real64 > >( viewKeyStruct::referencePorosityString ); + arrayView2d< real64 const > const & totalDens = fluid.totalDensity(); - RAJA::ReduceSum< parallelDeviceReduce, real64 > localSum( 0.0 ); + RAJA::ReduceSum< parallelDeviceReduce, real64 > localSum( 0.0 ); - forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( elemGhostRank[ei] < 0 ) + forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { - localIndex const localRow = dofNumber[ei] - rankOffset; - real64 const normalizer = totalDens[ei][0] * refPoro[ei] * volume[ei]; - - for( localIndex idof = 0; idof < NDOF; ++idof ) + if( elemGhostRank[ei] < 0 ) { - real64 const val = localRhs[localRow + idof] / normalizer; - localSum += val * val; + localIndex const localRow = dofNumber[ei] - rankOffset; + real64 const normalizer = totalDens[ei][0] * refPoro[ei] * volume[ei]; + + for( localIndex idof = 0; idof < NDOF; ++idof ) + { + real64 const val = localRhs[localRow + idof] / normalizer; + localSum += val * val; + } } - } - } ); + } ); - localResidualNorm += localSum.get(); - } ); + localResidualNorm += localSum.get(); + } ); - // compute global residual norm - residual = std::sqrt( MpiWrapper::Sum( localResidualNorm ) ); + // compute global residual norm + residual = std::sqrt( MpiWrapper::Sum( localResidualNorm ) ); - if( getLogLevel() >= 1 && logger::internal::rank==0 ) - { - char output[200] = {0}; - sprintf( output, " ( Rfluid ) = (%4.2e) ; ", residual ); - std::cout<= 1 && logger::internal::rank==0 ) + { + char output[200] = {0}; + sprintf( output, " ( Rfluid ) = (%4.2e) ; ", residual ); + std::cout<getMeshLevel( 0 ); - if ( m_isothermalFlag ) - { - forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) + if( m_isothermalFlag ) { - arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString ); - arrayView2d< real64 > const & dCompDens = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); + forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) + { + arrayView1d< real64 > const & dPres = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString ); + arrayView2d< real64 > const & dCompDens = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); - dPres.setValues< parallelDevicePolicy<> >( 0.0 ); - dCompDens.setValues< parallelDevicePolicy<> >( 0.0 ); + dPres.setValues< parallelDevicePolicy<> >( 0.0 ); + dCompDens.setValues< parallelDevicePolicy<> >( 0.0 ); - UpdateState( subRegion, targetIndex ); - } ); - }else + UpdateState( subRegion, targetIndex ); + } ); + } + else { forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) - { - arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString ); - arrayView2d< real64 > const & dCompDens = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); - arrayView1d< real64 > const & dTemp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); - - dPres.setValues< parallelDevicePolicy<> >( 0.0 ); - dCompDens.setValues< parallelDevicePolicy<> >( 0.0 ); - dTemp.setValues< parallelDevicePolicy<> >(0.0); - - UpdateState( subRegion, targetIndex ); - } ); + { + arrayView1d< real64 > const & dPres = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString ); + arrayView2d< real64 > const & dCompDens = + subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); + arrayView1d< real64 > const & dTemp = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + + dPres.setValues< parallelDevicePolicy<> >( 0.0 ); + dCompDens.setValues< parallelDevicePolicy<> >( 0.0 ); + dTemp.setValues< parallelDevicePolicy<> >( 0.0 ); + + UpdateState( subRegion, targetIndex ); + } ); } } @@ -1879,20 +1887,20 @@ void CompositionalMultiphaseFlow::ImplicitStepComplete( real64 const & GEOSX_UNU } ); } ); - if (m_isothermalFlag == 0) - { + if( m_isothermalFlag == 0 ) + { forTargetSubRegions( mesh, [&]( localIndex const, ElementSubRegionBase & subRegion ) - { - arrayView1d< real64 const > const dTemp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); - arrayView1d< real64 > const temp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); + { + arrayView1d< real64 const > const dTemp = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + arrayView1d< real64 > const temp = + subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); - forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - temp[ei] += dTemp[ei]; - } ); + forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + temp[ei] += dTemp[ei]; } ); + } ); } } @@ -1992,7 +2000,7 @@ void CompositionalMultiphaseFlow::ResetViews( MeshLevel & mesh ) capPresModelNames() ); m_dPhaseCapPressure_dPhaseVolFrac.setName( getName() + "/accessors/" + keys::dPhaseCapPressure_dPhaseVolFractionString ); } - if (m_isothermalFlag == 0) + if( m_isothermalFlag == 0 ) { using keys = MultiFluidBase::viewKeyStruct; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index 990e8157df3..9e2c4000589 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -165,7 +165,7 @@ PhaseVolumeFractionKernel:: (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; dPhaseVolFrac_dTemp[ip] = - (dPhaseFrac_dTemp[ip] - phaseVolFrac[ip] * dPhaseDens_dTemp[ip]) * phaseDensInv; + (dPhaseFrac_dTemp[ip] - phaseVolFrac[ip] * dPhaseDens_dTemp[ip]) * phaseDensInv; for( localIndex jc = 0; jc < NC; ++jc ) { @@ -278,15 +278,15 @@ void PhaseVolumeFractionKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseFrac, \ arrayView3d< real64 const > const & dPhaseFrac_dPres, \ - arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ + arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ arrayView4d< real64 const > const & dPhaseFrac_dComp, \ arrayView2d< real64 > const & phaseVolFrac, \ - arrayView2d< real64 > const & dPhaseVolFrac_dPres,\ - arrayView2d< real64 > const & dPhaseVolFrac_dTemp,\ + arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 > const & dPhaseVolFrac_dComp ); \ template \ void \ @@ -297,15 +297,15 @@ void PhaseVolumeFractionKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseFrac, \ arrayView3d< real64 const > const & dPhaseFrac_dPres, \ - arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ + arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ arrayView4d< real64 const > const & dPhaseFrac_dComp, \ arrayView2d< real64 > const & phaseVolFrac, \ arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 > const & dPhaseVolFrac_dTemp, \ + arrayView2d< real64 > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 > const & dPhaseVolFrac_dComp ) INST_PhaseVolumeFractionKernel( 1, 1 ); @@ -397,7 +397,7 @@ PhaseMobilityKernel:: + mobility * (dDens_dP / density - dVisc_dP / viscosity); dPhaseMob_dTemp[ip] = dRelPerm_dT * density / viscosity - + mobility * (dDens_dT / density - dVisc_dT / viscosity); + + mobility * (dDens_dT / density - dVisc_dT / viscosity); // compositional derivatives for( localIndex jc = 0; jc < NC; ++jc ) @@ -507,20 +507,20 @@ void PhaseMobilityKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseVisc, \ arrayView3d< real64 const > const & dPhaseVisc_dPres, \ - arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ + arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ arrayView4d< real64 const > const & dPhaseVisc_dComp, \ arrayView3d< real64 const > const & phaseRelPerm, \ arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp,\ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ arrayView2d< real64 > const & phaseMob, \ arrayView2d< real64 > const & dPhaseMob_dPres, \ - arrayView2d< real64 > const & dPhaseMob_dTemp, \ + arrayView2d< real64 > const & dPhaseMob_dTemp, \ arrayView3d< real64 > const & dPhaseMob_dComp ); \ template \ void \ @@ -529,20 +529,20 @@ void PhaseMobilityKernel:: arrayView3d< real64 const > const & dCompFrac_dCompDens, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseVisc, \ arrayView3d< real64 const > const & dPhaseVisc_dPres, \ - arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ + arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ arrayView4d< real64 const > const & dPhaseVisc_dComp, \ arrayView3d< real64 const > const & phaseRelPerm, \ arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp,\ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ arrayView2d< real64 > const & phaseMob, \ arrayView2d< real64 > const & dPhaseMob_dPres, \ - arrayView2d< real64 > const & dPhaseMob_dTemp, \ + arrayView2d< real64 > const & dPhaseMob_dTemp, \ arrayView3d< real64 > const & dPhaseMob_dComp ) INST_PhaseMobilityKernel( 1, 1 ); @@ -653,8 +653,8 @@ AccumulationKernel:: + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); real64 const dPhaseAmount_dT = dPoreVol_dT * phaseVolFrac[ip] * phaseDens[ip] - + poreVolNew * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); + + poreVolNew * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] + + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); // assemble density dependence applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); @@ -676,7 +676,7 @@ AccumulationKernel:: + phaseAmountNew * dPhaseCompFrac_dPres[ip][ic]; real64 const dPhaseCompAmount_dT = dPhaseAmount_dT * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; + + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; localAccum[ic] += phaseCompAmountNew - phaseCompAmountOld; localAccumJacobian[ic][0] += dPhaseCompAmount_dP; @@ -718,10 +718,10 @@ AccumulationKernel:: // derivatives w.r.t. component densities applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); - for ( localIndex jc = 0; jc < NC; ++jc ) + for( localIndex jc = 0; jc < NC; ++jc ) { real64 const dPhaseEnergy_dC = phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + - dPhaseInternalEnergy_dC[jc] * phaseAmountNew; + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; localAccumJacobian[NC][jc + 1] += dPhaseEnergy_dC; } @@ -852,27 +852,27 @@ AccumulationKernel:: arrayView2d< real64 const > const & phaseVolFracOld, \ arrayView2d< real64 const > const & phaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ arrayView2d< real64 const > const & phaseDensOld, \ arrayView3d< real64 const > const & phaseDens, \ arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ + arrayView3d< real64 const > const & dPhaseDens_dTemp, \ arrayView4d< real64 const > const & dPhaseDens_dComp, \ arrayView3d< real64 const > const & phaseCompFracOld, \ arrayView4d< real64 const > const & phaseCompFrac, \ arrayView4d< real64 const > const & dPhaseCompFrac_dPres, \ - arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, \ + arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, \ arrayView5d< real64 const > const & dPhaseCompFrac_dComp, \ - arrayView2d< real64 const > const & phaseInternalEnergyOld, \ - arrayView3d< real64 const > const & phaseInternalEnergy, \ - arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, \ - arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, \ - arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, \ - arrayView1d< real64 const > const & rockInternalEnergyOld, \ - arrayView2d< real64 const > const & rockInternalEnergy, \ - arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, \ - arrayView2d< real64 const > const & rockDensity, \ + arrayView2d< real64 const > const & phaseInternalEnergyOld, \ + arrayView3d< real64 const > const & phaseInternalEnergy, \ + arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, \ + arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, \ + arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, \ + arrayView1d< real64 const > const & rockInternalEnergyOld, \ + arrayView2d< real64 const > const & rockInternalEnergy, \ + arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, \ + arrayView2d< real64 const > const & rockDensity, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ arrayView1d< real64 > const & localRhs ) @@ -1398,29 +1398,29 @@ FluxKernel:: ElementViewConst< arrayView1d< real64 const > > const & gravCoef, \ ElementViewConst< arrayView2d< real64 const > > const & phaseMob, \ ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, \ - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, \ + ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, \ ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, \ - ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, \ + ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, \ ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, \ - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, \ + ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, \ ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, \ ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, \ ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, \ ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, \ ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, \ ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, \ ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, \ ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, \ ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, \ ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, \ - ElementViewConst< arrayView1d< real64 const > > const & temp, \ - ElementViewConst< arrayView1d< real64 const > > const & dTemp, \ - ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, \ + ElementViewConst< arrayView1d< real64 const > > const & temp, \ + ElementViewConst< arrayView1d< real64 const > > const & dTemp, \ + ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, \ + ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, \ + ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, \ integer const capPressureFlag, \ real64 const dt, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ @@ -1456,7 +1456,7 @@ VolumeBalanceKernel:: arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, real64 & localVolBalance, - real64 (& localVolBalanceJacobian)[NC+2] ) + real64 (& localVolBalanceJacobian)[NC+2] ) { localIndex constexpr NDOF = NC + 2; @@ -1565,7 +1565,7 @@ VolumeBalanceKernel:: arrayView2d< real64 const > const & dPvMult_dPres, \ arrayView2d< real64 const > const & phaseVolFrac, \ arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ + arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ CRSMatrixView< real64, globalIndex const > const & localMatrix, \ arrayView1d< real64 > const & localRhs ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp index bdeed51055e..cc4457afe6a 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.hpp @@ -396,8 +396,8 @@ struct AccumulationKernel real64 const & rockInternalEnergy, real64 const & dRockInternalEnergy_dTemp, real64 const & rockDensity, - real64 ( & localAccum )[NC + 1], - real64 ( & localAccumJacobian )[NC + 1][NC + 2] ); + real64 ( &localAccum )[NC + 1], + real64 ( &localAccumJacobian )[NC + 1][NC + 2] ); template< localIndex NC > static void @@ -552,16 +552,16 @@ struct VolumeBalanceKernel GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE static void - Compute( real64 const & volume, - real64 const & porosityRef, - real64 const & pvMult, - real64 const & dPvMult_dPres, - arraySlice1d< real64 const > const & phaseVolFrac, - arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, - real64 & localVolBalance, - real64 (& localVolBalanceJacobian)[NC+2] ); + Compute( real64 const & volume, + real64 const & porosityRef, + real64 const & pvMult, + real64 const & dPvMult_dPres, + arraySlice1d< real64 const > const & phaseVolFrac, + arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, + arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, + arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, + real64 & localVolBalance, + real64 ( &localVolBalanceJacobian )[NC+2] ); template< localIndex NC, localIndex NP > static void diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp index 944f6b7b5f2..df1a4a3c4dc 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.cpp @@ -1217,7 +1217,3 @@ INST_VolumeBalanceKernel( 5, 3 ); } // namespace IsothermalCompositionalMultiphaseFlowKernels } // namespace geosx - - - - diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp index ddb56b139ed..d2a943da962 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp @@ -359,11 +359,11 @@ void CompositionalMultiphaseWell::UpdateFluidModel( WellElementSubRegion & subRe typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( subRegion.size(), - fluidWrapper, - pres, - dPres, - m_temperature, - compFrac ); + fluidWrapper, + pres, + dPres, + m_temperature, + compFrac ); } ); } @@ -400,20 +400,20 @@ void CompositionalMultiphaseWell::UpdatePhaseVolumeFraction( WellElementSubRegio arrayView4d< real64 const > const & dPhaseDens_dComp = fluid.dPhaseDensity_dGlobalCompFraction(); IsothermalCompositionalMultiphaseFlowKernels::KernelLaunchSelector2< IsothermalCompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel - >( NumFluidComponents(), NumFluidPhases(), - subRegion.size(), - compDens, - dCompDens, - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dCompDens ); + >( NumFluidComponents(), NumFluidPhases(), + subRegion.size(), + compDens, + dCompDens, + dCompFrac_dCompDens, + phaseDens, + dPhaseDens_dPres, + dPhaseDens_dComp, + phaseFrac, + dPhaseFrac_dPres, + dPhaseFrac_dComp, + phaseVolFrac, + dPhaseVolFrac_dPres, + dPhaseVolFrac_dCompDens ); } void CompositionalMultiphaseWell::UpdateTotalMassDensity( WellElementSubRegion & subRegion, localIndex const targetIndex ) const @@ -544,10 +544,10 @@ void CompositionalMultiphaseWell::InitializeWells( DomainPartition & domain ) typename TYPEOFREF( castedFluid ) ::KernelWrapper fluidWrapper = castedFluid.createKernelWrapper(); IsothermalCompositionalMultiphaseFlowKernels::FluidUpdateKernel::Launch< serialPolicy >( subRegion.size(), - fluidWrapper, - wellElemPressure, - m_temperature, - wellElemCompFrac ); + fluidWrapper, + wellElemPressure, + m_temperature, + wellElemCompFrac ); } ); CompDensInitializationKernel::Launch< parallelDevicePolicy<> >( subRegion.size(), From c845d52ab0474ebfefc373d04d264be08dfeccde Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Mon, 28 Dec 2020 10:35:47 -0800 Subject: [PATCH 14/34] bug fix. --- .../fluidFlow/CompositionalMultiphaseFlowKernels.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp index 9e2c4000589..b09ca2d0b1f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp @@ -823,7 +823,7 @@ AccumulationKernel:: } // add contribution to residual and jacobian - for( localIndex i = 0; i < NBEQ + 1; ++i ) + for( localIndex i = 0; i < NBEQ; ++i ) { localRhs[localRow + i] += localAccum[i]; localMatrix.addToRow< serialAtomic >( localRow + i, From 97c6daa7d0407b255f6df5606a7aa5dc78d47344 Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Mon, 28 Dec 2020 15:00:59 -0800 Subject: [PATCH 15/34] xml file --- .../integratedTests/CO2Thermal.xml | 203 ++++++++++++------ 1 file changed, 132 insertions(+), 71 deletions(-) diff --git a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml index f4476f34d9d..7c4451fb7a7 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml +++ b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/CO2Thermal.xml @@ -17,50 +17,72 @@ isothermal="0"/> - - + + + + + + + + - + maxTime="2e7"> + target="/Outputs/vtkOutput"/> + name="solverApplications1" + forceDt="1e3" + beginTime="0" + endTime="1e4" + target="/Solvers/compositionalMultiphaseFlow"/> - - + name="solverApplications2" + forceDt="1e4" + beginTime="1e4" + endTime="1e5" + target="/Solvers/compositionalMultiphaseFlow"/> + name="solverApplications3" + forceDt="1e5" + beginTime="1e5" + target="/Solvers/compositionalMultiphaseFlow"/> + @@ -84,7 +106,7 @@ + scale="1e-16"/> + scale="1e-16"/> + scale="1e-16"/> - + + - + scale="5e6"/> + + + + + + + + + + + + + + + + + + + + + + + + + name="vtkOutput"/> - - - - - - - - - - - - - - - From fcc4890f9a864f776f7101a56daf1036c7d35836 Mon Sep 17 00:00:00 2001 From: Yue Hao Date: Mon, 11 Jan 2021 16:34:57 -0800 Subject: [PATCH 16/34] added CO2 and brine enthalpy functions --- .../constitutive/fluid/MultiFluidBase.cpp | 33 ++ .../fluid/MultiPhaseMultiComponentFluid.cpp | 26 +- .../fluid/MultiPhaseMultiComponentFluid.hpp | 5 - .../PVTFunctions/BrineEnthalpyFunction.cpp | 232 +++++++++++++- .../PVTFunctions/BrineEnthalpyFunction.hpp | 11 +- .../PVTFunctions/CO2EnthalpyFunction.cpp | 295 +++++++++++++++++- .../PVTFunctions/CO2EnthalpyFunction.hpp | 10 +- .../integratedTests/pvt_tables/pvtgas.txt | 5 +- .../integratedTests/pvt_tables/pvtliquid.txt | 3 +- 9 files changed, 573 insertions(+), 47 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index 8af2b033758..9b8a4a84201 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -100,6 +100,27 @@ MultiFluidBase::MultiFluidBase( std::string const & name, Group * const parent ) registerWrapper( viewKeyStruct::useMassString, &m_useMass )-> setRestartFlags( RestartFlags::NO_WRITE ); + registerWrapper( viewKeyStruct::phaseEnthalpyString, &m_phaseEnthalpy )-> + setPlotLevel( PlotLevel::LEVEL_0 ); + registerWrapper( viewKeyStruct::dPhaseEnthalpy_dPressureString, &m_dPhaseEnthalpy_dPressure )-> + setRestartFlags( RestartFlags::NO_WRITE ); + registerWrapper( viewKeyStruct::dPhaseEnthalpy_dTemperatureString, &m_dPhaseEnthalpy_dTemperature )-> + setRestartFlags( RestartFlags::NO_WRITE ); + registerWrapper( viewKeyStruct::dPhaseEnthalpy_dGlobalCompFractionString, &m_dPhaseEnthalpy_dGlobalCompFraction )-> + setRestartFlags( RestartFlags::NO_WRITE ); + + + registerWrapper( viewKeyStruct::phaseInternalEnergyString, &m_phaseInternalEnergy )-> + setPlotLevel( PlotLevel::LEVEL_0 ); + registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dPressureString, &m_dPhaseInternalEnergy_dPressure )-> + setRestartFlags( RestartFlags::NO_WRITE ); + registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dTemperatureString, &m_dPhaseInternalEnergy_dTemperature )-> + setRestartFlags( RestartFlags::NO_WRITE ); + registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dGlobalCompFractionString, &m_dPhaseInternalEnergy_dGlobalCompFraction )-> + setRestartFlags( RestartFlags::NO_WRITE ); + + + } void MultiFluidBase::ResizeFields( localIndex const size, localIndex const numPts ) @@ -136,6 +157,18 @@ void MultiFluidBase::ResizeFields( localIndex const size, localIndex const numPt m_dTotalDensity_dPressure.resize( size, numPts ); m_dTotalDensity_dTemperature.resize( size, numPts ); m_dTotalDensity_dGlobalCompFraction.resize( size, numPts, NC ); + + m_phaseEnthalpy.resize( size, numPts, NP ); + m_dPhaseEnthalpy_dPressure.resize( size, numPts, NP ); + m_dPhaseEnthalpy_dTemperature.resize( size, numPts, NP ); + m_dPhaseEnthalpy_dGlobalCompFraction.resize( size, numPts, NP, NC ); + + m_phaseInternalEnergy.resize( size, numPts, NP ); + m_dPhaseInternalEnergy_dPressure.resize( size, numPts, NP ); + m_dPhaseInternalEnergy_dTemperature.resize( size, numPts, NP ); + m_dPhaseInternalEnergy_dGlobalCompFraction.resize( size, numPts, NP, NC ); + + } void MultiFluidBase::allocateConstitutiveData( dataRepository::Group * const parent, diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp index 004dd8f16e6..c582184a26e 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp @@ -79,6 +79,8 @@ MultiPhaseMultiComponentFluid::deliverClone( string const & name, newConstitutiveRelation->m_phaseDensityFuns = this->m_phaseDensityFuns; newConstitutiveRelation->m_phaseViscosityFuns = this->m_phaseViscosityFuns; + newConstitutiveRelation->m_phaseEnthalpyFuns = this->m_phaseEnthalpyFuns; + newConstitutiveRelation->m_flashModel = this->m_flashModel; return clone; @@ -140,13 +142,6 @@ void MultiPhaseMultiComponentFluid::CreatePVTModels() m_componentNames, m_componentMolarWeight ) ); } - else if( strs[0] == "InternalEnergyFun" ) - { - m_phaseInternalEnergyFuns.emplace_back( PVTFunction::CatalogInterface::Factory( strs[ 1 ], - strs, - m_componentNames, - m_componentMolarWeight ) ); - } else { GEOSX_ERROR( "Error: Invalid PVT function: " << strs[0] << "." ); @@ -367,7 +362,7 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, m_phaseViscosityFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseViscosityTemp[ip] ); // molar or mass Enthalpy and Internal Energy m_phaseEnthalpyFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseEnthalpyTemp[ip], m_useMass ); - m_phaseInternalEnergyFuns[ip]->Evaluation( P, T, phaseCompFractionTemp[ip], phaseInternalEnergyTemp[ip], m_useMass ); + } if( m_useMass ) @@ -437,7 +432,7 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseDens.value[ip] = phaseDensityTemp[ip].m_var; phaseDens.dPres[ip] = phaseDensityTemp[ip].m_der[0]; - phaseDens.dTemp[ip] = 0.0; + phaseDens.dTemp[ip] = phaseDensityTemp[ip].m_der[NC+1]; phaseMassDens.value[ip] = phaseMassDensityTemp[ip].m_var; phaseMassDens.dPres[ip] = phaseMassDensityTemp[ip].m_der[0]; @@ -450,10 +445,12 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseEnt.value[ip] = phaseEnthalpyTemp[ip].m_var; phaseEnt.dPres[ip] = phaseEnthalpyTemp[ip].m_der[0]; phaseEnt.dTemp[ip] = phaseEnthalpyTemp[ip].m_der[NC+1]; + + EvalVarArgs E = phaseEnthalpyTemp[ip] - P / phaseDensityTemp[ip]; - phaseIntEner.value[ip] = phaseInternalEnergyTemp[ip].m_var; - phaseIntEner.dPres[ip] = phaseInternalEnergyTemp[ip].m_der[0]; - phaseIntEner.dTemp[ip] = phaseInternalEnergyTemp[ip].m_der[NC+1]; + phaseIntEner.value[ip] = E.m_var; + phaseIntEner.dPres[ip] = E.m_der[0]; + phaseIntEner.dTemp[ip] = E.m_der[NC+1]; for( localIndex ic = 0; ic < NC; ++ic ) { @@ -466,14 +463,15 @@ void MultiPhaseMultiComponentFluidUpdate::Compute( real64 pressure, phaseCompFrac.dPres[ip][ic] = phaseCompFractionTemp[ip][ic].m_der[0]; phaseCompFrac.dTemp[ip][ic] = 0.0; - phaseEnt.dComp[ip][ic] = 0.0; // phaseEnthapyTemp[ip].m_der[ic+1]; - phaseIntEner.dComp[ip][ic] = 0.0; // phaseInternalEnergyTemp[ip].m_der[ic+1]; + phaseEnt.dComp[ip][ic] = phaseEnthalpyTemp[ip].m_der[ic+1]; + phaseIntEner.dComp[ip][ic] = E.m_der[ic+1]; for( localIndex jc = 0; jc < NC; ++jc ) { phaseCompFrac.dComp[ip][ic][jc] = phaseCompFractionTemp[ip][ic].m_der[jc+1]; } } + } totalDens.value = totalDensityTemp.m_var; diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp index 3cb65536417..c892e737370 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.hpp @@ -55,7 +55,6 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate MultiPhaseMultiComponentFluidUpdate( std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseDensityFuns, std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseViscosityFuns, std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseEnthalpyFuns, - std::vector< std::shared_ptr< PVTProps::PVTFunction const > > const & phaseInternalEnergyFuns, std::shared_ptr< PVTProps::FlashModel const > const & flashModel, arrayView1d< real64 const > const & componentMolarWeight, bool useMass, @@ -128,7 +127,6 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate m_phaseDensityFuns( phaseDensityFuns ), m_phaseViscosityFuns( phaseViscosityFuns ), m_phaseEnthalpyFuns( phaseEnthalpyFuns ), - m_phaseInternalEnergyFuns( phaseInternalEnergyFuns ), m_flashModel( flashModel ) {} @@ -239,7 +237,6 @@ class MultiPhaseMultiComponentFluidUpdate final : public MultiFluidBaseUpdate std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseDensityFuns; std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseViscosityFuns; std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseEnthalpyFuns; - std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseInternalEnergyFuns; std::shared_ptr< PVTProps::FlashModel const > m_flashModel; }; @@ -273,7 +270,6 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase return KernelWrapper( m_phaseDensityFuns, m_phaseViscosityFuns, m_phaseEnthalpyFuns, - m_phaseInternalEnergyFuns, m_flashModel, m_componentMolarWeight.toViewConst(), m_useMass, @@ -336,7 +332,6 @@ class MultiPhaseMultiComponentFluid : public MultiFluidBase std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseDensityFuns; std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseViscosityFuns; std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseEnthalpyFuns; - std::vector< std::shared_ptr< PVTProps::PVTFunction const > > m_phaseInternalEnergyFuns; std::shared_ptr< PVTProps::FlashModel const > m_flashModel; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp index fab8fc5bc3c..e1f77a67171 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp @@ -17,6 +17,8 @@ */ #include "constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp" +#include "constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp" +#include "constitutive/fluid/PVTFunctions/SpanWagnerCO2DensityFunction.hpp" namespace geosx { @@ -30,24 +32,232 @@ BrineEnthalpyFunction::BrineEnthalpyFunction( string_array const & inputPara, string_array const & componentNames, real64_array const & componentMolarWeight ): PVTFunction( inputPara[1], componentNames, componentMolarWeight ) -{} +{ + + bool notFound = 1; + + for( localIndex i = 0; i < componentNames.size(); ++i ) + { + + if( streq( componentNames[i], "CO2" ) || streq( componentNames[i], "co2" )) + { + m_CO2Index = i; + notFound = 0; + break; + } + + } + + GEOSX_ERROR_IF( notFound, "Component CO2 is not found!" ); + + notFound = 1; + + for( localIndex i = 0; i < componentNames.size(); ++i ) + { + + if( streq( componentNames[i], "Water" ) || streq( componentNames[i], "water" )) + { + m_waterIndex = i; + notFound = 0; + break; + } + + } -void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, - arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const + GEOSX_ERROR_IF( notFound, "Component Water/Brine is not found!" ); + + + MakeTable( inputPara ); + + MakeTable( inputPara ); + +} + +void BrineEnthalpyFunction::MakeTable( string_array const & inputPara ) { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( useMass ); + real64_array pressures; + real64_array temperatures; + + real64 PStart, PEnd, dP; + real64 TStart, TEnd, dT; + real64 P, T, m; + + dT = -1.0; + dP = -1.0; + TStart = -1.0; + TEnd = -1.0; + PStart = -1.0; + PEnd = -1.0; + + + GEOSX_ERROR_IF( inputPara.size() < 9, "Invalid BrineEnthalpy input!" ); + + try + { + + PStart = stod( inputPara[2] ); + PEnd = stod( inputPara[3] ); + dP = stod( inputPara[4] ); + + TStart = stod( inputPara[5] ); + TEnd = stod( inputPara[6] ); + dT = stod( inputPara[7] ); + + m = stod( inputPara[8] ); + + } + catch( const std::invalid_argument & e ) + { + + GEOSX_ERROR( "Invalid BrineEnthalpy argument:" + std::string( e.what())); + + } + + P = PStart; + + while( P <= PEnd ) + { + + pressures.emplace_back( P ); + P += dP; + + } + + T = TStart; + + while( T <= TEnd ) + { + + temperatures.emplace_back( T ); + T += dT; + + } + + localIndex const nP = pressures.size(); + localIndex const nT = temperatures.size(); + + real64_array2d enthalpies( nP, nT ); - localIndex const numComponents = phaseComposition.size(); + CalculateBrineEnthalpy( pressures, temperatures, m, enthalpies ); - value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; - // pressure derivative - value.m_der[0] = 0.001; - // temperature derivative - value.m_der[numComponents+1] = 1.0; + m_BrineEnthalpyTable = std::make_shared< XYTable >( "BrineEnthalpyTable", pressures, temperatures, enthalpies ); + + + real64_array2d CO2Enthalpies( nP, nT ); + real64_array2d CO2Densities( nP, nT ); + + SpanWagnerCO2DensityFunction::CalculateCO2Density( pressures, temperatures, CO2Densities ); + + CO2EnthalpyFunction::CalculateCO2Enthalpy( pressures, temperatures, CO2Densities, CO2Enthalpies ); + + m_CO2EnthalpyTable = std::make_shared< XYTable >( "CO2EnthalpyTable", pressures, temperatures, CO2Enthalpies ); + } +void BrineEnthalpyFunction::CalculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ) +{ + + GEOSX_UNUSED_VAR( pressure ); + + static real64 a[4][3] = { + {-9633.6, -4080.0, 286.49}, + {166.58, 68.577, -4.6856}, + {-0.90963, -0.36524, 0.0249667}, + {1.7965e-3, 7.1924e-4, -4.9e-5} + }; + + real64 x1, x2, h1, h2, dh, T; + + x1 = 1000.0 / (1000.0 + 58.44 * m); + + x2 = 58.44 * m / (1000.0 + 58.44 * m); + + for(localIndex ip = 0; ip < pressure.size(); ++ip) + { + + for(localIndex it = 0; it < temperature.size(); ++it) + { + + T = temperature[it]; + + dh = 0.0; + + for(localIndex i = 0; i < 4; ++i) + for(localIndex j = 0; j < 3; ++j) + { + + dh += a[i][j] * pow(T, real64(i)) * pow(m, real64(j)); + + } + + dh *= 4.184 / (1000.0 + 58.44 * m); + + + h1 = 0.12453e-4 * pow(T, 3.0) - 0.45137e-2 * pow(T, 2.0) + 4.81155 * T - 29.578; + + h2 = (-0.83624e-3 * pow(T, 3.0) + 0.16792 * pow(T, 2.0) - 25.9293 * T) * 4.184 / 58.44; + enthalpy[ip][it] = (x1 * h1 + x2 * h2 + m * dh) * 1000.0; + + } + } +} + +void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +{ + GEOSX_UNUSED_VAR( phaseComposition ); + + localIndex const numComponents = phaseComposition.size(); + + EvalArgs2D P, T, enthalpy, CO2Enthalpy; + P.m_var = pressure.m_var; + P.m_der[0] = 1.0; + + T.m_var = temperature.m_var; + T.m_der[1] = 1.0; + + enthalpy = m_BrineEnthalpyTable->Value( P, T ); + + CO2Enthalpy = m_CO2EnthalpyTable->Value( P, T ); + + + //assume there are only CO2 and brine here. + + EvalVarArgs enth1, enth2; + + enth1.m_var = CO2Enthalpy.m_var; + enth1.m_der[0] = CO2Enthalpy.m_der[0]; + enth1.m_der[numComponents + 1] = CO2Enthalpy.m_der[1]; + + enth2.m_var = enthalpy.m_var; + enth2.m_der[0] = enthalpy.m_der[0]; + enth2.m_der[numComponents + 1] = enthalpy.m_der[1]; + + real64 C = phaseComposition[m_waterIndex].m_var; + + real64 const waterMW = m_componentMolarWeight[m_waterIndex]; + real64 const CO2MW = m_componentMolarWeight[m_CO2Index]; + + if( useMass ) + { + + EvalVarArgs X = C * waterMW / (C * waterMW + (1.0 - C) * CO2MW); + X.m_der[m_waterIndex+1] = 1.0; + + value = (1.0 - X ) * enth1 + X * enth2; + + } + else + { + + EvalVarArgs X = C; + X.m_der[m_waterIndex+1] = 1.0; + + value = (1.0 - X ) * enth1 / CO2MW + X * enth2 / waterMW; + + } + +} REGISTER_CATALOG_ENTRY( PVTFunction, BrineEnthalpyFunction, diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp index befe10b65c7..5d884e430da 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp @@ -50,10 +50,17 @@ class BrineEnthalpyFunction : public PVTFunction virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass = 0 ) const override; - static void CalculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & enthalpy ); - private: + void MakeTable( string_array const & inputPara ); + + void CalculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ); + + TableFunctionPtr m_BrineEnthalpyTable; + TableFunctionPtr m_CO2EnthalpyTable; + localIndex m_waterIndex; + localIndex m_CO2Index; + }; } diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp index 30b3386a90c..8c959210c99 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp @@ -17,6 +17,7 @@ */ #include "constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp" +#include "constitutive/fluid/PVTFunctions/SpanWagnerCO2DensityFunction.hpp" namespace geosx { @@ -30,24 +31,296 @@ CO2EnthalpyFunction::CO2EnthalpyFunction( string_array const & inputPara, string_array const & componentNames, real64_array const & componentMolarWeight ): PVTFunction( inputPara[1], componentNames, componentMolarWeight ) -{} +{ + + bool notFound = 1; + + for( localIndex i = 0; i < componentNames.size(); ++i ) + { + + if( streq( componentNames[i], "CO2" ) || streq( componentNames[i], "co2" )) + { + m_CO2Index = i; + notFound = 0; + break; + } + + } + + GEOSX_ERROR_IF( notFound, "Component CO2 is not found!" ); -void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, - arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const + MakeTable( inputPara ); + +} + +void CO2EnthalpyFunction::MakeTable( string_array const & inputPara ) { - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( useMass ); - localIndex const numComponents = phaseComposition.size(); + real64_array pressures; + real64_array temperatures; + + real64 PStart, PEnd, dP; + real64 TStart, TEnd, dT; + real64 P, T; + + dT = -1.0; + dP = -1.0; + TStart = -1.0; + TEnd = -1.0; + PStart = -1.0; + PEnd = -1.0; + + GEOSX_ERROR_IF( inputPara.size() < 8, "Invalid CO2Enthalpy input!" ); + + try + { + + PStart = stod( inputPara[2] ); + PEnd = stod( inputPara[3] ); + dP = stod( inputPara[4] ); + + TStart = stod( inputPara[5] ); + TEnd = stod( inputPara[6] ); + dT = stod( inputPara[7] ); + + } + catch( const std::invalid_argument & e ) + { + + GEOSX_ERROR( "Invalid CO2Enthalpy argument:" + std::string( e.what())); + + } + + P = PStart; + + while( P <= PEnd ) + { + + pressures.emplace_back( P ); + P += dP; + + } + + T = TStart; + + while( T <= TEnd ) + { + + temperatures.emplace_back( T ); + T += dT; + + } + + localIndex nP = pressures.size(); + localIndex nT = temperatures.size(); + + real64_array2d enthalpies( nP, nT ); + real64_array2d densities( nP, nT ); + + SpanWagnerCO2DensityFunction::CalculateCO2Density( pressures, temperatures, densities ); + + CalculateCO2Enthalpy( pressures, temperatures, densities, enthalpies ); + + m_CO2EnthalpyTable = std::make_shared< XYTable >( "CO2EnthalpyTable", pressures, temperatures, enthalpies ); + + +} + +void CO2EnthalpyFunction::CalculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & density, real64_array2d const & enthalpy ) +{ + + static const real64 dc = 467.6; + static const real64 Tc = 304.128; + static const real64 a0[8] = {8.37304456, -3.70454304, 2.500, 1.99427042, 0.62105248, 0.41195293, 1.04028922, 0.08327678}; + + static const real64 theta0[8] = {0.0, 0.0, 0.0, 3.15163, 6.11190, 6.77708, 11.32384, 27.08792}; + + static const real64 ni[42] = {0.38856823203161, 2.938547594274, -5.5867188534934, -0.76753199592477, + 0.31729005580416, 0.54803315897767, 0.12279411220335, 2.165896154322, + 1.5841735109724, -0.23132705405503, 0.058116916431436, -0.55369137205382, + 0.48946615909422, -0.024275739843501, 0.062494790501678, -0.12175860225246, + -0.37055685270086, -0.016775879700426 ,-0.11960736637987, -0.045619362508778, + 0.035612789270346, -0.0074427727132052,-0.0017395704902432,-0.021810121289527, + 0.024332166559236, -0.037440133423463, 0.14338715756878, -0.13491969083286, + -0.02315122505348, 0.012363125492901, 0.002105832197294, -0.00033958519026368, + 0.0055993651771592,-0.00030335118055646, -213.6548868832, 26641.569149272, + -24027.212204557, -283.41603423999, 212.47284400179, -0.66642276540751, + 0.72608632349897, 0.055068668612842}; + + static const real64 di[42] = {1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0, 1.0, 2.0, 4.0, + 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 1.0, 1.0, 4.0, 4.0, + 4.0, 7.0, 8.0, 2.0, 3.0, 3.0, 5.0, 5.0, 6.0, 7.0, + 8.0, 10.0, 4.0, 8.0, 2.0, 2.0, 2.0, 3.0, 3.0, 0.0, + 0.0, 0.0}; + + static const real64 ti[42] = {0.00, 0.75, 1.00, 2.00, 0.75, 2.00, 0.75, 1.50, 1.50, 2.50, + 0.00, 1.50, 2.00, 0.00, 1.00, 2.00, 3.00, 6.00, 3.00, 6.00, + 8.00, 6.00, 0.00, 7.00, 12.00, 16.00, 22.00, 24.00, 16.0, 24.00, + 8.00, 2.00, 28.00, 14.00, 1.00, 0.00, 1.00, 3.00, 3.00, 0.00, + 0.00, 0.00}; + static const real64 ci[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, + 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, + 4.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0}; + + static const real64 alphai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 25.0,25.0,25.0,15.0,20.0, 0.0, + 0.0, 0.0}; + + static const real64 betai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0,325.0,300.0,300.0,275.0,275.0, 0.3, + 0.3, 0.3}; + + static const real64 gammai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 1.16, 1.19, 1.19, 1.25,1.22, 0.0, + 0.0, 0.0}; + static const real64 ei[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, + 0.0, 0.0}; + + static const real64 bi[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.875, + 0.925, 0.875}; + + static const real64 Ai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.7, + 0.7, 0.7}; + + static const real64 Bi[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, + 0.3, 1.0}; + + static const real64 Ci[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, + 10.0, 12.5}; + + static const real64 Di[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 275.0, + 275.0, 275.0}; + + real64 rd, rt, den; + real64 Tkelvin; + + real64 phi0t; + real64 phirt, phird; + + real64 theta, delta, R, deltard; + + for(localIndex ip = 0; ip < pressure.size(); ++ip) + for(localIndex it = 0; it < temperature.size(); ++it) + { + + den = density[ip][it]; + Tkelvin = temperature[it] + 273.15; + rd=den/dc; + rt=Tc/Tkelvin; + + phi0t = a0[1] + a0[2] / rt; + + for(localIndex i=3; i<8; i++) + { + phi0t += a0[i] * theta0[i] * (1.0 / (1.0 - exp(-rt * theta0[i])) - 1.0); + + } + + phird = 0.0; + phirt = 0.0; + + for(localIndex i=0; i<7; i++) + { + + phird += ni[i] * di[i] * pow(rd, di[i] - 1.0) * pow(rt, ti[i]); + + phirt += ni[i] * ti[i] * pow(rd, di[i]) * pow(rt, ti[i] - 1.0); + + } + + + for(localIndex i=7; i<34; i++) + { + + phird += ni[i] * exp(-pow(rd, ci[i])) * pow(rd, di[i]-1.0) * pow(rt, ti[i]) * (di[i]-ci[i] * pow(rd, ci[i])); + + phirt += ni[i] * ti[i] * pow(rd, di[i]) * pow(rt, ti[i] - 1.0) * exp(-pow(rd, ci[i])); + + } + + + for(localIndex i=34; i<39; i++) + { + + phird += ni[i] * pow(rd, di[i]) * pow(rt, ti[i]) * exp(-alphai[i] * pow(rd - ei[i], 2.0) - betai[i] * pow(rt - gammai[i], 2.0)) * (di[i] / rd - 2.0 * alphai[i] * (rd - ei[i])); + + phirt += ni[i] * pow(rd, di[i]) * pow(rt, ti[i]) * exp(-alphai[i] * pow(rd - ei[i], 2.0) - betai[i] * pow(rt - gammai[i], 2.0)) * (ti[i] / rt - 2.0 * betai[i] * (rt - gammai[i])); + + } + + for(localIndex i=39; i<42; i++) + { + + theta = (1.0 - rt) + Ai[i] * pow(pow(rd - 1.0, 2.0), (1.0 / (2.0 * betai[i]))); + delta = pow(theta, 2.0) + Bi[i] * pow(rd - 1.0, 2.0*alphai[i]); + R = exp(-Ci[i] * pow(rd - 1.0, 2.0) - Di[i] * pow(rt - 1.0, 2.0)); + deltard = (rd - 1.0) * (Ai[i] * theta * 2.0 / betai[i] * pow(pow(rd - 1.0, 2.0), 0.5 / betai[i] - 1.0) + 2.0 * Bi[i] * alphai[i] * pow(pow(rd - 1.0, 2.0), alphai[i] - 1.0)); + + phird += ni[i] * (pow(delta, bi[i]) * (R + rd *(-2.0 *Ci[i] * (rd - 1.0) * R)) + bi[i] * pow(delta, bi[i] - 1.0) * deltard * rd * R); + + phirt += ni[i] * rd *(-2.0 * theta * bi[i] * pow(delta, bi[i] - 1.0) * R + pow(delta, bi[i]) * (-2.0 * Di[i] * R * (rt - 1.0))); + + } + + enthalpy[ip][it] = (1.0 + rt * (phi0t + phirt) + rd * phird) * Tkelvin * 188.924; + + } - value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; - // pressure derivative - value.m_der[0] = 0.001; - // temperature derivative - value.m_der[numComponents+1] = 1.0; } + +void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +{ + + localIndex const numComponents = phaseComposition.size(); + + EvalArgs2D P, T, enth; + P.m_var = pressure.m_var; + P.m_der[0] = 1.0; + + T.m_var = temperature.m_var; + T.m_der[1] = 1.0; + enth = m_CO2EnthalpyTable->Value( P, T ); + + if( !useMass ) + { + real64 CO2MW = m_componentMolarWeight[m_CO2Index]; + + enth /= CO2MW; + } + + value.m_var = enth.m_var; + value.m_der[0] = enth.m_der[0]; + value.m_der[numComponents+1] = enth.m_der[1]; + +} REGISTER_CATALOG_ENTRY( PVTFunction, CO2EnthalpyFunction, diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp index d8d37fe9397..76396613075 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp @@ -50,11 +50,19 @@ class CO2EnthalpyFunction : public PVTFunction virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass = 0 ) const override; - static void CalculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & enthalpy ); + static void CalculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & density, real64_array2d const & enthalpy ); + + private: + void MakeTable( string_array const & inputPara ); + + TableFunctionPtr m_CO2EnthalpyTable; + localIndex m_CO2Index; + + }; } diff --git a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtgas.txt b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtgas.txt index fd3d781edae..af6518e38ec 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtgas.txt +++ b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtgas.txt @@ -1,2 +1,3 @@ -DensityFun SpanWagnerCO2Density 1e6 1.5e7 5e4 94 96 1 -ViscosityFun FenghourCO2Viscosity 1e6 1.5e7 5e4 94 96 1 +DensityFun SpanWagnerCO2Density 1e6 1.5e7 5e4 94.85 130 1 +ViscosityFun FenghourCO2Viscosity 1e6 1.5e7 5e4 94.85 130 1 +EnthalpyFun CO2Enthalpy 1e6 1.5e7 5e4 94.85 130 1 diff --git a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtliquid.txt b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtliquid.txt index f5852c95fd9..3e6e9581ed3 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtliquid.txt +++ b/src/coreComponents/physicsSolvers/multiphysics/integratedTests/pvt_tables/pvtliquid.txt @@ -1,2 +1,3 @@ -DensityFun BrineCO2Density 1e6 1.5e7 5e4 94 96 1 0 +DensityFun BrineCO2Density 1e6 1.5e7 5e4 94.85 130 1 0 ViscosityFun BrineViscosity 0 +EnthalpyFun BrineEnthalpy 1e6 1.5e7 5e4 94.85 130 1 0 From e259158dcdffaf8316aa4bb8a9df3b7e9d0d4f6b Mon Sep 17 00:00:00 2001 From: Matteo Cusini Date: Mon, 22 Feb 2021 22:03:36 -0800 Subject: [PATCH 17/34] Post merge fixes. Mainly fixing the strings. --- .../constitutive/fluid/MultiFluidBase.cpp | 18 ++-- .../fluid/MultiPhaseMultiComponentFluid.cpp | 2 +- .../PVTFunctions/BrineEnthalpyFunction.cpp | 20 ++-- .../PVTFunctions/BrineEnthalpyFunction.hpp | 12 +-- .../BrineInternalEnergyFunction.cpp | 2 +- .../BrineInternalEnergyFunction.hpp | 10 +- .../PVTFunctions/CO2EnthalpyFunction.cpp | 14 +-- .../PVTFunctions/CO2EnthalpyFunction.hpp | 12 +-- .../CO2InternalEnergyFunction.cpp | 2 +- .../CO2InternalEnergyFunction.hpp | 10 +- .../fluidFlow/CompositionalMultiphaseFlow.cpp | 102 +++++++++--------- .../fluidFlow/CompositionalMultiphaseFlow.hpp | 2 +- ...rmalCompositionalMultiphaseFlowKernels.hpp | 12 +-- 13 files changed, 108 insertions(+), 110 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index f3d2254ca38..287f83516c0 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -100,27 +100,25 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) registerWrapper( viewKeyStruct::useMassString(), &m_useMass ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::phaseEnthalpyString(), &m_phaseEnthalpy )-> + registerWrapper( viewKeyStruct::phaseEnthalpyString(), &m_phaseEnthalpy ). setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseEnthalpy_dPressureString(), &m_dPhaseEnthalpy_dPressure )-> + registerWrapper( viewKeyStruct::dPhaseEnthalpy_dPressureString(), &m_dPhaseEnthalpy_dPressure ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseEnthalpy_dTemperatureString(), &m_dPhaseEnthalpy_dTemperature )-> + registerWrapper( viewKeyStruct::dPhaseEnthalpy_dTemperatureString(), &m_dPhaseEnthalpy_dTemperature ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseEnthalpy_dGlobalCompFractionString(), &m_dPhaseEnthalpy_dGlobalCompFraction )-> + registerWrapper( viewKeyStruct::dPhaseEnthalpy_dGlobalCompFractionString(), &m_dPhaseEnthalpy_dGlobalCompFraction ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::phaseInternalEnergyString(), &m_phaseInternalEnergy )-> + registerWrapper( viewKeyStruct::phaseInternalEnergyString(), &m_phaseInternalEnergy ). setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dPressureString(), &m_dPhaseInternalEnergy_dPressure )-> + registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dPressureString(), &m_dPhaseInternalEnergy_dPressure ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dTemperatureString(), &m_dPhaseInternalEnergy_dTemperature )-> + registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dTemperatureString(), &m_dPhaseInternalEnergy_dTemperature ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dGlobalCompFractionString(), &m_dPhaseInternalEnergy_dGlobalCompFraction )-> + registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dGlobalCompFractionString(), &m_dPhaseInternalEnergy_dGlobalCompFraction ). setRestartFlags( RestartFlags::NO_WRITE ); - - } void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPts ) diff --git a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp index fd5be4dfbba..617bc807478 100644 --- a/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp +++ b/src/coreComponents/constitutive/fluid/MultiPhaseMultiComponentFluid.cpp @@ -137,7 +137,7 @@ void MultiPhaseMultiComponentFluid::createPVTModels() } else if( strs[0] == "EnthalpyFun" ) { - m_phaseEnthalpyFuns.emplace_back( PVTFunction::CatalogInterface::Factory( strs[ 1 ], + m_phaseEnthalpyFuns.emplace_back( PVTFunction::CatalogInterface::factory( strs[ 1 ], strs, m_componentNames, m_componentMolarWeight ) ); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp index bc84ca3c390..cb4a2e6e24d 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp @@ -67,13 +67,13 @@ BrineEnthalpyFunction::BrineEnthalpyFunction( string_array const & inputPara, GEOSX_ERROR_IF( notFound, "Component Water/Brine is not found!" ); - MakeTable( inputPara ); + makeTable( inputPara ); - MakeTable( inputPara ); + makeTable( inputPara ); } -void BrineEnthalpyFunction::MakeTable( string_array const & inputPara ) +void BrineEnthalpyFunction::makeTable( string_array const & inputPara ) { real64_array pressures; real64_array temperatures; @@ -138,7 +138,7 @@ void BrineEnthalpyFunction::MakeTable( string_array const & inputPara ) real64_array2d enthalpies( nP, nT ); - CalculateBrineEnthalpy( pressures, temperatures, m, enthalpies ); + calculateBrineEnthalpy( pressures, temperatures, m, enthalpies ); m_BrineEnthalpyTable = std::make_shared< XYTable >( "BrineEnthalpyTable", pressures, temperatures, enthalpies ); @@ -146,15 +146,15 @@ void BrineEnthalpyFunction::MakeTable( string_array const & inputPara ) real64_array2d CO2Enthalpies( nP, nT ); real64_array2d CO2Densities( nP, nT ); - SpanWagnerCO2DensityFunction::CalculateCO2Density( pressures, temperatures, CO2Densities ); + SpanWagnerCO2DensityFunction::calculateCO2Density( pressures, temperatures, CO2Densities ); - CO2EnthalpyFunction::CalculateCO2Enthalpy( pressures, temperatures, CO2Densities, CO2Enthalpies ); + CO2EnthalpyFunction::calculateCO2Enthalpy( pressures, temperatures, CO2Densities, CO2Enthalpies ); m_CO2EnthalpyTable = std::make_shared< XYTable >( "CO2EnthalpyTable", pressures, temperatures, CO2Enthalpies ); } -void BrineEnthalpyFunction::CalculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ) +void BrineEnthalpyFunction::calculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ) { GEOSX_UNUSED_VAR( pressure ); @@ -203,7 +203,7 @@ void BrineEnthalpyFunction::CalculateBrineEnthalpy( real64_array const & pressur } } -void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +void BrineEnthalpyFunction::evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { localIndex const numComponents = phaseComposition.size(); @@ -214,9 +214,9 @@ void BrineEnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArg T.m_var = temperature.m_var; T.m_der[1] = 1.0; - enthalpy = m_BrineEnthalpyTable->Value( P, T ); + enthalpy = m_BrineEnthalpyTable->value( P, T ); - CO2Enthalpy = m_CO2EnthalpyTable->Value( P, T ); + CO2Enthalpy = m_CO2EnthalpyTable->value( P, T ); //assume there are only CO2 and brine here. diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp index 5d884e430da..f6cccc15e9d 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp @@ -38,23 +38,23 @@ class BrineEnthalpyFunction : public PVTFunction static constexpr auto m_catalogName = "BrineEnthalpy"; - static string CatalogName() { return m_catalogName; } - virtual string getCatalogName() const override final { return CatalogName(); } + static string catalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return catalogName(); } - virtual PVTFuncType FunctionType() const override + virtual PVTFuncType functionType() const override { return PVTFuncType::ENTHALPY; } - virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + virtual void evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass = 0 ) const override; private: - void MakeTable( string_array const & inputPara ); + void makeTable( string_array const & inputPara ); - void CalculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ); + void calculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ); TableFunctionPtr m_BrineEnthalpyTable; TableFunctionPtr m_CO2EnthalpyTable; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp index aa2d9ff7646..4b754bfef49 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp @@ -32,7 +32,7 @@ BrineInternalEnergyFunction::BrineInternalEnergyFunction( string_array const & i PVTFunction( inputPara[1], componentNames, componentMolarWeight ) {} -void BrineInternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, +void BrineInternalEnergyFunction::evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { GEOSX_UNUSED_VAR( phaseComposition ); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp index ee326397fde..ca83f3dca56 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp @@ -38,19 +38,19 @@ class BrineInternalEnergyFunction : public PVTFunction static constexpr auto m_catalogName = "BrineInternalEnergy"; - static string CatalogName() { return m_catalogName; } - virtual string getCatalogName() const override final { return CatalogName(); } + static string catalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return catalogName(); } - virtual PVTFuncType FunctionType() const override + virtual PVTFuncType functionType() const override { return PVTFuncType::INTERNALENR; } - virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + virtual void evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass = 0 ) const override; - static void CalculateBrineInternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); + static void calculateBrineInternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); private: diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp index 8c959210c99..8c6ee05257d 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.cpp @@ -49,11 +49,11 @@ CO2EnthalpyFunction::CO2EnthalpyFunction( string_array const & inputPara, GEOSX_ERROR_IF( notFound, "Component CO2 is not found!" ); - MakeTable( inputPara ); + makeTable( inputPara ); } -void CO2EnthalpyFunction::MakeTable( string_array const & inputPara ) +void CO2EnthalpyFunction::makeTable( string_array const & inputPara ) { real64_array pressures; @@ -117,16 +117,16 @@ void CO2EnthalpyFunction::MakeTable( string_array const & inputPara ) real64_array2d enthalpies( nP, nT ); real64_array2d densities( nP, nT ); - SpanWagnerCO2DensityFunction::CalculateCO2Density( pressures, temperatures, densities ); + SpanWagnerCO2DensityFunction::calculateCO2Density( pressures, temperatures, densities ); - CalculateCO2Enthalpy( pressures, temperatures, densities, enthalpies ); + calculateCO2Enthalpy( pressures, temperatures, densities, enthalpies ); m_CO2EnthalpyTable = std::make_shared< XYTable >( "CO2EnthalpyTable", pressures, temperatures, enthalpies ); } -void CO2EnthalpyFunction::CalculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & density, real64_array2d const & enthalpy ) +void CO2EnthalpyFunction::calculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & density, real64_array2d const & enthalpy ) { static const real64 dc = 467.6; @@ -295,7 +295,7 @@ void CO2EnthalpyFunction::CalculateCO2Enthalpy( real64_array const & pressure, r } -void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const +void CO2EnthalpyFunction::evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { localIndex const numComponents = phaseComposition.size(); @@ -307,7 +307,7 @@ void CO2EnthalpyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs T.m_var = temperature.m_var; T.m_der[1] = 1.0; - enth = m_CO2EnthalpyTable->Value( P, T ); + enth = m_CO2EnthalpyTable->value( P, T ); if( !useMass ) { diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp index 76396613075..68d4f81d032 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp @@ -38,25 +38,25 @@ class CO2EnthalpyFunction : public PVTFunction static constexpr auto m_catalogName = "CO2Enthalpy"; - static string CatalogName() { return m_catalogName; } - virtual string getCatalogName() const override final { return CatalogName(); } + static string catalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return catalogName(); } - virtual PVTFuncType FunctionType() const override + virtual PVTFuncType functionType() const override { return PVTFuncType::ENTHALPY; } - virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + virtual void evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass = 0 ) const override; - static void CalculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & density, real64_array2d const & enthalpy ); + static void calculateCO2Enthalpy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & density, real64_array2d const & enthalpy ); private: - void MakeTable( string_array const & inputPara ); + void makeTable( string_array const & inputPara ); TableFunctionPtr m_CO2EnthalpyTable; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp index 59d9009e7ca..c6cb5ca0e6f 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.cpp @@ -32,7 +32,7 @@ CO2InternalEnergyFunction::CO2InternalEnergyFunction( string_array const & input PVTFunction( inputPara[1], componentNames, componentMolarWeight ) {} -void CO2InternalEnergyFunction::Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, +void CO2InternalEnergyFunction::evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const { GEOSX_UNUSED_VAR( phaseComposition ); diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp index 91916ce7a1e..253e8ce3321 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergyFunction.hpp @@ -38,19 +38,19 @@ class CO2InternalEnergyFunction : public PVTFunction static constexpr auto m_catalogName = "CO2InternalEnergy"; - static string CatalogName() { return m_catalogName; } - virtual string getCatalogName() const override final { return CatalogName(); } + static string catalogName() { return m_catalogName; } + virtual string getCatalogName() const override final { return catalogName(); } - virtual PVTFuncType FunctionType() const override + virtual PVTFuncType functionType() const override { return PVTFuncType::INTERNALENR; } - virtual void Evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, + virtual void evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass = 0 ) const override; - static void CalculateCO2InternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); + static void calculateCO2InternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); private: diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp index 5d3d3662c64..508fba4c10a 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.cpp @@ -62,13 +62,13 @@ CompositionalMultiphaseFlow::CompositionalMultiphaseFlow( const string & name, m_allowCompDensChopping( 1 ) { //START_SPHINX_INCLUDE_00 - this->registerWrapper( viewKeyStruct::uniformTemperatureString(), &m_uniformTemperature )-> - setInputFlag( InputFlags::REQUIRED )-> + this->registerWrapper( viewKeyStruct::uniformTemperatureString(), &m_uniformTemperature ). + setInputFlag( InputFlags::REQUIRED ). setDescription( "Uniform temperature for isothermal simulations." ); - this->registerWrapper( viewKeyStruct::isothermalFlagString(), &m_isothermalFlag )-> - setApplyDefaultValue( 1 )-> - setInputFlag( InputFlags::OPTIONAL )-> + this->registerWrapper( viewKeyStruct::isothermalFlagString(), &m_isothermalFlag ). + setApplyDefaultValue( 1 ). + setInputFlag( InputFlags::OPTIONAL ). setDescription( "Flag indicating whether the problem is isothermal or not." ); this->registerWrapper( viewKeyStruct::useMassFlagString(), &m_useMass ). @@ -160,22 +160,22 @@ void CompositionalMultiphaseFlow::registerDataOnMesh( Group & meshBodies ) if( m_isothermalFlag == 0 ) { - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString() )-> + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString() ). setPlotLevel( PlotLevel::LEVEL_0 ); - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() )-> + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ). setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() )-> + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ). setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString() )-> + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString() ). setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString() )-> + elementSubRegion.registerWrapper< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString() ). setRestartFlags( RestartFlags::NO_WRITE ); - elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString() )-> + elementSubRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString() ). setRestartFlags( RestartFlags::NO_WRITE ); } } ); @@ -329,9 +329,9 @@ void CompositionalMultiphaseFlow::resizeFields( MeshLevel & meshLevel ) const { forTargetSubRegions( meshLevel, [&]( localIndex const, ElementSubRegionBase & subRegion ) { - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ).resizeDimension< 1 >( NP ); - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ).resizeDimension< 1 >( NP ); - subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ).resizeDimension< 1 >( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ).resizeDimension< 1 >( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString() ).resizeDimension< 1 >( NP ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString() ).resizeDimension< 1 >( NP ); } ); } } @@ -427,7 +427,7 @@ void CompositionalMultiphaseFlow::updatePhaseVolumeFraction( Group & dataGroup, arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); arrayView2d< real64 > const dPhaseVolFrac_dTemp = - dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseVolumeFractionKernel >( m_numComponents, m_numPhases, @@ -519,10 +519,10 @@ void CompositionalMultiphaseFlow::updatePhaseMobility( Group & dataGroup, localI arrayView3d< real64 const > const & dPhaseVisc_dTemp = fluid.dPhaseViscosity_dTemperature(); arrayView2d< real64 > const dPhaseMob_dTemp = - dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseMobility_dTemperatureString() ); arrayView2d< real64 const > const dPhaseVolFrac_dTemp = - dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + dataGroup.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::PhaseMobilityKernel >( m_numComponents, m_numPhases, @@ -575,8 +575,8 @@ void CompositionalMultiphaseFlow::updateFluidModel( Group & dataGroup, localInde } else { - arrayView1d< real64 const > const temperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); - arrayView1d< real64 const > const dTemperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + arrayView1d< real64 const > const temperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + arrayView1d< real64 const > const dTemperature = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); CompositionalMultiphaseFlowKernels::FluidUpdateKernel::launch< serialPolicy >( dataGroup.size(), fluidWrapper, @@ -799,8 +799,8 @@ void CompositionalMultiphaseFlow::backupFields( MeshLevel & mesh ) const { forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { - MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, fluidModelNames()[targetIndex] ); - SolidBase const & solid = GetConstitutiveModel< SolidBase >( subRegion, solidModelNames()[targetIndex] ); + MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidModelNames()[targetIndex] ); + SolidBase const & solid = getConstitutiveModel< SolidBase >( subRegion, solidModelNames()[targetIndex] ); arrayView1d< integer const > const elemGhostRank = subRegion.ghostRank(); @@ -974,20 +974,20 @@ void CompositionalMultiphaseFlow::assembleAccumulationTerms( DomainPartition con { arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); arrayView3d< real64 const > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); arrayView4d< real64 const > const & dPhaseCompFrac_dTemp = fluid.dPhaseCompFraction_dTemperature(); arrayView2d< real64 const > const & phaseInternalEnergyOld = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::phaseInternalEnergyOldString() ); arrayView3d< real64 const > const & phaseInternalEnergy = fluid.phaseInternalEnergy(); arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres = fluid.dPhaseInternalEnergy_dPressure(); arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp = fluid.dPhaseInternalEnergy_dTemperature(); arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp = fluid.dPhaseInternalEnergy_dGlobalCompFraction(); arrayView1d< real64 const > const & rockInternalEnergyOld = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::rockInternalEnergyOldString() ); arrayView2d< real64 const > const & rockInternalEnergy = solid.internalEnergy(); arrayView2d< real64 const > const & dRockInternalEnergy_dTemp = solid.dInternalEnergy_dTemperature(); arrayView2d< real64 const > const & rockDensity = solid.getDensity(); @@ -1228,7 +1228,7 @@ void CompositionalMultiphaseFlow::assembleVolumeBalanceTerms( DomainPartition co else { arrayView2d< real64 const > const & dPhaseVolFrac_dTemp = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); CompositionalMultiphaseFlowKernels::KernelLaunchSelector2 < CompositionalMultiphaseFlowKernels::VolumeBalanceKernel >( m_numComponents, m_numPhases, @@ -1486,7 +1486,7 @@ real64 CompositionalMultiphaseFlow::calculateResidualNorm( DomainPartition const arrayView1d< real64 const > const & localRhs ) { - MeshLevel const & mesh = domain.getMeshBody( 0 )->getMeshLevel( 0 ); + MeshLevel const & mesh = domain.getMeshBody( 0 ).getMeshLevel( 0 ); globalIndex const rankOffset = dofManager.rankOffset(); string const dofKey = dofManager.getKey( viewKeyStruct::dofFieldString() ); @@ -1501,7 +1501,7 @@ real64 CompositionalMultiphaseFlow::calculateResidualNorm( DomainPartition const forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase const & subRegion ) { - MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); + MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); @@ -1548,12 +1548,12 @@ real64 CompositionalMultiphaseFlow::calculateResidualNorm( DomainPartition const forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase const & subRegion ) { - MultiFluidBase const & fluid = GetConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); + MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & refPoro = subRegion.getReference< array1d< real64 > >( viewKeyStruct::referencePorosityString ); + arrayView1d< real64 const > const & refPoro = subRegion.getReference< array1d< real64 > >( viewKeyStruct::referencePorosityString() ); arrayView2d< real64 const > const & totalDens = fluid.totalDensity(); RAJA::ReduceSum< parallelDeviceReduce, real64 > localFlowSum( 0.0 ); @@ -1580,8 +1580,8 @@ real64 CompositionalMultiphaseFlow::calculateResidualNorm( DomainPartition const } ); // compute global residual norm - real64 const flowResidual = std::sqrt( MpiWrapper::Sum( localFlowResidualNorm ) ); - real64 const energyResidual = std::sqrt( MpiWrapper::Sum( localEnergyResidualNorm ) ); + real64 const flowResidual = std::sqrt( MpiWrapper::sum( localFlowResidualNorm ) ); + real64 const energyResidual = std::sqrt( MpiWrapper::sum( localEnergyResidualNorm ) ); residual = ( flowResidual + energyResidual ) / 2; if( getLogLevel() >= 1 && logger::internal::rank==0 ) @@ -1785,10 +1785,10 @@ void CompositionalMultiphaseFlow::applySystemSolution( DofManager const & dofMan if( m_isothermalFlag == 0 ) { - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaTemperatureString ) ); + fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaTemperatureString() ) ); } - getGlobalState().getCommunicationTools().synchronizeFields( fieldNames, &mesh, domain.getNeighbors(), true ); + getGlobalState().getCommunicationTools().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), true ); forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { @@ -1850,11 +1850,11 @@ void CompositionalMultiphaseFlow::resetStateToBeginningOfStep( DomainPartition & forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); arrayView2d< real64 > const & dCompDens = - subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString ); + subRegion.getReference< array2d< real64 > >( viewKeyStruct::deltaGlobalCompDensityString() ); arrayView1d< real64 > const & dTemp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); dPres.setValues< parallelDevicePolicy<> >( 0.0 ); dCompDens.setValues< parallelDevicePolicy<> >( 0.0 ); @@ -1900,9 +1900,9 @@ void CompositionalMultiphaseFlow::implicitStepComplete( real64 const & GEOSX_UNU forTargetSubRegions( mesh, [&]( localIndex const, ElementSubRegionBase & subRegion ) { arrayView1d< real64 const > const dTemp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); arrayView1d< real64 > const temp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -1930,8 +1930,8 @@ void CompositionalMultiphaseFlow::resetViews( MeshLevel & mesh ) m_dCompFrac_dCompDens.setName( getName() + "/accessors/" + viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); m_phaseVolFrac.clear(); - m_phaseVolFrac = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::phaseVolumeFractionString ); - m_phaseVolFrac.setName( getName() + "/accessors/" + viewKeyStruct::phaseVolumeFractionString ); + m_phaseVolFrac = elemManager.constructArrayViewAccessor< real64, 2 >( viewKeyStruct::phaseVolumeFractionString() ); + m_phaseVolFrac.setName( getName() + "/accessors/" + viewKeyStruct::phaseVolumeFractionString() ); m_dPhaseVolFrac_dPres.clear(); m_dPhaseVolFrac_dPres = elemManager.constructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); @@ -2013,58 +2013,58 @@ void CompositionalMultiphaseFlow::resetViews( MeshLevel & mesh ) using keys = MultiFluidBase::viewKeyStruct; m_temperature.clear(); - m_temperature = elemManager.ConstructArrayViewAccessor< real64, 1 >( viewKeyStruct::temperatureString ); + m_temperature = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::temperatureString() ); m_temperature.setName( getName() + "/accessors/" + viewKeyStruct::temperatureString() ); m_deltaTemperature.clear(); - m_deltaTemperature = elemManager.ConstructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaTemperatureString ); + m_deltaTemperature = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaTemperatureString() ); m_deltaTemperature.setName( getName() + "/accessors/" + viewKeyStruct::deltaTemperatureString() ); m_dPhaseVolFrac_dTemp.clear(); - m_dPhaseVolFrac_dTemp = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString ); + m_dPhaseVolFrac_dTemp = elemManager.constructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); m_dPhaseVolFrac_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); m_dPhaseMob_dTemp.clear(); - m_dPhaseMob_dTemp = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + m_dPhaseMob_dTemp = elemManager.constructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseMobility_dTemperatureString() ); m_dPhaseMob_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMobility_dTemperatureString() ); m_dPhaseMassDens_dTemp.clear(); - m_dPhaseMassDens_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseMassDensity_dTemperatureString, + m_dPhaseMassDens_dTemp = elemManager.constructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseMassDensity_dTemperatureString(), targetRegionNames(), fluidModelNames() ); m_dPhaseMassDens_dTemp.setName( getName() + "/accessors/" + keys::dPhaseMassDensity_dTemperatureString() ); m_dPhaseCompFrac_dTemp.clear(); - m_dPhaseCompFrac_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseCompFraction_dTemperatureString, + m_dPhaseCompFrac_dTemp = elemManager.constructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseCompFraction_dTemperatureString(), targetRegionNames(), fluidModelNames() ); m_dPhaseCompFrac_dTemp.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dTemperatureString() ); m_dPhaseMob_dTemp.clear(); - m_dPhaseMob_dTemp = elemManager.ConstructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseMobility_dTemperatureString ); + m_dPhaseMob_dTemp = elemManager.constructArrayViewAccessor< real64, 2 >( viewKeyStruct::dPhaseMobility_dTemperatureString() ); m_dPhaseMob_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMobility_dTemperatureString() ); m_phaseEnthalpy.clear(); - m_phaseEnthalpy = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::phaseEnthalpyString(), + m_phaseEnthalpy = elemManager.constructMaterialArrayViewAccessor< real64, 3 >( keys::phaseEnthalpyString(), targetRegionNames(), fluidModelNames() ); m_phaseEnthalpy.setName( getName() + "/accessors/" + keys::phaseEnthalpyString() ); m_dPhaseEnthalpy_dPres.clear(); - m_dPhaseEnthalpy_dPres = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dPressureString(), + m_dPhaseEnthalpy_dPres = elemManager.constructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dPressureString(), targetRegionNames(), fluidModelNames() ); m_dPhaseEnthalpy_dPres.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dPressureString() ); m_dPhaseEnthalpy_dTemp.clear(); - m_dPhaseEnthalpy_dTemp = elemManager.ConstructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dTemperatureString(), + m_dPhaseEnthalpy_dTemp = elemManager.constructMaterialArrayViewAccessor< real64, 3 >( keys::dPhaseEnthalpy_dTemperatureString(), targetRegionNames(), fluidModelNames() ); m_dPhaseEnthalpy_dTemp.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dTemperatureString() ); m_dPhaseEnthalpy_dComp.clear(); - m_dPhaseEnthalpy_dComp = elemManager.ConstructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseEnthalpy_dGlobalCompFractionString(), + m_dPhaseEnthalpy_dComp = elemManager.constructMaterialArrayViewAccessor< real64, 4 >( keys::dPhaseEnthalpy_dGlobalCompFractionString(), targetRegionNames(), fluidModelNames() ); m_dPhaseEnthalpy_dComp.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dGlobalCompFractionString() ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp index 7d78d1a5000..2ee2473f3d3 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlow.hpp @@ -279,7 +279,7 @@ class CompositionalMultiphaseFlow : public FlowSolverBase static constexpr char const * temperatureString() { return "temperature"; } - static constexpr char const * deltaTemperatureString() { "deltaTemperature"; } + static constexpr char const * deltaTemperatureString() { return "deltaTemperature"; } static constexpr char const * useMassFlagString() { return "useMass"; } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp index 6921abed77d..d883c469ea5 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFlowKernels.hpp @@ -165,7 +165,7 @@ struct FluidUpdateKernel { for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k], temp, compFrac[k] ); + fluidWrapper.update( k, q, pres[k], temp, compFrac[k] ); } } ); } @@ -183,7 +183,7 @@ struct FluidUpdateKernel { for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); + fluidWrapper.update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); } } ); } @@ -202,7 +202,7 @@ struct FluidUpdateKernel localIndex const k = targetSet[a]; for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); + fluidWrapper.update( k, q, pres[k] + dPres[k], temp, compFrac[k] ); } } ); } @@ -220,7 +220,7 @@ struct FluidUpdateKernel localIndex const k = targetSet[a]; for( localIndex q = 0; q < fluidWrapper.numGauss(); ++q ) { - fluidWrapper.Update( k, q, pres[k], temp, compFrac[k] ); + fluidWrapper.update( k, q, pres[k], temp, compFrac[k] ); } } ); } @@ -436,7 +436,7 @@ void KernellaunchSelectorCompSwitch( T value, LAMBDA && lambda ) } // namespace helpers template< typename KERNELWRAPPER, typename ... ARGS > -void KernellaunchSelector1( localIndex numComp, ARGS && ... args ) +void KernelLaunchSelector1( localIndex numComp, ARGS && ... args ) { internal::KernellaunchSelectorCompSwitch( numComp, [&] ( auto NC ) { @@ -445,7 +445,7 @@ void KernellaunchSelector1( localIndex numComp, ARGS && ... args ) } template< typename KERNELWRAPPER, typename ... ARGS > -void KernellaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ) +void KernelLaunchSelector2( localIndex numComp, localIndex numPhase, ARGS && ... args ) { internal::KernellaunchSelectorCompSwitch( numComp, [&] ( auto NC ) { From 628cdd0a57db6de32e118a8bfed7dda351ef4731 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 13 Oct 2021 17:08:37 -0700 Subject: [PATCH 18/34] removed old files not compiled --- .../PVTFunctions/BrineEnthalpyFunction.cpp | 266 --- .../PVTFunctions/BrineEnthalpyFunction.hpp | 71 - .../BrineInternalEnergyFunction.cpp | 58 - .../BrineInternalEnergyFunction.hpp | 64 - .../CompositionalMultiphaseFlowKernels.cpp | 1595 ----------------- 5 files changed, 2054 deletions(-) delete mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp delete mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp delete mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp delete mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp delete mode 100644 src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp deleted file mode 100644 index d896f812ca7..00000000000 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 Total, S.A - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file BrineEnthalpyFunction.cpp - */ - -#include "constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp" -#include "constitutive/fluid/PVTFunctions/CO2EnthalpyFunction.hpp" -#include "constitutive/fluid/PVTFunctions/SpanWagnerCO2DensityFunction.hpp" - -namespace geosx -{ - -using namespace stringutilities; - -namespace PVTProps -{ - -BrineEnthalpyFunction::BrineEnthalpyFunction( string_array const & inputPara, - string_array const & componentNames, - real64_array const & componentMolarWeight ): - PVTFunction( inputPara[1], componentNames, componentMolarWeight ) -{ - - bool notFound = 1; - - for( localIndex i = 0; i < componentNames.size(); ++i ) - { - - if( streq( componentNames[i], "CO2" ) || streq( componentNames[i], "co2" )) - { - m_CO2Index = i; - notFound = 0; - break; - } - - } - - GEOSX_ERROR_IF( notFound, "Component CO2 is not found!" ); - - notFound = 1; - - for( localIndex i = 0; i < componentNames.size(); ++i ) - { - - if( streq( componentNames[i], "Water" ) || streq( componentNames[i], "water" )) - { - m_waterIndex = i; - notFound = 0; - break; - } - - } - - GEOSX_ERROR_IF( notFound, "Component Water/Brine is not found!" ); - - - makeTable( inputPara ); - - makeTable( inputPara ); - -} - -void BrineEnthalpyFunction::makeTable( string_array const & inputPara ) -{ - real64_array pressures; - real64_array temperatures; - - real64 PStart, PEnd, dP; - real64 TStart, TEnd, dT; - real64 P, T, m; - - dT = -1.0; - dP = -1.0; - TStart = -1.0; - TEnd = -1.0; - PStart = -1.0; - PEnd = -1.0; - - - GEOSX_ERROR_IF( inputPara.size() < 9, "Invalid BrineEnthalpy input!" ); - - try - { - - PStart = stod( inputPara[2] ); - PEnd = stod( inputPara[3] ); - dP = stod( inputPara[4] ); - - TStart = stod( inputPara[5] ); - TEnd = stod( inputPara[6] ); - dT = stod( inputPara[7] ); - - m = stod( inputPara[8] ); - - } - catch( const std::invalid_argument & e ) - { - - GEOSX_ERROR( "Invalid BrineEnthalpy argument:" + std::string( e.what())); - - } - - P = PStart; - - while( P <= PEnd ) - { - - pressures.emplace_back( P ); - P += dP; - - } - - T = TStart; - - while( T <= TEnd ) - { - - temperatures.emplace_back( T ); - T += dT; - - } - - localIndex const nP = pressures.size(); - localIndex const nT = temperatures.size(); - - real64_array2d enthalpies( nP, nT ); - - calculateBrineEnthalpy( pressures, temperatures, m, enthalpies ); - - m_BrineEnthalpyTable = std::make_shared< XYTable >( "BrineEnthalpyTable", pressures, temperatures, enthalpies ); - - - real64_array2d CO2Enthalpies( nP, nT ); - real64_array2d CO2Densities( nP, nT ); - - SpanWagnerCO2DensityFunction::calculateCO2Density( pressures, temperatures, CO2Densities ); - - CO2EnthalpyFunction::calculateCO2Enthalpy( pressures, temperatures, CO2Densities, CO2Enthalpies ); - - m_CO2EnthalpyTable = std::make_shared< XYTable >( "CO2EnthalpyTable", pressures, temperatures, CO2Enthalpies ); - -} - -void BrineEnthalpyFunction::calculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ) -{ - - GEOSX_UNUSED_VAR( pressure ); - - static real64 a[4][3] = { - {-9633.6, -4080.0, 286.49}, - {166.58, 68.577, -4.6856}, - {-0.90963, -0.36524, 0.0249667}, - {1.7965e-3, 7.1924e-4, -4.9e-5} - }; - - real64 x1, x2, h1, h2, dh, T; - - x1 = 1000.0 / (1000.0 + 58.44 * m); - - x2 = 58.44 * m / (1000.0 + 58.44 * m); - - for( localIndex ip = 0; ip < pressure.size(); ++ip ) - { - - for( localIndex it = 0; it < temperature.size(); ++it ) - { - - T = temperature[it]; - - dh = 0.0; - - for( localIndex i = 0; i < 4; ++i ) - for( localIndex j = 0; j < 3; ++j ) - { - - dh += a[i][j] * pow( T, real64( i )) * pow( m, real64( j )); - - } - - dh *= 4.184 / (1000.0 + 58.44 * m); - - - h1 = 0.12453e-4 * pow( T, 3.0 ) - 0.45137e-2 * pow( T, 2.0 ) + 4.81155 * T - 29.578; - - h2 = (-0.83624e-3 * pow( T, 3.0 ) + 0.16792 * pow( T, 2.0 ) - 25.9293 * T) * 4.184 / 58.44; - - enthalpy[ip][it] = (x1 * h1 + x2 * h2 + m * dh) * 1000.0; - - } - } -} - -void BrineEnthalpyFunction::evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, - bool useMass ) const -{ - localIndex const numComponents = phaseComposition.size(); - - EvalArgs2D P, T, enthalpy, CO2Enthalpy; - P.m_var = pressure.m_var; - P.m_der[0] = 1.0; - - T.m_var = temperature.m_var; - T.m_der[1] = 1.0; - - enthalpy = m_BrineEnthalpyTable->value( P, T ); - - CO2Enthalpy = m_CO2EnthalpyTable->value( P, T ); - - - //assume there are only CO2 and brine here. - - EvalVarArgs enth1, enth2; - - enth1.m_var = CO2Enthalpy.m_var; - enth1.m_der[0] = CO2Enthalpy.m_der[0]; - enth1.m_der[numComponents + 1] = CO2Enthalpy.m_der[1]; - - enth2.m_var = enthalpy.m_var; - enth2.m_der[0] = enthalpy.m_der[0]; - enth2.m_der[numComponents + 1] = enthalpy.m_der[1]; - - real64 C = phaseComposition[m_waterIndex].m_var; - - real64 const waterMW = m_componentMolarWeight[m_waterIndex]; - real64 const CO2MW = m_componentMolarWeight[m_CO2Index]; - - if( useMass ) - { - - EvalVarArgs X = C * waterMW / (C * waterMW + (1.0 - C) * CO2MW); - X.m_der[m_waterIndex+1] = 1.0; - - value = (1.0 - X ) * enth1 + X * enth2; - - } - else - { - - EvalVarArgs X = C; - X.m_der[m_waterIndex+1] = 1.0; - - value = (1.0 - X ) * enth1 / CO2MW + X * enth2 / waterMW; - - } - -} - -REGISTER_CATALOG_ENTRY( PVTFunction, - BrineEnthalpyFunction, - string_array const &, string_array const &, real64_array const & ) - -} // namespace PVTProps -} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp deleted file mode 100644 index 11ed835177b..00000000000 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpyFunction.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 Total, S.A - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - - -#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPYFUNCTION_HPP_ -#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPYFUNCTION_HPP_ - - -#include "PVTFunctionBase.hpp" - -namespace geosx -{ - -namespace PVTProps -{ - -class BrineEnthalpyFunction : public PVTFunction -{ -public: - - - BrineEnthalpyFunction( string_array const & inputPara, - string_array const & componentNames, - real64_array const & componentMolarWeight ); - - ~BrineEnthalpyFunction() override {} - - - static constexpr auto m_catalogName = "BrineEnthalpy"; - static string catalogName() { return m_catalogName; } - virtual string getCatalogName() const override final { return catalogName(); } - - - virtual PVTFuncType functionType() const override - { - return PVTFuncType::ENTHALPY; - } - - virtual void evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, - EvalVarArgs & value, bool useMass = 0 ) const override; - -private: - - void makeTable( string_array const & inputPara ); - - void calculateBrineEnthalpy( real64_array const & pressure, real64_array const & temperature, real64 const & m, real64_array2d const & enthalpy ); - - TableFunctionPtr m_BrineEnthalpyTable; - TableFunctionPtr m_CO2EnthalpyTable; - localIndex m_waterIndex; - localIndex m_CO2Index; - -}; - -} - -} - - -#endif /* GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPYFUNCTION_HPP_ */ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp deleted file mode 100644 index 4b754bfef49..00000000000 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 Total, S.A - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file BrineInternalEnergyFunction.cpp - */ - -#include "constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp" - -namespace geosx -{ - -using namespace stringutilities; - -namespace PVTProps -{ - -BrineInternalEnergyFunction::BrineInternalEnergyFunction( string_array const & inputPara, - string_array const & componentNames, - real64_array const & componentMolarWeight ): - PVTFunction( inputPara[1], componentNames, componentMolarWeight ) -{} - -void BrineInternalEnergyFunction::evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, - arraySlice1d< EvalVarArgs const > const & phaseComposition, EvalVarArgs & value, bool useMass ) const -{ - GEOSX_UNUSED_VAR( phaseComposition ); - GEOSX_UNUSED_VAR( useMass ); - - localIndex const numComponents = phaseComposition.size(); - - value.m_var = 0.001 * pressure.m_var + 1.0 * temperature.m_var; - // pressure derivative - value.m_der[0] = 0.001; - // temperature derivative - value.m_der[numComponents+1] = 1.0; - -} - - - -REGISTER_CATALOG_ENTRY( PVTFunction, - BrineInternalEnergyFunction, - string_array const &, string_array const &, real64_array const & ) - -} // namespace PVTProps -} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp deleted file mode 100644 index ca83f3dca56..00000000000 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergyFunction.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 Total, S.A - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - - -#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGYFUNCTION_HPP_ -#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGYFUNCTION_HPP_ - - -#include "PVTFunctionBase.hpp" - -namespace geosx -{ - -namespace PVTProps -{ - -class BrineInternalEnergyFunction : public PVTFunction -{ -public: - - - BrineInternalEnergyFunction( string_array const & inputPara, - string_array const & componentNames, - real64_array const & componentMolarWeight ); - - ~BrineInternalEnergyFunction() override {} - - - static constexpr auto m_catalogName = "BrineInternalEnergy"; - static string catalogName() { return m_catalogName; } - virtual string getCatalogName() const override final { return catalogName(); } - - - virtual PVTFuncType functionType() const override - { - return PVTFuncType::INTERNALENR; - } - - virtual void evaluation( EvalVarArgs const & pressure, EvalVarArgs const & temperature, arraySlice1d< EvalVarArgs const > const & phaseComposition, - EvalVarArgs & value, bool useMass = 0 ) const override; - - static void calculateBrineInternalEnergy( real64_array const & pressure, real64_array const & temperature, real64_array2d const & internalEnergy ); - -private: - -}; - -} - -} - - -#endif /* GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGYFUNCTION_HPP_ */ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp deleted file mode 100644 index fe21d26584f..00000000000 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFlowKernels.cpp +++ /dev/null @@ -1,1595 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 Total, S.A - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file CompositionalMultiphaseFlowKernels.cpp - */ - -#include "CompositionalMultiphaseFlowKernels.hpp" - -#include "finiteVolume/CellElementStencilTPFA.hpp" -#include "finiteVolume/FaceElementStencil.hpp" - -namespace geosx -{ - -namespace CompositionalMultiphaseFlowKernels -{ - -/******************************** ComponentFractionKernel ********************************/ - -template< localIndex NC > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -ComponentFractionKernel:: - compute( arraySlice1d< real64 const > const compDens, - arraySlice1d< real64 const > const dCompDens, - arraySlice1d< real64 > const compFrac, - arraySlice2d< real64 > const dCompFrac_dCompDens ) -{ - real64 totalDensity = 0.0; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - real64 const totalDensityInv = 1.0 / totalDensity; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; - } - dCompFrac_dCompDens[ic][ic] += totalDensityInv; - } -} - -template< localIndex NC > -void -ComponentFractionKernel:: - launch( localIndex const size, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView2d< real64 > const & compFrac, - arrayView3d< real64 > const & dCompFrac_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC >( compDens[a], - dCompDens[a], - compFrac[a], - dCompFrac_dCompDens[a] ); - } ); -} - -template< localIndex NC > -void -ComponentFractionKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView2d< real64 > const & compFrac, - arrayView3d< real64 > const & dCompFrac_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC >( compDens[a], - dCompDens[a], - compFrac[a], - dCompFrac_dCompDens[a] ); - } ); -} - -#define INST_ComponentFractionKernel( NC ) \ - template \ - void ComponentFractionKernel:: \ - launch< NC >( localIndex const size, \ - arrayView2d< real64 const > const & compDens, \ - arrayView2d< real64 const > const & dCompDens, \ - arrayView2d< real64 > const & compFrac, \ - arrayView3d< real64 > const & dCompFrac_dCompDens ); \ - template \ - void ComponentFractionKernel:: \ - launch< NC >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView2d< real64 const > const & compDens, \ - arrayView2d< real64 const > const & dCompDens, \ - arrayView2d< real64 > const & compFrac, \ - arrayView3d< real64 > const & dCompFrac_dCompDens ) - -INST_ComponentFractionKernel( 1 ); -INST_ComponentFractionKernel( 2 ); -INST_ComponentFractionKernel( 3 ); -INST_ComponentFractionKernel( 4 ); -INST_ComponentFractionKernel( 5 ); - -#undef INST_ComponentFractionKernel - -/******************************** PhaseVolumeFractionKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -PhaseVolumeFractionKernel:: - compute( arraySlice1d< real64 const > const & compDens, - arraySlice1d< real64 const > const & dCompDens, - arraySlice2d< real64 const > const & dCompFrac_dCompDens, - arraySlice1d< real64 const > const & phaseDens, - arraySlice1d< real64 const > const & dPhaseDens_dPres, - arraySlice1d< real64 const > const & dPhaseDens_dTemp, - arraySlice2d< real64 const > const & dPhaseDens_dComp, - arraySlice1d< real64 const > const & phaseFrac, - arraySlice1d< real64 const > const & dPhaseFrac_dPres, - arraySlice1d< real64 const > const & dPhaseFrac_dTemp, - arraySlice2d< real64 const > const & dPhaseFrac_dComp, - arraySlice1d< real64 > const & phaseVolFrac, - arraySlice1d< real64 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 > const & dPhaseVolFrac_dComp ) -{ - real64 work[NC]; - - // compute total density from component partial densities - real64 totalDensity = 0.0; - real64 const dTotalDens_dCompDens = 1.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - for( localIndex ip = 0; ip < NP; ++ip ) - { - // Expression for volume fractions: S_p = (nu_p / rho_p) * rho_t - real64 const phaseDensInv = 1.0 / phaseDens[ip]; - - // compute saturation and derivatives except multiplying by the total density - phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; - - dPhaseVolFrac_dPres[ip] = - (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; - - dPhaseVolFrac_dTemp[ip] = - (dPhaseFrac_dTemp[ip] - phaseVolFrac[ip] * dPhaseDens_dTemp[ip]) * phaseDensInv; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] = - (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; - } - - // apply chain rule to convert derivatives from global component fractions to densities - applyChainRuleInPlace( NC, dCompFrac_dCompDens, dPhaseVolFrac_dComp[ip], work ); - - // now finalize the computation by multiplying by total density - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] *= totalDensity; - dPhaseVolFrac_dComp[ip][jc] += phaseVolFrac[ip] * dTotalDens_dCompDens; - } - - phaseVolFrac[ip] *= totalDensity; - dPhaseVolFrac_dPres[ip] *= totalDensity; - dPhaseVolFrac_dTemp[ip] *= totalDensity; - } -} - -template< localIndex NC, localIndex NP > -void PhaseVolumeFractionKernel:: - launch( localIndex const size, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView3d< real64 const > const & dCompFrac_dCompDens, - arrayView3d< real64 const > const & phaseDens, - arrayView3d< real64 const > const & dPhaseDens_dPres, - arrayView3d< real64 const > const & dPhaseDens_dTemp, - arrayView4d< real64 const > const & dPhaseDens_dComp, - arrayView3d< real64 const > const & phaseFrac, - arrayView3d< real64 const > const & dPhaseFrac_dPres, - arrayView3d< real64 const > const & dPhaseFrac_dTemp, - arrayView4d< real64 const > const & dPhaseFrac_dComp, - arrayView2d< real64 > const & phaseVolFrac, - arrayView2d< real64 > const & dPhaseVolFrac_dPres, - arrayView2d< real64 > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 > const & dPhaseVolFrac_dComp ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC, NP >( compDens[a], - dCompDens[a], - dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dTemp[a][0], - dPhaseDens_dComp[a][0], - phaseFrac[a][0], - dPhaseFrac_dPres[a][0], - dPhaseFrac_dTemp[a][0], - dPhaseFrac_dComp[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dTemp[a], - dPhaseVolFrac_dComp[a] ); - } ); -} - -template< localIndex NC, localIndex NP > -void PhaseVolumeFractionKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const > const & compDens, - arrayView2d< real64 const > const & dCompDens, - arrayView3d< real64 const > const & dCompFrac_dCompDens, - arrayView3d< real64 const > const & phaseDens, - arrayView3d< real64 const > const & dPhaseDens_dPres, - arrayView3d< real64 const > const & dPhaseDens_dTemp, - arrayView4d< real64 const > const & dPhaseDens_dComp, - arrayView3d< real64 const > const & phaseFrac, - arrayView3d< real64 const > const & dPhaseFrac_dPres, - arrayView3d< real64 const > const & dPhaseFrac_dTemp, - arrayView4d< real64 const > const & dPhaseFrac_dComp, - arrayView2d< real64 > const & phaseVolFrac, - arrayView2d< real64 > const & dPhaseVolFrac_dPres, - arrayView2d< real64 > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 > const & dPhaseVolFrac_dComp ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC, NP >( compDens[a], - dCompDens[a], - dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dTemp[a][0], - dPhaseDens_dComp[a][0], - phaseFrac[a][0], - dPhaseFrac_dPres[a][0], - dPhaseFrac_dTemp[a][0], - dPhaseFrac_dComp[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dTemp[a], - dPhaseVolFrac_dComp[a] ); - } ); -} - -#define INST_PhaseVolumeFractionKernel( NC, NP ) \ - template \ - void \ - PhaseVolumeFractionKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView2d< real64 const > const & compDens, \ - arrayView2d< real64 const > const & dCompDens, \ - arrayView3d< real64 const > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const > const & phaseDens, \ - arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const > const & dPhaseDens_dComp, \ - arrayView3d< real64 const > const & phaseFrac, \ - arrayView3d< real64 const > const & dPhaseFrac_dPres, \ - arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ - arrayView4d< real64 const > const & dPhaseFrac_dComp, \ - arrayView2d< real64 > const & phaseVolFrac, \ - arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 > const & dPhaseVolFrac_dComp ); \ - template \ - void \ - PhaseVolumeFractionKernel:: \ - launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView2d< real64 const > const & compDens, \ - arrayView2d< real64 const > const & dCompDens, \ - arrayView3d< real64 const > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const > const & phaseDens, \ - arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const > const & dPhaseDens_dComp, \ - arrayView3d< real64 const > const & phaseFrac, \ - arrayView3d< real64 const > const & dPhaseFrac_dPres, \ - arrayView3d< real64 const > const & dPhaseFrac_dTemp, \ - arrayView4d< real64 const > const & dPhaseFrac_dComp, \ - arrayView2d< real64 > const & phaseVolFrac, \ - arrayView2d< real64 > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 > const & dPhaseVolFrac_dComp ) - -INST_PhaseVolumeFractionKernel( 1, 1 ); -INST_PhaseVolumeFractionKernel( 2, 1 ); -INST_PhaseVolumeFractionKernel( 3, 1 ); -INST_PhaseVolumeFractionKernel( 4, 1 ); -INST_PhaseVolumeFractionKernel( 5, 1 ); - -INST_PhaseVolumeFractionKernel( 1, 2 ); -INST_PhaseVolumeFractionKernel( 2, 2 ); -INST_PhaseVolumeFractionKernel( 3, 2 ); -INST_PhaseVolumeFractionKernel( 4, 2 ); -INST_PhaseVolumeFractionKernel( 5, 2 ); - -INST_PhaseVolumeFractionKernel( 1, 3 ); -INST_PhaseVolumeFractionKernel( 2, 3 ); -INST_PhaseVolumeFractionKernel( 3, 3 ); -INST_PhaseVolumeFractionKernel( 4, 3 ); -INST_PhaseVolumeFractionKernel( 5, 3 ); - -#undef INST_PhaseVolumeFractionKernel - -/******************************** PhaseMobilityKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -PhaseMobilityKernel:: - compute( arraySlice2d< real64 const > const & dCompFrac_dCompDens, - arraySlice1d< real64 const > const & phaseDens, - arraySlice1d< real64 const > const & dPhaseDens_dPres, - arraySlice1d< real64 const > const & dPhaseDens_dTemp, - arraySlice2d< real64 const > const & dPhaseDens_dComp, - arraySlice1d< real64 const > const & phaseVisc, - arraySlice1d< real64 const > const & dPhaseVisc_dPres, - arraySlice1d< real64 const > const & dPhaseVisc_dTemp, - arraySlice2d< real64 const > const & dPhaseVisc_dComp, - arraySlice1d< real64 const > const & phaseRelPerm, - arraySlice2d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, - arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const > const & dPhaseVolFrac_dComp, - arraySlice1d< real64 > const & phaseMob, - arraySlice1d< real64 > const & dPhaseMob_dPres, - arraySlice1d< real64 > const & dPhaseMob_dTemp, - arraySlice2d< real64 > const & dPhaseMob_dComp ) -{ - real64 dRelPerm_dC[NC]; - real64 dDens_dC[NC]; - real64 dVisc_dC[NC]; - - for( localIndex ip = 0; ip < NP; ++ip ) - { - real64 const density = phaseDens[ip]; - real64 const dDens_dP = dPhaseDens_dPres[ip]; - real64 const dDens_dT = dPhaseDens_dTemp[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); - - real64 const viscosity = phaseVisc[ip]; - real64 const dVisc_dP = dPhaseVisc_dPres[ip]; - real64 const dVisc_dT = dPhaseVisc_dTemp[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); - - real64 const relPerm = phaseRelPerm[ip]; - real64 dRelPerm_dP = 0.0; - real64 dRelPerm_dT = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - dRelPerm_dC[ic] = 0.0; - } - - for( localIndex jp = 0; jp < NP; ++jp ) - { - real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; - dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; - dRelPerm_dT += dRelPerm_dS * dPhaseVolFrac_dTemp[jp]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; - } - } - - real64 const mobility = relPerm * density / viscosity; - - phaseMob[ip] = mobility; - dPhaseMob_dPres[ip] = dRelPerm_dP * density / viscosity - + mobility * (dDens_dP / density - dVisc_dP / viscosity); - - dPhaseMob_dTemp[ip] = dRelPerm_dT * density / viscosity - + mobility * (dDens_dT / density - dVisc_dT / viscosity); - - // compositional derivatives - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] * density / viscosity - + mobility * (dDens_dC[jc] / density - dVisc_dC[jc] / viscosity); - } - } -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( localIndex const size, - arrayView3d< real64 const > const & dCompFrac_dCompDens, - arrayView3d< real64 const > const & phaseDens, - arrayView3d< real64 const > const & dPhaseDens_dPres, - arrayView3d< real64 const > const & dPhaseDens_dTemp, - arrayView4d< real64 const > const & dPhaseDens_dComp, - arrayView3d< real64 const > const & phaseVisc, - arrayView3d< real64 const > const & dPhaseVisc_dPres, - arrayView3d< real64 const > const & dPhaseVisc_dTemp, - arrayView4d< real64 const > const & dPhaseVisc_dComp, - arrayView3d< real64 const > const & phaseRelPerm, - arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const > const & dPhaseVolFrac_dComp, - arrayView2d< real64 > const & phaseMob, - arrayView2d< real64 > const & dPhaseMob_dPres, - arrayView2d< real64 > const & dPhaseMob_dTemp, - arrayView3d< real64 > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dTemp[a][0], - dPhaseDens_dComp[a][0], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dTemp[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dTemp[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dTemp[a], - dPhaseMob_dComp[a] ); - } ); -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const > const & dCompFrac_dCompDens, - arrayView3d< real64 const > const & phaseDens, - arrayView3d< real64 const > const & dPhaseDens_dPres, - arrayView3d< real64 const > const & dPhaseDens_dTemp, - arrayView4d< real64 const > const & dPhaseDens_dComp, - arrayView3d< real64 const > const & phaseVisc, - arrayView3d< real64 const > const & dPhaseVisc_dPres, - arrayView3d< real64 const > const & dPhaseVisc_dTemp, - arrayView4d< real64 const > const & dPhaseVisc_dComp, - arrayView3d< real64 const > const & phaseRelPerm, - arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const > const & dPhaseVolFrac_dComp, - arrayView2d< real64 > const & phaseMob, - arrayView2d< real64 > const & dPhaseMob_dPres, - arrayView2d< real64 > const & dPhaseMob_dTemp, - arrayView3d< real64 > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dTemp[a][0], - dPhaseDens_dComp[a][0], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dTemp[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dTemp[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dTemp[a], - dPhaseMob_dComp[a] ); - } ); -} - -#define INST_PhaseMobilityKernel( NC, NP ) \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView3d< real64 const > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const > const & phaseDens, \ - arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const > const & dPhaseDens_dComp, \ - arrayView3d< real64 const > const & phaseVisc, \ - arrayView3d< real64 const > const & dPhaseVisc_dPres, \ - arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ - arrayView4d< real64 const > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const > const & phaseRelPerm, \ - arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64 > const & phaseMob, \ - arrayView2d< real64 > const & dPhaseMob_dPres, \ - arrayView2d< real64 > const & dPhaseMob_dTemp, \ - arrayView3d< real64 > const & dPhaseMob_dComp ); \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView3d< real64 const > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const > const & phaseDens, \ - arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const > const & dPhaseDens_dComp, \ - arrayView3d< real64 const > const & phaseVisc, \ - arrayView3d< real64 const > const & dPhaseVisc_dPres, \ - arrayView3d< real64 const > const & dPhaseVisc_dTemp, \ - arrayView4d< real64 const > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const > const & phaseRelPerm, \ - arrayView4d< real64 const > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64 > const & phaseMob, \ - arrayView2d< real64 > const & dPhaseMob_dPres, \ - arrayView2d< real64 > const & dPhaseMob_dTemp, \ - arrayView3d< real64 > const & dPhaseMob_dComp ) - -INST_PhaseMobilityKernel( 1, 1 ); -INST_PhaseMobilityKernel( 2, 1 ); -INST_PhaseMobilityKernel( 3, 1 ); -INST_PhaseMobilityKernel( 4, 1 ); -INST_PhaseMobilityKernel( 5, 1 ); - -INST_PhaseMobilityKernel( 1, 2 ); -INST_PhaseMobilityKernel( 2, 2 ); -INST_PhaseMobilityKernel( 3, 2 ); -INST_PhaseMobilityKernel( 4, 2 ); -INST_PhaseMobilityKernel( 5, 2 ); - -INST_PhaseMobilityKernel( 1, 3 ); -INST_PhaseMobilityKernel( 2, 3 ); -INST_PhaseMobilityKernel( 3, 3 ); -INST_PhaseMobilityKernel( 4, 3 ); -INST_PhaseMobilityKernel( 5, 3 ); - -#undef INST_PhaseMobilityKernel - -/******************************** AccumulationKernel ********************************/ - -template< localIndex NC > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -AccumulationKernel:: - compute( localIndex const numPhases, - real64 const & volume, - real64 const & porosityOld, - real64 const & porosityRef, - real64 const & pvMult, - real64 const & dPvMult_dPres, - arraySlice2d< real64 const > const & dCompFrac_dCompDens, - arraySlice1d< real64 const > const & phaseVolFracOld, - arraySlice1d< real64 const > const & phaseVolFrac, - arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, - arraySlice1d< real64 const > const & phaseDensOld, - arraySlice1d< real64 const > const & phaseDens, - arraySlice1d< real64 const > const & dPhaseDens_dPres, - arraySlice1d< real64 const > const & dPhaseDens_dTemp, - arraySlice2d< real64 const > const & dPhaseDens_dComp, - arraySlice2d< real64 const > const & phaseCompFracOld, - arraySlice2d< real64 const > const & phaseCompFrac, - arraySlice2d< real64 const > const & dPhaseCompFrac_dPres, - arraySlice2d< real64 const > const & dPhaseCompFrac_dTemp, - arraySlice3d< real64 const > const & dPhaseCompFrac_dComp, - arraySlice1d< real64 const > const & phaseInternalEnergyOld, - arraySlice1d< real64 const > const & phaseInternalEnergy, - arraySlice1d< real64 const > const & dPhaseInternalEnergy_dPres, - arraySlice1d< real64 const > const & dPhaseInternalEnergy_dTemp, - arraySlice2d< real64 const > const & dPhaseInternalEnergy_dComp, - real64 const & rockInternalEnergyOld, - real64 const & rockInternalEnergy, - real64 const & dRockInternalEnergy_dTemp, - real64 const & rockDensity, - real64 ( & localAccum )[NC + 1], - real64 ( & localAccumJacobian )[NC + 1][NC + 2] ) -{ - - // pressure, NC component densities, temperature - localIndex constexpr NDOF = NC + 2; - localIndex const NP = numPhases; - - // temporary work arrays - real64 dPhaseAmount_dC[NC]; // Derivative rho_ph * phi * S_ph w.r.t. comp densities - real64 dPhaseCompFrac_dC[NC]; // Derivative of phase component fractions w.r.t. comp densities - real64 dPhaseInternalEnergy_dC[NC]; // Derivative of phase internal energy w.r.t. comp densities - - // reset the local values - for( localIndex i = 0; i < NC+1; ++i ) - { - localAccum[i] = 0.0; - for( localIndex j = 0; j < NDOF; ++j ) - { - localAccumJacobian[i][j] = 0.0; - } - } - - // compute fluid-independent (pore volume) part - real64 const volNew = volume; - real64 const volOld = volume; - real64 const dVol_dP = 0.0; // used in poroelastic solver - - real64 const poroNew = porosityRef * pvMult; - real64 const poroOld = porosityOld; - real64 const dPoro_dP = porosityRef * dPvMult_dPres; - - real64 const poreVolNew = volNew * poroNew; - real64 const poreVolOld = volOld * poroOld; - real64 const dPoreVol_dP = dVol_dP * poroNew + volNew * dPoro_dP; - real64 const dPoreVol_dT = 0.0; - - // sum contributions to component accumulation from each phase - for( localIndex ip = 0; ip < NP; ++ip ) - { - // 1. Mass balance equations - - real64 const phaseAmountNew = poreVolNew * phaseVolFrac[ip] * phaseDens[ip]; - real64 const phaseAmountOld = poreVolOld * phaseVolFracOld[ip] * phaseDensOld[ip]; - - real64 const dPhaseAmount_dP = dPoreVol_dP * phaseVolFrac[ip] * phaseDens[ip] - + poreVolNew * (dPhaseVolFrac_dPres[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); - - real64 const dPhaseAmount_dT = dPoreVol_dT * phaseVolFrac[ip] * phaseDens[ip] - + poreVolNew * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); - - // assemble density dependence - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] - + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][jc]; - dPhaseAmount_dC[jc] *= poreVolNew; - } - - // ic - index of component whose conservation equation is assembled - // (i.e. row number in local matrix) - for( localIndex 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]; - - real64 const dPhaseCompAmount_dT = dPhaseAmount_dT * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; - - localAccum[ic] += phaseCompAmountNew - phaseCompAmountOld; - localAccumJacobian[ic][0] += dPhaseCompAmount_dP; - localAccumJacobian[ic][NC+1] += dPhaseCompAmount_dT; - - // jc - index of component w.r.t. whose compositional var the derivative is being taken - // (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 ) - { - real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew - + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; - localAccumJacobian[ic][jc + 1] += dPhaseCompAmount_dC; - } - } - - // 2. Energy balance equation - real64 const phaseEnergyNew = phaseAmountNew * phaseInternalEnergy[ip]; - real64 const phaseEnergyOld = phaseAmountOld * phaseInternalEnergyOld[ip]; - - real64 const solidEnergyNew = (1 - poroNew) * volNew * rockInternalEnergy * rockDensity; - real64 const solidEnergyOld = (1 - poroOld) * volOld * rockInternalEnergyOld * rockDensity; - - // local accumulation - localAccum[NC] = phaseEnergyNew - phaseEnergyOld + solidEnergyNew - solidEnergyOld; - - real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dPres[ip]; - real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dTemp[ip]; - - real64 const dSolidInternalEnergy_dP = -dPoro_dP * volNew * rockInternalEnergy * rockDensity; - // TODO porosity and volume may depend on temperature - real64 const dSolidInternalEnergy_dT = (1 - poroNew) * volNew * dRockInternalEnergy_dTemp; - - // derivatives w.r.t. pressure and temperature - localAccumJacobian[NC][0] += dPhaseEnergy_dP + dSolidInternalEnergy_dP; - localAccumJacobian[NC][NC+1] += dPhaseEnergy_dT + dSolidInternalEnergy_dT; - - // derivatives w.r.t. component densities - applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - real64 const dPhaseEnergy_dC = phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + - dPhaseInternalEnergy_dC[jc] * phaseAmountNew; - - localAccumJacobian[NC][jc + 1] += dPhaseEnergy_dC; - } - } -} - -template< localIndex NC > -void -AccumulationKernel:: - launch( localIndex const numPhases, - localIndex const size, - globalIndex const rankOffset, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & elemGhostRank, - arrayView1d< real64 const > const & volume, - arrayView1d< real64 const > const & porosityOld, - arrayView1d< real64 const > const & porosityRef, - arrayView2d< real64 const > const & pvMult, - arrayView2d< real64 const > const & dPvMult_dPres, - arrayView3d< real64 const > const & dCompFrac_dCompDens, - arrayView2d< real64 const > const & phaseVolFracOld, - arrayView2d< real64 const > const & phaseVolFrac, - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, - arrayView2d< real64 const > const & phaseDensOld, - arrayView3d< real64 const > const & phaseDens, - arrayView3d< real64 const > const & dPhaseDens_dPres, - arrayView3d< real64 const > const & dPhaseDens_dTemp, - arrayView4d< real64 const > const & dPhaseDens_dComp, - arrayView3d< real64 const > const & phaseCompFracOld, - arrayView4d< real64 const > const & phaseCompFrac, - arrayView4d< real64 const > const & dPhaseCompFrac_dPres, - arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, - arrayView5d< real64 const > const & dPhaseCompFrac_dComp, - arrayView2d< real64 const > const & phaseInternalEnergyOld, - arrayView3d< real64 const > const & phaseInternalEnergy, - arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, - arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, - arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, - arrayView1d< real64 const > const & rockInternalEnergyOld, - arrayView2d< real64 const > const & rockInternalEnergy, - arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, - arrayView2d< real64 const > const & rockDensity, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( elemGhostRank[ei] >= 0 ) - return; - - localIndex constexpr NDOF = NC + 2; // number of dofs - localIndex constexpr NBEQ = NC + 1; // number of balance equations - - real64 localAccum[NBEQ]; - real64 localAccumJacobian[NBEQ][NDOF]; - - compute< NC >( numPhases, - volume[ei], - porosityOld[ei], - porosityRef[ei], - pvMult[ei][0], - dPvMult_dPres[ei][0], - dCompFrac_dCompDens[ei], - phaseVolFracOld[ei], - phaseVolFrac[ei], - dPhaseVolFrac_dPres[ei], - dPhaseVolFrac_dTemp[ei], - dPhaseVolFrac_dCompDens[ei], - phaseDensOld[ei], - phaseDens[ei][0], - dPhaseDens_dPres[ei][0], - dPhaseDens_dTemp[ei][0], - dPhaseDens_dComp[ei][0], - phaseCompFracOld[ei], - phaseCompFrac[ei][0], - dPhaseCompFrac_dPres[ei][0], - dPhaseCompFrac_dTemp[ei][0], - dPhaseCompFrac_dComp[ei][0], - phaseInternalEnergyOld[ei], - phaseInternalEnergy[ei][0], - dPhaseInternalEnergy_dPres[ei][0], - dPhaseInternalEnergy_dTemp[ei][0], - dPhaseInternalEnergy_dComp[ei][0], - rockInternalEnergyOld[ei], - rockInternalEnergy[ei][0], - dRockInternalEnergy_dTemp[ei][0], - rockDensity[ei][0], - localAccum, - localAccumJacobian ); - - // set DOF indices for this block - localIndex const localRow = dofNumber[ei] - rankOffset; - globalIndex dofIndices[NDOF]; - for( localIndex idof = 0; idof < NDOF; ++idof ) - { - dofIndices[idof] = dofNumber[ei] + idof; - } - - // add contribution to residual and jacobian - for( localIndex i = 0; i < NBEQ; ++i ) - { - localRhs[localRow + i] += localAccum[i]; - localMatrix.addToRow< serialAtomic >( localRow + i, - dofIndices, - localAccumJacobian[i], - NDOF ); - } - } ); -} - -#define INST_AccumulationKernel( NC ) \ - template \ - void \ - AccumulationKernel:: \ - launch< NC >( localIndex const numPhases, \ - localIndex const size, \ - globalIndex const rankOffset, \ - arrayView1d< globalIndex const > const & dofNumber, \ - arrayView1d< integer const > const & elemGhostRank, \ - arrayView1d< real64 const > const & volume, \ - arrayView1d< real64 const > const & porosityOld, \ - arrayView1d< real64 const > const & porosityRef, \ - arrayView2d< real64 const > const & pvMult, \ - arrayView2d< real64 const > const & dPvMult_dPres, \ - arrayView3d< real64 const > const & dCompFrac_dCompDens, \ - arrayView2d< real64 const > const & phaseVolFracOld, \ - arrayView2d< real64 const > const & phaseVolFrac, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ - arrayView2d< real64 const > const & phaseDensOld, \ - arrayView3d< real64 const > const & phaseDens, \ - arrayView3d< real64 const > const & dPhaseDens_dPres, \ - arrayView3d< real64 const > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const > const & dPhaseDens_dComp, \ - arrayView3d< real64 const > const & phaseCompFracOld, \ - arrayView4d< real64 const > const & phaseCompFrac, \ - arrayView4d< real64 const > const & dPhaseCompFrac_dPres, \ - arrayView4d< real64 const > const & dPhaseCompFrac_dTemp, \ - arrayView5d< real64 const > const & dPhaseCompFrac_dComp, \ - arrayView2d< real64 const > const & phaseInternalEnergyOld, \ - arrayView3d< real64 const > const & phaseInternalEnergy, \ - arrayView3d< real64 const > const & dPhaseInternalEnergy_dPres, \ - arrayView3d< real64 const > const & dPhaseInternalEnergy_dTemp, \ - arrayView4d< real64 const > const & dPhaseInternalEnergy_dComp, \ - arrayView1d< real64 const > const & rockInternalEnergyOld, \ - arrayView2d< real64 const > const & rockInternalEnergy, \ - arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, \ - arrayView2d< real64 const > const & rockDensity, \ - CRSMatrixView< real64, globalIndex const > const & localMatrix, \ - arrayView1d< real64 > const & localRhs ) - -INST_AccumulationKernel( 1 ); -INST_AccumulationKernel( 2 ); -INST_AccumulationKernel( 3 ); -INST_AccumulationKernel( 4 ); -INST_AccumulationKernel( 5 ); - -#undef INST_AccumulationKernel - -/******************************** VolumeBalanceKernel ********************************/ - -template< localIndex NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -FluxKernel:: - compute( localIndex const numPhases, - localIndex const stencilSize, - arraySlice1d< localIndex const > const seri, - arraySlice1d< localIndex const > const sesri, - arraySlice1d< localIndex const > const sei, - arraySlice1d< real64 const > const stencilWeights, - ElementViewConst< arrayView1d< real64 const > > const & pres, - ElementViewConst< arrayView1d< real64 const > > const & dPres, - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, - ElementViewConst< arrayView2d< real64 const > > const & phaseMob, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, - ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, - ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, - ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, - ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, - ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, - ElementViewConst< arrayView1d< real64 const > > const & temp, - ElementViewConst< arrayView1d< real64 const > > const & dTemp, - ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, - integer const capPressureFlag, - real64 const dt, - arraySlice1d< real64 > const localFlux, - arraySlice2d< real64 > const localFluxJacobian ) -{ - localIndex constexpr NDOF = NC + 2; - localIndex const NP = numPhases; - - // they will be useful for conduction - GEOSX_UNUSED_VAR( temp ); - GEOSX_UNUSED_VAR( dTemp ); - GEOSX_UNUSED_VAR( phaseVolFrac ); - - real64 compFlux[NC]{}; - real64 dCompFlux_dP[MAX_STENCIL][NC]{}; - real64 dCompFlux_dT[MAX_STENCIL][NC]{}; - real64 dCompFlux_dC[MAX_STENCIL][NC][NC]{}; - real64 enthalpyFlux = 0.0; - real64 dEnthalpyFlux_dP[MAX_STENCIL]{}; - real64 dEnthalpyFlux_dT[MAX_STENCIL]{}; - real64 dEnthalpyFlux_dC[MAX_STENCIL][NC]{}; - - // loop over phases, compute and upwind phase flux and sum contributions to each component's flux - for( localIndex ip = 0; ip < NP; ++ip ) - { - // clear working arrays - real64 densMean{}; - real64 dDensMean_dP[NUM_ELEMS]{}; - real64 dDensMean_dT[NUM_ELEMS]{}; - real64 dDensMean_dC[NUM_ELEMS][NC]{}; - - // create local work arrays - real64 phaseFlux{}; - real64 dPhaseFlux_dP[MAX_STENCIL]{}; - real64 dPhaseFlux_dT[MAX_STENCIL]{}; - real64 dPhaseFlux_dC[MAX_STENCIL][NC]{}; - - real64 presGrad{}; - real64 dPresGrad_dP[MAX_STENCIL]{}; - real64 dPresGrad_dT[MAX_STENCIL]{}; - real64 dPresGrad_dC[MAX_STENCIL][NC]{}; - - real64 gravHead{}; - real64 dGravHead_dP[NUM_ELEMS]{}; - real64 dGravHead_dT[NUM_ELEMS]{}; - real64 dGravHead_dC[NUM_ELEMS][NC]{}; - - real64 dCapPressure_dC[NC]{}; - - // Working array - real64 dProp_dC[NC]{}; - - // calculate quantities on primary connected cells - for( localIndex i = 0; i < NUM_ELEMS; ++i ) - { - localIndex const er = seri[i]; - localIndex const esr = sesri[i]; - localIndex const ei = sei[i]; - - // density - real64 const density = phaseMassDens[er][esr][ei][0][ip]; - real64 const dDens_dP = dPhaseMassDens_dPres[er][esr][ei][0][ip]; - real64 const dDens_dT = dPhaseMassDens_dTemp[er][esr][ei][0][ip]; - - applyChainRule( NC, - dCompFrac_dCompDens[er][esr][ei], - dPhaseMassDens_dComp[er][esr][ei][0][ip], - dProp_dC ); - - // average density and derivatives - densMean += 0.5 * density; - dDensMean_dP[i] = 0.5 * dDens_dP; - dDensMean_dT[i] = 0.5 * dDens_dT; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dDensMean_dC[i][jc] = 0.5 * dProp_dC[jc]; - } - } - - //***** calculation of flux ***** - - // compute potential difference MPFA-style - for( localIndex i = 0; i < stencilSize; ++i ) - { - localIndex const er = seri[i]; - localIndex const esr = sesri[i]; - localIndex const ei = sei[i]; - real64 const weight = stencilWeights[i]; - - // capillary pressure - real64 capPressure = 0.0; - real64 dCapPressure_dP = 0.0; - real64 dCapPressure_dT = 0.0; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - dCapPressure_dC[ic] = 0.0; - } - - if( capPressureFlag ) - { - capPressure = phaseCapPressure[er][esr][ei][0][ip]; - - for( localIndex jp = 0; jp < NP; ++jp ) - { - real64 const dCapPressure_dS = dPhaseCapPressure_dPhaseVolFrac[er][esr][ei][0][ip][jp]; - dCapPressure_dP += dCapPressure_dS * dPhaseVolFrac_dPres[er][esr][ei][jp]; - dCapPressure_dT += dCapPressure_dS * dPhaseVolFrac_dTemp[er][esr][ei][jp]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCapPressure_dC[jc] += dCapPressure_dS * dPhaseVolFrac_dComp[er][esr][ei][jp][jc]; - } - } - } - - presGrad += weight * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); - dPresGrad_dP[i] += weight * (1 - dCapPressure_dP); - dPresGrad_dT[i] += weight * (1 - dCapPressure_dT); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPresGrad_dC[i][jc] += -weight * dCapPressure_dC[jc]; - } - - real64 const gravD = weight * gravCoef[er][esr][ei]; - - // the density used in the potential difference is always a mass density - // unlike the density used in the phase mobility, which is a mass density - // if useMass == 1 and a molar density otherwise - gravHead += densMean * gravD; - - // need to add contributions from both cells the mean density depends on - for( localIndex j = 0; j < NUM_ELEMS; ++j ) - { - dGravHead_dP[j] += dDensMean_dP[j] * gravD; - dGravHead_dT[j] += dDensMean_dT[j] * gravD; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dGravHead_dC[j][jc] += dDensMean_dC[j][jc] * gravD; - } - } - } - - // *** upwinding *** - - // use PPU currently; advanced stuff like IHU would go here - // TODO isolate into a kernel? - - // compute phase potential gradient - real64 const potGrad = presGrad - gravHead; - - // choose upstream cell - localIndex const k_up = (potGrad >= 0) ? 0 : 1; - - localIndex er_up = seri[k_up]; - localIndex esr_up = sesri[k_up]; - localIndex ei_up = sei[k_up]; - - real64 const mobility = phaseMob[er_up][esr_up][ei_up][ip]; - - // skip the phase flux if phase not present or immobile upstream - if( std::fabs( mobility ) < 1e-20 ) // TODO better constant - { - continue; - } - - // pressure gradient depends on all points in the stencil - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dPhaseFlux_dP[ke] += dPresGrad_dP[ke]; - dPhaseFlux_dT[ke] += dPresGrad_dT[ke]; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[ke][jc] += dPresGrad_dC[ke][jc]; - } - - } - - // gravitational head depends only on the two cells connected (same as mean density) - for( localIndex ke = 0; ke < NUM_ELEMS; ++ke ) - { - dPhaseFlux_dP[ke] -= dGravHead_dP[ke]; - dPhaseFlux_dT[ke] -= dGravHead_dT[ke]; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[ke][jc] -= dGravHead_dC[ke][jc]; - } - } - - // compute the phase flux and derivatives using upstream cell mobility - phaseFlux = mobility * potGrad; - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dPhaseFlux_dP[ke] *= mobility; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[ke][jc] *= mobility; - } - } - - real64 const dMob_dP = dPhaseMob_dPres[er_up][esr_up][ei_up][ip]; - real64 const dMob_dT = dPhaseMob_dTemp[er_up][esr_up][ei_up][ip]; - arraySlice1d< real64 const > dPhaseMob_dCompSub = dPhaseMob_dComp[er_up][esr_up][ei_up][ip]; - - // add contribution from upstream cell mobility derivatives - dPhaseFlux_dP[k_up] += dMob_dP * potGrad; - dPhaseFlux_dT[k_up] += dMob_dT * potGrad; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[k_up][jc] += dPhaseMob_dCompSub[jc] * potGrad; - } - - // slice some constitutive arrays to avoid too much indexing in component loop - arraySlice1d< real64 const > phaseCompFracSub = phaseCompFrac[er_up][esr_up][ei_up][0][ip]; - arraySlice1d< real64 const > dPhaseCompFrac_dPresSub = dPhaseCompFrac_dPres[er_up][esr_up][ei_up][0][ip]; - arraySlice1d< real64 const > dPhaseCompFrac_dTempSub = dPhaseCompFrac_dTemp[er_up][esr_up][ei_up][0][ip]; - arraySlice2d< real64 const > dPhaseCompFrac_dCompSub = dPhaseCompFrac_dComp[er_up][esr_up][ei_up][0][ip]; - - // compute component fluxes and derivatives using upstream cell composition - for( localIndex ic = 0; ic < NC; ++ic ) - { - real64 const ycp = phaseCompFracSub[ic]; - compFlux[ic] += phaseFlux * ycp; - - // derivatives stemming from phase flux - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dCompFlux_dP[ke][ic] += dPhaseFlux_dP[ke] * ycp; - dCompFlux_dT[ke][ic] += dPhaseFlux_dT[ke] * ycp; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFlux_dC[ke][ic][jc] += dPhaseFlux_dC[ke][jc] * ycp; - } - } - - // additional derivatives stemming from upstream cell phase composition - dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFrac_dPresSub[ic]; - dCompFlux_dT[k_up][ic] += phaseFlux * dPhaseCompFrac_dTempSub[ic]; - - // convert derivatives of component fraction w.r.t. component fractions to derivatives w.r.t. component - // densities - applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseCompFrac_dCompSub[ic], dProp_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; - } - } - - // compute enthalpy fluxes and derivatives - real64 const enthalpy = phaseEnthalpy[er_up][esr_up][ei_up][0][ip]; - enthalpyFlux = phaseFlux * enthalpy; - - // derivatives stemming from phase flux (it was upwinded previously) - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dEnthalpyFlux_dP[ke] = dPhaseFlux_dP[ke] * enthalpy; - dEnthalpyFlux_dT[ke] = dPhaseFlux_dT[ke] * enthalpy; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dEnthalpyFlux_dC[ke][jc] = dPhaseFlux_dC[ke][jc] * enthalpy; - } - } - - // add contribution from upstream cell enthalpy derivatives - dEnthalpyFlux_dP[k_up] += phaseFlux * dPhaseEnthalpy_dPres[er_up][esr_up][ei_up][0][ip]; - dEnthalpyFlux_dT[k_up] += phaseFlux * dPhaseEnthalpy_dTemp[er_up][esr_up][ei_up][0][ip]; - - applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseEnthalpy_dComp[er_up][esr_up][ei_up][0][ip], dProp_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dEnthalpyFlux_dC[k_up][jc] += phaseFlux * dProp_dC[jc]; - } - } - - // *** end of upwinding - - // populate local flux vector and derivatives - for( localIndex ic = 0; ic < NC; ++ic ) - { - // mass/mole flux - localFlux[ic] = dt * compFlux[ic]; - localFlux[NC + 1 + ic] = -dt * compFlux[ic]; - - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - // mass flux derivativex - localIndex const localDofIndexPres = ke * NDOF; - localFluxJacobian[ic][localDofIndexPres] = dt * dCompFlux_dP[ke][ic]; - localFluxJacobian[NC + 1 + ic][localDofIndexPres] = -dt * dCompFlux_dP[ke][ic]; - localIndex const localDofIndexTemp = localDofIndexPres + NC; - localFluxJacobian[ic][localDofIndexTemp] = dt * dCompFlux_dT[ke][ic]; - localFluxJacobian[NC + 1 + ic][localDofIndexTemp] = -dt * dCompFlux_dT[ke][ic]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - localIndex const localDofIndexComp = localDofIndexPres + jc + 1; - localFluxJacobian[ic][localDofIndexComp] = dt * dCompFlux_dC[ke][ic][jc]; - localFluxJacobian[NC + 1 + ic][localDofIndexComp] = -dt * dCompFlux_dC[ke][ic][jc]; - } - } - } - - // enthalpy flux - localFlux[NC] = dt * enthalpyFlux; - localFlux[2 * NC - 1] = -dt * enthalpyFlux; - - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - localIndex const localDofIndexPres = ke * NDOF; - localFluxJacobian[NC][localDofIndexPres] = dt * dEnthalpyFlux_dP[ke]; - localFluxJacobian[2*NC - 1][localDofIndexPres] = -dt * dEnthalpyFlux_dP[ke]; - localIndex const localDofIndexTemp = localDofIndexPres + NC; - localFluxJacobian[NC][localDofIndexTemp] = dt * dEnthalpyFlux_dT[ke]; - localFluxJacobian[2*NC - 1][localDofIndexTemp] = -dt * dEnthalpyFlux_dT[ke]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - localIndex const localDofIndexComp = localDofIndexPres + jc + 1; - localFluxJacobian[NC][localDofIndexComp] = dt * dEnthalpyFlux_dC[ke][jc]; - localFluxJacobian[2*NC - 1][localDofIndexComp] = -dt * dEnthalpyFlux_dC[ke][jc]; - } - } - -} - -template< localIndex NC, typename STENCIL_TYPE > -void -FluxKernel:: - launch( localIndex const numPhases, - STENCIL_TYPE const & stencil, - globalIndex const rankOffset, - ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, - ElementViewConst< arrayView1d< integer const > > const & ghostRank, - ElementViewConst< arrayView1d< real64 const > > const & pres, - ElementViewConst< arrayView1d< real64 const > > const & dPres, - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, - ElementViewConst< arrayView2d< real64 const > > const & phaseMob, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, - ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, - ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, - ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, - ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, - ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, - ElementViewConst< arrayView1d< real64 const > > const & temp, - ElementViewConst< arrayView1d< real64 const > > const & dTemp, - ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, - ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, - integer const capPressureFlag, - real64 const dt, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) -{ - typename STENCIL_TYPE::IndexContainerViewConstType const & seri = stencil.getElementRegionIndices(); - typename STENCIL_TYPE::IndexContainerViewConstType const & sesri = stencil.getElementSubRegionIndices(); - typename STENCIL_TYPE::IndexContainerViewConstType const & sei = stencil.getElementIndices(); - typename STENCIL_TYPE::WeightContainerViewConstType const & weights = stencil.getWeights(); - - localIndex constexpr NUM_ELEMS = STENCIL_TYPE::NUM_POINT_IN_FLUX; - localIndex constexpr MAX_STENCIL = STENCIL_TYPE::MAX_STENCIL_SIZE; - - forAll< parallelDevicePolicy<> >( stencil.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iconn ) - { - // TODO: hack! for MPFA, etc. must obtain proper size from e.g. seri - localIndex const stencilSize = MAX_STENCIL; - localIndex constexpr NDOF = NC + 2; - - stackArray1d< real64, NUM_ELEMS * NC > localFlux( NUM_ELEMS * ( NC + 1 ) ); - stackArray2d< real64, NUM_ELEMS * NC * MAX_STENCIL * NDOF > localFluxJacobian( NUM_ELEMS * ( NC + 1 ), stencilSize * NDOF ); - - FluxKernel::compute< NC, NUM_ELEMS, MAX_STENCIL >( numPhases, - stencilSize, - seri[iconn], - sesri[iconn], - sei[iconn], - weights[iconn], - pres, - dPres, - gravCoef, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dTemp, - dPhaseMob_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dTemp, - dPhaseVolFrac_dComp, - dCompFrac_dCompDens, - phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dTemp, - dPhaseMassDens_dComp, - phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dTemp, - dPhaseCompFrac_dComp, - phaseCapPressure, - dPhaseCapPressure_dPhaseVolFrac, - temp, - dTemp, - phaseEnthalpy, - dPhaseEnthalpy_dPres, - dPhaseEnthalpy_dTemp, - dPhaseEnthalpy_dComp, - capPressureFlag, - dt, - localFlux, - localFluxJacobian ); - - // populate dof indices - globalIndex dofColIndices[ MAX_STENCIL * NDOF ]; - for( localIndex i = 0; i < stencilSize; ++i ) - { - globalIndex const offset = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; - - for( localIndex jdof = 0; jdof < NDOF; ++jdof ) - { - dofColIndices[i * NDOF + jdof] = offset + jdof; - } - } - - // TODO: apply equation/variable change transformation(s) - - // Add to residual/jacobian - for( localIndex i = 0; i < NUM_ELEMS; ++i ) - { - if( ghostRank[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )] < 0 ) - { - globalIndex const globalRow = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; - localIndex const localRow = LvArray::integerConversion< localIndex >( globalRow - rankOffset ); - GEOSX_ASSERT_GE( localRow, 0 ); - GEOSX_ASSERT_GT( localMatrix.numRows(), localRow + NC ); - - for( localIndex ic = 0; ic < NC; ++ic ) - { - RAJA::atomicAdd( parallelDeviceAtomic{}, &localRhs[localRow + ic], localFlux[i * NC + ic] ); - localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( localRow + ic, - dofColIndices, - localFluxJacobian[i * NC + ic].dataIfContiguous(), - stencilSize * NDOF ); - } - } - } - } ); -} - -#define INST_FluxKernel( NC, STENCIL_TYPE ) \ - template \ - void FluxKernel:: \ - launch< NC, STENCIL_TYPE >( localIndex const numPhases, \ - STENCIL_TYPE const & stencil, \ - globalIndex const rankOffset, \ - ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, \ - ElementViewConst< arrayView1d< integer const > > const & ghostRank, \ - ElementViewConst< arrayView1d< real64 const > > const & pres, \ - ElementViewConst< arrayView1d< real64 const > > const & dPres, \ - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, \ - ElementViewConst< arrayView2d< real64 const > > const & phaseMob, \ - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dPres, \ - ElementViewConst< arrayView2d< real64 const > > const & dPhaseMob_dTemp, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMob_dComp, \ - ElementViewConst< arrayView2d< real64 const > > const & phaseVolFrac, \ - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dPres, \ - ElementViewConst< arrayView2d< real64 const > > const & dPhaseVolFrac_dTemp, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseVolFrac_dComp, \ - ElementViewConst< arrayView3d< real64 const > > const & dCompFrac_dCompDens, \ - ElementViewConst< arrayView3d< real64 const > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseMassDens_dTemp, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseMassDens_dComp, \ - ElementViewConst< arrayView4d< real64 const > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCompFrac_dTemp, \ - ElementViewConst< arrayView5d< real64 const > > const & dPhaseCompFrac_dComp, \ - ElementViewConst< arrayView3d< real64 const > > const & phaseCapPressure, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseCapPressure_dPhaseVolFrac, \ - ElementViewConst< arrayView1d< real64 const > > const & temp, \ - ElementViewConst< arrayView1d< real64 const > > const & dTemp, \ - ElementViewConst< arrayView3d< real64 const > > const & phaseEnthalpy, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dPres, \ - ElementViewConst< arrayView3d< real64 const > > const & dPhaseEnthalpy_dTemp, \ - ElementViewConst< arrayView4d< real64 const > > const & dPhaseEnthalpy_dComp, \ - integer const capPressureFlag, \ - real64 const dt, \ - CRSMatrixView< real64, globalIndex const > const & localMatrix, \ - arrayView1d< real64 > const & localRhs ) - -INST_FluxKernel( 1, CellElementStencilTPFA ); -INST_FluxKernel( 2, CellElementStencilTPFA ); -INST_FluxKernel( 3, CellElementStencilTPFA ); -INST_FluxKernel( 4, CellElementStencilTPFA ); -INST_FluxKernel( 5, CellElementStencilTPFA ); - -INST_FluxKernel( 1, FaceElementStencil ); -INST_FluxKernel( 2, FaceElementStencil ); -INST_FluxKernel( 3, FaceElementStencil ); -INST_FluxKernel( 4, FaceElementStencil ); -INST_FluxKernel( 5, FaceElementStencil ); - -#undef INST_FluxKernel - -/******************************** VolumeBalanceKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -GEOSX_FORCE_INLINE -void -VolumeBalanceKernel:: - compute( real64 const & volume, - real64 const & porosityRef, - real64 const & pvMult, - real64 const & dPvMult_dPres, - arraySlice1d< real64 const > const & phaseVolFrac, - arraySlice1d< real64 const > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const > const & dPhaseVolFrac_dCompDens, - real64 & localVolBalance, - real64 (& localVolBalanceJacobian)[NC+2] ) -{ - localIndex constexpr NDOF = NC + 2; - - real64 const poro = porosityRef * pvMult; - real64 const dPoro_dP = porosityRef * dPvMult_dPres; - - real64 const poreVol = volume * poro; - real64 const dPoreVol_dP = volume * dPoro_dP; - - localVolBalance = 1.0; - for( localIndex i = 0; i < NDOF; ++i ) - { - localVolBalanceJacobian[i] = 0.0; - } - - // sum contributions to component accumulation from each phase - for( localIndex ip = 0; ip < NP; ++ip ) - { - localVolBalance -= phaseVolFrac[ip]; - localVolBalanceJacobian[0] -= dPhaseVolFrac_dPres[ip]; - localVolBalanceJacobian[NC+1] -= dPhaseVolFrac_dTemp[ip]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - localVolBalanceJacobian[jc+1] -= dPhaseVolFrac_dCompDens[ip][jc]; - } - } - - // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) - for( localIndex idof = 0; idof < NDOF; ++idof ) - { - localVolBalanceJacobian[idof] *= poreVol; - } - localVolBalanceJacobian[0] += dPoreVol_dP * localVolBalance; - localVolBalance *= poreVol; -} - -template< localIndex NC, localIndex NP > -void -VolumeBalanceKernel:: - launch( localIndex const size, - globalIndex const rankOffset, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & elemGhostRank, - arrayView1d< real64 const > const & volume, - arrayView1d< real64 const > const & porosityRef, - arrayView2d< real64 const > const & pvMult, - arrayView2d< real64 const > const & dPvMult_dPres, - arrayView2d< real64 const > const & phaseVolFrac, - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( elemGhostRank[ei] >= 0 ) - return; - - localIndex constexpr NDOF = NC + 2; - - real64 localVolBalance; - real64 localVolBalanceJacobian[NDOF]; - - compute< NC, NP >( volume[ei], - porosityRef[ei], - pvMult[ei][0], - dPvMult_dPres[ei][0], - phaseVolFrac[ei], - dPhaseVolFrac_dPres[ei], - dPhaseVolFrac_dTemp[ei], - dPhaseVolFrac_dCompDens[ei], - localVolBalance, - localVolBalanceJacobian ); - - // get equation/dof indices - localIndex const localRow = dofNumber[ei] + NC + 1 - rankOffset; - globalIndex dofIndices[NDOF]; - for( localIndex jdof = 0; jdof < NDOF; ++jdof ) - { - dofIndices[jdof] = dofNumber[ei] + jdof; - } - - // TODO: apply equation/variable change transformation(s) - - // add contribution to residual and jacobian - localRhs[localRow] += localVolBalance; - localMatrix.addToRow< serialAtomic >( localRow, - dofIndices, - localVolBalanceJacobian, - NDOF ); - } ); -} - -#define INST_VolumeBalanceKernel( NC, NP ) \ - template \ - void VolumeBalanceKernel:: \ - launch< NC, NP >( localIndex const size, \ - globalIndex const rankOffset, \ - arrayView1d< globalIndex const > const & dofNumber, \ - arrayView1d< integer const > const & elemGhostRank, \ - arrayView1d< real64 const > const & volume, \ - arrayView1d< real64 const > const & porosityRef, \ - arrayView2d< real64 const > const & pvMult, \ - arrayView2d< real64 const > const & dPvMult_dPres, \ - arrayView2d< real64 const > const & phaseVolFrac, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const > const & dPhaseVolFrac_dCompDens, \ - CRSMatrixView< real64, globalIndex const > const & localMatrix, \ - arrayView1d< real64 > const & localRhs ) - -INST_VolumeBalanceKernel( 1, 1 ); -INST_VolumeBalanceKernel( 2, 1 ); -INST_VolumeBalanceKernel( 3, 1 ); -INST_VolumeBalanceKernel( 4, 1 ); -INST_VolumeBalanceKernel( 5, 1 ); - -INST_VolumeBalanceKernel( 1, 2 ); -INST_VolumeBalanceKernel( 2, 2 ); -INST_VolumeBalanceKernel( 3, 2 ); -INST_VolumeBalanceKernel( 4, 2 ); -INST_VolumeBalanceKernel( 5, 2 ); - -INST_VolumeBalanceKernel( 1, 3 ); -INST_VolumeBalanceKernel( 2, 3 ); -INST_VolumeBalanceKernel( 3, 3 ); -INST_VolumeBalanceKernel( 4, 3 ); -INST_VolumeBalanceKernel( 5, 3 ); - -#undef INST_VolumeBalanceKernel - -} // namespace CompositionalMultiphaseFlowKernels - -} // namespace geosx From 74c66cd82fa4cbb7f8029fe299c46c9c9b492a64 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 13 Oct 2021 17:57:35 -0700 Subject: [PATCH 19/34] additional fix --- .../fluidFlow/CompositionalMultiphaseBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index d4765fb34b1..f8ee262bacc 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -1443,13 +1443,13 @@ void CompositionalMultiphaseBase::implicitStepComplete( real64 const & GEOSX_UNU if( !m_isothermalFlag ) { arrayView1d< real64 const > const dTemp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); arrayView1d< real64 > const temp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { - temp[ei] += dTemp[ei]; + temp[ei] += dTemp[ei]; } ); } From 6af1845dedcb3ede65bb150c921f97f4eca39591 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 1 Dec 2021 18:31:39 -0800 Subject: [PATCH 20/34] added thermal accumulation and volume balance in the new style --- .../PVTFunctions/EzrokhiBrineDensity.hpp | 2 +- .../PVTFunctions/EzrokhiBrineViscosity.hpp | 2 +- .../fluidFlow/CompositionalMultiphaseBase.cpp | 59 ++- .../fluidFlow/CompositionalMultiphaseBase.hpp | 2 - ...rmalCompositionalMultiphaseBaseKernels.hpp | 38 +- ...rmalCompositionalMultiphaseBaseKernels.cpp | 457 ------------------ ...rmalCompositionalMultiphaseBaseKernels.hpp | 419 ++++++++++++---- 7 files changed, 369 insertions(+), 610 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp index e84cf70a9dc..c2f5e692149 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineDensity.hpp @@ -238,7 +238,7 @@ void EzrokhiBrineDensityUpdate::compute( real64 const & pressure, value = waterDensity * exponentPowered; - real64 const dValueCoef = log( 10 ) * value; + real64 const dValueCoef = LvArray::math::log( 10 ) * value; real64 const dValue_dPhaseComp = dValueCoef * exponent_dPhaseComp; dValue_dPressure = dValueCoef * exponent_dPressure + waterDensity_dPressure * exponentPowered; diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp index 5189c4870c9..cbfa6ee1151 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/EzrokhiBrineViscosity.hpp @@ -210,7 +210,7 @@ void EzrokhiBrineViscosityUpdate::compute( real64 const & pressure, real64 const exponentPowered = pow( 10, exponent ); value = waterVisc * exponentPowered; - real64 const dValueCoef = log( 10 ) * value; + real64 const dValueCoef = LvArray::math::log( 10 ) * value; real64 const dValue_dPhaseComp = dValueCoef * exponent_dPhaseComp; dValue_dPressure = dValueCoef * exponent_dPressure; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 12b5218a10a..b06f7f18f32 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -205,6 +205,10 @@ void CompositionalMultiphaseBase::registerDataOnMesh( Group & meshBodies ) subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseMobility_dTemperatureString() ). setRestartFlags( RestartFlags::NO_WRITE ). reference().resizeDimension< 1 >( m_numPhases ); + + subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseInternalEnergyOldString() ). + setRestartFlags( RestartFlags::NO_WRITE ). + reference().resizeDimension< 1 >( m_numPhases ); } if( m_computeCFLNumbers ) @@ -1009,7 +1013,9 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh ) const forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { if( elemGhostRank[ei] >= 0 ) + { return; + } for( localIndex ip = 0; ip < numPhase; ++ip ) { @@ -1024,6 +1030,27 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh ) const } totalDensOld[ei] = totalDens[ei][0]; } ); + + if( !m_isothermalFlag ) + { + arrayView3d< real64 const, multifluid::USD_PHASE > const phaseInternalEnergy = fluid.phaseInternalEnergy(); + + arrayView2d< real64, compflow::USD_PHASE > const phaseInternalEnergyOld = + subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseInternalEnergyOldString() ); + + forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( elemGhostRank[ei] >= 0 ) + { + return; + } + + for( localIndex ip = 0; ip < numPhase; ++ip ) + { + phaseInternalEnergyOld[ei][ip] = phaseInternalEnergy[ei][0][ip]; + } + } ); + } } ); } @@ -1089,20 +1116,24 @@ void CompositionalMultiphaseBase::assembleAccumulationAndVolumeBalanceTerms( Dom MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidModelNames()[targetIndex] ); CoupledSolidBase const & solid = getConstitutiveModel< CoupledSolidBase >( subRegion, m_solidModelNames[targetIndex] ); - bool const isIsothermal = true; - IsothermalCompositionalMultiphaseBaseKernels:: - ElementBasedAssemblyKernelFactory:: - createAndLaunch< parallelDevicePolicy<> > - ( isIsothermal, - m_numComponents, - m_numPhases, - dofManager.rankOffset(), - dofKey, - subRegion, - fluid, - solid, - localMatrix, - localRhs ); + if( m_isothermalFlag ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + ElementBasedAssemblyKernelFactory:: + createAndLaunch< parallelDevicePolicy<> > + ( m_numComponents, m_numPhases, dofManager.rankOffset(), dofKey, + subRegion, fluid, solid, + localMatrix, localRhs ); + } + else + { + ThermalCompositionalMultiphaseBaseKernels:: + ElementBasedAssemblyKernelFactory:: + createAndLaunch< parallelDevicePolicy<> > + ( m_numComponents, m_numPhases, dofManager.rankOffset(), dofKey, + subRegion, fluid, solid, + localMatrix, localRhs ); + } } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp index 24a25a1ac97..e5718b10f3e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp @@ -285,8 +285,6 @@ class CompositionalMultiphaseBase : public FlowSolverBase static constexpr char const * phaseInternalEnergyOldString() { return "phaseInternalEnergyOld"; } - static constexpr char const * rockInternalEnergyOldString() { return "rockInternalEnergyOld"; } - // these are allocated on faces for BC application until we can get constitutive models on faces static constexpr char const * phaseViscosityString() { return "phaseViscosity"; } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp index ebf7ac407a3..846ececcf12 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp @@ -428,13 +428,13 @@ class ElementBasedAssemblyKernel // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives // possible use: assemble the derivatives wrt temperature, and the accumulation term of the energy equation for this phase - phaseAmountKernelOp( ip, phaseAmountNew, phaseAmountOld, dPhaseAmount_dP, dPhaseAmount_dC ); + phaseAmountKernelOp( ip, stack.localResidual, stack.localJacobian, phaseAmountNew, phaseAmountOld, dPhaseAmount_dP, dPhaseAmount_dC ); } } /** - * @brief Compute the local accumulation contributions to the residual and Jacobian + * @brief Compute the local volume balance contributions to the residual and Jacobian * @tparam FUNC the type of the function that can be used to customize the kernel * @param[in] ei the element index * @param[inout] stack the stack variables @@ -474,7 +474,7 @@ class ElementBasedAssemblyKernel // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives // possible use: assemble the derivatives wrt temperature, and use oneMinusPhaseVolFracSum if poreVolumeNew depends on temperature - phaseVolFractionSumKernelOp( oneMinusPhaseVolFracSum ); + phaseVolFractionSumKernelOp( stack.localResidual, stack.localJacobian, oneMinusPhaseVolFracSum ); } /** @@ -624,7 +624,6 @@ class ElementBasedAssemblyKernelFactory /** * @brief Create a new kernel and launch * @tparam POLICY the policy used in the RAJA kernel - * @param[in] isIsothermal flag specifying whether the assembly is isothermal or non-isothermal * @param[in] numComps the number of fluid components * @param[in] numPhases the number of fluid phases * @param[in] rankOffset the offset of my MPI rank @@ -637,8 +636,7 @@ class ElementBasedAssemblyKernelFactory */ template< typename POLICY > static void - createAndLaunch( bool const isIsothermal, - localIndex const numComps, + createAndLaunch( localIndex const numComps, localIndex const numPhases, globalIndex const rankOffset, string const dofKey, @@ -650,28 +648,12 @@ class ElementBasedAssemblyKernelFactory { internal::kernelLaunchSelectorCompSwitch( numComps, [&] ( auto NC ) { - if( isIsothermal ) - { - localIndex constexpr NUM_COMP = NC(); - localIndex constexpr NUM_DOF = NC()+1; - ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > - kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); - ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template - launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > >( subRegion.size(), kernel ); - } - else - { - GEOSX_ERROR( "CompositionalMultiphaseBase: Thermal simulation is not supported yet: " ); - /* - TODO: uncomment and move when the thermal kernel is ready - localIndex constexpr NUM_COMP = NC(); - localIndex constexpr NUM_DOF = NC()+2; - ThermalElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > - kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); - ThermalElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template - launch< POLICY, ThermalElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > >( subRegion.size(), kernel ); - */ - } + localIndex constexpr NUM_COMP = NC(); + localIndex constexpr NUM_DOF = NC()+1; + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > + kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template + launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > >( subRegion.size(), kernel ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.cpp index 54b8649e9cf..c242a56e8a4 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.cpp @@ -246,463 +246,6 @@ INST_PhaseVolumeFractionKernel( 5, 3 ); #undef INST_PhaseVolumeFractionKernel -/******************************** AccumulationKernel ********************************/ - -template< localIndex NC > -GEOSX_HOST_DEVICE -void -AccumulationKernel:: - compute( localIndex const numPhases, - real64 const & volume, - real64 const & porosityOld, - real64 const & porosityNew, - real64 const & dPoro_dPres, - arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFracOld, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dCompDens, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseDensOld, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & phaseDens, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & dPhaseDens_dPres, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & dPhaseDens_dTemp, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, - arraySlice2d< real64 const, compflow::USD_PHASE_COMP-1 > const & phaseCompFracOld, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_COMP-2 > const & phaseCompFrac, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_COMP-2 > const & dPhaseCompFrac_dPres, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_COMP-2 > const & dPhaseCompFrac_dTemp, - arraySlice3d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC-2 > const & dPhaseCompFrac_dComp, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseInternalEnergyOld, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & dPhaseInternalEnergy_dPres, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & dPhaseInternalEnergy_dTemp, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const & dPhaseInternalEnergy_dComp, - real64 const & rockInternalEnergyOld, - real64 const & rockInternalEnergy, - real64 const & dRockInternalEnergy_dTemp, - real64 const & rockDensity, - real64 ( & localAccum )[NC+1], - real64 ( & localAccumJacobian )[NC+1][NC+2] ) -{ - localIndex constexpr NDOF = NC + 2; - localIndex const NP = numPhases; - - // pore volumes and solid volumes - real64 const poreVolNew = volume * porosityNew; - real64 const poreVolOld = volume * porosityOld; - real64 const dPoreVol_dP = volume * dPoro_dPres; - real64 const solidVolNew = volume * (1-porosityNew); - real64 const solidVolOld = volume * (1-porosityOld); - real64 const dSolidVol_dP = -volume * dPoro_dPres; - - // temporary work arrays - real64 dPhaseAmount_dC[NC]; - real64 dPhaseCompFrac_dC[NC]; - real64 dPhaseInternalEnergy_dC[NC]; - - // reset the local values - for( localIndex i = 0; i < NC+1; ++i ) - { - localAccum[i] = 0.0; - for( localIndex j = 0; j < NDOF; ++j ) - { - localAccumJacobian[i][j] = 0.0; - } - } - - // sum contributions to component accumulation from each phase - for( localIndex ip = 0; ip < NP; ++ip ) - { - real64 const phaseAmountNew = poreVolNew * phaseVolFrac[ip] * phaseDens[ip]; - real64 const phaseAmountOld = poreVolOld * phaseVolFracOld[ip] * phaseDensOld[ip]; - - real64 const dPhaseAmount_dP = dPoreVol_dP * phaseVolFrac[ip] * phaseDens[ip] - + poreVolNew * (dPhaseVolFrac_dPres[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dPres[ip]); - - real64 const dPoreVol_dT = 0.0; - real64 const dPhaseAmount_dT = dPoreVol_dT * phaseVolFrac[ip] * phaseDens[ip] - + poreVolNew * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] - + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); - - // assemble density dependence - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] - + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][jc]; - dPhaseAmount_dC[jc] *= poreVolNew; - } - - // ic - index of component whose conservation equation is assembled - // (i.e. row number in local matrix) - for( localIndex 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]; - - real64 const dPhaseCompAmount_dT = dPhaseAmount_dT * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; - - localAccum[ic] += phaseCompAmountNew - phaseCompAmountOld; - localAccumJacobian[ic][0] += dPhaseCompAmount_dP; - localAccumJacobian[ic][NC+1] += dPhaseCompAmount_dT; - - // jc - index of component w.r.t. whose compositional var the derivative is being taken - // (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 ) - { - real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew - + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; - localAccumJacobian[ic][jc + 1] += dPhaseCompAmount_dC; - } - } - - // Energy balance equation - real64 const phaseEnergyNew = phaseAmountNew * phaseInternalEnergy[ip]; - real64 const phaseEnergyOld = phaseAmountOld * phaseInternalEnergyOld[ip]; - - real64 const solidEnergyNew = solidVolNew * rockInternalEnergy * rockDensity; - real64 const solidEnergyOld = solidVolOld * rockInternalEnergyOld * rockDensity; - - // local accumulation - localAccum[NC] = phaseEnergyNew - phaseEnergyOld + solidEnergyNew - solidEnergyOld; - - real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dPres[ip]; - real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + phaseAmountNew * dPhaseInternalEnergy_dTemp[ip]; - - real64 const dSolidInternalEnergy_dP = dSolidVol_dP * rockInternalEnergy * rockDensity; - // TODO porosity and volume may depend on temperature - real64 const dSolidInternalEnergy_dT = solidVolNew * dRockInternalEnergy_dTemp; - - // derivatives w.r.t. pressure and temperature - localAccumJacobian[NC][0] += dPhaseEnergy_dP + dSolidInternalEnergy_dP; - localAccumJacobian[NC][NC+1] += dPhaseEnergy_dT + dSolidInternalEnergy_dT; - - // derivatives w.r.t. component densities - applyChainRule( NC, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - real64 const dPhaseEnergy_dC = phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] - + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; - - localAccumJacobian[NC][jc + 1] += dPhaseEnergy_dC; - } - } -} - -template< localIndex NC > -void -AccumulationKernel:: - launch( localIndex const numPhases, - localIndex const size, - globalIndex const rankOffset, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & elemGhostRank, - arrayView1d< real64 const > const & volume, - arrayView2d< real64 const > const & porosityOld, - arrayView2d< real64 const > const & porosityNew, - arrayView2d< real64 const > const & dPoro_dPres, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFracOld, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseDensOld, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, compflow::USD_PHASE_COMP > const & phaseCompFracOld, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const & phaseCompFrac, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dPres, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dTemp, - arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > const & dPhaseCompFrac_dComp, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseInternalEnergyOld, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseInternalEnergy, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseInternalEnergy_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseInternalEnergy_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseInternalEnergy_dComp, - arrayView1d< real64 const > const & rockInternalEnergyOld, - arrayView2d< real64 const > const & rockInternalEnergy, - arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, - arrayView2d< real64 const > const & rockDensity, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) -{ - using namespace CompositionalMultiphaseUtilities; - - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( elemGhostRank[ei] >= 0 ) - { - return; - } - - localIndex constexpr NDOF = NC + 2; // number of dofs - localIndex constexpr NBEQ = NC + 1; // number of balance equations - - real64 localAccum[NBEQ]; - real64 localAccumJacobian[NBEQ][NDOF]; - - compute< NC >( numPhases, - volume[ei], - porosityOld[ei][0], - porosityNew[ei][0], - dPoro_dPres[ei][0], - dCompFrac_dCompDens[ei], - phaseVolFracOld[ei], - phaseVolFrac[ei], - dPhaseVolFrac_dPres[ei], - dPhaseVolFrac_dTemp[ei], - dPhaseVolFrac_dCompDens[ei], - phaseDensOld[ei], - phaseDens[ei][0], - dPhaseDens_dPres[ei][0], - dPhaseDens_dTemp[ei][0], - dPhaseDens_dComp[ei][0], - phaseCompFracOld[ei], - phaseCompFrac[ei][0], - dPhaseCompFrac_dPres[ei][0], - dPhaseCompFrac_dTemp[ei][0], - dPhaseCompFrac_dComp[ei][0], - phaseInternalEnergyOld[ei], - phaseInternalEnergy[ei][0], - dPhaseInternalEnergy_dPres[ei][0], - dPhaseInternalEnergy_dTemp[ei][0], - dPhaseInternalEnergy_dComp[ei][0], - rockInternalEnergyOld[ei], - rockInternalEnergy[ei][0], - dRockInternalEnergy_dTemp[ei][0], - rockDensity[ei][0], - localAccum, - localAccumJacobian ); - - // set DOF indices for this block - localIndex const localRow = dofNumber[ei] - rankOffset; - globalIndex dofIndices[NDOF]; - for( localIndex idof = 0; idof < NDOF; ++idof ) - { - dofIndices[idof] = dofNumber[ei] + idof; - } - - // Apply equation/variable change transformation(s) - real64 work[NDOF-1]; - shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, NDOF-1, localAccumJacobian, work ); - shiftElementsAheadByOneAndReplaceFirstElementWithSum( NC, localAccum ); - - // add contribution to residual and jacobian - for( localIndex i = 0; i < NBEQ; ++i ) - { - localRhs[localRow + i] += localAccum[i]; - localMatrix.addToRow< serialAtomic >( localRow + i, - dofIndices, - localAccumJacobian[i], - NDOF ); - } - } ); -} - -#define INST_AccumulationKernel( NC ) \ - template \ - void \ - AccumulationKernel:: \ - launch< NC >( localIndex const numPhases, \ - localIndex const size, \ - globalIndex const rankOffset, \ - arrayView1d< globalIndex const > const & dofNumber, \ - arrayView1d< integer const > const & elemGhostRank, \ - arrayView1d< real64 const > const & volume, \ - arrayView2d< real64 const > const & porosityOld, \ - arrayView2d< real64 const > const & porosityNew, \ - arrayView2d< real64 const > const & dPoro_dPres, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFracOld, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseDensOld, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, compflow::USD_PHASE_COMP > const & phaseCompFracOld, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const & phaseCompFrac, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dPres, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dTemp, \ - arrayView5d< real64 const, constitutive::multifluid::USD_PHASE_COMP_DC > const & dPhaseCompFrac_dComp, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseInternalEnergyOld, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseInternalEnergy, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseInternalEnergy_dPres, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseInternalEnergy_dTemp, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseInternalEnergy_dComp, \ - arrayView1d< real64 const > const & rockInternalEnergyOld, \ - arrayView2d< real64 const > const & rockInternalEnergy, \ - arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, \ - arrayView2d< real64 const > const & rockDensity, \ - CRSMatrixView< real64, globalIndex const > const & localMatrix, \ - arrayView1d< real64 > const & localRhs ) - -INST_AccumulationKernel( 1 ); -INST_AccumulationKernel( 2 ); -INST_AccumulationKernel( 3 ); -INST_AccumulationKernel( 4 ); -INST_AccumulationKernel( 5 ); - -#undef INST_AccumulationKernel - -/******************************** VolumeBalanceKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -void -VolumeBalanceKernel:: - compute( real64 const & volume, - real64 const & porosity, - real64 const & dPoro_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dCompDens, - real64 & localVolBalance, - real64 (& localVolBalanceJacobian)[NC+2] ) -{ - localIndex constexpr NDOF = NC + 2; - - real64 const poreVol = volume * porosity; - real64 const dPoreVol_dP = volume * dPoro_dPres; - - localVolBalance = 1.0; - for( localIndex i = 0; i < NDOF; ++i ) - { - localVolBalanceJacobian[i] = 0.0; - } - - // sum contributions to component accumulation from each phase - for( localIndex ip = 0; ip < NP; ++ip ) - { - localVolBalance -= phaseVolFrac[ip]; - localVolBalanceJacobian[0] -= dPhaseVolFrac_dPres[ip]; - localVolBalanceJacobian[NC+1] -= dPhaseVolFrac_dTemp[ip]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - localVolBalanceJacobian[jc+1] -= dPhaseVolFrac_dCompDens[ip][jc]; - } - } - - // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) - for( localIndex idof = 0; idof < NDOF; ++idof ) - { - localVolBalanceJacobian[idof] *= poreVol; - } - localVolBalanceJacobian[0] += dPoreVol_dP * localVolBalance; - localVolBalance *= poreVol; -} - -template< localIndex NC, localIndex NP > -void -VolumeBalanceKernel:: - launch( localIndex const size, - globalIndex const rankOffset, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & elemGhostRank, - arrayView1d< real64 const > const & volume, - arrayView2d< real64 const > const & porosity, - arrayView2d< real64 const > const & dPoro_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( elemGhostRank[ei] >= 0 ) - return; - - localIndex constexpr NDOF = NC + 2; - - real64 localVolBalance; - real64 localVolBalanceJacobian[NDOF]; - - compute< NC, NP >( volume[ei], - porosity[ei][0], - dPoro_dPres[ei][0], - phaseVolFrac[ei], - dPhaseVolFrac_dPres[ei], - dPhaseVolFrac_dTemp[ei], - dPhaseVolFrac_dCompDens[ei], - localVolBalance, - localVolBalanceJacobian ); - - // get equation/dof indices - localIndex const localRow = dofNumber[ei] + NC + 1 - rankOffset; - globalIndex dofIndices[NDOF]; - for( localIndex jdof = 0; jdof < NDOF; ++jdof ) - { - dofIndices[jdof] = dofNumber[ei] + jdof; - } - - // TODO: apply equation/variable change transformation(s) - - // add contribution to residual and jacobian - localRhs[localRow] += localVolBalance; - localMatrix.addToRow< serialAtomic >( localRow, - dofIndices, - localVolBalanceJacobian, - NDOF ); - } ); -} - -#define INST_VolumeBalanceKernel( NC, NP ) \ - template \ - void VolumeBalanceKernel:: \ - launch< NC, NP >( localIndex const size, \ - globalIndex const rankOffset, \ - arrayView1d< globalIndex const > const & dofNumber, \ - arrayView1d< integer const > const & elemGhostRank, \ - arrayView1d< real64 const > const & volume, \ - arrayView2d< real64 const > const & porosity, \ - arrayView2d< real64 const > const & dPoro_dPres, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens, \ - CRSMatrixView< real64, globalIndex const > const & localMatrix, \ - arrayView1d< real64 > const & localRhs ) - -INST_VolumeBalanceKernel( 1, 1 ); -INST_VolumeBalanceKernel( 2, 1 ); -INST_VolumeBalanceKernel( 3, 1 ); -INST_VolumeBalanceKernel( 4, 1 ); -INST_VolumeBalanceKernel( 5, 1 ); - -INST_VolumeBalanceKernel( 1, 2 ); -INST_VolumeBalanceKernel( 2, 2 ); -INST_VolumeBalanceKernel( 3, 2 ); -INST_VolumeBalanceKernel( 4, 2 ); -INST_VolumeBalanceKernel( 5, 2 ); - -INST_VolumeBalanceKernel( 1, 3 ); -INST_VolumeBalanceKernel( 2, 3 ); -INST_VolumeBalanceKernel( 3, 3 ); -INST_VolumeBalanceKernel( 4, 3 ); -INST_VolumeBalanceKernel( 5, 3 ); - -#undef INST_VolumeBalanceKernel - - } // namespace ThermalCompositionalMultiphaseBaseKernels } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index ff128f78e53..6b29594f5b2 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -21,9 +21,11 @@ #include "common/DataLayouts.hpp" #include "common/DataTypes.hpp" +#include "common/GEOS_RAJA_Interface.hpp" #include "constitutive/fluid/layouts.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" #include "mesh/ElementRegionManager.hpp" -#include "common/GEOS_RAJA_Interface.hpp" + namespace geosx { @@ -99,126 +101,329 @@ struct PhaseVolumeFractionKernel arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ); }; -/******************************** AccumulationKernel ********************************/ +/******************************** ElementBasedAssemblyKernel ********************************/ /** - * @brief Functions to assemble accumulation term contributions to residual and Jacobian + * @class ElementBasedAssemblyKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_DOF number of degrees of freedom + * @brief Define the interface for the assembly kernel in charge of thermal accumulation and volume balance */ -struct AccumulationKernel +template< localIndex NUM_COMP, localIndex NUM_DOF > +class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseKernels::ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > { +public: + + using Base = IsothermalCompositionalMultiphaseBaseKernels::ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >; + using Base::numComp; + using Base::numDof; + using Base::numEqn; + using Base::m_numPhases; + using Base::m_rankOffset; + using Base::m_dofNumber; + using Base::m_elemGhostRank; + using Base::m_volume; + using Base::m_porosityOld; + using Base::m_porosityNew; + using Base::m_dPoro_dPres; + using Base::m_dCompFrac_dCompDens; + using Base::m_phaseVolFracOld; + using Base::m_phaseVolFrac; + using Base::m_dPhaseVolFrac_dPres; + using Base::m_dPhaseVolFrac_dCompDens; + using Base::m_phaseDensOld; + using Base::m_phaseDens; + using Base::m_dPhaseDens_dPres; + using Base::m_dPhaseDens_dComp; + using Base::m_phaseCompFracOld; + using Base::m_phaseCompFrac; + using Base::m_dPhaseCompFrac_dPres; + using Base::m_dPhaseCompFrac_dComp; + using Base::m_localMatrix; + using Base::m_localRhs; + using keys = CompositionalMultiphaseBase::viewKeyStruct; + + /** + * @brief Constructor + * @param[in] numPhases the number of fluid phases + * @param[in] rankOffset the offset of my MPI rank + * @param[in] dofKey the string key to retrieve the degress of freedom numbers + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] solid the solid model + * @param[inout] localMatrix the local CRS matrix + * @param[inout] localRhs the local right-hand side vector + */ + ElementBasedAssemblyKernel( localIndex const numPhases, + globalIndex const rankOffset, + string const dofKey, + ElementSubRegionBase const & subRegion, + MultiFluidBase const & fluid, + CoupledSolidBase const & solid, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) + : Base( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ), + m_dPhaseVolFrac_dTemp( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::dPhaseVolumeFraction_dTemperatureString() ) ), + m_dPhaseDens_dTemp( fluid.dPhaseDensity_dTemperature() ), + m_dPhaseCompFrac_dTemp( fluid.dPhaseCompFraction_dTemperature() ), + m_phaseInternalEnergyOld( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::phaseInternalEnergyOldString() ) ), + m_phaseInternalEnergy( fluid.phaseInternalEnergy() ), + m_dPhaseInternalEnergy_dPres( fluid.dPhaseInternalEnergy_dPressure() ), + m_dPhaseInternalEnergy_dTemp( fluid.dPhaseInternalEnergy_dTemperature() ), + m_dPhaseInternalEnergy_dComp( fluid.dPhaseInternalEnergy_dGlobalCompFraction() ), + m_rockInternalEnergyOld( solid.getOldInternalEnergy() ), + m_rockInternalEnergy( solid.getInternalEnergy() ), + m_dRockInternalEnergy_dTemp( solid.getDinternalEnergy_dTemperature() ), + m_rockDensity( solid.getDensity() ) + {} + + // This seems useless, but if I remove it, it does not compile + struct StackVariables : public Base::StackVariables + { +public: + + GEOSX_HOST_DEVICE + StackVariables() + : Base::StackVariables() + {} + + using Base::StackVariables::poreVolumeNew; + using Base::StackVariables::poreVolumeOld; + using Base::StackVariables::dPoreVolume_dPres; + using Base::StackVariables::localRow; + using Base::StackVariables::dofIndices; + using Base::StackVariables::localResidual; + using Base::StackVariables::localJacobian; + + // Solid energy + + /// Solid energy at time n+1 + real64 solidEnergyNew = 0.0; + + /// Solid energy at the previous converged time step + real64 solidEnergyOld = 0.0; - template< localIndex NC > + /// Derivative of solid internal energy with respect to pressure + real64 dSolidEnergy_dPres = 0.0; + + /// Derivative of solid internal energy with respect to temperature + real64 dSolidEnergy_dTemp = 0.0; + + }; + + /** + * @brief Performs the setup phase for the kernel. + * @param[in] ei the element index + * @param[in] stack the stack variables + */ GEOSX_HOST_DEVICE - static void - compute( localIndex const numPhases, - real64 const & volume, - real64 const & porosityOld, - real64 const & porosityNew, - real64 const & dPoro_dPres, - arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFracOld, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dCompDens, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseDensOld, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dPres, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, - arraySlice2d< real64 const, compflow::USD_PHASE_COMP - 1 > const & phaseCompFracOld, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & phaseCompFrac, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & dPhaseCompFrac_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP - 2 > const & dPhaseCompFrac_dTemp, - arraySlice3d< real64 const, multifluid::USD_PHASE_COMP_DC - 2 > const & dPhaseCompFrac_dComp, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseInternalEnergyOld, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseInternalEnergy, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseInternalEnergy_dPres, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseInternalEnergy_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseInternalEnergy_dComp, - real64 const & rockInternalEnergyOld, - real64 const & rockInternalEnergy, - real64 const & dRockInternalEnergy_dTemp, - real64 const & rockDensity, - real64 ( &localAccum )[NC+1], - real64 ( &localAccumJacobian )[NC+1][NC+2] ); - - template< localIndex NC > - static void - launch( localIndex const numPhases, - localIndex const size, - globalIndex const rankOffset, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & elemGhostRank, - arrayView1d< real64 const > const & volume, - arrayView2d< real64 const > const & porosityOld, - arrayView2d< real64 const > const & porosityNew, - arrayView2d< real64 const > const & dPoro_dPres, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFracOld, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseDensOld, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, compflow::USD_PHASE_COMP > const & phaseCompFracOld, - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & phaseCompFrac, - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const & dPhaseCompFrac_dTemp, - arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > const & dPhaseCompFrac_dComp, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseInternalEnergyOld, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseInternalEnergy, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseInternalEnergy_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseInternalEnergy_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseInternalEnergy_dComp, - arrayView1d< real64 const > const & rockInternalEnergyOld, - arrayView2d< real64 const > const & rockInternalEnergy, - arrayView2d< real64 const > const & dRockInternalEnergy_dTemp, - arrayView2d< real64 const > const & rockDensity, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ); + void setup( localIndex const ei, + StackVariables & stack ) const + { + Base::setup( ei, stack ); + + // initialize the solid volume + real64 const solidVolumeNew = m_volume[ei] * ( 1.0 - m_porosityNew[ei][0] ); + real64 const solidVolumeOld = m_volume[ei] * ( 1.0 - m_porosityOld[ei][0] ); + real64 const dSolidVolume_dPres = -m_volume[ei] * m_dPoro_dPres[ei][0]; + + // initialize the solid internal energy + stack.solidEnergyNew = solidVolumeNew * m_rockInternalEnergy[ei][0] * m_rockDensity[ei][0]; + stack.solidEnergyOld = solidVolumeOld * m_rockInternalEnergyOld[ei][0] * m_rockDensity[ei][0]; + stack.dSolidEnergy_dPres = dSolidVolume_dPres * m_rockInternalEnergy[ei][0] * m_rockDensity[ei][0]; + stack.dSolidEnergy_dTemp = solidVolumeNew * m_dRockInternalEnergy_dTemp[ei][0] * m_rockDensity[ei][0]; + } -}; + /** + * @brief Compute the local accumulation contributions to the residual and Jacobian + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[inout] stack the stack variables + */ + GEOSX_HOST_DEVICE + void computeAccumulation( localIndex const ei, + StackVariables & stack ) const + { + Base::computeAccumulation( ei, stack, [=] GEOSX_HOST_DEVICE ( localIndex const ip, + real64 (& localResidual)[numEqn], + real64 (& localJacobian)[numEqn][numDof], + real64 const & phaseAmountNew, + real64 const & phaseAmountOld, + real64 const & dPhaseAmount_dP, + real64 const (&dPhaseAmount_dC)[numComp] ) + { + // We are in the loop over phases, ip provides the current phase index. + // We have to do two things: + // 1- Assemble the derivatives of the component mass balance equations with respect to temperature + // 2- Assemble the phase-dependent part of the accumulation term of the energy equation + + real64 dPhaseInternalEnergy_dC[numComp]{}; + + // construct the slices + arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFrac = m_phaseVolFrac[ei]; + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dTemp = m_dPhaseVolFrac_dTemp[ei]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > phaseDens = m_phaseDens[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseDens_dTemp = m_dPhaseDens_dTemp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_COMP-2 > phaseCompFrac = m_phaseCompFrac[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_COMP-2 > dPhaseCompFrac_dTemp = m_dPhaseCompFrac_dTemp[ei][0]; + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseInternalEnergyOld = m_phaseInternalEnergyOld[ei]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > phaseInternalEnergy = m_phaseInternalEnergy[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseInternalEnergy_dPres = m_dPhaseInternalEnergy_dPres[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > dPhaseInternalEnergy_dTemp = m_dPhaseInternalEnergy_dTemp[ei][0]; + arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > dPhaseInternalEnergy_dComp = m_dPhaseInternalEnergy_dComp[ei][0]; + + // Step 1: assemble the derivatives of the component mass balance equations with respect to temperature + + real64 const dPhaseAmount_dT = stack.poreVolumeNew + * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); + for( integer ic = 0; ic < numComp; ++ic ) + { + localJacobian[ic][numDof-1] += dPhaseAmount_dT * phaseCompFrac[ip][ic] + + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; + } + + // Step 2: assemble the phase-dependent part of the accumulation term of the energy equation + + real64 const phaseEnergyNew = phaseAmountNew * phaseInternalEnergy[ip]; + real64 const phaseEnergyOld = phaseAmountOld * phaseInternalEnergyOld[ip]; + real64 const dPhaseEnergy_dP = dPhaseAmount_dP * phaseInternalEnergy[ip] + + phaseAmountNew * dPhaseInternalEnergy_dPres[ip]; + real64 const dPhaseEnergy_dT = dPhaseAmount_dT * phaseInternalEnergy[ip] + + phaseAmountNew * dPhaseInternalEnergy_dTemp[ip]; + + // local accumulation + localResidual[numEqn-1] = phaseEnergyNew - phaseEnergyOld; -/******************************** VolumeBalanceKernel ********************************/ + // derivatives w.r.t. pressure and temperature + localJacobian[numEqn-1][0] += dPhaseEnergy_dP; + localJacobian[numEqn-1][numDof-1] += dPhaseEnergy_dT; + + // derivatives w.r.t. component densities + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); + for( integer jc = 0; jc < numComp; ++jc ) + { + localJacobian[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; + } + } ); + + // Step 3: assemble the solid part of the accumulation term + + // local accumulation and derivatives w.r.t. pressure and temperature + stack.localResidual[numEqn-1] += stack.solidEnergyNew - stack.solidEnergyOld; + stack.localJacobian[numEqn-1][0] += stack.dSolidEnergy_dPres; + stack.localJacobian[numEqn-1][numDof-1] += stack.dSolidEnergy_dTemp; + } + + /** + * @brief Compute the local volume balance contributions to the residual and Jacobian + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[inout] stack the stack variables + */ + GEOSX_HOST_DEVICE + void computeVolumeBalance( localIndex const ei, + StackVariables & stack ) const + { + Base::computeVolumeBalance( ei, stack, [=] GEOSX_HOST_DEVICE ( real64 (& localResidual)[numEqn], + real64 (& localJacobian)[numEqn][numDof], + real64 const & oneMinusPhaseVolFraction ) + { + GEOSX_UNUSED_VAR( localResidual, oneMinusPhaseVolFraction ); + + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dTemp = m_dPhaseVolFrac_dTemp[ei]; + + for( integer ip = 0; ip < m_numPhases; ++ip ) + { + localJacobian[numEqn-2][numDof-1] -= dPhaseVolFrac_dTemp[ip]; + } + } ); + } + + GEOSX_HOST_DEVICE + void complete( localIndex const ei, + StackVariables & stack ) const + { + // Step 1: assemble the component mass balance equations + Base::complete( ei, stack ); + + // Step 2: assemble the energy equation + m_localRhs[stack.localRow + numDof-1] += stack.localResidual[numDof-1]; + m_localMatrix.template addToRow< serialAtomic >( stack.localRow + numDof-1, + stack.dofIndices, + stack.localJacobian[numDof-1], + numDof ); + } + +protected: + + /// Views on derivatives wrt to temperature for phase volume fraction, density, and phase comp fraction + arrayView2d< real64 const, compflow::USD_PHASE > m_dPhaseVolFrac_dTemp; + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseDens_dTemp; + arrayView4d< real64 const, multifluid::USD_PHASE_COMP > m_dPhaseCompFrac_dTemp; + + /// Views on phase internal energy + arrayView2d< real64 const, compflow::USD_PHASE > m_phaseInternalEnergyOld; + arrayView3d< real64 const, multifluid::USD_PHASE > m_phaseInternalEnergy; + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseInternalEnergy_dPres; + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseInternalEnergy_dTemp; + arrayView4d< real64 const, multifluid::USD_PHASE_DC > m_dPhaseInternalEnergy_dComp; + + /// Views on rock internal energy + arrayView2d< real64 const > m_rockInternalEnergyOld; + arrayView2d< real64 const > m_rockInternalEnergy; + arrayView2d< real64 const > m_dRockInternalEnergy_dTemp; + + /// View on rock density + arrayView2d< real64 const > m_rockDensity; + +}; /** - * @brief Functions to assemble volume balance contributions to residual and Jacobian + * @class ElementBasedAssemblyKernelFactory */ -struct VolumeBalanceKernel +class ElementBasedAssemblyKernelFactory { - template< localIndex NC, localIndex NP > - GEOSX_HOST_DEVICE +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComps the number of fluid components + * @param[in] numPhases the number of fluid phases + * @param[in] rankOffset the offset of my MPI rank + * @param[in] dofKey the string key to retrieve the degress of freedom numbers + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] solid the solid model + * @param[inout] localMatrix the local CRS matrix + * @param[inout] localRhs the local right-hand side vector + */ + template< typename POLICY > static void - compute( real64 const & volume, - real64 const & porosityNew, - real64 const & dPoro_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dCompDens, - real64 & localVolBalance, - real64 ( &localVolBalanceJacobian )[NC+2] ); + createAndLaunch( localIndex const numComps, + localIndex const numPhases, + globalIndex const rankOffset, + string const dofKey, + ElementSubRegionBase const & subRegion, + MultiFluidBase const & fluid, + CoupledSolidBase const & solid, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComps, [&] ( auto NC ) + { + localIndex constexpr NUM_COMP = NC(); + localIndex constexpr NUM_DOF = NC()+2; + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > + kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template + launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > >( subRegion.size(), kernel ); + } ); + } - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - globalIndex const rankOffset, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & elemGhostRank, - arrayView1d< real64 const > const & volume, - arrayView2d< real64 const > const & porosityNew, - arrayView2d< real64 const > const & dPoro_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ); }; /******************************** FluidUpdateKernel ********************************/ From f5e969a518f0481dc5dc326bf50df650968711f2 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 22 Dec 2021 18:49:57 -0800 Subject: [PATCH 21/34] Merge branch 'develop' into feature/addEnergyBalance --- .travis.yml | 52 +- host-configs/Stanford/sherlock-base.cmake | 51 ++ .../sherlock-gcc10-cuda11-ampere.cmake | 13 + .../sherlock-gcc10-cuda11-volta.cmake | 13 + host-configs/Stanford/sherlock-gcc10.cmake | 7 + .../Stanford/sherlock-gcc8-cuda10-volta.cmake | 13 + host-configs/Stanford/sherlock-modules.sh | 11 + .../co2_flux_3d.xml | 2 + ...ctMechanics_SingleFracCompression_base.xml | 7 +- ...tMechanics_SingleFracCompression_smoke.xml | 6 + .../ContactMechanics_TFrac_base.xml | 13 +- .../ContactMechanics_TFrac_smoke.xml | 8 +- .../Sneddon_contactMechanics_smoke.xml | 11 +- inputFiles/proppant/ProppantSlotTest_base.xml | 67 +-- .../proppant/ProppantSlotTest_benchmark.xml | 66 ++ .../proppant/ProppantSlotTest_smoke.xml | 71 +++ .../solidMechanics/KirschProblem_base.xml | 3 + .../solidMechanics/KirschProblem_smoke.xml | 6 + .../wellbore/CasedElasticWellbore_base.xml | 24 +- .../CasedElasticWellbore_benchmark.xml | 24 + .../wellbore/CasedElasticWellbore_smoke.xml | 26 +- .../wellbore/DeviatedElasticWellbore_base.xml | 32 +- .../DeviatedElasticWellbore_benchmark.xml | 24 + .../DeviatedElasticWellbore_smoke.xml | 24 + ...iatedPoroElasticWellbore_Drilling_base.xml | 66 +- ...PoroElasticWellbore_Drilling_benchmark.xml | 60 ++ ...atedPoroElasticWellbore_Drilling_smoke.xml | 62 ++ ...atedPoroElasticWellbore_Injection_base.xml | 66 +- ...oroElasticWellbore_Injection_benchmark.xml | 60 ++ ...tedPoroElasticWellbore_Injection_smoke.xml | 60 ++ scripts/travis_build_and_test.sh | 20 +- .../constitutive/CMakeLists.txt | 17 +- .../constitutive/ConstitutiveBase.hpp | 45 ++ .../CapillaryPressureBase.cpp | 8 +- .../CapillaryPressureBase.hpp | 3 - .../CapillaryPressureExtrinsicData.hpp | 59 ++ .../constitutive/docs/BlackOilFluid.rst | 2 +- .../docs/CompositionalMultiphaseFluid.rst | 2 +- .../constitutive/docs/FluidModels.rst | 3 + .../constitutive/docs/PVTDriver.rst | 151 +++++ .../constitutive/docs/TriaxialDriver.rst | 199 ------- .../constitutive/docs/TriaxialDriver.svg | 396 ------------ .../docs/solid/TriaxialDriver.rst | 5 +- .../constitutive/fluid/MultiFluidBase.cpp | 117 ++-- .../constitutive/fluid/MultiFluidBase.hpp | 49 +- .../fluid/MultiFluidExtrinsicData.hpp | 312 ++++++++++ .../constitutive/fluid/PVTDriver.cpp | 333 +++++++++++ .../constitutive/fluid/PVTDriver.hpp | 117 ++++ .../fluid/PVTFunctions/BrineEnthalpy.cpp | 224 +++++++ .../fluid/PVTFunctions/BrineEnthalpy.hpp | 234 ++++++++ .../PVTFunctions/BrineInternalEnergy.cpp | 44 ++ .../PVTFunctions/BrineInternalEnergy.hpp | 160 +++++ .../fluid/PVTFunctions/CO2Enthalpy.cpp | 297 +++++++++ .../fluid/PVTFunctions/CO2Enthalpy.hpp | 192 ++++++ .../fluid/PVTFunctions/CO2InternalEnergy.cpp} | 25 +- .../fluid/PVTFunctions/CO2InternalEnergy.hpp | 160 +++++ .../fluid/PVTFunctions/PVTFunctionBase.hpp | 2 +- .../fluid/PVTFunctions/PVTFunctionHelpers.hpp | 3 + .../RelativePermeabilityBase.cpp | 8 +- .../RelativePermeabilityBase.hpp | 4 +- .../RelativePermeabilityExtrinsicData.hpp | 59 ++ .../FieldSpecificationBase.cpp | 1 + .../docs/FieldSpecification.rst | 4 +- .../mesh/ElementRegionManager.hpp | 32 + src/coreComponents/mesh/ExtrinsicMeshData.hpp | 5 +- src/coreComponents/mesh/ObjectManagerBase.hpp | 28 +- .../mesh/generators/PAMELAMeshGenerator.cpp | 28 +- .../physicsSolvers/CMakeLists.txt | 11 +- .../fluidFlow/CompositionalMultiphaseBase.cpp | 551 +++++++---------- .../fluidFlow/CompositionalMultiphaseBase.hpp | 77 +-- ...mpositionalMultiphaseBaseExtrinsicData.hpp | 257 ++++++++ .../fluidFlow/CompositionalMultiphaseFVM.cpp | 172 ++---- .../fluidFlow/CompositionalMultiphaseFVM.hpp | 2 +- .../CompositionalMultiphaseHybridFVM.cpp | 126 ++-- .../CompositionalMultiphaseHybridFVM.hpp | 9 +- ...ompositionalMultiphaseHybridFVMKernels.cpp | 324 ++-------- ...ompositionalMultiphaseHybridFVMKernels.hpp | 286 ++++++--- .../fluidFlow/FlowSolverBase.cpp | 54 +- .../fluidFlow/FlowSolverBase.hpp | 9 - .../fluidFlow/FlowSolverBaseExtrinsicData.hpp | 121 ++++ ...rmalCompositionalMultiphaseBaseKernels.cpp | 318 ---------- ...rmalCompositionalMultiphaseBaseKernels.hpp | 563 +++++++++++++----- ...ermalCompositionalMultiphaseFVMKernels.cpp | 321 ++-------- ...ermalCompositionalMultiphaseFVMKernels.hpp | 305 +++++++--- .../fluidFlow/SinglePhaseBase.cpp | 160 ++--- .../fluidFlow/SinglePhaseBase.hpp | 19 +- .../SinglePhaseBaseExtrinsicData.hpp | 65 ++ .../fluidFlow/SinglePhaseFVM.cpp | 63 +- .../fluidFlow/SinglePhaseHybridFVM.cpp | 99 ++- .../fluidFlow/SinglePhaseHybridFVMKernels.hpp | 8 +- .../fluidFlow/SinglePhaseProppantBase.cpp | 16 +- .../fluidFlow/SinglePhaseProppantBase.hpp | 2 +- ...rmalCompositionalMultiphaseBaseKernels.hpp | 5 +- .../proppantTransport/ProppantTransport.cpp | 17 +- .../wells/CompositionalMultiphaseWell.cpp | 306 +++------- .../wells/CompositionalMultiphaseWell.hpp | 27 +- .../CompositionalMultiphaseWellKernels.cpp | 97 --- .../CompositionalMultiphaseWellKernels.hpp | 176 +++++- .../fluidFlow/wells/SinglePhaseWell.cpp | 50 +- .../fluidFlow/wells/SinglePhaseWell.hpp | 7 +- .../fluidFlow/wells/WellSolverBase.cpp | 4 +- .../fluidFlow/wells/WellSolverBase.hpp | 4 +- .../multiphysics/HydrofractureSolver.cpp | 19 +- .../MultiphasePoromechanicsKernel.hpp | 41 +- .../SinglePhasePoromechanicsEFEMKernel.hpp | 12 +- .../SinglePhasePoromechanicsKernel.hpp | 13 +- .../SinglePhasePoromechanicsSolver.cpp | 7 +- ...sePoromechanicsSolverEmbeddedFractures.cpp | 19 +- src/coreComponents/schema/docs/Aquifer.rst | 1 + .../schema/docs/BlackOilFluid_other.rst | 88 +-- ...ksCoreyBakerRelativePermeability_other.rst | 4 +- .../BrooksCoreyCapillaryPressure_other.rst | 4 +- .../BrooksCoreyRelativePermeability_other.rst | 4 +- .../docs/CO2BrineEzrokhiFluid_other.rst | 76 +-- .../docs/CO2BrinePhillipsFluid_other.rst | 76 +-- .../docs/CompositionalMultiphaseFVM_other.rst | 17 +- .../CompositionalMultiphaseFluid_other.rst | 76 +-- ...CompositionalMultiphaseHybridFVM_other.rst | 19 +- .../schema/docs/DeadOilFluid_other.rst | 86 +-- src/coreComponents/schema/docs/Dirichlet.rst | 1 + .../schema/docs/FaceManager_other.rst | 74 +-- .../schema/docs/FieldSpecification.rst | 1 + .../schema/docs/HydrostaticEquilibrium.rst | 1 + src/coreComponents/schema/docs/PVTDriver.rst | 17 + .../schema/docs/PVTDriver_other.rst | 9 + .../schema/docs/ProppantTransport_other.rst | 15 +- .../schema/docs/SinglePhaseFVM_other.rst | 17 +- .../docs/SinglePhaseHybridFVM_other.rst | 18 +- .../docs/SinglePhaseProppantFVM_other.rst | 17 +- src/coreComponents/schema/docs/SourceFlux.rst | 1 + .../docs/TableCapillaryPressure_other.rst | 18 +- .../docs/TableRelativePermeability_other.rst | 20 +- src/coreComponents/schema/docs/Tasks.rst | 1 + .../schema/docs/Tasks_other.rst | 1 + src/coreComponents/schema/docs/Traction.rst | 1 + ...nuchtenBakerRelativePermeability_other.rst | 4 +- .../VanGenuchtenCapillaryPressure_other.rst | 4 +- src/coreComponents/schema/schema.xsd | 33 + src/coreComponents/schema/schema.xsd.other | 368 ++++++------ .../constitutiveTests/CMakeLists.txt | 22 +- .../testCO2BrinePVTModels.cpp | 413 ++++++++++++- .../constitutiveTests/testMultiFluid.cpp | 55 +- .../unitTests/constitutiveTests/testPVT.cpp | 47 ++ .../unitTests/constitutiveTests/testPVT.xml | 97 +++ .../constitutiveTests/testPVT_CO2.txt | 57 ++ .../constitutiveTests/testPVT_brine.txt | 57 ++ .../testPVT_data/brinePVT.txt | 2 + .../testPVT_data/carbonDioxideFlash.txt | 1 + .../testPVT_data/carbonDioxidePVT.txt | 2 + .../constitutiveTests/testPVT_data/gasPVT.txt | 14 + .../constitutiveTests/testPVT_data/oilPVT.txt | 8 + .../testPVT_data/referencePVT_CO2.txt | 54 ++ .../testPVT_data/referencePVT_H2_CH4.txt | 22 + .../testPVT_data/referencePVT_brine.txt | 9 + .../constitutiveTests/testPVT_docExample.xml | 68 +++ .../testPVT_hydrogenMixtureA.txt | 57 ++ .../testPVT_hydrogenMixtureB.txt | 57 ++ .../fluidFlowTests/testCompMultiphaseFlow.cpp | 46 +- .../testCompMultiphaseFlowHybrid.cpp | 14 +- ...eservoirCompositionalMultiphaseMSWells.cpp | 13 +- .../testReservoirSinglePhaseMSWells.cpp | 9 +- src/docs/sphinx/CompleteXMLSchema.rst | 14 + .../casedElasticWellbore/Example.rst | 2 +- .../deviatedElasticWellbore/Example.rst | 2 +- .../deviatedPoroElasticWellbore/Example.rst | 6 +- .../intersectFrac/Example.rst | 12 +- .../displacementJump_history.hdf5 | Bin 204264 -> 204264 bytes .../proppantSlotTest/Example.rst | 6 +- .../singleFracCompression/Example.rst | 20 +- .../displacementJump_history.hdf5 | Bin 91864 -> 91864 bytes .../traction_history.hdf5 | Bin 91864 -> 91864 bytes .../validationStudies/sneddon/Example.rst | 4 +- .../displacementJump_contactMechanics.hdf5 | Bin 28680 -> 28680 bytes .../basicExamples/multiphaseFlow/Example.rst | 2 +- .../Dockerfile-remote-dev.example | 92 +-- 175 files changed, 7313 insertions(+), 4081 deletions(-) create mode 100644 host-configs/Stanford/sherlock-base.cmake create mode 100644 host-configs/Stanford/sherlock-gcc10-cuda11-ampere.cmake create mode 100644 host-configs/Stanford/sherlock-gcc10-cuda11-volta.cmake create mode 100644 host-configs/Stanford/sherlock-gcc10.cmake create mode 100644 host-configs/Stanford/sherlock-gcc8-cuda10-volta.cmake create mode 100755 host-configs/Stanford/sherlock-modules.sh create mode 100644 src/coreComponents/constitutive/capillaryPressure/CapillaryPressureExtrinsicData.hpp create mode 100644 src/coreComponents/constitutive/docs/PVTDriver.rst delete mode 100644 src/coreComponents/constitutive/docs/TriaxialDriver.rst delete mode 100644 src/coreComponents/constitutive/docs/TriaxialDriver.svg create mode 100644 src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTDriver.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTDriver.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.cpp create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp rename src/coreComponents/{physicsSolvers/fluidFlow/SinglePhaseBaseKernels.cpp => constitutive/fluid/PVTFunctions/CO2InternalEnergy.cpp} (57%) create mode 100644 src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp create mode 100644 src/coreComponents/constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp create mode 100644 src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp create mode 100644 src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp delete mode 100644 src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.cpp create mode 100644 src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp create mode 100644 src/coreComponents/schema/docs/PVTDriver.rst create mode 100644 src/coreComponents/schema/docs/PVTDriver_other.rst create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT.cpp create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT.xml create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_CO2.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_brine.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/brinePVT.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxideFlash.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxidePVT.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/gasPVT.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/oilPVT.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_CO2.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_H2_CH4.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_brine.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_docExample.xml create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureA.txt create mode 100644 src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureB.txt diff --git a/.travis.yml b/.travis.yml index a0ce7b94761..ce75eea3546 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: minimal env: global: - - GEOSX_TPL_TAG=168-693 + - GEOSX_TPL_TAG=169-704 - secure: CGs2uH6efq1Me6xJWRr0BnwtwxoujzlowC4FHXHdWbNOkPsXf7nCgdaW5vthfD3bhnOeEUQSrfxdhTRtyU/NfcKLmKgGBnZOdUG4/JJK4gDSJ2Wp8LZ/mB0QEoODKVxbh+YtoAiHe3y4M9PGCs+wkNDw/3eEU00cK12DZ6gad0RbLjI3xkhEr/ZEZDZkcYg9yHAhl5bmpqoh/6QGnIg8mxIqdAtGDw+6tT0EgUqjeqc5bG5WwsamKzJItHSXD5zx8IJAlgDk4EzEGjZe0m56YnNfb9iwqqUsmL3Cuwgs7ByVDYw78JC5Kv42YqoxA5BxMT2mFsEe37TpYNXlzofU7ma2Duw9DGXWQd4IkTCcBxlyR0I0bfo0TmgO+y7PYG9lIyHPUkENemdozsZcWamqqkqegiEdRhDVYlSRo3mu7iCwTS6ZTALliVyEYjYxYb7oAnR3cNywXjblTCI8oKfgLSY+8WijM9SRl57JruIHLkLMCjmRI+cZBfv5tS2tYQTBPkygGrigrrN77ZiC7/TGyfggSN0+y0oYtOAgqEnBcKcreiibMW7tKcV2Z1RFD9ZvIkSc1EXLUPDP8FX1oyhmqBMqVo8LksrYLDJHQ05+F3YNgl2taSt7uMjQ4e8iZ3/IjFeMnbylDw+cj/RbS520HXsFPbWFm2Pb9pceA9n6GnY= # The integrated test repository contains large data (using git lfs) and we do not use them here. @@ -98,7 +98,7 @@ geosx_totalenergies_cluster_build: &geosx_totalenergies_cluster_build - docker cp -a ${CONTAINER_NAME}:${GEOSX_TPL_DIR}/.. ${TMP_DIR}/${GEOSX_EXPORT_DIR} # ... and packing it. - GEOSX_BUNDLE=${TMP_DIR}/${GEOSX_EXPORT_DIR}.tar.gz - - tar cvzf ${GEOSX_BUNDLE} --directory=${TMP_DIR} ${GEOSX_EXPORT_DIR} + - tar czf ${GEOSX_BUNDLE} --directory=${TMP_DIR} ${GEOSX_EXPORT_DIR} # Uploading to GCP/GCS using gcloud CLI - GEOSX_GCLOUD_KEY=/tmp/geosx-key.json - openssl aes-256-cbc -K $encrypted_5ac030ea614b_key -iv $encrypted_5ac030ea614b_iv @@ -112,7 +112,7 @@ draft_script: &draft_script - if [[ $TRAVIS_PULL_REQUEST == false ]]; then exit 0; fi; - | is_draft=$(curl -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$TRAVIS_PULL_REQUEST_SLUG/pulls/$TRAVIS_PULL_REQUEST | \ + https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST | \ jq ".draft") # CI jobs will be cancelled if PR is a draft. @@ -135,7 +135,7 @@ assigned_script: &assigned_script - if [[ $TRAVIS_PULL_REQUEST == false ]]; then exit 0; fi; - | is_assigned=$(curl -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$TRAVIS_PULL_REQUEST_SLUG/pulls/$TRAVIS_PULL_REQUEST | \ + https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST | \ jq ".assignees|length") - if [[ $is_assigned == 0 ]]; then exit 1; else exit 0; fi @@ -170,14 +170,14 @@ jobs: name: code_style <<: *geosx_linux_build env: - - DOCKER_REPOSITORY=geosx/ubuntu18.04-gcc8 + - DOCKER_REPOSITORY=geosx/ubuntu20.04-gcc9 - CMAKE_BUILD_TYPE=Release - BUILD_AND_TEST_ARGS=--test-code-style - stage: checks name: documentation <<: *geosx_linux_build env: - - DOCKER_REPOSITORY=geosx/ubuntu18.04-gcc8 + - DOCKER_REPOSITORY=geosx/ubuntu20.04-gcc9 - CMAKE_BUILD_TYPE=Release - BUILD_AND_TEST_ARGS=--test-documentation - stage: checks @@ -187,22 +187,18 @@ jobs: name: check_pr_is_assigned <<: *assigned_script - stage: builds - name: Ubuntu18.04_clang8.0.0_cuda10.1.243_debug + name: Ubuntu CUDA debug (18.04, clang 8.0.0 + gcc 8.3.1, open-mpi 2.1.1, cuda-10.1.243) <<: *geosx_linux_build # Builds only the geosx executable (timeout when building tests) env: - DOCKER_REPOSITORY=geosx/ubuntu18.04-clang8.0.0-cuda10.1.243 - CMAKE_BUILD_TYPE=Debug - BUILD_AND_TEST_ARGS="--disable-unit-tests --build-exe-only" + - ENABLE_HYPRE=ON + - ENABLE_HYPRE_CUDA=ON + - ENABLE_TRILINOS=OFF - stage: builds - name: Ubuntu18.04_clang8.0.0_cuda10.1.243_release - <<: *geosx_linux_build - env: - - DOCKER_REPOSITORY=geosx/ubuntu18.04-clang8.0.0-cuda10.1.243 - - CMAKE_BUILD_TYPE=Release - - BUILD_AND_TEST_ARGS=--disable-unit-tests - - stage: builds - name: Ubuntu18.04_clang8.0.0_cuda10.1.243_release_hypreGPU + name: Ubuntu CUDA (18.04, clang 8.0.0 + gcc 8.3.1, open-mpi 2.1.1, cuda-10.1.243) <<: *geosx_linux_build env: - DOCKER_REPOSITORY=geosx/ubuntu18.04-clang8.0.0-cuda10.1.243 @@ -212,14 +208,14 @@ jobs: - ENABLE_HYPRE_CUDA=ON - ENABLE_TRILINOS=OFF - stage: builds - name: Centos7.6_gcc8.3.1_cuda10.1.243_release + name: Centos (7.6, gcc 8.3.1, open-mpi 1.10.7, cuda 10.1.243) <<: *geosx_linux_build env: - DOCKER_REPOSITORY=geosx/centos7.6.1810-gcc8.3.1-cuda10.1.243 - CMAKE_BUILD_TYPE=Release - BUILD_AND_TEST_ARGS=--disable-unit-tests - stage: builds - name: Pecan GPU + name: Pecan GPU (centos 7.7, gcc 8.2.0, open-mpi 4.0.1, mkl 2019.5, cuda 10.2.89p2) <<: *geosx_totalenergies_cluster_build env: - DOCKER_REPOSITORY=geosx/pecan-gpu-gcc8.2.0-openmpi4.0.1-mkl2019.5-cuda10.2.89p2 @@ -228,16 +224,15 @@ jobs: - HOST_CONFIG=host-configs/TOTAL/pecan-GPU.cmake - GCP_BUCKET=geosx/Pecan-GPU - stage: builds - name: Pecan CPU + name: Pecan CPU (centos 7.7, gcc 8.2.0, open-mpi 4.0.1, mkl 2019.5) <<: *geosx_totalenergies_cluster_build env: - DOCKER_REPOSITORY=geosx/pecan-cpu-gcc8.2.0-openmpi4.0.1-mkl2019.5 - CMAKE_BUILD_TYPE=Release - - BUILD_AND_TEST_ARGS=--disable-unit-tests - HOST_CONFIG=host-configs/TOTAL/pecan-CPU.cmake - GCP_BUCKET=geosx/Pecan-CPU - stage: builds - name: Pangea 2 + name: Pangea 2 (centos 7.6, gcc 8.3.0, open-mpi 2.1.5, mkl 2019.3) <<: *geosx_totalenergies_cluster_build env: - DOCKER_REPOSITORY=geosx/pangea2-gcc8.3.0-openmpi2.1.5-mkl2019.3 @@ -249,22 +244,29 @@ jobs: name: Mac_OSX <<: *geosx_osx_build - stage: builds - name: Centos7.7_clang9.0.0_release + name: Centos (7.7, clang 9.0.0 + gcc 4.9.3, open-mpi 1.10.7) <<: *geosx_linux_build env: - DOCKER_REPOSITORY=geosx/centos7.7.1908-clang9.0.0 - CMAKE_BUILD_TYPE=Release - stage: builds - name: Ubuntu18.04_gcc8_release + name: Ubuntu (20.04, gcc 9.3.0, open-mpi 4.0.3) <<: *geosx_linux_build env: - - DOCKER_REPOSITORY=geosx/ubuntu18.04-gcc8 + - DOCKER_REPOSITORY=geosx/ubuntu20.04-gcc9 - CMAKE_BUILD_TYPE=Release + - BUILD_AND_TEST_ARGS=--disable-unit-tests - stage: builds - name: Ubuntu18.04_gcc8_debug + name: Ubuntu debug (20.04, gcc 10.3.0, open-mpi 4.0.3) <<: *geosx_linux_build env: - - DOCKER_REPOSITORY=geosx/ubuntu18.04-gcc8 + - DOCKER_REPOSITORY=geosx/ubuntu20.04-gcc10 - CMAKE_BUILD_TYPE=Debug + - stage: builds + name: Ubuntu (20.04, gcc 10.3.0, open-mpi 4.0.3) + <<: *geosx_linux_build + env: + - DOCKER_REPOSITORY=geosx/ubuntu20.04-gcc10 + - CMAKE_BUILD_TYPE=Release - stage: return_status <<: *return_script diff --git a/host-configs/Stanford/sherlock-base.cmake b/host-configs/Stanford/sherlock-base.cmake new file mode 100644 index 00000000000..39a71798a46 --- /dev/null +++ b/host-configs/Stanford/sherlock-base.cmake @@ -0,0 +1,51 @@ +site_name(HOST_NAME) + +# Compilers +set(CMAKE_C_COMPILER "${GCC_ROOT}/bin/gcc" CACHE PATH "") +set(CMAKE_CXX_COMPILER "${GCC_ROOT}/bin/g++" CACHE PATH "") +set(CMAKE_Fortran_COMPILER "${GCC_ROOT}/bin/gfortran" CACHE PATH "") + +# OpenMP options +set(ENABLE_OPENMP ON CACHE BOOL "") + +# MPI options +set(ENABLE_MPI ON CACHE PATH "" FORCE) +set(MPI_C_COMPILER "${MPI_ROOT}/bin/mpicc" CACHE PATH "") +set(MPI_CXX_COMPILER "${MPI_ROOT}/bin/mpic++" CACHE PATH "") +set(MPI_Fortran_COMPILER "${MPI_ROOT}/bin/mpifort" CACHE PATH "") +set(MPIEXEC "${MPI_ROOT}/bin/mpirun" CACHE PATH "") +set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "") +set(ENABLE_WRAP_ALL_TESTS_WITH_MPIEXEC ON CACHE BOOL "") + +# CUDA options +if(ENABLE_CUDA) + set(CMAKE_CUDA_HOST_COMPILER ${MPI_CXX_COMPILER} CACHE STRING "") + set(CMAKE_CUDA_COMPILER ${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc CACHE STRING "") + set(CMAKE_CUDA_STANDARD 14 CACHE STRING "") + set(CMAKE_CUDA_FLAGS "-restrict -arch ${CUDA_ARCH} --expt-extended-lambda --expt-relaxed-constexpr -Werror cross-execution-space-call,reorder,deprecated-declarations" CACHE STRING "") + set(CMAKE_CUDA_FLAGS_RELEASE "-O3 -DNDEBUG -Xcompiler -DNDEBUG -Xcompiler -O3" CACHE STRING "") + set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-g -lineinfo ${CMAKE_CUDA_FLAGS_RELEASE}" CACHE STRING "") + set(CMAKE_CUDA_FLAGS_DEBUG "-g -G -O0 -Xcompiler -O0" CACHE STRING "") +endif() + +# Blas/Lapack options +set(BLAS_LIBRARIES "/share/software/user/open/openblas/0.3.10/lib/libblas.so" CACHE STRING "") +set(LAPACK_LIBRARIES "/share/software/user/open/openblas/0.3.10/lib/liblapack.so" CACHE STRING "") + +# Python options +#set(ENABLE_PYLVARRAY ON CACHE BOOL "") +#set(ENABLE_PYGEOSX ON CACHE BOOL "") +#set(PYTHON_DIR "/share/software/user/open/python/3.6.1" CACHE PATH "") +#set(Python3_EXECUTABLE "/share/software/user/open/python/3.6.1/bin/python3" CACHE PATH "") + +set(ENABLE_VALGRIND OFF CACHE BOOL "") +set(ENABLE_CALIPER ON CACHE BOOL "") + +if(ENABLE_HYPRE_CUDA) + set(ENABLE_PETSC OFF CACHE BOOL "") + set(ENABLE_TRILINOS OFF CACHE BOOL "") + set(GEOSX_LA_INTERFACE "Hypre" CACHE STRING "") +endif() + +set(GEOSX_TPL_DIR /home/groups/tchelepi/geosx/thirdPartyLibs/install-${CONFIG_NAME}-release CACHE PATH "") +include(/home/groups/tchelepi/geosx/GEOSX/host-configs/tpls.cmake) diff --git a/host-configs/Stanford/sherlock-gcc10-cuda11-ampere.cmake b/host-configs/Stanford/sherlock-gcc10-cuda11-ampere.cmake new file mode 100644 index 00000000000..89734aefe7d --- /dev/null +++ b/host-configs/Stanford/sherlock-gcc10-cuda11-ampere.cmake @@ -0,0 +1,13 @@ +set(CONFIG_NAME "sherlock-gcc10-cuda11-ampere" CACHE PATH "") + +set(GCC_ROOT "/share/software/user/open/gcc/10.1.0" CACHE PATH "") +set(MPI_ROOT "/share/software/user/open/openmpi/4.1.0" CACHE PATH "") + +set(ENABLE_CUDA ON CACHE BOOL "" FORCE) +set(ENABLE_HYPRE_CUDA ON CACHE BOOL "" FORCE) +set(CUDA_ARCH "sm_80" CACHE STRING "") +set(CMAKE_CUDA_ARCHITECTURES "80" CACHE STRING "") +set(CUDA_TOOLKIT_ROOT_DIR "/share/software/user/open/cuda/11.2.0" CACHE STRING "") + +include(/home/groups/tchelepi/geosx/host-configs/sherlock-base.cmake) + diff --git a/host-configs/Stanford/sherlock-gcc10-cuda11-volta.cmake b/host-configs/Stanford/sherlock-gcc10-cuda11-volta.cmake new file mode 100644 index 00000000000..cff404f1d38 --- /dev/null +++ b/host-configs/Stanford/sherlock-gcc10-cuda11-volta.cmake @@ -0,0 +1,13 @@ +set(CONFIG_NAME "sherlock-gcc10-cuda11-volta" CACHE PATH "") + +set(GCC_ROOT "/share/software/user/open/gcc/10.1.0" CACHE PATH "") +set(MPI_ROOT "/share/software/user/open/openmpi/4.1.0" CACHE PATH "") + +set(ENABLE_CUDA ON CACHE BOOL "" FORCE) +set(ENABLE_HYPRE_CUDA ON CACHE BOOL "" FORCE) +set(CUDA_ARCH "sm_70" CACHE STRING "") +set(CMAKE_CUDA_ARCHITECTURES "70" CACHE STRING "") +set(CUDA_TOOLKIT_ROOT_DIR "/share/software/user/open/cuda/11.2.0" CACHE STRING "") + +include(/home/groups/tchelepi/geosx/host-configs/sherlock-base.cmake) + diff --git a/host-configs/Stanford/sherlock-gcc10.cmake b/host-configs/Stanford/sherlock-gcc10.cmake new file mode 100644 index 00000000000..aa6308538b7 --- /dev/null +++ b/host-configs/Stanford/sherlock-gcc10.cmake @@ -0,0 +1,7 @@ +set(CONFIG_NAME "sherlock-gcc10" CACHE PATH "") + +set(GCC_ROOT "/share/software/user/open/gcc/10.1.0" CACHE PATH "") +set(MPI_ROOT "/share/software/user/open/openmpi/4.1.0" CACHE PATH "") + +include(/home/groups/tchelepi/geosx/host-configs/sherlock-base.cmake) + diff --git a/host-configs/Stanford/sherlock-gcc8-cuda10-volta.cmake b/host-configs/Stanford/sherlock-gcc8-cuda10-volta.cmake new file mode 100644 index 00000000000..663935bfd31 --- /dev/null +++ b/host-configs/Stanford/sherlock-gcc8-cuda10-volta.cmake @@ -0,0 +1,13 @@ +set(CONFIG_NAME "sherlock-gcc8-cuda10-volta" CACHE PATH "") + +set(GCC_ROOT "/share/software/user/open/gcc/8.1.0" CACHE PATH "") +set(MPI_ROOT "/share/software/user/open/openmpi/4.0.3" CACHE PATH "") + +set(ENABLE_CUDA ON CACHE BOOL "" FORCE) +set(ENABLE_HYPRE_CUDA ON CACHE BOOL "" FORCE) +set(CUDA_ARCH "sm_70" CACHE STRING "") +set(CMAKE_CUDA_ARCHITECTURES "70" CACHE STRING "") +set(CUDA_TOOLKIT_ROOT_DIR "/share/software/user/open/cuda/10.2.89" CACHE STRING "") + +include(/home/groups/tchelepi/geosx/host-configs/sherlock-base.cmake) + diff --git a/host-configs/Stanford/sherlock-modules.sh b/host-configs/Stanford/sherlock-modules.sh new file mode 100755 index 00000000000..3bdbe8257c5 --- /dev/null +++ b/host-configs/Stanford/sherlock-modules.sh @@ -0,0 +1,11 @@ +module load system +module load git/2.12.2 +module load git-lfs/2.4.0 +module load cmake/3.20.3 +module load ninja/1.9.0 +module load py-mpi4py/3.0.3_py36 +module load py-h5py/2.10.0_py36 +module load gcc/10.1.0 +module load openmpi/4.1.0 +module load cuda/11.2.0 +module load libevent/2.1.12 # needed for silo diff --git a/inputFiles/compositionalMultiphaseFlow/co2_flux_3d.xml b/inputFiles/compositionalMultiphaseFlow/co2_flux_3d.xml index 579636bc8a5..968a2f832f0 100644 --- a/inputFiles/compositionalMultiphaseFlow/co2_flux_3d.xml +++ b/inputFiles/compositionalMultiphaseFlow/co2_flux_3d.xml @@ -229,6 +229,7 @@ + fieldName="displacementJump"/> @@ -183,6 +183,9 @@ + filename="displacementJump_history" /> + + diff --git a/inputFiles/lagrangianContactMechanics/ContactMechanics_SingleFracCompression_smoke.xml b/inputFiles/lagrangianContactMechanics/ContactMechanics_SingleFracCompression_smoke.xml index dc96361ec6c..f3ba7003640 100644 --- a/inputFiles/lagrangianContactMechanics/ContactMechanics_SingleFracCompression_smoke.xml +++ b/inputFiles/lagrangianContactMechanics/ContactMechanics_SingleFracCompression_smoke.xml @@ -91,6 +91,12 @@ timeFrequency="1" targetExactTimestep="0" target="/Outputs/vtkOutput"/> + + + frictionCoefficient="0.577350269" + apertureTableName="apertureTable"/> @@ -200,7 +201,7 @@ + fieldName="displacementJump"/> @@ -210,6 +211,11 @@ inputVarNames="{ time }" coordinates="{ 0.0, 1.0 }" values="{ 0.0, 1.e0 }"/> + + @@ -227,5 +233,8 @@ name="displacementOutput" sources="{/Tasks/displacementJumpCollection}" filename="displacementJump_history" /> + + diff --git a/inputFiles/lagrangianContactMechanics/ContactMechanics_TFrac_smoke.xml b/inputFiles/lagrangianContactMechanics/ContactMechanics_TFrac_smoke.xml index 55119104cdc..0925b8be6f1 100644 --- a/inputFiles/lagrangianContactMechanics/ContactMechanics_TFrac_smoke.xml +++ b/inputFiles/lagrangianContactMechanics/ContactMechanics_TFrac_smoke.xml @@ -59,6 +59,12 @@ name="displacementHistoryOutput" timeFrequency="0.2" targetExactTimestep="0" - target="/Outputs/displacementOutput"/> + target="/Outputs/displacementOutput"/> + + diff --git a/inputFiles/lagrangianContactMechanics/Sneddon_contactMechanics_smoke.xml b/inputFiles/lagrangianContactMechanics/Sneddon_contactMechanics_smoke.xml index 475cfcdc00b..1379906fa9c 100755 --- a/inputFiles/lagrangianContactMechanics/Sneddon_contactMechanics_smoke.xml +++ b/inputFiles/lagrangianContactMechanics/Sneddon_contactMechanics_smoke.xml @@ -34,6 +34,11 @@ endTime="1.0" forceDt="1.0" target="/Solvers/lagrangiancontact"/> + + - - + diff --git a/inputFiles/proppant/ProppantSlotTest_base.xml b/inputFiles/proppant/ProppantSlotTest_base.xml index 9ebe8c6bf6e..55083bfa15d 100755 --- a/inputFiles/proppant/ProppantSlotTest_base.xml +++ b/inputFiles/proppant/ProppantSlotTest_base.xml @@ -1,71 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -290,6 +225,6 @@ name="siloOutput"/> + name="restartOutput"/> diff --git a/inputFiles/proppant/ProppantSlotTest_benchmark.xml b/inputFiles/proppant/ProppantSlotTest_benchmark.xml index 241d5cbd734..9671817df49 100755 --- a/inputFiles/proppant/ProppantSlotTest_benchmark.xml +++ b/inputFiles/proppant/ProppantSlotTest_benchmark.xml @@ -37,5 +37,71 @@ name="outputs" target="/Outputs/siloOutput"/> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/proppant/ProppantSlotTest_smoke.xml b/inputFiles/proppant/ProppantSlotTest_smoke.xml index cc0d78612ee..c0b29c3ce6a 100755 --- a/inputFiles/proppant/ProppantSlotTest_smoke.xml +++ b/inputFiles/proppant/ProppantSlotTest_smoke.xml @@ -36,6 +36,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/solidMechanics/KirschProblem_base.xml b/inputFiles/solidMechanics/KirschProblem_base.xml index 316c5019819..3b6db03e093 100755 --- a/inputFiles/solidMechanics/KirschProblem_base.xml +++ b/inputFiles/solidMechanics/KirschProblem_base.xml @@ -127,6 +127,9 @@ name="displacementOutput" sources="{/Tasks/displacementCollection}" filename="displacement_history" /> + + diff --git a/inputFiles/solidMechanics/KirschProblem_smoke.xml b/inputFiles/solidMechanics/KirschProblem_smoke.xml index aa480e86861..70b0138878e 100755 --- a/inputFiles/solidMechanics/KirschProblem_smoke.xml +++ b/inputFiles/solidMechanics/KirschProblem_smoke.xml @@ -44,6 +44,12 @@ name="outputs1" target="/Outputs/siloOutput" /> + + - - - - - - - - - - @@ -46,7 +24,7 @@ diff --git a/inputFiles/wellbore/CasedElasticWellbore_benchmark.xml b/inputFiles/wellbore/CasedElasticWellbore_benchmark.xml index cf99ddf5e2a..388348882cc 100644 --- a/inputFiles/wellbore/CasedElasticWellbore_benchmark.xml +++ b/inputFiles/wellbore/CasedElasticWellbore_benchmark.xml @@ -24,4 +24,28 @@ /> + + + + + + + + + + + + diff --git a/inputFiles/wellbore/CasedElasticWellbore_smoke.xml b/inputFiles/wellbore/CasedElasticWellbore_smoke.xml index a3ea9f42f16..c59c285bcc9 100644 --- a/inputFiles/wellbore/CasedElasticWellbore_smoke.xml +++ b/inputFiles/wellbore/CasedElasticWellbore_smoke.xml @@ -14,7 +14,7 @@ theta="{ 0, 360 }" zCoords="{ 0, 1 }" nr="{ 1, 1, 3 }" - nt="{ 3 }" + nt="{ 32 }" nz="{ 1 }" trajectory="{ { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0 } }" @@ -24,4 +24,28 @@ /> + + + + + + + + + + + + diff --git a/inputFiles/wellbore/DeviatedElasticWellbore_base.xml b/inputFiles/wellbore/DeviatedElasticWellbore_base.xml index fffe668574b..78b3f753e0e 100644 --- a/inputFiles/wellbore/DeviatedElasticWellbore_base.xml +++ b/inputFiles/wellbore/DeviatedElasticWellbore_base.xml @@ -1,28 +1,6 @@ - - - - - - - - - - @@ -44,11 +22,11 @@ targetExactTimestep="1" target="/Outputs/siloOutput"/> - + target="/Outputs/restartOutput"/> @@ -133,7 +111,7 @@ plotFileRoot="plot" childDirectory="sub"/> - + diff --git a/inputFiles/wellbore/DeviatedElasticWellbore_benchmark.xml b/inputFiles/wellbore/DeviatedElasticWellbore_benchmark.xml index 23ae9b603f4..95b86816903 100644 --- a/inputFiles/wellbore/DeviatedElasticWellbore_benchmark.xml +++ b/inputFiles/wellbore/DeviatedElasticWellbore_benchmark.xml @@ -23,4 +23,28 @@ cellBlockNames="{ cb1 }"/> + + + + + + + + + + + + diff --git a/inputFiles/wellbore/DeviatedElasticWellbore_smoke.xml b/inputFiles/wellbore/DeviatedElasticWellbore_smoke.xml index 9b5d8238b99..65c883f8e88 100644 --- a/inputFiles/wellbore/DeviatedElasticWellbore_smoke.xml +++ b/inputFiles/wellbore/DeviatedElasticWellbore_smoke.xml @@ -23,4 +23,28 @@ cellBlockNames="{ cb1 }"/> + + + + + + + + + + + + diff --git a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_base.xml b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_base.xml index cf3cbd80572..9d888823fa0 100644 --- a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_base.xml +++ b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_base.xml @@ -1,65 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + - + target="/Outputs/restartOutput"/> diff --git a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_benchmark.xml b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_benchmark.xml index a5f36a6bffd..1a1412d6521 100644 --- a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_benchmark.xml +++ b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_benchmark.xml @@ -23,4 +23,64 @@ cellBlockNames="{ cb1 }"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_smoke.xml b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_smoke.xml index 040f5cfc5f7..3ed99166c29 100644 --- a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_smoke.xml +++ b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Drilling_smoke.xml @@ -23,4 +23,66 @@ cellBlockNames="{ cb1 }"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml index 7de3177cdc8..62ea1c51087 100644 --- a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml +++ b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml @@ -1,65 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -74,11 +16,11 @@ timeFrequency="7.8" target="/Outputs/siloOutput"/> - + target="/Outputs/restartOutput"/> diff --git a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml index f4b35b6db0f..0fc4c28e877 100644 --- a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml +++ b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml @@ -23,4 +23,64 @@ cellBlockNames="{ cb1 }"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_smoke.xml b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_smoke.xml index 0101745c625..0da3f657045 100644 --- a/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_smoke.xml +++ b/inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_smoke.xml @@ -23,4 +23,64 @@ cellBlockNames="{ cb1 }"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/travis_build_and_test.sh b/scripts/travis_build_and_test.sh index fae61cd4c68..b014a6c84a1 100755 --- a/scripts/travis_build_and_test.sh +++ b/scripts/travis_build_and_test.sh @@ -31,18 +31,26 @@ if [[ -z "${GEOSX_DIR}" ]]; then exit 1 fi -# The -DBLT_MPI_COMMAND_APPEND:STRING=--allow-run-as-root option is added for openmpi -# which prevents from running as root user by default. -# And by default, you are root in a docker container. -# Using this option therefore offers a minimal and convenient way -# to run the unit tests. +# The -DBLT_MPI_COMMAND_APPEND="--allow-run-as-root;--oversubscribe" option is added for OpenMPI. +# +# OpenMPI prevents from running as `root` user by default. +# And by default user is `root` in a docker container. +# Using this option therefore offers a minimal and convenient way to run the unit tests. +# +# The option `--oversubscribe` tells OpenMPI to allow more MPI ranks than the node has cores. +# This is needed because our unit test `blt_mpi_smoke` is run in parallel with _hard coded_ 4 ranks. +# While our travis-ci nodes only have 2. +# +# In case we have more powerful nodes, consider removing `--oversubscribe` and use `--use-hwthread-cpus` instead. +# This will tells OpenMPI to discover the number of hardware threads on the node, +# and use that as the number of slots available. (There is a distinction between threads and cores). GEOSX_BUILD_DIR=/tmp/build or_die python scripts/config-build.py \ -hc ${HOST_CONFIG} \ -bt ${CMAKE_BUILD_TYPE} \ -bp ${GEOSX_BUILD_DIR} \ -ip ${GEOSX_DIR} \ - -DBLT_MPI_COMMAND_APPEND:STRING=--allow-run-as-root + -DBLT_MPI_COMMAND_APPEND='"--allow-run-as-root;--oversubscribe"' or_die cd ${GEOSX_BUILD_DIR} diff --git a/src/coreComponents/constitutive/CMakeLists.txt b/src/coreComponents/constitutive/CMakeLists.txt index 4d195ae5f4a..622ff551a03 100644 --- a/src/coreComponents/constitutive/CMakeLists.txt +++ b/src/coreComponents/constitutive/CMakeLists.txt @@ -10,6 +10,7 @@ set( constitutive_headers NullModel.hpp capillaryPressure/BrooksCoreyCapillaryPressure.hpp capillaryPressure/CapillaryPressureBase.hpp + capillaryPressure/CapillaryPressureExtrinsicData.hpp capillaryPressure/TableCapillaryPressure.hpp capillaryPressure/VanGenuchtenCapillaryPressure.hpp capillaryPressure/capillaryPressureSelector.hpp @@ -24,7 +25,9 @@ set( constitutive_headers fluid/DeadOilFluid.hpp fluid/MultiFluidBase.hpp fluid/MultiFluidUtils.hpp + fluid/MultiFluidExtrinsicData.hpp fluid/MultiPhaseMultiComponentFluid.hpp + fluid/PVTDriver.hpp fluid/PVTOData.hpp fluid/PVTFunctions/PhillipsBrineDensity.hpp fluid/PVTFunctions/PhillipsBrineViscosity.hpp @@ -36,6 +39,10 @@ set( constitutive_headers fluid/PVTFunctions/PVTFunctionBase.hpp fluid/PVTFunctions/PVTFunctionHelpers.hpp fluid/PVTFunctions/SpanWagnerCO2Density.hpp + fluid/PVTFunctions/BrineEnthalpy.hpp + fluid/PVTFunctions/CO2Enthalpy.hpp + fluid/PVTFunctions/BrineInternalEnergy.hpp + fluid/PVTFunctions/CO2InternalEnergy.hpp fluid/ParticleFluid.hpp fluid/ParticleFluidBase.hpp fluid/ProppantSlurryFluid.hpp @@ -54,7 +61,8 @@ set( constitutive_headers permeability/ProppantPermeability.hpp relativePermeability/BrooksCoreyBakerRelativePermeability.hpp relativePermeability/BrooksCoreyRelativePermeability.hpp - relativePermeability/RelativePermeabilityBase.hpp + relativePermeability/RelativePermeabilityBase.hpp + relativePermeability/RelativePermeabilityExtrinsicData.hpp relativePermeability/RelativePermeabilityInterpolators.hpp relativePermeability/TableRelativePermeability.hpp relativePermeability/VanGenuchtenBakerRelativePermeability.hpp @@ -112,6 +120,7 @@ set( constitutive_sources fluid/DeadOilFluid.cpp fluid/MultiFluidBase.cpp fluid/MultiPhaseMultiComponentFluid.cpp + fluid/PVTDriver.cpp fluid/PVTOData.cpp fluid/PVTFunctions/PhillipsBrineDensity.cpp fluid/PVTFunctions/PhillipsBrineViscosity.cpp @@ -120,7 +129,11 @@ set( constitutive_sources fluid/PVTFunctions/CO2Solubility.cpp fluid/PVTFunctions/FenghourCO2Viscosity.cpp fluid/PVTFunctions/SpanWagnerCO2Density.cpp - fluid/PVTFunctions/PVTFunctionHelpers.cpp + fluid/PVTFunctions/PVTFunctionHelpers.cpp + fluid/PVTFunctions/BrineEnthalpy.cpp + fluid/PVTFunctions/CO2Enthalpy.cpp + fluid/PVTFunctions/BrineInternalEnergy.cpp + fluid/PVTFunctions/CO2InternalEnergy.cpp fluid/ParticleFluid.cpp fluid/ParticleFluidBase.cpp fluid/ProppantSlurryFluid.cpp diff --git a/src/coreComponents/constitutive/ConstitutiveBase.hpp b/src/coreComponents/constitutive/ConstitutiveBase.hpp index 3cfea8aa741..ca6bd22e250 100644 --- a/src/coreComponents/constitutive/ConstitutiveBase.hpp +++ b/src/coreComponents/constitutive/ConstitutiveBase.hpp @@ -110,6 +110,51 @@ class ConstitutiveBase : public dataRepository::Group virtual std::vector< string > getSubRelationNames() const { return {}; } + /** + * @brief Helper function to register extrinsic data on a constitutive model + * @tparam TRAIT the type of extrinsic data + * @param[in] extrinsicData the extrinsic data struct corresponding to the object being registered + * @param[in] newObject a pointer to the object that is being registered + * @return A reference to the newly registered/created Wrapper + * TODO: move up to Group + */ + template< typename TRAIT > + dataRepository::Wrapper< typename TRAIT::type > & registerExtrinsicData( TRAIT const & extrinsicDataTrait, + typename TRAIT::type * newObject ) + { + return registerWrapper( extrinsicDataTrait.key(), newObject ). + setApplyDefaultValue( extrinsicDataTrait.defaultValue() ). + setPlotLevel( TRAIT::plotLevel ). + setRestartFlags( TRAIT::restartFlag ). + setDescription( TRAIT::description ); + } + + /** + * @brief Get a wrapper associated with a trait from the constitutive model + * @tparam TRAIT The trait that holds the type and key of the data + * to be retrieved from this constitutive model + * @return A const reference to a view to const wrapper. + * TODO: move up to Group + */ + template< typename TRAIT > + dataRepository::Wrapper< typename TRAIT::type > const & getExtrinsicData() const + { + return this->getWrapper< typename TRAIT::type >( TRAIT::key() ); + } + + /** + * @brief Get a wrapper associated with a trait from the constitutive model + * @tparam TRAIT The trait that holds the type and key of the data + * to be retrieved from this constitutive model + * @return A reference to the wrapper. + * TODO: move up to Group + */ + template< typename TRAIT > + dataRepository::Wrapper< typename TRAIT::type > & getExtrinsicData() + { + return this->getWrapper< typename TRAIT::type >( TRAIT::key() ); + } + protected: private: diff --git a/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.cpp b/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.cpp index 7183add1c40..e55db893767 100644 --- a/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.cpp +++ b/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.cpp @@ -17,6 +17,7 @@ */ #include "CapillaryPressureBase.hpp" +#include "CapillaryPressureExtrinsicData.hpp" namespace geosx { @@ -41,10 +42,9 @@ CapillaryPressureBase::CapillaryPressureBase( string const & name, registerWrapper( viewKeyStruct::phaseOrderString(), &m_phaseOrder ). setSizedFromParent( 0 ); - registerWrapper( viewKeyStruct::phaseCapPressureString(), &m_phaseCapPressure ). - setPlotLevel( PlotLevel::LEVEL_0 ); + registerExtrinsicData( extrinsicMeshData::cappres::phaseCapPressure{}, &m_phaseCapPressure ); + registerExtrinsicData( extrinsicMeshData::cappres::dPhaseCapPressure_dPhaseVolFraction{}, &m_dPhaseCapPressure_dPhaseVolFrac ); - registerWrapper( viewKeyStruct::dPhaseCapPressure_dPhaseVolFractionString(), &m_dPhaseCapPressure_dPhaseVolFrac ); } void CapillaryPressureBase::postProcessInput() @@ -97,7 +97,7 @@ void CapillaryPressureBase::resizeFields( localIndex const size, void CapillaryPressureBase::setLabels() { - getWrapper< array3d< real64, cappres::LAYOUT_CAPPRES > >( viewKeyStruct::phaseCapPressureString() ). + getExtrinsicData< extrinsicMeshData::cappres::phaseCapPressure >(). setDimLabels( 2, m_phaseNames ); } diff --git a/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.hpp b/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.hpp index e96163f36e5..aa4c22ff7c5 100644 --- a/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.hpp +++ b/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureBase.hpp @@ -123,9 +123,6 @@ class CapillaryPressureBase : public ConstitutiveBase static constexpr char const * phaseNamesString() { return "phaseNames"; } static constexpr char const * phaseTypesString() { return "phaseTypes"; } static constexpr char const * phaseOrderString() { return "phaseOrder"; } - - static constexpr char const * phaseCapPressureString() { return "phaseCapPressure"; } - static constexpr char const * dPhaseCapPressure_dPhaseVolFractionString() { return "dPhaseCapPressure_dPhaseVolFraction"; } }; private: diff --git a/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureExtrinsicData.hpp b/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureExtrinsicData.hpp new file mode 100644 index 00000000000..89df88645df --- /dev/null +++ b/src/coreComponents/constitutive/capillaryPressure/CapillaryPressureExtrinsicData.hpp @@ -0,0 +1,59 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CapillaryPressureExtrinsicData.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_CAPILLARYPRESSURE_CAPILLARYPRESSUREEXTRINSICDATA_HPP_ +#define GEOSX_CONSTITUTIVE_CAPILLARYPRESSURE_CAPILLARYPRESSUREEXTRINSICDATA_HPP_ + +#include "constitutive/capillaryPressure/layouts.hpp" +#include "mesh/ExtrinsicMeshData.hpp" + +namespace geosx +{ + +namespace extrinsicMeshData +{ + +namespace cappres +{ + +using array3dLayoutCapPressure = array3d< real64, constitutive::cappres::LAYOUT_CAPPRES >; +using array4dLayoutCapPressure_dS = array4d< real64, constitutive::cappres::LAYOUT_CAPPRES_DS >; + +EXTRINSIC_MESH_DATA_TRAIT( phaseCapPressure, + "phaseCapPressure", + array3dLayoutCapPressure, + 0, + LEVEL_0, + WRITE_AND_READ, + "Phase capillary pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseCapPressure_dPhaseVolFraction, + "dPhaseCapPressure_dPhaseVolFraction", + array4dLayoutCapPressure_dS, + 0, + NOPLOT, + WRITE_AND_READ, + "Derivative of phase capillary pressure with respect to phase volume fraction" ); + +} + +} + +} + +#endif // GEOSX_CONSTITUTIVE_CAPILLARYPRESSURE_CAPILLARYPRESSUREEXTRINSICDATA_HPP_ diff --git a/src/coreComponents/constitutive/docs/BlackOilFluid.rst b/src/coreComponents/constitutive/docs/BlackOilFluid.rst index aa0744a08d8..57a8737a4f9 100644 --- a/src/coreComponents/constitutive/docs/BlackOilFluid.rst +++ b/src/coreComponents/constitutive/docs/BlackOilFluid.rst @@ -110,4 +110,4 @@ Example -.. _Petrowiki: https://petrowiki.org/Phase_behavior_in_reservoir_simulation#Black-oil_PVT_models +.. _Petrowiki: https://petrowiki.spe.org/Phase_behavior_in_reservoir_simulation#Black-oil_PVT_models diff --git a/src/coreComponents/constitutive/docs/CompositionalMultiphaseFluid.rst b/src/coreComponents/constitutive/docs/CompositionalMultiphaseFluid.rst index 567a1db6833..b6960b4c052 100644 --- a/src/coreComponents/constitutive/docs/CompositionalMultiphaseFluid.rst +++ b/src/coreComponents/constitutive/docs/CompositionalMultiphaseFluid.rst @@ -66,4 +66,4 @@ Example -.. _Petrowiki: https://petrowiki.org/Phase_behavior_in_reservoir_simulation#Equation-of-state_models +.. _Petrowiki: https://petrowiki.spe.org/Phase_behavior_in_reservoir_simulation#Equation-of-state_models diff --git a/src/coreComponents/constitutive/docs/FluidModels.rst b/src/coreComponents/constitutive/docs/FluidModels.rst index b10444a91d1..1a81b05419c 100644 --- a/src/coreComponents/constitutive/docs/FluidModels.rst +++ b/src/coreComponents/constitutive/docs/FluidModels.rst @@ -16,3 +16,6 @@ single fluids and fluid mixtures. CompositionalMultiphaseFluid CO2BrinePhillips + + PVTDriver + diff --git a/src/coreComponents/constitutive/docs/PVTDriver.rst b/src/coreComponents/constitutive/docs/PVTDriver.rst new file mode 100644 index 00000000000..7cf8f6d3bf7 --- /dev/null +++ b/src/coreComponents/constitutive/docs/PVTDriver.rst @@ -0,0 +1,151 @@ +PVT Driver +=============== + +.. contents:: Table of Contents + :depth: 3 + +Introduction +------------ + +When calibrating fluid material parameters to experimental or other reference data, it can be a hassle to launch a full flow simulation just to confirm density, viscosity, and other fluid properties are behaving as expected. +Instead, GEOSX provides a ``PVTDriver`` allowing the user to test fluid property models for a well defined set of pressure, temperature, and composition conditions. +The driver itself is launched like any other GEOSX simulation, but with a particular XML structure: + +.. code-block:: sh + + ./bin/geosx -i myFluidTest.xml + +This driver will work for any multi-phase fluid model (e.g. black-oil, co2-brine, compositional multiphase) enabled within GEOSX. + +XML Structure +------------- +A typical XML file to run the driver will have several key elements. +Here, we will walk through an example file included in the source tree at + +.. code-block:: sh + + src/coreComponents/unitTests/constitutiveTests/testPVT_docExample.xml + +The first thing to note is that the XML file structure is identical to a standard GEOSX input deck. +In fact, once the constitutive block is calibrated, one could start adding solver and discretization blocks to the same file to create a proper field simulation. +This makes it easy to go back and forth between calibration and simulation. + +The first step is to define a parameterized fluid model to test. +Here, we create a particular type of CO2-Brine mixture: + +.. literalinclude:: ../../unitTests/constitutiveTests/testPVT_docExample.xml + :language: xml + :start-after: + :end-before: + +We also define two time-history functions for the pressure (Pascal units) and temperature (Kelvin units) conditions we want to explore. + +.. literalinclude:: ../../unitTests/constitutiveTests/testPVT_docExample.xml + :language: xml + :start-after: + :end-before: + +Note that the time-axis here is just a pseudo-time, allowing us to `parameterize `_ arbitrarily complicated paths through a (pressure,temperature) diagram. +The actual time values have no impact on the resulting fluid properties. +Here, we fix the temperature at 350K and simply ramp up pressure from 1 MPa to 50 MPa: + +A ``PVTDriver`` is then added as a ``Task``, a particular type of executable event often used for simple actions. + +.. literalinclude:: ../../unitTests/constitutiveTests/testPVT_docExample.xml + :language: xml + :start-after: + :end-before: + +The driver itself takes as input the fluid model, the pressure and temperature control functions, and a "feed composition." +The latter is the mole fraction of each component in the mixture to be tested. +The ``steps`` parameter controls how many steps are taken along the parametric (P,T) path. +Results will be written in a simple ASCII table format (described below) to the file ``output``. +The ``logLevel`` parameter controls the verbosity of log output during execution. + +The driver task is added as a ``SoloEvent`` to the event queue. +This leads to a trivial event queue, since all we do is launch the driver and then quit. + +.. literalinclude:: ../../unitTests/constitutiveTests/testPVT_docExample.xml + :language: xml + :start-after: + :end-before: + +Internally, the driver uses a simple form of time-stepping to advance through the (P,T) steps. +This timestepping is handled independently of the more complicated time-stepping pattern used by physics ``Solvers`` and coordinated by the ``EventManager``. +In particular, in the XML file above, the ``maxTime`` parameter in the ``Events`` block is an event manager control, controlling when/if certain events occur. +Once launched, the PVTDriver internally determines its own max time and timestep size using a combination of the input functions' time coordinates and the requested number of loadsteps. +It is therefore helpful to think of the driver as an instantaneous *event* (from the event manager's point of view), but one which has a separate, internal clock. + +Parameters +---------- +The key XML parameters for the PVTDriver are summarized in the following table: + +.. include:: /coreComponents/schema/docs/PVTDriver.rst + +Output Format +------------- +The ``output`` key is used to identify a file to which the results of the simulation are written. +If this key is omitted, or the user specifies ``output="none"``, file output will be suppressed. +The file is a simple ASCII format with a brief header followed by test data: + +.. code:: sh + + # column 1 = time + # column 2 = pressure + # column 3 = temperature + # column 4 = density + # columns 5-6 = phase fractions + # columns 7-8 = phase densities + # columns 9-10 = phase viscosities + 0.0000e+00 1.0000e+06 3.5000e+02 1.5581e+01 1.0000e+00 4.1138e-11 1.5581e+01 1.0033e+03 1.7476e-05 9.9525e-04 + 2.0408e-02 2.0000e+06 3.5000e+02 3.2165e+01 1.0000e+00 4.1359e-11 3.2165e+01 1.0050e+03 1.7601e-05 9.9525e-04 + 4.0816e-02 3.0000e+06 3.5000e+02 4.9901e+01 1.0000e+00 4.1563e-11 4.9901e+01 1.0066e+03 1.7778e-05 9.9525e-04 + ... + +Note that the number of columns will depend on how may phases are present. +In this case, we have a two-phase, two-component mixture. +The total density is reported in column 4, while phase fractions, phase densities, and phase viscosities are reported in subsequent columns. +The phase order will match the one defined in the input XML (here, the co2-rich phase followed by the water-rich phase). +This file can be readily plotted using any number of plotting tools. Each row corresponds to one timestep of the driver, starting from initial conditions in the first row. + +Unit Testing +------------ + +The development team also uses the PVTDriver to perform unit testing on the various fluid models within GEOSX. +The optional argument ``baseline`` can be used to point to a previous output file that has been validated (e.g. against experimental benchmarks or reference codes). +If such a file is specified, the driver will perform a testing run and then compare the new results against the baseline. +In this way, any regressions in the fluid models can be quickly identified. + +Developers of new models are encouraged to add their own baselines to ``src/coreComponents/constitutive/unitTests``. +Adding additional tests is straightforward: + +1. Create a new xml file for your test in ``src/coreComponents/constitutive/unitTests`` or (easier) add extra blocks to the existing XML at ``src/coreComponents/constitutive/unitTests/testPVT.xml``. +For new XMLs, we suggest using the naming convention ``testPVT_myTest.xml``, so that all tests will be grouped together alphabetically. +Set the ``output`` file to ``testPVT_myTest.txt``, and run your test. +Validate the results however is appropriate. +If you have reference data available for this validation, we suggest archiving it in the ``testPVT_data/`` subdirectory, with a description of the source and formatting in the file header. +Several reference datasets are included already as examples. +This directory is also a convenient place to store auxiliary input files like PVT tables. + +2. This output file will now become your new baseline. +Replace the ``output`` key with ``baseline`` so that the driver can read in your file as a baseline for comparison. +Make sure there is no remaining ``output`` key, or set ``output=none``, to suppress further file output. +While you can certainly write a new output for debugging purposes, during our automated unit tests we prefer to suppress file output. +Re-run the driver to confirm that the comparison test passes. + +3. Modify ``src/coreComponents/constitutive/unitTests/CMakeLists.txt`` to enable your new test in the unit test suite. +In particular, you will need to add your new XML file to the existing list in the ``gtest_pvt_xmls`` variable. +Note that if you simply added your test to the existing ``testPVT.xml`` file, no changes are needed. + +.. code:: sh + + set( gtest_pvt_xmls + testPVT.xml + testPVT_myTest.xml + ) + +4. Run ``make`` in your build directory to make sure the CMake syntax is correct + +5. Run ``ctest -V -R PVT`` to run the PVT unit tests. Confirm your test is included and passes properly. + +If you run into troubles, do not hesitate to contact the development team for help. diff --git a/src/coreComponents/constitutive/docs/TriaxialDriver.rst b/src/coreComponents/constitutive/docs/TriaxialDriver.rst deleted file mode 100644 index 421e07769d0..00000000000 --- a/src/coreComponents/constitutive/docs/TriaxialDriver.rst +++ /dev/null @@ -1,199 +0,0 @@ -Triaxial Driver -=============== - -When calibrating solid material parameters to experimental data, it can be a hassle to launch a full finite element simulation to mimic experimental loading conditions. Instead, GEOSX provides a ``TriaxialDriver`` allowing the user to run loading tests on a single material point. This makes it easy to understand the material response and fit it to lab data. The driver itself is launched like any other GEOSX simulation, but with a particular XML structure: - -.. code-block:: sh - - ./bin/geosx -i myTest.xml - -XML Structure -------------- -A typical XML file to run the triaxial driver will have the following key elements. We present the whole file first, before digging into the individual blocks. - -.. code-block:: xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The first thing to note is that the XML structure is identical to a standard GEOSX input deck. In fact, once the constitutive block is calibrated, one could start adding solver and discretization blocks to the same file to create a proper field simulation. This makes it easy to go back and forth between calibration and simulation. - -The ``TriaxialDriver`` is added as a ``Task``, a particular type of executable event often used for simple actions. It is added as a ``SoloEvent`` to the event queue. This leads to a trivial event queue, since all we do is launch the driver and then quit. - -.. note:: - - Internally, the triaxial driver uses a simple form of time-stepping to advance through the loading steps, allowing for both rate-dependent and rate-independent models to be tested. This timestepping is handled independently from the more complicated time-stepping pattern used by physics ``Solvers`` and coordinated by the ``EventManager``. In particular, in the XML file above, the ``maxTime`` parameter in the ``Events`` block is an event manager control, controlling when/if certain events occur. Once launched, the triaxial driver internally determines its own max time and timestep size using a combination of the strain function's time coordinates and the requested number of loadsteps. It is therefore helpful to think of the driver as an instantaneous *event* (from the event manager's point of view), but one which has a separate, internal clock. - -The key parameters for the TriaxialDriver are: - -.. include:: /coreComponents/fileIO/schema/docs/TriaxialDriver.rst - -.. note:: - - GEOSX uses the *engineering* sign convention where compressive stresses and strains are *negative*. - This is one of the most frequent issues users make when calibrating material parameters, as - stress- and strain-like quantities often need to be negative to make physical sense. You may note in the - XML above, for example, that ``stressFunction`` and ``strainFunction`` have negative values for - a compressive test. - -Test Modes ----------- -The most complicated part of the driver is understanding how the stress and strain functions are applied in different testing modes. The driver mimics laboratory core tests, with loading controlled in the -axial and radial directions. These conditions may be either strain-controlled or stress-controlled. The following table describes the available test modes in detail: - -+---------------+-------------------------+-------------------------+---------------------------+ -| **mode** | **axial loading** | **radial loading** | **initial stress** | -+---------------+-------------------------+-------------------------+---------------------------+ -| ``triaxial`` | axial strain controlled | radial stress controlled| isotropic stress using | -| | with ``strainFunction`` | with ``stressFunction`` | ``stressFunction(t=tmin)``| -+---------------+-------------------------+-------------------------+---------------------------+ -| ``volumetric``| axial strain controlled | radial strain = | isotropic stress using | -| | with ``strainFunction`` | axial strain | ``stressFunction(t=tmin)``| -+---------------+-------------------------+-------------------------+---------------------------+ -| ``oedometer`` | axial strain controlled | zero radial strain | isotropic stress using | -| | with ``strainFunction`` | | ``stressFunction(t=tmin)``| -+---------------+-------------------------+-------------------------+---------------------------+ - -To set the initial stress state, the ``stressFunction`` is evaluated at ``t=tmin`` (usually ``t=0``, though conceivably a user may put in a time-function with a non-zero starting point). This scalar value is used to set the material to an isotropic initial stress state. In the volumetric and oedometer tests, the remainder of the ``stressFunction`` time history is ignored, as they are strain-controlled tests. By setting the initial stress this way, it makes it easy to start the test from a well-defined confining pressure. - -Output Format -------------- -The ``output`` key is used to identify a file to which the results of the simulation are written. If this key is omitted, or the user specifies ``output="none"``, file output will be suppressed. The file is a simple ASCII format with a brief header followed by test data: - -.. code:: sh - - # column 1 = time - # column 2 = axial_strain - # column 3 = radial_strain_1 - # column 4 = radial_strain_2 - # column 5 = axial_stress - # column 6 = radial_stress_1 - # column 7 = radial_stress_2 - # column 8 = newton_iter - # column 9 = residual_norm - 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 -1.0000e+00 -1.0000e+00 -1.0000e+00 0.0000e+00 0.0000e+00 - 1.6000e-01 -1.6000e-04 4.0000e-05 4.0000e-05 -1.1200e+00 -1.0000e+00 -1.0000e+00 2.0000e+00 0.0000e+00 - 3.2000e-01 -3.2000e-04 8.0000e-05 8.0000e-05 -1.2400e+00 -1.0000e+00 -1.0000e+00 2.0000e+00 0.0000e+00 - ... - -This file can be readily plotted using any number of plotting tools. Each row corresponds to one timestep of the driver, starting from initial conditions in the first row. - -We note that the file contains two columns for radial strain and two columns for radial stress. For an isotropic material, the stresses and strains along the two radial axes will usually be identical. We choose to output this way, however, to accommodate both anisotropic materials and true-triaxial loading conditions. In these cases, the stresses and strains in the radial directions could potentially differ. - -These columns can be added and subtracted to produce other quantities of interest, like mean stress or deviatoric stress. For example, we can plot the output of our "sand" XML to produce the following stress / strain curves: - -.. figure:: TriaxialDriver.svg - :width: 600px - :align: center - :alt: stress/strain figure - :figclass: align-center - - **Figure**: Stress/strain behavior resulting from the sand model XML above. - -In this plot, we have reversed the sign convention to be consistent with typical experimental plots. Note also that the ``strainFunction`` above includes two unloading cycles, allowing us to observe both plastic loading and elastic unloading. - -Model Convergence ------------------ - -The last two columns of the output file contain information about the convergence behavior of the material driver. In ``triaxial`` mode, the mixed nature of the stress/strain control requires using a Newton solver to converge the solution. This last column reports the number of Newton iterations and final residual norm. Large values here would be indicative of the material model struggling (or failing) to converge. Convergence failures can result from several reasons, including: - -1. Inappropriate material parameter settings -2. Overly large timesteps -3. Infeasible loading conditions (i.e. trying to load a material to a physically-unreachable stress point) -4. Poor model implementation - -We generally spend a lot of time vetting the material model implementations (#4). When you first encounter a problem, it is therefore good to explore the other three scenarios first. If you find something unusual in the model implementation or are just really stuck, please submit an issue on our issue tracker so we can help resolve any bugs. - -Unit Testing ------------- - -The development team also uses the Triaxial Driver to perform unit testing on the various material models within GEOSX. The optional argument ``baseline`` can be used to point to a previous output file that has been validated (e.g. against analytical or experimental benchmarks). If such a file is specified, the driver will perform a loading run and then compare the new results against the baseline. In this way, any regressions in the material models can be quickly identified. - -Developers of new models are encouraged to add their own baselines to ``src/coreComponents/constitutive/unitTests``. Adding additional tests is straightforward: - -1. Create a new xml file for your test in ``src/coreComponents/constitutive/unitTests``. There are several examples is this directory already to use as a template. We suggest using the naming convention ``testTriaxial_myTest.xml``, so that all triaxial tests will be grouped together alphabetically. Set the ``output`` file to ``testTriaxial_myTest.txt``, and run your test. Validate the results however is appropriate. - -2. This output file will now become your new baseline. Replace the ``output`` key with ``baseline`` so that the driver can read in your file as a baseline for comparison. Make sure there is no remaining ``output`` key, or set ``output=none``, to suppress further file output. While you can certainly write a new output for debugging purposes, during our automated unit tests we prefer to suppress file output. Re-run the triaxial driver to confirm that the comparison test passes. - -3. Modify ``src/coreComponents/constitutive/unitTests/CMakeLists.txt`` to enable your new test in the unit test suite. In particular, you will need to add your new XML file to the existing list in the ``gtest_triaxial_xmls`` variable: - -.. code:: sh - - set( gtest_triaxial_xmls - testTriaxial_elasticIsotropic.xml - testTriaxial_druckerPragerExtended.xml - testTriaxial_myTest.xml - ) -4. Run ``make`` in your build directory to make sure the CMake syntax is correct - -5. Run ``ctest -V -R Triax`` to run the triaxial unit tests. Confirm your test is included and passes properly. - -If you run into troubles, do not hesitate to contact the development team for help. - - - diff --git a/src/coreComponents/constitutive/docs/TriaxialDriver.svg b/src/coreComponents/constitutive/docs/TriaxialDriver.svg deleted file mode 100644 index d06d1221654..00000000000 --- a/src/coreComponents/constitutive/docs/TriaxialDriver.svg +++ /dev/null @@ -1,396 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/coreComponents/constitutive/docs/solid/TriaxialDriver.rst b/src/coreComponents/constitutive/docs/solid/TriaxialDriver.rst index 61a34e1c2b8..9defe969e65 100644 --- a/src/coreComponents/constitutive/docs/solid/TriaxialDriver.rst +++ b/src/coreComponents/constitutive/docs/solid/TriaxialDriver.rst @@ -18,9 +18,8 @@ XML Structure ------------- A typical XML file to run the triaxial driver will have the following key elements. We present the whole file first, before digging into the individual blocks. -.. code-block:: console - - src/coreComponents/unitTests/constitutiveTests/testTriaxial_druckerPragerExtended.xml +.. literalinclude:: ../../../unitTests/constitutiveTests/testTriaxial_druckerPragerExtended.xml + :language: xml The first thing to note is that the XML structure is identical to a standard GEOSX input deck. In fact, once the constitutive block is calibrated, one could start adding solver and discretization blocks to the same file to create a proper field simulation. This makes it easy to go back and forth between calibration and simulation. diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp index c5c630ef4a5..4122e47d18c 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.cpp @@ -16,7 +16,9 @@ * @file MultiFluidBase.cpp */ + #include "MultiFluidBase.hpp" +#include "MultiFluidExtrinsicData.hpp" namespace geosx { @@ -45,83 +47,50 @@ MultiFluidBase::MultiFluidBase( string const & name, Group * const parent ) setInputFlag( InputFlags::OPTIONAL ). setDescription( "List of fluid phases" ); - registerWrapper( viewKeyStruct::phaseFractionString(), &m_phaseFraction.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseFraction_dPressureString(), &m_phaseFraction.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseFraction_dTemperatureString(), &m_phaseFraction.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseFraction_dGlobalCompFractionString(), &m_phaseFraction.dComp ). - setRestartFlags( RestartFlags::NO_WRITE ); - - registerWrapper( viewKeyStruct::phaseDensityString(), &m_phaseDensity.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseDensity_dPressureString(), &m_phaseDensity.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseDensity_dTemperatureString(), &m_phaseDensity.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseDensity_dGlobalCompFractionString(), &m_phaseDensity.dComp ). + registerWrapper( viewKeyStruct::useMassString(), &m_useMass ). setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::phaseMassDensityString(), &m_phaseMassDensity.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseMassDensity_dPressureString(), &m_phaseMassDensity.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseMassDensity_dTemperatureString(), &m_phaseMassDensity.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseMassDensity_dGlobalCompFractionString(), &m_phaseMassDensity.dComp ). - 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 ); - registerWrapper( viewKeyStruct::phaseViscosityString(), &m_phaseViscosity.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseViscosity_dPressureString(), &m_phaseViscosity.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseViscosity_dTemperatureString(), &m_phaseViscosity.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseViscosity_dGlobalCompFractionString(), &m_phaseViscosity.dComp ). - setRestartFlags( RestartFlags::NO_WRITE ); + 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 ); - registerWrapper( viewKeyStruct::phaseCompFractionString(), &m_phaseCompFraction.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseCompFraction_dPressureString(), &m_phaseCompFraction.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseCompFraction_dTemperatureString(), &m_phaseCompFraction.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseCompFraction_dGlobalCompFractionString(), &m_phaseCompFraction.dComp ). - setRestartFlags( RestartFlags::NO_WRITE ); + 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 ); - registerWrapper( viewKeyStruct::totalDensityString(), &m_totalDensity.value ) - .setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dTotalDensity_dPressureString(), &m_totalDensity.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dTotalDensity_dTemperatureString(), &m_totalDensity.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dTotalDensity_dGlobalCompFractionString(), &m_totalDensity.dComp ). - setRestartFlags( RestartFlags::NO_WRITE ); + 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 ); - registerWrapper( viewKeyStruct::initialTotalMassDensityString(), &m_initialTotalMassDensity ); + registerExtrinsicData( extrinsicMeshData::multifluid::phaseEnthalpy{}, &m_phaseEnthalpy.value ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy_dPressure{}, &m_phaseEnthalpy.dPres ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy_dTemperature{}, &m_phaseEnthalpy.dTemp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction{}, &m_phaseEnthalpy.dComp ); - registerWrapper( viewKeyStruct::useMassString(), &m_useMass ). - setRestartFlags( RestartFlags::NO_WRITE ); + registerExtrinsicData( extrinsicMeshData::multifluid::phaseInternalEnergy{}, &m_phaseInternalEnergy.value ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy_dPressure{}, &m_phaseInternalEnergy.dPres ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy_dTemperature{}, &m_phaseInternalEnergy.dTemp ); + registerExtrinsicData( extrinsicMeshData::multifluid::dPhaseInternalEnergy_dGlobalCompFraction{}, &m_phaseInternalEnergy.dComp ); - registerWrapper( viewKeyStruct::phaseEnthalpyString(), &m_phaseEnthalpy.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseEnthalpy_dPressureString(), &m_phaseEnthalpy.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseEnthalpy_dTemperatureString(), &m_phaseEnthalpy.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseEnthalpy_dGlobalCompFractionString(), &m_phaseEnthalpy.dComp ). - setRestartFlags( RestartFlags::NO_WRITE ); + 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::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 ); - registerWrapper( viewKeyStruct::phaseInternalEnergyString(), &m_phaseInternalEnergy.value ). - setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dPressureString(), &m_phaseInternalEnergy.dPres ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dTemperatureString(), &m_phaseInternalEnergy.dTemp ). - setRestartFlags( RestartFlags::NO_WRITE ); - registerWrapper( viewKeyStruct::dPhaseInternalEnergy_dGlobalCompFractionString(), &m_phaseInternalEnergy.dComp ). - setRestartFlags( RestartFlags::NO_WRITE ); + registerExtrinsicData( extrinsicMeshData::multifluid::initialTotalMassDensity{}, &m_initialTotalMassDensity ); } @@ -175,25 +144,25 @@ void MultiFluidBase::resizeFields( localIndex const size, localIndex const numPt void MultiFluidBase::setLabels() { - getWrapper< array3d< real64, multifluid::LAYOUT_PHASE > >( viewKeyStruct::phaseFractionString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseFraction >(). setDimLabels( 2, m_phaseNames ); - getWrapper< array3d< real64, multifluid::LAYOUT_PHASE > >( viewKeyStruct::phaseDensityString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseDensity >(). setDimLabels( 2, m_phaseNames ); - getWrapper< array3d< real64, multifluid::LAYOUT_PHASE > >( viewKeyStruct::phaseMassDensityString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseMassDensity >(). setDimLabels( 2, m_phaseNames ); - getWrapper< array3d< real64, multifluid::LAYOUT_PHASE > >( viewKeyStruct::phaseViscosityString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseViscosity >(). setDimLabels( 2, m_phaseNames ); - getWrapper< array3d< real64, multifluid::LAYOUT_PHASE > >( viewKeyStruct::phaseEnthalpyString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseEnthalpy >(). setDimLabels( 2, m_phaseNames ); - getWrapper< array3d< real64, multifluid::LAYOUT_PHASE > >( viewKeyStruct::phaseInternalEnergyString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseInternalEnergy >(). setDimLabels( 2, m_phaseNames ); - getWrapper< array4d< real64, multifluid::LAYOUT_PHASE_COMP > >( viewKeyStruct::phaseCompFractionString() ). + getExtrinsicData< extrinsicMeshData::multifluid::phaseCompFraction >(). setDimLabels( 2, m_phaseNames ). setDimLabels( 3, m_componentNames ); } diff --git a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp index d115156f9a9..55b4ec303d7 100644 --- a/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/MultiFluidBase.hpp @@ -66,6 +66,12 @@ class MultiFluidBase : public ConstitutiveBase */ arrayView1d< string const > componentNames() const { return m_componentNames; } + /** + * @brief Getter for the fluid component molar weights + * @return an arrayView1d storing the component molar weights + */ + arrayView1d< real64 const > componentMolarWeights() const { return m_componentMolarWeight; } + /** * @return number of fluid phases in the model */ @@ -201,51 +207,8 @@ class MultiFluidBase : public ConstitutiveBase { static constexpr char const * componentNamesString() { return "componentNames"; } static constexpr char const * componentMolarWeightString() { return "componentMolarWeight"; } - static constexpr char const * phaseNamesString() { return "phaseNames"; } - static constexpr char const * phaseFractionString() { return "phaseFraction"; } // xi_p - static constexpr char const * dPhaseFraction_dPressureString() { return "dPhaseFraction_dPressure"; } // dXi_p/dP - static constexpr char const * dPhaseFraction_dTemperatureString() { return "dPhaseFraction_dTemperature"; } // dXi_p/dT - static constexpr char const * dPhaseFraction_dGlobalCompFractionString() { return "dPhaseFraction_dGlobalCompFraction"; } // dXi_p/dz - - static constexpr char const * phaseDensityString() { return "phaseDensity"; } // rho_p - static constexpr char const * dPhaseDensity_dPressureString() { return "dPhaseDensity_dPressure"; } // dRho_p/dP - static constexpr char const * dPhaseDensity_dTemperatureString() { return "dPhaseDensity_dTemperature"; } // dRho_p/dT - static constexpr char const * dPhaseDensity_dGlobalCompFractionString() { return "dPhaseDensity_dGlobalCompFraction"; } // dRho_p/dz - - static constexpr char const * phaseMassDensityString() { return "phaseMassDensity"; } // rho_p - static constexpr char const * dPhaseMassDensity_dPressureString() { return "dPhaseMassDensity_dPressure"; } // dRho_p/dP - static constexpr char const * dPhaseMassDensity_dTemperatureString() { return "dPhaseMassDensity_dTemperature"; } // dRho_p/dT - static constexpr char const * dPhaseMassDensity_dGlobalCompFractionString() { return "dPhaseMassDensity_dGlobalCompFraction"; } // dRho_p/dz - - static constexpr char const * phaseViscosityString() { return "phaseViscosity"; } // mu_p - static constexpr char const * dPhaseViscosity_dPressureString() { return "dPhaseViscosity_dPressure"; } // dMu_p/dP - static constexpr char const * dPhaseViscosity_dTemperatureString() { return "dPhaseViscosity_dTemperature"; } // dMu_p/dT - static constexpr char const * dPhaseViscosity_dGlobalCompFractionString() { return "dPhaseViscosity_dGlobalCompFraction"; } // dMu_p/dz - - static constexpr char const * phaseCompFractionString() { return "phaseCompFraction"; } // x_cp - static constexpr char const * dPhaseCompFraction_dPressureString() { return "dPhaseCompFraction_dPressure"; } // dx_cp/dP - static constexpr char const * dPhaseCompFraction_dTemperatureString() { return "dPhaseCompFraction_dTemperature"; } // dx_cp/dT - static constexpr char const * dPhaseCompFraction_dGlobalCompFractionString() { return "dPhaseCompFraction_dGlobalCompFraction"; } // dx_cp/dz - - static constexpr char const * totalDensityString() { return "totalDensity"; } // rho_t - static constexpr char const * dTotalDensity_dPressureString() { return "dTotalDensity_dPressure"; } // dRho_t/dP - static constexpr char const * dTotalDensity_dTemperatureString() { return "dTotalDensity_dTemperature"; } // dRho_t/dT - static constexpr char const * dTotalDensity_dGlobalCompFractionString() { return "dTotalDensity_dGlobalCompFraction"; } // dRho_t/dz - - static constexpr char const * initialTotalMassDensityString() { return "initialTotalMassDensity"; } // rho^int_t - - static constexpr char const * phaseEnthalpyString() { return "phaseEnthalpy"; } // H_p - static constexpr char const * dPhaseEnthalpy_dPressureString() { return "dPhaseEnthalpy_dPressure"; } // dH_p/dP - static constexpr char const * dPhaseEnthalpy_dTemperatureString() { return "dPhaseEnthalpy_dTemperature"; } // dH_p/dT - static constexpr char const * dPhaseEnthalpy_dGlobalCompFractionString() { return "dPhaseEnthalpy_dGlobalCompFraction"; } // dH_p/dz - - static constexpr char const * phaseInternalEnergyString() { return "phaseInternalEnergy"; } // U_p - static constexpr char const * dPhaseInternalEnergy_dPressureString() { return "dPhaseInternalEnergy_dPressure"; } // dU_p/dP - static constexpr char const * dPhaseInternalEnergy_dTemperatureString() { return "dPhaseInternalEnergy_dTemperature"; } // dU_p/dT - static constexpr char const * dPhaseInternalEnergy_dGlobalCompFractionString() { return "dPhaseInternalEnergy_dGlobalCompFraction"; } // dU_p/dz - static constexpr char const * useMassString() { return "useMass"; } }; diff --git a/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp new file mode 100644 index 00000000000..ce3fb829d58 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/MultiFluidExtrinsicData.hpp @@ -0,0 +1,312 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file MultiFluidExtrinsicData.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_MULTIFLUIDEXTRINSICDATA_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_MULTIFLUIDEXTRINSICDATA_HPP_ + +#include "constitutive/fluid/layouts.hpp" +#include "mesh/ExtrinsicMeshData.hpp" + +namespace geosx +{ + +namespace extrinsicMeshData +{ + +namespace multifluid +{ + +using array2dLayoutFluid = array2d< real64, constitutive::multifluid::LAYOUT_FLUID >; +using array3dLayoutFluid_dC = array3d< real64, constitutive::multifluid::LAYOUT_FLUID_DC >; +using array3dLayoutPhase = array3d< real64, constitutive::multifluid::LAYOUT_PHASE >; +using array4dLayoutPhase_dC = array4d< real64, constitutive::multifluid::LAYOUT_PHASE_DC >; +using array4dLayoutPhaseComp = array4d< real64, constitutive::multifluid::LAYOUT_PHASE_COMP >; +using array5dLayoutPhaseComp_dC = array5d< real64, constitutive::multifluid::LAYOUT_PHASE_COMP_DC >; + +EXTRINSIC_MESH_DATA_TRAIT( phaseFraction, + "phaseFraction", + array3dLayoutPhase, + 0, + LEVEL_0, + 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", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase fraction with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseDensity, + "phaseDensity", + array3dLayoutPhase, + 0, + LEVEL_0, + 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", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase density with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseMassDensity, + "phaseMassDensity", + array3dLayoutPhase, + 0, + LEVEL_0, + 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", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase mass density with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseViscosity, + "phaseViscosity", + array3dLayoutPhase, + 0, + LEVEL_0, + 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", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase viscosity with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseEnthalpy, + "phaseEnthalpy", + array3dLayoutPhase, + 0, + LEVEL_0, + WRITE_AND_READ, + "Phase enthalpy" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy_dPressure, + "dPhaseEnthalpy_dPressure", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy_dTemperature, + "dPhaseEnthalpy_dTemperature", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseEnthalpy_dGlobalCompFraction, + "dPhaseEnthalpy_dGlobalCompFraction", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase enthalpy with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseInternalEnergy, + "phaseInternalEnergy", + array3dLayoutPhase, + 0, + LEVEL_0, + WRITE_AND_READ, + "Phase internal energy" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseInternalEnergy_dPressure, + "dPhaseInternalEnergy_dPressure", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseInternalEnergy_dTemperature, + "dPhaseInternalEnergy_dTemperature", + array3dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseInternalEnergy_dGlobalCompFraction, + "dPhaseInternalEnergy_dGlobalCompFraction", + array4dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase internal energy with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseCompFraction, + "phaseCompFraction", + array4dLayoutPhaseComp, + 0, + LEVEL_0, + 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", + array5dLayoutPhaseComp_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase component fraction with respect to global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( totalDensity, + "totalDensity", + array2dLayoutFluid, + 0, + LEVEL_0, + WRITE_AND_READ, + "Total density" ); + +EXTRINSIC_MESH_DATA_TRAIT( initialTotalMassDensity, + "initialTotalMassDensity", + array2dLayoutFluid, + 0, + LEVEL_0, + 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", + array3dLayoutFluid_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of total density with respect to global component fraction" ); + + +} + +} + +} + +#endif // GEOSX_CONSTITUTIVE_FLUID_MULTIFLUIDEXTRINSICDATA_HPP_ diff --git a/src/coreComponents/constitutive/fluid/PVTDriver.cpp b/src/coreComponents/constitutive/fluid/PVTDriver.cpp new file mode 100644 index 00000000000..5339e84bec4 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTDriver.cpp @@ -0,0 +1,333 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file PVTDriver.cpp + */ + +#include "PVTDriver.hpp" +#include "fileIO/Outputs/OutputBase.hpp" + +namespace geosx +{ +using namespace dataRepository; +using namespace constitutive; + + +PVTDriver::PVTDriver( const string & name, + Group * const parent ): + TaskBase( name, parent ) +{ + enableLogLevelInput(); + + registerWrapper( viewKeyStruct::fluidNameString(), &m_fluidName ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Fluid to test" ); + + registerWrapper( viewKeyStruct::feedString(), &m_feed ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Feed composition array [mol fraction]" ); + + registerWrapper( viewKeyStruct::pressureFunctionString(), &m_pressureFunctionName ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Function controlling pressure time history" ); + + registerWrapper( viewKeyStruct::temperatureFunctionString(), &m_temperatureFunctionName ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Function controlling temperature time history" ); + + registerWrapper( viewKeyStruct::numStepsString(), &m_numSteps ). + setInputFlag( InputFlags::REQUIRED ). + setDescription( "Number of load steps to take" ); + + registerWrapper( viewKeyStruct::outputString(), &m_outputFile ). + setInputFlag( InputFlags::OPTIONAL ). + setApplyDefaultValue( "none" ). + setDescription( "Output file" ); + + registerWrapper( viewKeyStruct::baselineString(), &m_baselineFile ). + setInputFlag( InputFlags::OPTIONAL ). + setApplyDefaultValue( "none" ). + setDescription( "Baseline file" ); +} + + +PVTDriver::~PVTDriver() +{} + + +void PVTDriver::postProcessInput() +{ + // get number of phases and components + + ConstitutiveManager & constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" ); + MultiFluidBase & baseFluid = constitutiveManager.getGroup< MultiFluidBase >( m_fluidName ); + + m_numPhases = baseFluid.numFluidPhases(); + m_numComponents = baseFluid.numFluidComponents(); + + // resize data table to fit number of timesteps and fluid phases: + // (numRows,numCols) = (numSteps+1,4+3*numPhases) + // column order = time, pressure, temp, totalDensity, phaseFraction_{1:NP}, phaseDensity_{1:NP}, phaseViscosity_{1:NP} + + m_table.resize( m_numSteps+1, 3*m_numPhases+4 ); + + // initialize functions + + FunctionManager & functionManager = FunctionManager::getInstance(); + + TableFunction & pressureFunction = functionManager.getGroup< TableFunction >( m_pressureFunctionName ); + TableFunction & temperatureFunction = functionManager.getGroup< TableFunction >( m_temperatureFunctionName ); + + pressureFunction.initializeFunction(); + temperatureFunction.initializeFunction(); + + // determine time increment + + ArrayOfArraysView< real64 > coordinates = pressureFunction.getCoordinates(); + real64 const minTime = coordinates[0][0]; + real64 const maxTime = coordinates[0][coordinates.sizeOfArray( 0 )-1]; + real64 const dt = (maxTime-minTime) / m_numSteps; + + // set input columns + + for( integer n=0; n 0, "PVTDriver should only be run in serial", std::runtime_error ); + + // get the fluid out of the constitutive manager. + // for the moment it is of type MultiFluidBase. + + ConstitutiveManager & constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" ); + MultiFluidBase & baseFluid = constitutiveManager.getGroup< MultiFluidBase >( m_fluidName ); + + // depending on logLevel, print some useful info + + if( getLogLevel() > 0 ) + { + GEOSX_LOG_RANK_0( "Launching PVT Driver" ); + GEOSX_LOG_RANK_0( " Fluid .................. " << m_fluidName ); + GEOSX_LOG_RANK_0( " Type ................... " << baseFluid.getCatalogName() ); + GEOSX_LOG_RANK_0( " No. of Phases .......... " << m_numPhases ); + GEOSX_LOG_RANK_0( " No. of Components ...... " << m_numComponents ); + GEOSX_LOG_RANK_0( " Pressure Control ....... " << m_pressureFunctionName ); + GEOSX_LOG_RANK_0( " Temperature Control .... " << m_temperatureFunctionName ); + GEOSX_LOG_RANK_0( " Steps .................. " << m_numSteps ); + GEOSX_LOG_RANK_0( " Output ................. " << m_outputFile ); + GEOSX_LOG_RANK_0( " Baseline ............... " << m_baselineFile ); + } + + // create a dummy discretization with one quadrature point for + // storing constitutive data + + conduit::Node node; + dataRepository::Group rootGroup( "root", node ); + dataRepository::Group discretization( "discretization", &rootGroup ); + + discretization.resize( 1 ); // one element + baseFluid.allocateConstitutiveData( discretization, 1 ); // one quadrature point + + // pass the solid through the ConstitutivePassThru to downcast from the + // base type to a known model type. the lambda here then executes the + // appropriate test driver. note that these calls will move data to device if available. + + constitutiveUpdatePassThru( baseFluid, [&] ( auto & selectedFluid ) + { + using FLUID_TYPE = TYPEOFREF( selectedFluid ); + runTest< FLUID_TYPE >( selectedFluid, m_table ); + } ); + + // move table back to host for output + m_table.move( LvArray::MemorySpace::host ); + + if( m_outputFile != "none" ) + { + outputResults(); + } + + if( m_baselineFile != "none" ) + { + compareWithBaseline(); + } + + return false; +} + + +template< typename FLUID_TYPE > +void PVTDriver::runTest( FLUID_TYPE & fluid, arrayView2d< real64 > & table ) +{ + // get number of phases and components + + localIndex const NC = fluid.numFluidComponents(); + localIndex const NP = fluid.numFluidPhases(); + + // prefer output in mass + + fluid.setMassFlag( true ); + + // get output data views + + arrayView2d< real64 const, multifluid::USD_FLUID > totalDensity = fluid.totalDensity(); + arrayView3d< real64 const, multifluid::USD_PHASE > phaseFraction = fluid.phaseFraction(); + arrayView3d< real64 const, multifluid::USD_PHASE > phaseDensity = fluid.phaseDensity(); + arrayView3d< real64 const, multifluid::USD_PHASE > phaseViscosity = fluid.phaseViscosity(); + + // create kernel wrapper + + typename FLUID_TYPE::KernelWrapper kernelWrapper = fluid.createKernelWrapper(); + + // set composition to user specified feed + // it is more convenient to provide input in molar, so perform molar to mass conversion here + + GEOSX_ASSERT_EQ( NC, m_feed.size() ); + array2d< real64, compflow::LAYOUT_COMP > compositionValues( 1, NC ); + + real64 sum = 0.0; + for( localIndex i = 0; i < NC; ++i ) + { + compositionValues[0][i] = m_feed[i] * fluid.componentMolarWeights()[i]; + sum += compositionValues[0][i]; + } + for( localIndex i = 0; i < NC; ++i ) + { + compositionValues[0][i] /= sum; + } + + arraySlice1d< real64 const, compflow::USD_COMP - 1 > const composition = compositionValues[0]; + + // perform fluid update using table (P,T) and save resulting total density, etc. + // note: column indexing should be kept consistent with output file header below. + + using ExecPolicy = typename FLUID_TYPE::exec_policy; + forAll< ExecPolicy >( 1, [=] GEOSX_HOST_DEVICE ( integer const ei ) + { + for( integer n=0; n<=m_numSteps; ++n ) + { + kernelWrapper.update( ei, 0, table( n, PRES ), table( n, TEMP ), composition ); + table( n, TEMP+1 ) = totalDensity( ei, 0 ); + + for( integer p=0; p> value; + + error = fabs( m_table[row][col]-value ) / ( fabs( value )+1 ); + GEOSX_THROW_IF( error > m_baselineTol, "Results do not match baseline at data row " << row+1 + << " (row " << row+m_numColumns << " with header)" + << " and column " << col+1, std::runtime_error ); + } + } + + // check we actually reached the end of the baseline file + + file >> value; + GEOSX_THROW_IF( !file.eof(), "Baseline file appears longer than internal results", std::runtime_error ); + + // success + + if( getLogLevel() > 0 ) + { + GEOSX_LOG_RANK_0( " Comparison ............. Internal results consistent with baseline." ); + } + + file.close(); +} + + +REGISTER_CATALOG_ENTRY( TaskBase, + PVTDriver, + string const &, dataRepository::Group * const ) + +} /* namespace geosx */ diff --git a/src/coreComponents/constitutive/fluid/PVTDriver.hpp b/src/coreComponents/constitutive/fluid/PVTDriver.hpp new file mode 100644 index 00000000000..6eee29937ff --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTDriver.hpp @@ -0,0 +1,117 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file PVTDriver.hpp + */ + +#ifndef SRC_CORECOMPONENTS_CONSTITUTIVE_FLUID_PVTDRIVER_HPP_ +#define SRC_CORECOMPONENTS_CONSTITUTIVE_FLUID_PVTDRIVER_HPP_ + +#include "common/MpiWrapper.hpp" +#include "constitutive/ConstitutiveManager.hpp" +#include "constitutive/fluid/MultiFluidBase.hpp" +#include "constitutive/fluid/multiFluidSelector.hpp" +#include "events/tasks/TaskBase.hpp" +#include "functions/FunctionManager.hpp" +#include "functions/TableFunction.hpp" +#include "mesh/DomainPartition.hpp" + +namespace geosx +{ + +using namespace constitutive; + +/** + * @class PVTDriver + * + * Class to allow for testing PVT behavior without the + * complexity of setting up a full simulation. + * + */ +class PVTDriver : public TaskBase +{ +public: + PVTDriver( const string & name, + Group * const parent ); + ~PVTDriver() override; + + static string catalogName() { return "PVTDriver"; } + + void postProcessInput() override; + + virtual bool execute( real64 const GEOSX_UNUSED_PARAM( time_n ), + real64 const GEOSX_UNUSED_PARAM( dt ), + integer const GEOSX_UNUSED_PARAM( cycleNumber ), + integer const GEOSX_UNUSED_PARAM( eventCounter ), + real64 const GEOSX_UNUSED_PARAM( eventProgress ), + DomainPartition & GEOSX_UNUSED_PARAM( domain ) ) override; + + /** + * @brief Run test using loading protocol in table + * @param fluid Fluid constitutive model + * @param table Table with input/output time history + */ + template< typename FLUID_TYPE > + void runTest( FLUID_TYPE & fluid, arrayView2d< real64 > & table ); + + /** + * @brief Ouput table to file for easy plotting + */ + void outputResults(); + + /** + * @brief Read in a baseline table from file and compare with computed one (for unit testing purposes) + */ + void compareWithBaseline(); + +private: + + /** + * @struct viewKeyStruct holds char strings and viewKeys for fast lookup + */ + struct viewKeyStruct + { + constexpr static char const * fluidNameString() { return "fluid"; } + constexpr static char const * pressureFunctionString() { return "pressureControl"; } + constexpr static char const * temperatureFunctionString() { return "temperatureControl"; } + constexpr static char const * numStepsString() { return "steps"; } + constexpr static char const * outputString() { return "output"; } + constexpr static char const * baselineString() { return "baseline"; } + constexpr static char const * feedString() { return "feedComposition"; } + }; + + integer m_numSteps; ///< Number of load steps + integer m_numColumns; ///< Number of columns in data table (depends on number of fluid phases) + integer m_numPhases; ///< Number of fluid phases + integer m_numComponents; ///< Number of fluid components + + string m_fluidName; ///< Fluid identifier + string m_pressureFunctionName; ///< Time-dependent function controlling pressure + string m_temperatureFunctionName; ///< Time-dependent function controlling temperature + string m_outputFile; ///< Output file (optional, no output if not specified) + + array1d< real64 > m_feed; ///< User specified feed composition + array2d< real64 > m_table; ///< Table storing time-history of input/output + + Path m_baselineFile; ///< Baseline file (optional, for unit testing of solid models) + + enum columnKeys { TIME, PRES, TEMP }; ///< Enumeration of "input" column keys for readability + + static constexpr real64 m_baselineTol = 1e-3; ///< Comparison tolerance for baseline results +}; + +} /* namespace geosx */ + +#endif /* SRC_CORECOMPONENTS_CONSTITUTIVE_FLUID_PVTDRIVER_HPP_ */ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.cpp new file mode 100644 index 00000000000..548f3d15768 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.cpp @@ -0,0 +1,224 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file BrineEnthalpy.cpp + */ + +#include "constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp" + +#include "functions/FunctionManager.hpp" +#include "constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp" +#include "constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp" + + +namespace geosx +{ + +using namespace stringutilities; + +namespace constitutive +{ + +namespace PVTProps +{ + +namespace +{ + +real64 MichaelidesBrineEnthalpy( real64 const & T, + real64 const & m ) +{ + + static real64 a[4][3] = { + {-9633.6, -4080.0, 286.49}, + {166.58, 68.577, -4.6856}, + {-0.90963, -0.36524, 0.0249667}, + {1.7965e-3, 7.1924e-4, -4.9e-5} + }; + + real64 x1, x2, h1, h2, dh; + + x1 = 1000.0 / (1000.0 + 58.44 * m); + + x2 = 58.44 * m / (1000.0 + 58.44 * m); + + + + dh = 0.0; + + for( localIndex i = 0; i < 4; ++i ) + for( localIndex j = 0; j < 3; ++j ) + { + + dh += a[i][j] * pow( T, real64( i )) * pow( m, real64( j )); + + } + + dh *= 4.184 / (1000.0 + 58.44 * m); + + + h1 = 0.12453e-4 * pow( T, 3.0 ) - 0.45137e-2 * pow( T, 2.0 ) + 4.81155 * T - 29.578; + + h2 = (-0.83624e-3 * pow( T, 3.0 ) + 0.16792 * pow( T, 2.0 ) - 25.9293 * T) * 4.184 / 58.44; + + return ( (x1 * h1 + x2 * h2 + m * dh) * 1000.0 ); +} + +void calculateBrineEnthalpy( PTTableCoordinates const & tableCoords, + real64 const & m, + array1d< real64 > const & enthalpies ) +{ + + localIndex const nTemperatures = tableCoords.nTemperatures(); + + for( localIndex i = 0; i < nTemperatures; ++i ) + { + real64 const TC = tableCoords.getTemperature( i ); + enthalpies[i] = MichaelidesBrineEnthalpy( TC, m ); + } +} + +TableFunction const * makeCO2EnthalpyTable( string_array const & inputParams, + string const & functionName, + FunctionManager & functionManager ) +{ + string const tableName = functionName + "_CO2_enthalpy_table"; + + if( functionManager.hasGroup< TableFunction >( tableName ) ) + { + return functionManager.getGroupPointer< TableFunction >( tableName ); + } + else + { + // initialize the (p,T) coordinates + PTTableCoordinates tableCoords; + PVTFunctionHelpers::initializePropertyTable( inputParams, tableCoords ); + + real64 tolerance = 1e-10; + + try + { + if( inputParams.size() >= 10 ) + { + tolerance = stod( inputParams[9] ); + } + } + catch( const std::invalid_argument & e ) + { + GEOSX_THROW( GEOSX_FMT( "{}: invalid model parameter value: {}", functionName, e.what() ), InputError ); + } + + array1d< real64 > densities( tableCoords.nPressures() * tableCoords.nTemperatures() ); + array1d< real64 > enthalpies( tableCoords.nPressures() * tableCoords.nTemperatures() ); + + + SpanWagnerCO2Density::calculateCO2Density( tolerance, tableCoords, densities ); + + CO2Enthalpy::calculateCO2Enthalpy( tableCoords, densities, enthalpies ); + + TableFunction * const enthalpyTable = dynamicCast< TableFunction * >( functionManager.createChild( TableFunction::catalogName(), tableName ) ); + enthalpyTable->setTableCoordinates( tableCoords.getCoords() ); + enthalpyTable->setTableValues( enthalpies ); + enthalpyTable->setInterpolationMethod( TableFunction::InterpolationType::Linear ); + return enthalpyTable; + } +} + +TableFunction const * makeBrineEnthalpyTable( string_array const & inputParams, + string const & functionName, + FunctionManager & functionManager ) +{ + string const tableName = functionName + "_brine_enthalpy_table"; + + if( functionManager.hasGroup< TableFunction >( tableName ) ) + { + return functionManager.getGroupPointer< TableFunction >( tableName ); + } + else + { + // initialize the (p,T) coordinates + PTTableCoordinates tableCoords; + PVTFunctionHelpers::initializePropertyTable( inputParams, tableCoords ); + + // initialize salinity + GEOSX_THROW_IF_LT_MSG( inputParams.size(), 9, + GEOSX_FMT( "{}: insufficient number of model parameters", functionName ), + InputError ); + real64 salinity; + + try + { + salinity = stod( inputParams[8] ); + } + catch( std::invalid_argument const & e ) + { + GEOSX_THROW( GEOSX_FMT( "{}: invalid model parameter value: {}", functionName, e.what() ), InputError ); + } + + array1d< real64 > enthalpies( tableCoords.nTemperatures() ); + array1d< array1d< real64 > > temperatures; + temperatures.resize( 1 ); + temperatures[0] = tableCoords.getTemperatures(); + + calculateBrineEnthalpy( tableCoords, salinity, enthalpies ); + + + TableFunction * const enthalpyTable = dynamicCast< TableFunction * >( functionManager.createChild( TableFunction::catalogName(), tableName ) ); + enthalpyTable->setTableCoordinates( temperatures ); + enthalpyTable->setTableValues( enthalpies ); + enthalpyTable->setInterpolationMethod( TableFunction::InterpolationType::Linear ); + return enthalpyTable; + } +} + +} // namespace + +BrineEnthalpy::BrineEnthalpy( string const & name, + string_array const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ): + PVTFunctionBase( name, + componentNames, + componentMolarWeight ) +{ + string const expectedCO2ComponentNames[] = { "CO2", "co2" }; + m_CO2Index = PVTFunctionHelpers::findName( componentNames, expectedCO2ComponentNames, "componentNames" ); + + string const expectedWaterComponentNames[] = { "Water", "water" }; + m_waterIndex = PVTFunctionHelpers::findName( componentNames, expectedWaterComponentNames, "componentNames" ); + + m_CO2EnthalpyTable = makeCO2EnthalpyTable( inputParams, m_functionName, FunctionManager::getInstance() ); + m_brineEnthalpyTable = makeBrineEnthalpyTable( inputParams, m_functionName, FunctionManager::getInstance() ); +} + + + +BrineEnthalpy::KernelWrapper +BrineEnthalpy::createKernelWrapper() const +{ + return KernelWrapper( m_componentMolarWeight, + *m_CO2EnthalpyTable, + *m_brineEnthalpyTable, + m_CO2Index, + m_waterIndex ); +} + +REGISTER_CATALOG_ENTRY( PVTFunctionBase, BrineEnthalpy, string const &, string_array const &, string_array const &, array1d< real64 > const & ) + +} // namespace PVTProps + +} // namespace constitutive + +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp new file mode 100644 index 00000000000..1e5dea1866e --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp @@ -0,0 +1,234 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file BrineEnthalpy.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPY_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPY_HPP_ + +#include "PVTFunctionBase.hpp" + +#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" +#include "functions/TableFunction.hpp" + +namespace geosx +{ + +namespace constitutive +{ + +namespace PVTProps +{ + +class BrineEnthalpyUpdate final : public PVTFunctionBaseUpdate +{ +public: + + BrineEnthalpyUpdate( arrayView1d< real64 const > const & componentMolarWeight, + TableFunction const & CO2EnthalpyTable, + TableFunction const & brineEnthalpyTable, + integer const CO2Index, + integer const waterIndex ) + : PVTFunctionBaseUpdate( componentMolarWeight ), + m_CO2EnthalpyTable( CO2EnthalpyTable.createKernelWrapper() ), + m_brineEnthalpyTable( brineEnthalpyTable.createKernelWrapper() ), + m_CO2Index( CO2Index ), + m_waterIndex( waterIndex ) + {} + + template< int USD1 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const; + + template< int USD1, int USD2, int USD3, int USD4 > + 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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const; + + virtual void move( LvArray::MemorySpace const space, bool const touch ) override + { + PVTFunctionBaseUpdate::move( space, touch ); + m_CO2EnthalpyTable.move( space, touch ); + m_brineEnthalpyTable.move( space, touch ); + } + +protected: + + /// Table with CO2 enthalpy tabulated as a function of (P,T) + TableFunction::KernelWrapper m_CO2EnthalpyTable; + + /// Table with brine enthalpy tabulated as a function of (T) + TableFunction::KernelWrapper m_brineEnthalpyTable; + + /// Index of the CO2 component + integer m_CO2Index; + + /// Index of the water component + integer m_waterIndex; + +}; + +class BrineEnthalpy : public PVTFunctionBase +{ +public: + + BrineEnthalpy( string const & name, + string_array const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ); + + static string catalogName() { return "BrineEnthalpy"; } + + virtual string getCatalogName() const final { return catalogName(); } + + virtual PVTFunctionType functionType() const override + { + return PVTFunctionType::ENTHALPY; + } + + /// Type of kernel wrapper for in-kernel update + using KernelWrapper = BrineEnthalpyUpdate; + + /** + * @brief Create an update kernel wrapper. + * @return the wrapper + */ + KernelWrapper createKernelWrapper() const; + + +private: + + /// Table with CO2 enthalpy tabulated as a function of (P,T) + TableFunction const * m_CO2EnthalpyTable; + + /// Table with brine enthalpy tabulated as a function of (T) + TableFunction const * m_brineEnthalpyTable; + + /// Index of the CO2 phase + integer m_CO2Index; + + /// Index of the water phase + integer m_waterIndex; + +}; + +template< int USD1 > +GEOSX_HOST_DEVICE +void BrineEnthalpyUpdate::compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const +{ + real64 const input[2] = { pressure, temperature }; + real64 const brineEnthalpy = m_brineEnthalpyTable.compute( &temperature ); + real64 const CO2Enthalpy = m_CO2EnthalpyTable.compute( input ); + + + //assume there are only CO2 and brine here. + + real64 const C = phaseComposition[m_waterIndex]; + + real64 const waterMW = m_componentMolarWeight[m_waterIndex]; + real64 const CO2MW = m_componentMolarWeight[m_CO2Index]; + + if( useMass ) + { + value = (1.0 - C ) * CO2Enthalpy + C * brineEnthalpy; + } + else + { + value = (1.0 - C ) * CO2Enthalpy / CO2MW + C * brineEnthalpy / waterMW; + } +} + +template< int USD1, int USD2, int USD3, int USD4 > +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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const +{ + real64 const input[2] = { pressure, temperature }; + real64 brineEnthalpy_dTemperature; + real64 dvalue_dC; + 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; + + 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];; + } + else + { + real64 const waterMWInv = 1 / m_componentMolarWeight[m_waterIndex]; + real64 const CO2MWInv = 1 / 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_dGlobalCompFraction[m_CO2Index] = dvalue_dC * dPhaseComposition_dGlobalCompFraction[m_waterIndex][m_CO2Index]; + dValue_dGlobalCompFraction[m_waterIndex] = dvalue_dC * dPhaseComposition_dGlobalCompFraction[m_waterIndex][m_waterIndex]; +} + +} // end namespace PVTProps + +} // end namespace constitutive + +} // end namespace geosx + +#endif //GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEENTHALPY_HPP_ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.cpp new file mode 100644 index 00000000000..10b1b88e72d --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.cpp @@ -0,0 +1,44 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file BrineInternalEnergy.cpp + */ + +#include "constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp" + +namespace geosx +{ + +using namespace stringutilities; + +namespace constitutive +{ + +namespace PVTProps +{ + +BrineInternalEnergy::KernelWrapper +BrineInternalEnergy::createKernelWrapper() const +{ + return KernelWrapper( m_componentMolarWeight ); +} + +REGISTER_CATALOG_ENTRY( PVTFunctionBase, BrineInternalEnergy, string const &, string_array const &, string_array const &, array1d< real64 > const & ) + +} // namespace PVTProps + +} // namespace constitutive + +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp new file mode 100644 index 00000000000..458c006f5b9 --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp @@ -0,0 +1,160 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file BrineInternalEnergy.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGY_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGY_HPP_ + +#include "PVTFunctionBase.hpp" + +#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" +#include "functions/TableFunction.hpp" + +namespace geosx +{ + +namespace constitutive +{ + +namespace PVTProps +{ + +class BrineInternalEnergyUpdate final : public PVTFunctionBaseUpdate +{ +public: + + BrineInternalEnergyUpdate( arrayView1d< real64 const > const & componentMolarWeight ) + : PVTFunctionBaseUpdate( componentMolarWeight ) + {} + + template< int USD1 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const; + + template< int USD1, int USD2, int USD3, int USD4 > + 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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const; + + virtual void move( LvArray::MemorySpace const space, bool const touch ) override + { + PVTFunctionBaseUpdate::move( space, touch ); + } + +protected: + +}; + +class BrineInternalEnergy : public PVTFunctionBase +{ +public: + + BrineInternalEnergy( string const & name, + string_array const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ) + : PVTFunctionBase( name, + componentNames, + componentMolarWeight ) + { + // reserve for future: more accurate internal energy model should probably have some parameters + GEOSX_UNUSED_VAR ( inputParams ); + } + + static string catalogName() { return "BrineInternalEnergy"; } + + virtual string getCatalogName() const final { return catalogName(); } + + virtual PVTFunctionType functionType() const override + { + return PVTFunctionType::INTERNAL_ENERGY; + } + + /// Type of kernel wrapper for in-kernel update + using KernelWrapper = BrineInternalEnergyUpdate; + + /** + * @brief Create an update kernel wrapper. + * @return the wrapper + */ + KernelWrapper createKernelWrapper() const; + +private: + +}; + +template< int USD1 > +GEOSX_HOST_DEVICE +void BrineInternalEnergyUpdate::compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const +{ + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( useMass ); + + value = 0.001 * pressure + 1.0 * temperature; +} + +template< int USD1, int USD2, int USD3, int USD4 > +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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + 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 ); + + value = 0.001 * pressure + 1.0 * temperature; + dValue_dPressure = 0.001; + dValue_dTemperature = 1.0; + + LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); +} + +} // end namespace PVTProps + +} // end namespace constitutive + +} // end namespace geosx + +#endif //GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_BRINEINTERNALENERGY_HPP_ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.cpp new file mode 100644 index 00000000000..63d89fc4a2d --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.cpp @@ -0,0 +1,297 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CO2Enthalpy.cpp + */ + +#include "constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp" + +#include "functions/FunctionManager.hpp" +#include "constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp" + +namespace geosx +{ + +using namespace stringutilities; + +namespace constitutive +{ + +namespace PVTProps +{ + +namespace +{ + +real64 HelmholtzCO2Enthalpy( real64 const & T, + real64 const & rho ) +{ + static const real64 dc = 467.6; + static const real64 Tc = 304.128; + static const real64 a0[8] = {8.37304456, -3.70454304, 2.500, 1.99427042, 0.62105248, 0.41195293, 1.04028922, 0.08327678}; + + static const real64 theta0[8] = {0.0, 0.0, 0.0, 3.15163, 6.11190, 6.77708, 11.32384, 27.08792}; + + static const real64 ni[42] = {0.38856823203161, 2.938547594274, -5.5867188534934, -0.76753199592477, + 0.31729005580416, 0.54803315897767, 0.12279411220335, 2.165896154322, + 1.5841735109724, -0.23132705405503, 0.058116916431436, -0.55369137205382, + 0.48946615909422, -0.024275739843501, 0.062494790501678, -0.12175860225246, + -0.37055685270086, -0.016775879700426, -0.11960736637987, -0.045619362508778, + 0.035612789270346, -0.0074427727132052, -0.0017395704902432, -0.021810121289527, + 0.024332166559236, -0.037440133423463, 0.14338715756878, -0.13491969083286, + -0.02315122505348, 0.012363125492901, 0.002105832197294, -0.00033958519026368, + 0.0055993651771592, -0.00030335118055646, -213.6548868832, 26641.569149272, + -24027.212204557, -283.41603423999, 212.47284400179, -0.66642276540751, + 0.72608632349897, 0.055068668612842}; + + static const real64 di[42] = {1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0, 1.0, 2.0, 4.0, + 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 1.0, 1.0, 4.0, 4.0, + 4.0, 7.0, 8.0, 2.0, 3.0, 3.0, 5.0, 5.0, 6.0, 7.0, + 8.0, 10.0, 4.0, 8.0, 2.0, 2.0, 2.0, 3.0, 3.0, 0.0, + 0.0, 0.0}; + + static const real64 ti[42] = {0.00, 0.75, 1.00, 2.00, 0.75, 2.00, 0.75, 1.50, 1.50, 2.50, + 0.00, 1.50, 2.00, 0.00, 1.00, 2.00, 3.00, 6.00, 3.00, 6.00, + 8.00, 6.00, 0.00, 7.00, 12.00, 16.00, 22.00, 24.00, 16.0, 24.00, + 8.00, 2.00, 28.00, 14.00, 1.00, 0.00, 1.00, 3.00, 3.00, 0.00, + 0.00, 0.00}; + static const real64 ci[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, + 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, + 4.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0}; + + static const real64 alphai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 25.0, 25.0, 25.0, 15.0, 20.0, 0.0, + 0.0, 0.0}; + + static const real64 betai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 325.0, 300.0, 300.0, 275.0, 275.0, 0.3, + 0.3, 0.3}; + + static const real64 gammai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 1.16, 1.19, 1.19, 1.25, 1.22, 0.0, + 0.0, 0.0}; + static const real64 ei[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, + 0.0, 0.0}; + + static const real64 bi[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.875, + 0.925, 0.875}; + + static const real64 Ai[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.7, + 0.7, 0.7}; + + static const real64 Bi[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, + 0.3, 1.0}; + + static const real64 Ci[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 10.0, + 10.0, 12.5}; + + static const real64 Di[42] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 275.0, + 275.0, 275.0}; + + real64 rd, rt; + real64 Tkelvin; + + real64 phi0t; + real64 phirt, phird; + + real64 theta, delta, R, deltard; + + Tkelvin = T + 273.15; + rd=rho/dc; + rt=Tc/Tkelvin; + + phi0t = a0[1] + a0[2] / rt; + + for( localIndex i=3; i<8; i++ ) + { + phi0t += a0[i] * theta0[i] * (1.0 / (1.0 - exp( -rt * theta0[i] )) - 1.0); + + } + + phird = 0.0; + phirt = 0.0; + + for( localIndex i=0; i<7; i++ ) + { + + phird += ni[i] * di[i] * pow( rd, di[i] - 1.0 ) * pow( rt, ti[i] ); + + phirt += ni[i] * ti[i] * pow( rd, di[i] ) * pow( rt, ti[i] - 1.0 ); + + } + + + for( localIndex i=7; i<34; i++ ) + { + + phird += ni[i] * exp( -pow( rd, ci[i] )) * pow( rd, di[i]-1.0 ) * pow( rt, ti[i] ) * (di[i]-ci[i] * pow( rd, ci[i] )); + + phirt += ni[i] * ti[i] * pow( rd, di[i] ) * pow( rt, ti[i] - 1.0 ) * exp( -pow( rd, ci[i] )); + + } + + + for( localIndex i=34; i<39; i++ ) + { + + phird += ni[i] * pow( rd, di[i] ) * pow( rt, ti[i] ) * exp( -alphai[i] * pow( rd - ei[i], 2.0 ) - betai[i] * pow( rt - gammai[i], 2.0 )) * (di[i] / rd - 2.0 * alphai[i] * (rd - ei[i])); + + phirt += ni[i] * pow( rd, di[i] ) * pow( rt, ti[i] ) * exp( -alphai[i] * pow( rd - ei[i], 2.0 ) - betai[i] * pow( rt - gammai[i], 2.0 )) * (ti[i] / rt - 2.0 * betai[i] * (rt - gammai[i])); + + } + + for( localIndex i=39; i<42; i++ ) + { + + theta = (1.0 - rt) + Ai[i] * pow( pow( rd - 1.0, 2.0 ), (1.0 / (2.0 * betai[i]))); + delta = pow( theta, 2.0 ) + Bi[i] * pow( rd - 1.0, 2.0*alphai[i] ); + R = exp( -Ci[i] * pow( rd - 1.0, 2.0 ) - Di[i] * pow( rt - 1.0, 2.0 )); + deltard = (rd - 1.0) * (Ai[i] * theta * 2.0 / betai[i] * pow( pow( rd - 1.0, 2.0 ), 0.5 / betai[i] - 1.0 ) + 2.0 * Bi[i] * alphai[i] * pow( pow( rd - 1.0, 2.0 ), alphai[i] - 1.0 )); + + phird += ni[i] * (pow( delta, bi[i] ) * (R + rd *(-2.0 *Ci[i] * (rd - 1.0) * R)) + bi[i] * pow( delta, bi[i] - 1.0 ) * deltard * rd * R); + + phirt += ni[i] * rd *(-2.0 * theta * bi[i] * pow( delta, bi[i] - 1.0 ) * R + pow( delta, bi[i] ) * (-2.0 * Di[i] * R * (rt - 1.0))); + + } + + return (1.0 + rt * (phi0t + phirt) + rd * phird) * Tkelvin * 188.924; + +} + + + +TableFunction const * makeCO2EnthalpyTable( string_array const & inputParams, + string const & functionName, + FunctionManager & functionManager ) +{ + string const tableName = functionName + "_CO2_enthalpy_table"; + + if( functionManager.hasGroup< TableFunction >( tableName ) ) + { + return functionManager.getGroupPointer< TableFunction >( tableName ); + } + else + { + // initialize the (p,T) coordinates + PTTableCoordinates tableCoords; + PVTFunctionHelpers::initializePropertyTable( inputParams, tableCoords ); + + real64 tolerance = 1e-10; + + try + { + if( inputParams.size() >= 10 ) + { + tolerance = stod( inputParams[9] ); + } + } + catch( const std::invalid_argument & e ) + { + GEOSX_THROW( GEOSX_FMT( "{}: invalid model parameter value: {}", functionName, e.what() ), InputError ); + } + + array1d< real64 > densities( tableCoords.nPressures() * tableCoords.nTemperatures() ); + array1d< real64 > enthalpies( tableCoords.nPressures() * tableCoords.nTemperatures() ); + + + SpanWagnerCO2Density::calculateCO2Density( tolerance, tableCoords, densities ); + + CO2Enthalpy::calculateCO2Enthalpy( tableCoords, densities, enthalpies ); + + TableFunction * const enthalpyTable = dynamicCast< TableFunction * >( functionManager.createChild( TableFunction::catalogName(), tableName ) ); + enthalpyTable->setTableCoordinates( tableCoords.getCoords() ); + enthalpyTable->setTableValues( enthalpies ); + enthalpyTable->setInterpolationMethod( TableFunction::InterpolationType::Linear ); + return enthalpyTable; + } +} + +} // namespace + +CO2Enthalpy::CO2Enthalpy( string const & name, + string_array const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ): + PVTFunctionBase( name, + componentNames, + componentMolarWeight ) +{ + string const expectedCO2ComponentNames[] = { "CO2", "co2" }; + m_CO2Index = PVTFunctionHelpers::findName( componentNames, expectedCO2ComponentNames, "componentNames" ); + + m_CO2EnthalpyTable = makeCO2EnthalpyTable( inputParams, m_functionName, FunctionManager::getInstance() ); +} + + +void +CO2Enthalpy::calculateCO2Enthalpy( PTTableCoordinates const & tableCoords, + array1d< real64 > const & densities, + array1d< real64 > const & enthalpies ) +{ + localIndex const nPressures = tableCoords.nPressures(); + localIndex const nTemperatures = tableCoords.nTemperatures(); + + for( localIndex i = 0; i < nPressures; ++i ) + { + for( localIndex j = 0; j < nTemperatures; ++j ) + { + real64 const TC = tableCoords.getTemperature( j ); + enthalpies[j*nPressures+i] = HelmholtzCO2Enthalpy( TC, densities[j*nPressures+i] ); + } + } +} + + +CO2Enthalpy::KernelWrapper +CO2Enthalpy::createKernelWrapper() const +{ + return KernelWrapper( m_componentMolarWeight, + *m_CO2EnthalpyTable, + m_CO2Index ); +} + +REGISTER_CATALOG_ENTRY( PVTFunctionBase, CO2Enthalpy, string const &, string_array const &, string_array const &, array1d< real64 > const & ) + +} // namespace PVTProps + +} // namespace constitutive + +} // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp new file mode 100644 index 00000000000..e34ed51283c --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp @@ -0,0 +1,192 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CO2Enthalpy.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2ENTHALPY_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2ENTHALPY_HPP_ + +#include "PVTFunctionBase.hpp" + +#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" +#include "functions/TableFunction.hpp" + +namespace geosx +{ + +namespace constitutive +{ + +namespace PVTProps +{ + +class CO2EnthalpyUpdate final : public PVTFunctionBaseUpdate +{ +public: + + CO2EnthalpyUpdate( arrayView1d< real64 const > const & componentMolarWeight, + TableFunction const & CO2EnthalpyTable, + integer const CO2Index ) + : PVTFunctionBaseUpdate( componentMolarWeight ), + m_CO2EnthalpyTable( CO2EnthalpyTable.createKernelWrapper() ), + m_CO2Index( CO2Index ) + {} + + template< int USD1 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const; + + template< int USD1, int USD2, int USD3, int USD4 > + 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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const; + + virtual void move( LvArray::MemorySpace const space, bool const touch ) override + { + PVTFunctionBaseUpdate::move( space, touch ); + m_CO2EnthalpyTable.move( space, touch ); + } + +protected: + + /// Table with CO2 enthalpy tabulated as a function of (P,T) + TableFunction::KernelWrapper m_CO2EnthalpyTable; + + /// Index of the CO2 component + integer m_CO2Index; +}; + +class CO2Enthalpy : public PVTFunctionBase +{ +public: + + CO2Enthalpy( string const & name, + string_array const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ); + + static string catalogName() { return "CO2Enthalpy"; } + + virtual string getCatalogName() const final { return catalogName(); } + + virtual PVTFunctionType functionType() const override + { + return PVTFunctionType::ENTHALPY; + } + + /// Type of kernel wrapper for in-kernel update + using KernelWrapper = CO2EnthalpyUpdate; + + /** + * @brief Create an update kernel wrapper. + * @return the wrapper + */ + KernelWrapper createKernelWrapper() const; + + static void calculateCO2Enthalpy( PTTableCoordinates const & tableCoords, + array1d< real64 > const & densities, + array1d< real64 > const & enthalpies ); + + +private: + + /// Table with CO2 enthalpy tabulated as a function of (P,T) + TableFunction const * m_CO2EnthalpyTable; + + /// Index of the CO2 phase + integer m_CO2Index; +}; + +template< int USD1 > +GEOSX_HOST_DEVICE +void CO2EnthalpyUpdate::compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const +{ + GEOSX_UNUSED_VAR( phaseComposition ); + real64 const input[2] = { pressure, temperature }; + + + value = m_CO2EnthalpyTable.compute( input ); + + if( !useMass ) + { + value /= m_componentMolarWeight[m_CO2Index]; + } +} + +template< int USD1, int USD2, int USD3, int USD4 > +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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const +{ + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( dPhaseComposition_dPressure ); + GEOSX_UNUSED_VAR( dPhaseComposition_dTemperature ); + GEOSX_UNUSED_VAR( dPhaseComposition_dGlobalCompFraction ); + + + real64 const input[2] = { pressure, temperature }; + real64 CO2EnthalpyDeriv[2]; + + + dValue_dPressure = 0; + value = m_CO2EnthalpyTable.compute( input, CO2EnthalpyDeriv ); + dValue_dPressure = CO2EnthalpyDeriv[0]; + dValue_dTemperature = CO2EnthalpyDeriv[1]; + + if( !useMass ) + { + real64 const CO2MWInv = 1 / m_componentMolarWeight[m_CO2Index]; + value *= CO2MWInv; + dValue_dPressure *= CO2MWInv; + dValue_dTemperature *= CO2MWInv; + } + + LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); +} + +} // end namespace PVTProps + +} // end namespace constitutive + +} // end namespace geosx + +#endif //GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2ENTHALPY_HPP_ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.cpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.cpp similarity index 57% rename from src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.cpp rename to src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.cpp index d1f01a0c44d..fc78a187634 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.cpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.cpp @@ -13,15 +13,32 @@ */ /** - * @file SinglePhaseBaseKernels.cpp + * @file CO2InternalEnergy.cpp */ -#include "SinglePhaseBaseKernels.hpp" +#include "constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp" namespace geosx { -namespace SinglePhaseBaseKernels -{} // namespace SinglePhaseBaseKernels +using namespace stringutilities; + +namespace constitutive +{ + +namespace PVTProps +{ + +CO2InternalEnergy::KernelWrapper +CO2InternalEnergy::createKernelWrapper() const +{ + return KernelWrapper( m_componentMolarWeight ); +} + +REGISTER_CATALOG_ENTRY( PVTFunctionBase, CO2InternalEnergy, string const &, string_array const &, string_array const &, array1d< real64 > const & ) + +} // namespace PVTProps + +} // namespace constitutive } // namespace geosx diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp new file mode 100644 index 00000000000..003006e0e2f --- /dev/null +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp @@ -0,0 +1,160 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CO2InternalEnergy.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2INTERNALENERGY_HPP_ +#define GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2INTERNALENERGY_HPP_ + +#include "PVTFunctionBase.hpp" + +#include "constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp" +#include "functions/TableFunction.hpp" + +namespace geosx +{ + +namespace constitutive +{ + +namespace PVTProps +{ + +class CO2InternalEnergyUpdate final : public PVTFunctionBaseUpdate +{ +public: + + CO2InternalEnergyUpdate( arrayView1d< real64 const > const & componentMolarWeight ) + : PVTFunctionBaseUpdate( componentMolarWeight ) + {} + + template< int USD1 > + GEOSX_HOST_DEVICE + void compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const; + + template< int USD1, int USD2, int USD3, int USD4 > + 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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + bool useMass ) const; + + virtual void move( LvArray::MemorySpace const space, bool const touch ) override + { + PVTFunctionBaseUpdate::move( space, touch ); + } + +protected: + +}; + +class CO2InternalEnergy : public PVTFunctionBase +{ +public: + + CO2InternalEnergy( string const & name, + string_array const & inputParams, + string_array const & componentNames, + array1d< real64 > const & componentMolarWeight ) + : PVTFunctionBase( name, + componentNames, + componentMolarWeight ) + { + // reserve for future: more accurate internal energy model should probably have some parameters + GEOSX_UNUSED_VAR ( inputParams ); + } + + static string catalogName() { return "CO2InternalEnergy"; } + + virtual string getCatalogName() const final { return catalogName(); } + + virtual PVTFunctionType functionType() const override + { + return PVTFunctionType::INTERNAL_ENERGY; + } + + /// Type of kernel wrapper for in-kernel update + using KernelWrapper = CO2InternalEnergyUpdate; + + /** + * @brief Create an update kernel wrapper. + * @return the wrapper + */ + KernelWrapper createKernelWrapper() const; + +private: + +}; + +template< int USD1 > +GEOSX_HOST_DEVICE +void CO2InternalEnergyUpdate::compute( real64 const & pressure, + real64 const & temperature, + arraySlice1d< real64 const, USD1 > const & phaseComposition, + real64 & value, + bool useMass ) const +{ + GEOSX_UNUSED_VAR( phaseComposition ); + GEOSX_UNUSED_VAR( useMass ); + + value = 0.001 * pressure + 1.0 * temperature; +} + +template< int USD1, int USD2, int USD3, int USD4 > +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, + real64 & value, + real64 & dValue_dPressure, + real64 & dValue_dTemperature, + arraySlice1d< real64, USD4 > const & dValue_dGlobalCompFraction, + 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 ); + + value = 0.001 * pressure + 1.0 * temperature; + dValue_dPressure = 0.001; + dValue_dTemperature = 1.0; + + LvArray::forValuesInSlice( dValue_dGlobalCompFraction, []( real64 & val ){ val = 0.0; } ); +} + +} // end namespace PVTProps + +} // end namespace constitutive + +} // end namespace geosx + +#endif //GEOSX_CONSTITUTIVE_FLUID_PVTFUNCTIONS_CO2INTERNALENERGY_HPP_ diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp index 73e2349ec0d..4968b9c7169 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionBase.hpp @@ -30,7 +30,7 @@ namespace constitutive namespace PVTProps { -enum class PVTFunctionType { UNKNOWN, DENSITY, VISCOSITY }; +enum class PVTFunctionType { UNKNOWN, DENSITY, VISCOSITY, ENTHALPY, INTERNAL_ENERGY}; class PVTFunctionBaseUpdate { diff --git a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp index 90421d1b22c..8e05dabde2e 100644 --- a/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp +++ b/src/coreComponents/constitutive/fluid/PVTFunctions/PVTFunctionHelpers.hpp @@ -127,6 +127,9 @@ class PTTableCoordinates real64 const & getPressure( localIndex i ) const { return coords[coordType::PRES][i]; } real64 const & getTemperature( localIndex i ) const { return coords[coordType::TEMP][i]; } + array1d< real64 > const & getPressures( ) const { return coords[coordType::PRES]; } + array1d< real64 > const & getTemperatures( ) const { return coords[coordType::TEMP]; } + array1d< array1d< real64 > > const & getCoords() const { return coords; } private: diff --git a/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.cpp b/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.cpp index 9da218c4a04..a15e3a2679d 100644 --- a/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.cpp +++ b/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.cpp @@ -17,6 +17,7 @@ */ #include "RelativePermeabilityBase.hpp" +#include "RelativePermeabilityExtrinsicData.hpp" namespace geosx { @@ -39,8 +40,9 @@ RelativePermeabilityBase::RelativePermeabilityBase( string const & name, Group * registerWrapper( viewKeyStruct::phaseOrderString(), &m_phaseOrder ). setSizedFromParent( 0 ); - registerWrapper( viewKeyStruct::phaseRelPermString(), &m_phaseRelPerm ).setPlotLevel( PlotLevel::LEVEL_0 ); - registerWrapper( viewKeyStruct::dPhaseRelPerm_dPhaseVolFractionString(), &m_dPhaseRelPerm_dPhaseVolFrac ); + registerExtrinsicData( extrinsicMeshData::relperm::phaseRelPerm{}, &m_phaseRelPerm ); + registerExtrinsicData( extrinsicMeshData::relperm::dPhaseRelPerm_dPhaseVolFraction{}, &m_dPhaseRelPerm_dPhaseVolFrac ); + } void RelativePermeabilityBase::postProcessInput() @@ -92,7 +94,7 @@ void RelativePermeabilityBase::resizeFields( localIndex const size, localIndex c void RelativePermeabilityBase::setLabels() { - getWrapper< array3d< real64, relperm::LAYOUT_RELPERM > >( viewKeyStruct::phaseRelPermString() ). + getExtrinsicData< extrinsicMeshData::relperm::phaseRelPerm >(). setDimLabels( 2, m_phaseNames ); } diff --git a/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.hpp b/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.hpp index 1e62821d633..933afcbd29f 100644 --- a/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.hpp +++ b/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityBase.hpp @@ -26,6 +26,7 @@ namespace geosx { + namespace constitutive { @@ -138,9 +139,6 @@ class RelativePermeabilityBase : public ConstitutiveBase static constexpr char const * phaseNamesString() { return "phaseNames"; } static constexpr char const * phaseTypesString() { return "phaseTypes"; } static constexpr char const * phaseOrderString() { return "phaseOrder"; } - - static constexpr char const * phaseRelPermString() { return "phaseRelPerm"; } // Kr - static constexpr char const * dPhaseRelPerm_dPhaseVolFractionString() { return "dPhaseRelPerm_dPhaseVolFraction"; } // dKr_p/dS_p }; private: diff --git a/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp b/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp new file mode 100644 index 00000000000..5bb74867d9d --- /dev/null +++ b/src/coreComponents/constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp @@ -0,0 +1,59 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file RelativePermeabilityExtrinsicData.hpp + */ + +#ifndef GEOSX_CONSTITUTIVE_RELATIVEPERMEABILITY_RELATIVEPERMEABILITYEXTRINSICDATA_HPP_ +#define GEOSX_CONSTITUTIVE_RELATIVEPERMEABILITY_RELATIVEPERMEABILITYEXTRINSICDATA_HPP_ + +#include "constitutive/relativePermeability/layouts.hpp" +#include "mesh/ExtrinsicMeshData.hpp" + +namespace geosx +{ + +namespace extrinsicMeshData +{ + +namespace relperm +{ + +using array3dLayoutRelPerm = array3d< real64, constitutive::relperm::LAYOUT_RELPERM >; +using array4dLayoutRelPerm_dS = array4d< real64, constitutive::relperm::LAYOUT_RELPERM_DS >; + +EXTRINSIC_MESH_DATA_TRAIT( phaseRelPerm, + "phaseRelPerm", + array3dLayoutRelPerm, + 0, + LEVEL_0, + WRITE_AND_READ, + "Phase relative permeability" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseRelPerm_dPhaseVolFraction, + "dPhaseRelPerm_dPhaseVolFraction", + array4dLayoutRelPerm_dS, + 0, + NOPLOT, + WRITE_AND_READ, + "Derivative of phase relative permeability with respect to phase volume fraction" ); + +} + +} + +} + +#endif // GEOSX_CONSTITUTIVE_RELATIVEPERMEABILITY_RELATIVEPERMEABILITYEXTRINSICDATA_HPP_ diff --git a/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp b/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp index 27ff621dd44..e89db4ed472 100644 --- a/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp +++ b/src/coreComponents/fieldSpecification/FieldSpecificationBase.cpp @@ -80,6 +80,7 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par setInputFlag( InputFlags::OPTIONAL ). setDescription( "Time at which the boundary condition will stop being applied." ); + enableLogLevelInput(); } diff --git a/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst b/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst index 33afcef2f09..7752ed84863 100644 --- a/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst +++ b/src/coreComponents/fieldSpecification/docs/FieldSpecification.rst @@ -3,10 +3,10 @@ Initial and Boundary Conditions ================================== -.. toctree: +.. toctree:: :maxdepth: 1 - EquilibriumInitialCondition + EquilibriumInitialCondition AquiferBoundaryCondition diff --git a/src/coreComponents/mesh/ElementRegionManager.hpp b/src/coreComponents/mesh/ElementRegionManager.hpp index 559c7832a5d..c7f8eecbd6c 100644 --- a/src/coreComponents/mesh/ElementRegionManager.hpp +++ b/src/coreComponents/mesh/ElementRegionManager.hpp @@ -819,6 +819,23 @@ class ElementRegionManager : public ObjectManagerBase constructFullMaterialViewAccessor( string const & viewName, constitutive::ConstitutiveManager const & cm ); + /** + * @brief This is a const function to construct a MaterialViewAccessor to access the material data for specified + * regions/materials. + * @tparam TRAIT mesh data trait + * @param regionNames list of region names + * @param materialNames list of corresponding material names + * @param allowMissingViews flag to indicate whether it is allowed to miss the specified material data in material + * list + * @return ElementViewAccessor that contains traits::ViewTypeConst< typename TRAIT::type > data + */ + template< typename TRAIT > + ElementViewAccessor< traits::ViewTypeConst< typename TRAIT::type > > + constructMaterialExtrinsicAccessor( arrayView1d< string const > const & regionNames, + arrayView1d< string const > const & materialNames, + bool const allowMissingViews = false ) const; + + /** * @brief This is a const function to construct a MaterialViewAccessor to access the material data for specified * regions/materials. @@ -1413,6 +1430,21 @@ ElementRegionManager::constructMaterialViewAccessor( string const & viewName, return accessor; } +template< typename TRAIT > +ElementRegionManager::ElementViewAccessor< traits::ViewTypeConst< typename TRAIT::type > > +ElementRegionManager:: + constructMaterialExtrinsicAccessor( arrayView1d< string const > const & regionNames, + arrayView1d< string const > const & materialNames, + bool const allowMissingViews ) const +{ + return constructMaterialViewAccessor< typename TRAIT::type, + traits::ViewTypeConst< typename TRAIT::type > >( TRAIT::key(), + regionNames, + materialNames, + allowMissingViews ); +} + + template< typename T, int NDIM, typename PERM > ElementRegionManager::ElementViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > ElementRegionManager:: diff --git a/src/coreComponents/mesh/ExtrinsicMeshData.hpp b/src/coreComponents/mesh/ExtrinsicMeshData.hpp index 42790d05df5..85b8cecf703 100644 --- a/src/coreComponents/mesh/ExtrinsicMeshData.hpp +++ b/src/coreComponents/mesh/ExtrinsicMeshData.hpp @@ -53,8 +53,9 @@ using type = TYPE; \ /** The template type T for registration of a container. */ \ using dataType = internal::typeHelper_t< TYPE >; \ - /** The dataRepository::DefaultValue for NAME. */ \ - static constexpr dataType defaultValue = DEFAULT; \ + /** @brief @return The default data value for NAME. */ \ + static constexpr dataType defaultValue() \ + { return DEFAULT; } \ /** The default dataRepository::PlotLevel for NAME. */ \ static constexpr dataRepository::PlotLevel plotLevel = dataRepository::PlotLevel::PLOTLEVEL; \ /** The default dataRepository::RestartFlags for NAME. */ \ diff --git a/src/coreComponents/mesh/ObjectManagerBase.hpp b/src/coreComponents/mesh/ObjectManagerBase.hpp index 9fcf12fa7c7..68106300bbe 100644 --- a/src/coreComponents/mesh/ObjectManagerBase.hpp +++ b/src/coreComponents/mesh/ObjectManagerBase.hpp @@ -578,7 +578,7 @@ class ObjectManagerBase : public dataRepository::Group //constexpr typename MESH_DATA_TRAIT::DataType defaultValue = MESH_DATA_TRAIT::defaultValue; // This is required for the Tensor classes. - typename MESH_DATA_TRAIT::dataType defaultValue( MESH_DATA_TRAIT::defaultValue ); + typename MESH_DATA_TRAIT::dataType defaultValue( MESH_DATA_TRAIT::defaultValue() ); return this->registerWrapper< typename MESH_DATA_TRAIT::type >( MESH_DATA_TRAIT::key() ). setApplyDefaultValue( defaultValue ). @@ -648,7 +648,7 @@ class ObjectManagerBase : public dataRepository::Group template< typename MESH_DATA_TRAIT > dataRepository::Wrapper< typename MESH_DATA_TRAIT::Type > & registerExtrinsicData( string const & nameOfRegisteringObject, - MESH_DATA_TRAIT const & extrinisicDataTrait ) + MESH_DATA_TRAIT const & extrinsicDataTrait ) { // These are required to work-around the need for instantiation of // the static constexpr trait components. This will not be required once @@ -659,9 +659,9 @@ class ObjectManagerBase : public dataRepository::Group string const description = MESH_DATA_TRAIT::description; // This is required for the Tensor classes. - typename MESH_DATA_TRAIT::DataType defaultValue( MESH_DATA_TRAIT::defaultValue ); + typename MESH_DATA_TRAIT::DataType defaultValue( MESH_DATA_TRAIT::defaultValue() ); - return *(this->registerWrapper< typename MESH_DATA_TRAIT::Type >( extrinisicDataTrait.viewKey ). + return *(this->registerWrapper< typename MESH_DATA_TRAIT::type >( extrinsicDataTrait.key() ). setApplyDefaultValue( defaultValue ). setPlotLevel( plotLevel ). setDescription( description ). @@ -670,27 +670,27 @@ class ObjectManagerBase : public dataRepository::Group template< typename MESH_DATA_TRAIT0, typename MESH_DATA_TRAIT1, typename ... MESH_DATA_TRAITS > void registerExtrinsicData( string const & nameOfRegisteringObject, - MESH_DATA_TRAIT0 const & extrinisicDataTrait0, - MESH_DATA_TRAIT1 const & extrinisicDataTrait1, - MESH_DATA_TRAITS && ... extrinisicDataTraits ) + MESH_DATA_TRAIT0 const & extrinsicDataTrait0, + MESH_DATA_TRAIT1 const & extrinsicDataTrait1, + MESH_DATA_TRAITS && ... extrinsicDataTraits ) { - registerExtrinsicData< MESH_DATA_TRAIT0 >( nameOfRegisteringObject, extrinisicDataTrait0 ); + registerExtrinsicData< MESH_DATA_TRAIT0 >( nameOfRegisteringObject, extrinsicDataTrait0 ); registerExtrinsicData< MESH_DATA_TRAIT1, MESH_DATA_TRAITS... >( nameOfRegisteringObject, - extrinisicDataTrait1, - std::forward< MESH_DATA_TRAITS >( extrinisicDataTraits )... ); + extrinsicDataTrait1, + std::forward< MESH_DATA_TRAITS >( extrinsicDataTraits )... ); } template< typename MESH_DATA_TRAIT > - auto const & getExtrinsicData( MESH_DATA_TRAIT const & extrinisicDataTrait ) const + auto const & getExtrinsicData( MESH_DATA_TRAIT const & extrinsicDataTrait ) const { - return this->getWrapper< typename MESH_DATA_TRAIT::Type >( extrinisicDataTrait.viewKey ).referenceAsView(); + return this->getWrapper< typename MESH_DATA_TRAIT::type >( extrinsicDataTrait.key() ).referenceAsView(); } template< typename MESH_DATA_TRAIT > - auto & getExtrinsicData( MESH_DATA_TRAIT const & extrinisicDataTrait ) + auto & getExtrinsicData( MESH_DATA_TRAIT const & extrinsicDataTrait ) { - return this->getWrapper< typename MESH_DATA_TRAIT::Type >( extrinisicDataTrait.viewKey ).referenceAsView(); + return this->getWrapper< typename MESH_DATA_TRAIT::type >( extrinsicDataTrait.key() ).referenceAsView(); } #endif diff --git a/src/coreComponents/mesh/generators/PAMELAMeshGenerator.cpp b/src/coreComponents/mesh/generators/PAMELAMeshGenerator.cpp index 7d59956be81..551611197f6 100644 --- a/src/coreComponents/mesh/generators/PAMELAMeshGenerator.cpp +++ b/src/coreComponents/mesh/generators/PAMELAMeshGenerator.cpp @@ -22,6 +22,7 @@ #include "common/TypeDispatch.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/MeshBody.hpp" +#include "mesh/mpiCommunications/CommunicationTools.hpp" // PAMELA includes #include "Elements/Element.hpp" @@ -382,11 +383,8 @@ void importRegularField( PAMELA::VariableDouble & source, GEOSX_ERROR_IF_NE_MSG( numComponentsDst, numComponentsSrc, objectName << ": mismatch in number of components for field " << source.Label ); - // Sanity check, shouldn't happen - GEOSX_ERROR_IF_NE_MSG( view.size( 0 ), LvArray::integerConversion< localIndex >( indexMap.size() ), - objectName << ": mismatch in size for field " << source.Label ); - - for( int i = 0; i < view.size( 0 ); ++i ) + // the assumption here is that before this step, GEOSX has added ghost elements **at the end** of the view + for( localIndex i = 0; i < LvArray::integerConversion< localIndex >( indexMap.size() ); ++i ) { // get_data() currently returns a new vector for each cell, but auto const & makes sure // this code keeps working if/when PAMELA is fixed to return a more reasonable type (span/pointer) @@ -418,11 +416,8 @@ void importMaterialField( PAMELA::VariableDouble & source, GEOSX_ERROR_IF_NE_MSG( numComponentsDst, numComponentsSrc, objectName << ": mismatch in number of components for field " << source.Label ); - // Sanity check, shouldn't happen - GEOSX_ERROR_IF_NE_MSG( view.size( 0 ), LvArray::integerConversion< localIndex >( indexMap.size() ), - objectName << ": mismatch in size for field " << source.Label ); - - for( int i = 0; i < view.size( 0 ); ++i ) + // the assumption here is that before this step, GEOSX has added ghost elements **at the end** of the view + for( localIndex i = 0; i < LvArray::integerConversion< localIndex >( indexMap.size() ); ++i ) { // get_data() currently returns a new vector for each cell, but auto const & makes sure // this code keeps working if/when PAMELA is fixed to return a more reasonable type (span/pointer) @@ -513,6 +508,19 @@ void PAMELAMeshGenerator::importFields( DomainPartition & domain ) const } } } ); + + // this is needed to avoid breaking the unit test testPamelaImport, in which CommunicationTools is not setup + if( MpiWrapper::commSize( MPI_COMM_GEOSX ) > 1 ) + { + std::map< string, string_array > fieldNames; + for( localIndex fieldIndex = 0; fieldIndex < m_fieldsToImport.size(); fieldIndex++ ) + { + string const & wrapperName = m_fieldNamesInGEOSX[fieldIndex]; + fieldNames["elems"].emplace_back( wrapperName ); + } + CommunicationTools::getInstance().synchronizeFields( fieldNames, domain.getMeshBody( this->getName() ).getMeshLevel( 0 ), domain.getNeighbors(), false ); + } + } REGISTER_CATALOG_ENTRY( MeshGeneratorBase, PAMELAMeshGenerator, string const &, Group * const ) diff --git a/src/coreComponents/physicsSolvers/CMakeLists.txt b/src/coreComponents/physicsSolvers/CMakeLists.txt index 49d7d5c7ebc..31bff0aa1ec 100644 --- a/src/coreComponents/physicsSolvers/CMakeLists.txt +++ b/src/coreComponents/physicsSolvers/CMakeLists.txt @@ -7,6 +7,7 @@ set( physicsSolvers_headers PhysicsSolverManager.hpp SolverBase.hpp fluidFlow/CompositionalMultiphaseBase.hpp + fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp fluidFlow/CompositionalMultiphaseFVM.hpp @@ -16,15 +17,17 @@ set( physicsSolvers_headers fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp fluidFlow/CompositionalMultiphaseUtilities.hpp fluidFlow/FlowSolverBase.hpp + fluidFlow/FlowSolverBaseExtrinsicData.hpp fluidFlow/FluxKernelsHelper.hpp fluidFlow/HybridFVMHelperKernels.hpp fluidFlow/proppantTransport/ProppantTransport.hpp fluidFlow/proppantTransport/ProppantTransportKernels.hpp fluidFlow/SinglePhaseBase.hpp + fluidFlow/SinglePhaseBaseExtrinsicData.hpp fluidFlow/SinglePhaseBaseKernels.hpp fluidFlow/SinglePhaseFVM.hpp fluidFlow/SinglePhaseFVMKernels.hpp - fluidFlow/SinglePhaseHybridFVM.hpp + fluidFlow/SinglePhaseHybridFVM.hpp fluidFlow/SinglePhaseHybridFVMKernels.hpp fluidFlow/SinglePhaseProppantBase.hpp fluidFlow/SinglePhaseProppantBaseKernels.hpp @@ -83,9 +86,8 @@ set( physicsSolvers_sources PhysicsSolverManager.cpp SolverBase.cpp fluidFlow/CompositionalMultiphaseBase.cpp - fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.cpp - fluidFlow/ThermalCompositionalMultiphaseBaseKernels.cpp - fluidFlow/CompositionalMultiphaseFVM.cpp + fluidFlow/ThermalCompositionalMultiphaseBaseKernels.cpp + fluidFlow/CompositionalMultiphaseFVM.cpp fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.cpp fluidFlow/ThermalCompositionalMultiphaseFVMKernels.cpp fluidFlow/CompositionalMultiphaseHybridFVM.cpp @@ -94,7 +96,6 @@ set( physicsSolvers_sources fluidFlow/proppantTransport/ProppantTransport.cpp fluidFlow/proppantTransport/ProppantTransportKernels.cpp fluidFlow/SinglePhaseBase.cpp - fluidFlow/SinglePhaseBaseKernels.cpp fluidFlow/SinglePhaseFVM.cpp fluidFlow/SinglePhaseHybridFVM.cpp fluidFlow/SinglePhaseProppantBase.cpp diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index b06f7f18f32..74114003638 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -21,16 +21,22 @@ #include "common/DataTypes.hpp" #include "common/TimingMacros.hpp" #include "constitutive/ConstitutiveManager.hpp" +#include "constitutive/capillaryPressure/CapillaryPressureExtrinsicData.hpp" #include "constitutive/capillaryPressure/capillaryPressureSelector.hpp" #include "constitutive/ConstitutivePassThru.hpp" +#include "constitutive/fluid/MultiFluidExtrinsicData.hpp" #include "constitutive/fluid/multiFluidSelector.hpp" +#include "constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp" #include "constitutive/relativePermeability/relativePermeabilitySelector.hpp" #include "constitutive/solid/SolidBase.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" -#include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/EquilibriumInitialCondition.hpp" +#include "fieldSpecification/FieldSpecificationManager.hpp" +#include "fieldSpecification/SourceFluxBoundaryCondition.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" #include "physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp" @@ -114,6 +120,8 @@ void CompositionalMultiphaseBase::postProcessInput() void CompositionalMultiphaseBase::registerDataOnMesh( Group & meshBodies ) { + using namespace extrinsicMeshData::flow; + FlowSolverBase::registerDataOnMesh( meshBodies ); DomainPartition const & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" ); @@ -139,111 +147,83 @@ void CompositionalMultiphaseBase::registerDataOnMesh( Group & meshBodies ) { MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::pressureString() ). - setPlotLevel( PlotLevel::LEVEL_0 ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::initialPressureString() ); + subRegion.registerExtrinsicData< pressure >( getName() ); + subRegion.registerExtrinsicData< initialPressure >( getName() ); + subRegion.registerExtrinsicData< deltaPressure >( getName() ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); - - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::bcPressureString() ); + subRegion.registerExtrinsicData< bcPressure >( getName() ); // these fields are always registered for the evaluation of the fluid properties - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString() ). - setPlotLevel( PlotLevel::LEVEL_0 ); - - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.registerExtrinsicData< temperature >( getName() ); + subRegion.registerExtrinsicData< deltaTemperature >( getName() ); // The resizing of the arrays needs to happen here, before the call to initializePreSubGroups, // to make sure that the dimensions are properly set before the timeHistoryOutput starts its initialization. - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). + subRegion.registerExtrinsicData< globalCompDensity >( getName() ). setDimLabels( 1, fluid.componentNames() ). reference().resizeDimension< 1 >( m_numComponents ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< deltaGlobalCompDensity >( getName() ). reference().resizeDimension< 1 >( m_numComponents ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). + subRegion.registerExtrinsicData< globalCompFraction >( getName() ). setDimLabels( 1, fluid.componentNames() ). reference().resizeDimension< 1 >( m_numComponents ); - subRegion.registerWrapper< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dGlobalCompFraction_dGlobalCompDensity >( getName() ). reference().resizeDimension< 1, 2 >( m_numComponents, m_numComponents ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). + subRegion.registerExtrinsicData< phaseVolumeFraction >( getName() ). setDimLabels( 1, fluid.phaseNames() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dPhaseVolumeFraction_dPressure >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dPhaseVolumeFraction_dGlobalCompDensity >( getName() ). reference().resizeDimension< 1, 2 >( m_numPhases, m_numComponents ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseMobilityString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). + subRegion.registerExtrinsicData< phaseMobility >( getName() ). setDimLabels( 1, fluid.phaseNames() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseMobility_dPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dPhaseMobility_dPressure >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseMobility_dGlobalCompDensityString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dPhaseMobility_dGlobalCompDensity >( getName() ). reference().resizeDimension< 1, 2 >( m_numPhases, m_numComponents ); if( !m_isothermalFlag ) { - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dPhaseVolumeFraction_dTemperature >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseMobility_dTemperatureString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< dPhaseMobility_dTemperature >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseInternalEnergyOldString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< phaseInternalEnergyOld >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); } if( m_computeCFLNumbers ) { - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseOutfluxString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< phaseOutflux >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::componentOutfluxString() ). - setRestartFlags( RestartFlags::NO_WRITE ). + subRegion.registerExtrinsicData< componentOutflux >( getName() ). reference().resizeDimension< 1 >( m_numComponents ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::phaseCFLNumberString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). - setRestartFlags( RestartFlags::NO_WRITE ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::componentCFLNumberString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.registerExtrinsicData< phaseCFLNumber >( getName() ); + subRegion.registerExtrinsicData< componentCFLNumber >( getName() ); } - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionOldString() ). + subRegion.registerExtrinsicData< phaseVolumeFractionOld >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::totalDensityOldString() ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseDensityOldString() ). + subRegion.registerExtrinsicData< totalDensityOld >( getName() ); + subRegion.registerExtrinsicData< phaseDensityOld >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseMobilityOldString() ). + subRegion.registerExtrinsicData< phaseMobilityOld >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); - subRegion.registerWrapper< array3d< real64, compflow::LAYOUT_PHASE_COMP > >( viewKeyStruct::phaseComponentFractionOldString() ). + subRegion.registerExtrinsicData< phaseComponentFractionOld >( getName() ). reference().resizeDimension< 1, 2 >( m_numPhases, m_numComponents ); } ); FaceManager & faceManager = mesh.getFaceManager(); { - faceManager.registerWrapper< array1d< real64 > >( viewKeyStruct::facePressureString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). - setRegisteringObjects( this->getName() ). - setDescription( "An array that holds the pressures at the faces." ); + faceManager.registerExtrinsicData< facePressure >( getName() ); } } ); @@ -382,7 +362,7 @@ void CompositionalMultiphaseBase::initializePreSubGroups() // 3. Set the value of temperature forTargetSubRegions( meshLevel, [&]( localIndex const, ElementSubRegionBase & subRegion ) { - arrayView1d< real64 > const temp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + arrayView1d< real64 > const temp = subRegion.getExtrinsicData< extrinsicMeshData::flow::temperature >(); temp.setValues< parallelHostPolicy >( m_inputTemperature ); } ); } @@ -392,135 +372,54 @@ void CompositionalMultiphaseBase::initializePreSubGroups() validateAquiferBC( cm ); } -void CompositionalMultiphaseBase::updateComponentFraction( Group & dataGroup ) const +void CompositionalMultiphaseBase::updateComponentFraction( ObjectManagerBase & dataGroup ) const { GEOSX_MARK_FUNCTION; - // outputs + IsothermalCompositionalMultiphaseBaseKernels:: + ComponentFractionKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + dataGroup ); - arrayView2d< real64, compflow::USD_COMP > const & compFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); - - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); - - // inputs - arrayView2d< real64 const, compflow::USD_COMP > const compDens = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); - - arrayView2d< real64 const, compflow::USD_COMP > const dCompDens = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); - - IsothermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector1 - < IsothermalCompositionalMultiphaseBaseKernels::ComponentFractionKernel > - ( m_numComponents, - dataGroup.size(), - compDens, - dCompDens, - compFrac, - dCompFrac_dCompDens ); } -void CompositionalMultiphaseBase::updatePhaseVolumeFraction( Group & dataGroup, +void CompositionalMultiphaseBase::updatePhaseVolumeFraction( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; - // outputs - - arrayView2d< real64, compflow::USD_PHASE > const phaseVolFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); - - arrayView2d< real64, compflow::USD_PHASE > const dPhaseVolFrac_dPres = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); - - arrayView3d< real64, compflow::USD_PHASE_DC > const dPhaseVolFrac_dComp = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ); - - // inputs - - arrayView3d< real64 const, compflow::USD_COMP_DC > const dCompFrac_dCompDens = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); - - arrayView2d< real64 const, compflow::USD_COMP > const compDens = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); - - arrayView2d< real64 const, compflow::USD_COMP > const dCompDens = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); - MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( dataGroup, m_fluidModelNames[targetIndex] ); - 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(); - - 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(); - if( m_isothermalFlag ) { - IsothermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector2 - < IsothermalCompositionalMultiphaseBaseKernels::PhaseVolumeFractionKernel > - ( m_numComponents, - m_numPhases, - dataGroup.size(), - compDens, - dCompDens, - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp ); + IsothermalCompositionalMultiphaseBaseKernels:: + PhaseVolumeFractionKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dataGroup, + fluid ); } else { - // get thermal views - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dTemp = fluid.dPhaseFraction_dTemperature(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); - - arrayView2d< real64, compflow::USD_PHASE > const dPhaseVolFrac_dTemp = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); - - ThermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector2 - < ThermalCompositionalMultiphaseBaseKernels::PhaseVolumeFractionKernel > - ( m_numComponents, - m_numPhases, - dataGroup.size(), - compDens, - dCompDens, - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dTemp, - dPhaseDens_dComp, - phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dTemp, - dPhaseFrac_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dTemp, - dPhaseVolFrac_dComp ); + IsothermalCompositionalMultiphaseBaseKernels:: // TODO FRANCOIS + PhaseVolumeFractionKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dataGroup, + fluid ); } } -void CompositionalMultiphaseBase::updateFluidModel( Group & dataGroup, localIndex const targetIndex ) const +void CompositionalMultiphaseBase::updateFluidModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const pres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const dPres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); - arrayView1d< real64 const > const temp = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); - arrayView1d< real64 const > const dTemp = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); - + arrayView1d< real64 const > const pres = dataGroup.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 const > const dPres = dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); + arrayView1d< real64 const > const temp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::temperature >(); + arrayView1d< real64 const > const dTemp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); arrayView2d< real64 const, compflow::USD_COMP > const compFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >(); MultiFluidBase & fluid = getConstitutiveModel< MultiFluidBase >( dataGroup, m_fluidModelNames[targetIndex] ); @@ -542,12 +441,12 @@ void CompositionalMultiphaseBase::updateFluidModel( Group & dataGroup, localInde } ); } -void CompositionalMultiphaseBase::updateRelPermModel( Group & dataGroup, localIndex const targetIndex ) const +void CompositionalMultiphaseBase::updateRelPermModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >(); RelativePermeabilityBase & relPerm = getConstitutiveModel< RelativePermeabilityBase >( dataGroup, m_relPermModelNames[targetIndex] ); @@ -564,14 +463,14 @@ void CompositionalMultiphaseBase::updateRelPermModel( Group & dataGroup, localIn } ); } -void CompositionalMultiphaseBase::updateCapPressureModel( Group & dataGroup, localIndex const targetIndex ) const +void CompositionalMultiphaseBase::updateCapPressureModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; if( m_capPressureFlag ) { arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >(); CapillaryPressureBase & capPressure = getConstitutiveModel< CapillaryPressureBase >( dataGroup, m_capPressureModelNames[targetIndex] ); @@ -589,7 +488,7 @@ void CompositionalMultiphaseBase::updateCapPressureModel( Group & dataGroup, loc } } -void CompositionalMultiphaseBase::updateFluidState( Group & subRegion, localIndex targetIndex ) const +void CompositionalMultiphaseBase::updateFluidState( ObjectManagerBase & subRegion, localIndex targetIndex ) const { GEOSX_MARK_FUNCTION; @@ -623,9 +522,9 @@ void CompositionalMultiphaseBase::initializeFluidState( MeshLevel & mesh ) arrayView2d< real64 const, multifluid::USD_FLUID > const totalDens = fluid.totalDensity(); arrayView2d< real64 const, compflow::USD_COMP > const compFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >(); arrayView2d< real64, compflow::USD_COMP > const compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -661,16 +560,16 @@ void CompositionalMultiphaseBase::initializeFluidState( MeshLevel & mesh ) // And the initial total mass density is used to compute a deltaBodyForce forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { - arrayView1d< real64 const > const pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 > const initPres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::initialPressureString() ); + arrayView1d< real64 const > const pres = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 > const initPres = subRegion.getExtrinsicData< extrinsicMeshData::flow::initialPressure >(); + arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >(); + MultiFluidBase & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidModelNames()[targetIndex] ); arrayView3d< real64 const, multifluid::USD_PHASE > const phaseMassDens = fluid.phaseMassDensity(); - arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); - arrayView2d< real64, multifluid::USD_FLUID > const initTotalMassDens = - fluid.getReference< array2d< real64, multifluid::LAYOUT_FLUID > >( MultiFluidBase::viewKeyStruct::initialTotalMassDensityString() ); + fluid.getReference< extrinsicMeshData::multifluid::initialTotalMassDensity::type >( extrinsicMeshData::multifluid::initialTotalMassDensity::key() ); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -892,10 +791,10 @@ void CompositionalMultiphaseBase::computeHydrostaticEquilibrium() arrayView2d< real64 const > const elemCenter = subRegion.getReference< array2d< real64 > >( ElementSubRegionBase::viewKeyStruct::elementCenterString() ); - arrayView1d< real64 > const pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 > const temp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + arrayView1d< real64 > const pres = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); + arrayView1d< real64 > const temp = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::temperature::key() ); arrayView2d< real64, compflow::USD_COMP > const compFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); + subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::globalCompFraction::key() ); arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappersViewConst = compFracTableWrappers.toViewConst(); @@ -933,8 +832,8 @@ void CompositionalMultiphaseBase::initializePostInitialConditionsPreSubGroups() MeshLevel & mesh = domain.getMeshBody( 0 ).getMeshLevel( 0 ); std::map< string, string_array > fieldNames; - fieldNames["elems"].emplace_back( string( viewKeyStruct::pressureString() ) ); - fieldNames["elems"].emplace_back( string( viewKeyStruct::globalCompDensityString() ) ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::pressure::key() ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::globalCompDensity::key() ); CommunicationTools::getInstance().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), false ); @@ -989,9 +888,9 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh ) const arrayView1d< integer const > const elemGhostRank = subRegion.ghostRank(); arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >(); arrayView2d< real64 const, compflow::USD_PHASE > const & phaseMob = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseMobilityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobility >(); MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidModelNames()[targetIndex] ); arrayView2d< real64 const, multifluid::USD_FLUID > const totalDens = fluid.totalDensity(); @@ -999,16 +898,16 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh ) const arrayView4d< real64 const, multifluid::USD_PHASE_COMP > const phaseCompFrac = fluid.phaseCompFraction(); arrayView1d< real64 > const totalDensOld = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::totalDensityOldString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::totalDensityOld >(); arrayView2d< real64, compflow::USD_PHASE > const phaseDensOld = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseDensityOldString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseDensityOld >(); arrayView2d< real64, compflow::USD_PHASE > const phaseVolFracOld = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionOldString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFractionOld >(); arrayView2d< real64, compflow::USD_PHASE > const phaseMobOld = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseMobilityOldString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobilityOld >(); arrayView3d< real64, compflow::USD_PHASE_COMP > const phaseCompFracOld = - subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_COMP > >( viewKeyStruct::phaseComponentFractionOldString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseComponentFractionOld >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -1036,7 +935,7 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh ) const arrayView3d< real64 const, multifluid::USD_PHASE > const phaseInternalEnergy = fluid.phaseInternalEnergy(); arrayView2d< real64, compflow::USD_PHASE > const phaseInternalEnergyOld = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseInternalEnergyOldString() ); + subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( extrinsicMeshData::flow::phaseInternalEnergyOld::key() ); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -1157,6 +1056,15 @@ void CompositionalMultiphaseBase::applyBoundaryConditions( real64 const time_n, applyAquiferBC( time_n, dt, dofManager, domain, localMatrix.toViewConstSizes(), localRhs.toView() ); } +namespace internal +{ +string const bcLogMessage = string( "CompositionalMultiphaseBase {}: at time {}s, " ) + + string( "the <{}> boundary condition '{}' is applied to the element set '{}' in subRegion '{}'. " ) + + string( "\nThe scale of this boundary condition is {} and multiplies the value of the provided function (if any). " ) + + string( "\nThe total number of target elements (including ghost elements) is {}. " ) + + string( "\nNote that if this number is equal to zero for all subRegions, the boundary condition will not be applied on this element set." ); +} + void CompositionalMultiphaseBase::applySourceFluxBC( real64 const time, real64 const dt, DofManager const & dofManager, @@ -1175,11 +1083,19 @@ void CompositionalMultiphaseBase::applySourceFluxBC( real64 const time, "ElementRegions", FieldSpecificationBase::viewKeyStruct::fluxBoundaryConditionString(), [&]( FieldSpecificationBase const & fs, - string const &, + string const & setName, SortedArrayView< localIndex const > const & targetSet, Group & subRegion, string const & ) { + if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( targetSet.size() ); + GEOSX_LOG_RANK_0( GEOSX_FMT( geosx::internal::bcLogMessage, + getName(), time+dt, SourceFluxBoundaryCondition::catalogName(), + fs.getName(), setName, subRegion.getName(), fs.getScale(), numTargetElems ) ); + } + arrayView1d< globalIndex const > const dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const ghostRank = subRegion.getReference< array1d< integer > >( ObjectManagerBase::viewKeyStruct::ghostRankString() ); @@ -1252,7 +1168,6 @@ bool validateDirichletBC( DomainPartition & domain, real64 const time ) { constexpr integer MAX_NC = MultiFluidBase::MAX_NUM_COMPONENTS; - using keys = CompositionalMultiphaseBase::viewKeyStruct; FieldSpecificationManager & fsManager = FieldSpecificationManager::getInstance(); map< string, map< string, map< string, ComponentMask< MAX_NC > > > > bcStatusMap; // map to check consistent application of BC @@ -1262,7 +1177,7 @@ bool validateDirichletBC( DomainPartition & domain, fsManager.apply( time, domain, "ElementRegions", - keys::pressureString(), + extrinsicMeshData::flow::pressure::key(), [&]( FieldSpecificationBase const &, string const & setName, SortedArrayView< localIndex const > const &, @@ -1286,7 +1201,7 @@ bool validateDirichletBC( DomainPartition & domain, fsManager.apply( time, domain, "ElementRegions", - keys::globalCompFractionString(), + extrinsicMeshData::flow::globalCompFraction::key(), [&] ( FieldSpecificationBase const & fs, string const & setName, SortedArrayView< localIndex const > const &, @@ -1369,24 +1284,32 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, fsManager.apply( time + dt, domain, "ElementRegions", - viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), [&]( FieldSpecificationBase const & fs, - string const &, + string const & setName, SortedArrayView< localIndex const > const & targetSet, Group & subRegion, string const & ) { + if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( targetSet.size() ); + GEOSX_LOG_RANK_0( GEOSX_FMT( geosx::internal::bcLogMessage, + getName(), time+dt, FieldSpecificationBase::catalogName(), + fs.getName(), setName, subRegion.getName(), fs.getScale(), numTargetElems ) ); + } + fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, time + dt, subRegion, - viewKeyStruct::bcPressureString() ); + extrinsicMeshData::flow::bcPressure::key() ); } ); // 2. Apply composition BC (global component fraction) and store them for constitutive call fsManager.apply( time + dt, domain, "ElementRegions", - viewKeyStruct::globalCompFractionString(), + extrinsicMeshData::flow::globalCompFraction::key(), [&] ( FieldSpecificationBase const & fs, string const &, SortedArrayView< localIndex const > const & targetSet, @@ -1396,7 +1319,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, time + dt, subRegion, - viewKeyStruct::globalCompFractionString() ); + extrinsicMeshData::flow::globalCompFraction::key() ); } ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -1406,7 +1329,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, fsManager.apply( time + dt, domain, "ElementRegions", - viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), [&] ( FieldSpecificationBase const &, string const &, SortedArrayView< localIndex const > const & targetSet, @@ -1419,11 +1342,11 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, MultiFluidBase & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidName ); arrayView1d< real64 const > const bcPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::bcPressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::bcPressure::key() ); arrayView1d< real64 const > const temp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::temperature::key() ); arrayView2d< real64 const, compflow::USD_COMP > const compFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); + subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::globalCompFraction::key() ); constitutiveUpdatePassThru( fluid, [&] ( auto & castedFluid ) { @@ -1445,13 +1368,13 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, arrayView1d< globalIndex const > const dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< real64 const > const pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); arrayView1d< real64 const > const dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); arrayView2d< real64 const, compflow::USD_COMP > const compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::globalCompDensity::key() ); arrayView2d< real64 const, compflow::USD_COMP > const dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::deltaGlobalCompDensity::key() ); arrayView2d< real64 const, multifluid::USD_FLUID > const totalDens = fluid.totalDensity(); integer const numComp = m_numComponents; @@ -1517,9 +1440,9 @@ void CompositionalMultiphaseBase::chopNegativeDensities( DomainPartition & domai arrayView1d< integer const > const ghostRank = subRegion.ghostRank(); arrayView2d< real64 const, compflow::USD_COMP > const compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64, compflow::USD_COMP > const dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -1547,9 +1470,9 @@ void CompositionalMultiphaseBase::resetStateToBeginningOfStep( DomainPartition & forTargetSubRegions< CellElementSubRegion, SurfaceElementSubRegion >( mesh, [&]( localIndex const targetIndex, auto & subRegion ) { arrayView1d< real64 > const & dPres = - subRegion.template getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64, compflow::USD_COMP > const & dCompDens = - subRegion.template getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); dPres.zero(); dCompDens.zero(); @@ -1557,7 +1480,7 @@ void CompositionalMultiphaseBase::resetStateToBeginningOfStep( DomainPartition & if( !m_isothermalFlag ) { arrayView1d< real64 > const & dTemp = - subRegion.template getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); dTemp.zero(); } @@ -1583,14 +1506,14 @@ void CompositionalMultiphaseBase::implicitStepComplete( real64 const & time, forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { arrayView1d< real64 const > const dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64 const, compflow::USD_COMP > const dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); arrayView1d< real64 > const pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView2d< real64, compflow::USD_COMP > const compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -1604,9 +1527,9 @@ void CompositionalMultiphaseBase::implicitStepComplete( real64 const & time, if( !m_isothermalFlag ) { arrayView1d< real64 const > const dTemp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); arrayView1d< real64 > const temp = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::temperature >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -1638,204 +1561,182 @@ void CompositionalMultiphaseBase::resetViews( MeshLevel & mesh ) ElementRegionManager const & elemManager = mesh.getElemManager(); { - using keys = viewKeyStruct; + using namespace extrinsicMeshData::flow; using namespace compflow; m_dCompFrac_dCompDens.clear(); m_dCompFrac_dCompDens = - elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_COMP_DC >( keys::dGlobalCompFraction_dGlobalCompDensityString() ); - m_dCompFrac_dCompDens.setName( getName() + "/accessors/" + keys::dGlobalCompFraction_dGlobalCompDensityString() ); + elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_COMP_DC >( dGlobalCompFraction_dGlobalCompDensity::key() ); + m_dCompFrac_dCompDens.setName( getName() + "/accessors/" + dGlobalCompFraction_dGlobalCompDensity::key() ); m_phaseVolFrac.clear(); m_phaseVolFrac = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::phaseVolumeFractionString() ); - m_phaseVolFrac.setName( getName() + "/accessors/" + keys::phaseVolumeFractionString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( phaseVolumeFraction::key() ); + m_phaseVolFrac.setName( getName() + "/accessors/" + phaseVolumeFraction::key() ); m_dPhaseVolFrac_dPres.clear(); m_dPhaseVolFrac_dPres = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::dPhaseVolumeFraction_dPressureString() ); - m_dPhaseVolFrac_dPres.setName( getName() + "/accessors/" + keys::dPhaseVolumeFraction_dPressureString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( dPhaseVolumeFraction_dPressure::key() ); + m_dPhaseVolFrac_dPres.setName( getName() + "/accessors/" + dPhaseVolumeFraction_dPressure::key() ); m_dPhaseVolFrac_dCompDens.clear(); m_dPhaseVolFrac_dCompDens = - elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_PHASE_DC >( keys::dPhaseVolumeFraction_dGlobalCompDensityString() ); - m_dPhaseVolFrac_dCompDens.setName( getName() + "/accessors/" + keys::dPhaseVolumeFraction_dGlobalCompDensityString() ); + elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_PHASE_DC >( dPhaseVolumeFraction_dGlobalCompDensity::key() ); + m_dPhaseVolFrac_dCompDens.setName( getName() + "/accessors/" + dPhaseVolumeFraction_dGlobalCompDensity::key() ); m_phaseMob.clear(); m_phaseMob = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::phaseMobilityString() ); - m_phaseMob.setName( getName() + "/accessors/" + keys::phaseMobilityString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( phaseMobility::key() ); + m_phaseMob.setName( getName() + "/accessors/" + phaseMobility::key() ); m_dPhaseMob_dPres.clear(); m_dPhaseMob_dPres = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::dPhaseMobility_dPressureString() ); - m_dPhaseMob_dPres.setName( getName() + "/accessors/" + keys::dPhaseMobility_dPressureString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( dPhaseMobility_dPressure::key() ); + m_dPhaseMob_dPres.setName( getName() + "/accessors/" + dPhaseMobility_dPressure::key() ); m_dPhaseMob_dCompDens.clear(); m_dPhaseMob_dCompDens = - elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_PHASE_DC >( keys::dPhaseMobility_dGlobalCompDensityString() ); - m_dPhaseMob_dCompDens.setName( getName() + "/accessors/" + keys::dPhaseMobility_dGlobalCompDensityString() ); + elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_PHASE_DC >( dPhaseMobility_dGlobalCompDensity::key() ); + m_dPhaseMob_dCompDens.setName( getName() + "/accessors/" + dPhaseMobility_dGlobalCompDensity::key() ); m_phaseMobOld.clear(); m_phaseMobOld = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::phaseMobilityOldString() ); - m_phaseMobOld.setName( getName() + "/accessors/" + keys::phaseMobilityOldString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( phaseMobilityOld::key() ); + m_phaseMobOld.setName( getName() + "/accessors/" + phaseMobilityOld::key() ); m_totalDensOld.clear(); - m_totalDensOld = elemManager.constructArrayViewAccessor< real64, 1 >( keys::totalDensityOldString() ); - m_totalDensOld.setName( getName() + "/accessors/" + keys::totalDensityOldString() ); + m_totalDensOld = elemManager.constructArrayViewAccessor< real64, 1 >( totalDensityOld::key() ); + m_totalDensOld.setName( getName() + "/accessors/" + totalDensityOld::key() ); if( !m_isothermalFlag ) { m_temperature.clear(); - m_temperature = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::temperatureString() ); - m_temperature.setName( getName() + "/accessors/" + viewKeyStruct::temperatureString() ); + m_temperature = elemManager.constructArrayViewAccessor< real64, 1 >( temperature::key() ); + m_temperature.setName( getName() + "/accessors/" + temperature::key() ); m_deltaTemperature.clear(); - m_deltaTemperature = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaTemperatureString() ); - m_deltaTemperature.setName( getName() + "/accessors/" + viewKeyStruct::deltaTemperatureString() ); + m_deltaTemperature = elemManager.constructArrayViewAccessor< real64, 1 >( deltaTemperature::key() ); + m_deltaTemperature.setName( getName() + "/accessors/" + deltaTemperature::key() ); m_dPhaseVolFrac_dTemp.clear(); - m_dPhaseVolFrac_dTemp = elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); - m_dPhaseVolFrac_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); + m_dPhaseVolFrac_dTemp = elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( dPhaseVolumeFraction_dTemperature::key() ); + m_dPhaseVolFrac_dTemp.setName( getName() + "/accessors/" + dPhaseVolumeFraction_dTemperature::key() ); m_dPhaseMob_dTemp.clear(); - m_dPhaseMob_dTemp = elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( viewKeyStruct::dPhaseMobility_dTemperatureString() ); - m_dPhaseMob_dTemp.setName( getName() + "/accessors/" + viewKeyStruct::dPhaseMobility_dTemperatureString() ); + m_dPhaseMob_dTemp = elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( dPhaseMobility_dTemperature::key() ); + m_dPhaseMob_dTemp.setName( getName() + "/accessors/" + dPhaseMobility_dTemperature::key() ); } } { - using keys = MultiFluidBase::viewKeyStruct; - using namespace constitutive::multifluid; + using namespace extrinsicMeshData::multifluid; m_phaseVisc.clear(); - m_phaseVisc = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseViscosityString(), - targetRegionNames(), - fluidModelNames() ); - m_phaseVisc.setName( getName() + "/accessors/" + keys::phaseViscosityString() ); + m_phaseVisc = elemManager.constructMaterialExtrinsicAccessor< phaseViscosity >( targetRegionNames(), + fluidModelNames() ); + m_phaseVisc.setName( getName() + "/accessors/" + phaseViscosity::key() ); m_phaseDens.clear(); - m_phaseDens = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseDensityString(), - targetRegionNames(), - fluidModelNames() ); - m_phaseDens.setName( getName() + "/accessors/" + keys::phaseDensityString() ); + m_phaseDens = elemManager.constructMaterialExtrinsicAccessor< phaseDensity >( targetRegionNames(), + fluidModelNames() ); + m_phaseDens.setName( getName() + "/accessors/" + phaseDensity::key() ); m_dPhaseDens_dPres.clear(); - m_dPhaseDens_dPres = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseDensity_dPressureString(), - targetRegionNames(), + m_dPhaseDens_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseDensity_dPressure >( targetRegionNames(), fluidModelNames() ); - m_dPhaseDens_dPres.setName( getName() + "/accessors/" + keys::dPhaseDensity_dPressureString() ); + m_dPhaseDens_dPres.setName( getName() + "/accessors/" + dPhaseDensity_dPressure::key() ); m_dPhaseDens_dComp.clear(); - m_dPhaseDens_dComp = elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_DC >( keys::dPhaseDensity_dGlobalCompFractionString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseDens_dComp.setName( getName() + "/accessors/" + keys::dPhaseDensity_dGlobalCompFractionString() ); + m_dPhaseDens_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseDensity_dGlobalCompFraction >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseDens_dComp.setName( getName() + "/accessors/" + dPhaseDensity_dGlobalCompFraction::key() ); m_phaseMassDens.clear(); - m_phaseMassDens = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseMassDensityString(), - targetRegionNames(), - fluidModelNames() ); - m_phaseMassDens.setName( getName() + "/accessors/" + keys::phaseMassDensityString() ); + m_phaseMassDens = elemManager.constructMaterialExtrinsicAccessor< phaseMassDensity >( targetRegionNames(), + fluidModelNames() ); + m_phaseMassDens.setName( getName() + "/accessors/" + phaseMassDensity::key() ); m_dPhaseMassDens_dPres.clear(); - m_dPhaseMassDens_dPres = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseMassDensity_dPressureString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseMassDens_dPres.setName( getName() + "/accessors/" + keys::dPhaseMassDensity_dPressureString() ); + m_dPhaseMassDens_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseMassDensity_dPressure >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseMassDens_dPres.setName( getName() + "/accessors/" + dPhaseMassDensity_dPressure::key() ); m_dPhaseMassDens_dComp.clear(); - m_dPhaseMassDens_dComp = elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_DC >( keys::dPhaseMassDensity_dGlobalCompFractionString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseMassDens_dComp.setName( getName() + "/accessors/" + keys::dPhaseMassDensity_dGlobalCompFractionString() ); + m_dPhaseMassDens_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseMassDensity_dGlobalCompFraction >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseMassDens_dComp.setName( getName() + "/accessors/" + dPhaseMassDensity_dGlobalCompFraction::key() ); m_phaseCompFrac.clear(); - m_phaseCompFrac = elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_COMP >( keys::phaseCompFractionString(), - targetRegionNames(), - fluidModelNames() ); - m_phaseCompFrac.setName( getName() + "/accessors/" + keys::phaseCompFractionString() ); + m_phaseCompFrac = elemManager.constructMaterialExtrinsicAccessor< phaseCompFraction >( targetRegionNames(), + fluidModelNames() ); + m_phaseCompFrac.setName( getName() + "/accessors/" + phaseCompFraction::key() ); m_dPhaseCompFrac_dPres.clear(); - m_dPhaseCompFrac_dPres = elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_COMP >( keys::dPhaseCompFraction_dPressureString(), - targetRegionNames(), + m_dPhaseCompFrac_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseCompFraction_dPressure >( targetRegionNames(), fluidModelNames() ); - m_dPhaseCompFrac_dPres.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dPressureString() ); + m_dPhaseCompFrac_dPres.setName( getName() + "/accessors/" + dPhaseCompFraction_dPressure::key() ); m_dPhaseCompFrac_dComp.clear(); - m_dPhaseCompFrac_dComp = elemManager.constructMaterialArrayViewAccessor< real64, 5, LAYOUT_PHASE_COMP_DC >( keys::dPhaseCompFraction_dGlobalCompFractionString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseCompFrac_dComp.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dGlobalCompFractionString() ); + m_dPhaseCompFrac_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseCompFraction_dGlobalCompFraction >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseCompFrac_dComp.setName( getName() + "/accessors/" + dPhaseCompFraction_dGlobalCompFraction::key() ); if( !m_isothermalFlag ) { m_dPhaseMassDens_dTemp.clear(); - m_dPhaseMassDens_dTemp = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseMassDensity_dTemperatureString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseMassDens_dTemp.setName( getName() + "/accessors/" + keys::dPhaseMassDensity_dTemperatureString() ); + m_dPhaseMassDens_dTemp = elemManager.constructMaterialExtrinsicAccessor< dPhaseMassDensity_dTemperature >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseMassDens_dTemp.setName( getName() + "/accessors/" + dPhaseMassDensity_dTemperature::key() ); m_dPhaseCompFrac_dTemp.clear(); - m_dPhaseCompFrac_dTemp = elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_DC >( keys::dPhaseCompFraction_dTemperatureString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseCompFrac_dTemp.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dTemperatureString() ); + m_dPhaseCompFrac_dTemp = elemManager.constructMaterialExtrinsicAccessor< dPhaseCompFraction_dTemperature >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseCompFrac_dTemp.setName( getName() + "/accessors/" + dPhaseCompFraction_dTemperature::key() ); m_phaseEnthalpy.clear(); - m_phaseEnthalpy = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseEnthalpyString(), - targetRegionNames(), - fluidModelNames() ); - m_phaseEnthalpy.setName( getName() + "/accessors/" + keys::phaseEnthalpyString() ); + m_phaseEnthalpy = elemManager.constructMaterialExtrinsicAccessor< phaseEnthalpy >( targetRegionNames(), + fluidModelNames() ); + m_phaseEnthalpy.setName( getName() + "/accessors/" + phaseEnthalpy::key() ); m_dPhaseEnthalpy_dPres.clear(); - m_dPhaseEnthalpy_dPres = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseEnthalpy_dPressureString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseEnthalpy_dPres.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dPressureString() ); + m_dPhaseEnthalpy_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseEnthalpy_dPressure >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseEnthalpy_dPres.setName( getName() + "/accessors/" + dPhaseEnthalpy_dPressure::key() ); m_dPhaseEnthalpy_dTemp.clear(); - m_dPhaseEnthalpy_dTemp = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseEnthalpy_dTemperatureString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseEnthalpy_dTemp.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dTemperatureString() ); + m_dPhaseEnthalpy_dTemp = elemManager.constructMaterialExtrinsicAccessor< dPhaseEnthalpy_dTemperature >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseEnthalpy_dTemp.setName( getName() + "/accessors/" + dPhaseEnthalpy_dTemperature::key() ); m_dPhaseEnthalpy_dComp.clear(); - m_dPhaseEnthalpy_dComp = elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_DC >( keys::dPhaseEnthalpy_dGlobalCompFractionString(), - targetRegionNames(), - fluidModelNames() ); - m_dPhaseEnthalpy_dComp.setName( getName() + "/accessors/" + keys::dPhaseEnthalpy_dGlobalCompFractionString() ); + m_dPhaseEnthalpy_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseEnthalpy_dGlobalCompFraction >( targetRegionNames(), + fluidModelNames() ); + m_dPhaseEnthalpy_dComp.setName( getName() + "/accessors/" + dPhaseEnthalpy_dGlobalCompFraction::key() ); } } { - using keys = RelativePermeabilityBase::viewKeyStruct; - using namespace constitutive::relperm; + using namespace extrinsicMeshData::relperm; m_phaseRelPerm.clear(); - m_phaseRelPerm = elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_RELPERM >( keys::phaseRelPermString(), - targetRegionNames(), - relPermModelNames() ); - m_phaseRelPerm.setName( getName() + "/accessors/" + keys::phaseRelPermString() ); + m_phaseRelPerm = elemManager.constructMaterialExtrinsicAccessor< phaseRelPerm >( targetRegionNames(), + relPermModelNames() ); + m_phaseRelPerm.setName( getName() + "/accessors/" + phaseRelPerm::key() ); } if( m_capPressureFlag ) { - using keys = CapillaryPressureBase::viewKeyStruct; - using namespace constitutive::cappres; + using namespace extrinsicMeshData::cappres; m_phaseCapPressure.clear(); m_phaseCapPressure = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_CAPPRES >( keys::phaseCapPressureString(), - targetRegionNames(), - capPresModelNames() ); - m_phaseCapPressure.setName( getName() + "/accessors/" + keys::phaseCapPressureString() ); + elemManager.constructMaterialExtrinsicAccessor< phaseCapPressure >( targetRegionNames(), + capPresModelNames() ); + m_phaseCapPressure.setName( getName() + "/accessors/" + phaseCapPressure::key() ); m_dPhaseCapPressure_dPhaseVolFrac.clear(); m_dPhaseCapPressure_dPhaseVolFrac = - elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_CAPPRES_DS >( keys::dPhaseCapPressure_dPhaseVolFractionString(), - targetRegionNames(), - capPresModelNames() ); - m_dPhaseCapPressure_dPhaseVolFrac.setName( getName() + "/accessors/" + keys::dPhaseCapPressure_dPhaseVolFractionString() ); + elemManager.constructMaterialExtrinsicAccessor< dPhaseCapPressure_dPhaseVolFraction >( targetRegionNames(), + capPresModelNames() ); + m_dPhaseCapPressure_dPhaseVolFrac.setName( getName() + "/accessors/" + dPhaseCapPressure_dPhaseVolFraction::key() ); } } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp index e5718b10f3e..c1ac58240db 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp @@ -122,39 +122,39 @@ class CompositionalMultiphaseBase : public FlowSolverBase * @brief Recompute component fractions from primary variables (component densities) * @param dataGroup the group storing the required fields */ - void updateComponentFraction( Group & dataGroup ) const; + void updateComponentFraction( ObjectManagerBase & dataGroup ) const; /** * @brief Recompute phase volume fractions (saturations) from constitutive and primary variables * @param dataGroup the group storing the required fields */ - void updatePhaseVolumeFraction( Group & dataGroup, localIndex const targetIndex ) const; + void updatePhaseVolumeFraction( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const; /** * @brief Update all relevant fluid models using current values of pressure and composition * @param dataGroup the group storing the required fields */ - void updateFluidModel( Group & dataGroup, localIndex const targetIndex ) const; + void updateFluidModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const; /** * @brief Update all relevant fluid models using current values of pressure and composition * @param castedRelPerm the group storing the required fields */ - void updateRelPermModel( Group & castedRelPerm, localIndex const targetIndex ) const; + void updateRelPermModel( ObjectManagerBase & castedRelPerm, localIndex const targetIndex ) const; /** * @brief Update all relevant fluid models using current values of pressure and composition * @param castedCapPres the group storing the required fields */ - void updateCapPressureModel( Group & castedCapPres, localIndex const targetIndex ) const; + void updateCapPressureModel( ObjectManagerBase & castedCapPres, localIndex const targetIndex ) const; /** * @brief Recompute phase mobility from constitutive and primary variables * @param domain the domain containing the mesh and fields */ - virtual void updatePhaseMobility( Group & dataGroup, localIndex const targetIndex ) const = 0; + virtual void updatePhaseMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const = 0; - void updateFluidState( Group & dataGroup, localIndex const targetIndex ) const; + void updateFluidState( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const; virtual void updateState( DomainPartition & domain ) override final; @@ -215,10 +215,6 @@ class CompositionalMultiphaseBase : public FlowSolverBase static constexpr char const * inputTemperatureString() { return "temperature"; } - static constexpr char const * temperatureString() { return "temperature"; } - - static constexpr char const * deltaTemperatureString() { return "deltaTemperature"; } - static constexpr char const * useMassFlagString() { return "useMass"; } static constexpr char const * isothermalFlagString() { return "isothermal"; } @@ -232,65 +228,6 @@ class CompositionalMultiphaseBase : public FlowSolverBase static constexpr char const * maxCompFracChangeString() { return "maxCompFractionChange"; } static constexpr char const * allowLocalCompDensChoppingString() { return "allowLocalCompDensityChopping"; } - - static constexpr char const * facePressureString() { return "facePressure"; } - - static constexpr char const * bcPressureString() { return "bcPressure"; } - - static constexpr char const * globalCompDensityString() { return "globalCompDensity"; } - - static constexpr char const * deltaGlobalCompDensityString() { return "deltaGlobalCompDensity"; } - - // intermediate values for constitutive model input - static constexpr char const * globalCompFractionString() { return "globalCompFraction"; } - - static constexpr char const * dGlobalCompFraction_dGlobalCompDensityString() { return "dGlobalCompFraction_dGlobalCompDensity"; } - - static constexpr char const * phaseVolumeFractionString() { return "phaseVolumeFraction"; } - - static constexpr char const * dPhaseVolumeFraction_dPressureString() { return "dPhaseVolumeFraction_dPressure"; } - - static constexpr char const * dPhaseVolumeFraction_dGlobalCompDensityString() { return "dPhaseVolumeFraction_dGlobalCompDensity"; } - - static constexpr char const * dPhaseVolumeFraction_dTemperatureString() { return "dPhaseVolumeFraction_dTemperature"; } - - // intermediate values for mobilities - static constexpr char const * phaseMobilityString() { return "phaseMobility"; } - - static constexpr char const * dPhaseMobility_dPressureString() { return "dPhaseMobility_dPressure"; } - - static constexpr char const * dPhaseMobility_dGlobalCompDensityString() { return "dPhaseMobility_dGlobalCompDensity"; } - - static constexpr char const * dPhaseMobility_dTemperatureString() { return "dPhaseMobility_dTemperature"; } - - // intermediate values for CFL number computation and actual cell CFL numbers - static constexpr char const * phaseOutfluxString() { return "phaseOutflux"; } - - static constexpr char const * componentOutfluxString() { return "componentOutflux"; } - - static constexpr char const * phaseCFLNumberString() { return "phaseCFLNumber"; } - - static constexpr char const * componentCFLNumberString() { return "componentCFLNumber"; } - - // these are used to store last converged time step values - static constexpr char const * phaseVolumeFractionOldString() { return "phaseVolumeFractionOld"; } - - static constexpr char const * phaseDensityOldString() { return "phaseDensityOld"; } - - static constexpr char const * totalDensityOldString() { return "totalDensityOld"; } - - static constexpr char const * phaseComponentFractionOldString() { return "phaseComponentFractionOld"; } - - static constexpr char const * phaseMobilityOldString() { return "phaseMobilityOld"; } - - static constexpr char const * phaseInternalEnergyOldString() { return "phaseInternalEnergyOld"; } - - // these are allocated on faces for BC application until we can get constitutive models on faces - static constexpr char const * phaseViscosityString() { return "phaseViscosity"; } - - static constexpr char const * phaseRelativePermeabilityString() { return "phaseRelativePermeability"; } - - static constexpr char const * phaseCapillaryPressureString() { return "phaseCapillaryPressure"; } }; /** diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp new file mode 100644 index 00000000000..64b2b6f2f15 --- /dev/null +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp @@ -0,0 +1,257 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file CompositionalMultiphaseBaseExtrinsicData.hpp + */ + +#ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEBASEEXTRINSICDATA_HPP_ +#define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEBASEEXTRINSICDATA_HPP_ + +#include "common/DataLayouts.hpp" +#include "mesh/ExtrinsicMeshData.hpp" + +namespace geosx +{ +/** + * A scope for extrinsic mesh data traits. + */ +namespace extrinsicMeshData +{ + +namespace flow +{ + +using array2dLayoutPhase = array2d< real64, compflow::LAYOUT_PHASE >; +using array3dLayoutPhase_dC = array3d< real64, compflow::LAYOUT_PHASE_DC >; +using array2dLayoutComp = array2d< real64, compflow::LAYOUT_COMP >; +using array3dLayoutComp_dC = array3d< real64, compflow::LAYOUT_COMP_DC >; +using array3dLayoutPhaseComp = array3d< real64, compflow::LAYOUT_PHASE_COMP >; + +EXTRINSIC_MESH_DATA_TRAIT( temperature, + "temperature", + array1d< real64 >, + 0, + LEVEL_0, + WRITE_AND_READ, + "Temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( deltaTemperature, + "deltaTemperature", + array1d< real64 >, + 0, + NOPLOT, + NO_WRITE, + "Accumulated temperature updates" ); + + +EXTRINSIC_MESH_DATA_TRAIT( globalCompDensity, + "globalCompDensity", + array2dLayoutComp, + 0, + LEVEL_0, + WRITE_AND_READ, + "Global component density" ); + +EXTRINSIC_MESH_DATA_TRAIT( deltaGlobalCompDensity, + "deltaGlobalCompDensity", + array2dLayoutComp, + 0, + NOPLOT, + NO_WRITE, + "Accumulated global component density updates" ); + +EXTRINSIC_MESH_DATA_TRAIT( globalCompFraction, + "globalCompFraction", + array2dLayoutComp, + 0, + LEVEL_0, + WRITE_AND_READ, + "Global component fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( dGlobalCompFraction_dGlobalCompDensity, + "dGlobalCompFraction_dGlobalCompDensity", + array3dLayoutComp_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of global component fraction with respect to component density" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseVolumeFraction, + "phaseVolumeFraction", + array2dLayoutPhase, + 0, + LEVEL_0, + WRITE_AND_READ, + "Phase volume fraction" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseVolumeFraction_dPressure, + "dPhaseVolumeFraction_dPressure", + array2dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase volume fraction with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseVolumeFraction_dTemperature, + "dPhaseVolumeFraction_dTemperature", + array2dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase volume fraction with respect to temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseVolumeFraction_dGlobalCompDensity, + "dPhaseVolumeFraction_dGlobalCompDensity", + array3dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase volume fraction with respect to global component density" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseMobility, + "phaseMobility", + array2dLayoutPhase, + 0, + LEVEL_0, + WRITE_AND_READ, + "Phase mobility" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseMobility_dPressure, + "dPhaseMobility_dPressure", + array2dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase mobility with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseMobility_dTemperature, + "dPhaseMobility_dTemperature", + array2dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase mobility with respect to temperature" ); + +EXTRINSIC_MESH_DATA_TRAIT( dPhaseMobility_dGlobalCompDensity, + "dPhaseMobility_dGlobalCompDensity", + array3dLayoutPhase_dC, + 0, + NOPLOT, + NO_WRITE, + "Derivative of phase volume fraction with respect to global component density" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseVolumeFractionOld, + "phaseVolumeFractionOld", + array2dLayoutPhase, + 0, + NOPLOT, + WRITE_AND_READ, + "Phase volume fraction at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseDensityOld, + "phaseDensityOld", + array2dLayoutPhase, + 0, + NOPLOT, + WRITE_AND_READ, + "Phase density at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( totalDensityOld, + "totalDensityOld", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Total density at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseMobilityOld, + "phaseMobilityOld", + array2dLayoutPhase, + 0, + NOPLOT, + WRITE_AND_READ, + "Phase mobility at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseEnthalpyOld, + "phaseEnthalpyOld", + array2dLayoutPhase, + 0, + NOPLOT, + WRITE_AND_READ, + "Phase enthalpy at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseInternalEnergyOld, + "phaseInternalEnergyOld", + array2dLayoutPhase, + 0, + NOPLOT, + WRITE_AND_READ, + "Phase internal energy at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseComponentFractionOld, + "phaseComponentFractionOld", + array3dLayoutPhaseComp, + 0, + NOPLOT, + WRITE_AND_READ, + "Phase component fraction at the previous converged time step" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseOutflux, + "phaseOutflux", + array2dLayoutPhase, + 0, + NOPLOT, + NO_WRITE, + "Phase outflux" ); + +EXTRINSIC_MESH_DATA_TRAIT( componentOutflux, + "componentOutflux", + array2dLayoutComp, + 0, + NOPLOT, + NO_WRITE, + "Component outflux" ); + +EXTRINSIC_MESH_DATA_TRAIT( phaseCFLNumber, + "phaseCFLNumber", + array1d< real64 >, + 0, + LEVEL_0, + NO_WRITE, + "Phase CFL number" ); + +EXTRINSIC_MESH_DATA_TRAIT( componentCFLNumber, + "componentCFLNumber", + array1d< real64 >, + 0, + LEVEL_0, + NO_WRITE, + "Component CFL number" ); + +EXTRINSIC_MESH_DATA_TRAIT( bcPressure, + "bcPressure", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Boundary condition pressure" ); + +} + +} + +} + +#endif // GEOSX_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEBASEEXTRINSICDATA_HPP_ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index d6696f5037a..242857aef20 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -34,6 +34,8 @@ #include "finiteVolume/FluxApproximationBase.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" #include "physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp" @@ -247,9 +249,9 @@ void CompositionalMultiphaseFVM::computeCFLNumbers( real64 const & dt, forTargetSubRegions( mesh, [&]( localIndex const, ElementSubRegionBase & subRegion ) { arrayView2d< real64, compflow::USD_PHASE > const & phaseOutflux = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseOutfluxString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseOutflux >(); arrayView2d< real64, compflow::USD_COMP > const & compOutflux = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::componentOutfluxString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::componentOutflux >(); phaseOutflux.zero(); compOutflux.zero(); } ); @@ -260,10 +262,12 @@ void CompositionalMultiphaseFVM::computeCFLNumbers( real64 const & dt, FluxApproximationBase & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); ElementRegionManager::ElementViewAccessor< arrayView2d< real64, compflow::USD_PHASE > > const & phaseOutfluxAccessor = - mesh.getElemManager().constructViewAccessor< array2d< real64, compflow::LAYOUT_PHASE >, arrayView2d< real64, compflow::USD_PHASE > >( viewKeyStruct::phaseOutfluxString() ); + mesh.getElemManager().constructViewAccessor< array2d< real64, compflow::LAYOUT_PHASE >, + arrayView2d< real64, compflow::USD_PHASE > >( extrinsicMeshData::flow::phaseOutflux::key() ); ElementRegionManager::ElementViewAccessor< arrayView2d< real64, compflow::USD_COMP > > const & compOutfluxAccessor = - mesh.getElemManager().constructViewAccessor< array2d< real64, compflow::LAYOUT_COMP >, arrayView2d< real64, compflow::USD_COMP > >( viewKeyStruct::componentOutfluxString() ); + mesh.getElemManager().constructViewAccessor< array2d< real64, compflow::LAYOUT_COMP >, + arrayView2d< real64, compflow::USD_COMP > >( extrinsicMeshData::flow::componentOutflux::key() ); fluxApprox.forAllStencils( mesh, [&] ( auto & stencil ) { @@ -297,21 +301,21 @@ void CompositionalMultiphaseFVM::computeCFLNumbers( real64 const & dt, { arrayView2d< real64 const, compflow::USD_PHASE > const & phaseOutflux = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseOutfluxString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseOutflux >(); arrayView2d< real64 const, compflow::USD_COMP > const & compOutflux = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::componentOutfluxString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::componentOutflux >(); - arrayView1d< real64 > const & phaseCFLNumber = subRegion.getReference< array1d< real64 > >( viewKeyStruct::phaseCFLNumberString() ); - arrayView1d< real64 > const & compCFLNumber = subRegion.getReference< array1d< real64 > >( viewKeyStruct::componentCFLNumberString() ); + arrayView1d< real64 > const & phaseCFLNumber = subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseCFLNumber >(); + arrayView1d< real64 > const & compCFLNumber = subRegion.getExtrinsicData< extrinsicMeshData::flow::componentCFLNumber >(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64 const, compflow::USD_COMP > const compFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >(); arrayView2d< real64, compflow::USD_PHASE > const phaseVolFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >(); MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc = fluid.phaseViscosity(); @@ -378,7 +382,7 @@ real64 CompositionalMultiphaseFVM::calculateResidualNorm( DomainPartition const arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & totalDensOld = subRegion.getReference< array1d< real64 > >( viewKeyStruct::totalDensityOldString() ); + arrayView1d< real64 const > const & totalDensOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::totalDensityOld >(); CoupledSolidBase const & solidModel = getConstitutiveModel< CoupledSolidBase >( subRegion, m_solidModelNames[targetIndex] ); @@ -476,9 +480,9 @@ real64 CompositionalMultiphaseFVM::scalingForSystemSolution( DomainPartition con arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); RAJA::ReduceMin< parallelDeviceReduce, real64 > minVal( 1.0 ); @@ -541,12 +545,12 @@ bool CompositionalMultiphaseFVM::checkSystemSolution( DomainPartition const & do arrayView1d< globalIndex const > const & dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); - arrayView1d< real64 const > const & pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const & dPres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const & pres = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); + arrayView1d< real64 const > const & dPres = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); localIndex const subRegionSolutionCheck = IsothermalCompositionalMultiphaseBaseKernels:: @@ -583,13 +587,13 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), - viewKeyStruct::deltaPressureString(), + extrinsicMeshData::flow::deltaPressure::key(), scalingFactor, pressureMask ); dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), - viewKeyStruct::deltaGlobalCompDensityString(), + extrinsicMeshData::flow::deltaGlobalCompDensity::key(), scalingFactor, ~pressureMask ); @@ -601,121 +605,45 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana } std::map< string, string_array > fieldNames; - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaPressureString() ) ); - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaGlobalCompDensityString() ) ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaPressure::key() ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaGlobalCompDensity::key() ); if( !m_isothermalFlag ) { - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaTemperatureString() ) ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaTemperature::key() ); } CommunicationTools::getInstance().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), true ); } -void CompositionalMultiphaseFVM::updatePhaseMobility( Group & dataGroup, localIndex const targetIndex ) const +void CompositionalMultiphaseFVM::updatePhaseMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; - // note that for convenience, the phase mobility computed here also includes phase density - - // outputs - - arrayView2d< real64, compflow::USD_PHASE > const phaseMob = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseMobilityString() ); - - arrayView2d< real64, compflow::USD_PHASE > const dPhaseMob_dPres = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseMobility_dPressureString() ); - - arrayView3d< real64, compflow::USD_PHASE_DC > const dPhaseMob_dComp = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseMobility_dGlobalCompDensityString() ); - - // inputs - - arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); - - arrayView2d< real64 const, compflow::USD_PHASE > const dPhaseVolFrac_dPres = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); - - arrayView3d< real64 const, compflow::USD_PHASE_DC > const dPhaseVolFrac_dComp = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ); - - arrayView3d< real64 const, compflow::USD_COMP_DC > const dCompFrac_dCompDens = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); + // note that the phase mobility computed here also includes phase density MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( dataGroup, m_fluidModelNames[targetIndex] ); - - 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(); - - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc = fluid.phaseViscosity(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres = fluid.dPhaseViscosity_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp = fluid.dPhaseViscosity_dGlobalCompFraction(); - RelativePermeabilityBase const & relperm = getConstitutiveModel< RelativePermeabilityBase >( dataGroup, m_relPermModelNames[targetIndex] ); - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm = relperm.phaseRelPerm(); - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac = relperm.dPhaseRelPerm_dPhaseVolFraction(); - if( m_isothermalFlag ) { - IsothermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector2 - < IsothermalCompositionalMultiphaseFVMKernels::PhaseMobilityKernel > - ( m_numComponents, - m_numPhases, - dataGroup.size(), - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseVisc, - dPhaseVisc_dPres, - dPhaseVisc_dComp, - phaseRelPerm, - dPhaseRelPerm_dPhaseVolFrac, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dComp ); + IsothermalCompositionalMultiphaseFVMKernels:: + PhaseMobilityKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dataGroup, + fluid, + relperm ); } else { - // get thermal views - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp = fluid.dPhaseDensity_dTemperature(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp = fluid.dPhaseViscosity_dTemperature(); - arrayView2d< real64 const, compflow::USD_PHASE > const dPhaseVolFrac_dTemp = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dTemperatureString() ); - - arrayView2d< real64, compflow::USD_PHASE > const dPhaseMob_dTemp = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseMobility_dTemperatureString() ); - - ThermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector2 - < ThermalCompositionalMultiphaseFVMKernels::PhaseMobilityKernel > - ( m_numComponents, - m_numPhases, - dataGroup.size(), - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dTemp, - dPhaseDens_dComp, - phaseVisc, - dPhaseVisc_dPres, - dPhaseVisc_dTemp, - dPhaseVisc_dComp, - phaseRelPerm, - dPhaseRelPerm_dPhaseVolFrac, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dTemp, - dPhaseVolFrac_dComp, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dTemp, - dPhaseMob_dComp ); + IsothermalCompositionalMultiphaseFVMKernels:: // TODO FRANCOIS + PhaseMobilityKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dataGroup, + fluid, + relperm ); } } @@ -747,10 +675,22 @@ void CompositionalMultiphaseFVM::applyAquiferBC( real64 const time, [&] ( AquiferBoundaryCondition const & bc, string const & setName, SortedArrayView< localIndex const > const &, - Group &, + Group & subRegion, string const & ) { BoundaryStencil const & stencil = fluxApprox.getStencil< BoundaryStencil >( mesh, setName ); + if( bc.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetFaces = MpiWrapper::sum< globalIndex >( stencil.size() ); + string const logMessage = string( "CompositionalMultiphaseFVM {}: at time {}s, " ) + + string( "the <{}> boundary condition '{}' is applied to the face set '{}' in '{}'. " ) + + string( "\nThe total number of target faces (including ghost faces) is {}. " ) + + string( "\nNote that if this number is equal to zero, the boundary condition will not be applied on this face set." ); + GEOSX_LOG_RANK_0( GEOSX_FMT( logMessage, + getName(), time+dt, AquiferBoundaryCondition::catalogName(), + bc.getName(), setName, subRegion.getName(), numTargetFaces ) ); + } + if( stencil.size() == 0 ) { return; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.hpp index 68de96e64dd..ffef9503afa 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.hpp @@ -123,7 +123,7 @@ class CompositionalMultiphaseFVM : public CompositionalMultiphaseBase virtual void - updatePhaseMobility( Group & dataGroup, localIndex const targetIndex ) const override; + updatePhaseMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const override; virtual void applyAquiferBC( real64 const time, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp index 35e10fd6e26..fbd1a73a897 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp @@ -27,8 +27,10 @@ #include "finiteVolume/HybridMimeticDiscretization.hpp" #include "finiteVolume/MimeticInnerProductDispatch.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" -#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp" /** @@ -74,11 +76,11 @@ void CompositionalMultiphaseHybridFVM::registerDataOnMesh( Group & meshBodies ) FaceManager & faceManager = meshLevel.getFaceManager(); // primary variables: face pressure changes - faceManager.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + + faceManager.registerExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >( getName() ); // auxiliary data for the buoyancy coefficient - faceManager.registerWrapper< array1d< real64 > >( viewKeyStruct::mimGravityCoefString() ); + faceManager.registerExtrinsicData< extrinsicMeshData::flow::mimGravityCoefficient >( getName() ); } ); } @@ -187,7 +189,7 @@ void CompositionalMultiphaseHybridFVM::precomputeData( MeshLevel & mesh ) faceManager.getReference< array1d< real64 > >( m_transMultName ); arrayView1d< real64 > const mimFaceGravCoef = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::mimGravityCoefString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::mimGravityCoefficient >(); ArrayOfArraysView< localIndex const > const & faceToNodes = faceManager.nodeList().toViewConst(); @@ -205,7 +207,7 @@ void CompositionalMultiphaseHybridFVM::precomputeData( MeshLevel & mesh ) arrayView3d< real64 const > const & elemPerm = getConstitutiveModel< PermeabilityBase >( subRegion, m_permeabilityModelNames[targetIndex] ).permeability(); arrayView1d< real64 const > const elemGravCoef = - subRegion.template getReference< array1d< real64 > >( viewKeyStruct::gravityCoefString() ); + subRegion.template getReference< array1d< real64 > >( extrinsicMeshData::flow::gravityCoefficient::key() ); arrayView1d< real64 const > const & elemVolume = subRegion.getElementVolume(); arrayView2d< localIndex const > const & elemToFaces = subRegion.faceList(); @@ -249,7 +251,7 @@ void CompositionalMultiphaseHybridFVM::implicitStepSetup( real64 const & time_n, // get the accumulated pressure updates arrayView1d< real64 > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); // zero out the face pressures dFacePres.zero(); @@ -271,9 +273,9 @@ void CompositionalMultiphaseHybridFVM::implicitStepComplete( real64 const & time // get the face-based pressure arrayView1d< real64 > const facePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 > const dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); forAll< parallelDevicePolicy<> >( faceManager.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iface ) { @@ -401,15 +403,15 @@ void CompositionalMultiphaseHybridFVM::assembleFluxTerms( real64 const dt, // get the face-centered pressures arrayView1d< real64 const > const & facePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 const > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); // get the face-centered depth arrayView1d< real64 const > const & faceGravCoef = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::gravityCoefString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >(); arrayView1d< real64 const > const & mimFaceGravCoef = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::mimGravityCoefString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::mimGravityCoefficient >(); // get the face-centered transMultiplier arrayView1d< real64 const > const & transMultiplier = @@ -509,9 +511,9 @@ real64 CompositionalMultiphaseHybridFVM::scalingForSystemSolution( DomainPartiti arrayView1d< integer const > const & faceGhostRank = faceManager.ghostRank(); arrayView1d< real64 const > const & facePressure = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 const > const & dFacePressure = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); globalIndex const rankOffset = dofManager.rankOffset(); string const dofKey = dofManager.getKey( viewKeyStruct::elemDofFieldString() ); @@ -524,14 +526,14 @@ real64 CompositionalMultiphaseHybridFVM::scalingForSystemSolution( DomainPartiti arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & pressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); arrayView1d< real64 const > const & dPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); RAJA::ReduceMin< parallelDeviceReduce, real64 > minElemVal( 1.0 ); @@ -635,14 +637,14 @@ bool CompositionalMultiphaseHybridFVM::checkSystemSolution( DomainPartition cons arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & elemPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); arrayView1d< real64 const > const & dElemPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); localIndex const subRegionSolutionCheck = IsothermalCompositionalMultiphaseBaseKernels:: @@ -670,9 +672,9 @@ bool CompositionalMultiphaseHybridFVM::checkSystemSolution( DomainPartition cons faceManager.getReference< array1d< globalIndex > >( faceDofKey ); arrayView1d< real64 const > const & facePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 const > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); localIndex const faceSolutionCheck = CompositionalMultiphaseHybridFVMKernels::SolutionCheckKernel::launch< parallelDevicePolicy<>, @@ -759,7 +761,7 @@ real64 CompositionalMultiphaseHybridFVM::calculateResidualNorm( DomainPartition arrayView1d< globalIndex const > const & elemDofNumber = subRegion.getReference< array1d< globalIndex > >( elemDofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & totalDensOld = subRegion.getReference< array1d< real64 > >( viewKeyStruct::totalDensityOldString() ); + arrayView1d< real64 const > const & totalDensOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::totalDensityOld >(); CoupledSolidBase const & solidModel = getConstitutiveModel< CoupledSolidBase >( subRegion, m_solidModelNames[targetIndex] ); @@ -833,13 +835,13 @@ void CompositionalMultiphaseHybridFVM::applySystemSolution( DofManager const & d dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), - viewKeyStruct::deltaPressureString(), + extrinsicMeshData::flow::deltaPressure::key(), scalingFactor, pressureMask ); dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), - viewKeyStruct::deltaGlobalCompDensityString(), + extrinsicMeshData::flow::deltaGlobalCompDensity::key(), scalingFactor, ~pressureMask ); @@ -854,15 +856,15 @@ void CompositionalMultiphaseHybridFVM::applySystemSolution( DofManager const & d dofManager.addVectorToField( localSolution, viewKeyStruct::faceDofFieldString(), - viewKeyStruct::deltaFacePressureString(), + extrinsicMeshData::flow::deltaFacePressure::key(), scalingFactor ); // 3. synchronize std::map< string, string_array > fieldNames; - fieldNames["face"].emplace_back( string( viewKeyStruct::deltaFacePressureString() ) ); - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaPressureString() ) ); - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaGlobalCompDensityString() ) ); + fieldNames["face"].emplace_back( extrinsicMeshData::flow::deltaFacePressure::key() ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaPressure::key() ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaGlobalCompDensity::key() ); CommunicationTools::getInstance().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), @@ -883,69 +885,27 @@ void CompositionalMultiphaseHybridFVM::resetStateToBeginningOfStep( DomainPartit // get the accumulated face pressure updates arrayView1d< real64 > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); // zero out the face pressures dFacePres.zero(); } -void CompositionalMultiphaseHybridFVM::updatePhaseMobility( Group & dataGroup, localIndex const targetIndex ) const +void CompositionalMultiphaseHybridFVM::updatePhaseMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; - // note that the phase mobility computed here does NOT include phase density - - // outputs - - arrayView2d< real64, compflow::USD_PHASE > const phaseMob = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseMobilityString() ); - - arrayView2d< real64, compflow::USD_PHASE > const dPhaseMob_dPres = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseMobility_dPressureString() ); - - arrayView3d< real64, compflow::USD_PHASE_DC > const dPhaseMob_dComp = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseMobility_dGlobalCompDensityString() ); - - // inputs - - arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFrac = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); - - arrayView2d< real64 const, compflow::USD_PHASE > const dPhaseVolFrac_dPres = - dataGroup.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); - - arrayView3d< real64 const, compflow::USD_PHASE_DC > const dPhaseVolFrac_dComp = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ); - - arrayView3d< real64 const, compflow::USD_COMP_DC > const dCompFrac_dCompDens = - dataGroup.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); - MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( dataGroup, m_fluidModelNames[targetIndex] ); - - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc = fluid.phaseViscosity(); - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres = fluid.dPhaseViscosity_dPressure(); - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp = fluid.dPhaseViscosity_dGlobalCompFraction(); - RelativePermeabilityBase const & relperm = getConstitutiveModel< RelativePermeabilityBase >( dataGroup, m_relPermModelNames[targetIndex] ); - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm = relperm.phaseRelPerm(); - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac = relperm.dPhaseRelPerm_dPhaseVolFraction(); - - KernelLaunchSelector2< PhaseMobilityKernel >( m_numComponents, m_numPhases, - dataGroup.size(), - dCompFrac_dCompDens, - phaseVisc, - dPhaseVisc_dPres, - dPhaseVisc_dComp, - phaseRelPerm, - dPhaseRelPerm_dPhaseVolFrac, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dComp, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dComp ); + CompositionalMultiphaseHybridFVMKernels:: + PhaseMobilityKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dataGroup, + fluid, + relperm ); } REGISTER_CATALOG_ENTRY( SolverBase, CompositionalMultiphaseHybridFVM, std::string const &, Group * const ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp index 8cc653a4f88..c7c451fe952 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp @@ -133,7 +133,7 @@ class CompositionalMultiphaseHybridFVM : public CompositionalMultiphaseBase arrayView1d< real64 > const & localRhs ) const override; virtual void - updatePhaseMobility( Group & dataGroup, localIndex const targetIndex ) const override; + updatePhaseMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const override; virtual void applyAquiferBC( real64 const time, @@ -157,13 +157,6 @@ class CompositionalMultiphaseHybridFVM : public CompositionalMultiphaseBase // inputs static constexpr char const * maxRelativePresChangeString() { return "maxRelativePressureChange"; } - // primary face-based field - static constexpr char const * deltaFacePressureString() { return "deltaFacePressure"; } - - // auxiliary data for the buoyancy term - // TODO: change the name - static constexpr char const * mimGravityCoefString() { return "mimGravityCoefficient"; } - }; virtual void initializePostInitialConditionsPreSubGroups() override; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp index e03f5a88e67..cd7222d1431 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp @@ -23,6 +23,7 @@ #include "finiteVolume/mimeticInnerProducts/BdVLMInnerProduct.hpp" #include "finiteVolume/mimeticInnerProducts/TPFAInnerProduct.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/HybridFVMHelperKernels.hpp" namespace geosx @@ -33,7 +34,7 @@ namespace CompositionalMultiphaseHybridFVMKernels /******************************** UpwindingHelper ********************************/ -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > void UpwindingHelper:: upwindViscousCoefficient( localIndex const (&localIds)[ 3 ], @@ -69,24 +70,24 @@ UpwindingHelper:: real64 totalMob = 0; real64 dTotalMob_dPres = 0; real64 dTotalMob_dCompDens[ NC ]{}; - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { totalMob = totalMob + phaseMob[er][esr][ei][ip]; dTotalMob_dPres = dTotalMob_dPres + dPhaseMob_dPres[er][esr][ei][ip]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dTotalMob_dCompDens[ic] = dTotalMob_dCompDens[ic] + dPhaseMob_dCompDens[er][esr][ei][ip][ic]; } } real64 const totalMobInv = 1.0 / totalMob; - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { // 3) Compute viscous mobility ratio: \frac{\lambda_{\ell}}{\lambda_T} real64 const upwMobRatio = phaseMob[er][esr][ei][ip] * totalMobInv; real64 const dUpwMobRatio_dPres = ( dPhaseMob_dPres[er][esr][ei][ip] - upwMobRatio * dTotalMob_dPres ) * totalMobInv; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dUpwMobRatio_dCompDens[ic] = ( dPhaseMob_dCompDens[er][esr][ei][ip][ic] - upwMobRatio * dTotalMob_dCompDens[ic] ) * totalMobInv; @@ -100,14 +101,14 @@ UpwindingHelper:: real64 const upwDensMobRatio = phaseDens[er][esr][ei][0][ip] * upwMobRatio; real64 const dUpwDensMobRatio_dPres = dPhaseDens_dPres[er][esr][ei][0][ip] * upwMobRatio + phaseDens[er][esr][ei][0][ip] * dUpwMobRatio_dPres; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dUpwDensMobRatio_dCompDens[ic] = dPhaseDens_dC[ic] * upwMobRatio + phaseDens[er][esr][ei][0][ip] * dUpwMobRatio_dCompDens[ic]; } // 5) Multiply density mobility ratio by phase comp fraction: x_{c,\ell} \rho^{up}_{\ell} \frac{\lambda_{\ell}}{\lambda_T} - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], @@ -116,7 +117,7 @@ UpwindingHelper:: upwPhaseViscCoef[ip][ic] = phaseCompFrac[er][esr][ei][0][ip][ic] * upwDensMobRatio; dUpwPhaseViscCoef_dPres[ip][ic] = dPhaseCompFrac_dPres[er][esr][ei][0][ip][ic] * upwDensMobRatio + phaseCompFrac[er][esr][ei][0][ip][ic] * dUpwDensMobRatio_dPres; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dUpwPhaseViscCoef_dCompDens[ip][ic][jc] = dPhaseCompFrac_dC[jc] * upwDensMobRatio + phaseCompFrac[er][esr][ei][0][ip][ic] * dUpwDensMobRatio_dCompDens[jc]; @@ -128,7 +129,7 @@ UpwindingHelper:: } -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > GEOSX_HOST_DEVICE void UpwindingHelper:: @@ -192,10 +193,10 @@ UpwindingHelper:: real64 dPhaseDens_dC[ NC ]{}; real64 dPhaseCompFrac_dC[ NC ]{}; - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { localIndex k = 0; - for( localIndex jp = 0; jp < NP; ++jp ) + for( integer jp = 0; jp < NP; ++jp ) { if( ip == jp ) { @@ -218,7 +219,7 @@ UpwindingHelper:: dMobRatio_dPres[posd] = ( dPhaseMob_dPres[erd][esrd][eid][jp] * phaseMob[eru][esru][eiu][ip] - mobRatio * dTotalMob_dPres[posd] ) * totalMobInv; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dMobRatio_dCompDens[posu][ic] = ( dPhaseMob_dCompDens[eru][esru][eiu][ip][ic] * phaseMob[erd][esrd][eid][jp] - mobRatio * dTotalMob_dCompDens[posu][ic] ) * totalMobInv; @@ -235,7 +236,7 @@ UpwindingHelper:: dDensMobRatio_dPres[posu] = dPhaseDens_dPres[eru][esru][eiu][0][ip] * mobRatio + phaseDens[eru][esru][eiu][0][ip] * dMobRatio_dPres[posu]; dDensMobRatio_dPres[posd] = phaseDens[eru][esru][eiu][0][ip] * dMobRatio_dPres[posd]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dDensMobRatio_dCompDens[posu][ic] = dPhaseDens_dC[ic] * mobRatio + phaseDens[eru][esru][eiu][0][ip] * dMobRatio_dCompDens[posu][ic]; @@ -243,7 +244,7 @@ UpwindingHelper:: } // 3.d) Compute the final gravity coefficient \x_{up}_{c,p} \rho_p \frac{\lambda_l \lambda_m}{\lambda_T} - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { applyChainRule( NC, dCompFrac_dCompDens[eru][esru][eiu], @@ -254,7 +255,7 @@ UpwindingHelper:: + 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]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dUpwPhaseGravCoef_dCompDens[ip][k][ic][posu][jc] = dPhaseCompFrac_dC[jc] * densMobRatio + phaseCompFrac[eru][esru][eiu][0][ip][ic] * dDensMobRatio_dCompDens[posu][jc]; @@ -266,7 +267,7 @@ UpwindingHelper:: } } -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > GEOSX_HOST_DEVICE void UpwindingHelper:: @@ -292,7 +293,7 @@ UpwindingHelper:: real64 dPhaseMassDens_dCNeighbor[ NC ]{}; real64 dPhaseMassDens_dC[ NC ]{}; - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { applyChainRule( NC, dCompFrac_dCompDens[er][esr][ei], @@ -304,7 +305,7 @@ UpwindingHelper:: dPhaseMassDens_dCNeighbor ); localIndex k = 0; - for( localIndex jp = 0; jp < NP; ++jp ) + for( integer jp = 0; jp < NP; ++jp ) { if( ip == jp ) { @@ -321,7 +322,7 @@ UpwindingHelper:: 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] *= 0.5 * transGravCoef; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dPhaseGravTerm_dCompDens[ip][k][Pos::LOCAL][ic] = -0.5 * transGravCoef * dPhaseMassDens_dCLoc[ic]; dPhaseGravTerm_dCompDens[ip][k][Pos::NEIGHBOR][ic] = -0.5 * transGravCoef * dPhaseMassDens_dCNeighbor[ic]; @@ -330,7 +331,7 @@ UpwindingHelper:: dCompFrac_dCompDens[er][esr][ei], dPhaseMassDens_dCompFrac[er][esr][ei][0][jp], dPhaseMassDens_dC ); - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dPhaseGravTerm_dCompDens[ip][k][Pos::LOCAL][ic] += 0.5 * transGravCoef * dPhaseMassDens_dC[ic]; } @@ -347,7 +348,7 @@ UpwindingHelper:: } } -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > GEOSX_HOST_DEVICE void UpwindingHelper:: @@ -368,7 +369,7 @@ UpwindingHelper:: phaseGravTerm, totalMobIds, totalMobPos ); - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { localIndex const er = totalMobIds[ip][0]; localIndex const esr = totalMobIds[ip][1]; @@ -376,7 +377,7 @@ UpwindingHelper:: localIndex const pos = totalMobPos[ip]; totalMob = totalMob + phaseMob[er][esr][ei][ip]; dTotalMob_dPres[pos] = dTotalMob_dPres[pos] + dPhaseMob_dPres[er][esr][ei][pos]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dTotalMob_dCompDens[pos][ic] = dTotalMob_dCompDens[pos][ic] + dPhaseMob_dCompDens[er][esr][ei][ip][ic]; } @@ -420,7 +421,7 @@ UpwindingHelper:: } } -template< localIndex NP > +template< integer NP > GEOSX_HOST_DEVICE void UpwindingHelper:: @@ -459,7 +460,7 @@ UpwindingHelper:: { // TODO Francois: this should be improved // currently this implements the algorithm proposed by SH Lee - for( localIndex ip = 0; ip < NP; ++ip ) + 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 ) || @@ -586,7 +587,7 @@ INST_UpwindingHelperNP( 3 ); /******************************** AssemblerKernelHelper ********************************/ -template< localIndex NF, localIndex NC, localIndex NP > +template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE void AssemblerKernelHelper:: @@ -616,7 +617,7 @@ AssemblerKernelHelper:: real64 dPhaseMobPotDif_dCompDens[ NC ]{}; // 0) precompute dPhaseDens_dC since it is always computed at the element center - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { applyChainRule( NC, dElemCompFrac_dCompDens, @@ -624,11 +625,11 @@ AssemblerKernelHelper:: dPhaseMassDens_dC[ip] ); } - for( localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) + for( integer ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) { // now in the following nested loop, // we compute the contribution of face jfaceLoc to the one sided total volumetric flux at face iface - for( localIndex jfaceLoc = 0; jfaceLoc < NF; ++jfaceLoc ) + for( integer jfaceLoc = 0; jfaceLoc < NF; ++jfaceLoc ) { // depth difference between element center and face center @@ -636,7 +637,7 @@ AssemblerKernelHelper:: real64 const fGravCoef = faceGravCoef[elemToFaces[jfaceLoc]]; real64 const gravCoefDif = ccGravCoef - fGravCoef; - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { // 1) compute the potential diff between the cell center and the face center @@ -647,7 +648,7 @@ AssemblerKernelHelper:: real64 const presDif = ccPres - fPres; real64 const dPresDif_dPres = 1; real64 const dPresDif_dFacePres = -1; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dPresDif_dCompDens[ic] = 0.0; // no capillary pressure } @@ -667,7 +668,7 @@ AssemblerKernelHelper:: real64 const dPhaseMobPotDif_dPres = dElemPhaseMob_dPres[ip] * phasePotDif + elemPhaseMob[ip] * (dPresDif_dPres - dPhaseGravDif_dPres); real64 const dPhaseMobPotDif_dFacePres = elemPhaseMob[ip] * dPresDif_dFacePres; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dPhaseMobPotDif_dCompDens[ic] = dElemPhaseMob_dCompDens[ip][ic] * phasePotDif + elemPhaseMob[ip] * (dPresDif_dCompDens[ic] - dPhaseGravDif_dCompDens[ic]); @@ -690,7 +691,7 @@ AssemblerKernelHelper:: } } -template< localIndex NF, localIndex NC, localIndex NP > +template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE void AssemblerKernelHelper:: @@ -728,12 +729,12 @@ AssemblerKernelHelper:: arrayView1d< real64 > const & localRhs ) { using namespace CompositionalMultiphaseUtilities; - localIndex constexpr NDOF = NC+1; + integer constexpr NDOF = NC+1; // dof numbers globalIndex dofColIndicesElemVars[ NDOF*(NF+1) ]{}; globalIndex dofColIndicesFaceVars[ NF ]{}; - for( localIndex idof = 0; idof < NDOF; ++idof ) + for( integer idof = 0; idof < NDOF; ++idof ) { dofColIndicesElemVars[idof] = elemDofNumber[localIds[0]][localIds[1]][localIds[2]] + idof; } @@ -762,7 +763,7 @@ AssemblerKernelHelper:: real64 dUpwPhaseGravCoef_dCompDens[ NP ][ NP-1 ][ NC ][ 2 ][ NC ]{}; // for each element, loop over the one-sided faces - for( localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) + for( integer ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) { // 1) Find if there is a neighbor, and if there is, grab the indices of the neighbor element @@ -873,7 +874,7 @@ AssemblerKernelHelper:: // we are ready to assemble the local flux and its derivatives // no need for atomic adds - each row is assembled by a single thread - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { localIndex const eqnRowLocalIndex = LvArray::integerConversion< localIndex >( elemDofNumber[localIds[0]][localIds[1]][localIds[2]] + ic - rankOffset ); @@ -898,7 +899,7 @@ AssemblerKernelHelper:: } } -template< localIndex NF, localIndex NC, localIndex NP > +template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE void AssemblerKernelHelper:: @@ -921,12 +922,12 @@ AssemblerKernelHelper:: globalIndex ( & dofColIndicesElemVars )[ (NC+1)*(NF+1) ], globalIndex ( & dofColIndicesFaceVars )[ NF ] ) { - localIndex constexpr NDOF = NC+1; + integer constexpr NDOF = NC+1; localIndex const elemVarsOffset = NDOF*(ifaceLoc+1); - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { // compute the mass flux at the one-sided face plus its derivatives // add the newly computed flux to the sum @@ -942,7 +943,7 @@ AssemblerKernelHelper:: dDivMassFluxes_dElemVars[ic][0] = dDivMassFluxes_dElemVars[ic][0] + ( elemDofNumber == upwViscDofNumber ) * dt * dUpwPhaseViscCoef_dPres[ip][ic] * oneSidedVolFlux[ifaceLoc]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dDivMassFluxes_dElemVars[ic][jc+1] = dDivMassFluxes_dElemVars[ic][jc+1] + dt_upwPhaseViscCoef * dOneSidedVolFlux_dCompDens[ifaceLoc][jc]; @@ -956,14 +957,14 @@ AssemblerKernelHelper:: + ( elemDofNumber != upwViscDofNumber ) * dt * dUpwPhaseViscCoef_dPres[ip][ic] * oneSidedVolFlux[ifaceLoc]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dDivMassFluxes_dElemVars[ic][elemVarsOffset+jc+1] = dDivMassFluxes_dElemVars[ic][elemVarsOffset+jc+1] + ( elemDofNumber != upwViscDofNumber ) * dt * dUpwPhaseViscCoef_dCompDens[ip][ic][jc] * oneSidedVolFlux[ifaceLoc]; } - for( localIndex jfaceLoc = 0; jfaceLoc < NF; ++jfaceLoc ) + for( integer jfaceLoc = 0; jfaceLoc < NF; ++jfaceLoc ) { dDivMassFluxes_dFaceVars[ic][jfaceLoc] = dDivMassFluxes_dFaceVars[ic][jfaceLoc] + dt_upwPhaseViscCoef * dOneSidedVolFlux_dFacePres[ifaceLoc][jfaceLoc]; @@ -972,14 +973,14 @@ AssemblerKernelHelper:: } // collect the relevant dof numbers - for( localIndex idof = 0; idof < NDOF; ++idof ) + for( integer idof = 0; idof < NDOF; ++idof ) { dofColIndicesElemVars[elemVarsOffset+idof] = neighborDofNumber + idof; } dofColIndicesFaceVars[ifaceLoc] = faceDofNumber; } -template< localIndex NF, localIndex NC, localIndex NP > +template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE void AssemblerKernelHelper:: @@ -994,14 +995,14 @@ AssemblerKernelHelper:: real64 ( & divMassFluxes )[ NC ], real64 ( & dDivMassFluxes_dElemVars )[ NC ][ (NC+1)*(NF+1) ] ) { - localIndex constexpr NDOF = NC+1; + integer constexpr NDOF = NC+1; localIndex const elemVarsOffset = NDOF*(ifaceLoc+1); - for( localIndex ip = 0; ip < NP; ++ip ) + for( integer ip = 0; ip < NP; ++ip ) { - for( localIndex jp = 0; jp < NP - 1; ++jp ) + for( integer jp = 0; jp < NP - 1; ++jp ) { - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { real64 const dt_upwPhaseGravCoef = dt * upwPhaseGravCoef[ip][jp][ic]; @@ -1014,7 +1015,7 @@ AssemblerKernelHelper:: dDivMassFluxes_dElemVars[ic][0] = dDivMassFluxes_dElemVars[ic][0] + dt_upwPhaseGravCoef * dPhaseGravTerm_dPres[ip][jp][Pos::LOCAL]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dDivMassFluxes_dElemVars[ic][jc+1] = dDivMassFluxes_dElemVars[ic][jc+1] + dt * dUpwPhaseGravCoef_dCompDens[ip][jp][ic][Pos::LOCAL][jc] * phaseGravTerm[ip][jp]; @@ -1028,7 +1029,7 @@ AssemblerKernelHelper:: dDivMassFluxes_dElemVars[ic][elemVarsOffset] = dDivMassFluxes_dElemVars[ic][elemVarsOffset] + dt_upwPhaseGravCoef * dPhaseGravTerm_dPres[ip][jp][Pos::NEIGHBOR]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dDivMassFluxes_dElemVars[ic][elemVarsOffset+jc+1] = dDivMassFluxes_dElemVars[ic][elemVarsOffset+jc+1] + dt * dUpwPhaseGravCoef_dCompDens[ip][jp][ic][Pos::NEIGHBOR][jc] * phaseGravTerm[ip][jp]; @@ -1040,7 +1041,7 @@ AssemblerKernelHelper:: } } -template< localIndex NF, localIndex NC, localIndex NP > +template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE void AssemblerKernelHelper:: @@ -1056,7 +1057,7 @@ AssemblerKernelHelper:: CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { - localIndex constexpr NDOF = NC+1; + integer constexpr NDOF = NC+1; // fluxes real64 dFlux_dElemVars[ NDOF ]{}; @@ -1065,13 +1066,13 @@ AssemblerKernelHelper:: // dof numbers globalIndex dofColIndicesElemVars[ NDOF ]{}; globalIndex dofColIndicesFaceVars[ NF ]{}; - for( localIndex idof = 0; idof < NDOF; ++idof ) + for( integer idof = 0; idof < NDOF; ++idof ) { dofColIndicesElemVars[idof] = elemDofNumber + idof; } // for each element, loop over the local (one-sided) faces - for( localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) + for( integer ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) { if( faceGhostRank[elemToFaces[ifaceLoc]] >= 0 ) { @@ -1081,12 +1082,12 @@ AssemblerKernelHelper:: // flux at this face real64 const flux = oneSidedVolFlux[ifaceLoc]; dFlux_dElemVars[0] = dOneSidedVolFlux_dPres[ifaceLoc]; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dFlux_dElemVars[ic+1] = dOneSidedVolFlux_dCompDens[ifaceLoc][ic]; } - for( localIndex jfaceLoc = 0; jfaceLoc < NF; ++jfaceLoc ) + for( integer jfaceLoc = 0; jfaceLoc < NF; ++jfaceLoc ) { dFlux_dFaceVars[jfaceLoc] = dOneSidedVolFlux_dFacePres[ifaceLoc][jfaceLoc]; dofColIndicesFaceVars[jfaceLoc] = faceDofNumber[elemToFaces[jfaceLoc]]; @@ -1263,7 +1264,7 @@ INST_AssemblerKernelHelper( 6, 5, 3 ); /******************************** AssemblerKernel ********************************/ -template< localIndex NF, localIndex NC, localIndex NP > +template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE void AssemblerKernel:: @@ -1486,7 +1487,7 @@ INST_AssemblerKernel( 6, 5, 3 ); /******************************** FluxKernel ********************************/ -template< localIndex NF, localIndex NC, localIndex NP, typename IP_TYPE > +template< integer NF, integer NC, integer NP, typename IP_TYPE > void FluxKernel:: launch( localIndex er, localIndex esr, @@ -1533,9 +1534,9 @@ FluxKernel:: // get the cell-centered pressures arrayView1d< real64 const > const & elemPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseBase::viewKeyStruct::pressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); arrayView1d< real64 const > const & dElemPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseBase::viewKeyStruct::deltaPressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); // get the element data needed for transmissibility computation arrayView2d< real64 const > const & elemCenter = @@ -1550,7 +1551,7 @@ FluxKernel:: // get the cell-centered depth arrayView1d< real64 const > const & elemGravCoef = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseBase::viewKeyStruct::gravityCoefString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::gravityCoefficient::key() ); // assemble the residual and Jacobian element by element // in this loop we assemble both equation types: mass conservation in the elements and constraints at the faces @@ -1744,203 +1745,6 @@ INST_FluxKernel( 6, 5, 3, mimeticInnerProduct::BdVLMInnerProduct const ); #undef INST_FluxKernel - -/******************************** PhaseMobilityKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -void -PhaseMobilityKernel:: - compute( arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseVisc_dComp, - arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & phaseRelPerm, - arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dPhaseRelPerm_dPhaseVolFrac, - 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_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseMob, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dPres, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseMob_dComp ) -{ - real64 dRelPerm_dC[NC]; - real64 dVisc_dC[NC]; - - for( localIndex ip = 0; ip < NP; ++ip ) - { - // compute the phase mobility only if the phase is present - bool const phaseExists = (phaseVolFrac[ip] > 0); - if( !phaseExists ) - { - phaseMob[ip] = 0.; - dPhaseMob_dPres[ip] = 0.; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = 0.; - } - continue; - } - - real64 const viscosity = phaseVisc[ip]; - real64 const dVisc_dP = dPhaseVisc_dPres[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); - - real64 const relPerm = phaseRelPerm[ip]; - real64 dRelPerm_dP = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - dRelPerm_dC[ic] = 0.0; - } - - for( localIndex jp = 0; jp < NP; ++jp ) - { - real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; - dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; - } - } - - real64 const mobility = relPerm / viscosity; - - phaseMob[ip] = mobility; - dPhaseMob_dPres[ip] = dRelPerm_dP / viscosity - - mobility * dVisc_dP / viscosity; - - // compositional derivatives - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] / viscosity - - mobility * dVisc_dC[jc] / viscosity; - } - } -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( localIndex const size, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dComp[a] ); - } ); -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dComp[a] ); - } ); -} - -#define INST_PhaseMobilityKernel( NC, NP ) \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, \ - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, \ - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) - -INST_PhaseMobilityKernel( 1, 1 ); -INST_PhaseMobilityKernel( 2, 1 ); -INST_PhaseMobilityKernel( 3, 1 ); -INST_PhaseMobilityKernel( 4, 1 ); -INST_PhaseMobilityKernel( 5, 1 ); - -INST_PhaseMobilityKernel( 1, 2 ); -INST_PhaseMobilityKernel( 2, 2 ); -INST_PhaseMobilityKernel( 3, 2 ); -INST_PhaseMobilityKernel( 4, 2 ); -INST_PhaseMobilityKernel( 5, 2 ); - -INST_PhaseMobilityKernel( 1, 3 ); -INST_PhaseMobilityKernel( 2, 3 ); -INST_PhaseMobilityKernel( 3, 3 ); -INST_PhaseMobilityKernel( 4, 3 ); -INST_PhaseMobilityKernel( 5, 3 ); - -#undef INST_PhaseMobilityKernel - - } // namespace CompositionalMultiphaseHybridFVMKernels } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp index 535e1d358db..6caddf54941 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp @@ -20,13 +20,14 @@ #define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEHYBRIDFVMKERNELS_HPP #include "common/DataTypes.hpp" -#include "constitutive/fluid/layouts.hpp" -#include "constitutive/relativePermeability/layouts.hpp" -#include "constitutive/capillaryPressure/layouts.hpp" -#include "linearAlgebra/interfaces/InterfaceTypes.hpp" -#include "mesh/MeshLevel.hpp" -#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp" + +#include "constitutive/fluid/MultiFluidBase.hpp" #include "constitutive/permeability/PermeabilityBase.hpp" +#include "constitutive/relativePermeability/RelativePermeabilityBase.hpp" +#include "mesh/ElementRegionManager.hpp" +#include "mesh/ObjectManagerBase.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" + namespace geosx { @@ -79,7 +80,7 @@ struct UpwindingHelper * @param[out] dUpwPhaseViscCoef_dCompDens the derivatives of the upwind viscous transport coef wrt component density at this face * @param[out] upwViscDofNumber the dof number of the upwind cell at this face */ - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > GEOSX_HOST_DEVICE static void upwindViscousCoefficient( localIndex const (&localIds)[ 3 ], @@ -125,7 +126,7 @@ struct UpwindingHelper * @param[inout] dUpwPhaseGravCoef_dPres the derivative of the upwinded buoyancy transport coefficient wrt pressure * @param[inout] dUpwPhaseGravCoef_dCompDens the derivative of the upwinded buoyancy transport coefficient wrt component density */ - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > GEOSX_HOST_DEVICE static void upwindBuoyancyCoefficient( localIndex const (&localIds)[ 3 ], @@ -166,7 +167,7 @@ struct UpwindingHelper * @param[inout] dPhaseGravTerm_dCompDens the derivatives of the gravCoef multiplied by the difference in phase densities wrt component * density */ - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > GEOSX_HOST_DEVICE static void computePhaseGravTerm( localIndex const (&localIds)[ 3 ], @@ -192,7 +193,7 @@ struct UpwindingHelper * @param[inout] dTotalMob_dPres the derivative of the upwinded total mobility wrt pressure * @param[inout] dTotalMob_dCompDens the derivative of the upwinded total mobility wrt component density */ - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > GEOSX_HOST_DEVICE static void computeUpwindedTotalMobility( localIndex const (&localIds)[ 3 ], @@ -236,7 +237,7 @@ struct UpwindingHelper * @param[out] totalMobIds for each phase, triplet of indices of the upwind element * @param[out] totalMobPos for each phase, flag specifying with the upwind element is local or neighbor */ - template< localIndex NP > + template< integer NP > GEOSX_HOST_DEVICE static void setIndicesForTotalMobilityUpwinding( localIndex const (&localIds)[ 3 ], @@ -285,7 +286,7 @@ struct AssemblerKernelHelper * @param[out] dOneSidedVolFlux_dFacePres the derivatives of the vol fluxes wrt to this element's face pressures * @param[out] dOneSidedVolFlux_dCompDens the derivatives of the vol fluxes wrt to this element's component density */ - template< localIndex NF, localIndex NC, localIndex NP > + template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE static void applyGradient( arrayView1d< real64 const > const & facePres, @@ -337,7 +338,7 @@ struct AssemblerKernelHelper * @param[inout] localMatrix the Jacobian matrix * @param[inout] localRhs the residual */ - template< localIndex NF, localIndex NC, localIndex NP > + template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE static void assembleFluxDivergence( localIndex const (&localIds)[ 3 ], @@ -392,7 +393,7 @@ struct AssemblerKernelHelper * @param[inout] dofColIndicesElemVars degrees of freedom of the cells involved in the flux divergence * @param[inout] dofColIndicesFaceVars degrees of freedom of the faces involved in the flux divergence */ - template< localIndex NF, localIndex NC, localIndex NP > + template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE static void assembleViscousFlux( localIndex const ifaceLoc, @@ -430,7 +431,7 @@ struct AssemblerKernelHelper * @param[inout] dDivMassFluxes_dElemVars the derivatives of the flux divergence wrt the element centered vars (pres and comp dens) * @param[inout] dofColIndicesElemVars degrees of freedom of the cells involved in the flux divergence */ - template< localIndex NF, localIndex NC, localIndex NP > + template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE static void assembleBuoyancyFlux( localIndex const ifaceLoc, @@ -458,7 +459,7 @@ struct AssemblerKernelHelper * @param[inout] matrix the jacobian matrix * @param[inout] rhs the residual */ - template< localIndex NF, localIndex NC, localIndex NP > + template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE static void assembleFaceConstraints( arrayView1d< globalIndex const > const & faceDofNumber, @@ -529,7 +530,7 @@ struct AssemblerKernel * @param[inout] matrix the system matrix * @param[inout] rhs the system right-hand side vector */ - template< localIndex NF, localIndex NC, localIndex NP > + template< integer NF, integer NC, integer NP > GEOSX_HOST_DEVICE static void compute( localIndex const er, localIndex const esr, localIndex const ei, @@ -624,7 +625,7 @@ struct FluxKernel * @param[inout] matrix the system matrix * @param[inout] rhs the system right-hand side vector */ - template< localIndex NF, localIndex NC, localIndex NP, typename IP_TYPE > + template< integer NF, integer NC, integer NP, typename IP_TYPE > static void launch( localIndex er, localIndex esr, CellElementSubRegion const & subRegion, @@ -668,59 +669,204 @@ struct FluxKernel /******************************** PhaseMobilityKernel ********************************/ /** - * @brief Functions to compute phase mobilities and derivatives from viscosity and relperm + * @class PhaseMobilityKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the phase mobilities */ -struct PhaseMobilityKernel +template< integer NUM_COMP, integer NUM_PHASE > +class PhaseMobilityKernel : public IsothermalCompositionalMultiphaseBaseKernels::PropertyKernelBase< NUM_COMP > { - template< localIndex NC, localIndex NP > +public: + + using Base = IsothermalCompositionalMultiphaseBaseKernels::PropertyKernelBase< NUM_COMP >; + using Base::numComp; + + /// Compile time value for the number of phases + static constexpr integer numPhase = NUM_PHASE; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] relperm the relperm model + */ + PhaseMobilityKernel( ObjectManagerBase & subRegion, + MultiFluidBase const & fluid, + RelativePermeabilityBase const & relperm ) + : Base(), + m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), + m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), + 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_phaseRelPerm( relperm.phaseRelPerm() ), + m_dPhaseRelPerm_dPhaseVolFrac( relperm.dPhaseRelPerm_dPhaseVolFraction() ), + m_phaseMob( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobility >() ), + m_dPhaseMob_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dPressure >() ), + m_dPhaseMob_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity >() ) + {} + + /** + * @brief Compute the phase mobilities in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] phaseMobilityKernelOp the function used to customize the kernel + */ + template< typename FUNC = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc > GEOSX_HOST_DEVICE - static void - compute( arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseVisc_dComp, - arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & phaseRelPerm, - arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dPhaseRelPerm_dPhaseVolFrac, - 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_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseMob, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dPres, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseMob_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); + void compute( localIndex const ei, + FUNC && phaseMobilityKernelOp = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc{} ) const + { + 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]; + 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]; + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const dPhaseVolFrac_dPres = m_dPhaseVolFrac_dPres[ei]; + arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac_dComp = m_dPhaseVolFrac_dComp[ei]; + arraySlice1d< real64, compflow::USD_PHASE - 1 > const phaseMob = m_phaseMob[ei]; + arraySlice1d< real64, compflow::USD_PHASE - 1 > const dPhaseMob_dPres = m_dPhaseMob_dPres[ei]; + arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const dPhaseMob_dComp = m_dPhaseMob_dComp[ei]; + + real64 dRelPerm_dC[numComp]{}; + real64 dVisc_dC[numComp]{}; + + for( integer ip = 0; ip < numPhase; ++ip ) + { + // compute the phase mobility only if the phase is present + bool const phaseExists = (phaseVolFrac[ip] > 0); + if( !phaseExists ) + { + phaseMob[ip] = 0.; + dPhaseMob_dPres[ip] = 0.; + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseMob_dComp[ip][jc] = 0.; + } + continue; + } + + real64 const viscosity = phaseVisc[ip]; + real64 const dVisc_dP = dPhaseVisc_dPres[ip]; + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); + + real64 const relPerm = phaseRelPerm[ip]; + real64 dRelPerm_dP = 0.0; + for( integer ic = 0; ic < numComp; ++ic ) + { + dRelPerm_dC[ic] = 0.0; + } + + for( integer jp = 0; jp < numPhase; ++jp ) + { + real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; + dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; + + for( integer jc = 0; jc < numComp; ++jc ) + { + dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; + } + } + + real64 const mobility = relPerm / viscosity; + + phaseMob[ip] = mobility; + dPhaseMob_dPres[ip] = dRelPerm_dP / viscosity + - mobility * dVisc_dP / viscosity; + + // compositional derivatives + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] / viscosity + - mobility * dVisc_dC[jc] / viscosity; + } + + // call the lambda in the phase loop to allow the reuse of the relperm, viscosity, and mobility + // possible use: assemble the derivatives wrt temperature + phaseMobilityKernelOp( ip, phaseMob[ip], dPhaseMob_dPres[ip], dPhaseMob_dComp[ip] ); + } + } + + +protected: + + // inputs + + /// Views on the phase volume fractions + arrayView2d< real64 const, compflow::USD_PHASE > m_phaseVolFrac; + arrayView2d< real64 const, compflow::USD_PHASE > m_dPhaseVolFrac_dPres; + arrayView3d< real64 const, compflow::USD_PHASE_DC > m_dPhaseVolFrac_dComp; + arrayView3d< real64 const, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + + /// 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; + + /// Views on the phase relative permeabilities + arrayView3d< real64 const, relperm::USD_RELPERM > m_phaseRelPerm; + arrayView4d< real64 const, relperm::USD_RELPERM_DS > m_dPhaseRelPerm_dPhaseVolFrac; + + // outputs + + /// Views on the phase mobilities + arrayView2d< real64, compflow::USD_PHASE > m_phaseMob; + arrayView2d< real64, compflow::USD_PHASE > m_dPhaseMob_dPres; + arrayView3d< real64, compflow::USD_PHASE_DC > m_dPhaseMob_dComp; + }; +/** + * @class PhaseMobilityKernelFactory + */ +class PhaseMobilityKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] relperm the relperm model + */ + template< typename POLICY > + static void + createAndLaunch( integer const numComp, + integer const numPhase, + ObjectManagerBase & subRegion, + MultiFluidBase const & fluid, + RelativePermeabilityBase const & relperm ) + { + if( numPhase == 2 ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseMobilityKernel< NUM_COMP, 2 > kernel( subRegion, fluid, relperm ); + PhaseMobilityKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseMobilityKernel< NUM_COMP, 3 > kernel( subRegion, fluid, relperm ); + PhaseMobilityKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } +}; /******************************** ResidualNormKernel ********************************/ @@ -766,7 +912,7 @@ struct ResidualNormKernel { // compute a normalizer to obtain a dimensionless norm real64 sumMobOld = 0.0; - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { sumMobOld += phaseMobOld[er][esr][ei][ip]; } @@ -827,7 +973,7 @@ struct SolutionCheckKernel struct PrecomputeKernel { - template< typename IP_TYPE, localIndex NF > + template< typename IP_TYPE, integer NF > static void launch( localIndex const subRegionSize, localIndex const faceManagerSize, @@ -860,7 +1006,7 @@ struct PrecomputeKernel lengthTolerance, transMatrix ); - for( localIndex ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) + for( integer ifaceLoc = 0; ifaceLoc < NF; ++ifaceLoc ) { mimFaceGravCoefNumerator[elemToFaces[ei][ifaceLoc]] += elemGravCoef[ei] * transMatrix[ifaceLoc][ifaceLoc]; mimFaceGravCoefDenominator[elemToFaces[ei][ifaceLoc]] += transMatrix[ifaceLoc][ifaceLoc]; @@ -902,7 +1048,7 @@ void KernelLaunchSelectorFaceSwitch( T value, LAMBDA && lambda ) } // namespace internal template< typename KERNELWRAPPER, typename IP_TYPE, typename ... ARGS > -void KernelLaunchSelector( localIndex numFacesInElem, localIndex numComps, localIndex numPhases, ARGS && ... args ) +void KernelLaunchSelector( integer numFacesInElem, integer numComps, integer numPhases, ARGS && ... args ) { // Ideally this would be inside the dispatch, but it breaks on Summit with GCC 9.1.0 and CUDA 11.0.3. if( numPhases == 2 ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp index 0e5ac031b0a..aa88d5fbeb4 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp @@ -28,6 +28,7 @@ #include "mainInterface/ProblemManager.hpp" #include "mesh/DomainPartition.hpp" #include "physicsSolvers/fluidFlow/FluxKernelsHelper.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" namespace geosx { @@ -124,7 +125,7 @@ void FlowSolverBase::registerDataOnMesh( Group & meshBodies ) forTargetSubRegions( mesh, [&]( localIndex const, ElementSubRegionBase & subRegion ) { - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::gravityCoefString() ). + subRegion.registerExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >( getName() ). setApplyDefaultValue( 0.0 ); } ); @@ -137,19 +138,19 @@ void FlowSolverBase::registerDataOnMesh( Group & meshBodies ) { SurfaceElementRegion & faceRegion = dynamicCast< SurfaceElementRegion & >( region ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::gravityCoefString() ). - setApplyDefaultValue( 0.0 ); + subRegion.registerExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >( getName() ); + + subRegion.registerExtrinsicData< extrinsicMeshData::flow::aperture0 >( getName() ). + setDefaultValue( faceRegion.getDefaultAperture() ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::aperture0String() ). + subRegion.registerExtrinsicData< extrinsicMeshData::flow::hydraulicAperture >( getName() ). setDefaultValue( faceRegion.getDefaultAperture() ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::hydraulicApertureString() ). - setApplyDefaultValue( faceRegion.getDefaultAperture() ). - setPlotLevel( PlotLevel::LEVEL_0 ); } ); FaceManager & faceManager = mesh.getFaceManager(); - faceManager.registerWrapper< array1d< real64 > >( viewKeyStruct::gravityCoefString() ).setApplyDefaultValue( 0.0 ); + faceManager.registerExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >( getName() ). + setApplyDefaultValue( 0.0 ); } ); } @@ -231,7 +232,7 @@ void FlowSolverBase::precomputeData( MeshLevel & mesh ) arrayView2d< real64 const > const elemCenter = subRegion.getElementCenter(); arrayView1d< real64 > const gravityCoef = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::gravityCoefString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >(); forAll< parallelHostPolicy >( subRegion.size(), [=] ( localIndex const ei ) { @@ -243,7 +244,7 @@ void FlowSolverBase::precomputeData( MeshLevel & mesh ) arrayView2d< real64 const > const faceCenter = faceManager.faceCenter(); arrayView1d< real64 > const gravityCoef = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::gravityCoefString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >(); forAll< parallelHostPolicy >( faceManager.size(), [=] ( localIndex const kf ) { @@ -259,8 +260,8 @@ void FlowSolverBase::updatePorosityAndPermeability( CellElementSubRegion & subRe { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const & pressure = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const & deltaPressure = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const & pressure = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 const > const & deltaPressure = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); CoupledSolidBase & porousSolid = subRegion.template getConstitutiveModel< CoupledSolidBase >( m_solidModelNames[targetIndex] ); @@ -277,11 +278,11 @@ void FlowSolverBase::updatePorosityAndPermeability( SurfaceElementSubRegion & su { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const & pressure = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const & deltaPressure = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const & pressure = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 const > const & deltaPressure = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); - arrayView1d< real64 const > const newHydraulicAperture = subRegion.getReference< array1d< real64 > >( viewKeyStruct::hydraulicApertureString() ); - arrayView1d< real64 const > const oldHydraulicAperture = subRegion.getReference< array1d< real64 > >( viewKeyStruct:: viewKeyStruct::aperture0String() ); + arrayView1d< real64 const > const newHydraulicAperture = subRegion.getExtrinsicData< extrinsicMeshData::flow::hydraulicAperture >(); + arrayView1d< real64 const > const oldHydraulicAperture = subRegion.getExtrinsicData< extrinsicMeshData::flow::aperture0 >(); CoupledSolidBase & porousSolid = subRegion.template getConstitutiveModel< CoupledSolidBase >( m_solidModelNames[targetIndex] ); @@ -298,13 +299,15 @@ void FlowSolverBase::resetViews( MeshLevel & mesh ) { ElementRegionManager const & elemManager = mesh.getElemManager(); + using namespace extrinsicMeshData::flow; + m_pressure.clear(); - m_pressure = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::pressureString() ); - m_pressure.setName( getName() + "/accessors/" + viewKeyStruct::pressureString() ); + m_pressure = elemManager.constructArrayViewAccessor< real64, 1 >( pressure::key() ); + m_pressure.setName( getName() + "/accessors/" + pressure::key() ); m_deltaPressure.clear(); - m_deltaPressure = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaPressureString() ); - m_deltaPressure.setName( getName() + "/accessors/" + viewKeyStruct::deltaPressureString() ); + m_deltaPressure = elemManager.constructArrayViewAccessor< real64, 1 >( deltaPressure::key() ); + m_deltaPressure.setName( getName() + "/accessors/" + deltaPressure::key() ); m_elemGhostRank.clear(); m_elemGhostRank = elemManager.constructArrayViewAccessor< integer, 1 >( ObjectManagerBase::viewKeyStruct::ghostRankString() ); @@ -315,8 +318,8 @@ void FlowSolverBase::resetViews( MeshLevel & mesh ) m_volume.setName( getName() + "/accessors/" + ElementSubRegionBase::viewKeyStruct::elementVolumeString() ); m_gravCoef.clear(); - m_gravCoef = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::gravityCoefString() ); - m_gravCoef.setName( getName() + "/accessors/" + viewKeyStruct::gravityCoefString() ); + m_gravCoef = elemManager.constructArrayViewAccessor< real64, 1 >( gravityCoefficient::key() ); + m_gravCoef.setName( getName() + "/accessors/" + gravityCoefficient::key() ); using keys = PermeabilityBase::viewKeyStruct; @@ -485,6 +488,13 @@ void FlowSolverBase::saveAquiferConvergedState( real64 const & time, fsManager.forSubGroups< AquiferBoundaryCondition >( [&] ( AquiferBoundaryCondition & bc ) { localIndex const aquiferIndex = aquiferNameToAquiferId.at( bc.getName() ); + + if( bc.getLogLevel() >= 1 ) + { + GEOSX_LOG_RANK_0( GEOSX_FMT( string( "FlowSolverBase {}: at time {}s, " ) + + string( "the <{}> boundary condition '{}' produces a flux of {} kg (or moles if useMass=0). " ), + getName(), time+dt, AquiferBoundaryCondition::catalogName(), bc.getName(), dt * globalSumFluxes[aquiferIndex] ) ); + } bc.saveConvergedState( dt * globalSumFluxes[aquiferIndex] ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.hpp index cf2177e3080..bd9d0d72a32 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.hpp @@ -83,19 +83,10 @@ class FlowSolverBase : public SolverBase static constexpr char const * referencePorosityString() { return "referencePorosity"; } static constexpr char const * permeabilityString() { return "permeability"; } - // gravity term precomputed values - static constexpr char const * gravityCoefString() { return "gravityCoefficient"; } - // misc inputs static constexpr char const * fluidNamesString() { return "fluidNames"; } static constexpr char const * solidNamesString() { return "solidNames"; } static constexpr char const * permeabilityNamesString() { return "permeabilityNames"; } - static constexpr char const * pressureString() { return "pressure"; } - static constexpr char const * deltaPressureString() { return "deltaPressure"; } - static constexpr char const * initialPressureString() { return "initialPressure"; } - static constexpr char const * deltaVolumeString() { return "deltaVolume"; } - static constexpr char const * aperture0String() { return "aperture_n"; } - static constexpr char const * hydraulicApertureString() { return "hydraulicAperture"; } static constexpr char const * inputFluxEstimateString() { return "inputFluxEstimate"; } }; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp b/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp new file mode 100644 index 00000000000..cb75df6604b --- /dev/null +++ b/src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp @@ -0,0 +1,121 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file FlowSolverBaseExtrinsicData.hpp + */ + +#ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_FLOWSOLVERBASEEXTRINSICDATA_HPP_ +#define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_FLOWSOLVERBASEEXTRINSICDATA_HPP_ + +#include "mesh/ExtrinsicMeshData.hpp" + +namespace geosx +{ +/** + * A scope for extrinsic mesh data traits. + */ +namespace extrinsicMeshData +{ + +namespace flow +{ + +EXTRINSIC_MESH_DATA_TRAIT( pressure, + "pressure", + array1d< real64 >, + 0, + LEVEL_0, + WRITE_AND_READ, + "Pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( initialPressure, + "initialPressure", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Initial pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( deltaPressure, + "deltaPressure", + array1d< real64 >, + 0, + NOPLOT, + NO_WRITE, + "Accumulated pressure updates" ); + +EXTRINSIC_MESH_DATA_TRAIT( facePressure, + "facePressure", + array1d< real64 >, + 0, + LEVEL_0, + WRITE_AND_READ, + "Face pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( deltaFacePressure, + "deltaFacePressure", + array1d< real64 >, + 0, + NOPLOT, + NO_WRITE, + "Accumulated face pressure updates" ); + +EXTRINSIC_MESH_DATA_TRAIT( deltaVolume, + "deltaVolume", + array1d< real64 >, + 0, + NOPLOT, + NO_WRITE, + "Accumulated volume updates" ); + +EXTRINSIC_MESH_DATA_TRAIT( aperture0, + "aperture_n", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Initial aperture" ); + +EXTRINSIC_MESH_DATA_TRAIT( hydraulicAperture, + "hydraulicAperture", + array1d< real64 >, + 0, + LEVEL_0, + WRITE_AND_READ, + "Hydraulic aperture" ); + +EXTRINSIC_MESH_DATA_TRAIT( gravityCoefficient, + "gravityCoefficient", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Gravity coefficient (dot product of gravity acceleration by gravity vector)" ); + +EXTRINSIC_MESH_DATA_TRAIT( mimGravityCoefficient, + "mimGravityCoefficient", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Mimetic gravity coefficient" ); + +} + +} + +} + +#endif // GEOSX_PHYSICSSOLVERS_FLUIDFLOW_FLOWSOLVERBASEEXTRINSICDATA_HPP_ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.cpp deleted file mode 100644 index 222511878dc..00000000000 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 TotalEnergies - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file IsothermalCompositionalMultiphaseBaseKernels.cpp - */ - -#include "IsothermalCompositionalMultiphaseBaseKernels.hpp" -#include "CompositionalMultiphaseUtilities.hpp" - -namespace geosx -{ - -namespace IsothermalCompositionalMultiphaseBaseKernels -{ - -/******************************** ComponentFractionKernel ********************************/ - -template< localIndex NC > -GEOSX_HOST_DEVICE -void -ComponentFractionKernel:: - compute( arraySlice1d< real64 const, compflow::USD_COMP - 1 > const compDens, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const dCompDens, - arraySlice1d< real64, compflow::USD_COMP - 1 > const compFrac, - arraySlice2d< real64, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens ) -{ - real64 totalDensity = 0.0; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - real64 const totalDensityInv = 1.0 / totalDensity; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; - } - dCompFrac_dCompDens[ic][ic] += totalDensityInv; - } -} - -template< localIndex NC > -void -ComponentFractionKernel:: - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView2d< real64, compflow::USD_COMP > const & compFrac, - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC >( compDens[a], - dCompDens[a], - compFrac[a], - dCompFrac_dCompDens[a] ); - } ); -} - -template< localIndex NC > -void -ComponentFractionKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView2d< real64, compflow::USD_COMP > const & compFrac, - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC >( compDens[a], - dCompDens[a], - compFrac[a], - dCompFrac_dCompDens[a] ); - } ); -} - -#define INST_ComponentFractionKernel( NC ) \ - template \ - void ComponentFractionKernel:: \ - launch< NC >( localIndex const size, \ - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, \ - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, \ - arrayView2d< real64, compflow::USD_COMP > const & compFrac, \ - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens ); \ - template \ - void ComponentFractionKernel:: \ - launch< NC >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, \ - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, \ - arrayView2d< real64, compflow::USD_COMP > const & compFrac, \ - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens ) - -INST_ComponentFractionKernel( 1 ); -INST_ComponentFractionKernel( 2 ); -INST_ComponentFractionKernel( 3 ); -INST_ComponentFractionKernel( 4 ); -INST_ComponentFractionKernel( 5 ); - -#undef INST_ComponentFractionKernel - -/******************************** PhaseVolumeFractionKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -void -PhaseVolumeFractionKernel:: - compute( arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & compDens, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & dCompDens, - arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > const & dCompFrac_dCompDens, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & phaseDens, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & dPhaseDens_dPres, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & phaseFrac, - arraySlice1d< real64 const, constitutive::multifluid::USD_PHASE - 2 > const & dPhaseFrac_dPres, - arraySlice2d< real64 const, constitutive::multifluid::USD_PHASE_DC - 2 > const & dPhaseFrac_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dComp ) -{ - real64 work[NC]; - - // compute total density from component partial densities - real64 totalDensity = 0.0; - real64 const dTotalDens_dCompDens = 1.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - for( localIndex ip = 0; ip < NP; ++ip ) - { - - // set the saturation to zero if the phase is absent - bool const phaseExists = (phaseFrac[ip] > 0); - if( !phaseExists ) - { - phaseVolFrac[ip] = 0.; - dPhaseVolFrac_dPres[ip] = 0.; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] = 0.; - } - continue; - } - - // Expression for volume fractions: S_p = (nu_p / rho_p) * rho_t - real64 const phaseDensInv = 1.0 / phaseDens[ip]; - - // compute saturation and derivatives except multiplying by the total density - phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; - - dPhaseVolFrac_dPres[ip] = - (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] = - (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; - } - - // apply chain rule to convert derivatives from global component fractions to densities - applyChainRuleInPlace( NC, dCompFrac_dCompDens, dPhaseVolFrac_dComp[ip], work ); - - // now finalize the computation by multiplying by total density - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] *= totalDensity; - dPhaseVolFrac_dComp[ip][jc] += phaseVolFrac[ip] * dTotalDens_dCompDens; - } - - phaseVolFrac[ip] *= totalDensity; - dPhaseVolFrac_dPres[ip] *= totalDensity; - } -} - -template< localIndex NC, localIndex NP > -void PhaseVolumeFractionKernel:: - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseFrac, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseFrac_dPres, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC, NP >( compDens[a], - dCompDens[a], - dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dComp[a][0], - phaseFrac[a][0], - dPhaseFrac_dPres[a][0], - dPhaseFrac_dComp[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dComp[a] ); - } ); -} - -template< localIndex NC, localIndex NP > -void PhaseVolumeFractionKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseFrac, - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseFrac_dPres, - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC, NP >( compDens[a], - dCompDens[a], - dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dComp[a][0], - phaseFrac[a][0], - dPhaseFrac_dPres[a][0], - dPhaseFrac_dComp[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dComp[a] ); - } ); -} - -#define INST_PhaseVolumeFractionKernel( NC, NP ) \ - template \ - void \ - PhaseVolumeFractionKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, \ - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseFrac, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseFrac_dPres, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ); \ - template \ - void \ - PhaseVolumeFractionKernel:: \ - launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, \ - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & phaseFrac, \ - arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > const & dPhaseFrac_dPres, \ - arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ) - -INST_PhaseVolumeFractionKernel( 1, 1 ); -INST_PhaseVolumeFractionKernel( 2, 1 ); -INST_PhaseVolumeFractionKernel( 3, 1 ); -INST_PhaseVolumeFractionKernel( 4, 1 ); -INST_PhaseVolumeFractionKernel( 5, 1 ); - -INST_PhaseVolumeFractionKernel( 1, 2 ); -INST_PhaseVolumeFractionKernel( 2, 2 ); -INST_PhaseVolumeFractionKernel( 3, 2 ); -INST_PhaseVolumeFractionKernel( 4, 2 ); -INST_PhaseVolumeFractionKernel( 5, 2 ); - -INST_PhaseVolumeFractionKernel( 1, 3 ); -INST_PhaseVolumeFractionKernel( 2, 3 ); -INST_PhaseVolumeFractionKernel( 3, 3 ); -INST_PhaseVolumeFractionKernel( 4, 3 ); -INST_PhaseVolumeFractionKernel( 5, 3 ); - -#undef INST_PhaseVolumeFractionKernel - -} // namespace IsothermalCompositionalMultiphaseBaseKernels - -} // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp index 846ececcf12..5a721b9c4df 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp @@ -24,9 +24,10 @@ #include "common/GEOS_RAJA_Interface.hpp" #include "constitutive/solid/CoupledSolidBase.hpp" #include "constitutive/fluid/MultiFluidBase.hpp" -#include "constitutive/fluid/layouts.hpp" #include "functions/TableFunction.hpp" -#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp" +#include "mesh/ElementSubRegionBase.hpp" +#include "mesh/ObjectManagerBase.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp" #include "mesh/ElementRegionManager.hpp" @@ -40,92 +41,406 @@ using namespace constitutive; static constexpr real64 minDensForDivision = 1e-10; -/******************************** ComponentFractionKernel ********************************/ +/******************************** PropertyKernelBase ********************************/ /** - * @brief Functions to compute component fractions from global component densities (mass or molar) + * @brief Internal struct to provide no-op defaults used in the inclusion + * of lambda functions into kernel component functions. + * @struct NoOpFuncs */ -struct ComponentFractionKernel +struct NoOpFunc { - template< localIndex NC > + template< typename ... Ts > GEOSX_HOST_DEVICE - static void - compute( arraySlice1d< real64 const, compflow::USD_COMP - 1 > compDens, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > dCompDens, - arraySlice1d< real64, compflow::USD_COMP - 1 > compFrac, - arraySlice2d< real64, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens ); + constexpr void + operator()( Ts && ... ) const {} +}; + +/** + * @class PropertyKernelBase + * @tparam NUM_COMP number of fluid components + * @brief Define the base interface for the property update kernels + */ +template< integer NUM_COMP > +class PropertyKernelBase +{ +public: + + /// Compile time value for the number of components + static constexpr integer numComp = NUM_COMP; - template< localIndex NC > + /** + * @brief Performs the kernel launch + * @tparam POLICY the policy used in the RAJA kernels + * @tparam KERNEL_TYPE the kernel type + * @param[in] numElems the number of elements + * @param[inout] kernelComponent the kernel component providing access to the compute function + */ + template< typename POLICY, typename KERNEL_TYPE > static void - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView2d< real64, compflow::USD_COMP > const & compFrac, - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens ); + launch( localIndex const numElems, + KERNEL_TYPE const & kernelComponent ) + { + forAll< POLICY >( numElems, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + kernelComponent.compute( ei ); + } ); + } - template< localIndex NC > + /** + * @brief Performs the kernel launch on a sorted array + * @tparam POLICY the policy used in the RAJA kernels + * @tparam KERNEL_TYPE the kernel type + * @param[in] targetSet the indices of the elements in which we compute the property + * @param[inout] kernelComponent the kernel component providing access to the compute function + */ + template< typename POLICY, typename KERNEL_TYPE > static void launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView2d< real64, compflow::USD_COMP > const & compFrac, - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens ); + KERNEL_TYPE const & kernelComponent ) + { + forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) + { + localIndex const ei = targetSet[ i ]; + kernelComponent.compute( ei ); + } ); + } + }; -/******************************** PhaseVolumeFractionKernel ********************************/ +namespace internal +{ -/* - * @brief Functions to compute phase volume fractions (saturations) and derivatives +template< typename T, typename LAMBDA > +void kernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) +{ + static_assert( std::is_integral< T >::value, "kernelLaunchSelectorCompSwitch: type should be integral" ); + + switch( value ) + { + case 1: + { lambda( std::integral_constant< T, 1 >() ); return; } + case 2: + { lambda( std::integral_constant< T, 2 >() ); return; } + case 3: + { lambda( std::integral_constant< T, 3 >() ); return; } + case 4: + { lambda( std::integral_constant< T, 4 >() ); return; } + case 5: + { lambda( std::integral_constant< T, 5 >() ); return; } + default: + { GEOSX_ERROR( "Unsupported number of components: " << value ); } + } +} + +} // namespace internal + + +/******************************** ComponentFractionKernel ********************************/ + +/** + * @class ComponentFractionKernel + * @tparam NUM_COMP number of fluid components + * @brief Define the interface for the update kernel in charge of computing the phase volume fractions */ -struct PhaseVolumeFractionKernel +template< integer NUM_COMP > +class ComponentFractionKernel : public PropertyKernelBase< NUM_COMP > { - template< localIndex NC, localIndex NP > +public: + + using Base = PropertyKernelBase< NUM_COMP >; + using Base::numComp; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + ComponentFractionKernel( ObjectManagerBase & subRegion ) + : Base(), + m_compDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >() ), + m_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >() ), + m_compFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >() ), + m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ) + {} + + /** + * @brief Compute the phase volume fractions in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] phaseVolFractionKernelOp the function used to customize the kernel + */ + template< typename FUNC = NoOpFunc > GEOSX_HOST_DEVICE + void compute( localIndex const ei, + FUNC && compFractionKernelOp = NoOpFunc{} ) const + { + arraySlice1d< real64 const, compflow::USD_COMP - 1 > const compDens = m_compDens[ei]; + arraySlice1d< real64 const, compflow::USD_COMP - 1 > const dCompDens = m_dCompDens[ei]; + arraySlice1d< real64, compflow::USD_COMP - 1 > const compFrac = m_compFrac[ei]; + arraySlice2d< real64, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; + + real64 totalDensity = 0.0; + + for( integer ic = 0; ic < numComp; ++ic ) + { + totalDensity += compDens[ic] + dCompDens[ic]; + } + + real64 const totalDensityInv = 1.0 / totalDensity; + + for( integer ic = 0; ic < numComp; ++ic ) + { + compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; + for( integer jc = 0; jc < numComp; ++jc ) + { + dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; + } + dCompFrac_dCompDens[ic][ic] += totalDensityInv; + } + + compFractionKernelOp( compFrac, dCompFrac_dCompDens ); + } + +protected: + + // inputs + + // Views on component densities + arrayView2d< real64 const, compflow::USD_COMP > m_compDens; + arrayView2d< real64 const, compflow::USD_COMP > m_dCompDens; + + // outputs + + // Views on component fraction + arrayView2d< real64, compflow::USD_COMP > m_compFrac; + arrayView3d< real64, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + +}; + +/** + * @class ComponentFractionKernelFactory + */ +class ComponentFractionKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + template< typename POLICY > static void - compute( arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & compDens, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & 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, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseFrac, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseFrac_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseFrac_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseFrac, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ); - - template< localIndex NC, localIndex NP > + createAndLaunch( integer const numComp, + ObjectManagerBase & subRegion ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + ComponentFractionKernel< NUM_COMP > kernel( subRegion ); + ComponentFractionKernel< NUM_COMP >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + +}; + +/******************************** PhaseVolumeFractionKernel ********************************/ + +/** + * @class PhaseVolumeFractionKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the phase volume fractions + */ +template< integer NUM_COMP, integer NUM_PHASE > +class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > +{ +public: + + using Base = PropertyKernelBase< NUM_COMP >; + using Base::numComp; + + /// Compile time value for the number of phases + static constexpr integer numPhase = NUM_PHASE; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + PhaseVolumeFractionKernel( ObjectManagerBase & subRegion, + MultiFluidBase const & fluid ) + : Base(), + m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), + m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), + m_dPhaseVolFrac_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >() ), + m_compDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >() ), + 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_phaseDens( fluid.phaseDensity() ), + m_dPhaseDens_dPres( fluid.dPhaseDensity_dPressure() ), + m_dPhaseDens_dComp( fluid.dPhaseDensity_dGlobalCompFraction() ) + {} + + /** + * @brief Compute the phase volume fractions in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] phaseVolFractionKernelOp the function used to customize the kernel + */ + template< typename FUNC = NoOpFunc > + GEOSX_HOST_DEVICE + void compute( localIndex const ei, + FUNC && phaseVolFractionKernelOp = NoOpFunc{} ) const + { + 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]; + 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]; + 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]; + + real64 work[numComp]{}; + + // compute total density from component partial densities + real64 totalDensity = 0.0; + real64 const dTotalDens_dCompDens = 1.0; + for( integer ic = 0; ic < numComp; ++ic ) + { + totalDensity += compDens[ic] + dCompDens[ic]; + } + + for( integer ip = 0; ip < numPhase; ++ip ) + { + + // set the saturation to zero if the phase is absent + bool const phaseExists = (phaseFrac[ip] > 0); + if( !phaseExists ) + { + phaseVolFrac[ip] = 0.; + dPhaseVolFrac_dPres[ip] = 0.; + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] = 0.; + } + continue; + } + + // Expression for volume fractions: S_p = (nu_p / rho_p) * rho_t + real64 const phaseDensInv = 1.0 / phaseDens[ip]; + + // compute saturation and derivatives except multiplying by the total density + phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; + + dPhaseVolFrac_dPres[ip] = + (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; + + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] = + (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; + } + + // apply chain rule to convert derivatives from global component fractions to densities + applyChainRuleInPlace( numComp, dCompFrac_dCompDens, dPhaseVolFrac_dComp[ip], work ); + + // call the lambda in the phase loop to allow the reuse of the phaseVolFrac and totalDensity + // possible use: assemble the derivatives wrt temperature + phaseVolFractionKernelOp( ip, phaseVolFrac[ip], totalDensity ); + + // now finalize the computation by multiplying by total density + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] *= totalDensity; + dPhaseVolFrac_dComp[ip][jc] += phaseVolFrac[ip] * dTotalDens_dCompDens; + } + + phaseVolFrac[ip] *= totalDensity; + dPhaseVolFrac_dPres[ip] *= totalDensity; + } + } + +protected: + + // outputs + + /// Views on phase volume fractions + arrayView2d< real64, compflow::USD_PHASE > m_phaseVolFrac; + arrayView2d< real64, compflow::USD_PHASE > m_dPhaseVolFrac_dPres; + arrayView3d< real64, compflow::USD_PHASE_DC > m_dPhaseVolFrac_dComp; + + // inputs + + /// Views on component densities + arrayView2d< real64 const, compflow::USD_COMP > m_compDens; + arrayView2d< real64 const, compflow::USD_COMP > m_dCompDens; + arrayView3d< real64 const, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + + /// 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; + + /// 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; + +}; + +/** + * @class PhaseVolumeFractionKernelFactory + */ +class PhaseVolumeFractionKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + template< typename POLICY > static void - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseFrac, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ); + createAndLaunch( integer const numComp, + integer const numPhase, + ObjectManagerBase & subRegion, + MultiFluidBase const & fluid ) + { + if( numPhase == 2 ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseVolumeFractionKernel< NUM_COMP, 2 > kernel( subRegion, fluid ); + PhaseVolumeFractionKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseVolumeFractionKernel< NUM_COMP, 3 > kernel( subRegion, fluid ); + PhaseVolumeFractionKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } }; /******************************** RelativePermeabilityUpdateKernel ********************************/ @@ -202,38 +517,25 @@ struct CapillaryPressureUpdateKernel /******************************** ElementBasedAssemblyKernel ********************************/ -/** - * @brief Internal struct to provide no-op defaults used in the inclusion - * of lambda functions into kernel component functions. - * @struct NoOpFuncs - */ -struct NoOpFunc -{ - template< typename ... Ts > - GEOSX_HOST_DEVICE - constexpr void - operator()( Ts && ... ) const {} -}; - /** * @class ElementBasedAssemblyKernel * @tparam NUM_COMP number of fluid components * @tparam NUM_DOF number of degrees of freedom * @brief Define the interface for the assembly kernel in charge of accumulation and volume balance */ -template< localIndex NUM_COMP, localIndex NUM_DOF > +template< integer NUM_COMP, integer NUM_DOF > class ElementBasedAssemblyKernel { public: /// Compile time value for the number of components - static constexpr localIndex numComp = NUM_COMP; + static constexpr integer numComp = NUM_COMP; /// Compute time value for the number of degrees of freedom - static constexpr localIndex numDof = NUM_DOF; + static constexpr integer numDof = NUM_DOF; /// Compute time value for the number of equations - static constexpr localIndex numEqn = NUM_DOF; + static constexpr integer numEqn = NUM_DOF; /** * @brief Constructor @@ -262,16 +564,16 @@ class ElementBasedAssemblyKernel m_porosityOld( solid.getOldPorosity() ), m_porosityNew( solid.getPorosity() ), m_dPoro_dPres( solid.getDporosity_dPressure() ), - m_dCompFrac_dCompDens( subRegion.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( CompositionalMultiphaseBase::viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ) ), - m_phaseVolFracOld( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseBase::viewKeyStruct::phaseVolumeFractionOldString() ) ), - m_phaseVolFrac( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseBase::viewKeyStruct::phaseVolumeFractionString() ) ), - m_dPhaseVolFrac_dPres( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseBase::viewKeyStruct::dPhaseVolumeFraction_dPressureString() ) ), - m_dPhaseVolFrac_dCompDens( subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( CompositionalMultiphaseBase::viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ) ), - m_phaseDensOld( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseBase::viewKeyStruct::phaseDensityOldString() ) ), + m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ), + m_phaseVolFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFractionOld >() ), + m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), + m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), + 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_phaseCompFracOld( subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_COMP > >( CompositionalMultiphaseBase::viewKeyStruct::phaseComponentFractionOldString() ) ), + m_phaseCompFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseComponentFractionOld >() ), m_phaseCompFrac( fluid.phaseCompFraction() ), m_dPhaseCompFrac_dPres( fluid.dPhaseCompFraction_dPressure() ), m_dPhaseCompFrac_dComp( fluid.dPhaseCompFraction_dGlobalCompFraction() ), @@ -539,7 +841,7 @@ class ElementBasedAssemblyKernel protected: /// Number of fluid phases - localIndex const m_numPhases; + integer const m_numPhases; /// Offset for my MPI rank globalIndex const m_rankOffset; @@ -586,34 +888,6 @@ class ElementBasedAssemblyKernel }; -namespace internal -{ - -template< typename T, typename LAMBDA > -void kernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) -{ - static_assert( std::is_integral< T >::value, "kernelLaunchSelectorCompSwitch: type should be integral" ); - - switch( value ) - { - case 1: - { lambda( std::integral_constant< T, 1 >() ); return; } - case 2: - { lambda( std::integral_constant< T, 2 >() ); return; } - case 3: - { lambda( std::integral_constant< T, 3 >() ); return; } - case 4: - { lambda( std::integral_constant< T, 4 >() ); return; } - case 5: - { lambda( std::integral_constant< T, 5 >() ); return; } - default: - { GEOSX_ERROR( "Unsupported number of components: " << value ); } - } -} - -} // namespace internal - - /** * @class ElementBasedAssemblyKernelFactory */ @@ -636,8 +910,8 @@ class ElementBasedAssemblyKernelFactory */ template< typename POLICY > static void - createAndLaunch( localIndex const numComps, - localIndex const numPhases, + createAndLaunch( integer const numComps, + integer const numPhases, globalIndex const rankOffset, string const dofKey, ElementSubRegionBase const & subRegion, @@ -648,12 +922,11 @@ class ElementBasedAssemblyKernelFactory { internal::kernelLaunchSelectorCompSwitch( numComps, [&] ( auto NC ) { - localIndex constexpr NUM_COMP = NC(); - localIndex constexpr NUM_DOF = NC()+1; + integer constexpr NUM_COMP = NC(); + integer constexpr NUM_DOF = NC()+1; ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); - ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template - launch< POLICY, ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > >( subRegion.size(), kernel ); + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template launch< POLICY >( subRegion.size(), kernel ); } ); } @@ -667,7 +940,7 @@ struct ResidualNormKernel template< typename POLICY, typename REDUCE_POLICY > static void launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, - localIndex const numComponents, + integer const numComponents, arrayView1d< globalIndex const > const & dofNumber, arrayView1d< integer const > const & ghostRank, arrayView1d< real64 const > const & refPoro, @@ -684,7 +957,7 @@ struct ResidualNormKernel localIndex const localRow = dofNumber[ei] - rankOffset; real64 const normalizer = totalDensOld[ei] * refPoro[ei] * volume[ei]; - for( localIndex idof = 0; idof < numComponents + 1; ++idof ) + for( integer idof = 0; idof < numComponents + 1; ++idof ) { real64 const val = localResidual[localRow + idof] / normalizer; localSum += val * val; @@ -734,7 +1007,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 ) { real64 const newDens = compDens[ei][ic] + dCompDens[ei][ic] + scalingFactor * localSolution[localRow + ic + 1]; check.min( newDens >= 0.0 ); @@ -743,7 +1016,7 @@ struct SolutionCheckKernel else { real64 totalDens = 0.0; - for( localIndex ic = 0; ic < numComponents; ++ic ) + for( integer ic = 0; ic < numComponents; ++ic ) { real64 const newDens = compDens[ei][ic] + dCompDens[ei][ic] + scalingFactor * localSolution[localRow + ic + 1]; totalDens += (newDens > 0.0) ? newDens : 0.0; @@ -774,8 +1047,8 @@ struct HydrostaticPressureKernel template< typename FLUID_WRAPPER > static ReturnType - computeHydrostaticPressure( localIndex const numComps, - localIndex const numPhases, + computeHydrostaticPressure( integer const numComps, + integer const numPhases, integer const ipInit, integer const maxNumEquilIterations, real64 const & equilTolerance, @@ -808,7 +1081,7 @@ struct HydrostaticPressureKernel real64 const gravCoef = gravVector[2] * ( refElevation - newElevation ); real64 const temp = tempTableWrapper.compute( &newElevation ); - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { compFrac[0][ic] = compFracTableWrappers[ic].compute( &newElevation ); } @@ -836,7 +1109,7 @@ struct HydrostaticPressureKernel // Step 4: fixed-point iteration until convergence bool equilHasConverged = false; - for( localIndex eqIter = 0; eqIter < maxNumEquilIterations; ++eqIter ) + for( integer eqIter = 0; eqIter < maxNumEquilIterations; ++eqIter ) { // check convergence @@ -849,7 +1122,7 @@ struct HydrostaticPressureKernel // make sure that the fluid is single-phase, other we have to issue a warning (for now) // if only one phase is mobile, we are in good shape (unfortunately it is hard to access relperm from here) localIndex numberOfPhases = 0; - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { if( phaseFrac[0][0][ip] > MIN_FOR_PHASE_PRESENCE ) { @@ -882,7 +1155,7 @@ struct HydrostaticPressureKernel // Step 5: save the hydrostatic pressure and the corresponding density newPres = pres1; - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { newPhaseMassDens[ip] = phaseMassDens[0][0][ip]; } @@ -904,8 +1177,8 @@ struct HydrostaticPressureKernel template< typename FLUID_WRAPPER > static ReturnType launch( localIndex const size, - localIndex const numComps, - localIndex const numPhases, + integer const numComps, + integer const numPhases, integer const ipInit, integer const maxNumEquilIterations, real64 const equilTolerance, @@ -937,7 +1210,7 @@ struct HydrostaticPressureKernel real64 datumTotalDens = 0.0; real64 const datumTemp = tempTableWrapper.compute( &datumElevation ); - for( localIndex ic = 0; ic < numComps; ++ic ) + for( integer ic = 0; ic < numComps; ++ic ) { datumCompFrac[0][ic] = compFracTableWrappers[ic].compute( &datumElevation ); } @@ -969,7 +1242,7 @@ struct HydrostaticPressureKernel array2d< real64 > phaseMassDens( pressureValues.size(), numPhases ); // temporary array without permutation to compile on Lassen array1d< real64 > datumPhaseMassDensTmp( numPhases ); - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { datumPhaseMassDensTmp[ip] = datumPhaseMassDens[0][0][ip]; } @@ -1074,7 +1347,7 @@ struct HydrostaticPressureKernel /******************************** Kernel launch machinery ********************************/ template< typename KERNELWRAPPER, typename ... ARGS > -void KernelLaunchSelector1( localIndex const numComp, ARGS && ... args ) +void KernelLaunchSelector1( integer const numComp, ARGS && ... args ) { internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) { @@ -1083,7 +1356,7 @@ void KernelLaunchSelector1( localIndex const numComp, ARGS && ... args ) } template< typename KERNELWRAPPER, typename ... ARGS > -void KernelLaunchSelector2( localIndex const numComp, localIndex const numPhase, ARGS && ... args ) +void KernelLaunchSelector2( integer const numComp, integer const numPhase, ARGS && ... args ) { // Ideally this would be inside the dispatch, but it breaks on Summit with GCC 9.1.0 and CUDA 11.0.3. if( numPhase == 2 ) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.cpp index 3613517db91..7c45d3c118f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.cpp @@ -33,236 +33,13 @@ namespace geosx namespace IsothermalCompositionalMultiphaseFVMKernels { -/******************************** PhaseMobilityKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -void -PhaseMobilityKernel:: - compute( 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, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseVisc_dComp, - arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & phaseRelPerm, - arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dPhaseRelPerm_dPhaseVolFrac, - 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_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseMob, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dPres, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseMob_dComp ) -{ - real64 dRelPerm_dC[NC]; - real64 dDens_dC[NC]; - real64 dVisc_dC[NC]; - - for( localIndex ip = 0; ip < NP; ++ip ) - { - - // compute the phase mobility only if the phase is present - bool const phaseExists = (phaseVolFrac[ip] > 0); - if( !phaseExists ) - { - phaseMob[ip] = 0.; - dPhaseMob_dPres[ip] = 0.; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = 0.; - } - continue; - } - - real64 const density = phaseDens[ip]; - real64 const dDens_dP = dPhaseDens_dPres[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); - - real64 const viscosity = phaseVisc[ip]; - real64 const dVisc_dP = dPhaseVisc_dPres[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); - - real64 const relPerm = phaseRelPerm[ip]; - real64 dRelPerm_dP = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - dRelPerm_dC[ic] = 0.0; - } - - for( localIndex jp = 0; jp < NP; ++jp ) - { - real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; - dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; - } - } - - real64 const mobility = relPerm * density / viscosity; - - phaseMob[ip] = mobility; - dPhaseMob_dPres[ip] = dRelPerm_dP * density / viscosity - + mobility * (dDens_dP / density - dVisc_dP / viscosity); - - // compositional derivatives - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] * density / viscosity - + mobility * (dDens_dC[jc] / density - dVisc_dC[jc] / viscosity); - } - } -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( localIndex const size, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dComp[a][0], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dComp[a] ); - } ); -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dComp[a][0], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dComp[a] ); - } ); -} - -#define INST_PhaseMobilityKernel( NC, NP ) \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, \ - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, \ - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) - -INST_PhaseMobilityKernel( 1, 1 ); -INST_PhaseMobilityKernel( 2, 1 ); -INST_PhaseMobilityKernel( 3, 1 ); -INST_PhaseMobilityKernel( 4, 1 ); -INST_PhaseMobilityKernel( 5, 1 ); - -INST_PhaseMobilityKernel( 1, 2 ); -INST_PhaseMobilityKernel( 2, 2 ); -INST_PhaseMobilityKernel( 3, 2 ); -INST_PhaseMobilityKernel( 4, 2 ); -INST_PhaseMobilityKernel( 5, 2 ); - -INST_PhaseMobilityKernel( 1, 3 ); -INST_PhaseMobilityKernel( 2, 3 ); -INST_PhaseMobilityKernel( 3, 3 ); -INST_PhaseMobilityKernel( 4, 3 ); -INST_PhaseMobilityKernel( 5, 3 ); - -#undef INST_PhaseMobilityKernel - - /******************************** FluxKernel ********************************/ -template< localIndex NC, localIndex MAX_NUM_ELEMS, localIndex MAX_STENCIL_SIZE > +template< integer NC, localIndex MAX_NUM_ELEMS, localIndex MAX_STENCIL_SIZE > GEOSX_HOST_DEVICE void FluxKernel:: - compute( localIndex const numPhases, + compute( integer const numPhases, localIndex const stencilSize, localIndex const numFluxElems, arraySlice1d< localIndex const > const seri, @@ -292,14 +69,14 @@ FluxKernel:: arraySlice1d< real64 > const localFlux, arraySlice2d< real64 > const localFluxJacobian ) { - localIndex constexpr NDOF = NC + 1; + integer constexpr NDOF = NC + 1; stackArray1d< real64, NC > compFlux( NC ); stackArray2d< real64, MAX_STENCIL_SIZE * NC > dCompFlux_dP( stencilSize, NC ); stackArray3d< real64, MAX_STENCIL_SIZE * NC * NC > dCompFlux_dC( stencilSize, NC, NC ); // loop over phases, compute and upwind phase flux and sum contributions to each component's flux - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { // clear working arrays real64 densMean{}; @@ -343,7 +120,7 @@ FluxKernel:: // average density and derivatives densMean += 0.5 * density; dDensMean_dP[i] = 0.5 * dDens_dP; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dDensMean_dC[i][jc] = 0.5 * dProp_dC[jc]; } @@ -362,7 +139,7 @@ FluxKernel:: real64 capPressure = 0.0; real64 dCapPressure_dP = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { dCapPressure_dC[ic] = 0.0; } @@ -371,12 +148,12 @@ FluxKernel:: { capPressure = phaseCapPressure[er][esr][ei][0][ip]; - for( localIndex jp = 0; jp < numPhases; ++jp ) + for( integer jp = 0; jp < numPhases; ++jp ) { real64 const dCapPressure_dS = dPhaseCapPressure_dPhaseVolFrac[er][esr][ei][0][ip][jp]; dCapPressure_dP += dCapPressure_dS * dPhaseVolFrac_dPres[er][esr][ei][jp]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCapPressure_dC[jc] += dCapPressure_dS * dPhaseVolFrac_dComp[er][esr][ei][jp][jc]; } @@ -385,7 +162,7 @@ FluxKernel:: presGrad += transmissibility[i] * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); dPresGrad_dP[i] += transmissibility[i] * (1 - dCapPressure_dP) + dTrans_dPres[i] * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dPresGrad_dC[i][jc] += -transmissibility[i] * dCapPressure_dC[jc]; } @@ -402,7 +179,7 @@ FluxKernel:: for( localIndex j = 0; j < numFluxElems; ++j ) { dGravHead_dP[j] += dDensMean_dP[j] * gravD + dGravD_dP * densMean; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dGravHead_dC[j][jc] += dDensMean_dC[j][jc] * gravD; } @@ -436,7 +213,7 @@ FluxKernel:: for( localIndex ke = 0; ke < stencilSize; ++ke ) { dPhaseFlux_dP[ke] += dPresGrad_dP[ke]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dPhaseFlux_dC[ke][jc] += dPresGrad_dC[ke][jc]; } @@ -458,7 +235,7 @@ FluxKernel:: for( localIndex ke = 0; ke < stencilSize; ++ke ) { dPhaseFlux_dP[ke] *= mobility; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dPhaseFlux_dC[ke][jc] *= mobility; } @@ -469,7 +246,7 @@ FluxKernel:: // add contribution from upstream cell mobility derivatives dPhaseFlux_dP[k_up] += dMob_dP * potGrad; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dPhaseFlux_dC[k_up][jc] += dPhaseMob_dCompSub[jc] * potGrad; } @@ -480,7 +257,7 @@ FluxKernel:: arraySlice2d< real64 const, multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFrac_dCompSub = dPhaseCompFrac_dComp[er_up][esr_up][ei_up][0][ip]; // compute component fluxes and derivatives using upstream cell composition - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { real64 const ycp = phaseCompFracSub[ic]; compFlux[ic] += phaseFlux * ycp; @@ -489,7 +266,7 @@ FluxKernel:: for( localIndex ke = 0; ke < stencilSize; ++ke ) { dCompFlux_dP[ke][ic] += dPhaseFlux_dP[ke] * ycp; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompFlux_dC[ke][ic][jc] += dPhaseFlux_dC[ke][jc] * ycp; } @@ -501,7 +278,7 @@ FluxKernel:: // convert derivatives of component fraction w.r.t. component fractions to derivatives w.r.t. component // densities applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseCompFrac_dCompSub[ic], dProp_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; } @@ -511,7 +288,7 @@ FluxKernel:: // *** end of upwinding // populate local flux vector and derivatives - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { localFlux[ic] = dt * compFlux[ic]; localFlux[NC + ic] = -dt * compFlux[ic]; @@ -522,7 +299,7 @@ FluxKernel:: localFluxJacobian[ic][localDofIndexPres] = dt * dCompFlux_dP[ke][ic]; localFluxJacobian[NC + ic][localDofIndexPres] = -dt * dCompFlux_dP[ke][ic]; - for( localIndex jc = 0; jc < NC; ++jc ) + for( integer jc = 0; jc < NC; ++jc ) { localIndex const localDofIndexComp = localDofIndexPres + jc + 1; localFluxJacobian[ic][localDofIndexComp] = dt * dCompFlux_dC[ke][ic][jc]; @@ -532,10 +309,10 @@ FluxKernel:: } } -template< localIndex NC, typename STENCILWRAPPER_TYPE > +template< integer NC, typename STENCILWRAPPER_TYPE > void FluxKernel:: - launch( localIndex const numPhases, + launch( integer const numPhases, STENCILWRAPPER_TYPE const & stencilWrapper, globalIndex const rankOffset, ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, @@ -630,7 +407,7 @@ FluxKernel:: { globalIndex const offset = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; - for( localIndex jdof = 0; jdof < NDOF; ++jdof ) + for( integer jdof = 0; jdof < NDOF; ++jdof ) { dofColIndices[i * NDOF + jdof] = offset + jdof; } @@ -651,7 +428,7 @@ FluxKernel:: GEOSX_ASSERT_GE( localRow, 0 ); GEOSX_ASSERT_GT( localMatrix.numRows(), localRow + NC ); - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { RAJA::atomicAdd( parallelDeviceAtomic{}, &localRhs[localRow + ic], localFlux[i * NC + ic] ); localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( localRow + ic, @@ -667,7 +444,7 @@ FluxKernel:: #define INST_FluxKernel( NC, STENCILWRAPPER_TYPE ) \ template \ void FluxKernel:: \ - launch< NC, STENCILWRAPPER_TYPE >( localIndex const numPhases, \ + launch< NC, STENCILWRAPPER_TYPE >( integer const numPhases, \ STENCILWRAPPER_TYPE const & stencilWrapper, \ globalIndex const rankOffset, \ ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, \ @@ -725,11 +502,11 @@ INST_FluxKernel( 5, FaceElementToCellStencilWrapper ); /******************************** CFLFluxKernel ********************************/ -template< localIndex NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL_SIZE > +template< integer NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL_SIZE > GEOSX_HOST_DEVICE void CFLFluxKernel:: - compute( localIndex const numPhases, + compute( integer const numPhases, localIndex const stencilSize, real64 const & dt, arraySlice1d< localIndex const > const seri, @@ -748,7 +525,7 @@ CFLFluxKernel:: ElementView< arrayView2d< real64, compflow::USD_COMP > > const & compOutflux ) { // loop over phases, compute and upwind phase flux and sum contributions to each component's flux - for( localIndex ip = 0; ip < numPhases; ++ip ) + for( integer ip = 0; ip < numPhases; ++ip ) { // clear working arrays @@ -808,7 +585,7 @@ CFLFluxKernel:: RAJA::atomicAdd( parallelDeviceAtomic{}, &phaseOutflux[er_up][esr_up][ei_up][ip], absPhaseFlux ); // increment the component (mass/molar) outflux of the upstream cell - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { real64 const absCompFlux = phaseCompFrac[er_up][esr_up][ei_up][0][ip][ic] * phaseDens[er_up][esr_up][ei_up][0][ip] @@ -818,10 +595,10 @@ CFLFluxKernel:: } } -template< localIndex NC, typename STENCILWRAPPER_TYPE > +template< integer NC, typename STENCILWRAPPER_TYPE > void CFLFluxKernel:: - launch( localIndex const numPhases, + launch( integer const numPhases, real64 const & dt, STENCILWRAPPER_TYPE const & stencilWrapper, ElementViewConst< arrayView1d< real64 const > > const & pres, @@ -881,7 +658,7 @@ CFLFluxKernel:: #define INST_CFLFluxKernel( NC, STENCILWRAPPER_TYPE ) \ template \ void CFLFluxKernel:: \ - launch< NC, STENCILWRAPPER_TYPE >( localIndex const numPhases, \ + launch< NC, STENCILWRAPPER_TYPE >( integer const numPhases, \ real64 const & dt, \ STENCILWRAPPER_TYPE const & stencil, \ ElementViewConst< arrayView1d< real64 const > > const & pres, \ @@ -925,7 +702,7 @@ INST_CFLFluxKernel( 5, FaceElementToCellStencilWrapper ); /******************************** CFLKernel ********************************/ -template< localIndex NP > +template< integer NP > GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE void @@ -982,20 +759,20 @@ CFLKernel:: { // from Keith Coats, IMPES stability: Selection of stable timesteps (2003) real64 totalMob = 0.0; - for( localIndex ip = 0; ip < numMobilePhases; ++ip ) + for( integer ip = 0; ip < numMobilePhases; ++ip ) { totalMob += mob[ip]; } real64 f[2][2]{}; - for( localIndex i = 0; i < 2; ++i ) + for( integer i = 0; i < 2; ++i ) { - for( localIndex j = 0; j < 2; ++j ) + for( integer j = 0; j < 2; ++j ) { f[i][j] = ( i == j )*totalMob - mob[i]; f[i][j] /= (totalMob * mob[j]); real64 sum = 0; - for( localIndex k = 0; k < 3; ++k ) + for( integer k = 0; k < 3; ++k ) { sum += dPhaseRelPerm_dPhaseVolFrac[k][j] / phaseVisc[k] * phaseOutflux[j]; @@ -1010,7 +787,7 @@ CFLKernel:: } -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE void @@ -1024,7 +801,7 @@ CFLKernel:: compCFLNumber = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { if( compFrac[ic] > minComponentFraction ) { @@ -1038,7 +815,7 @@ CFLKernel:: } } -template< localIndex NC, localIndex NP > +template< integer NC, integer NP > void CFLKernel:: launch( localIndex const size, @@ -1125,12 +902,12 @@ INST_CFLKernel( 5, 3 ); /******************************** AquiferBCKernel ********************************/ -template< localIndex NC > +template< integer NC > GEOSX_HOST_DEVICE void AquiferBCKernel:: - compute( localIndex const numPhases, - localIndex const ipWater, + compute( integer const numPhases, + integer const ipWater, bool const allowAllPhasesIntoAquifer, real64 const & aquiferVolFlux, real64 const & dAquiferVolFlux_dPres, @@ -1206,11 +983,11 @@ AquiferBCKernel:: } } -template< localIndex NC > +template< integer NC > void AquiferBCKernel:: - launch( localIndex const numPhases, - localIndex const ipWater, + launch( integer const numPhases, + integer const ipWater, bool const allowAllPhasesIntoAquifer, BoundaryStencil const & stencil, globalIndex const rankOffset, @@ -1248,7 +1025,7 @@ AquiferBCKernel:: forAll< parallelDevicePolicy<> >( stencil.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iconn ) { - constexpr localIndex NDOF = NC + 1; + constexpr integer NDOF = NC + 1; // working arrays globalIndex dofColIndices[NDOF]{}; @@ -1294,7 +1071,7 @@ AquiferBCKernel:: // populate dof indices globalIndex const offset = dofNumber[er][esr][ei]; - for( localIndex jdof = 0; jdof < NDOF; ++jdof ) + for( integer jdof = 0; jdof < NDOF; ++jdof ) { dofColIndices[jdof] = offset + jdof; } @@ -1313,7 +1090,7 @@ AquiferBCKernel:: GEOSX_ASSERT_GE( localRow, 0 ); GEOSX_ASSERT_GT( localMatrix.numRows(), localRow + NC ); - for( localIndex ic = 0; ic < NC; ++ic ) + for( integer ic = 0; ic < NC; ++ic ) { RAJA::atomicAdd( parallelDeviceAtomic{}, &localRhs[localRow + ic], localFlux[ic] ); localMatrix.addToRow< parallelDeviceAtomic >( localRow + ic, @@ -1328,8 +1105,8 @@ AquiferBCKernel:: #define INST_AquiferBCKernel( NC ) \ template \ void AquiferBCKernel:: \ - launch< NC >( localIndex const numPhases, \ - localIndex const ipWater, \ + launch< NC >( integer const numPhases, \ + integer const ipWater, \ bool const allowAllPhasesIntoAquifer, \ BoundaryStencil const & stencil, \ globalIndex const rankOffset, \ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index 0d764b6d145..3c712905a26 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -22,12 +22,13 @@ #include "common/DataLayouts.hpp" #include "common/DataTypes.hpp" #include "common/GEOS_RAJA_Interface.hpp" -#include "constitutive/fluid/layouts.hpp" -#include "constitutive/relativePermeability/layouts.hpp" -#include "constitutive/capillaryPressure/layouts.hpp" +#include "constitutive/fluid/MultiFluidBase.hpp" +#include "constitutive/relativePermeability/RelativePermeabilityBase.hpp" +#include "constitutive/capillaryPressure/CapillaryPressureBase.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" #include "finiteVolume/BoundaryStencil.hpp" -#include "mesh/ElementRegionManager.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" namespace geosx { @@ -40,68 +41,218 @@ using namespace constitutive; /******************************** PhaseMobilityKernel ********************************/ /** - * @brief Functions to compute phase mobilities and derivatives from density, viscosity and relperm + * @class PhaseMobilityKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the phase mobilities */ -struct PhaseMobilityKernel +template< integer NUM_COMP, integer NUM_PHASE > +class PhaseMobilityKernel : public IsothermalCompositionalMultiphaseBaseKernels::PropertyKernelBase< NUM_COMP > { - template< localIndex NC, localIndex NP > +public: + + using Base = IsothermalCompositionalMultiphaseBaseKernels::PropertyKernelBase< NUM_COMP >; + using Base::numComp; + + /// Compile time value for the number of phases + static constexpr integer numPhase = NUM_PHASE; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] relperm the relperm model + */ + PhaseMobilityKernel( ObjectManagerBase & subRegion, + MultiFluidBase const & fluid, + RelativePermeabilityBase const & relperm ) + : Base(), + m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), + m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), + 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_phaseVisc( fluid.phaseViscosity() ), + m_dPhaseVisc_dPres( fluid.dPhaseViscosity_dPressure() ), + m_dPhaseVisc_dComp( fluid.dPhaseViscosity_dGlobalCompFraction() ), + m_phaseRelPerm( relperm.phaseRelPerm() ), + m_dPhaseRelPerm_dPhaseVolFrac( relperm.dPhaseRelPerm_dPhaseVolFraction() ), + m_phaseMob( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobility >() ), + m_dPhaseMob_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dPressure >() ), + m_dPhaseMob_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity >() ) + {} + + /** + * @brief Compute the phase mobilities in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] phaseMobilityKernelOp the function used to customize the kernel + */ + template< typename FUNC = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc > GEOSX_HOST_DEVICE - static void - compute( 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, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseVisc_dComp, - arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & phaseRelPerm, - arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dPhaseRelPerm_dPhaseVolFrac, - 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_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseMob, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dPres, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseMob_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); + void compute( localIndex const ei, + FUNC && phaseMobilityKernelOp = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc{} ) const + { + 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]; + 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]; + 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]; + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const dPhaseVolFrac_dPres = m_dPhaseVolFrac_dPres[ei]; + arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const dPhaseVolFrac_dComp = m_dPhaseVolFrac_dComp[ei]; + arraySlice1d< real64, compflow::USD_PHASE - 1 > const phaseMob = m_phaseMob[ei]; + arraySlice1d< real64, compflow::USD_PHASE - 1 > const dPhaseMob_dPres = m_dPhaseMob_dPres[ei]; + arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const dPhaseMob_dComp = m_dPhaseMob_dComp[ei]; + + real64 dRelPerm_dC[numComp]{}; + real64 dDens_dC[numComp]{}; + real64 dVisc_dC[numComp]{}; + + for( integer ip = 0; ip < numPhase; ++ip ) + { + + // compute the phase mobility only if the phase is present + bool const phaseExists = (phaseVolFrac[ip] > 0); + if( !phaseExists ) + { + phaseMob[ip] = 0.0; + dPhaseMob_dPres[ip] = 0.0; + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseMob_dComp[ip][jc] = 0.0; + } + continue; + } + + real64 const density = phaseDens[ip]; + real64 const dDens_dP = dPhaseDens_dPres[ip]; + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); + + real64 const viscosity = phaseVisc[ip]; + real64 const dVisc_dP = dPhaseVisc_dPres[ip]; + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); + + real64 const relPerm = phaseRelPerm[ip]; + real64 dRelPerm_dP = 0.0; + for( integer ic = 0; ic < numComp; ++ic ) + { + dRelPerm_dC[ic] = 0.0; + } + + for( integer jp = 0; jp < numPhase; ++jp ) + { + real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; + dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; + + for( integer jc = 0; jc < numComp; ++jc ) + { + dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; + } + } + + real64 const mobility = relPerm * density / viscosity; + + phaseMob[ip] = mobility; + dPhaseMob_dPres[ip] = dRelPerm_dP * density / viscosity + + mobility * (dDens_dP / density - dVisc_dP / viscosity); + + // compositional derivatives + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] * density / viscosity + + mobility * (dDens_dC[jc] / density - dVisc_dC[jc] / viscosity); + } + + // call the lambda in the phase loop to allow the reuse of the relperm, density, viscosity, and mobility + // possible use: assemble the derivatives wrt temperature + phaseMobilityKernelOp( ip, phaseMob[ip], dPhaseMob_dPres[ip], dPhaseMob_dComp[ip] ); + } + } + +protected: + + // inputs + + /// Views on the phase volume fractions + arrayView2d< real64 const, compflow::USD_PHASE > m_phaseVolFrac; + arrayView2d< real64 const, compflow::USD_PHASE > m_dPhaseVolFrac_dPres; + arrayView3d< real64 const, compflow::USD_PHASE_DC > m_dPhaseVolFrac_dComp; + arrayView3d< real64 const, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + + /// 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; + + /// 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; + + /// Views on the phase relative permeabilities + arrayView3d< real64 const, relperm::USD_RELPERM > m_phaseRelPerm; + arrayView4d< real64 const, relperm::USD_RELPERM_DS > m_dPhaseRelPerm_dPhaseVolFrac; + + // outputs + + /// Views on the phase mobilities + arrayView2d< real64, compflow::USD_PHASE > m_phaseMob; + arrayView2d< real64, compflow::USD_PHASE > m_dPhaseMob_dPres; + arrayView3d< real64, compflow::USD_PHASE_DC > m_dPhaseMob_dComp; - template< localIndex NC, localIndex NP > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); }; +/** + * @class PhaseMobilityKernelFactory + */ +class PhaseMobilityKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] relperm the relperm model + */ + template< typename POLICY > + static void + createAndLaunch( integer const numComp, + integer const numPhase, + ObjectManagerBase & subRegion, + MultiFluidBase const & fluid, + RelativePermeabilityBase const & relperm ) + { + if( numPhase == 2 ) + { + IsothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseMobilityKernel< NUM_COMP, 2 > kernel( subRegion, fluid, relperm ); + PhaseMobilityKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + IsothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseMobilityKernel< NUM_COMP, 3 > kernel( subRegion, fluid, relperm ); + PhaseMobilityKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } +}; /******************************** FluxKernel ********************************/ @@ -120,10 +271,10 @@ struct FluxKernel template< typename VIEWTYPE > using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >; - template< localIndex NC, localIndex MAX_NUM_ELEMS, localIndex MAX_STENCIL_SIZE > + template< integer NC, localIndex MAX_NUM_ELEMS, localIndex MAX_STENCIL_SIZE > GEOSX_HOST_DEVICE static void - compute( localIndex const numPhases, + compute( integer const numPhases, localIndex const stencilSize, localIndex const numFluxElems, arraySlice1d< localIndex const > const seri, @@ -153,9 +304,9 @@ struct FluxKernel arraySlice1d< real64 > const localFlux, arraySlice2d< real64 > const localFluxJacobian ); - template< localIndex NC, typename STENCILWRAPPER_TYPE > + template< integer NC, typename STENCILWRAPPER_TYPE > static void - launch( localIndex const numPhases, + launch( integer const numPhases, STENCILWRAPPER_TYPE const & stencilWrapper, globalIndex const rankOffset, ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, @@ -205,10 +356,10 @@ struct CFLFluxKernel template< typename VIEWTYPE > using ElementView = ElementRegionManager::ElementView< VIEWTYPE >; - template< localIndex NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL_SIZE > + template< integer NC, localIndex NUM_ELEMS, localIndex MAX_STENCIL_SIZE > GEOSX_HOST_DEVICE static void - compute( localIndex const numPhases, + compute( integer const numPhases, localIndex const stencilSize, real64 const & dt, arraySlice1d< localIndex const > const seri, @@ -226,9 +377,9 @@ struct CFLFluxKernel ElementView< arrayView2d< real64, compflow::USD_PHASE > > const & phaseOutflux, ElementView< arrayView2d< real64, compflow::USD_COMP > > const & compOutflux ); - template< localIndex NC, typename STENCILWRAPPER_TYPE > + template< integer NC, typename STENCILWRAPPER_TYPE > static void - launch( localIndex const numPhases, + launch( integer const numPhases, real64 const & dt, STENCILWRAPPER_TYPE const & stencil, ElementViewConst< arrayView1d< real64 const > > const & pres, @@ -256,7 +407,7 @@ struct CFLKernel static constexpr real64 minPhaseMobility = 1e-12; static constexpr real64 minComponentFraction = 1e-12; - template< localIndex NP > + template< integer NP > GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE static void @@ -268,7 +419,7 @@ struct CFLKernel arraySlice1d< real64 const, compflow::USD_PHASE- 1 > phaseOutflux, real64 & phaseCFLNumber ); - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE static void @@ -278,7 +429,7 @@ struct CFLKernel arraySlice1d< real64 const, compflow::USD_COMP - 1 > compOutflux, real64 & compCFLNumber ); - template< localIndex NC, localIndex NP > + template< integer NC, integer NP > static void launch( localIndex const size, arrayView1d< real64 const > const & volume, @@ -315,11 +466,11 @@ struct AquiferBCKernel template< typename VIEWTYPE > using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >; - template< localIndex NC > + template< integer NC > GEOSX_HOST_DEVICE static void - compute( localIndex const numPhases, - localIndex const ipWater, + compute( integer const numPhases, + integer const ipWater, bool const allowAllPhasesIntoAquifer, real64 const & aquiferVolFlux, real64 const & dAquiferVolFlux_dPres, @@ -339,10 +490,10 @@ struct AquiferBCKernel real64 ( &localFlux )[NC], real64 ( &localFluxJacobian )[NC][NC+1] ); - template< localIndex NC > + template< integer NC > static void - launch( localIndex const numPhases, - localIndex const ipWater, + launch( integer const numPhases, + integer const ipWater, bool const allowAllPhasesIntoAquifer, BoundaryStencil const & stencil, globalIndex const rankOffset, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp index 654a12bd6b1..8e6023a9d5f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.cpp @@ -27,11 +27,14 @@ #include "fieldSpecification/AquiferBoundaryCondition.hpp" #include "fieldSpecification/EquilibriumInitialCondition.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" +#include "fieldSpecification/SourceFluxBoundaryCondition.hpp" #include "finiteVolume/FiniteVolumeManager.hpp" #include "functions/TableFunction.hpp" #include "mainInterface/ProblemManager.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBaseKernels.hpp" namespace geosx @@ -51,6 +54,8 @@ SinglePhaseBase::SinglePhaseBase( const string & name, void SinglePhaseBase::registerDataOnMesh( Group & meshBodies ) { + using namespace extrinsicMeshData::flow; + FlowSolverBase::registerDataOnMesh( meshBodies ); meshBodies.forSubGroups< MeshBody >( [&] ( MeshBody & meshBody ) @@ -61,50 +66,35 @@ void SinglePhaseBase::registerDataOnMesh( Group & meshBodies ) elemManager.forElementSubRegions< CellElementSubRegion >( [&]( CellElementSubRegion & subRegion ) { - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::pressureString() ).setPlotLevel( PlotLevel::LEVEL_0 ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::initialPressureString() ); - - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.registerExtrinsicData< pressure >( getName() ); + subRegion.registerExtrinsicData< initialPressure >( getName() ); + subRegion.registerExtrinsicData< deltaPressure >( getName() ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaVolumeString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.registerExtrinsicData< deltaVolume >( getName() ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::mobilityString() ); + subRegion.registerExtrinsicData< mobility >( getName() ); + subRegion.registerExtrinsicData< dMobility_dPressure >( getName() ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::dMobility_dPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); - - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::densityOldString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.registerExtrinsicData< densityOld >( getName() ); } ); elemManager.forElementSubRegions< FaceElementSubRegion, EmbeddedSurfaceSubRegion >( [&] ( auto & subRegion ) { - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::pressureString() ).setPlotLevel( PlotLevel::LEVEL_0 ); - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::initialPressureString() ); - - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::deltaPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::pressure >( getName() ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::initialPressure >( getName() ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::deltaPressure >( getName() ); - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::deltaVolumeString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::deltaVolume >( getName() ); - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::mobilityString() ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::mobility >( getName() ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::dMobility_dPressure >( getName() ); - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::dMobility_dPressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); - - subRegion.template registerWrapper< array1d< real64 > >( viewKeyStruct::densityOldString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + subRegion.template registerExtrinsicData< extrinsicMeshData::flow::densityOld >( getName() ); } ); FaceManager & faceManager = meshLevel.getFaceManager(); { - faceManager.registerWrapper< array1d< real64 > >( viewKeyStruct::facePressureString() ). - setPlotLevel( PlotLevel::LEVEL_0 ). - setRegisteringObjects( this->getName() ). - setDescription( "An array that holds the pressures at the faces." ); + faceManager.registerExtrinsicData< facePressure >( getName() ); } } ); } @@ -150,12 +140,12 @@ void SinglePhaseBase::initializePreSubGroups() initializeAquiferBC(); } -void SinglePhaseBase::updateFluidModel( Group & dataGroup, localIndex const targetIndex ) const +void SinglePhaseBase::updateFluidModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const pres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const dPres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const pres = dataGroup.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 const > const dPres = dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); SingleFluidBase & fluid = getConstitutiveModel< SingleFluidBase >( dataGroup, m_fluidModelNames[targetIndex] ); @@ -166,17 +156,17 @@ void SinglePhaseBase::updateFluidModel( Group & dataGroup, localIndex const targ } ); } -void SinglePhaseBase::updateMobility( Group & dataGroup, localIndex const targetIndex ) const +void SinglePhaseBase::updateMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; // output arrayView1d< real64 > const mob = - dataGroup.getReference< array1d< real64 > >( viewKeyStruct::mobilityString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::mobility >(); arrayView1d< real64 > const dMob_dPres = - dataGroup.getReference< array1d< real64 > >( viewKeyStruct::dMobility_dPressureString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::dMobility_dPressure >(); // input @@ -202,7 +192,7 @@ void SinglePhaseBase::initializePostInitialConditionsPreSubGroups() MeshLevel & mesh = domain.getMeshBody( 0 ).getMeshLevel( 0 ); std::map< string, string_array > fieldNames; - fieldNames["elems"].emplace_back( string( viewKeyStruct::pressureString() ) ); + fieldNames["elems"].emplace_back( string( extrinsicMeshData::flow::pressure::key() ) ); CommunicationTools::getInstance().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), false ); @@ -219,7 +209,7 @@ void SinglePhaseBase::initializePostInitialConditionsPreSubGroups() ConstitutiveBase const & fluid = getConstitutiveModel( subRegion, m_fluidModelNames[targetIndex] ); real64 const defaultDensity = getFluidProperties( fluid ).defaultDensity; - subRegion.template getWrapper< array1d< real64 > >( viewKeyStruct::densityOldString() ).setDefaultValue( defaultDensity ); + subRegion.template getWrapper< array1d< real64 > >( extrinsicMeshData::flow::densityOld::key() ).setDefaultValue( defaultDensity ); // 1. update porosity, permeability, and density/viscosity @@ -250,7 +240,7 @@ void SinglePhaseBase::initializePostInitialConditionsPreSubGroups() ConstitutiveBase & fluid = getConstitutiveModel( subRegion, m_fluidModelNames[targetIndex] ); real64 const defaultDensity = getFluidProperties( fluid ).defaultDensity; - subRegion.getWrapper< real64_array >( viewKeyStruct::hydraulicApertureString() ). + subRegion.getWrapper< real64_array >( extrinsicMeshData::flow::hydraulicAperture::key() ). setApplyDefaultValue( region.getDefaultAperture() ); subRegion.getWrapper< real64_array >( FaceElementSubRegion::viewKeyStruct::creationMassString() ). @@ -262,8 +252,8 @@ void SinglePhaseBase::initializePostInitialConditionsPreSubGroups() forTargetSubRegions( mesh, [&]( localIndex const, ElementSubRegionBase & subRegion ) { - arrayView1d< real64 const > const pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 > const initPres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::initialPressureString() ); + arrayView1d< real64 const > const pres = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 > const initPres = subRegion.getExtrinsicData< extrinsicMeshData::flow::initialPressure >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -430,7 +420,7 @@ void SinglePhaseBase::computeHydrostaticEquilibrium() subRegion.getReference< array2d< real64 > >( ElementSubRegionBase::viewKeyStruct::elementCenterString() ); arrayView1d< real64 > const pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) { @@ -494,8 +484,8 @@ void SinglePhaseBase::implicitStepSetup( real64 const & GEOSX_UNUSED_PARAM( time forTargetSubRegions< CellElementSubRegion, SurfaceElementSubRegion >( mesh, [&]( localIndex const targetIndex, auto & subRegion ) { - arrayView1d< real64 > const & dPres = subRegion.template getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); - arrayView1d< real64 > const & dVol = subRegion.template getReference< array1d< real64 > >( viewKeyStruct::deltaVolumeString() ); + arrayView1d< real64 > const & dPres = subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); + arrayView1d< real64 > const & dVol = subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaVolume >(); dPres.zero(); dVol.zero(); @@ -508,8 +498,8 @@ void SinglePhaseBase::implicitStepSetup( real64 const & GEOSX_UNUSED_PARAM( time forTargetSubRegions< FaceElementSubRegion >( mesh, [&]( localIndex const targetIndex, FaceElementSubRegion & subRegion ) { - arrayView1d< real64 const > const aper = subRegion.getReference< array1d< real64 > >( viewKeyStruct::hydraulicApertureString() ); - arrayView1d< real64 > const aper0 = subRegion.getReference< array1d< real64 > >( viewKeyStruct::aperture0String() ); + arrayView1d< real64 const > const aper = subRegion.getExtrinsicData< extrinsicMeshData::flow::hydraulicAperture >(); + arrayView1d< real64 > const aper0 = subRegion.getExtrinsicData< extrinsicMeshData::flow::aperture0 >(); aper0.setValues< parallelDevicePolicy<> >( aper ); @@ -539,10 +529,10 @@ void SinglePhaseBase::implicitStepComplete( real64 const & time, forTargetSubRegions( mesh, [&]( localIndex const targetIndex, ElementSubRegionBase & subRegion ) { - arrayView1d< real64 const > const dPres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); - arrayView1d< real64 const > const dVol = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaVolumeString() ); + arrayView1d< real64 const > const dPres = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); + arrayView1d< real64 const > const dVol = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaVolume >(); - arrayView1d< real64 > const pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + arrayView1d< real64 > const pres = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const vol = subRegion.getReference< array1d< real64 > >( CellBlock::viewKeyStruct::elementVolumeString() ); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) @@ -563,7 +553,7 @@ void SinglePhaseBase::implicitStepComplete( real64 const & time, { arrayView1d< integer const > const elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const densOld = subRegion.getReference< array1d< real64 > >( viewKeyStruct::densityOldString() ); + arrayView1d< real64 const > const densOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::densityOld >(); arrayView1d< real64 > const creationMass = subRegion.getReference< real64_array >( FaceElementSubRegion::viewKeyStruct::creationMassString() ); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) @@ -614,13 +604,13 @@ void SinglePhaseBase::accumulationLaunch( localIndex const targetIndex, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { - string const dofKey = dofManager.getKey( viewKeyStruct::pressureString() ); + string const dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); arrayView1d< globalIndex const > const dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const ghostRank = subRegion.ghostRank(); arrayView1d< real64 const > const densityOld = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::densityOldString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::densityOld >(); arrayView1d< real64 const > const volume = subRegion.getElementVolume(); @@ -658,14 +648,14 @@ void SinglePhaseBase::accumulationLaunch( localIndex const targetIndex, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { - string const dofKey = dofManager.getKey( viewKeyStruct::pressureString() ); + string const dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); arrayView1d< globalIndex const > const & dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const & ghostRank = subRegion.ghostRank(); - arrayView1d< real64 const > const & densityOld = subRegion.getReference< array1d< real64 > >( viewKeyStruct::densityOldString() ); + arrayView1d< real64 const > const & densityOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::densityOld >(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & deltaVolume = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaVolumeString() ); + arrayView1d< real64 const > const & deltaVolume = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaVolume >(); ConstitutiveBase const & fluid = getConstitutiveModel( subRegion, fluidModelNames()[targetIndex] ); FluidPropViews const fluidProps = getFluidProperties( fluid ); @@ -742,6 +732,15 @@ void SinglePhaseBase::applyBoundaryConditions( real64 time_n, } +namespace internal +{ +string const bcLogMessage = string( "SinglePhaseBase {}: at time {}s, " ) + + string( "the <{}> boundary condition '{}' is applied to the element set '{}' in subRegion '{}'. " ) + + string( "\nThe scale of this boundary condition is {} and multiplies the value of the provided function (if any). " ) + + string( "\nThe total number of target elements (including ghost elements) is {}. " ) + + string( "\nNote that if this number is equal to zero for all subRegions, the boundary condition will not be applied on this element set." ); +} + void SinglePhaseBase::applyDirichletBC( real64 const time_n, real64 const dt, DomainPartition & domain, @@ -752,26 +751,35 @@ void SinglePhaseBase::applyDirichletBC( real64 const time_n, GEOSX_MARK_FUNCTION; FieldSpecificationManager & fsManager = FieldSpecificationManager::getInstance(); - string const dofKey = dofManager.getKey( viewKeyStruct::pressureString() ); + string const dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); fsManager.apply( time_n + dt, domain, "ElementRegions", - viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), [&]( FieldSpecificationBase const & fs, - string const &, + string const & setName, SortedArrayView< localIndex const > const & lset, Group & subRegion, string const & ) { + if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( lset.size() ); + GEOSX_LOG_RANK_0( GEOSX_FMT( geosx::internal::bcLogMessage, + getName(), time_n+dt, FieldSpecificationBase::catalogName(), + fs.getName(), setName, subRegion.getName(), fs.getScale(), numTargetElems ) ); + } + + arrayView1d< globalIndex const > const dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< real64 const > const pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); arrayView1d< real64 const > const dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); // call the application of the boundary condition to alter the matrix and rhs fs.applyBoundaryConditionToSystem< FieldSpecificationEqual, @@ -799,18 +807,26 @@ void SinglePhaseBase::applySourceFluxBC( real64 const time_n, GEOSX_MARK_FUNCTION; FieldSpecificationManager & fsManager = FieldSpecificationManager::getInstance(); - string const dofKey = dofManager.getKey( viewKeyStruct::pressureString() ); + string const dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); fsManager.apply( time_n + dt, domain, "ElementRegions", FieldSpecificationBase::viewKeyStruct::fluxBoundaryConditionString(), [&]( FieldSpecificationBase const & fs, - string const &, + string const & setName, SortedArrayView< localIndex const > const & targetSet, Group & subRegion, string const & ) { + if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( targetSet.size() ); + GEOSX_LOG_RANK_0( GEOSX_FMT( geosx::internal::bcLogMessage, + getName(), time_n+dt, SourceFluxBoundaryCondition::catalogName(), + fs.getName(), setName, subRegion.getName(), fs.getScale(), numTargetElems ) ); + } + arrayView1d< globalIndex const > const dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); @@ -831,7 +847,7 @@ void SinglePhaseBase::applySourceFluxBC( real64 const time_n, } ); } -void SinglePhaseBase::updateFluidState( Group & subRegion, localIndex targetIndex ) const +void SinglePhaseBase::updateFluidState( ObjectManagerBase & subRegion, localIndex targetIndex ) const { updateFluidModel( subRegion, targetIndex ); updateMobility( subRegion, targetIndex ); @@ -870,7 +886,7 @@ void SinglePhaseBase::resetStateToBeginningOfStep( DomainPartition & domain ) auto & subRegion ) { arrayView1d< real64 > const & dPres = - subRegion.template getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); dPres.zero(); @@ -887,7 +903,7 @@ void SinglePhaseBase::backupFields( MeshLevel & mesh ) const ConstitutiveBase const & fluid = getConstitutiveModel( subRegion, m_fluidModelNames[targetIndex] ); arrayView2d< real64 const > const & dens = getFluidProperties( fluid ).dens; - arrayView1d< real64 > const & densOld = subRegion.getReference< array1d< real64 > >( viewKeyStruct::densityOldString() ); + arrayView1d< real64 > const & densOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::densityOld >(); forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -901,21 +917,23 @@ void SinglePhaseBase::resetViews( MeshLevel & mesh ) FlowSolverBase::resetViews( mesh ); ElementRegionManager const & elemManager = mesh.getElemManager(); + using namespace extrinsicMeshData::flow; + m_volume.clear(); m_volume = elemManager.constructArrayViewAccessor< real64, 1 >( ElementSubRegionBase::viewKeyStruct::elementVolumeString() ); m_volume.setName( string( "accessors/" ) + ElementSubRegionBase::viewKeyStruct::elementVolumeString() ); m_deltaVolume.clear(); - m_deltaVolume = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaVolumeString() ); - m_deltaVolume.setName( getName() + "/accessors/" + viewKeyStruct::deltaVolumeString() ); + m_deltaVolume = elemManager.constructArrayViewAccessor< real64, 1 >( deltaVolume::key() ); + m_deltaVolume.setName( getName() + "/accessors/" + deltaVolume::key() ); m_mobility.clear(); - m_mobility = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::mobilityString() ); - m_mobility.setName( getName() + "/accessors/" + viewKeyStruct::mobilityString() ); + m_mobility = elemManager.constructArrayViewAccessor< real64, 1 >( mobility::key() ); + m_mobility.setName( getName() + "/accessors/" + mobility::key() ); m_dMobility_dPres.clear(); - m_dMobility_dPres = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::dMobility_dPressureString() ); - m_dMobility_dPres.setName( getName() + "/accessors/" + viewKeyStruct::dMobility_dPressureString() ); + m_dMobility_dPres = elemManager.constructArrayViewAccessor< real64, 1 >( dMobility_dPressure::key() ); + m_dMobility_dPres.setName( getName() + "/accessors/" + dMobility_dPressure::key() ); resetViewsPrivate( elemManager ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.hpp index c9f39d1b394..120bcfe5d92 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBase.hpp @@ -272,7 +272,7 @@ class SinglePhaseBase : public FlowSolverBase * @param dataGroup group that contains the fields */ void - updateFluidState( Group & subRegion, localIndex const targetIndex ) const; + updateFluidState( ObjectManagerBase & subRegion, localIndex const targetIndex ) const; /** @@ -280,27 +280,14 @@ class SinglePhaseBase : public FlowSolverBase * @param dataGroup group that contains the fields */ virtual void - updateFluidModel( Group & dataGroup, localIndex const targetIndex ) const; + updateFluidModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const; /** * @brief Function to update fluid mobility * @param dataGroup group that contains the fields */ void - updateMobility( Group & dataGroup, localIndex const targetIndex ) const; - - struct viewKeyStruct : FlowSolverBase::viewKeyStruct - { - // used for face-based BC - static constexpr char const * facePressureString() { return "facePressure"; } - - // intermediate fields - static constexpr char const * mobilityString() { return "mobility"; } - static constexpr char const * dMobility_dPressureString() { return "dMobility_dPressure"; } - - // backup fields - static constexpr char const * densityOldString() { return "densityOld"; } - }; + updateMobility( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const; /** * @brief Setup stored views into domain data for the current step diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp new file mode 100644 index 00000000000..e7ba9c52466 --- /dev/null +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp @@ -0,0 +1,65 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file SinglePhaseBaseExtrinsicData.hpp + */ + +#ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEBASEEXTRINSICDATA_HPP_ +#define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEBASEEXTRINSICDATA_HPP_ + +#include "mesh/ExtrinsicMeshData.hpp" + +namespace geosx +{ +/** + * A scope for extrinsic mesh data traits. + */ +namespace extrinsicMeshData +{ + +namespace flow +{ + +EXTRINSIC_MESH_DATA_TRAIT( mobility, + "mobility", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Mobility" ); + +EXTRINSIC_MESH_DATA_TRAIT( dMobility_dPressure, + "dMobility_dPressure", + array1d< real64 >, + 0, + NOPLOT, + NO_WRITE, + "Derivative of mobility with respect to pressure" ); + +EXTRINSIC_MESH_DATA_TRAIT( densityOld, + "densityOld", + array1d< real64 >, + 0, + NOPLOT, + NO_WRITE, + "Density at the previous converged time step" ); + +} + +} + +} + +#endif // GEOSX_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEBASEEXTRINSICDATA_HPP_ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp index 89cb1ccef3b..9106e31cda6 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp @@ -30,6 +30,8 @@ #include "finiteVolume/FluxApproximationBase.hpp" #include "fieldSpecification/FieldSpecificationManager.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBaseKernels.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseFVMKernels.hpp" #include "physicsSolvers/multiphysics/SinglePhasePoromechanicsFluxKernels.hpp" @@ -73,7 +75,7 @@ template< typename BASE > void SinglePhaseFVM< BASE >::setupDofs( DomainPartition const & domain, DofManager & dofManager ) const { - dofManager.addField( BASE::viewKeyStruct::pressureString(), + dofManager.addField( extrinsicMeshData::flow::pressure::key(), DofManager::Location::Elem, 1, targetRegionNames() ); @@ -82,7 +84,7 @@ void SinglePhaseFVM< BASE >::setupDofs( DomainPartition const & domain, FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); FluxApproximationBase const & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); - dofManager.addCoupling( BASE::viewKeyStruct::pressureString(), fluxApprox ); + dofManager.addCoupling( extrinsicMeshData::flow::pressure::key(), fluxApprox ); } template< typename BASE > @@ -110,7 +112,7 @@ real64 SinglePhaseFVM< BASE >::calculateResidualNorm( DomainPartition const & do { MeshLevel const & mesh = domain.getMeshBody( 0 ).getMeshLevel( 0 ); - string const dofKey = dofManager.getKey( BASE::viewKeyStruct::pressureString() ); + string const dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); // compute the norm of local residual scaled by cell pore volume @@ -121,7 +123,7 @@ real64 SinglePhaseFVM< BASE >::calculateResidualNorm( DomainPartition const & do arrayView1d< globalIndex const > const & dofNumber = subRegion.template getReference< array1d< globalIndex > >( dofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & densOld = subRegion.template getReference< array1d< real64 > >( BASE::viewKeyStruct::densityOldString() ); + arrayView1d< real64 const > const & densOld = subRegion.template getExtrinsicData< extrinsicMeshData::flow::densityOld >(); CoupledSolidBase const & solidModel = subRegion.template getConstitutiveModel< CoupledSolidBase >( m_solidModelNames[targetIndex] ); @@ -160,12 +162,12 @@ void SinglePhaseFVM< BASE >::applySystemSolution( DofManager const & dofManager, MeshLevel & mesh = domain.getMeshBody( 0 ).getMeshLevel( 0 ); dofManager.addVectorToField( localSolution, - BASE::viewKeyStruct::pressureString(), - BASE::viewKeyStruct::deltaPressureString(), + extrinsicMeshData::flow::pressure::key(), + extrinsicMeshData::flow::deltaPressure::key(), scalingFactor ); std::map< string, string_array > fieldNames; - fieldNames["elems"].emplace_back( string( BASE::viewKeyStruct::deltaPressureString() ) ); + fieldNames["elems"].emplace_back( string( extrinsicMeshData::flow::deltaPressure::key() ) ); CommunicationTools::getInstance().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), true ); } @@ -186,7 +188,7 @@ void SinglePhaseFVM< SinglePhaseBase >::assembleFluxTerms( real64 const GEOSX_UN FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); FluxApproximationBase const & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); - string const & dofKey = dofManager.getKey( SinglePhaseBase::viewKeyStruct::pressureString() ); + string const & dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > elemDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( dofKey ); elemDofNumber.setName( this->getName() + "/accessors/" + dofKey ); @@ -232,7 +234,7 @@ void SinglePhaseFVM< SinglePhaseProppantBase >::assembleFluxTerms( real64 const FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); FluxApproximationBase const & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); - string const & dofKey = dofManager.getKey( SinglePhaseProppantBase::viewKeyStruct::pressureString() ); + string const & dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > elemDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( dofKey ); elemDofNumber.setName( this->getName() + "/accessors/" + dofKey ); @@ -286,7 +288,7 @@ void SinglePhaseFVM< BASE >::assemblePoroelasticFluxTerms( real64 const GEOSX_UN FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); FluxApproximationBase const & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); - string const & pressureDofKey = dofManager.getKey( BASE::viewKeyStruct::pressureString() ); + string const & pressureDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > pressureDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( pressureDofKey ); pressureDofNumber.setName( this->getName() + "/accessors/" + pressureDofKey ); @@ -343,7 +345,7 @@ void SinglePhaseFVM< BASE >::assembleHydrofracFluxTerms( real64 const GEOSX_UNUS FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); FluxApproximationBase const & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); - string const & dofKey = dofManager.getKey( BASE::viewKeyStruct::pressureString() ); + string const & dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > elemDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( dofKey ); elemDofNumber.setName( this->getName() + "/accessors/" + dofKey ); @@ -393,6 +395,15 @@ SinglePhaseFVM< BASE >::applyBoundaryConditions( real64 const time_n, applyFaceDirichletBC( time_n, dt, dofManager, domain, localMatrix, localRhs ); } +namespace internal +{ +string const faceBcLogMessage = string( "SinglePhaseFVM {}: at time {}s, " ) + + string( "the <{}> boundary condition '{}' is applied to the face set '{}' in '{}'. " ) + + string( "\nThe total number of target faces (including ghost faces) is {}. " ) + + string( "\nNote that if this number is equal to zero, the boundary condition will not be applied on this face set." ); +} + + template< typename BASE > void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, real64 const dt, @@ -422,12 +433,12 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, } ); arrayView1d< real64 const > const presFace = - faceManager.getReference< array1d< real64 > >( BASE::viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 const > const gravCoefFace = - faceManager.getReference< array1d< real64 > >( BASE::viewKeyStruct::gravityCoefString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >(); - string const & dofKey = dofManager.getKey( BASE::viewKeyStruct::pressureString() ); + string const & dofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > elemDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( dofKey ); elemDofNumber.setName( this->getName() + "/accessors/" + dofKey ); @@ -436,7 +447,7 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, fsManager.apply( time_n + dt, domain, "faceManager", - BASE::viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), [&] ( FieldSpecificationBase const & fs, string const & setName, SortedArrayView< localIndex const > const & targetSet, @@ -444,6 +455,14 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, string const & ) { BoundaryStencil const & stencil = fluxApprox.getStencil< BoundaryStencil >( mesh, setName ); + if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetFaces = MpiWrapper::sum< globalIndex >( stencil.size() ); + GEOSX_LOG_RANK_0( GEOSX_FMT( geosx::internal::faceBcLogMessage, + this->getName(), time_n+dt, AquiferBoundaryCondition::catalogName(), + fs.getName(), setName, targetGroup.getName(), numTargetFaces ) ); + } + if( stencil.size() == 0 ) { return; @@ -453,7 +472,7 @@ void SinglePhaseFVM< BASE >::applyFaceDirichletBC( real64 const time_n, fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, time_n + dt, targetGroup, - BASE::viewKeyStruct::facePressureString() ); + extrinsicMeshData::flow::facePressure::key() ); // Now run the actual kernel BoundaryStencil::IndexContainerViewConstType const & seri = stencil.getElementRegionIndices(); @@ -510,7 +529,7 @@ void SinglePhaseFVM< BASE >::applyAquiferBC( real64 const time, FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); FluxApproximationBase const & fluxApprox = fvManager.getFluxApproximation( m_discretizationName ); - string const & elemDofKey = dofManager.getKey( BASE::viewKeyStruct::pressureString() ); + string const & elemDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > elemDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( elemDofKey ); elemDofNumber.setName( this->getName() + "/accessors/" + elemDofKey ); @@ -522,10 +541,18 @@ void SinglePhaseFVM< BASE >::applyAquiferBC( real64 const time, [&] ( AquiferBoundaryCondition const & bc, string const & setName, SortedArrayView< localIndex const > const &, - Group &, + Group & targetGroup, string const & ) { BoundaryStencil const & stencil = fluxApprox.getStencil< BoundaryStencil >( mesh, setName ); + if( bc.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) + { + globalIndex const numTargetFaces = MpiWrapper::sum< globalIndex >( stencil.size() ); + GEOSX_LOG_RANK_0( GEOSX_FMT( geosx::internal::faceBcLogMessage, + this->getName(), time+dt, AquiferBoundaryCondition::catalogName(), + bc.getName(), setName, targetGroup.getName(), numTargetFaces ) ); + } + if( stencil.size() == 0 ) { return; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp index a3cdff70cbf..517373b2aef 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp @@ -27,6 +27,7 @@ #include "finiteVolume/MimeticInnerProductDispatch.hpp" #include "mainInterface/ProblemManager.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" /** @@ -67,8 +68,7 @@ void SinglePhaseHybridFVM::registerDataOnMesh( Group & meshBodies ) FaceManager & faceManager = meshLevel.getFaceManager(); // primary variables: face pressures changes - faceManager.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ). - setRestartFlags( RestartFlags::NO_WRITE ); + faceManager.registerExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >( getName() ); } ); } @@ -128,7 +128,7 @@ void SinglePhaseHybridFVM::initializePostInitialConditionsPreSubGroups() fsManager.apply( 0.0, domain, "faceManager", - FlowSolverBase::viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), [&] ( FieldSpecificationBase const & bc, string const &, SortedArrayView< localIndex const > const &, @@ -165,7 +165,7 @@ void SinglePhaseHybridFVM::implicitStepSetup( real64 const & time_n, // get the accumulated pressure updates arrayView1d< real64 > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); // zero out the face pressures dFacePres.zero(); @@ -186,9 +186,9 @@ void SinglePhaseHybridFVM::implicitStepComplete( real64 const & time_n, // get the face-based pressures arrayView1d< real64 > const & facePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); forAll< parallelDevicePolicy<> >( faceManager.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iface ) { @@ -203,28 +203,28 @@ void SinglePhaseHybridFVM::setupDofs( DomainPartition const & GEOSX_UNUSED_PARAM // setup the connectivity of elem fields // we need Connectivity::Face because of the two-point upwinding // in AssembleOneSidedMassFluxes - dofManager.addField( viewKeyStruct::pressureString(), + dofManager.addField( extrinsicMeshData::flow::pressure::key(), DofManager::Location::Elem, 1, targetRegionNames() ); - dofManager.addCoupling( viewKeyStruct::pressureString(), - viewKeyStruct::pressureString(), + dofManager.addCoupling( extrinsicMeshData::flow::pressure::key(), + extrinsicMeshData::flow::pressure::key(), DofManager::Connector::Face ); // setup the connectivity of face fields - dofManager.addField( viewKeyStruct::facePressureString(), + dofManager.addField( extrinsicMeshData::flow::facePressure::key(), DofManager::Location::Face, 1, targetRegionNames() ); - dofManager.addCoupling( viewKeyStruct::facePressureString(), - viewKeyStruct::facePressureString(), + dofManager.addCoupling( extrinsicMeshData::flow::facePressure::key(), + extrinsicMeshData::flow::facePressure::key(), DofManager::Connector::Elem ); // setup coupling between pressure and face pressure - dofManager.addCoupling( viewKeyStruct::facePressureString(), - viewKeyStruct::pressureString(), + dofManager.addCoupling( extrinsicMeshData::flow::facePressure::key(), + extrinsicMeshData::flow::pressure::key(), DofManager::Connector::Elem ); } @@ -254,26 +254,26 @@ void SinglePhaseHybridFVM::assembleFluxTerms( real64 const GEOSX_UNUSED_PARAM( t // face data // get the face-based DOF numbers for the assembly - string const faceDofKey = dofManager.getKey( viewKeyStruct::facePressureString() ); + string const faceDofKey = dofManager.getKey( extrinsicMeshData::flow::facePressure::key() ); arrayView1d< globalIndex const > const & faceDofNumber = faceManager.getReference< array1d< globalIndex > >( faceDofKey ); arrayView1d< integer const > const & faceGhostRank = faceManager.ghostRank(); // get the element dof numbers for the assembly - string const & elemDofKey = dofManager.getKey( viewKeyStruct::pressureString() ); + string const & elemDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > elemDofNumber = mesh.getElemManager().constructArrayViewAccessor< globalIndex, 1 >( elemDofKey ); elemDofNumber.setName( getName() + "/accessors/" + elemDofKey ); // get the face-centered pressures arrayView1d< real64 const > const & facePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 const > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); // get the face-centered depth arrayView1d< real64 const > const & faceGravCoef = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::gravityCoefString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >(); // get the face-centered transMultiplier string const & coeffName = hmDiscretization.getReference< string >( HybridMimeticDiscretization::viewKeyStruct::coeffNameString() ); @@ -421,8 +421,8 @@ real64 SinglePhaseHybridFVM::calculateResidualNorm( DomainPartition const & doma // get a view into local residual vector - string const elemDofKey = dofManager.getKey( viewKeyStruct::pressureString() ); - string const faceDofKey = dofManager.getKey( viewKeyStruct::facePressureString() ); + string const elemDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); + string const faceDofKey = dofManager.getKey( extrinsicMeshData::flow::facePressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -444,24 +444,23 @@ real64 SinglePhaseHybridFVM::calculateResidualNorm( DomainPartition const & doma arrayView1d< globalIndex const > const & elemDofNumber = subRegion.template getReference< array1d< globalIndex > >( elemDofKey ); arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & densOld = subRegion.template getReference< array1d< real64 > >( viewKeyStruct::densityOldString() ); + arrayView1d< real64 const > const & densOld = subRegion.template getExtrinsicData< extrinsicMeshData::flow::densityOld >(); - ConstitutiveBase const & solidModel = subRegion.template getConstitutiveModel< ConstitutiveBase >( m_solidModelNames[targetIndex] ); + CoupledSolidBase const & solidModel = subRegion.template getConstitutiveModel< CoupledSolidBase >( m_solidModelNames[targetIndex] ); - constitutive::ConstitutivePassThru< CompressibleSolidBase >::execute( solidModel, [=, &localResidualNorm] ( auto & castedSolidModel ) - { - arrayView2d< real64 const > const & porosityOld = castedSolidModel.getOldPorosity(); - - SinglePhaseBaseKernels::ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - elemDofNumber, - elemGhostRank, - volume, - densOld, - porosityOld, - localResidualNorm ); - } ); + arrayView2d< real64 const > const & porosityOld = solidModel.getOldPorosity(); + + SinglePhaseBaseKernels:: + ResidualNormKernel:: + launch< parallelDevicePolicy<>, + parallelDeviceReduce >( localRhs, + rankOffset, + elemDofNumber, + elemGhostRank, + volume, + densOld, + porosityOld, + localResidualNorm ); SingleFluidBase const & fluid = getConstitutiveModel< SingleFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); defaultViscosity += fluid.defaultViscosity(); @@ -523,8 +522,8 @@ bool SinglePhaseHybridFVM::checkSystemSolution( DomainPartition const & domain, localIndex localCheck = 1; - string const elemDofKey = dofManager.getKey( viewKeyStruct::pressureString() ); - string const faceDofKey = dofManager.getKey( viewKeyStruct::facePressureString() ); + string const elemDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); + string const faceDofKey = dofManager.getKey( extrinsicMeshData::flow::facePressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -537,9 +536,9 @@ bool SinglePhaseHybridFVM::checkSystemSolution( DomainPartition const & domain, subRegion.ghostRank(); arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); localIndex const subRegionSolutionCheck = SinglePhaseBaseKernels::SolutionCheckKernel::launch< parallelDevicePolicy<>, @@ -563,9 +562,9 @@ bool SinglePhaseHybridFVM::checkSystemSolution( DomainPartition const & domain, faceManager.getReference< array1d< globalIndex > >( faceDofKey ); arrayView1d< real64 const > const & facePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); arrayView1d< real64 const > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); localIndex const faceSolutionCheck = SinglePhaseBaseKernels::SolutionCheckKernel::launch< parallelDevicePolicy<>, @@ -599,23 +598,23 @@ void SinglePhaseHybridFVM::applySystemSolution( DofManager const & dofManager, // 1. apply the cell-centered update dofManager.addVectorToField( localSolution, - viewKeyStruct::pressureString(), - viewKeyStruct::deltaPressureString(), + extrinsicMeshData::flow::pressure::key(), + extrinsicMeshData::flow::deltaPressure::key(), scalingFactor ); // 2. apply the face-based update dofManager.addVectorToField( localSolution, - viewKeyStruct::facePressureString(), - viewKeyStruct::deltaFacePressureString(), + extrinsicMeshData::flow::facePressure::key(), + extrinsicMeshData::flow::deltaFacePressure::key(), scalingFactor ); // 3. synchronize // the tags in fieldNames have to match the tags used in NeighborCommunicator.cpp std::map< string, string_array > fieldNames; - fieldNames["face"].emplace_back( string( viewKeyStruct::deltaFacePressureString() ) ); - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaPressureString() ) ); + fieldNames["face"].emplace_back( extrinsicMeshData::flow::deltaFacePressure::key() ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaPressure::key() ); CommunicationTools::getInstance().synchronizeFields( fieldNames, mesh, domain.getNeighbors(), true ); } @@ -632,7 +631,7 @@ void SinglePhaseHybridFVM::resetStateToBeginningOfStep( DomainPartition & domain // get the accumulated face pressure updates arrayView1d< real64 > const & dFacePres = - faceManager.getReference< array1d< real64 > >( viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); // zero out the face pressures dFacePres.zero(); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp index df7f9b187f1..b2ab9784586 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp @@ -29,7 +29,7 @@ #include "finiteVolume/mimeticInnerProducts/SimpleInnerProduct.hpp" #include "linearAlgebra/interfaces/InterfaceTypes.hpp" #include "mesh/MeshLevel.hpp" -#include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/HybridFVMHelperKernels.hpp" namespace geosx @@ -553,9 +553,9 @@ struct FluxKernel // get the cell-centered pressures arrayView1d< real64 const > const elemPres = - subRegion.getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const dElemPres = - subRegion.getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); // get the element data needed for transmissibility computation arrayView2d< real64 const > const elemCenter = @@ -569,7 +569,7 @@ struct FluxKernel // get the cell-centered depth arrayView1d< real64 const > const elemGravCoef = - subRegion.getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::gravityCoefString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::gravityCoefficient >(); // get the fluid data arrayView2d< real64 const > const elemDens = fluid.density(); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.cpp index 153a24a193a..0dc60ee188b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.cpp @@ -25,6 +25,7 @@ #include "constitutive/solid/CoupledSolidBase.hpp" #include "constitutive/solid/ProppantSolid.hpp" #include "constitutive/solid/porosity/ProppantPorosity.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseProppantBaseKernels.hpp" @@ -83,15 +84,15 @@ SinglePhaseBase::FluidPropViews SinglePhaseProppantBase::getFluidProperties( con slurryFluid.getWrapper< array2d< real64 > >( SlurryFluidBase::viewKeyStruct::viscosityString() ).getDefaultValue() }; } -void SinglePhaseProppantBase::updateFluidModel( Group & dataGroup, localIndex const targetIndex ) const +void SinglePhaseProppantBase::updateFluidModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const { GEOSX_MARK_FUNCTION; arrayView1d< real64 const > const pres = - dataGroup.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const dPres = - dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 const > const proppantConcentration = dataGroup.getReference< array1d< real64 > >( ProppantTransport::viewKeyStruct::proppantConcentrationString() ); @@ -130,10 +131,13 @@ void SinglePhaseProppantBase::updatePorosityAndPermeability( SurfaceElementSubRe { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const proppantPackVolumeFraction = subRegion.getReference< array1d< real64 > >( ProppantTransport::viewKeyStruct::proppantPackVolumeFractionString() ); + arrayView1d< real64 const > const proppantPackVolumeFraction = + subRegion.getReference< array1d< real64 > >( ProppantTransport::viewKeyStruct::proppantPackVolumeFractionString() ); - arrayView1d< real64 const > const newHydraulicAperture = subRegion.getReference< array1d< real64 > >( viewKeyStruct::hydraulicApertureString() ); - arrayView1d< real64 const > const oldHydraulicAperture = subRegion.getReference< array1d< real64 > >( viewKeyStruct::aperture0String() ); + arrayView1d< real64 const > const newHydraulicAperture = + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::hydraulicAperture::key() ); + arrayView1d< real64 const > const oldHydraulicAperture = + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::aperture0::key() ); CoupledSolidBase & porousSolid = subRegion.template getConstitutiveModel< CoupledSolidBase >( m_solidModelNames[targetIndex] ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.hpp index d4cee36d5f7..662fdcc7feb 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseProppantBase.hpp @@ -54,7 +54,7 @@ class SinglePhaseProppantBase : public SinglePhaseBase */ virtual ~SinglePhaseProppantBase(); - virtual void updateFluidModel( Group & dataGroup, localIndex const targetIndex ) const override; + virtual void updateFluidModel( ObjectManagerBase & dataGroup, localIndex const targetIndex ) const override; virtual void updatePorosityAndPermeability( SurfaceElementSubRegion & subRegion, localIndex const targetIndex ) const override; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index 6b29594f5b2..3b65da33797 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -141,7 +141,6 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK using Base::m_dPhaseCompFrac_dComp; using Base::m_localMatrix; using Base::m_localRhs; - using keys = CompositionalMultiphaseBase::viewKeyStruct; /** * @brief Constructor @@ -163,10 +162,10 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) : Base( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ), - m_dPhaseVolFrac_dTemp( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::dPhaseVolumeFraction_dTemperatureString() ) ), + m_dPhaseVolFrac_dTemp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature >() ), m_dPhaseDens_dTemp( fluid.dPhaseDensity_dTemperature() ), m_dPhaseCompFrac_dTemp( fluid.dPhaseCompFraction_dTemperature() ), - m_phaseInternalEnergyOld( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::phaseInternalEnergyOldString() ) ), + m_phaseInternalEnergyOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseInternalEnergyOld >() ), m_phaseInternalEnergy( fluid.phaseInternalEnergy() ), m_dPhaseInternalEnergy_dPres( fluid.dPhaseInternalEnergy_dPressure() ), m_dPhaseInternalEnergy_dTemp( fluid.dPhaseInternalEnergy_dTemperature() ), diff --git a/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp b/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp index 10d86564730..b919e418d0a 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/proppantTransport/ProppantTransport.cpp @@ -28,6 +28,7 @@ #include "fieldSpecification/FieldSpecificationManager.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/mpiCommunications/CommunicationTools.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/proppantTransport/ProppantTransportKernels.hpp" /** @@ -190,8 +191,8 @@ void ProppantTransport::updateFluidModel( Group & dataGroup, localIndex const ta { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const pres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const dPres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const pres = dataGroup.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); + arrayView1d< real64 const > const dPres = dataGroup.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); arrayView2d< real64 const > const componentConc = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::componentConcentrationString() ); arrayView2d< real64 const > const dComponentConc = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::deltaComponentConcentrationString() ); @@ -213,8 +214,8 @@ void ProppantTransport::updateComponentDensity( Group & dataGroup, localIndex co { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const pres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const dPres = dataGroup.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const pres = dataGroup.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); + arrayView1d< real64 const > const dPres = dataGroup.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); arrayView2d< real64 const > const componentConc = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::componentConcentrationString() ); arrayView2d< real64 const > const dComponentConc = dataGroup.getReference< array2d< real64 > >( viewKeyStruct::deltaComponentConcentrationString() ); @@ -949,12 +950,12 @@ void ProppantTransport::resetViews( MeshLevel & mesh ) ElementRegionManager & elemManager = mesh.getElemManager(); m_pressure.clear(); - m_pressure = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::pressureString() ); - m_pressure.setName( getName() + "/accessors/" + viewKeyStruct::pressureString() ); + m_pressure = elemManager.constructArrayViewAccessor< real64, 1 >( extrinsicMeshData::flow::pressure::key() ); + m_pressure.setName( getName() + "/accessors/" + extrinsicMeshData::flow::pressure::key() ); m_deltaPressure.clear(); - m_deltaPressure = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::deltaPressureString() ); - m_deltaPressure.setName( getName() + "/accessors/" + viewKeyStruct::deltaPressureString() ); + m_deltaPressure = elemManager.constructArrayViewAccessor< real64, 1 >( extrinsicMeshData::flow::deltaPressure::key() ); + m_deltaPressure.setName( getName() + "/accessors/" + extrinsicMeshData::flow::deltaPressure::key() ); m_proppantConcentration.clear(); m_proppantConcentration = elemManager.constructArrayViewAccessor< real64, 1 >( viewKeyStruct::proppantConcentrationString() ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp index 6af9df33b14..2fd14a75474 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp @@ -25,8 +25,10 @@ #include "common/TimingMacros.hpp" #include "constitutive/ConstitutiveManager.hpp" #include "constitutive/fluid/MultiFluidBase.hpp" +#include "constitutive/fluid/MultiFluidExtrinsicData.hpp" #include "constitutive/fluid/multiFluidSelector.hpp" #include "constitutive/relativePermeability/RelativePermeabilityBase.hpp" +#include "constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp" #include "mesh/DomainPartition.hpp" #include "mesh/WellElementSubRegion.hpp" #include "mesh/PerforationData.hpp" @@ -130,9 +132,9 @@ void CompositionalMultiphaseWell::registerDataOnMesh( Group & meshBodies ) { MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::pressureString() ). + subRegion.registerWrapper< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ). setPlotLevel( PlotLevel::LEVEL_0 ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaPressureString() ). + subRegion.registerWrapper< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ). setRestartFlags( RestartFlags::NO_WRITE ); subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::temperatureString() ). @@ -448,26 +450,10 @@ void CompositionalMultiphaseWell::updateComponentFraction( WellElementSubRegion { GEOSX_MARK_FUNCTION; - // outputs - arrayView2d< real64, compflow::USD_COMP > const & compFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); - arrayView3d< real64, compflow::USD_COMP_DC > const & dCompFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); - - // inputs - arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); - - IsothermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector1 - < IsothermalCompositionalMultiphaseBaseKernels::ComponentFractionKernel > - ( numFluidComponents(), - subRegion.size(), - compDens, - dCompDens, - compFrac, - dCompFrac_dCompDens ); + IsothermalCompositionalMultiphaseBaseKernels:: + ComponentFractionKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + subRegion ); } @@ -490,9 +476,9 @@ void CompositionalMultiphaseWell::updateBHPForConstraint( WellElementSubRegion & // subRegion data arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 > const & totalMassDens = subRegion.getReference< array1d< real64 > >( viewKeyStruct::totalMassDensityString() ); @@ -560,9 +546,9 @@ void CompositionalMultiphaseWell::updateVolRatesForConstraint( WellElementSubReg // subRegion data arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 const > const & temp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); @@ -738,12 +724,10 @@ void CompositionalMultiphaseWell::updateFluidModel( WellElementSubRegion & subRe { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const & pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const & dPres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); - - arrayView1d< real64 const > const temp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); + arrayView1d< real64 const > const & pres = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 const > const & dPres = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); + arrayView1d< real64 const > const & temp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); arrayView1d< real64 const > const dTemp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaTemperatureString() ); - arrayView2d< real64 const, compflow::USD_COMP > const & compFrac = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompFractionString() ); @@ -771,99 +755,28 @@ void CompositionalMultiphaseWell::updatePhaseVolumeFraction( WellElementSubRegio { GEOSX_MARK_FUNCTION; - // outputs - - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ); - - // inputs - - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); - arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); - MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); - 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(); - - 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(); - - IsothermalCompositionalMultiphaseBaseKernels::KernelLaunchSelector2 - < IsothermalCompositionalMultiphaseBaseKernels::PhaseVolumeFractionKernel > - ( numFluidComponents(), - numFluidPhases(), - subRegion.size(), - compDens, - dCompDens, - dCompFrac_dCompDens, - phaseDens, - dPhaseDens_dPres, - dPhaseDens_dComp, - phaseFrac, - dPhaseFrac_dPres, - dPhaseFrac_dComp, - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dCompDens ); + IsothermalCompositionalMultiphaseBaseKernels:: + PhaseVolumeFractionKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + subRegion, + fluid ); } void CompositionalMultiphaseWell::updateTotalMassDensity( WellElementSubRegion & subRegion, localIndex const targetIndex ) const { - // outputs - - arrayView1d< real64 > const & totalMassDens = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::totalMassDensityString() ); - arrayView1d< real64 > const & dTotalMassDens_dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::dTotalMassDensity_dPressureString() ); - arrayView2d< real64, compflow::USD_FLUID_DC > const & dTotalMassDens_dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_FLUID_DC > >( viewKeyStruct::dTotalMassDensity_dGlobalCompDensityString() ); - - // inputs - - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::phaseVolumeFractionString() ); - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ); - - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); + GEOSX_MARK_FUNCTION; MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); - 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(); - - IsothermalCompositionalMultiphaseBaseKernels:: - KernelLaunchSelector2< TotalMassDensityKernel > - ( numFluidComponents(), - numFluidPhases(), - subRegion.size(), - phaseVolFrac, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dCompDens, - dCompFrac_dCompDens, - phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dComp, - totalMassDens, - dTotalMassDens_dPres, - dTotalMassDens_dCompDens ); - + TotalMassDensityKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + subRegion, + fluid ); } void CompositionalMultiphaseWell::updateSubRegionState( WellElementSubRegion & subRegion, localIndex const targetIndex ) @@ -906,7 +819,7 @@ void CompositionalMultiphaseWell::initializeWells( DomainPartition & domain ) // get well primary variables on well elements arrayView1d< real64 > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const & wellElemTemp = subRegion.getReference< array1d< real64 > >( viewKeyStruct::temperatureString() ); @@ -1258,9 +1171,9 @@ CompositionalMultiphaseWell::scalingForSystemSolution( DomainPartition const & d // get a reference to the primary variables on well elements arrayView1d< real64 const > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64 const, compflow::USD_COMP > const & wellElemCompDens = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); @@ -1313,9 +1226,9 @@ CompositionalMultiphaseWell::checkSystemSolution( DomainPartition const & domain // get a reference to the primary variables on well elements arrayView1d< real64 const > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64 const, compflow::USD_COMP > const & wellElemCompDens = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); @@ -1365,9 +1278,9 @@ void CompositionalMultiphaseWell::computePerforationRates( WellElementSubRegion // get well primary variables on well elements arrayView1d< real64 const > const & wellElemPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64 const, compflow::USD_COMP > const & wellElemCompDens = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); @@ -1463,7 +1376,7 @@ CompositionalMultiphaseWell::applySystemSolution( DofManager const & dofManager, // update all the fields using the global damping coefficients dofManager.addVectorToField( localSolution, wellElementDofName(), - viewKeyStruct::deltaPressureString(), + extrinsicMeshData::flow::deltaPressure::key(), scalingFactor, { m_numDofPerWellElement, 0, 1 } ); @@ -1488,7 +1401,7 @@ CompositionalMultiphaseWell::applySystemSolution( DofManager const & dofManager, // synchronize std::map< string, string_array > fieldNames; - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaPressureString() ) ); + fieldNames["elems"].emplace_back( string( extrinsicMeshData::flow::deltaPressure::key() ) ); fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaGlobalCompDensityString() ) ); fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaMixtureConnRateString() ) ); CommunicationTools::getInstance().synchronizeFields( fieldNames, @@ -1543,7 +1456,7 @@ void CompositionalMultiphaseWell::resetStateToBeginningOfStep( DomainPartition & { // get a reference to the primary variables on well elements arrayView1d< real64 > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64, compflow::USD_COMP > const & dWellElemGlobalCompDensity = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::deltaGlobalCompDensityString() ); arrayView1d< real64 > const & dConnRate = @@ -1629,141 +1542,114 @@ void CompositionalMultiphaseWell::resetViews( DomainPartition & domain ) CompositionalMultiphaseBase & flowSolver = getParent().getGroup< CompositionalMultiphaseBase >( getFlowSolverName() ); { - using keys = CompositionalMultiphaseBase::viewKeyStruct; + using namespace extrinsicMeshData::flow; using namespace compflow; m_resPres.clear(); - m_resPres = elemManager.constructArrayViewAccessor< real64, 1 >( keys::pressureString() ); - m_resPres.setName( getName() + "/accessors/" + keys::pressureString() ); + m_resPres = elemManager.constructArrayViewAccessor< real64, 1 >( pressure::key() ); + m_resPres.setName( getName() + "/accessors/" + pressure::key() ); m_deltaResPres.clear(); m_deltaResPres = - elemManager.constructArrayViewAccessor< real64, 1 >( keys::deltaPressureString() ); - m_deltaResPres.setName( getName() + "/accessors/" + keys::deltaPressureString() ); + elemManager.constructArrayViewAccessor< real64, 1 >( deltaPressure::key() ); + m_deltaResPres.setName( getName() + "/accessors/" + deltaPressure::key() ); m_resTemp.clear(); - m_resTemp = elemManager.constructArrayViewAccessor< real64, 1 >( keys::temperatureString() ); - m_resTemp.setName( getName() + "/accessors/" + keys::temperatureString() ); + m_resTemp = elemManager.constructArrayViewAccessor< real64, 1 >( temperature::key() ); + m_resTemp.setName( getName() + "/accessors/" + temperature::key() ); m_resCompDens.clear(); m_resCompDens = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_COMP >( keys::globalCompDensityString() ); - m_resCompDens.setName( getName() + "/accessors/" + keys::globalCompDensityString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_COMP >( globalCompDensity::key() ); + m_resCompDens.setName( getName() + "/accessors/" + globalCompDensity::key() ); m_dResCompFrac_dCompDens.clear(); m_dResCompFrac_dCompDens = - elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_COMP_DC >( keys::dGlobalCompFraction_dGlobalCompDensityString() ); - m_dResCompFrac_dCompDens.setName( getName() + "/accessors/" + keys::dGlobalCompFraction_dGlobalCompDensityString() ); + elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_COMP_DC >( dGlobalCompFraction_dGlobalCompDensity::key() ); + m_dResCompFrac_dCompDens.setName( getName() + "/accessors/" + dGlobalCompFraction_dGlobalCompDensity::key() ); m_resPhaseVolFrac.clear(); m_resPhaseVolFrac = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::phaseVolumeFractionString() ); - m_resPhaseVolFrac.setName( getName() + "/accessors/" + keys::phaseVolumeFractionString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( phaseVolumeFraction::key() ); + m_resPhaseVolFrac.setName( getName() + "/accessors/" + phaseVolumeFraction::key() ); m_dResPhaseVolFrac_dPres.clear(); m_dResPhaseVolFrac_dPres = - elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( keys::dPhaseVolumeFraction_dPressureString() ); - m_dResPhaseVolFrac_dPres.setName( getName() + "/accessors/" + keys::dPhaseVolumeFraction_dPressureString() ); + elemManager.constructArrayViewAccessor< real64, 2, LAYOUT_PHASE >( dPhaseVolumeFraction_dPressure::key() ); + m_dResPhaseVolFrac_dPres.setName( getName() + "/accessors/" + dPhaseVolumeFraction_dPressure::key() ); m_dResPhaseVolFrac_dCompDens.clear(); m_dResPhaseVolFrac_dCompDens = - elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_PHASE_DC >( keys::dPhaseVolumeFraction_dGlobalCompDensityString() ); - m_dResPhaseVolFrac_dCompDens.setName( getName() + "/accessors/" + keys::dPhaseVolumeFraction_dGlobalCompDensityString() ); + elemManager.constructArrayViewAccessor< real64, 3, LAYOUT_PHASE_DC >( dPhaseVolumeFraction_dGlobalCompDensity::key() ); + m_dResPhaseVolFrac_dCompDens.setName( getName() + "/accessors/" + dPhaseVolumeFraction_dGlobalCompDensity::key() ); } { - using keys = MultiFluidBase::viewKeyStruct; - using namespace multifluid; + using namespace extrinsicMeshData::multifluid; m_resPhaseDens.clear(); - m_resPhaseDens = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseDensityString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_resPhaseDens.setName( getName() + "/accessors/" + keys::phaseDensityString() ); + m_resPhaseDens = elemManager.constructMaterialExtrinsicAccessor< phaseDensity >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_resPhaseDens.setName( getName() + "/accessors/" + phaseDensity::key() ); m_dResPhaseDens_dPres.clear(); - m_dResPhaseDens_dPres = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseDensity_dPressureString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_dResPhaseDens_dPres.setName( getName() + "/accessors/" + keys::dPhaseDensity_dPressureString() ); + m_dResPhaseDens_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseDensity_dPressure >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_dResPhaseDens_dPres.setName( getName() + "/accessors/" + dPhaseDensity_dPressure::key() ); m_dResPhaseDens_dComp.clear(); - m_dResPhaseDens_dComp = - elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_DC >( keys::dPhaseDensity_dGlobalCompFractionString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_dResPhaseDens_dComp.setName( getName() + "/accessors/" + keys::dPhaseDensity_dGlobalCompFractionString() ); - + m_dResPhaseDens_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseDensity_dGlobalCompFraction >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_dResPhaseDens_dComp.setName( getName() + "/accessors/" + dPhaseDensity_dGlobalCompFraction::key() ); m_resPhaseMassDens.clear(); - m_resPhaseMassDens = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseMassDensityString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_resPhaseMassDens.setName( getName() + "/accessors/" + keys::phaseMassDensityString() ); + m_resPhaseMassDens = elemManager.constructMaterialExtrinsicAccessor< phaseMassDensity >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_resPhaseMassDens.setName( getName() + "/accessors/" + phaseMassDensity::key() ); m_resPhaseVisc.clear(); - m_resPhaseVisc = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::phaseViscosityString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_resPhaseVisc.setName( getName() + "/accessors/" + keys::phaseViscosityString() ); + m_resPhaseVisc = elemManager.constructMaterialExtrinsicAccessor< phaseViscosity >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_resPhaseVisc.setName( getName() + "/accessors/" + phaseViscosity::key() ); m_dResPhaseVisc_dPres.clear(); - m_dResPhaseVisc_dPres = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_PHASE >( keys::dPhaseViscosity_dPressureString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_dResPhaseVisc_dPres.setName( getName() + "/accessors/" + keys::dPhaseViscosity_dPressureString() ); + m_dResPhaseVisc_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseViscosity_dPressure >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_dResPhaseVisc_dPres.setName( getName() + "/accessors/" + dPhaseViscosity_dPressure::key() ); m_dResPhaseVisc_dComp.clear(); - m_dResPhaseVisc_dComp = - elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_DC >( keys::dPhaseViscosity_dGlobalCompFractionString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_dResPhaseVisc_dComp.setName( getName() + "/accessors/" + keys::dPhaseViscosity_dGlobalCompFractionString() ); + m_dResPhaseVisc_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseViscosity_dGlobalCompFraction >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_dResPhaseVisc_dComp.setName( getName() + "/accessors/" + dPhaseViscosity_dGlobalCompFraction::key() ); m_resPhaseCompFrac.clear(); - m_resPhaseCompFrac = - elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_COMP >( keys::phaseCompFractionString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_resPhaseCompFrac.setName( getName() + "/accessors/" + keys::phaseCompFractionString() ); + m_resPhaseCompFrac = elemManager.constructMaterialExtrinsicAccessor< phaseCompFraction >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_resPhaseCompFrac.setName( getName() + "/accessors/" + phaseCompFraction::key() ); m_dResPhaseCompFrac_dPres.clear(); - m_dResPhaseCompFrac_dPres = - elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_PHASE_COMP >( keys::dPhaseCompFraction_dPressureString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_dResPhaseCompFrac_dPres.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dPressureString() ); + m_dResPhaseCompFrac_dPres = elemManager.constructMaterialExtrinsicAccessor< dPhaseCompFraction_dPressure >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_dResPhaseCompFrac_dPres.setName( getName() + "/accessors/" + dPhaseCompFraction_dPressure::key() ); m_dResPhaseCompFrac_dComp.clear(); - m_dResPhaseCompFrac_dComp = - elemManager.constructMaterialArrayViewAccessor< real64, 5, LAYOUT_PHASE_COMP_DC >( keys::dPhaseCompFraction_dGlobalCompFractionString(), - flowSolver.targetRegionNames(), - flowSolver.fluidModelNames() ); - m_dResPhaseCompFrac_dComp.setName( getName() + "/accessors/" + keys::dPhaseCompFraction_dGlobalCompFractionString() ); + m_dResPhaseCompFrac_dComp = elemManager.constructMaterialExtrinsicAccessor< dPhaseCompFraction_dGlobalCompFraction >( flowSolver.targetRegionNames(), + flowSolver.fluidModelNames() ); + m_dResPhaseCompFrac_dComp.setName( getName() + "/accessors/" + dPhaseCompFraction_dGlobalCompFraction::key() ); } { - using keys = RelativePermeabilityBase::viewKeyStruct; - using namespace relperm; + using namespace extrinsicMeshData::relperm; m_resPhaseRelPerm.clear(); - m_resPhaseRelPerm = - elemManager.constructMaterialArrayViewAccessor< real64, 3, LAYOUT_RELPERM >( keys::phaseRelPermString(), - flowSolver.targetRegionNames(), - flowSolver.relPermModelNames() ); - m_resPhaseRelPerm.setName( getName() + "/accessors/" + keys::phaseRelPermString() ); + m_resPhaseRelPerm = elemManager.constructMaterialExtrinsicAccessor< phaseRelPerm >( flowSolver.targetRegionNames(), + flowSolver.relPermModelNames() ); + m_resPhaseRelPerm.setName( getName() + "/accessors/" + phaseRelPerm::key() ); m_dResPhaseRelPerm_dPhaseVolFrac.clear(); - m_dResPhaseRelPerm_dPhaseVolFrac = - elemManager.constructMaterialArrayViewAccessor< real64, 4, LAYOUT_RELPERM_DS >( keys::dPhaseRelPerm_dPhaseVolFractionString(), - flowSolver.targetRegionNames(), - flowSolver.relPermModelNames() ); - m_dResPhaseRelPerm_dPhaseVolFrac.setName( getName() + "/accessors/" + keys::dPhaseRelPerm_dPhaseVolFractionString() ); + m_dResPhaseRelPerm_dPhaseVolFrac = elemManager.constructMaterialExtrinsicAccessor< dPhaseRelPerm_dPhaseVolFraction >( flowSolver.targetRegionNames(), + flowSolver.relPermModelNames() ); + m_dResPhaseRelPerm_dPhaseVolFrac.setName( getName() + "/accessors/" + dPhaseRelPerm_dPhaseVolFraction::key() ); } } @@ -1795,9 +1681,9 @@ void CompositionalMultiphaseWell::assemblePressureRelations( DomainPartition con // get primary variables on well elements arrayView1d< real64 const > const & wellElemPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); // get total mass density on well elements (for potential calculations) arrayView1d< real64 const > const & wellElemTotalMassDens = @@ -1889,9 +1775,9 @@ void CompositionalMultiphaseWell::implicitStepComplete( real64 const & GEOSX_UNU { // get a reference to the primary variables on well elements arrayView1d< real64 > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64, compflow::USD_COMP > const & wellElemGlobalCompDensity = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( viewKeyStruct::globalCompDensityString() ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp index f7bb58f88a4..b20f5ca3c9c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp @@ -22,6 +22,7 @@ #include "constitutive/fluid/layouts.hpp" #include "constitutive/relativePermeability/layouts.hpp" #include "physicsSolvers/fluidFlow/wells/WellSolverBase.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp" namespace geosx @@ -285,29 +286,25 @@ class CompositionalMultiphaseWell : public WellSolverBase static constexpr char const * allowLocalCompDensChoppingString() { return CompositionalMultiphaseBase::viewKeyStruct::allowLocalCompDensChoppingString(); } // primary solution field - static constexpr char const * pressureString() { return CompositionalMultiphaseBase::viewKeyStruct::pressureString(); } + static constexpr char const * globalCompDensityString() { return extrinsicMeshData::flow::globalCompDensity::key(); } - static constexpr char const * deltaPressureString() { return CompositionalMultiphaseBase::viewKeyStruct::deltaPressureString(); } - - static constexpr char const * globalCompDensityString() { return CompositionalMultiphaseBase::viewKeyStruct::globalCompDensityString(); } - - static constexpr char const * deltaGlobalCompDensityString() { return CompositionalMultiphaseBase::viewKeyStruct::deltaGlobalCompDensityString(); } + static constexpr char const * deltaGlobalCompDensityString() { return extrinsicMeshData::flow::deltaGlobalCompDensity::key(); } static constexpr char const * mixtureConnRateString() { return "wellElementMixtureConnectionRate"; } static constexpr char const * deltaMixtureConnRateString() { return "deltaWellElementMixtureConnectionRate"; } // saturations - static constexpr char const * phaseVolumeFractionString() { return CompositionalMultiphaseBase::viewKeyStruct::phaseVolumeFractionString(); } + static constexpr char const * phaseVolumeFractionString() { return extrinsicMeshData::flow::phaseVolumeFraction::key(); } - static constexpr char const * dPhaseVolumeFraction_dPressureString() { return CompositionalMultiphaseBase::viewKeyStruct::dPhaseVolumeFraction_dPressureString(); } + static constexpr char const * dPhaseVolumeFraction_dPressureString() { return extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure::key(); } - static constexpr char const * dPhaseVolumeFraction_dGlobalCompDensityString() { return CompositionalMultiphaseBase::viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString(); } + static constexpr char const * dPhaseVolumeFraction_dGlobalCompDensityString() { return extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity::key(); } // global component fractions - static constexpr char const * globalCompFractionString() { return CompositionalMultiphaseBase::viewKeyStruct::globalCompFractionString(); } + static constexpr char const * globalCompFractionString() { return extrinsicMeshData::flow::globalCompFraction::key(); } - static constexpr char const * dGlobalCompFraction_dGlobalCompDensityString() { return CompositionalMultiphaseBase::viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString(); } + static constexpr char const * dGlobalCompFraction_dGlobalCompDensityString() { return extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity::key(); } // total mass densities static constexpr char const * totalMassDensityString() { return "totalMassDensity"; } @@ -317,13 +314,13 @@ class CompositionalMultiphaseWell : public WellSolverBase static constexpr char const * dTotalMassDensity_dGlobalCompDensityString() { return "dTotalMassDensity_dComp"; } // these are used to store last converged time step values - static constexpr char const * phaseVolumeFractionOldString() { return CompositionalMultiphaseBase::viewKeyStruct::phaseVolumeFractionOldString(); } + static constexpr char const * phaseVolumeFractionOldString() { return extrinsicMeshData::flow::phaseVolumeFractionOld::key(); } - static constexpr char const * phaseDensityOldString() { return CompositionalMultiphaseBase::viewKeyStruct::phaseDensityOldString(); } + static constexpr char const * phaseDensityOldString() { return extrinsicMeshData::flow::phaseDensityOld::key(); } - static constexpr char const * totalDensityOldString() { return CompositionalMultiphaseBase::viewKeyStruct::totalDensityOldString(); } + static constexpr char const * totalDensityOldString() { return extrinsicMeshData::flow::totalDensityOld::key(); } - static constexpr char const * phaseComponentFractionOldString() { return CompositionalMultiphaseBase::viewKeyStruct::phaseComponentFractionOldString(); } + static constexpr char const * phaseComponentFractionOldString() { return extrinsicMeshData::flow::phaseComponentFractionOld::key(); } // perforation rates and derivatives diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp index 9bda15338c5..ebdab02ac9b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp @@ -1755,103 +1755,6 @@ RateInitializationKernel:: } ); } -/******************************** TotalMassDensityKernel ****************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -void -TotalMassDensityKernel:: - compute( 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 & phaseMassDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseMassDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseMassDens_dComp, - real64 & totalMassDens, - real64 & dTotalMassDens_dPres, - arraySlice1d< real64, compflow::USD_FLUID_DC - 1 > const & dTotalMassDens_dCompDens ) -{ - real64 dMassDens_dC[NC]{}; - - totalMassDens = 0.0; - dTotalMassDens_dPres = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - dTotalMassDens_dCompDens[ic] = 0.0; - } - - for( localIndex ip = 0; ip < NP; ++ip ) - { - totalMassDens += phaseVolFrac[ip] * phaseMassDens[ip]; - dTotalMassDens_dPres += dPhaseVolFrac_dPres[ip] * phaseMassDens[ip] - + phaseVolFrac[ip] * dPhaseMassDens_dPres[ip]; - - applyChainRule( NC, dCompFrac_dCompDens, dPhaseMassDens_dComp[ip], dMassDens_dC ); - for( localIndex ic = 0; ic < NC; ++ic ) - { - dTotalMassDens_dCompDens[ic] += dPhaseVolFrac_dCompDens[ip][ic] * phaseMassDens[ip] - + phaseVolFrac[ip] * dMassDens_dC[ic]; - } - } -} - -template< localIndex NC, localIndex NP > -void -TotalMassDensityKernel:: - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dWellElemPhaseVolFrac_dPres, - 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 & wellElemPhaseMassDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseMassDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseMassDens_dComp, - arrayView1d< real64 > const & wellElemTotalMassDens, - arrayView1d< real64 > const & dWellElemTotalMassDens_dPres, - arrayView2d< real64, compflow::USD_FLUID_DC > const & dWellElemTotalMassDens_dCompDens ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) - { - compute< NC, NP >( wellElemPhaseVolFrac[iwelem], - dWellElemPhaseVolFrac_dPres[iwelem], - dWellElemPhaseVolFrac_dCompDens[iwelem], - dWellElemCompFrac_dCompDens[iwelem], - wellElemPhaseMassDens[iwelem][0], - dWellElemPhaseMassDens_dPres[iwelem][0], - dWellElemPhaseMassDens_dComp[iwelem][0], - wellElemTotalMassDens[iwelem], - dWellElemTotalMassDens_dPres[iwelem], - dWellElemTotalMassDens_dCompDens[iwelem] ); - } ); -} - -#define INST_TotalMassDensityKernel( NC, NP ) \ - template \ - void TotalMassDensityKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dWellElemPhaseVolFrac_dPres, \ - 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 & wellElemPhaseMassDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseMassDens_dPres, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseMassDens_dComp, \ - arrayView1d< real64 > const & wellElemTotalMassDens, \ - arrayView1d< real64 > const & dWellElemTotalMassDens_dPres, \ - arrayView2d< real64, compflow::USD_FLUID_DC > const & dWellElemTotalMassDens_dCompDens ) - -INST_TotalMassDensityKernel( 1, 2 ); -INST_TotalMassDensityKernel( 2, 2 ); -INST_TotalMassDensityKernel( 3, 2 ); -INST_TotalMassDensityKernel( 4, 2 ); -INST_TotalMassDensityKernel( 5, 2 ); -INST_TotalMassDensityKernel( 1, 3 ); -INST_TotalMassDensityKernel( 2, 3 ); -INST_TotalMassDensityKernel( 3, 3 ); -INST_TotalMassDensityKernel( 4, 3 ); -INST_TotalMassDensityKernel( 5, 3 ); - } // end namespace CompositionalMultiphaseWellKernels diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp index 6ad43404883..dc18734fe5d 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp @@ -22,6 +22,7 @@ #include "common/DataTypes.hpp" #include "common/GEOS_RAJA_Interface.hpp" #include "constitutive/fluid/MultiFluidBase.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" #include "physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp" #include "physicsSolvers/fluidFlow/wells/WellControls.hpp" @@ -439,39 +440,162 @@ struct RateInitializationKernel /******************************** TotalMassDensityKernel ****************************/ -struct TotalMassDensityKernel +/** + * @class TotalMassDensityKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the total mass density + */ +template< integer NUM_COMP, integer NUM_PHASE > +class TotalMassDensityKernel : public IsothermalCompositionalMultiphaseBaseKernels::PropertyKernelBase< NUM_COMP > { +public: - template< localIndex NC, localIndex NP > + using Base = IsothermalCompositionalMultiphaseBaseKernels::PropertyKernelBase< NUM_COMP >; + // TODO: get rid of this as soon as extrinsicData is available for the wells + using keys = CompositionalMultiphaseWell::viewKeyStruct; + + using Base::numComp; + + /// Compile time value for the number of phases + static constexpr integer numPhase = NUM_PHASE; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + TotalMassDensityKernel( dataRepository::Group & subRegion, + MultiFluidBase const & fluid ) + : Base(), + m_phaseVolFrac( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::phaseVolumeFractionString() ) ), + m_dPhaseVolFrac_dPres( subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::dPhaseVolumeFraction_dPressureString() ) ), + m_dPhaseVolFrac_dCompDens( subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( keys::dPhaseVolumeFraction_dGlobalCompDensityString() ) ), + m_dCompFrac_dCompDens( subRegion.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( keys::dGlobalCompFraction_dGlobalCompDensityString() ) ), + m_phaseMassDens( fluid.phaseMassDensity() ), + m_dPhaseMassDens_dPres( fluid.dPhaseMassDensity_dPressure() ), + m_dPhaseMassDens_dComp( fluid.dPhaseMassDensity_dGlobalCompFraction() ), + m_totalMassDens( subRegion.getReference< array1d< real64 > >( keys::totalMassDensityString() ) ), + m_dTotalMassDens_dPres( subRegion.getReference< array1d< real64 > >( keys::dTotalMassDensity_dPressureString() ) ), + m_dTotalMassDens_dCompDens( subRegion.getReference< array2d< real64, compflow::LAYOUT_FLUID_DC > >( keys::dTotalMassDensity_dGlobalCompDensityString() ) ) + {} + + /** + * @brief Compute the total mass density in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] totalMassDensityKernelOp the function used to customize the kernel + */ + template< typename FUNC = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc > GEOSX_HOST_DEVICE - static void - compute( 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 & phaseMassDens, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseMassDens_dPres, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseMassDens_dComp, - real64 & totalMassDens, - real64 & dTotalMassDens_dPres, - arraySlice1d< real64, compflow::USD_FLUID_DC - 1 > const & dTotalMassDens_dCompDens ); + void compute( localIndex const ei, + FUNC && totalMassDensityKernelOp = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc{} ) const + { + 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]; + 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]; + + real64 dMassDens_dC[numComp]{}; + + totalMassDens = 0.0; + dTotalMassDens_dPres = 0.0; + for( integer ic = 0; ic < numComp; ++ic ) + { + dTotalMassDens_dCompDens[ic] = 0.0; + } - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_PHASE > const & wellElemPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dWellElemPhaseVolFrac_dPres, - 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 & wellElemPhaseMassDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dWellElemPhaseMassDens_dPres, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dWellElemPhaseMassDens_dComp, - arrayView1d< real64 > const & wellElemTotalMassDens, - arrayView1d< real64 > const & dWellElemTotalMassDens_dPres, - arrayView2d< real64, compflow::USD_FLUID_DC > const & dWellElemTotalMassDens_dCompDens ); + for( integer ip = 0; ip < numPhase; ++ip ) + { + totalMassDens += phaseVolFrac[ip] * phaseMassDens[ip]; + dTotalMassDens_dPres += dPhaseVolFrac_dPres[ip] * phaseMassDens[ip] + + phaseVolFrac[ip] * dPhaseMassDens_dPres[ip]; + + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseMassDens_dComp[ip], dMassDens_dC ); + for( integer ic = 0; ic < numComp; ++ic ) + { + dTotalMassDens_dCompDens[ic] += dPhaseVolFrac_dCompDens[ip][ic] * phaseMassDens[ip] + + phaseVolFrac[ip] * dMassDens_dC[ic]; + } + totalMassDensityKernelOp( ip, totalMassDens, dTotalMassDens_dPres, dTotalMassDens_dCompDens ); + } + } + +protected: + + // inputs + + /// Views on phase volume fractions + arrayView2d< real64 const, compflow::USD_PHASE > m_phaseVolFrac; + arrayView2d< real64 const, compflow::USD_PHASE > m_dPhaseVolFrac_dPres; + arrayView3d< real64 const, compflow::USD_PHASE_DC > m_dPhaseVolFrac_dCompDens; + arrayView3d< real64 const, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + + /// 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; + + // outputs + + /// Views on total mass densities + arrayView1d< real64 > m_totalMassDens; + arrayView1d< real64 > m_dTotalMassDens_dPres; + arrayView2d< real64, compflow::USD_FLUID_DC > m_dTotalMassDens_dCompDens; + +}; + +/** + * @class TotalMassDensityKernelFactory + */ +class TotalMassDensityKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + template< typename POLICY > + static void + createAndLaunch( integer const numComp, + integer const numPhase, + dataRepository::Group & subRegion, + MultiFluidBase const & fluid ) + { + if( numPhase == 2 ) + { + IsothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + TotalMassDensityKernel< NUM_COMP, 2 > kernel( subRegion, fluid ); + TotalMassDensityKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + IsothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + TotalMassDensityKernel< NUM_COMP, 3 > kernel( subRegion, fluid ); + TotalMassDensityKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } }; + /******************************** ResidualNormKernel ********************************/ struct ResidualNormKernel diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp index a2dfdae77ad..9bf785fb5fa 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp @@ -65,8 +65,8 @@ void SinglePhaseWell::registerDataOnMesh( Group & meshBodies ) forTargetSubRegions< WellElementSubRegion >( meshLevel, [&]( localIndex const, WellElementSubRegion & subRegion ) { - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::pressureString() ).setPlotLevel( PlotLevel::LEVEL_0 ); - subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.registerWrapper< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ).setPlotLevel( PlotLevel::LEVEL_0 ); + subRegion.registerWrapper< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::connRateString() ).setPlotLevel( PlotLevel::LEVEL_0 ); subRegion.registerWrapper< array1d< real64 > >( viewKeyStruct::deltaConnRateString() ); @@ -143,9 +143,9 @@ void SinglePhaseWell::updateBHPForConstraint( WellElementSubRegion & subRegion, // subRegion data arrayView1d< real64 const > const pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 const > const wellElemGravCoef = subRegion.getReference< array1d< real64 > >( viewKeyStruct::gravityCoefString() ); @@ -198,9 +198,9 @@ void SinglePhaseWell::updateVolRateForConstraint( WellElementSubRegion & subRegi // subRegion data arrayView1d< real64 const > const pres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const dPres = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 const > const & connRate = subRegion.getReference< array1d< real64 > >( viewKeyStruct::connRateString() ); @@ -274,8 +274,8 @@ void SinglePhaseWell::updateFluidModel( WellElementSubRegion & subRegion, localI { GEOSX_MARK_FUNCTION; - arrayView1d< real64 const > const pres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); - arrayView1d< real64 const > const dPres = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + arrayView1d< real64 const > const pres = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); + arrayView1d< real64 const > const dPres = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); SingleFluidBase & fluid = getConstitutiveModel< SingleFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); @@ -321,7 +321,7 @@ void SinglePhaseWell::initializeWells( DomainPartition & domain ) // get well primary variables on well elements arrayView1d< real64 > const wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const connRate = subRegion.getReference< array1d< real64 > >( viewKeyStruct::connRateString() ); @@ -432,9 +432,9 @@ void SinglePhaseWell::assemblePressureRelations( DomainPartition const & domain, // get primary variables on well elements arrayView1d< real64 const > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); // get well constitutive data SingleFluidBase const & fluid = getConstitutiveModel< SingleFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); @@ -562,9 +562,9 @@ void SinglePhaseWell::computePerforationRates( WellElementSubRegion & subRegion, // get well primary variables on well elements arrayView1d< real64 const > const - wellElemPressure = subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + wellElemPressure = subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const - dWellElemPressure = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + dWellElemPressure = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); // get well constitutive data SingleFluidBase const & fluid = getConstitutiveModel< SingleFluidBase >( subRegion, m_fluidModelNames[targetIndex] ); @@ -686,9 +686,9 @@ bool SinglePhaseWell::checkSystemSolution( DomainPartition const & domain, // get a reference to the primary variables on well elements arrayView1d< real64 const > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); // here we can reuse the flow solver kernel checking that pressures are positive localIndex const subRegionSolutionCheck = @@ -718,7 +718,7 @@ SinglePhaseWell::applySystemSolution( DofManager const & dofManager, { dofManager.addVectorToField( localSolution, wellElementDofName(), - viewKeyStruct::deltaPressureString(), + extrinsicMeshData::flow::deltaPressure::key(), scalingFactor, { m_numDofPerWellElement, 0, 1 } ); @@ -729,7 +729,7 @@ SinglePhaseWell::applySystemSolution( DofManager const & dofManager, { m_numDofPerWellElement, 1, m_numDofPerWellElement } ); std::map< string, string_array > fieldNames; - fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaPressureString() ) ); + fieldNames["elems"].emplace_back( string( extrinsicMeshData::flow::deltaPressure::key() ) ); fieldNames["elems"].emplace_back( string( viewKeyStruct::deltaConnRateString() ) ); CommunicationTools::getInstance().synchronizeFields( fieldNames, domain.getMeshBody( 0 ).getMeshLevel( 0 ), @@ -750,7 +750,7 @@ void SinglePhaseWell::resetStateToBeginningOfStep( DomainPartition & domain ) { // get a reference to the primary variables on well elements arrayView1d< real64 > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 > const & dConnRate = subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaConnRateString() ); @@ -793,15 +793,13 @@ void SinglePhaseWell::resetViews( DomainPartition & domain ) SinglePhaseBase & flowSolver = getParent().getGroup< SinglePhaseBase >( getFlowSolverName() ); { - using keys = SinglePhaseBase::viewKeyStruct; - m_resPressure.clear(); - m_resPressure = elemManager.constructArrayViewAccessor< real64, 1 >( keys::pressureString() ); - m_resPressure.setName( getName() + "/accessors/" + keys::pressureString() ); + m_resPressure = elemManager.constructArrayViewAccessor< real64, 1 >( extrinsicMeshData::flow::pressure::key() ); + m_resPressure.setName( getName() + "/accessors/" + extrinsicMeshData::flow::pressure::key() ); m_deltaResPressure.clear(); - m_deltaResPressure = elemManager.constructArrayViewAccessor< real64, 1 >( keys::deltaPressureString() ); - m_deltaResPressure.setName( getName() + "/accessors/" + keys::deltaPressureString() ); + m_deltaResPressure = elemManager.constructArrayViewAccessor< real64, 1 >( extrinsicMeshData::flow::deltaPressure::key() ); + m_deltaResPressure.setName( getName() + "/accessors/" + extrinsicMeshData::flow::deltaPressure::key() ); } { @@ -856,9 +854,9 @@ void SinglePhaseWell::implicitStepComplete( real64 const & GEOSX_UNUSED_PARAM( t { // get a reference to the primary variables on well elements arrayView1d< real64 > const wellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const dWellElemPressure = - subRegion.getReference< array1d< real64 > >( viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView1d< real64 > const connRate = subRegion.getReference< array1d< real64 > >( viewKeyStruct::connRateString() ); arrayView1d< real64 const > const dConnRate = diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.hpp index 2ffcb15221c..3ffb7aacb2d 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.hpp @@ -20,6 +20,7 @@ #define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_ #include "WellSolverBase.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" namespace geosx @@ -136,7 +137,7 @@ class SinglePhaseWell : public WellSolverBase virtual string wellElementDofName() const override { return viewKeyStruct::dofFieldString(); } - virtual string resElementDofName() const override { return SinglePhaseBase::viewKeyStruct::pressureString(); } + virtual string resElementDofName() const override { return extrinsicMeshData::flow::pressure::key(); } virtual localIndex numFluidComponents() const override { return 1; } @@ -236,13 +237,11 @@ class SinglePhaseWell : public WellSolverBase static constexpr char const * dofFieldString() { return "singlePhaseWellVars"; } // primary solution field - static constexpr char const * pressureString() { return SinglePhaseBase::viewKeyStruct::pressureString(); } - static constexpr char const * deltaPressureString() { return SinglePhaseBase::viewKeyStruct::deltaPressureString(); } static constexpr char const * connRateString() { return "connectionRate"; } static constexpr char const * deltaConnRateString() { return "deltaConnectionRate"; } // backup field for the accumulation term - static constexpr char const * densityOldString() { return SinglePhaseBase::viewKeyStruct::densityOldString(); } + static constexpr char const * densityOldString() { return extrinsicMeshData::flow::densityOld::key(); } // perforation rates static constexpr char const * perforationRateString() { return "perforationRate"; } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp index bfe91376f69..eee091d4406 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.cpp @@ -256,8 +256,8 @@ void WellSolverBase::resetViews( DomainPartition & domain ) ElementRegionManager const & elemManager = mesh.getElemManager(); m_resGravCoef.clear(); - m_resGravCoef = elemManager.constructArrayViewAccessor< real64, 1 >( FlowSolverBase::viewKeyStruct::gravityCoefString() ); - m_resGravCoef.setName( getName() + "/accessors/" + FlowSolverBase::viewKeyStruct::gravityCoefString() ); + m_resGravCoef = elemManager.constructArrayViewAccessor< real64, 1 >( extrinsicMeshData::flow::gravityCoefficient::key() ); + m_resGravCoef.setName( getName() + "/accessors/" + extrinsicMeshData::flow::gravityCoefficient::key() ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.hpp index f8ae84c7a02..2aafdbec46e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/WellSolverBase.hpp @@ -21,7 +21,7 @@ #include "physicsSolvers/SolverBase.hpp" #include "physicsSolvers/fluidFlow/FlowSolverBase.hpp" - +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" namespace geosx { @@ -259,7 +259,7 @@ class WellSolverBase : public SolverBase struct viewKeyStruct : SolverBase::viewKeyStruct { // gravity term precomputed values - static constexpr char const * gravityCoefString() { return FlowSolverBase::viewKeyStruct::gravityCoefString(); } + static constexpr char const * gravityCoefString() { return extrinsicMeshData::flow::gravityCoefficient::key(); } // misc inputs static constexpr char const * fluidNamesString() { return "fluidNames"; } diff --git a/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp b/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp index cd6a96840a3..dd5835719c8 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/HydrofractureSolver.cpp @@ -34,6 +34,7 @@ #include "mesh/MeshForLoopInterface.hpp" #include "mesh/utilities/ComputationalGeometry.hpp" #include "mesh/mpiCommunications/NeighborCommunicator.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" #include "physicsSolvers/multiphysics/HydrofractureSolverKernels.hpp" #include "physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.hpp" @@ -210,7 +211,7 @@ real64 HydrofractureSolver::solverStep( real64 const & time_n, std::map< string, string_array > fieldNames; fieldNames["node"].emplace_back( keys::IncrementalDisplacement ); fieldNames["node"].emplace_back( keys::TotalDisplacement ); - fieldNames["elems"].emplace_back( string( FlowSolverBase::viewKeyStruct::pressureString() ) ); + fieldNames["elems"].emplace_back( extrinsicMeshData::flow::pressure::key() ); fieldNames["elems"].emplace_back( "elementAperture" ); CommunicationTools::getInstance().synchronizeFields( fieldNames, @@ -254,9 +255,9 @@ void HydrofractureSolver::updateDeformationForCoupling( DomainPartition & domain ContactBase const & contact = getConstitutiveModel< ContactBase >( subRegion, m_contactRelationName ); arrayView1d< real64 > const aperture = subRegion.getElementAperture(); - arrayView1d< real64 > const hydraulicAperture = subRegion.getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::hydraulicApertureString() ); + arrayView1d< real64 > const hydraulicAperture = subRegion.getExtrinsicData< extrinsicMeshData::flow::hydraulicAperture >(); arrayView1d< real64 const > const volume = subRegion.getElementVolume(); - arrayView1d< real64 > const deltaVolume = subRegion.getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::deltaVolumeString() ); + arrayView1d< real64 > const deltaVolume = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaVolume >(); arrayView1d< real64 const > const area = subRegion.getElementArea(); arrayView2d< localIndex const > const elemsToFaces = subRegion.faceList(); @@ -456,7 +457,7 @@ void HydrofractureSolver::setupDofs( DomainPartition const & domain, } ); dofManager.addCoupling( keys::TotalDisplacement, - FlowSolverBase::viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), DofManager::Connector::Elem, fractureRegions ); @@ -534,7 +535,7 @@ void HydrofractureSolver::addFluxApertureCouplingNNZ( DomainPartition & domain, ElementRegionManager const & elemManager = mesh.getElemManager(); - string const presDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const presDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -594,7 +595,7 @@ void HydrofractureSolver::addFluxApertureCouplingSparsityPattern( DomainPartitio NodeManager const & nodeManager = mesh.getNodeManager(); ElementRegionManager const & elemManager = mesh.getElemManager(); - string const presDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const presDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); string const dispDofKey = dofManager.getKey( keys::TotalDisplacement ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -735,7 +736,7 @@ HydrofractureSolver:: fext = nodeManager.getReference< array2d< real64 > >( SolidMechanicsLagrangianFEM::viewKeyStruct::forceExternalString() ); fext.zero(); - string const presDofKey = m_dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const presDofKey = m_dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); string const dispDofKey = m_dofManager.getKey( keys::TotalDisplacement ); globalIndex const rankOffset = m_dofManager.rankOffset(); @@ -829,7 +830,7 @@ HydrofractureSolver:: FaceManager const & faceManager = mesh.getFaceManager(); NodeManager const & nodeManager = mesh.getNodeManager(); - string const presDofKey = m_dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const presDofKey = m_dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); string const dispDofKey = m_dofManager.getKey( keys::TotalDisplacement ); globalIndex const rankOffset = m_dofManager.rankOffset(); @@ -973,7 +974,7 @@ void HydrofractureSolver::setUpDflux_dApertureMatrix( DomainPartition & domain, } } - string const presDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const presDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); NumericalMethodsManager const & numericalMethodManager = domain.getNumericalMethodManager(); FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager(); diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp index c4de77cb344..ac6d0ae105d 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp @@ -18,8 +18,10 @@ #ifndef GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_MULTIPHASEPOROMECHANICSKERNEL_HPP_ #define GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_MULTIPHASEPOROMECHANICSKERNEL_HPP_ + #include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" -#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp" namespace geosx @@ -139,35 +141,24 @@ class Multiphase : } - // extract views into common flow solver data + // extract views into flow solver data { - using keys = FlowSolverBase::viewKeyStruct; + using namespace extrinsicMeshData::flow; - m_initialFluidPressure = elementSubRegion.template getReference< array1d< real64 > >( keys::initialPressureString() ); - m_fluidPressure = elementSubRegion.template getReference< array1d< real64 > >( keys::pressureString() ); - m_deltaFluidPressure = elementSubRegion.template getReference< array1d< real64 > >( keys::deltaPressureString() ); - } + m_initialFluidPressure = elementSubRegion.template getExtrinsicData< initialPressure >(); + m_fluidPressure = elementSubRegion.template getExtrinsicData< pressure >(); + m_deltaFluidPressure = elementSubRegion.template getExtrinsicData< deltaPressure >(); - // extract views into multiphase solver data - { - using keys = CompositionalMultiphaseBase::viewKeyStruct; - - m_fluidPhaseDensityOld = - elementSubRegion.template getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::phaseDensityOldString() ); - m_fluidPhaseCompFracOld = - elementSubRegion.template getReference< array3d< real64, compflow::LAYOUT_PHASE_COMP > >( keys::phaseComponentFractionOldString() ); - m_fluidPhaseSaturationOld = - elementSubRegion.template getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::phaseVolumeFractionOldString() ); - - m_fluidPhaseSaturation = - elementSubRegion.template getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::phaseVolumeFractionString() ); - m_dFluidPhaseSaturation_dPressure = - elementSubRegion.template getReference< array2d< real64, compflow::LAYOUT_PHASE > >( keys::dPhaseVolumeFraction_dPressureString() ); - m_dFluidPhaseSaturation_dGlobalCompDensity = - elementSubRegion.template getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( keys::dPhaseVolumeFraction_dGlobalCompDensityString() ); + m_fluidPhaseDensityOld = elementSubRegion.template getExtrinsicData< phaseDensityOld >(); + m_fluidPhaseCompFracOld = elementSubRegion.template getExtrinsicData< phaseComponentFractionOld >(); + m_fluidPhaseSaturationOld = elementSubRegion.template getExtrinsicData< phaseVolumeFractionOld >(); + + m_fluidPhaseSaturation = elementSubRegion.template getExtrinsicData< phaseVolumeFraction >(); + m_dFluidPhaseSaturation_dPressure = elementSubRegion.template getExtrinsicData< dPhaseVolumeFraction_dPressure >(); + m_dFluidPhaseSaturation_dGlobalCompDensity = elementSubRegion.template getExtrinsicData< dPhaseVolumeFraction_dGlobalCompDensity >(); m_dGlobalCompFraction_dGlobalCompDensity = - elementSubRegion.template getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( keys::dGlobalCompFraction_dGlobalCompDensityString() ); + elementSubRegion.template getExtrinsicData< dGlobalCompFraction_dGlobalCompDensity >(); } } diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEFEMKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEFEMKernel.hpp index 2015d8a0094..f0758ff5c0b 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEFEMKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsEFEMKernel.hpp @@ -18,9 +18,11 @@ #ifndef GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_SINGLEPHASEPOROMECHANICSEFEMKERNEL_HPP_ #define GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_SINGLEPHASEPOROMECHANICSEFEMKERNEL_HPP_ + #include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" #include "SinglePhasePoromechanicsKernel.hpp" -#include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" namespace geosx @@ -114,10 +116,10 @@ class SinglePhase : m_wDofNumber( jumpDofNumber ), m_solidDensity( inputConstitutiveType.getDensity() ), m_fluidDensity( embeddedSurfSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( fluidModelNames[targetRegionIndex] ).density() ), - m_fluidDensityOld( embeddedSurfSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::densityOldString() ) ), + m_fluidDensityOld( embeddedSurfSubRegion.template getExtrinsicData< extrinsicMeshData::flow::densityOld >() ), m_dFluidDensity_dPressure( embeddedSurfSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( fluidModelNames[targetRegionIndex] ).dDensity_dPressure() ), - m_matrixPressure( elementSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::pressureString() ) ), - m_deltaMatrixPressure( elementSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::deltaPressureString() ) ), + m_matrixPressure( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::pressure >() ), + m_deltaMatrixPressure( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaPressure >() ), m_oldPorosity( inputConstitutiveType.getOldPorosity() ), m_tractionVec( embeddedSurfSubRegion.tractionVector() ), m_dTraction_dJump( embeddedSurfSubRegion.dTraction_dJump() ), @@ -128,7 +130,7 @@ class SinglePhase : m_surfaceCenter( embeddedSurfSubRegion.getElementCenter() ), m_surfaceArea( embeddedSurfSubRegion.getElementArea() ), m_elementVolume( elementSubRegion.getElementVolume() ), - m_deltaVolume( elementSubRegion.template getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::deltaVolumeString() ) ), + m_deltaVolume( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaVolume >() ), m_fracturedElems( elementSubRegion.fracturedElementsList() ), m_cellsToEmbeddedSurfaces( elementSubRegion.embeddedSurfacesList().toViewConst() ), m_gravityVector{ inputGravityVector[0], inputGravityVector[1], inputGravityVector[2] }, diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp index c11693066fd..9254573e45a 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp @@ -18,9 +18,10 @@ #ifndef GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_SINGLEPHASEPOROMECHANICSKERNEL_HPP_ #define GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_SINGLEPHASEPOROMECHANICSKERNEL_HPP_ -#include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" -#include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" +#include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" namespace geosx { @@ -112,13 +113,13 @@ class SinglePhase : m_gravityAcceleration( LvArray::tensorOps::l2Norm< 3 >( inputGravityVector ) ), m_solidDensity( inputConstitutiveType.getDensity() ), m_fluidDensity( elementSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( fluidModelNames[targetRegionIndex] ).density() ), - m_fluidDensityOld( elementSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::densityOldString() ) ), + m_fluidDensityOld( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::densityOld >() ), m_initialFluidDensity( elementSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( fluidModelNames[targetRegionIndex] ).initialDensity() ), m_dFluidDensity_dPressure( elementSubRegion.template getConstitutiveModel< constitutive::SingleFluidBase >( fluidModelNames[targetRegionIndex] ).dDensity_dPressure() ), m_flowDofNumber( elementSubRegion.template getReference< array1d< globalIndex > >( inputFlowDofKey )), - m_initialFluidPressure( elementSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::initialPressureString() ) ), - m_fluidPressure( elementSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::pressureString() ) ), - m_deltaFluidPressure( elementSubRegion.template getReference< array1d< real64 > >( SinglePhaseBase::viewKeyStruct::deltaPressureString() ) ) + m_initialFluidPressure( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::initialPressure >() ), + m_fluidPressure( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::pressure >() ), + m_deltaFluidPressure( elementSubRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaPressure >() ) {} //***************************************************************************** diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp index d20a78bca06..77426676c72 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp @@ -32,6 +32,7 @@ #include "mainInterface/ProblemManager.hpp" #include "mesh/MeshForLoopInterface.hpp" #include "mesh/utilities/ComputationalGeometry.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" #include "physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.hpp" #include "common/GEOS_RAJA_Interface.hpp" @@ -77,7 +78,7 @@ void SinglePhasePoromechanicsSolver::setupDofs( DomainPartition const & domain, m_flowSolver->setupDofs( domain, dofManager ); dofManager.addCoupling( keys::TotalDisplacement, - FlowSolverBase::viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), DofManager::Connector::Elem ); } @@ -183,7 +184,7 @@ void SinglePhasePoromechanicsSolver::assembleSystem( real64 const time_n, string const dofKey = dofManager.getKey( dataRepository::keys::TotalDisplacement ); arrayView1d< globalIndex const > const & dispDofNumber = nodeManager.getReference< globalIndex_array >( dofKey ); - string const pDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const pDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); // m_solidSolver->resetStressToBeginningOfStep( domain ); @@ -266,7 +267,7 @@ void SinglePhasePoromechanicsSolver::createPreconditioner() auto flowPrecond = LAInterface::createPreconditioner( m_flowSolver->getLinearSolverParameters() ); precond->setupBlock( 1, - { { SinglePhaseBase::viewKeyStruct::pressureString(), { 1, true } } }, + { { extrinsicMeshData::flow::pressure::key(), { 1, true } } }, std::move( flowPrecond ) ); m_precond = std::move( precond ); diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolverEmbeddedFractures.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolverEmbeddedFractures.cpp index 8a4c5fed878..40debecdee7 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolverEmbeddedFractures.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolverEmbeddedFractures.cpp @@ -33,6 +33,7 @@ #include "mainInterface/ProblemManager.hpp" #include "mesh/MeshForLoopInterface.hpp" #include "mesh/utilities/ComputationalGeometry.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" #include "physicsSolvers/solidMechanics/SolidMechanicsEFEMKernelsHelper.hpp" #include "physicsSolvers/solidMechanics/SolidMechanicsEmbeddedFractures.hpp" @@ -103,7 +104,7 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::setupDofs( DomainPartition // Add coupling between displacement and cell pressures dofManager.addCoupling( keys::TotalDisplacement, - FlowSolverBase::viewKeyStruct::pressureString(), + extrinsicMeshData::flow::pressure::key(), DofManager::Connector::Elem ); // Add coupling between fracture pressure and displacement jump @@ -115,7 +116,7 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::setupDofs( DomainPartition regions.emplace_back( region.getName() ); } ); - dofManager.addCoupling( FlowSolverBase::viewKeyStruct::pressureString(), + dofManager.addCoupling( extrinsicMeshData::flow::pressure::key(), SolidMechanicsEmbeddedFractures::viewKeyStruct::dispJumpString(), DofManager::Connector::Elem, regions ); @@ -189,7 +190,7 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::addCouplingNumNonzeros( Do ElementRegionManager const & elemManager = mesh.getElemManager(); string const jumpDofKey = dofManager.getKey( SolidMechanicsEmbeddedFractures::viewKeyStruct::dispJumpString() ); - string const pressureDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const pressureDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -289,7 +290,7 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::addCouplingSparsityPattern ElementRegionManager const & elemManager = mesh.getElemManager(); string const jumpDofKey = dofManager.getKey( SolidMechanicsEmbeddedFractures::viewKeyStruct::dispJumpString() ); - string const pressureDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const pressureDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); globalIndex const rankOffset = dofManager.rankOffset(); @@ -403,7 +404,7 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::assembleSystem( real64 con arrayView1d< globalIndex const > const & dispDofNumber = nodeManager.getReference< globalIndex_array >( dofKey ); arrayView1d< globalIndex const > const & jumpDofNumber = subRegion.getReference< globalIndex_array >( jumpDofKey ); - string const pDofKey = dofManager.getKey( FlowSolverBase::viewKeyStruct::pressureString() ); + string const pDofKey = dofManager.getKey( extrinsicMeshData::flow::pressure::key() ); real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( gravityVector() ); @@ -583,12 +584,12 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::updateState( DomainPartiti arrayView1d< real64 > const aperture = subRegion.getElementAperture(); arrayView1d< real64 > const hydraulicAperture = - subRegion.template getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::hydraulicApertureString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::hydraulicAperture >(); arrayView1d< real64 const > const volume = subRegion.getElementVolume(); arrayView1d< real64 > const deltaVolume = - subRegion.template getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::deltaVolumeString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaVolume >(); arrayView1d< real64 const > const area = subRegion.getElementArea().toViewConst(); arrayView2d< real64 > const & fractureTraction = @@ -598,10 +599,10 @@ void SinglePhasePoromechanicsSolverEmbeddedFractures::updateState( DomainPartiti subRegion.template getReference< array1d< real64 > >( viewKeyStruct::dTraction_dPressureString() ); arrayView1d< real64 const > const & pressure = - subRegion.template getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::pressureString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 const > const & deltaPressure = - subRegion.template getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::deltaPressureString() ); + subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); ContactBase const & contact = getConstitutiveModel< ContactBase >( subRegion, m_fracturesSolver->getContactRelationName() ); diff --git a/src/coreComponents/schema/docs/Aquifer.rst b/src/coreComponents/schema/docs/Aquifer.rst index f38ebc0ad6d..a9e1b72f02e 100644 --- a/src/coreComponents/schema/docs/Aquifer.rst +++ b/src/coreComponents/schema/docs/Aquifer.rst @@ -27,6 +27,7 @@ direction R1Tensor {0,0,0} Direction to apply boun endTime real64 1e+99 Time at which the boundary condition will stop being applied. functionName string Name of function that specifies variation of the boundary condition. initialCondition integer 0 Boundary condition is applied as an initial condition. +logLevel integer 0 Log level name string required A name is required for any non-unique nodes pressureInfluenceFunctionName string | Name of the table describing the pressure influence function | . If not provided, we use a default pressure influence function diff --git a/src/coreComponents/schema/docs/BlackOilFluid_other.rst b/src/coreComponents/schema/docs/BlackOilFluid_other.rst index 746e6006dc2..ae2bf54c08d 100644 --- a/src/coreComponents/schema/docs/BlackOilFluid_other.rst +++ b/src/coreComponents/schema/docs/BlackOilFluid_other.rst @@ -1,48 +1,48 @@ -======================================== ========================================================================================================= ========================== -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 > (no description available) -dPhaseCompFraction_dPressure real64_array4d (no description available) -dPhaseCompFraction_dTemperature real64_array4d (no description available) -dPhaseDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseDensity_dPressure real64_array3d (no description available) -dPhaseDensity_dTemperature real64_array3d (no description available) -dPhaseEnthalpy_dGlobalCompFraction real64_array4d (no description available) -dPhaseEnthalpy_dPressure real64_array3d (no description available) -dPhaseEnthalpy_dTemperature real64_array3d (no description available) -dPhaseFraction_dGlobalCompFraction real64_array4d (no description available) -dPhaseFraction_dPressure real64_array3d (no description available) -dPhaseFraction_dTemperature real64_array3d (no description available) -dPhaseInternalEnergy_dGlobalCompFraction real64_array4d (no description available) -dPhaseInternalEnergy_dPressure real64_array3d (no description available) -dPhaseInternalEnergy_dTemperature real64_array3d (no description available) -dPhaseMassDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseMassDensity_dPressure real64_array3d (no description available) -dPhaseMassDensity_dTemperature real64_array3d (no description available) -dPhaseViscosity_dGlobalCompFraction real64_array4d (no description available) -dPhaseViscosity_dPressure real64_array3d (no description available) -dPhaseViscosity_dTemperature real64_array3d (no description available) -dTotalDensity_dGlobalCompFraction real64_array3d (no description available) -dTotalDensity_dPressure real64_array2d (no description available) -dTotalDensity_dTemperature real64_array2d (no description available) -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 (no description available) -phaseCompFraction real64_array4d (no description available) -phaseDensity real64_array3d (no description available) -phaseEnthalpy real64_array3d (no description available) -phaseFraction real64_array3d (no description available) -phaseInternalEnergy real64_array3d (no description available) -phaseMassDensity real64_array3d (no description available) -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -phaseViscosity real64_array3d (no description available) -totalDensity real64_array2d (no description available) -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_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 +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy 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 +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy 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 +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +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/BrooksCoreyBakerRelativePermeability_other.rst b/src/coreComponents/schema/docs/BrooksCoreyBakerRelativePermeability_other.rst index a0820b67d26..d9b56a614ac 100644 --- a/src/coreComponents/schema/docs/BrooksCoreyBakerRelativePermeability_other.rst +++ b/src/coreComponents/schema/docs/BrooksCoreyBakerRelativePermeability_other.rst @@ -3,9 +3,9 @@ =============================== ============== ======================================================================================================================= Name Type Description =============================== ============== ======================================================================================================================= -dPhaseRelPerm_dPhaseVolFraction real64_array4d (no description available) +dPhaseRelPerm_dPhaseVolFraction real64_array4d Derivative of phase relative permeability with respect to phase volume fraction phaseOrder integer_array (no description available) -phaseRelPerm real64_array3d (no description available) +phaseRelPerm real64_array3d Phase relative permeability phaseTypes integer_array (no description available) volFracScale real64 Factor used to scale the phase capillary pressure, defined as: one minus the sum of the phase minimum volume fractions. =============================== ============== ======================================================================================================================= diff --git a/src/coreComponents/schema/docs/BrooksCoreyCapillaryPressure_other.rst b/src/coreComponents/schema/docs/BrooksCoreyCapillaryPressure_other.rst index 3ade6bc985d..336528e2f6f 100644 --- a/src/coreComponents/schema/docs/BrooksCoreyCapillaryPressure_other.rst +++ b/src/coreComponents/schema/docs/BrooksCoreyCapillaryPressure_other.rst @@ -3,8 +3,8 @@ =================================== ============== ======================================================================================================================= Name Type Description =================================== ============== ======================================================================================================================= -dPhaseCapPressure_dPhaseVolFraction real64_array4d (no description available) -phaseCapPressure real64_array3d (no description available) +dPhaseCapPressure_dPhaseVolFraction real64_array4d Derivative of phase capillary pressure with respect to phase volume fraction +phaseCapPressure real64_array3d Phase capillary pressure phaseOrder integer_array (no description available) phaseTypes integer_array (no description available) volFracScale real64 Factor used to scale the phase capillary pressure, defined as: one minus the sum of the phase minimum volume fractions. diff --git a/src/coreComponents/schema/docs/BrooksCoreyRelativePermeability_other.rst b/src/coreComponents/schema/docs/BrooksCoreyRelativePermeability_other.rst index d296760a61e..3bcc35d5d1e 100644 --- a/src/coreComponents/schema/docs/BrooksCoreyRelativePermeability_other.rst +++ b/src/coreComponents/schema/docs/BrooksCoreyRelativePermeability_other.rst @@ -3,9 +3,9 @@ =============================== ============== ========================================================================================================================== Name Type Description =============================== ============== ========================================================================================================================== -dPhaseRelPerm_dPhaseVolFraction real64_array4d (no description available) +dPhaseRelPerm_dPhaseVolFraction real64_array4d Derivative of phase relative permeability with respect to phase volume fraction phaseOrder integer_array (no description available) -phaseRelPerm real64_array3d (no description available) +phaseRelPerm real64_array3d Phase relative permeability phaseTypes integer_array (no description available) volFracScale real64 Factor used to scale the phase relative permeability, defined as: one minus the sum of the phase minimum volume fractions. =============================== ============== ========================================================================================================================== diff --git a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst index d252fbdf8da..44509515edf 100644 --- a/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrineEzrokhiFluid_other.rst @@ -1,42 +1,42 @@ -======================================== ============================================================================================== ========================== -Name Type Description -======================================== ============================================================================================== ========================== -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > (no description available) -dPhaseCompFraction_dPressure real64_array4d (no description available) -dPhaseCompFraction_dTemperature real64_array4d (no description available) -dPhaseDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseDensity_dPressure real64_array3d (no description available) -dPhaseDensity_dTemperature real64_array3d (no description available) -dPhaseEnthalpy_dGlobalCompFraction real64_array4d (no description available) -dPhaseEnthalpy_dPressure real64_array3d (no description available) -dPhaseEnthalpy_dTemperature real64_array3d (no description available) -dPhaseFraction_dGlobalCompFraction real64_array4d (no description available) -dPhaseFraction_dPressure real64_array3d (no description available) -dPhaseFraction_dTemperature real64_array3d (no description available) -dPhaseInternalEnergy_dGlobalCompFraction real64_array4d (no description available) -dPhaseInternalEnergy_dPressure real64_array3d (no description available) -dPhaseInternalEnergy_dTemperature real64_array3d (no description available) -dPhaseMassDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseMassDensity_dPressure real64_array3d (no description available) -dPhaseMassDensity_dTemperature real64_array3d (no description available) -dPhaseViscosity_dGlobalCompFraction real64_array4d (no description available) -dPhaseViscosity_dPressure real64_array3d (no description available) -dPhaseViscosity_dTemperature real64_array3d (no description available) -dTotalDensity_dGlobalCompFraction real64_array3d (no description available) -dTotalDensity_dPressure real64_array2d (no description available) -dTotalDensity_dTemperature real64_array2d (no description available) -initialTotalMassDensity real64_array2d (no description available) -phaseCompFraction real64_array4d (no description available) -phaseDensity real64_array3d (no description available) -phaseEnthalpy real64_array3d (no description available) -phaseFraction real64_array3d (no description available) -phaseInternalEnergy real64_array3d (no description available) -phaseMassDensity real64_array3d (no description available) -phaseViscosity real64_array3d (no description available) -totalDensity real64_array2d (no description available) -useMass integer (no description available) -======================================== ============================================================================================== ========================== +======================================== ============================================================================================== ================================================================================ +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 +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy 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 +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy 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 +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +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 d252fbdf8da..44509515edf 100644 --- a/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst +++ b/src/coreComponents/schema/docs/CO2BrinePhillipsFluid_other.rst @@ -1,42 +1,42 @@ -======================================== ============================================================================================== ========================== -Name Type Description -======================================== ============================================================================================== ========================== -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > (no description available) -dPhaseCompFraction_dPressure real64_array4d (no description available) -dPhaseCompFraction_dTemperature real64_array4d (no description available) -dPhaseDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseDensity_dPressure real64_array3d (no description available) -dPhaseDensity_dTemperature real64_array3d (no description available) -dPhaseEnthalpy_dGlobalCompFraction real64_array4d (no description available) -dPhaseEnthalpy_dPressure real64_array3d (no description available) -dPhaseEnthalpy_dTemperature real64_array3d (no description available) -dPhaseFraction_dGlobalCompFraction real64_array4d (no description available) -dPhaseFraction_dPressure real64_array3d (no description available) -dPhaseFraction_dTemperature real64_array3d (no description available) -dPhaseInternalEnergy_dGlobalCompFraction real64_array4d (no description available) -dPhaseInternalEnergy_dPressure real64_array3d (no description available) -dPhaseInternalEnergy_dTemperature real64_array3d (no description available) -dPhaseMassDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseMassDensity_dPressure real64_array3d (no description available) -dPhaseMassDensity_dTemperature real64_array3d (no description available) -dPhaseViscosity_dGlobalCompFraction real64_array4d (no description available) -dPhaseViscosity_dPressure real64_array3d (no description available) -dPhaseViscosity_dTemperature real64_array3d (no description available) -dTotalDensity_dGlobalCompFraction real64_array3d (no description available) -dTotalDensity_dPressure real64_array2d (no description available) -dTotalDensity_dTemperature real64_array2d (no description available) -initialTotalMassDensity real64_array2d (no description available) -phaseCompFraction real64_array4d (no description available) -phaseDensity real64_array3d (no description available) -phaseEnthalpy real64_array3d (no description available) -phaseFraction real64_array3d (no description available) -phaseInternalEnergy real64_array3d (no description available) -phaseMassDensity real64_array3d (no description available) -phaseViscosity real64_array3d (no description available) -totalDensity real64_array2d (no description available) -useMass integer (no description available) -======================================== ============================================================================================== ========================== +======================================== ============================================================================================== ================================================================================ +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 +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy 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 +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy 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 +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +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/CompositionalMultiphaseFVM_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst index 8a4c243b5b0..fd6a957d827 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst @@ -1,12 +1,13 @@ -========================= ============ ================================ ===================================================== -Name Type Registered On Description -========================= ============ ================================ ===================================================== -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` An array that holds the pressures at the faces. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= ============ ================================ ===================================================== +========================= ============ ================================ =========================================================================== +Name Type Registered On Description +========================= ============ ================================ =========================================================================== +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Face pressure +gravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Gravity coefficient (dot product of gravity acceleration by gravity vector) +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= ============ ================================ =========================================================================== diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst index d252fbdf8da..44509515edf 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFluid_other.rst @@ -1,42 +1,42 @@ -======================================== ============================================================================================== ========================== -Name Type Description -======================================== ============================================================================================== ========================== -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > (no description available) -dPhaseCompFraction_dPressure real64_array4d (no description available) -dPhaseCompFraction_dTemperature real64_array4d (no description available) -dPhaseDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseDensity_dPressure real64_array3d (no description available) -dPhaseDensity_dTemperature real64_array3d (no description available) -dPhaseEnthalpy_dGlobalCompFraction real64_array4d (no description available) -dPhaseEnthalpy_dPressure real64_array3d (no description available) -dPhaseEnthalpy_dTemperature real64_array3d (no description available) -dPhaseFraction_dGlobalCompFraction real64_array4d (no description available) -dPhaseFraction_dPressure real64_array3d (no description available) -dPhaseFraction_dTemperature real64_array3d (no description available) -dPhaseInternalEnergy_dGlobalCompFraction real64_array4d (no description available) -dPhaseInternalEnergy_dPressure real64_array3d (no description available) -dPhaseInternalEnergy_dTemperature real64_array3d (no description available) -dPhaseMassDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseMassDensity_dPressure real64_array3d (no description available) -dPhaseMassDensity_dTemperature real64_array3d (no description available) -dPhaseViscosity_dGlobalCompFraction real64_array4d (no description available) -dPhaseViscosity_dPressure real64_array3d (no description available) -dPhaseViscosity_dTemperature real64_array3d (no description available) -dTotalDensity_dGlobalCompFraction real64_array3d (no description available) -dTotalDensity_dPressure real64_array2d (no description available) -dTotalDensity_dTemperature real64_array2d (no description available) -initialTotalMassDensity real64_array2d (no description available) -phaseCompFraction real64_array4d (no description available) -phaseDensity real64_array3d (no description available) -phaseEnthalpy real64_array3d (no description available) -phaseFraction real64_array3d (no description available) -phaseInternalEnergy real64_array3d (no description available) -phaseMassDensity real64_array3d (no description available) -phaseViscosity real64_array3d (no description available) -totalDensity real64_array2d (no description available) -useMass integer (no description available) -======================================== ============================================================================================== ========================== +======================================== ============================================================================================== ================================================================================ +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 +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy 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 +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy 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 +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +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/CompositionalMultiphaseHybridFVM_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst index 8a4c243b5b0..e47b664c563 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst @@ -1,12 +1,15 @@ -========================= ============ ================================ ===================================================== -Name Type Registered On Description -========================= ============ ================================ ===================================================== -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` An array that holds the pressures at the faces. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= ============ ================================ ===================================================== +========================= ============ ================================ =========================================================================== +Name Type Registered On Description +========================= ============ ================================ =========================================================================== +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +deltaFacePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Accumulated face pressure updates +facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Face pressure +gravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Gravity coefficient (dot product of gravity acceleration by gravity vector) +mimGravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Mimetic gravity coefficient +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= ============ ================================ =========================================================================== diff --git a/src/coreComponents/schema/docs/DeadOilFluid_other.rst b/src/coreComponents/schema/docs/DeadOilFluid_other.rst index a476f99ee0d..58b6e630a01 100644 --- a/src/coreComponents/schema/docs/DeadOilFluid_other.rst +++ b/src/coreComponents/schema/docs/DeadOilFluid_other.rst @@ -1,47 +1,47 @@ -======================================== ========================================================================================================= ========================== -Name Type Description -======================================== ========================================================================================================= ========================== -dPhaseCompFraction_dGlobalCompFraction LvArray_Array< double, 5, camp_int_seq< long, 0l, 1l, 2l, 3l, 4l >, long, LvArray_ChaiBuffer > (no description available) -dPhaseCompFraction_dPressure real64_array4d (no description available) -dPhaseCompFraction_dTemperature real64_array4d (no description available) -dPhaseDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseDensity_dPressure real64_array3d (no description available) -dPhaseDensity_dTemperature real64_array3d (no description available) -dPhaseEnthalpy_dGlobalCompFraction real64_array4d (no description available) -dPhaseEnthalpy_dPressure real64_array3d (no description available) -dPhaseEnthalpy_dTemperature real64_array3d (no description available) -dPhaseFraction_dGlobalCompFraction real64_array4d (no description available) -dPhaseFraction_dPressure real64_array3d (no description available) -dPhaseFraction_dTemperature real64_array3d (no description available) -dPhaseInternalEnergy_dGlobalCompFraction real64_array4d (no description available) -dPhaseInternalEnergy_dPressure real64_array3d (no description available) -dPhaseInternalEnergy_dTemperature real64_array3d (no description available) -dPhaseMassDensity_dGlobalCompFraction real64_array4d (no description available) -dPhaseMassDensity_dPressure real64_array3d (no description available) -dPhaseMassDensity_dTemperature real64_array3d (no description available) -dPhaseViscosity_dGlobalCompFraction real64_array4d (no description available) -dPhaseViscosity_dPressure real64_array3d (no description available) -dPhaseViscosity_dTemperature real64_array3d (no description available) -dTotalDensity_dGlobalCompFraction real64_array3d (no description available) -dTotalDensity_dPressure real64_array2d (no description available) -dTotalDensity_dTemperature real64_array2d (no description available) -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 (no description available) -phaseCompFraction real64_array4d (no description available) -phaseDensity real64_array3d (no description available) -phaseEnthalpy real64_array3d (no description available) -phaseFraction real64_array3d (no description available) -phaseInternalEnergy real64_array3d (no description available) -phaseMassDensity real64_array3d (no description available) -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -phaseViscosity real64_array3d (no description available) -totalDensity real64_array2d (no description available) -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_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 +dPhaseEnthalpy_dGlobalCompFraction real64_array4d Derivative of phase enthalpy with respect to global component fraction +dPhaseEnthalpy_dPressure real64_array3d Derivative of phase enthalpy with respect to pressure +dPhaseEnthalpy_dTemperature real64_array3d Derivative of phase enthalpy 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 +dPhaseInternalEnergy_dGlobalCompFraction real64_array4d Derivative of phase internal energy with respect to global component fraction +dPhaseInternalEnergy_dPressure real64_array3d Derivative of phase internal energy with respect to pressure +dPhaseInternalEnergy_dTemperature real64_array3d Derivative of phase internal energy 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 +phaseEnthalpy real64_array3d Phase enthalpy +phaseFraction real64_array3d Phase fraction +phaseInternalEnergy real64_array3d Phase internal energy +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/Dirichlet.rst b/src/coreComponents/schema/docs/Dirichlet.rst index 5c2c21b3724..46a4c0ab2b2 100644 --- a/src/coreComponents/schema/docs/Dirichlet.rst +++ b/src/coreComponents/schema/docs/Dirichlet.rst @@ -11,6 +11,7 @@ endTime real64 1e+99 Time at which the boundary conditio fieldName string Name of field that boundary condition is applied to. functionName string Name of function that specifies variation of the boundary condition. initialCondition integer 0 Boundary condition is applied as an initial condition. +logLevel integer 0 Log level name string required A name is required for any non-unique nodes objectPath string Path to the target field scale real64 0 Scale factor for value of the boundary condition. diff --git a/src/coreComponents/schema/docs/FaceManager_other.rst b/src/coreComponents/schema/docs/FaceManager_other.rst index ffb1aebbc21..88b2fb95be9 100644 --- a/src/coreComponents/schema/docs/FaceManager_other.rst +++ b/src/coreComponents/schema/docs/FaceManager_other.rst @@ -1,41 +1,41 @@ -======================== ==================================================================================== =================================================================================================================================================================================================================================== ===================================================================================================================================================== -Name Type Registered By Description -======================== ==================================================================================== =================================================================================================================================================================================================================================== ===================================================================================================================================================== -deltaFacePressure real64_array (no description available) -domainBoundaryIndicator integer_array (no description available) -edgeList geosx_InterObjectRelation< LvArray_ArrayOfArrays< long, long, LvArray_ChaiBuffer > > (no description available) -elemList localIndex_array2d (no description available) -elemRegionList localIndex_array2d (no description available) -elemSubRegionList localIndex_array2d (no description available) -faceArea real64_array (no description available) -faceCenter real64_array2d (no description available) -faceNormal real64_array2d (no description available) -ghostRank integer_array (no description available) -globalToLocalMap geosx_mapBase< long long, long, std_integral_constant< bool, false > > (no description available) -gravityCoefficient real64_array (no description available) -isExternal integer_array (no description available) -localToGlobalMap globalIndex_array Array that contains a map from localIndex to globalIndex. -mimGravityCoefficient real64_array (no description available) -nodeList geosx_InterObjectRelation< LvArray_ArrayOfArrays< long, long, LvArray_ChaiBuffer > > (no description available) -K_IC real64_array2d :ref:`DATASTRUCTURE_SurfaceGenerator` Critical Stress Intensity Factor :math:`K_{IC}` in the plane of the face. -SIFonFace real64_array :ref:`DATASTRUCTURE_SurfaceGenerator` Calculated Stress Intensity Factor on the face. -TransMultiplier real64_array :ref:`DATASTRUCTURE_HybridMimeticDiscretization`, :ref:`DATASTRUCTURE_TwoPointFluxApproximation` An array that holds the transmissibility multipliers -childIndex localIndex_array :ref:`DATASTRUCTURE_SurfaceGenerator` Index of child within the mesh object it is registered on. -degreeFromCrackTip integer_array :ref:`DATASTRUCTURE_SurfaceGenerator` Distance to the crack tip in terms of topological distance. (i.e. how many nodes are along the path to the closest node that is on the crack surface. -facePressure real64_array :ref:`DATASTRUCTURE_CompositionalMultiphaseFVM`, :ref:`DATASTRUCTURE_CompositionalMultiphaseHybridFVM`, :ref:`DATASTRUCTURE_SinglePhaseFVM`, :ref:`DATASTRUCTURE_SinglePhaseHybridFVM`, :ref:`DATASTRUCTURE_SinglePhaseProppantFVM` An array that holds the pressures at the faces. -freeSurfaceFaceIndicator localIndex_array :ref:`DATASTRUCTURE_AcousticSEM` Free surface indicator, 1 if a face is on free surface 0 otherwise. -isFaceSeparable integer_array :ref:`DATASTRUCTURE_SurfaceGenerator` A flag to mark if the face is separable. -parentIndex localIndex_array :ref:`DATASTRUCTURE_SurfaceGenerator` Index of parent within the mesh object it is registered on. -primaryCandidateFace localIndex_array :ref:`DATASTRUCTURE_SurfaceGenerator` ?? -ruptureState integer_array :ref:`DATASTRUCTURE_SurfaceGenerator` | Rupture state of the face: - | 0=not ready for rupture - | 1=ready for rupture - | 2=ruptured. -ruptureTime real64_array :ref:`DATASTRUCTURE_SurfaceGenerator` Time that the object was ruptured/split. -neighborData node :ref:`DATASTRUCTURE_neighborData` -sets node :ref:`DATASTRUCTURE_sets` -======================== ==================================================================================== =================================================================================================================================================================================================================================== ===================================================================================================================================================== +======================== ==================================================================================== =========================================================================================================================================================================================================================================================================== ===================================================================================================================================================== +Name Type Registered By Description +======================== ==================================================================================== =========================================================================================================================================================================================================================================================================== ===================================================================================================================================================== +domainBoundaryIndicator integer_array (no description available) +edgeList geosx_InterObjectRelation< LvArray_ArrayOfArrays< long, long, LvArray_ChaiBuffer > > (no description available) +elemList localIndex_array2d (no description available) +elemRegionList localIndex_array2d (no description available) +elemSubRegionList localIndex_array2d (no description available) +faceArea real64_array (no description available) +faceCenter real64_array2d (no description available) +faceNormal real64_array2d (no description available) +ghostRank integer_array (no description available) +globalToLocalMap geosx_mapBase< long long, long, std_integral_constant< bool, false > > (no description available) +isExternal integer_array (no description available) +localToGlobalMap globalIndex_array Array that contains a map from localIndex to globalIndex. +nodeList geosx_InterObjectRelation< LvArray_ArrayOfArrays< long, long, LvArray_ChaiBuffer > > (no description available) +K_IC real64_array2d :ref:`DATASTRUCTURE_SurfaceGenerator` Critical Stress Intensity Factor :math:`K_{IC}` in the plane of the face. +SIFonFace real64_array :ref:`DATASTRUCTURE_SurfaceGenerator` Calculated Stress Intensity Factor on the face. +TransMultiplier real64_array :ref:`DATASTRUCTURE_HybridMimeticDiscretization`, :ref:`DATASTRUCTURE_TwoPointFluxApproximation` An array that holds the transmissibility multipliers +childIndex localIndex_array :ref:`DATASTRUCTURE_SurfaceGenerator` Index of child within the mesh object it is registered on. +degreeFromCrackTip integer_array :ref:`DATASTRUCTURE_SurfaceGenerator` Distance to the crack tip in terms of topological distance. (i.e. how many nodes are along the path to the closest node that is on the crack surface. +deltaFacePressure real64_array :ref:`DATASTRUCTURE_CompositionalMultiphaseHybridFVM`, :ref:`DATASTRUCTURE_SinglePhaseHybridFVM` Accumulated face pressure updates +facePressure real64_array :ref:`DATASTRUCTURE_CompositionalMultiphaseFVM`, :ref:`DATASTRUCTURE_CompositionalMultiphaseHybridFVM`, :ref:`DATASTRUCTURE_SinglePhaseFVM`, :ref:`DATASTRUCTURE_SinglePhaseHybridFVM`, :ref:`DATASTRUCTURE_SinglePhaseProppantFVM` Face pressure +freeSurfaceFaceIndicator localIndex_array :ref:`DATASTRUCTURE_AcousticSEM` Free surface indicator, 1 if a face is on free surface 0 otherwise. +gravityCoefficient real64_array :ref:`DATASTRUCTURE_CompositionalMultiphaseFVM`, :ref:`DATASTRUCTURE_CompositionalMultiphaseHybridFVM`, :ref:`DATASTRUCTURE_ProppantTransport`, :ref:`DATASTRUCTURE_SinglePhaseFVM`, :ref:`DATASTRUCTURE_SinglePhaseHybridFVM`, :ref:`DATASTRUCTURE_SinglePhaseProppantFVM` Gravity coefficient (dot product of gravity acceleration by gravity vector) +isFaceSeparable integer_array :ref:`DATASTRUCTURE_SurfaceGenerator` A flag to mark if the face is separable. +mimGravityCoefficient real64_array :ref:`DATASTRUCTURE_CompositionalMultiphaseHybridFVM` Mimetic gravity coefficient +parentIndex localIndex_array :ref:`DATASTRUCTURE_SurfaceGenerator` Index of parent within the mesh object it is registered on. +primaryCandidateFace localIndex_array :ref:`DATASTRUCTURE_SurfaceGenerator` ?? +ruptureState integer_array :ref:`DATASTRUCTURE_SurfaceGenerator` | Rupture state of the face: + | 0=not ready for rupture + | 1=ready for rupture + | 2=ruptured. +ruptureTime real64_array :ref:`DATASTRUCTURE_SurfaceGenerator` Time that the object was ruptured/split. +neighborData node :ref:`DATASTRUCTURE_neighborData` +sets node :ref:`DATASTRUCTURE_sets` +======================== ==================================================================================== =========================================================================================================================================================================================================================================================================== ===================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/FieldSpecification.rst b/src/coreComponents/schema/docs/FieldSpecification.rst index 5c2c21b3724..46a4c0ab2b2 100644 --- a/src/coreComponents/schema/docs/FieldSpecification.rst +++ b/src/coreComponents/schema/docs/FieldSpecification.rst @@ -11,6 +11,7 @@ endTime real64 1e+99 Time at which the boundary conditio fieldName string Name of field that boundary condition is applied to. functionName string Name of function that specifies variation of the boundary condition. initialCondition integer 0 Boundary condition is applied as an initial condition. +logLevel integer 0 Log level name string required A name is required for any non-unique nodes objectPath string Path to the target field scale real64 0 Scale factor for value of the boundary condition. diff --git a/src/coreComponents/schema/docs/HydrostaticEquilibrium.rst b/src/coreComponents/schema/docs/HydrostaticEquilibrium.rst index 6f23ba8db54..10dc9970a44 100644 --- a/src/coreComponents/schema/docs/HydrostaticEquilibrium.rst +++ b/src/coreComponents/schema/docs/HydrostaticEquilibrium.rst @@ -15,6 +15,7 @@ endTime real64 1e+99 Time at which equilibrationTolerance real64 0.001 Tolerance in the fixed-point iteration scheme used for hydrostatic initialization functionName string Name of function that specifies variation of the boundary condition. initialPhaseName string Name of the phase initially saturating the reservoir +logLevel integer 0 Log level maxNumberOfEquilibrationIterations integer 5 Maximum number of equilibration iterations name string required A name is required for any non-unique nodes objectPath string Path to the target field diff --git a/src/coreComponents/schema/docs/PVTDriver.rst b/src/coreComponents/schema/docs/PVTDriver.rst new file mode 100644 index 00000000000..1b4ec2948bf --- /dev/null +++ b/src/coreComponents/schema/docs/PVTDriver.rst @@ -0,0 +1,17 @@ + + +================== ============ ======== ============================================= +Name Type Default Description +================== ============ ======== ============================================= +baseline path none Baseline file +feedComposition real64_array required Feed composition array [mol fraction] +fluid string required Fluid to test +logLevel integer 0 Log level +name string required A name is required for any non-unique nodes +output string none Output file +pressureControl string required Function controlling pressure time history +steps integer required Number of load steps to take +temperatureControl string required Function controlling temperature time history +================== ============ ======== ============================================= + + diff --git a/src/coreComponents/schema/docs/PVTDriver_other.rst b/src/coreComponents/schema/docs/PVTDriver_other.rst new file mode 100644 index 00000000000..adf1c1b8aec --- /dev/null +++ b/src/coreComponents/schema/docs/PVTDriver_other.rst @@ -0,0 +1,9 @@ + + +==== ==== ============================ +Name Type Description +==== ==== ============================ + (no documentation available) +==== ==== ============================ + + diff --git a/src/coreComponents/schema/docs/ProppantTransport_other.rst b/src/coreComponents/schema/docs/ProppantTransport_other.rst index 115d235bf40..55250e35950 100644 --- a/src/coreComponents/schema/docs/ProppantTransport_other.rst +++ b/src/coreComponents/schema/docs/ProppantTransport_other.rst @@ -1,11 +1,12 @@ -========================= ====== ===================================================== -Name Type Description -========================= ====== ===================================================== -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= ====== ===================================================== +========================= ============ ================================ =========================================================================== +Name Type Registered On Description +========================= ============ ================================ =========================================================================== +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +gravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Gravity coefficient (dot product of gravity acceleration by gravity vector) +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= ============ ================================ =========================================================================== diff --git a/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst b/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst index 8a4c243b5b0..fd6a957d827 100644 --- a/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst @@ -1,12 +1,13 @@ -========================= ============ ================================ ===================================================== -Name Type Registered On Description -========================= ============ ================================ ===================================================== -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` An array that holds the pressures at the faces. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= ============ ================================ ===================================================== +========================= ============ ================================ =========================================================================== +Name Type Registered On Description +========================= ============ ================================ =========================================================================== +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Face pressure +gravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Gravity coefficient (dot product of gravity acceleration by gravity vector) +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= ============ ================================ =========================================================================== diff --git a/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst b/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst index 8a4c243b5b0..0bb15c81009 100644 --- a/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst @@ -1,12 +1,14 @@ -========================= ============ ================================ ===================================================== -Name Type Registered On Description -========================= ============ ================================ ===================================================== -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` An array that holds the pressures at the faces. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= ============ ================================ ===================================================== +========================= ============ ================================ =========================================================================== +Name Type Registered On Description +========================= ============ ================================ =========================================================================== +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +deltaFacePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Accumulated face pressure updates +facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Face pressure +gravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Gravity coefficient (dot product of gravity acceleration by gravity vector) +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= ============ ================================ =========================================================================== diff --git a/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst b/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst index 8a4c243b5b0..fd6a957d827 100644 --- a/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst @@ -1,12 +1,13 @@ -========================= ============ ================================ ===================================================== -Name Type Registered On Description -========================= ============ ================================ ===================================================== -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` An array that holds the pressures at the faces. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= ============ ================================ ===================================================== +========================= ============ ================================ =========================================================================== +Name Type Registered On Description +========================= ============ ================================ =========================================================================== +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +facePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Face pressure +gravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Gravity coefficient (dot product of gravity acceleration by gravity vector) +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= ============ ================================ =========================================================================== diff --git a/src/coreComponents/schema/docs/SourceFlux.rst b/src/coreComponents/schema/docs/SourceFlux.rst index 5c2c21b3724..46a4c0ab2b2 100644 --- a/src/coreComponents/schema/docs/SourceFlux.rst +++ b/src/coreComponents/schema/docs/SourceFlux.rst @@ -11,6 +11,7 @@ endTime real64 1e+99 Time at which the boundary conditio fieldName string Name of field that boundary condition is applied to. functionName string Name of function that specifies variation of the boundary condition. initialCondition integer 0 Boundary condition is applied as an initial condition. +logLevel integer 0 Log level name string required A name is required for any non-unique nodes objectPath string Path to the target field scale real64 0 Scale factor for value of the boundary condition. diff --git a/src/coreComponents/schema/docs/TableCapillaryPressure_other.rst b/src/coreComponents/schema/docs/TableCapillaryPressure_other.rst index f73e79aa2f1..8a3f5a6a27e 100644 --- a/src/coreComponents/schema/docs/TableCapillaryPressure_other.rst +++ b/src/coreComponents/schema/docs/TableCapillaryPressure_other.rst @@ -1,13 +1,13 @@ -=================================== ========================================================================================================= ========================== -Name Type Description -=================================== ========================================================================================================= ========================== -capPresWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -dPhaseCapPressure_dPhaseVolFraction real64_array4d (no description available) -phaseCapPressure real64_array3d (no description available) -phaseOrder integer_array (no description available) -phaseTypes integer_array (no description available) -=================================== ========================================================================================================= ========================== +=================================== ========================================================================================================= ============================================================================ +Name Type Description +=================================== ========================================================================================================= ============================================================================ +capPresWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +dPhaseCapPressure_dPhaseVolFraction real64_array4d Derivative of phase capillary pressure with respect to phase volume fraction +phaseCapPressure real64_array3d Phase capillary pressure +phaseOrder integer_array (no description available) +phaseTypes integer_array (no description available) +=================================== ========================================================================================================= ============================================================================ diff --git a/src/coreComponents/schema/docs/TableRelativePermeability_other.rst b/src/coreComponents/schema/docs/TableRelativePermeability_other.rst index a22eec9b142..c765e67a488 100644 --- a/src/coreComponents/schema/docs/TableRelativePermeability_other.rst +++ b/src/coreComponents/schema/docs/TableRelativePermeability_other.rst @@ -1,14 +1,14 @@ -=============================== ========================================================================================================= ========================== -Name Type Description -=============================== ========================================================================================================= ========================== -dPhaseRelPerm_dPhaseVolFraction real64_array4d (no description available) -phaseMinVolumeFraction real64_array (no description available) -phaseOrder integer_array (no description available) -phaseRelPerm real64_array3d (no description available) -phaseTypes integer_array (no description available) -relPermWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) -=============================== ========================================================================================================= ========================== +=============================== ========================================================================================================= =============================================================================== +Name Type Description +=============================== ========================================================================================================= =============================================================================== +dPhaseRelPerm_dPhaseVolFraction real64_array4d Derivative of phase relative permeability with respect to phase volume fraction +phaseMinVolumeFraction real64_array (no description available) +phaseOrder integer_array (no description available) +phaseRelPerm real64_array3d Phase relative permeability +phaseTypes integer_array (no description available) +relPermWrappers LvArray_Array< geosx_TableFunction_KernelWrapper, 1, camp_int_seq< long, 0l >, long, LvArray_ChaiBuffer > (no description available) +=============================== ========================================================================================================= =============================================================================== diff --git a/src/coreComponents/schema/docs/Tasks.rst b/src/coreComponents/schema/docs/Tasks.rst index 316f0782397..a6d1211627a 100644 --- a/src/coreComponents/schema/docs/Tasks.rst +++ b/src/coreComponents/schema/docs/Tasks.rst @@ -3,6 +3,7 @@ ============== ==== ======= ========================= Name Type Default Description ============== ==== ======= ========================= +PVTDriver node :ref:`XML_PVTDriver` PackCollection node :ref:`XML_PackCollection` TriaxialDriver node :ref:`XML_TriaxialDriver` ============== ==== ======= ========================= diff --git a/src/coreComponents/schema/docs/Tasks_other.rst b/src/coreComponents/schema/docs/Tasks_other.rst index fdc8ac91c65..ea8a93bcd94 100644 --- a/src/coreComponents/schema/docs/Tasks_other.rst +++ b/src/coreComponents/schema/docs/Tasks_other.rst @@ -3,6 +3,7 @@ ============== ==== =================================== Name Type Description ============== ==== =================================== +PVTDriver node :ref:`DATASTRUCTURE_PVTDriver` PackCollection node :ref:`DATASTRUCTURE_PackCollection` TriaxialDriver node :ref:`DATASTRUCTURE_TriaxialDriver` ============== ==== =================================== diff --git a/src/coreComponents/schema/docs/Traction.rst b/src/coreComponents/schema/docs/Traction.rst index 9f52cbc8829..e411956accd 100644 --- a/src/coreComponents/schema/docs/Traction.rst +++ b/src/coreComponents/schema/docs/Traction.rst @@ -10,6 +10,7 @@ endTime real64 1e+99 functionName string Name of function that specifies variation of the boundary condition. initialCondition integer 0 Boundary condition is applied as an initial condition. inputStress R2SymTensor {0,0,0,0,0,0} Input stress for tractionType = stress +logLevel integer 0 Log level name string required A name is required for any non-unique nodes objectPath string Path to the target field scale real64 0 Scale factor for value of the boundary condition. diff --git a/src/coreComponents/schema/docs/VanGenuchtenBakerRelativePermeability_other.rst b/src/coreComponents/schema/docs/VanGenuchtenBakerRelativePermeability_other.rst index a0820b67d26..d9b56a614ac 100644 --- a/src/coreComponents/schema/docs/VanGenuchtenBakerRelativePermeability_other.rst +++ b/src/coreComponents/schema/docs/VanGenuchtenBakerRelativePermeability_other.rst @@ -3,9 +3,9 @@ =============================== ============== ======================================================================================================================= Name Type Description =============================== ============== ======================================================================================================================= -dPhaseRelPerm_dPhaseVolFraction real64_array4d (no description available) +dPhaseRelPerm_dPhaseVolFraction real64_array4d Derivative of phase relative permeability with respect to phase volume fraction phaseOrder integer_array (no description available) -phaseRelPerm real64_array3d (no description available) +phaseRelPerm real64_array3d Phase relative permeability phaseTypes integer_array (no description available) volFracScale real64 Factor used to scale the phase capillary pressure, defined as: one minus the sum of the phase minimum volume fractions. =============================== ============== ======================================================================================================================= diff --git a/src/coreComponents/schema/docs/VanGenuchtenCapillaryPressure_other.rst b/src/coreComponents/schema/docs/VanGenuchtenCapillaryPressure_other.rst index 3ade6bc985d..336528e2f6f 100644 --- a/src/coreComponents/schema/docs/VanGenuchtenCapillaryPressure_other.rst +++ b/src/coreComponents/schema/docs/VanGenuchtenCapillaryPressure_other.rst @@ -3,8 +3,8 @@ =================================== ============== ======================================================================================================================= Name Type Description =================================== ============== ======================================================================================================================= -dPhaseCapPressure_dPhaseVolFraction real64_array4d (no description available) -phaseCapPressure real64_array3d (no description available) +dPhaseCapPressure_dPhaseVolFraction real64_array4d Derivative of phase capillary pressure with respect to phase volume fraction +phaseCapPressure real64_array3d Phase capillary pressure phaseOrder integer_array (no description available) phaseTypes integer_array (no description available) volFracScale real64 Factor used to scale the phase capillary pressure, defined as: one minus the sum of the phase minimum volume fractions. diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index e846438c5de..d2eac71b4fc 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -333,6 +333,8 @@ This keyword is ignored for single-phase flow simulations--> + + @@ -360,6 +362,8 @@ This keyword is ignored for single-phase flow simulations--> + + @@ -386,6 +390,8 @@ This keyword is ignored for single-phase flow simulations--> + + @@ -420,6 +426,8 @@ This keyword is ignored for single-phase flow simulations--> + + @@ -448,6 +456,8 @@ This keyword is ignored for single-phase flow simulations--> + + @@ -472,6 +482,8 @@ This keyword is ignored for single-phase flow simulations--> + + @@ -1854,10 +1866,31 @@ Equal to 1 for surface conditions, and to 0 for reservoir conditions--> + + + + + + + + + + + + + + + + + + + + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 308756a1aa2..853167aec54 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -724,10 +724,12 @@ + + @@ -835,79 +837,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -915,11 +917,11 @@ - + - + @@ -927,9 +929,9 @@ - + - + @@ -939,11 +941,11 @@ - + - + @@ -951,141 +953,141 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1099,71 +1101,71 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1242,79 +1244,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1608,9 +1610,9 @@ - + - + @@ -1618,13 +1620,13 @@ - + - + @@ -1632,11 +1634,11 @@ - + - + @@ -1644,9 +1646,9 @@ - + - + @@ -1809,7 +1811,7 @@ - + @@ -1827,7 +1829,7 @@ - + @@ -1835,7 +1837,7 @@ - + @@ -1843,7 +1845,7 @@ - + diff --git a/src/coreComponents/unitTests/constitutiveTests/CMakeLists.txt b/src/coreComponents/unitTests/constitutiveTests/CMakeLists.txt index ef8962aea7b..3766989cfd4 100644 --- a/src/coreComponents/unitTests/constitutiveTests/CMakeLists.txt +++ b/src/coreComponents/unitTests/constitutiveTests/CMakeLists.txt @@ -21,6 +21,10 @@ set( gtest_triaxial_xmls testTriaxial_delftEggCase2.xml ) +set( gtest_pvt_xmls + testPVT.xml + ) + set( dependencyList gtest ) if ( GEOSX_BUILD_SHARED_LIBS ) @@ -59,7 +63,6 @@ foreach(test ${gtest_geosx_tests}) endforeach() - # # Add triaxial xml based tests # @@ -76,3 +79,20 @@ foreach(test ${gtest_triaxial_xmls}) COMMAND testTriaxial -i ${CMAKE_CURRENT_LIST_DIR}/${test} ) endforeach() + +# +# Add pvtdriver xml based tests +# + +blt_add_executable( NAME testPVT + SOURCES testPVT.cpp + OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY} + DEPENDS_ON ${dependencyList} "-lz" + ) + +foreach(test ${gtest_pvt_xmls}) + get_filename_component( test_name ${test} NAME_WE ) + blt_add_test( NAME ${test_name} + COMMAND testPVT -i ${CMAKE_CURRENT_LIST_DIR}/${test} + ) +endforeach() diff --git a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp index ab97a7a6a61..ae47a380efa 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testCO2BrinePVTModels.cpp @@ -23,6 +23,10 @@ #include "constitutive/fluid/PVTFunctions/PhillipsBrineDensity.hpp" #include "constitutive/fluid/PVTFunctions/SpanWagnerCO2Density.hpp" #include "constitutive/fluid/PVTFunctions/CO2Solubility.hpp" +#include "constitutive/fluid/PVTFunctions/BrineEnthalpy.hpp" +#include "constitutive/fluid/PVTFunctions/CO2Enthalpy.hpp" +#include "constitutive/fluid/PVTFunctions/BrineInternalEnergy.hpp" +#include "constitutive/fluid/PVTFunctions/CO2InternalEnergy.hpp" #include "mainInterface/GeosxState.hpp" #include "mainInterface/initialization.hpp" @@ -41,6 +45,12 @@ using namespace geosx::constitutive::PVTProps; static const char * pvtLiquidPhillipsTableContent = "DensityFun PhillipsBrineDensity 1e6 1.5e7 5e4 367.15 369.15 1 0.2\n" "ViscosityFun PhillipsBrineViscosity 0.1"; +// Used also for gas phase +static const char * pvtLiquidEnthalpyTableContent = "EnthalpyFun BrineEnthalpy 1e6 1.5e7 5e4 367.15 369.15 1 0.2"; + +// InternalEnergy model has no parameters +static const char * pvtLiquidInternalEnergyTableContent = "InternalEnergyFun BrineInternalEnergy"; + // the last are set relatively high (1e-4) to increase derivative value and check it properly static const char * pvtLiquidEzrokhiTableContent = "DensityFun EzrokhiBrineDensity 2.01e-6 -6.34e-7 1e-4\n" "ViscosityFun EzrokhiBrineViscosity 2.42e-7 0 1e-4"; @@ -423,7 +433,6 @@ std::unique_ptr< MODEL > makeFlashModel( string const & filename, return flashModel; } - class PhillipsBrineViscosityTest : public ::testing::Test { public: @@ -925,6 +934,408 @@ TEST_F( CO2SolubilityTest, co2SolubilityValuesAndDeriv ) } } +class BrineEnthalpyTest : public ::testing::Test +{ +public: + BrineEnthalpyTest() + { + writeTableToFile( filename, pvtLiquidEnthalpyTableContent ); + pvtFunction = makePVTFunction< BrineEnthalpy >( filename, key ); + } + + ~BrineEnthalpyTest() override + { + removeFile( filename ); + } + +protected: + string const key = "EnthalpyFun"; + string const filename = "pvtliquid.txt"; + std::unique_ptr< BrineEnthalpy > pvtFunction; +}; + +TEST_F( BrineEnthalpyTest, BrineEnthalpyMassValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + BrineEnthalpy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 279338.177769, 281327.917595, 282984.982790, 273523.601187, 275547.730627, + 277232.967486, 259305.594861, 261448.359022, 263229.980673, 207243.035969, + 208857.558651, 210202.000531, 197603.080058, 199274.617099, 200665.764632, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + { + testValuesAgainstPreviousImplementation( pvtFunctionWrapper, + P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); + testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, true, eps, relTol ); + counter++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + +TEST_F( BrineEnthalpyTest, BrineEnthalpyMolarValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + BrineEnthalpy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 15234891.499346, 15338606.577025, 15424985.891636, 15102742.031582, 15207238.691387, 15294258.271084, + 14779605.524173, 14886798.427634, 14976008.570783, 11042832.057960, 11121210.933610, 11186485.534383, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex 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++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + + +class CO2EnthalpyTest : public ::testing::Test +{ +public: + CO2EnthalpyTest() + { + // gas enthalpy model repeats liquid parameters (except m), use them here + writeTableToFile( filename, pvtLiquidEnthalpyTableContent ); + pvtFunction = makePVTFunction< CO2Enthalpy >( filename, key ); + + } + + ~CO2EnthalpyTest() override + { + removeFile( filename ); + } + +protected: + string const key = "EnthalpyFun"; + string const filename = "pvtgas.txt"; + std::unique_ptr< CO2Enthalpy > pvtFunction; +}; + +TEST_F( CO2EnthalpyTest, CO2EnthalpyMassValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + CO2Enthalpy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 28447.084306, 29131.068469, 29700.204529, 9320.187656, 10117.295548, 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, 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + { + testValuesAgainstPreviousImplementation( pvtFunctionWrapper, + P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); + testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, true, eps, relTol ); + counter++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + +TEST_F( CO2EnthalpyTest, CO2EnthalpyMolarValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + CO2Enthalpy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 646524.643323, 662069.737939, 675004.648394, 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, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex 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++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + +class BrineInternalEnergyTest : public ::testing::Test +{ +public: + BrineInternalEnergyTest() + { + writeTableToFile( filename, pvtLiquidInternalEnergyTableContent ); + pvtFunction = makePVTFunction< BrineInternalEnergy >( filename, key ); + + } + + ~BrineInternalEnergyTest() override + { + removeFile( filename ); + } + +protected: + string const key = "InternalEnergyFun"; + string const filename = "pvtliquid.txt"; + std::unique_ptr< BrineInternalEnergy > pvtFunction; +}; + +TEST_F( BrineInternalEnergyTest, BrineInternalEnergyMassValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + BrineInternalEnergy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 5106.500000, 5107.100000, 5107.600000, 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, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + { + testValuesAgainstPreviousImplementation( pvtFunctionWrapper, + P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); + testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, true, eps, relTol ); + counter++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + +TEST_F( BrineInternalEnergyTest, BrineInternalEnergyMolarValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + BrineInternalEnergy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 5106.500000, 5107.100000, 5107.600000, 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, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex 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++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + +class CO2InternalEnergyTest : public ::testing::Test +{ +public: + CO2InternalEnergyTest() + { + writeTableToFile( filename, pvtLiquidInternalEnergyTableContent ); + pvtFunction = makePVTFunction< CO2InternalEnergy >( filename, key ); + + } + + ~CO2InternalEnergyTest() override + { + removeFile( filename ); + } + +protected: + string const key = "InternalEnergyFun"; + string const filename = "pvtgas.txt"; + std::unique_ptr< CO2InternalEnergy > pvtFunction; +}; + +TEST_F( CO2InternalEnergyTest, CO2InternalEnergyMassValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + CO2InternalEnergy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 5106.500000, 5107.100000, 5107.600000, 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, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex iTemp = 0; iTemp < 3; ++iTemp ) + { + testValuesAgainstPreviousImplementation( pvtFunctionWrapper, + P[iPres], TC[iTemp], comp, savedValues[counter], true, relTol ); + testNumericalDerivatives( pvtFunctionWrapper, P[iPres], TC[iTemp], comp, true, eps, relTol ); + counter++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + +TEST_F( CO2InternalEnergyTest, CO2InternalEnergyMolarValuesAndDeriv ) +{ + // when checking numerical derivatives, do not fall on the coordinate points of the tables!! + // (see the txt file defined at the top of the file for the definition of the coordinates) + real64 const P[3] = { 5.012e6, 7.546e6, 1.289e7 }; + real64 const TC[3] = { 94.5, 95.1, 95.6 }; + array1d< real64 > comp( 2 ); + comp[0] = 0.304; comp[1] = 0.696; + real64 const deltaComp = 0.2; + + real64 const eps = sqrt( std::numeric_limits< real64 >::epsilon()); + real64 const relTol = 5e-5; + + + + CO2InternalEnergy::KernelWrapper pvtFunctionWrapper = pvtFunction->createKernelWrapper(); + real64 const savedValues[] = { 5106.500000, 5107.100000, 5107.600000, 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, + 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 ) + { + for( localIndex iPres = 0; iPres < 3; ++iPres ) + { + for( localIndex 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++; + } + } + comp[0] += deltaComp; + comp[1] = 1 - comp[0]; + } +} + + int main( int argc, char * * argv ) { ::testing::InitGoogleTest( &argc, argv ); diff --git a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp index 6cf38d60af6..4767d8e98d7 100644 --- a/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp +++ b/src/coreComponents/unitTests/constitutiveTests/testMultiFluid.cpp @@ -15,6 +15,7 @@ // Source includes #include "common/DataTypes.hpp" #include "common/TimingMacros.hpp" +#include "constitutive/fluid/MultiFluidExtrinsicData.hpp" #include "constitutive/fluid/multiFluidSelector.hpp" #include "constitutive/fluid/MultiFluidUtils.hpp" #include "unitTests/fluidFlowTests/testCompFlowUtils.hpp" @@ -127,49 +128,49 @@ void testNumericalDerivatives( MultiFluidBase & fluid, fluidCopy.allocateConstitutiveData( fluid.getParent(), 1 ); // extract data views from both fluids - #define GET_FLUID_DATA( FLUID, DIM, PERM, KEY ) \ - FLUID.getReference< Array< real64, DIM, PERM > >( MultiFluidBase::viewKeyStruct::KEY() )[0][0] + #define GET_FLUID_DATA( FLUID, TRAIT ) \ + FLUID.getReference< TRAIT::type >( TRAIT::key() )[0][0] MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > phaseFrac { - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, phaseFractionString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, dPhaseFraction_dPressureString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, dPhaseFraction_dTemperatureString ), - GET_FLUID_DATA( fluid, 4, LAYOUT_PHASE_DC, dPhaseFraction_dGlobalCompFractionString ) + 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 ) }; MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > phaseDens { - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, phaseDensityString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, dPhaseDensity_dPressureString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, dPhaseDensity_dTemperatureString ), - GET_FLUID_DATA( fluid, 4, LAYOUT_PHASE_DC, dPhaseDensity_dGlobalCompFractionString ) + 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 ) }; MultiFluidVarSlice< real64, 1, USD_PHASE - 2, USD_PHASE_DC - 2 > phaseVisc { - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, phaseViscosityString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, dPhaseViscosity_dPressureString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_PHASE, dPhaseViscosity_dTemperatureString ), - GET_FLUID_DATA( fluid, 4, LAYOUT_PHASE_DC, dPhaseViscosity_dGlobalCompFractionString ) + 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 ) }; MultiFluidVarSlice< real64, 2, USD_PHASE_COMP - 2, USD_PHASE_COMP_DC - 2 > phaseCompFrac { - GET_FLUID_DATA( fluid, 4, LAYOUT_PHASE_COMP, phaseCompFractionString ), - GET_FLUID_DATA( fluid, 4, LAYOUT_PHASE_COMP, dPhaseCompFraction_dPressureString ), - GET_FLUID_DATA( fluid, 4, LAYOUT_PHASE_COMP, dPhaseCompFraction_dTemperatureString ), - GET_FLUID_DATA( fluid, 5, LAYOUT_PHASE_COMP_DC, dPhaseCompFraction_dGlobalCompFractionString ) + 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 ) }; MultiFluidVarSlice< real64, 0, USD_FLUID - 2, USD_FLUID_DC - 2 > totalDens { - GET_FLUID_DATA( fluid, 2, LAYOUT_FLUID, totalDensityString ), - GET_FLUID_DATA( fluid, 2, LAYOUT_FLUID, dTotalDensity_dPressureString ), - GET_FLUID_DATA( fluid, 2, LAYOUT_FLUID, dTotalDensity_dTemperatureString ), - GET_FLUID_DATA( fluid, 3, LAYOUT_FLUID_DC, dTotalDensity_dGlobalCompFractionString ) + 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 ) }; - auto const & phaseFracCopy = GET_FLUID_DATA( fluidCopy, 3, LAYOUT_PHASE, phaseFractionString ); - auto const & phaseDensCopy = GET_FLUID_DATA( fluidCopy, 3, LAYOUT_PHASE, phaseDensityString ); - auto const & phaseViscCopy = GET_FLUID_DATA( fluidCopy, 3, LAYOUT_PHASE, phaseViscosityString ); - auto const & phaseCompFracCopy = GET_FLUID_DATA( fluidCopy, 4, LAYOUT_PHASE_COMP, phaseCompFractionString ); - auto const & totalDensCopy = GET_FLUID_DATA( fluidCopy, 2, LAYOUT_FLUID, totalDensityString ); + auto const & phaseFracCopy = GET_FLUID_DATA( fluidCopy, extrinsicMeshData::multifluid::phaseFraction ); + auto const & phaseDensCopy = GET_FLUID_DATA( fluidCopy, extrinsicMeshData::multifluid::phaseDensity ); + auto const & phaseViscCopy = GET_FLUID_DATA( fluidCopy, extrinsicMeshData::multifluid::phaseViscosity ); + auto const & phaseCompFracCopy = GET_FLUID_DATA( fluidCopy, extrinsicMeshData::multifluid::phaseCompFraction ); + auto const & totalDensCopy = GET_FLUID_DATA( fluidCopy, extrinsicMeshData::multifluid::totalDensity ); #undef GET_FLUID_DATA diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT.cpp b/src/coreComponents/unitTests/constitutiveTests/testPVT.cpp new file mode 100644 index 00000000000..6aa56c309d8 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT.cpp @@ -0,0 +1,47 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +// Source includes +#include "mainInterface/ProblemManager.hpp" +#include "mainInterface/initialization.hpp" +#include "mainInterface/GeosxState.hpp" + +// TPL includes +#include +#include + +// this unit test basically launches a full geosx instance, and then uses the +// input xml to launch a PVTDriver task + +TEST( testPVT, testPVT ) +{ + geosx::GeosxState & state = geosx::getGlobalState(); + + state.initializeDataRepository(); + state.applyInitialConditions(); + state.run(); +} + +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + + geosx::GeosxState state( geosx::basicSetup( argc, argv, true ) ); + + int const result = RUN_ALL_TESTS(); + + geosx::basicCleanup(); + + return result; +} diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT.xml b/src/coreComponents/unitTests/constitutiveTests/testPVT.xml new file mode 100644 index 00000000000..ff3182aec4c --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_CO2.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_CO2.txt new file mode 100644 index 00000000000..86b4d12b8dc --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_CO2.txt @@ -0,0 +1,57 @@ +# column 1 = time +# column 2 = pressure +# column 3 = temperature +# column 4 = density +# columns 5-6 = phase fractions +# columns 7-8 = phase densities +# columns 9-10 = phase viscosities +0.0000e+00 1.0000e+06 3.5000e+02 1.5581e+01 1.0000e+00 4.1138e-11 1.5581e+01 1.0033e+03 1.7476e-05 9.9525e-04 +2.0408e-02 2.0000e+06 3.5000e+02 3.2165e+01 1.0000e+00 4.1359e-11 3.2165e+01 1.0050e+03 1.7601e-05 9.9525e-04 +4.0816e-02 3.0000e+06 3.5000e+02 4.9901e+01 1.0000e+00 4.1563e-11 4.9901e+01 1.0066e+03 1.7778e-05 9.9525e-04 +6.1224e-02 4.0000e+06 3.5000e+02 6.8976e+01 1.0000e+00 4.1749e-11 6.8976e+01 1.0081e+03 1.8019e-05 9.9525e-04 +8.1633e-02 5.0000e+06 3.5000e+02 8.9619e+01 1.0000e+00 4.1919e-11 8.9619e+01 1.0096e+03 1.8338e-05 9.9525e-04 +1.0204e-01 6.0000e+06 3.5000e+02 1.1212e+02 1.0000e+00 4.2074e-11 1.1212e+02 1.0109e+03 1.8757e-05 9.9525e-04 +1.2245e-01 7.0000e+06 3.5000e+02 1.3682e+02 1.0000e+00 4.2213e-11 1.3682e+02 1.0122e+03 1.9300e-05 9.9525e-04 +1.4286e-01 8.0000e+06 3.5000e+02 1.6416e+02 1.0000e+00 4.2339e-11 1.6416e+02 1.0134e+03 2.0004e-05 9.9525e-04 +1.6327e-01 9.0000e+06 3.5000e+02 1.9463e+02 1.0000e+00 4.2450e-11 1.9463e+02 1.0145e+03 2.0915e-05 9.9525e-04 +1.8367e-01 1.0000e+07 3.5000e+02 2.2880e+02 1.0000e+00 4.2549e-11 2.2880e+02 1.0156e+03 2.2097e-05 9.9525e-04 +2.0408e-01 1.1000e+07 3.5000e+02 2.6713e+02 1.0000e+00 4.2635e-11 2.6713e+02 1.0166e+03 2.3623e-05 9.9525e-04 +2.2449e-01 1.2000e+07 3.5000e+02 3.0970e+02 1.0000e+00 4.2710e-11 3.0970e+02 1.0175e+03 2.5569e-05 9.9525e-04 +2.4490e-01 1.3000e+07 3.5000e+02 3.5571e+02 1.0000e+00 4.2774e-11 3.5571e+02 1.0184e+03 2.7974e-05 9.9525e-04 +2.6531e-01 1.4000e+07 3.5000e+02 4.0315e+02 1.0000e+00 4.2830e-11 4.0315e+02 1.0193e+03 3.0787e-05 9.9525e-04 +2.8571e-01 1.5000e+07 3.5000e+02 4.4920e+02 1.0000e+00 4.2878e-11 4.4920e+02 1.0201e+03 3.3852e-05 9.9525e-04 +3.0612e-01 1.6000e+07 3.5000e+02 4.9148e+02 1.0000e+00 4.2921e-11 4.9148e+02 1.0209e+03 3.6971e-05 9.9525e-04 +3.2653e-01 1.7000e+07 3.5000e+02 5.2886e+02 1.0000e+00 4.2959e-11 5.2886e+02 1.0216e+03 3.9987e-05 9.9525e-04 +3.4694e-01 1.8000e+07 3.5000e+02 5.6137e+02 1.0000e+00 4.2994e-11 5.6137e+02 1.0224e+03 4.2821e-05 9.9525e-04 +3.6735e-01 1.9000e+07 3.5000e+02 5.8957e+02 1.0000e+00 4.3027e-11 5.8957e+02 1.0231e+03 4.5454e-05 9.9525e-04 +3.8776e-01 2.0000e+07 3.5000e+02 6.1418e+02 1.0000e+00 4.3057e-11 6.1418e+02 1.0238e+03 4.7891e-05 9.9525e-04 +4.0816e-01 2.1000e+07 3.5000e+02 6.3583e+02 1.0000e+00 4.3086e-11 6.3583e+02 1.0245e+03 5.0154e-05 9.9525e-04 +4.2857e-01 2.2000e+07 3.5000e+02 6.5507e+02 1.0000e+00 4.3114e-11 6.5507e+02 1.0252e+03 5.2266e-05 9.9525e-04 +4.4898e-01 2.3000e+07 3.5000e+02 6.7233e+02 1.0000e+00 4.3140e-11 6.7233e+02 1.0259e+03 5.4246e-05 9.9525e-04 +4.6939e-01 2.4000e+07 3.5000e+02 6.8796e+02 1.0000e+00 4.3166e-11 6.8796e+02 1.0266e+03 5.6114e-05 9.9525e-04 +4.8980e-01 2.5000e+07 3.5000e+02 7.0222e+02 1.0000e+00 4.3191e-11 7.0222e+02 1.0273e+03 5.7883e-05 9.9525e-04 +5.1020e-01 2.6000e+07 3.5000e+02 7.1531e+02 1.0000e+00 4.3215e-11 7.1531e+02 1.0280e+03 5.9568e-05 9.9525e-04 +5.3061e-01 2.7000e+07 3.5000e+02 7.2741e+02 1.0000e+00 4.3239e-11 7.2741e+02 1.0287e+03 6.1177e-05 9.9525e-04 +5.5102e-01 2.8000e+07 3.5000e+02 7.3865e+02 1.0000e+00 4.3262e-11 7.3865e+02 1.0294e+03 6.2721e-05 9.9525e-04 +5.7143e-01 2.9000e+07 3.5000e+02 7.4914e+02 1.0000e+00 4.3284e-11 7.4914e+02 1.0300e+03 6.4206e-05 9.9525e-04 +5.9184e-01 3.0000e+07 3.5000e+02 7.5898e+02 1.0000e+00 4.3306e-11 7.5898e+02 1.0307e+03 6.5640e-05 9.9525e-04 +6.1224e-01 3.1000e+07 3.5000e+02 7.6825e+02 1.0000e+00 4.3328e-11 7.6825e+02 1.0314e+03 6.7027e-05 9.9525e-04 +6.3265e-01 3.2000e+07 3.5000e+02 7.7700e+02 1.0000e+00 4.3349e-11 7.7700e+02 1.0320e+03 6.8372e-05 9.9525e-04 +6.5306e-01 3.3000e+07 3.5000e+02 7.8529e+02 1.0000e+00 4.3370e-11 7.8529e+02 1.0327e+03 6.9679e-05 9.9525e-04 +6.7347e-01 3.4000e+07 3.5000e+02 7.9317e+02 1.0000e+00 4.3391e-11 7.9317e+02 1.0333e+03 7.0953e-05 9.9525e-04 +6.9388e-01 3.5000e+07 3.5000e+02 8.0068e+02 1.0000e+00 4.3411e-11 8.0068e+02 1.0340e+03 7.2195e-05 9.9525e-04 +7.1429e-01 3.6000e+07 3.5000e+02 8.0785e+02 1.0000e+00 4.3431e-11 8.0785e+02 1.0346e+03 7.3409e-05 9.9525e-04 +7.3469e-01 3.7000e+07 3.5000e+02 8.1472e+02 1.0000e+00 4.3450e-11 8.1472e+02 1.0353e+03 7.4597e-05 9.9525e-04 +7.5510e-01 3.8000e+07 3.5000e+02 8.2130e+02 1.0000e+00 4.3470e-11 8.2130e+02 1.0359e+03 7.5761e-05 9.9525e-04 +7.7551e-01 3.9000e+07 3.5000e+02 8.2763e+02 1.0000e+00 4.3489e-11 8.2763e+02 1.0366e+03 7.6904e-05 9.9525e-04 +7.9592e-01 4.0000e+07 3.5000e+02 8.3372e+02 1.0000e+00 4.3508e-11 8.3372e+02 1.0372e+03 7.8025e-05 9.9525e-04 +8.1633e-01 4.1000e+07 3.5000e+02 8.3960e+02 1.0000e+00 4.3527e-11 8.3960e+02 1.0378e+03 7.9128e-05 9.9525e-04 +8.3673e-01 4.2000e+07 3.5000e+02 8.4526e+02 1.0000e+00 4.3545e-11 8.4526e+02 1.0385e+03 8.0214e-05 9.9525e-04 +8.5714e-01 4.3000e+07 3.5000e+02 8.5074e+02 1.0000e+00 4.3564e-11 8.5074e+02 1.0391e+03 8.1283e-05 9.9525e-04 +8.7755e-01 4.4000e+07 3.5000e+02 8.5605e+02 1.0000e+00 4.3582e-11 8.5605e+02 1.0398e+03 8.2337e-05 9.9525e-04 +8.9796e-01 4.5000e+07 3.5000e+02 8.6119e+02 1.0000e+00 4.3600e-11 8.6119e+02 1.0404e+03 8.3376e-05 9.9525e-04 +9.1837e-01 4.6000e+07 3.5000e+02 8.6617e+02 1.0000e+00 4.3618e-11 8.6617e+02 1.0410e+03 8.4403e-05 9.9525e-04 +9.3878e-01 4.7000e+07 3.5000e+02 8.7102e+02 1.0000e+00 4.3636e-11 8.7102e+02 1.0416e+03 8.5416e-05 9.9525e-04 +9.5918e-01 4.8000e+07 3.5000e+02 8.7572e+02 1.0000e+00 4.3653e-11 8.7572e+02 1.0423e+03 8.6418e-05 9.9525e-04 +9.7959e-01 4.9000e+07 3.5000e+02 8.8030e+02 1.0000e+00 4.3670e-11 8.8030e+02 1.0429e+03 8.7409e-05 9.9525e-04 +1.0000e+00 5.0000e+07 3.5000e+02 8.8476e+02 1.0000e+00 4.3688e-11 8.8476e+02 1.0435e+03 8.8389e-05 9.9525e-04 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_brine.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_brine.txt new file mode 100644 index 00000000000..de211f032d4 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_brine.txt @@ -0,0 +1,57 @@ +# column 1 = time +# column 2 = pressure +# column 3 = temperature +# column 4 = density +# columns 5-6 = phase fractions +# columns 7-8 = phase densities +# columns 9-10 = phase viscosities +0.0000e+00 1.0000e+06 3.5000e+02 1.0022e+03 0.0000e+00 1.0000e+00 1.5581e+01 1.0022e+03 1.7476e-05 9.9525e-04 +2.0408e-02 2.0000e+06 3.5000e+02 1.0028e+03 0.0000e+00 1.0000e+00 3.2165e+01 1.0028e+03 1.7601e-05 9.9525e-04 +4.0816e-02 3.0000e+06 3.5000e+02 1.0034e+03 0.0000e+00 1.0000e+00 4.9901e+01 1.0034e+03 1.7778e-05 9.9525e-04 +6.1224e-02 4.0000e+06 3.5000e+02 1.0041e+03 0.0000e+00 1.0000e+00 6.8976e+01 1.0041e+03 1.8019e-05 9.9525e-04 +8.1633e-02 5.0000e+06 3.5000e+02 1.0047e+03 0.0000e+00 1.0000e+00 8.9619e+01 1.0047e+03 1.8338e-05 9.9525e-04 +1.0204e-01 6.0000e+06 3.5000e+02 1.0053e+03 0.0000e+00 1.0000e+00 1.1212e+02 1.0053e+03 1.8757e-05 9.9525e-04 +1.2245e-01 7.0000e+06 3.5000e+02 1.0059e+03 0.0000e+00 1.0000e+00 1.3682e+02 1.0059e+03 1.9300e-05 9.9525e-04 +1.4286e-01 8.0000e+06 3.5000e+02 1.0065e+03 0.0000e+00 1.0000e+00 1.6416e+02 1.0065e+03 2.0004e-05 9.9525e-04 +1.6327e-01 9.0000e+06 3.5000e+02 1.0072e+03 0.0000e+00 1.0000e+00 1.9463e+02 1.0072e+03 2.0915e-05 9.9525e-04 +1.8367e-01 1.0000e+07 3.5000e+02 1.0078e+03 0.0000e+00 1.0000e+00 2.2880e+02 1.0078e+03 2.2097e-05 9.9525e-04 +2.0408e-01 1.1000e+07 3.5000e+02 1.0084e+03 0.0000e+00 1.0000e+00 2.6713e+02 1.0084e+03 2.3623e-05 9.9525e-04 +2.2449e-01 1.2000e+07 3.5000e+02 1.0090e+03 0.0000e+00 1.0000e+00 3.0970e+02 1.0090e+03 2.5569e-05 9.9525e-04 +2.4490e-01 1.3000e+07 3.5000e+02 1.0096e+03 0.0000e+00 1.0000e+00 3.5571e+02 1.0096e+03 2.7974e-05 9.9525e-04 +2.6531e-01 1.4000e+07 3.5000e+02 1.0102e+03 0.0000e+00 1.0000e+00 4.0315e+02 1.0102e+03 3.0787e-05 9.9525e-04 +2.8571e-01 1.5000e+07 3.5000e+02 1.0108e+03 0.0000e+00 1.0000e+00 4.4920e+02 1.0108e+03 3.3852e-05 9.9525e-04 +3.0612e-01 1.6000e+07 3.5000e+02 1.0114e+03 0.0000e+00 1.0000e+00 4.9148e+02 1.0114e+03 3.6971e-05 9.9525e-04 +3.2653e-01 1.7000e+07 3.5000e+02 1.0120e+03 0.0000e+00 1.0000e+00 5.2886e+02 1.0120e+03 3.9987e-05 9.9525e-04 +3.4694e-01 1.8000e+07 3.5000e+02 1.0126e+03 0.0000e+00 1.0000e+00 5.6137e+02 1.0126e+03 4.2821e-05 9.9525e-04 +3.6735e-01 1.9000e+07 3.5000e+02 1.0133e+03 0.0000e+00 1.0000e+00 5.8957e+02 1.0133e+03 4.5454e-05 9.9525e-04 +3.8776e-01 2.0000e+07 3.5000e+02 1.0139e+03 0.0000e+00 1.0000e+00 6.1418e+02 1.0139e+03 4.7891e-05 9.9525e-04 +4.0816e-01 2.1000e+07 3.5000e+02 1.0145e+03 0.0000e+00 1.0000e+00 6.3583e+02 1.0145e+03 5.0154e-05 9.9525e-04 +4.2857e-01 2.2000e+07 3.5000e+02 1.0151e+03 0.0000e+00 1.0000e+00 6.5507e+02 1.0151e+03 5.2266e-05 9.9525e-04 +4.4898e-01 2.3000e+07 3.5000e+02 1.0157e+03 0.0000e+00 1.0000e+00 6.7233e+02 1.0157e+03 5.4246e-05 9.9525e-04 +4.6939e-01 2.4000e+07 3.5000e+02 1.0163e+03 0.0000e+00 1.0000e+00 6.8796e+02 1.0163e+03 5.6114e-05 9.9525e-04 +4.8980e-01 2.5000e+07 3.5000e+02 1.0169e+03 0.0000e+00 1.0000e+00 7.0222e+02 1.0169e+03 5.7883e-05 9.9525e-04 +5.1020e-01 2.6000e+07 3.5000e+02 1.0174e+03 0.0000e+00 1.0000e+00 7.1531e+02 1.0174e+03 5.9568e-05 9.9525e-04 +5.3061e-01 2.7000e+07 3.5000e+02 1.0180e+03 0.0000e+00 1.0000e+00 7.2741e+02 1.0180e+03 6.1177e-05 9.9525e-04 +5.5102e-01 2.8000e+07 3.5000e+02 1.0186e+03 0.0000e+00 1.0000e+00 7.3865e+02 1.0186e+03 6.2721e-05 9.9525e-04 +5.7143e-01 2.9000e+07 3.5000e+02 1.0192e+03 0.0000e+00 1.0000e+00 7.4914e+02 1.0192e+03 6.4206e-05 9.9525e-04 +5.9184e-01 3.0000e+07 3.5000e+02 1.0198e+03 0.0000e+00 1.0000e+00 7.5898e+02 1.0198e+03 6.5640e-05 9.9525e-04 +6.1224e-01 3.1000e+07 3.5000e+02 1.0204e+03 0.0000e+00 1.0000e+00 7.6825e+02 1.0204e+03 6.7027e-05 9.9525e-04 +6.3265e-01 3.2000e+07 3.5000e+02 1.0210e+03 0.0000e+00 1.0000e+00 7.7700e+02 1.0210e+03 6.8372e-05 9.9525e-04 +6.5306e-01 3.3000e+07 3.5000e+02 1.0216e+03 0.0000e+00 1.0000e+00 7.8529e+02 1.0216e+03 6.9679e-05 9.9525e-04 +6.7347e-01 3.4000e+07 3.5000e+02 1.0222e+03 0.0000e+00 1.0000e+00 7.9317e+02 1.0222e+03 7.0953e-05 9.9525e-04 +6.9388e-01 3.5000e+07 3.5000e+02 1.0228e+03 0.0000e+00 1.0000e+00 8.0068e+02 1.0228e+03 7.2195e-05 9.9525e-04 +7.1429e-01 3.6000e+07 3.5000e+02 1.0233e+03 0.0000e+00 1.0000e+00 8.0785e+02 1.0233e+03 7.3409e-05 9.9525e-04 +7.3469e-01 3.7000e+07 3.5000e+02 1.0239e+03 0.0000e+00 1.0000e+00 8.1472e+02 1.0239e+03 7.4597e-05 9.9525e-04 +7.5510e-01 3.8000e+07 3.5000e+02 1.0245e+03 0.0000e+00 1.0000e+00 8.2130e+02 1.0245e+03 7.5761e-05 9.9525e-04 +7.7551e-01 3.9000e+07 3.5000e+02 1.0251e+03 0.0000e+00 1.0000e+00 8.2763e+02 1.0251e+03 7.6904e-05 9.9525e-04 +7.9592e-01 4.0000e+07 3.5000e+02 1.0257e+03 0.0000e+00 1.0000e+00 8.3372e+02 1.0257e+03 7.8025e-05 9.9525e-04 +8.1633e-01 4.1000e+07 3.5000e+02 1.0263e+03 0.0000e+00 1.0000e+00 8.3960e+02 1.0263e+03 7.9128e-05 9.9525e-04 +8.3673e-01 4.2000e+07 3.5000e+02 1.0268e+03 0.0000e+00 1.0000e+00 8.4526e+02 1.0268e+03 8.0214e-05 9.9525e-04 +8.5714e-01 4.3000e+07 3.5000e+02 1.0274e+03 0.0000e+00 1.0000e+00 8.5074e+02 1.0274e+03 8.1283e-05 9.9525e-04 +8.7755e-01 4.4000e+07 3.5000e+02 1.0280e+03 0.0000e+00 1.0000e+00 8.5605e+02 1.0280e+03 8.2337e-05 9.9525e-04 +8.9796e-01 4.5000e+07 3.5000e+02 1.0286e+03 0.0000e+00 1.0000e+00 8.6119e+02 1.0286e+03 8.3376e-05 9.9525e-04 +9.1837e-01 4.6000e+07 3.5000e+02 1.0292e+03 0.0000e+00 1.0000e+00 8.6617e+02 1.0292e+03 8.4403e-05 9.9525e-04 +9.3878e-01 4.7000e+07 3.5000e+02 1.0297e+03 0.0000e+00 1.0000e+00 8.7102e+02 1.0297e+03 8.5416e-05 9.9525e-04 +9.5918e-01 4.8000e+07 3.5000e+02 1.0303e+03 0.0000e+00 1.0000e+00 8.7572e+02 1.0303e+03 8.6418e-05 9.9525e-04 +9.7959e-01 4.9000e+07 3.5000e+02 1.0309e+03 0.0000e+00 1.0000e+00 8.8030e+02 1.0309e+03 8.7409e-05 9.9525e-04 +1.0000e+00 5.0000e+07 3.5000e+02 1.0315e+03 0.0000e+00 1.0000e+00 8.8476e+02 1.0315e+03 8.8389e-05 9.9525e-04 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/brinePVT.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/brinePVT.txt new file mode 100644 index 00000000000..7894909ba43 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/brinePVT.txt @@ -0,0 +1,2 @@ +DensityFun PhillipsBrineDensity 1e6 5e7 1e6 340 360 10 1.0 +ViscosityFun PhillipsBrineViscosity 1.0 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxideFlash.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxideFlash.txt new file mode 100644 index 00000000000..40c0cc8c35a --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxideFlash.txt @@ -0,0 +1 @@ +FlashModel CO2Solubility 1e6 5e7 1e6 340 350 10 0 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxidePVT.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxidePVT.txt new file mode 100644 index 00000000000..f9661292bea --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/carbonDioxidePVT.txt @@ -0,0 +1,2 @@ +DensityFun SpanWagnerCO2Density 1e6 5e7 1e6 340 360 10 +ViscosityFun FenghourCO2Viscosity 1e6 5e7 1e6 340 460 10 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/gasPVT.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/gasPVT.txt new file mode 100644 index 00000000000..811a899bf10 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/gasPVT.txt @@ -0,0 +1,14 @@ +# Pg(Pa) Bg(m3/sm3) Visc(Pa.s) +3000000 0.04234 0.00005344 +6000000 0.02046 0.0000542 +9000000 0.01328 0.00005526 +12000000 0.00977 0.0000566 +15000000 0.00773 0.00005818 +18000000 0.006426 0.00005994 +21000000 0.005541 0.00006181 +24000000 0.004919 0.0000637 +27000000 0.004471 0.00006559 +29500000 0.004194 0.00006714 +31000000 0.004031 0.00006806 +33000000 0.00391 0.00006832 +53000000 0.003868 0.00006935 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/oilPVT.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/oilPVT.txt new file mode 100644 index 00000000000..df0be305c70 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/oilPVT.txt @@ -0,0 +1,8 @@ +# P[Pa] Bo[m3/sm3] Visc(Pa.s) +2000000 1.02 0.000975 +5000000 1.03 0.00091 +10000000 1.04 0.00083 +20000000 1.05 0.000695 +30000000 1.07 0.000594 +40000000 1.08 0.00051 +50000000.7 1.09 0.000449 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_CO2.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_CO2.txt new file mode 100644 index 00000000000..14cc297679d --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_CO2.txt @@ -0,0 +1,54 @@ +# Temperature (K) Pressure (MPa) Density (kg/m3) Volume (m3/kg) Internal Energy (kJ/mol) Enthalpy (kJ/mol) Entropy (J/mol*K) Cv (J/mol*K) Cp (J/mol*K) Sound Spd. (m/s) Joule-Thomson (K/MPa) Viscosity (Pa*s) Therm. Cond. (W/m*K) Phase +# reference = Eric W. Lemmon, Mark O. McLinden and Daniel G. Friend, "Thermophysical Properties of Fluid Systems" in NIST Chemistry WebBook, NIST Standard Reference Database Number 69, Eds. P.J. Linstrom and W.G. Mallard, National Institute of Standards and Technology, Gaithersburg MD, 20899, https://doi.org/10.18434/T4D303, (retrieved December 14, 2021). +350.00 1.0000 15.581 0.064180 21.169 23.993 107.04 31.637 41.229 284.86 7.3204 1.7476e-05 0.021295 vapor +350.00 2.0000 32.165 0.031090 20.948 23.684 100.64 32.226 43.352 280.22 7.2981 1.7601e-05 0.021789 vapor +350.00 3.0000 49.901 0.020040 20.714 23.360 96.593 32.850 45.833 275.58 7.2598 1.7778e-05 0.022390 vapor +350.00 4.0000 68.976 0.014498 20.466 23.018 93.478 33.511 48.764 270.98 7.2015 1.8019e-05 0.023122 vapor +350.00 5.0000 89.619 0.011158 20.201 22.657 90.848 34.213 52.264 266.45 7.1178 1.8338e-05 0.024020 vapor +350.00 6.0000 112.12 0.0089193 19.918 22.273 88.499 34.957 56.495 262.05 7.0022 1.8757e-05 0.025130 vapor +350.00 7.0000 136.82 0.0073090 19.613 21.865 86.316 35.745 61.668 257.89 6.8467 1.9300e-05 0.026511 vapor +350.00 8.0000 164.16 0.0060918 19.283 21.428 84.228 36.575 68.054 254.10 6.6420 2.0004e-05 0.028239 vapor +350.00 8.0000 164.16 0.0060918 19.283 21.428 84.228 36.575 68.054 254.10 6.6420 2.0004e-05 0.028239 supercritical +350.00 8.0000 164.16 0.0060918 19.283 21.428 84.228 36.575 68.054 254.10 6.6420 2.0004e-05 0.028239 supercritical +350.00 9.0000 194.64 0.0051378 18.925 20.960 82.187 37.441 75.974 250.90 6.3777 2.0915e-05 0.030403 supercritical +350.00 10.000 228.80 0.0043705 18.535 20.458 80.159 38.325 85.729 248.62 6.0435 2.2097e-05 0.033090 supercritical +350.00 11.000 267.13 0.0037435 18.112 19.925 78.125 39.192 97.387 247.74 5.6312 2.3623e-05 0.036350 supercritical +350.00 12.000 309.70 0.0032290 17.660 19.365 76.090 39.978 110.30 248.93 5.1406 2.5570e-05 0.040130 supercritical +350.00 13.000 355.71 0.0028113 17.190 18.798 74.091 40.597 122.55 252.99 4.5877 2.7974e-05 0.044224 supercritical +350.00 14.000 403.15 0.0024805 16.723 18.251 72.196 40.978 131.39 260.58 4.0104 3.0787e-05 0.048312 supercritical +350.00 15.000 449.20 0.0022262 16.283 17.753 70.477 41.122 135.06 271.76 3.4558 3.3852e-05 0.052132 supercritical +350.00 16.000 491.48 0.0020347 15.888 17.321 68.976 41.100 133.96 285.80 2.9602 3.6971e-05 0.055591 supercritical +350.00 17.000 528.86 0.0018908 15.544 16.958 67.693 40.988 130.04 301.61 2.5404 3.9987e-05 0.058722 supercritical +350.00 18.000 561.37 0.0017814 15.246 16.657 66.601 40.840 125.06 318.22 2.1944 4.2821e-05 0.061588 supercritical +350.00 19.000 589.57 0.0016961 14.988 16.406 65.666 40.685 120.01 334.99 1.9109 4.5454e-05 0.064232 supercritical +350.00 20.000 614.18 0.0016282 14.762 16.195 64.855 40.540 115.34 351.52 1.6780 4.7891e-05 0.066685 supercritical +350.00 21.000 635.83 0.0015728 14.563 16.016 64.143 40.409 111.18 367.57 1.4851 5.0154e-05 0.068974 supercritical +350.00 22.000 655.07 0.0015266 14.385 15.863 63.510 40.294 107.54 383.04 1.3238 5.2266e-05 0.071120 supercritical +350.00 23.000 672.33 0.0014874 14.225 15.730 62.941 40.197 104.37 397.92 1.1871 5.4246e-05 0.073139 supercritical +350.00 24.000 687.96 0.0014536 14.079 15.614 62.425 40.114 101.58 412.22 1.0700 5.6114e-05 0.075047 supercritical +350.00 25.000 702.22 0.0014241 13.945 15.512 61.952 40.044 99.133 425.97 0.96858 5.7883e-05 0.076856 supercritical +350.00 26.000 715.31 0.0013980 13.822 15.422 61.516 39.986 96.963 439.20 0.87989 5.9568e-05 0.078576 supercritical +350.00 27.000 727.41 0.0013747 13.707 15.341 61.111 39.937 95.030 451.95 0.80171 6.1177e-05 0.080218 supercritical +350.00 28.000 738.65 0.0013538 13.600 15.269 60.733 39.897 93.302 464.24 0.73230 6.2721e-05 0.081789 supercritical +350.00 29.000 749.14 0.0013349 13.500 15.204 60.379 39.865 91.749 476.11 0.67029 6.4206e-05 0.083296 supercritical +350.00 30.000 758.98 0.0013176 13.406 15.145 60.045 39.838 90.349 487.58 0.61457 6.5640e-05 0.084746 supercritical +350.00 31.000 768.25 0.0013017 13.317 15.093 59.730 39.816 89.080 498.68 0.56426 6.7027e-05 0.086144 supercritical +350.00 32.000 777.00 0.0012870 13.232 15.045 59.430 39.800 87.927 509.43 0.51860 6.8372e-05 0.087494 supercritical +350.00 33.000 785.29 0.0012734 13.152 15.001 59.145 39.787 86.874 519.86 0.47698 6.9679e-05 0.088801 supercritical +350.00 34.000 793.17 0.0012608 13.075 14.962 58.873 39.777 85.909 529.99 0.43890 7.0953e-05 0.090067 supercritical +350.00 35.000 800.68 0.0012489 13.002 14.926 58.612 39.771 85.022 539.84 0.40392 7.2195e-05 0.091297 supercritical +350.00 36.000 807.85 0.0012378 12.932 14.893 58.362 39.767 84.204 549.42 0.37168 7.3409e-05 0.092493 supercritical +350.00 37.000 814.72 0.0012274 12.864 14.863 58.122 39.765 83.447 558.75 0.34186 7.4597e-05 0.093658 supercritical +350.00 38.000 821.30 0.0012176 12.800 14.836 57.890 39.765 82.745 567.84 0.31420 7.5761e-05 0.094793 supercritical +350.00 39.000 827.63 0.0012083 12.737 14.811 57.667 39.767 82.091 576.72 0.28848 7.6904e-05 0.095901 supercritical +350.00 40.000 833.72 0.0011994 12.677 14.788 57.451 39.771 81.481 585.39 0.26449 7.8025e-05 0.096984 supercritical +350.00 41.000 839.60 0.0011911 12.619 14.768 57.242 39.776 80.911 593.86 0.24206 7.9128e-05 0.098042 supercritical +350.00 42.000 845.26 0.0011831 12.562 14.749 57.039 39.782 80.376 602.15 0.22104 8.0214e-05 0.099079 supercritical +350.00 43.000 850.74 0.0011754 12.508 14.732 56.842 39.790 79.873 610.26 0.20130 8.1283e-05 0.10009 supercritical +350.00 44.000 856.05 0.0011682 12.455 14.717 56.651 39.798 79.399 618.20 0.18273 8.2337e-05 0.10109 supercritical +350.00 45.000 861.19 0.0011612 12.403 14.703 56.466 39.808 78.953 625.99 0.16521 8.3376e-05 0.10206 supercritical +350.00 46.000 866.17 0.0011545 12.354 14.691 56.285 39.818 78.530 633.63 0.14867 8.4403e-05 0.10302 supercritical +350.00 47.000 871.02 0.0011481 12.305 14.680 56.109 39.828 78.130 641.12 0.13303 8.5416e-05 0.10396 supercritical +350.00 48.000 875.72 0.0011419 12.258 14.670 55.937 39.840 77.751 648.48 0.11820 8.6418e-05 0.10489 supercritical +350.00 49.000 880.30 0.0011360 12.212 14.661 55.769 39.852 77.390 655.71 0.10413 8.7409e-05 0.10580 supercritical +350.00 50.000 884.76 0.0011303 12.167 14.654 55.605 39.865 77.047 662.81 0.090755 8.8389e-05 0.10670 supercritical diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_H2_CH4.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_H2_CH4.txt new file mode 100644 index 00000000000..0ab359b2c7b --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_H2_CH4.txt @@ -0,0 +1,22 @@ +# experimental PVT measurements for H2-CH4 blends +# ref: https://doi.org/10.1021/acs.jced.7b01125 +# column 1 = pressure [MPa] +# column 2 = density [kg/m3] for 10% hydrogen blend (mole fraction) +# colume 3 = density [kg/m3] for 50% hydrogen blend (mole fraction) +1 5.061 3.109 +2 10.188 6.207 +3 15.301 9.284 +4 20.614 12.364 +5 25.902 15.42 +6 31.226 18.469 +7 36.584 21.49 +8 41.97 24.491 +9 47.361 27.473 +10 52.782 30.433 +11 58.181 33.381 +12 63.582 36.281 +13 68.93 39.178 +14 74.229 42.035 +15 79.534 44.896 +16 84.764 47.697 +17 89.954 50.454 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_brine.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_brine.txt new file mode 100644 index 00000000000..48767cac0a9 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_data/referencePVT_brine.txt @@ -0,0 +1,9 @@ +# reference data for 1.0 molal brine @ 75 degC +# source = https://escholarship.org/content/qt5wg167jq/qt5wg167jq.pdf +# p [MPa] density [kg/m^3] +1 1008.2 +10 1011.6 +20 1017.7 +30 1023.7 +50 1035.3 + diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_docExample.xml b/src/coreComponents/unitTests/constitutiveTests/testPVT_docExample.xml new file mode 100644 index 00000000000..68fe65b3924 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_docExample.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureA.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureA.txt new file mode 100644 index 00000000000..92ee3698e8a --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureA.txt @@ -0,0 +1,57 @@ +# column 1 = time +# column 2 = pressure +# column 3 = temperature +# column 4 = density +# columns 5-6 = phase fractions +# columns 7-8 = phase densities +# columns 9-10 = phase viscosities +0.0000e+00 1.0000e+06 3.5000e+02 5.0614e+00 0.0000e+00 1.0000e+00 5.0614e+00 5.0614e+00 1.0000e-03 1.0000e-03 +2.0408e-02 2.0000e+06 3.5000e+02 1.0180e+01 0.0000e+00 1.0000e+00 1.0180e+01 1.0180e+01 1.0000e-03 1.0000e-03 +4.0816e-02 3.0000e+06 3.5000e+02 1.5348e+01 0.0000e+00 1.0000e+00 1.5348e+01 1.5348e+01 1.0000e-03 1.0000e-03 +6.1224e-02 4.0000e+06 3.5000e+02 2.0560e+01 0.0000e+00 1.0000e+00 2.0560e+01 2.0560e+01 1.0000e-03 1.0000e-03 +8.1633e-02 5.0000e+06 3.5000e+02 2.5808e+01 0.0000e+00 1.0000e+00 2.5808e+01 2.5808e+01 1.0000e-03 1.0000e-03 +1.0204e-01 6.0000e+06 3.5000e+02 3.1082e+01 0.0000e+00 1.0000e+00 3.1082e+01 3.1082e+01 1.0000e-03 1.0000e-03 +1.2245e-01 7.0000e+06 3.5000e+02 3.6375e+01 0.0000e+00 1.0000e+00 3.6375e+01 3.6375e+01 1.0000e-03 1.0000e-03 +1.4286e-01 8.0000e+06 3.5000e+02 4.1677e+01 0.0000e+00 1.0000e+00 4.1677e+01 4.1677e+01 1.0000e-03 1.0000e-03 +1.6327e-01 9.0000e+06 3.5000e+02 4.6978e+01 0.0000e+00 1.0000e+00 4.6978e+01 4.6978e+01 1.0000e-03 1.0000e-03 +1.8367e-01 1.0000e+07 3.5000e+02 5.2270e+01 0.0000e+00 1.0000e+00 5.2270e+01 5.2270e+01 1.0000e-03 1.0000e-03 +2.0408e-01 1.1000e+07 3.5000e+02 5.7543e+01 0.0000e+00 1.0000e+00 5.7543e+01 5.7543e+01 1.0000e-03 1.0000e-03 +2.2449e-01 1.2000e+07 3.5000e+02 6.2788e+01 0.0000e+00 1.0000e+00 6.2788e+01 6.2788e+01 1.0000e-03 1.0000e-03 +2.4490e-01 1.3000e+07 3.5000e+02 6.7996e+01 0.0000e+00 1.0000e+00 6.7996e+01 6.7996e+01 1.0000e-03 1.0000e-03 +2.6531e-01 1.4000e+07 3.5000e+02 7.3159e+01 0.0000e+00 1.0000e+00 7.3159e+01 7.3159e+01 1.0000e-03 1.0000e-03 +2.8571e-01 1.5000e+07 3.5000e+02 7.8269e+01 0.0000e+00 1.0000e+00 7.8269e+01 7.8269e+01 1.0000e-03 1.0000e-03 +3.0612e-01 1.6000e+07 3.5000e+02 8.3319e+01 0.0000e+00 1.0000e+00 8.3319e+01 8.3319e+01 1.0000e-03 1.0000e-03 +3.2653e-01 1.7000e+07 3.5000e+02 8.8303e+01 0.0000e+00 1.0000e+00 8.8303e+01 8.8303e+01 1.0000e-03 1.0000e-03 +3.4694e-01 1.8000e+07 3.5000e+02 9.3216e+01 0.0000e+00 1.0000e+00 9.3216e+01 9.3216e+01 1.0000e-03 1.0000e-03 +3.6735e-01 1.9000e+07 3.5000e+02 9.8052e+01 0.0000e+00 1.0000e+00 9.8052e+01 9.8052e+01 1.0000e-03 1.0000e-03 +3.8776e-01 2.0000e+07 3.5000e+02 1.0281e+02 0.0000e+00 1.0000e+00 1.0281e+02 1.0281e+02 1.0000e-03 1.0000e-03 +4.0816e-01 2.1000e+07 3.5000e+02 1.0748e+02 0.0000e+00 1.0000e+00 1.0748e+02 1.0748e+02 1.0000e-03 1.0000e-03 +4.2857e-01 2.2000e+07 3.5000e+02 1.1207e+02 0.0000e+00 1.0000e+00 1.1207e+02 1.1207e+02 1.0000e-03 1.0000e-03 +4.4898e-01 2.3000e+07 3.5000e+02 1.1656e+02 0.0000e+00 1.0000e+00 1.1656e+02 1.1656e+02 1.0000e-03 1.0000e-03 +4.6939e-01 2.4000e+07 3.5000e+02 1.2097e+02 0.0000e+00 1.0000e+00 1.2097e+02 1.2097e+02 1.0000e-03 1.0000e-03 +4.8980e-01 2.5000e+07 3.5000e+02 1.2529e+02 0.0000e+00 1.0000e+00 1.2529e+02 1.2529e+02 1.0000e-03 1.0000e-03 +5.1020e-01 2.6000e+07 3.5000e+02 1.2952e+02 0.0000e+00 1.0000e+00 1.2952e+02 1.2952e+02 1.0000e-03 1.0000e-03 +5.3061e-01 2.7000e+07 3.5000e+02 1.3366e+02 0.0000e+00 1.0000e+00 1.3366e+02 1.3366e+02 1.0000e-03 1.0000e-03 +5.5102e-01 2.8000e+07 3.5000e+02 1.3770e+02 0.0000e+00 1.0000e+00 1.3770e+02 1.3770e+02 1.0000e-03 1.0000e-03 +5.7143e-01 2.9000e+07 3.5000e+02 1.4166e+02 0.0000e+00 1.0000e+00 1.4166e+02 1.4166e+02 1.0000e-03 1.0000e-03 +5.9184e-01 3.0000e+07 3.5000e+02 1.4554e+02 0.0000e+00 1.0000e+00 1.4554e+02 1.4554e+02 1.0000e-03 1.0000e-03 +6.1224e-01 3.1000e+07 3.5000e+02 1.4932e+02 0.0000e+00 1.0000e+00 1.4932e+02 1.4932e+02 1.0000e-03 1.0000e-03 +6.3265e-01 3.2000e+07 3.5000e+02 1.5302e+02 0.0000e+00 1.0000e+00 1.5302e+02 1.5302e+02 1.0000e-03 1.0000e-03 +6.5306e-01 3.3000e+07 3.5000e+02 1.5664e+02 0.0000e+00 1.0000e+00 1.5664e+02 1.5664e+02 1.0000e-03 1.0000e-03 +6.7347e-01 3.4000e+07 3.5000e+02 1.6018e+02 0.0000e+00 1.0000e+00 1.6018e+02 1.6018e+02 1.0000e-03 1.0000e-03 +6.9388e-01 3.5000e+07 3.5000e+02 1.6363e+02 0.0000e+00 1.0000e+00 1.6363e+02 1.6363e+02 1.0000e-03 1.0000e-03 +7.1429e-01 3.6000e+07 3.5000e+02 1.6701e+02 0.0000e+00 1.0000e+00 1.6701e+02 1.6701e+02 1.0000e-03 1.0000e-03 +7.3469e-01 3.7000e+07 3.5000e+02 1.7032e+02 0.0000e+00 1.0000e+00 1.7032e+02 1.7032e+02 1.0000e-03 1.0000e-03 +7.5510e-01 3.8000e+07 3.5000e+02 1.7355e+02 0.0000e+00 1.0000e+00 1.7355e+02 1.7355e+02 1.0000e-03 1.0000e-03 +7.7551e-01 3.9000e+07 3.5000e+02 1.7671e+02 0.0000e+00 1.0000e+00 1.7671e+02 1.7671e+02 1.0000e-03 1.0000e-03 +7.9592e-01 4.0000e+07 3.5000e+02 1.7980e+02 0.0000e+00 1.0000e+00 1.7980e+02 1.7980e+02 1.0000e-03 1.0000e-03 +8.1633e-01 4.1000e+07 3.5000e+02 1.8282e+02 0.0000e+00 1.0000e+00 1.8282e+02 1.8282e+02 1.0000e-03 1.0000e-03 +8.3673e-01 4.2000e+07 3.5000e+02 1.8578e+02 0.0000e+00 1.0000e+00 1.8578e+02 1.8578e+02 1.0000e-03 1.0000e-03 +8.5714e-01 4.3000e+07 3.5000e+02 1.8867e+02 0.0000e+00 1.0000e+00 1.8867e+02 1.8867e+02 1.0000e-03 1.0000e-03 +8.7755e-01 4.4000e+07 3.5000e+02 1.9151e+02 0.0000e+00 1.0000e+00 1.9151e+02 1.9151e+02 1.0000e-03 1.0000e-03 +8.9796e-01 4.5000e+07 3.5000e+02 1.9428e+02 0.0000e+00 1.0000e+00 1.9428e+02 1.9428e+02 1.0000e-03 1.0000e-03 +9.1837e-01 4.6000e+07 3.5000e+02 1.9699e+02 0.0000e+00 1.0000e+00 1.9699e+02 1.9699e+02 1.0000e-03 1.0000e-03 +9.3878e-01 4.7000e+07 3.5000e+02 1.9965e+02 0.0000e+00 1.0000e+00 1.9965e+02 1.9965e+02 1.0000e-03 1.0000e-03 +9.5918e-01 4.8000e+07 3.5000e+02 2.0226e+02 0.0000e+00 1.0000e+00 2.0226e+02 2.0226e+02 1.0000e-03 1.0000e-03 +9.7959e-01 4.9000e+07 3.5000e+02 2.0481e+02 0.0000e+00 1.0000e+00 2.0481e+02 2.0481e+02 1.0000e-03 1.0000e-03 +1.0000e+00 5.0000e+07 3.5000e+02 2.0731e+02 0.0000e+00 1.0000e+00 2.0731e+02 2.0731e+02 1.0000e-03 1.0000e-03 diff --git a/src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureB.txt b/src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureB.txt new file mode 100644 index 00000000000..6a881df4155 --- /dev/null +++ b/src/coreComponents/unitTests/constitutiveTests/testPVT_hydrogenMixtureB.txt @@ -0,0 +1,57 @@ +# column 1 = time +# column 2 = pressure +# column 3 = temperature +# column 4 = density +# columns 5-6 = phase fractions +# columns 7-8 = phase densities +# columns 9-10 = phase viscosities +0.0000e+00 1.0000e+06 3.5000e+02 3.1006e+00 0.0000e+00 1.0000e+00 3.1006e+00 3.1006e+00 1.0000e-03 1.0000e-03 +2.0408e-02 2.0000e+06 3.5000e+02 6.1951e+00 0.0000e+00 1.0000e+00 6.1951e+00 6.1951e+00 1.0000e-03 1.0000e-03 +4.0816e-02 3.0000e+06 3.5000e+02 9.2811e+00 0.0000e+00 1.0000e+00 9.2811e+00 9.2811e+00 1.0000e-03 1.0000e-03 +6.1224e-02 4.0000e+06 3.5000e+02 1.2356e+01 0.0000e+00 1.0000e+00 1.2356e+01 1.2356e+01 1.0000e-03 1.0000e-03 +8.1633e-02 5.0000e+06 3.5000e+02 1.5418e+01 0.0000e+00 1.0000e+00 1.5418e+01 1.5418e+01 1.0000e-03 1.0000e-03 +1.0204e-01 6.0000e+06 3.5000e+02 1.8465e+01 0.0000e+00 1.0000e+00 1.8465e+01 1.8465e+01 1.0000e-03 1.0000e-03 +1.2245e-01 7.0000e+06 3.5000e+02 2.1494e+01 0.0000e+00 1.0000e+00 2.1494e+01 2.1494e+01 1.0000e-03 1.0000e-03 +1.4286e-01 8.0000e+06 3.5000e+02 2.4504e+01 0.0000e+00 1.0000e+00 2.4504e+01 2.4504e+01 1.0000e-03 1.0000e-03 +1.6327e-01 9.0000e+06 3.5000e+02 2.7493e+01 0.0000e+00 1.0000e+00 2.7493e+01 2.7493e+01 1.0000e-03 1.0000e-03 +1.8367e-01 1.0000e+07 3.5000e+02 3.0458e+01 0.0000e+00 1.0000e+00 3.0458e+01 3.0458e+01 1.0000e-03 1.0000e-03 +2.0408e-01 1.1000e+07 3.5000e+02 3.3399e+01 0.0000e+00 1.0000e+00 3.3399e+01 3.3399e+01 1.0000e-03 1.0000e-03 +2.2449e-01 1.2000e+07 3.5000e+02 3.6314e+01 0.0000e+00 1.0000e+00 3.6314e+01 3.6314e+01 1.0000e-03 1.0000e-03 +2.4490e-01 1.3000e+07 3.5000e+02 3.9201e+01 0.0000e+00 1.0000e+00 3.9201e+01 3.9201e+01 1.0000e-03 1.0000e-03 +2.6531e-01 1.4000e+07 3.5000e+02 4.2059e+01 0.0000e+00 1.0000e+00 4.2059e+01 4.2059e+01 1.0000e-03 1.0000e-03 +2.8571e-01 1.5000e+07 3.5000e+02 4.4888e+01 0.0000e+00 1.0000e+00 4.4888e+01 4.4888e+01 1.0000e-03 1.0000e-03 +3.0612e-01 1.6000e+07 3.5000e+02 4.7685e+01 0.0000e+00 1.0000e+00 4.7685e+01 4.7685e+01 1.0000e-03 1.0000e-03 +3.2653e-01 1.7000e+07 3.5000e+02 5.0451e+01 0.0000e+00 1.0000e+00 5.0451e+01 5.0451e+01 1.0000e-03 1.0000e-03 +3.4694e-01 1.8000e+07 3.5000e+02 5.3184e+01 0.0000e+00 1.0000e+00 5.3184e+01 5.3184e+01 1.0000e-03 1.0000e-03 +3.6735e-01 1.9000e+07 3.5000e+02 5.5884e+01 0.0000e+00 1.0000e+00 5.5884e+01 5.5884e+01 1.0000e-03 1.0000e-03 +3.8776e-01 2.0000e+07 3.5000e+02 5.8550e+01 0.0000e+00 1.0000e+00 5.8550e+01 5.8550e+01 1.0000e-03 1.0000e-03 +4.0816e-01 2.1000e+07 3.5000e+02 6.1183e+01 0.0000e+00 1.0000e+00 6.1183e+01 6.1183e+01 1.0000e-03 1.0000e-03 +4.2857e-01 2.2000e+07 3.5000e+02 6.3780e+01 0.0000e+00 1.0000e+00 6.3780e+01 6.3780e+01 1.0000e-03 1.0000e-03 +4.4898e-01 2.3000e+07 3.5000e+02 6.6343e+01 0.0000e+00 1.0000e+00 6.6343e+01 6.6343e+01 1.0000e-03 1.0000e-03 +4.6939e-01 2.4000e+07 3.5000e+02 6.8871e+01 0.0000e+00 1.0000e+00 6.8871e+01 6.8871e+01 1.0000e-03 1.0000e-03 +4.8980e-01 2.5000e+07 3.5000e+02 7.1364e+01 0.0000e+00 1.0000e+00 7.1364e+01 7.1364e+01 1.0000e-03 1.0000e-03 +5.1020e-01 2.6000e+07 3.5000e+02 7.3822e+01 0.0000e+00 1.0000e+00 7.3822e+01 7.3822e+01 1.0000e-03 1.0000e-03 +5.3061e-01 2.7000e+07 3.5000e+02 7.6245e+01 0.0000e+00 1.0000e+00 7.6245e+01 7.6245e+01 1.0000e-03 1.0000e-03 +5.5102e-01 2.8000e+07 3.5000e+02 7.8634e+01 0.0000e+00 1.0000e+00 7.8634e+01 7.8634e+01 1.0000e-03 1.0000e-03 +5.7143e-01 2.9000e+07 3.5000e+02 8.0988e+01 0.0000e+00 1.0000e+00 8.0988e+01 8.0988e+01 1.0000e-03 1.0000e-03 +5.9184e-01 3.0000e+07 3.5000e+02 8.3307e+01 0.0000e+00 1.0000e+00 8.3307e+01 8.3307e+01 1.0000e-03 1.0000e-03 +6.1224e-01 3.1000e+07 3.5000e+02 8.5593e+01 0.0000e+00 1.0000e+00 8.5593e+01 8.5593e+01 1.0000e-03 1.0000e-03 +6.3265e-01 3.2000e+07 3.5000e+02 8.7844e+01 0.0000e+00 1.0000e+00 8.7844e+01 8.7844e+01 1.0000e-03 1.0000e-03 +6.5306e-01 3.3000e+07 3.5000e+02 9.0062e+01 0.0000e+00 1.0000e+00 9.0062e+01 9.0062e+01 1.0000e-03 1.0000e-03 +6.7347e-01 3.4000e+07 3.5000e+02 9.2247e+01 0.0000e+00 1.0000e+00 9.2247e+01 9.2247e+01 1.0000e-03 1.0000e-03 +6.9388e-01 3.5000e+07 3.5000e+02 9.4400e+01 0.0000e+00 1.0000e+00 9.4400e+01 9.4400e+01 1.0000e-03 1.0000e-03 +7.1429e-01 3.6000e+07 3.5000e+02 9.6520e+01 0.0000e+00 1.0000e+00 9.6520e+01 9.6520e+01 1.0000e-03 1.0000e-03 +7.3469e-01 3.7000e+07 3.5000e+02 9.8608e+01 0.0000e+00 1.0000e+00 9.8608e+01 9.8608e+01 1.0000e-03 1.0000e-03 +7.5510e-01 3.8000e+07 3.5000e+02 1.0067e+02 0.0000e+00 1.0000e+00 1.0067e+02 1.0067e+02 1.0000e-03 1.0000e-03 +7.7551e-01 3.9000e+07 3.5000e+02 1.0269e+02 0.0000e+00 1.0000e+00 1.0269e+02 1.0269e+02 1.0000e-03 1.0000e-03 +7.9592e-01 4.0000e+07 3.5000e+02 1.0469e+02 0.0000e+00 1.0000e+00 1.0469e+02 1.0469e+02 1.0000e-03 1.0000e-03 +8.1633e-01 4.1000e+07 3.5000e+02 1.0665e+02 0.0000e+00 1.0000e+00 1.0665e+02 1.0665e+02 1.0000e-03 1.0000e-03 +8.3673e-01 4.2000e+07 3.5000e+02 1.0859e+02 0.0000e+00 1.0000e+00 1.0859e+02 1.0859e+02 1.0000e-03 1.0000e-03 +8.5714e-01 4.3000e+07 3.5000e+02 1.1050e+02 0.0000e+00 1.0000e+00 1.1050e+02 1.1050e+02 1.0000e-03 1.0000e-03 +8.7755e-01 4.4000e+07 3.5000e+02 1.1238e+02 0.0000e+00 1.0000e+00 1.1238e+02 1.1238e+02 1.0000e-03 1.0000e-03 +8.9796e-01 4.5000e+07 3.5000e+02 1.1423e+02 0.0000e+00 1.0000e+00 1.1423e+02 1.1423e+02 1.0000e-03 1.0000e-03 +9.1837e-01 4.6000e+07 3.5000e+02 1.1605e+02 0.0000e+00 1.0000e+00 1.1605e+02 1.1605e+02 1.0000e-03 1.0000e-03 +9.3878e-01 4.7000e+07 3.5000e+02 1.1785e+02 0.0000e+00 1.0000e+00 1.1785e+02 1.1785e+02 1.0000e-03 1.0000e-03 +9.5918e-01 4.8000e+07 3.5000e+02 1.1962e+02 0.0000e+00 1.0000e+00 1.1962e+02 1.1962e+02 1.0000e-03 1.0000e-03 +9.7959e-01 4.9000e+07 3.5000e+02 1.2136e+02 0.0000e+00 1.0000e+00 1.2136e+02 1.2136e+02 1.0000e-03 1.0000e-03 +1.0000e+00 5.0000e+07 3.5000e+02 1.2308e+02 0.0000e+00 1.0000e+00 1.2308e+02 1.2308e+02 1.0000e-03 1.0000e-03 diff --git a/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlow.cpp b/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlow.cpp index eeae53979e3..66013b849af 100644 --- a/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlow.cpp +++ b/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlow.cpp @@ -18,7 +18,9 @@ #include "mainInterface/initialization.hpp" #include "mainInterface/GeosxState.hpp" #include "physicsSolvers/PhysicsSolverManager.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "unitTests/fluidFlowTests/testCompFlowUtils.hpp" using namespace geosx; @@ -177,16 +179,16 @@ void testCompositionNumericalDerivatives( CompositionalMultiphaseFVM & solver, arrayView1d< string const > const & components = fluid.componentNames(); arrayView2d< real64, compflow::USD_COMP > & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64, compflow::USD_COMP > & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); arrayView2d< real64, compflow::USD_COMP > & compFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::globalCompFractionString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >(); arrayView3d< real64, compflow::USD_COMP_DC > & dCompFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_COMP_DC > >( CompositionalMultiphaseFVM::viewKeyStruct::dGlobalCompFraction_dGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >(); // reset the solver state to zero out variable updates solver.resetStateToBeginningOfStep( domain ); @@ -254,25 +256,25 @@ void testPhaseVolumeFractionNumericalDerivatives( CompositionalMultiphaseFVM & s arrayView1d< string const > const & phases = fluid.phaseNames(); arrayView1d< real64 > & pres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseFVM::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > & dPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64, compflow::USD_COMP > & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64, compflow::USD_COMP > & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); arrayView2d< real64, compflow::USD_PHASE > & phaseVolFrac = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseFVM::viewKeyStruct::phaseVolumeFractionString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >(); arrayView2d< real64, compflow::USD_PHASE > & dPhaseVolFrac_dPres = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseFVM::viewKeyStruct::dPhaseVolumeFraction_dPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >(); arrayView3d< real64, compflow::USD_PHASE_DC > & dPhaseVolFrac_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( CompositionalMultiphaseFVM::viewKeyStruct::dPhaseVolumeFraction_dGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >(); // reset the solver state to zero out variable updates solver.resetStateToBeginningOfStep( domain ); @@ -367,25 +369,25 @@ void testPhaseMobilityNumericalDerivatives( CompositionalMultiphaseFVM & solver, arrayView1d< string const > const & phases = fluid.phaseNames(); arrayView1d< real64 > & pres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseFVM::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > & dPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64, compflow::USD_COMP > & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64, compflow::USD_COMP > & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); arrayView2d< real64, compflow::USD_PHASE > & phaseMob = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseFVM::viewKeyStruct::phaseMobilityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseMobility >(); arrayView2d< real64, compflow::USD_PHASE > & dPhaseMob_dPres = - subRegion.getReference< array2d< real64, compflow::LAYOUT_PHASE > >( CompositionalMultiphaseFVM::viewKeyStruct::dPhaseMobility_dPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dPressure >(); arrayView3d< real64, compflow::USD_PHASE_DC > & dPhaseMob_dCompDens = - subRegion.getReference< array3d< real64, compflow::LAYOUT_PHASE_DC > >( CompositionalMultiphaseFVM::viewKeyStruct::dPhaseMobility_dGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity >(); // reset the solver state to zero out variable updates solver.resetStateToBeginningOfStep( domain ); @@ -502,18 +504,18 @@ void testNumericalJacobian( CompositionalMultiphaseFVM & solver, subRegion.getReference< array1d< globalIndex > >( dofKey ); arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseFVM::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); pres.move( LvArray::MemorySpace::host, false ); arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); compDens.move( LvArray::MemorySpace::host, false ); arrayView2d< real64, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseFVM::viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); for( localIndex ei = 0; ei < subRegion.size(); ++ei ) { diff --git a/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlowHybrid.cpp b/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlowHybrid.cpp index 3ea82ea9874..7fb1cd55b69 100644 --- a/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlowHybrid.cpp +++ b/src/coreComponents/unitTests/fluidFlowTests/testCompMultiphaseFlowHybrid.cpp @@ -19,6 +19,8 @@ #include "mainInterface/ProblemManager.hpp" #include "mainInterface/GeosxState.hpp" #include "physicsSolvers/PhysicsSolverManager.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp" #include "unitTests/fluidFlowTests/testCompFlowUtils.hpp" @@ -199,18 +201,18 @@ void testNumericalJacobian( CompositionalMultiphaseHybridFVM & solver, subRegion.getReference< array1d< globalIndex > >( elemDofKey ); arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseHybridFVM::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); pres.move( LvArray::MemorySpace::host, false ); arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseHybridFVM::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseHybridFVM::viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); compDens.move( LvArray::MemorySpace::host, false ); arrayView2d< real64, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseHybridFVM::viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); for( localIndex ei = 0; ei < subRegion.size(); ++ei ) { @@ -280,10 +282,10 @@ void testNumericalJacobian( CompositionalMultiphaseHybridFVM & solver, // get the face-based pressure arrayView1d< real64 > const & facePres = - faceManager.getReference< array1d< real64 > >( CompositionalMultiphaseHybridFVM::viewKeyStruct::facePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::facePressure >(); facePres.move( LvArray::MemorySpace::host, false ); arrayView1d< real64 > const & dFacePres = - faceManager.getReference< array1d< real64 > >( CompositionalMultiphaseHybridFVM::viewKeyStruct::deltaFacePressureString() ); + faceManager.getExtrinsicData< extrinsicMeshData::flow::deltaFacePressure >(); string const faceDofKey = dofManager.getKey( CompositionalMultiphaseHybridFVM::viewKeyStruct::faceDofFieldString() ); diff --git a/src/coreComponents/unitTests/wellsTests/testReservoirCompositionalMultiphaseMSWells.cpp b/src/coreComponents/unitTests/wellsTests/testReservoirCompositionalMultiphaseMSWells.cpp index 4e257a47b6e..e61407f46a2 100644 --- a/src/coreComponents/unitTests/wellsTests/testReservoirCompositionalMultiphaseMSWells.cpp +++ b/src/coreComponents/unitTests/wellsTests/testReservoirCompositionalMultiphaseMSWells.cpp @@ -24,6 +24,7 @@ #include "physicsSolvers/PhysicsSolverManager.hpp" #include "physicsSolvers/multiphysics/ReservoirSolverBase.hpp" #include "physicsSolvers/multiphysics/CompositionalMultiphaseReservoir.hpp" +#include "physicsSolvers/fluidFlow/FlowSolverBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.hpp" #include "physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp" @@ -259,15 +260,15 @@ void testNumericalJacobian( CompositionalMultiphaseReservoir & solver, // get the primary variables on the reservoir elements arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseBase::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseBase::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); pres.move( LvArray::MemorySpace::host, false ); arrayView2d< real64 const, compflow::USD_COMP > const & compDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseBase::viewKeyStruct::globalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >(); arrayView2d< real64, compflow::USD_COMP > const & dCompDens = - subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( CompositionalMultiphaseBase::viewKeyStruct::deltaGlobalCompDensityString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >(); compDens.move( LvArray::MemorySpace::host, false ); @@ -354,9 +355,9 @@ void testNumericalJacobian( CompositionalMultiphaseReservoir & solver, // get the primary variables on the well elements arrayView1d< real64 > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseWell::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( CompositionalMultiphaseWell::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); wellElemPressure.move( LvArray::MemorySpace::host, false ); arrayView2d< real64 const, compflow::USD_COMP > const & wellElemCompDens = diff --git a/src/coreComponents/unitTests/wellsTests/testReservoirSinglePhaseMSWells.cpp b/src/coreComponents/unitTests/wellsTests/testReservoirSinglePhaseMSWells.cpp index bf2ca8db32f..308fb3b0a21 100644 --- a/src/coreComponents/unitTests/wellsTests/testReservoirSinglePhaseMSWells.cpp +++ b/src/coreComponents/unitTests/wellsTests/testReservoirSinglePhaseMSWells.cpp @@ -25,6 +25,7 @@ #include "physicsSolvers/multiphysics/ReservoirSolverBase.hpp" #include "physicsSolvers/multiphysics/SinglePhaseReservoir.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" +#include "physicsSolvers/fluidFlow/SinglePhaseBaseExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseFVM.hpp" #include "physicsSolvers/fluidFlow/wells/SinglePhaseWell.hpp" @@ -209,9 +210,9 @@ void testNumericalJacobian( SinglePhaseReservoir & solver, // get the primary variables on reservoir elements arrayView1d< real64 const > const & pres = - subRegion.getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const & dPres = - subRegion.getReference< array1d< real64 > >( FlowSolverBase::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); pres.move( LvArray::MemorySpace::host, false ); // a) compute all the derivatives wrt to the pressure in RESERVOIR elem ei @@ -265,9 +266,9 @@ void testNumericalJacobian( SinglePhaseReservoir & solver, // get the primary variables on well elements arrayView1d< real64 const > const & wellElemPressure = - subRegion.getReference< array1d< real64 > >( SinglePhaseWell::viewKeyStruct::pressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::pressure >(); arrayView1d< real64 > const & dWellElemPressure = - subRegion.getReference< array1d< real64 > >( SinglePhaseWell::viewKeyStruct::deltaPressureString() ); + subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); wellElemPressure.move( LvArray::MemorySpace::host, false ); arrayView1d< real64 const > const & connRate = diff --git a/src/docs/sphinx/CompleteXMLSchema.rst b/src/docs/sphinx/CompleteXMLSchema.rst index 2e2865c17df..85581bba477 100644 --- a/src/docs/sphinx/CompleteXMLSchema.rst +++ b/src/docs/sphinx/CompleteXMLSchema.rst @@ -533,6 +533,13 @@ Element: PAMELAMeshGenerator .. include:: ../../coreComponents/schema/docs/PAMELAMeshGenerator.rst +.. _XML_PVTDriver: + +Element: PVTDriver +================== +.. include:: ../../coreComponents/schema/docs/PVTDriver.rst + + .. _XML_PackCollection: Element: PackCollection @@ -1503,6 +1510,13 @@ Datastructure: PAMELAMeshGenerator .. include:: ../../coreComponents/schema/docs/PAMELAMeshGenerator_other.rst +.. _DATASTRUCTURE_PVTDriver: + +Datastructure: PVTDriver +======================== +.. include:: ../../coreComponents/schema/docs/PVTDriver_other.rst + + .. _DATASTRUCTURE_PackCollection: Datastructure: PackCollection diff --git a/src/docs/sphinx/advancedExamples/validationStudies/casedElasticWellbore/Example.rst b/src/docs/sphinx/advancedExamples/validationStudies/casedElasticWellbore/Example.rst index 0056937b8f5..37529b25673 100644 --- a/src/docs/sphinx/advancedExamples/validationStudies/casedElasticWellbore/Example.rst +++ b/src/docs/sphinx/advancedExamples/validationStudies/casedElasticWellbore/Example.rst @@ -51,7 +51,7 @@ Solid mechanics solver As fluid flow is not considered, only the solid mechanics ``SolidMechanicsLagrangianSSLE`` solver is required for solving this linear elastic problem. In this solver, the three regions and three materials associated to casing, cement sheath and rock are respectively defined by ``targetRegions`` and ``solidMaterialNames``. -.. literalinclude:: ../../../../../../inputFiles/wellbore/CasedElasticWellbore_base.xml +.. literalinclude:: ../../../../../../inputFiles/wellbore/CasedElasticWellbore_benchmark.xml :language: xml :start-after: :end-before: diff --git a/src/docs/sphinx/advancedExamples/validationStudies/deviatedElasticWellbore/Example.rst b/src/docs/sphinx/advancedExamples/validationStudies/deviatedElasticWellbore/Example.rst index ebe4d4929ca..8f10f906085 100644 --- a/src/docs/sphinx/advancedExamples/validationStudies/deviatedElasticWellbore/Example.rst +++ b/src/docs/sphinx/advancedExamples/validationStudies/deviatedElasticWellbore/Example.rst @@ -51,7 +51,7 @@ Solid mechanics solver As fluid flow is not considered, only the solid mechanics solver ``SolidMechanicsLagrangianSSLE`` is required for solving this wellbore problem. -.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedElasticWellbore_base.xml +.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedElasticWellbore_benchmark.xml :language: xml :start-after: :end-before: diff --git a/src/docs/sphinx/advancedExamples/validationStudies/deviatedPoroElasticWellbore/Example.rst b/src/docs/sphinx/advancedExamples/validationStudies/deviatedPoroElasticWellbore/Example.rst index f33353f9e19..f221f4719fa 100644 --- a/src/docs/sphinx/advancedExamples/validationStudies/deviatedPoroElasticWellbore/Example.rst +++ b/src/docs/sphinx/advancedExamples/validationStudies/deviatedPoroElasticWellbore/Example.rst @@ -48,19 +48,19 @@ Poroelastic solver The coupled ``Poroelastic`` solver, that defines a coupling strategy between the solid mechanics solver ``SolidMechanicsLagrangianSSLE`` and the single phase flow solver ``SinglePhaseFVM``, is required for solving this wellbore problem. -.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml +.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml :language: xml :start-after: :end-before: -.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml +.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml :language: xml :start-after: :end-before: -.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_base.xml +.. literalinclude:: ../../../../../../inputFiles/wellbore/DeviatedPoroElasticWellbore_Injection_benchmark.xml :language: xml :start-after: :end-before: diff --git a/src/docs/sphinx/advancedExamples/validationStudies/intersectFrac/Example.rst b/src/docs/sphinx/advancedExamples/validationStudies/intersectFrac/Example.rst index 0bf3eb07ba9..90ed06b60e7 100644 --- a/src/docs/sphinx/advancedExamples/validationStudies/intersectFrac/Example.rst +++ b/src/docs/sphinx/advancedExamples/validationStudies/intersectFrac/Example.rst @@ -122,7 +122,7 @@ Constitutive laws For this problem, we simulate the elastic deformation and fracture slippage caused by the uniaxial compression. A homogeneous and isotropic domain with one solid material is assumed, and its mechanical properties are specified in the ``Constitutive`` section. -Fracture surface slippage is assumed to be governed by the Coulomb failure criterion. The contact constitutive behavior is named ``fractureMaterial`` in the ``Coulomb`` block, where cohesion ``cohesion="0.0"`` and friction angle ``frictionAngle="0.523598776"`` are specified. +Fracture surface slippage is assumed to be governed by the Coulomb failure criterion. The contact constitutive behavior is named ``fractureMaterial`` in the ``Coulomb`` block, where cohesion ``cohesion="0.0"`` and friction coefficient ``frictionCoefficient="0.577350269"`` are specified. .. literalinclude:: ../../../../../../inputFiles/lagrangianContactMechanics/ContactMechanics_TFrac_base.xml :language: xml @@ -143,7 +143,7 @@ Time history function In the ``Tasks`` section, ``PackCollection`` tasks are defined to collect time history information from fields. Either the entire field or specified named sets of indices in the field can be collected. -In this example, ``tractionCollection`` and ``displacementJumpCollection`` tasks are specified to output the local traction ``fieldName="traction"`` and relative displacement ``fieldName="localJump"`` on the fracture surface. +In this example, ``tractionCollection`` and ``displacementJumpCollection`` tasks are specified to output the local traction ``fieldName="traction"`` and relative displacement ``fieldName="displacementJump"`` on the fracture surface. .. literalinclude:: ../../../../../../inputFiles/lagrangianContactMechanics/ContactMechanics_TFrac_base.xml :language: xml @@ -191,7 +191,7 @@ The parameters used in the simulation are summarized in the following table. +------------------+-------------------------+------------------+--------------------+ | :math:`\sigma_y` | Remote Stress | [MPa] | -100.0 | +------------------+-------------------------+------------------+--------------------+ -| :math:`P_in` | Internal Pressure | [MPa] | -100.0 | +| :math:`P_{in}` | Internal Pressure | [MPa] | -100.0 | +------------------+-------------------------+------------------+--------------------+ | :math:`\theta` | Friction Angle | [Degree] | 30.0 | +------------------+-------------------------+------------------+--------------------+ @@ -263,12 +263,12 @@ The figure below compares the results from GEOSX (marks) and the corresponding l param = tree.find('Constitutive/ElasticIsotropic') - mechanicalParameters = dict.fromkeys(["bulkModulus", "shearModulus", "frictionAngle"]) + mechanicalParameters = dict.fromkeys(["bulkModulus", "shearModulus", "frictionCoefficient"]) mechanicalParameters["bulkModulus"] = float(param.get("defaultBulkModulus")) mechanicalParameters["shearModulus"] = float(param.get("defaultShearModulus")) param = tree.find('Constitutive/Coulomb') - mechanicalParameters["frictionAngle"] = float(param.get("frictionAngle")) + mechanicalParameters["frictionCoefficient"] = float(param.get("frictionCoefficient")) return mechanicalParameters @@ -342,7 +342,7 @@ The figure below compares the results from GEOSX (marks) and the corresponding l # Local Shear Displacement hf = h5py.File(hdf5File2Path, 'r') - jump = hf.get('localJump') + jump = hf.get('displacementJump') jump = np.array(jump) displacementJump = jump[-1,:,1] aperture = jump[-1,:,0] diff --git a/src/docs/sphinx/advancedExamples/validationStudies/intersectFrac/displacementJump_history.hdf5 b/src/docs/sphinx/advancedExamples/validationStudies/intersectFrac/displacementJump_history.hdf5 index b68bccfd7698af4c86c63c880e778a967f402418..46a5832268a8bff4da52df782e52fd39b2b62f01 100644 GIT binary patch delta 18366 zcmZXbc|Z*BAIGOckt6pNErpa)_>y$2JA@DtUp9)ObU2DIgHWzYsZ?s|-rC*SLXMAV zU0*rNmH37ba(qdyT=_jav)i=KZ~j>J^?9y&o|)(Ke$Q;RXWG`DX&Xc92owr^T^}8S zJ4$uc|55+r?YAb#-)osqfY0i+Q`ZFqX`(n6`1rGB#-nmRAq4S%ad*D}pSV7H#d;r~ zC&UGII#d+Y!lrFp`EY}{Tq8l8a)LooxlyW)Dq0lS>92PB=s#Wr;Tx+6NEG+fX;su$ zVBdx$c1CTy6HPf0;&ELr=pACzqoD{Nqk*$Kg*g$_mtu3DW;{N!>{5%BsN9g+G0%jW z@&w_*>>pR>g}#sc4zY`PF4l38dibF4FJ6>aui|<6l|hfn+2W+wg?Dd z2xG%j^_rwgwFTZB3^Ouqi6%ql@4}|?a+5>SVfud7M_a} zEw_r$_v&HGO#{end_XwM^FXrd`|5oe;+;G%&8t}6aTh~~635-P-^+8O^3m`0_b~(= z@?y+~Se|=qO3p|;fI66vx7In4=i-lNa~39{0mXg@ADzx|QZ?Tb*82~cCuRtt&4M;A z*?a|$6O%^WL*K=d&6h2a@qApNqu*?rAwDaA)(84jaw|Uu;9C+a-Ls2>#7WvdWX|6<~_da5b(-X#~$1Gdr@!rlF91l||8ecAgAtQsKE zZr@i92VVK)ts_0LfU6uHTha55?!ovwIsEfyNaNa581F&D&4@u48=qsmR1UtK$6L%a z%-8O?Rt{6&KDJ&vl;b2?cW&woXeb~>z8l@J3Pv=zDc%?dtj2h28bqZZ=go`4_*XR0 zIjz4r9lG_Vn6rNAn3pMS3nt7 zArzf)a^CFA490zE7~FODSlfJzd(sfrF=S^}JjQ)#nD^Yj!Z@7g`fSH@>7tp#qI!_e zzV^Dke=#3rgA-_&FxBhZM<zZJVp*Po|G2PY>n|q8N|FgzUX%ew!3tpp>XZR z%3UEC7s#OOPyfl61sEsIWiUzZ>Jfbv+wSV}!AyEZAq&K~ksNwmzHIfr1IE!lJ7dU_ z`VRTn{wtEfg)_>zH-#84Mdh=Q1MUE_IZwBsGsFOgBVMj&w5iA9U<-_}A11q~< zST6O=0gJp&m%mTLczF)!S?Pxyh{keqOct1l4V=?0Y=kyfZiO&^PLDbL%j&TbG#u4IHK_I5u|QV8 zX*faj6sR4mKzTkxtyqb3D#glk zp<3aFu?m;u18PaEoXkpMo|mgNbPTJZd2X)O+)7q+^ITcRY4mDVqc`IcwWd!}X?is$ z(Ik1eaV9{tN@W803UzANK#WALVH?lIj-1O7+NxXz iADwM3`~OKkxTQcd0Tpv=cOKv(>;-K7Ox(gn3v0Q!S@TqOJx7-KI&FkDtKO5xN?nO zCbE;pZFN7Nau*Y;=CTy?3s>sh~jfEwr`o-svunXlkG{^gW2sDV-U z_r)jF@%&xk*U;Q^3^mrS&G_?u>?<^P)|?kn*T-JG{SG5a^sO}L zFoWlRiQBg()1ET>i#K;wZGyXiG0clAW9cX&3_Q{Qc%mdsK0 ze*~taOm&>mO{y8WdO+*JBD9~~r7D>=7iPfd>~9Yz32AMPc7EUL&{-aO3T>{;gm>kR zowuFBxF{d!ze(wl3EqX;6>PG>*kjM#J1vT|xmW`BCHcoJQZa6m12b<~4(e%n3@a~# z+2gMqo?eLY>H;uj?)6(V>^P=dWAdTb&ZW^8@=<_0xS5E_1B0RmyFd0lq0Q-BczWgQ z-idoLj&f}4;M?Onf5v!>6lPZ(TbntrxTzhI?MILUqlcf}Y=4Xou)Mqg%p>mX>(K6G zQw5fb3ZRf$mNDN8<3Td$JJxdXSOvxj8IU2~(yzZT?j|QeboXzs!xK(vcRdb+#*xwt>*jfiY;jt<9dkLnteMur)Dh!CWX2W;c~1->u>f*!EMC%}LGeXG6mb zvH!uuRagZiy6d`J3^d-2@y~MT*1h-9Ls=NVE(e2mHr72DjJKj;jg`-@^gG&|B#z0U z@6pEEQ7^Rv#9cYe9uQLY;tR%+{~Tst5hv3H?K3l{!T(~8MM7JQBRjd?@poE!XKhX) zdt>eEOm@G~T{|FrKtqpfVU;F5wK>&DgZanFE=gE)KG)*H#AfR9{WA`HpWlV zpzN1my$Ud%Nkhofqd$*jG~=yQJtxpbWhqnIl9MfNc>meeEUF43TbH^!cIH?=jITwl zwRH~-nvC&k^gQ9-goRuCW4s*M#x7e1ulRvosSPwF>NjS0E<26cM%2)dJ?*-Lim?jD z3h<8F*Opq1apbzaOLi~oJsRWg=n4*<_kB2ladZzx1l#W^yr8+4HMS8wm}ny?2;aP2 z6Hu>@3k^$6vtq-XF;2_ib7q({;v2TR^iY5-y;m@qk8$MQHlB2QFm55n$!Zz+zsk6n z*$NBL63E`#+k3qf+aA%7A_URnq})5?-h=VBR0Acto!4G#9`hjF3+B3j7* zC}Y`-#@-8*>Y5{HDR|U0PBZ+0r$#xrCb-YGU4U_959_bnO?HuCIhM+UsfQ0-8P$O0 zYEc#xol83<`>Q!u^)HqIarso03H|1oYN-lzN2kLO z-*V&m?0)&ppDhe z@sabehuTCql&kgF>R?unm9QP7At}}RZDc&F-!z<{+H!i292Lk4zNP?SgA^hXi0LO; zfyncEPEjTuVihIN)e2O!hE?552>;}gqh0r@BtfN)+eF2 zYbu+>bLA?vuPRabDxP=I_%K_Q597I;#nz_2twriZ@kX@uw8gk0fyEe_yP^wEM?qJYTz4>vjdm108 z?Oh|=gzO@9eoN@dX6{Y&-Plur8Wzj?W&FtD%iB%w-}!YcLm1g7t+GV#;50`VGy4AO zgA5TLMX10;~BrIQtY@l-0a`NmYzCv#JvkK1)hLD8r zKT+|P=RrNTJU2l$(t7@(lHoNxSKfcPB~r#HA3vY(ebmfZGaf>C(zH-s#E1vq{2(oz zq~@wiwbVFp@rP4P`83nuIiU;r3T7)q?kAsP-YEY1luh{Y+^);KWyz(C?Zy$0J|?f> z`RRLlGoo%YjftK9={I~6&&_*JYwY`wDKYsnd&7wBJpX6z^DAWjOJ;?1aAPmWC_XUF zToU`Pf%*4~_tS|Zn_m7A;;C^n!)wh-Ml|d?)jlDLrvVj zICl5w`TI5BDRw5PZ4kL|h2K{x_Z*Q#kP8r-;CW`U@A>!GGgxE~eJ@?^@A?AUu!#+z z%d{Mog1a!Gjq_brp&_jOHcb)o*LBar*Yp~~}FQx4=R5R`+_ z_WzcK+hIvroC$^=)#rDw#gcn<7D#?gT`)TtQx$?Na53I|{a67eTTmvt>P!}||18A> zmN*+09bU4mIvvxS$^wvFoj0U@`&sQN73VD82>LgofF&wn2JbXz4KUF~~N`4%xYk*1w?LfsG8-(qWRV_82D$VRD~NeswD`ZX<^z zo8a8!B#cus2=YIDDDDEr1;`!l+L8b6Er|taIV^ZvRdl@LMePBJY3N_HugmWd7+0cK zTBS!Hmd(XDy0|Pz=E3N-7#GQ52=(&9#27V4^UtlliyYecIXL~!!z$FtVAEBDPrm2= zpAQoT9EqvGICAb5o-HiHUt>I124NwRbn745oFsb4!03i}GHq~4`-~BH9yFq$MOTcw z%izSn2I)ghFkUJH$tiQ;h(Q>CCj*;+*ScM;Fpf@m=ZUkV;*Jd#K*m=;>Q7McFl|nu zHQToAtn$6BHYY~XU|AHqdD>8IPPx*sQn{;or-e2ryl4mrXul=hRK?N!qk~(5aWup~ z`7%DP7ghniwUT@cUcaOR#w+Ep^h@^wLKowk?wWvlWe7RUF)%)o-yh@Xu~zE$Z@s#`$M%(K z8uVri92#{3<1q#B+9kv6Z8*lsASvvu2~n6hVF5Y^!V9j+^?zda~AoV^RUn*jaJW69)Wg6URRlCwdt+(!-D zFLuF_BFehMHhh!1&&QIeC>Oeg48I)Vfn{CMQMhMudb-oJ=2=?RzYz`lKKnzOj5)t5->64#0qPew210|wh?%JEt?~mbvC=|qMB{rW^VkN55=%9#coO0X2 zDK`yAzqI0%9%=rSm3n;O9MXnJ8vfv>^g%l6;_&6T|;ZXT>njJvjC3Ysso-p3|J#7F4rpo98ZSb#BM1b0=;h&}Rdu z=BrPzYF^Dr)g;w(^52M+|9l17jPnaNzg2#L=P_!35ybino_}>^{fIJsw91e0yt;w& zFBI!vcphV1BO_IYM|eSHc=$l&71kjU#0Ql@;(3E1=ct77Do4e0SG5D9cBmW}&$nqD zTcOIa@%(*%&f(Q5hLgzR@qx{1OQ>WmA8*zjCx8bf`|^9)B=6Y#+B12t_mUM_SbJjFN)R9pQKkHMN@<}5bOLR5X428v^y56V7j9?CF8C>DP zS0D;3_jW zw}@Fto}eQJi#PKDw+<7D5ht0e4_2IovQJZzb}jBOcUz_=q<>-oHD{&JSmmgf!x5%ud z1_s`na_?vpr|P{g-?p-HUhdo};mzHwCO+<`nTOxBcxO_*AQbm61*h}}RL%X3`9VSi z{X6u2c2J6Mi|Zle{$$^rKTZ3qx;bx$n>)?~@4bLM5=FmCy+?L=HQlNy5vcnYW;wLz z9C<(89m^=lC-y&8N3C^f%1r7Gk{w!X`t);uCoJ`$*M&b^Jchkqgr!O%8~T2nejKbo~wFJ(3? zcb>C5^c2Pg66o9ERJ^4BWwyL({<#X(awz$IU`P5+F3`k9M?kk>^oXPv7#9@4((?m_ zWzMDA9al?W)0iBo3C}elz{$CX9>Z z@XEBke#`S17ZkzyrC+Yi*So6S4ib{5OP~DwA;dUZvYF#Zy+sD$SRjdp-&yxO5)~L1 z&@hnja5`Iqar6@A{+X-3`?_4y?if7_kZt&|y60GoqZ7!fDV-F&5^;3?s)J%b(MVe= z(|j^wunIPEkc7PX7m6^B%AY)OEa1u=jK|2J)%J>rDgY`nQq6 zUp7uhTK4Ay?0_gKoL3s?IF7_Px)|5H_x6sRjB&Ka{nMR>7|g>s@`H{$m)^ z)Ya$e16E>zFy!qgX1Xj3!Z>=1{_GEDFu438Q9vp3g`D}7?Yj1)hk%LJW)%- z`=V}9-TX-`@SKJ}evA72ScY-*`Y)`-&kk)CV0=9d*Kb5G9zPA^=)Ktpsn^h>_82!t zCL-b5^?rlY9L+zs_UO#k{|-+FBdh}Y;pyXpn+N%S!`2cRznQf^KAHcEan$k5Mfr!` zoWZz(0y0zX<>VaF<|I)~!`l_*DRb9q2MD18+&yb=*G|JYdW)Z$uz#bw0OOGgDD^Mg zvil=;chG3b0tc=SFTr>W4Gq8Q$i3ZmV*xuFZgunXpE3*M$XRxssMn9^ig7e^je?WE z&F*3Q0lL~PEE_h7V=-Q*07;aM$%3gW&Rzf95(uPlBJS6u;eWJtD6~LQ81Uct&K+rt zBO6qE^W>=8i!hF6&evh>-8n5Wjvmo<+*L6>D6iR0%DzGlQWST$*Fo=)iTyqU|F|>@ zvv;8kdZiD2boV*7lZ*3V)-R8{=Qm*74ZTOaX*e;l4aS2`fUAd{OP>TRgCL)3Hu!X- zvGFDBk$^HE+!h+vE=;NzZT% zA-lMIdY>K6Eiqq9tOw!~C&*GbK~}=9FuKMlB;ZJug6npcRdAXBL7d@q7!X z5C>+n3X$h(MR|o&lswPm^yeN<+)lA$8&<1=Rur+ zwtmP8Xr7mHircuD72G_J;S{>HJFCzUC)JZ7+{;RO)3dCk=PP*Rvld|O4%Pzjyhj*o z8BTJRf#-ERJc;#X)|2p@G*FwEO4h_UsfU9MtlIR%v!;jVHupJ`B<`s) zNjx{-$(gF^bt+TE^IBcbg%Ncs7sm5c&b8SQl P@qyg^oXsPCt85<6SF3HIAXQ}x zor-U{>z3;ki)QG=`jM{dXSYn%SN<)`X@eKXRe-Slu9bZ9gvFJ}mBD1`--BQK(jXaOp+w*&A3R6{JVWgi= z@m$<<%%hcJ#{1RJzlRNq;JHmjQr)f$#;~=#viQ@krcI0>Y1&8C#F%o%iw; zf<8n|^DJP}x~)0=Yhnz~1y^@xEL1T6#@@b?OCR8QP-OP%J;#~42?=S!=?8gE8Cw|H zo?(*j)+gOGNm6qXO?X7P?LG1wb9nFUDXvz{%v)~k%X?;*nJ2-oWwqgH%^JGoA0J-E z9Pju-_f+d6JQq$Enm(#vpwr*y8yk=E{G#>W1{a<%ujh#5>&$plM^wLjWk}|}VMH#Q zf)lsr@D+4TtGe#_#Vl`Md10xgq=^e&-OEY4WL7dfWZcY-BbuIV5!9+G{VR{GoQpQ> z+rP=B$@CHC`!>9ZUw=qbpW?2q?Eov+9l7o)XF1t)!J+>QIVV$0{SSL8NBG0Yku#;1 zJ(_k+b(JuOcP3YRKn%9~DvyA;w`BPEq^510D^C?T2!bCSa2lwU4p9HpQ5dzt^>G)G zCb6j77iKy<-S*_;1^fjNl?98&%s+ZK3QK5I4g~GkW>Q9B856n8@&QThFRs8ctg;aN z-;fSzUP3H|Q`r!4>dk~9Z81fFT&C}=r#D5{F)qvj=Jr2_TW-Uo3v~=u58LwWs}&}J zM1>I9XDIcd9C7vhQ|vh_<#7IIr|jrem{_B7L3%CtrdK1zi7Xf$Q<3mE3R9s(KK$63 zq6}<*gI#0PHrGBn0q?p`F(G?-uI@h#k~?M=k8W{Oy8=}JH>{b;_Ukb&mcW1Uf88AZ z4C6vMc#pkGKX)n9ZihgBJ!GqUY>ouuVw!}-3ZoAT^vbm>h~?1mbNj9CLor@g1PeA6 z3=j3dxL5`Y?K?L_kr)@sAZLNlOO%Omq)h}{uiLl2j8|}@p>vnpzhYlu6_hkASd;#y zRjXUt11+cFwAWIrHT^M;JX+3)WpAq;FpgehY#imbXu(`HCpBv$l0v|UuMcZhVHF4| z)VbXJyqm(fTLFCBpBOqj4&$PHSg$u>^Vm#`+Z4bWH{bPt7in{nK)<;29qTzfU#T4+ z$|W#6s{cFd>lm-j2d{e3c!V76$FC83zQcHd9HtCecU_E^m&pNoF*ZY9W921ss8rbY{lyLl&41JF zF%bP}nmv?tc!E^`8EiP|+h+NFjJwKU)z0t6zi(h%EQKAT^`G26k8$Kor22XCn&Ztl z>nIGQ#ji?KjzZ{_w`OQgv#@G#Xae2rro_n;FfJ~DeM{oMi6U?=1G}^-`p!WZ7s;T{ zfdv^8JTdMj2YMP|>ObyQQ!=Jh{SroUXuQ5P$!3bv%;6?x5Icf`ptVr$9n${ z*u8`1qoOjsb!8dGs|&#L`;t~dnTBf|g#i7G!@5SCvRf0-JoGAn@^7&<)!rCKPt~5! z8f($g5##7)c0E6|^Y2a=7v(`>-!`o`+`zUYvN{hs?G2e65QGINF_`z>k$a{+#tAv( z3i_^|oQv&)f^3*_>YYcu1J318_d%~H^*X-+volTQ!Ohve%g6!qv4Aog>iWprt*pX! zc;o`l7(X35c@f5Kjzh)J(DO+ZSf&slQ{4GN?P&b*0BV0p$dBQzPO~YBy%{KWM1%y+ z4-j>I*dNPXXpJ*Qhj)wLf#>X))f1B4aWIK_*oI}y)slw&!96{3K~InhZAHa+>8>G zP%YqsI02{O1YyVtKJqB1`1n8-l88tlrgI9B=cSya?C;J>N}k(s67(}CL3y6UN!E9q zWaW7zCvoS5uo9PS3Q&7EO-$@#HE|Os#GHt(=R`EmMV#oKI*}FKJU8M*y3+wxr1QLv z6ZN{?Sy8X%B$_B;ch&{Cm9Q>=uRz>qZ9^(&8+abc*^EB5tj*xL4QETFQr4F6JczR~ zH?OcZhUcOOhAt%XJ%yiH-@^xN3R$C6&-o;ti?Uf`Wz>c>Ry+^ljF^G#MU@fbd5ev# zaTC_E#*OC@oYAXZZ60WhoSr5?5i>YvNbF*rVM(H`iH?avc}r)P&0U>ho4dLvr~D7! CkUCia delta 18355 zcmZXb30zFw8^>>D2_ef%h=!u<*^AUz%MwY*J}5$I$`V=bMM%P=QbMMEotZm@!ebh; zB&jSV`@Gf=5~>&RKXdO)w>kg&`55l^xo4Sk?>W!!ckZaXWK?;{NJQ(I$mK2d=kN*k zDA3pZL-Uun@2VBv(>MDF@pGQ1x2KQihE0>uA5VXx@j9N{S|3k>(2H8pU$1L;ZihqR z83z3gMhq2(`*u8$Eo^3O6s~kM3{N%Yh4UvFW|tbD(o;vXeLIe7+Yy_u`FhO;Qh!2HrnP*%Q36o%0P&C^S8x2#IMw*N$8534T?Mm1h$U`%11iTZgV| zRypn^Uwb{OH|NO2>J{kR5-$>gCzUt-e7QjN zL*HgTKIq($uJ7&7ajVoL+c)_s2x^VpX2E8Tdv)MDJlv!p_!lC-3bt`vHO%HuTXfEE zTVCR|i{reIfx89hT-klKxevLA3#2+NIu?V@d9w~Di1%~6AhvvUhXbg<`ib|(hH_kZ z#rAW{!>B`Z-;Dbb#_?ePn1rZfh<8ofI=wr5yQs>eIi+k4P_ zv4RjZxVLsn<_aiNr;aH@=ho4dtCmYSZl5xKtt*Wx3i?$uD2w9+uk({}mlQ+`;=ml~ z9gY`HobuHCih@{u>%RGpcO0Le-JI-~U#w7$9kp|bXN|q)-V=n)AYz>T3q{40`XS15 zJsh+=xaiSLs~+Zg_UBv1F5fk^k-Ja6w{*zzc@3l#LPBHaR z0WkZ=7|D<8!D>#b8KwRp`1@e)W!1lvf<;(?!w|AyN6$_7!ZCgXhN|qZhaEkR@e{D3 zBpghSY0lPgFAus zv3o{|b-6GeOso%Q)YM^I6c5R=<2@-!obL55$#9Xf_UA4O(H~`pYD=Whw;i} zhzKmmT6ZKt_j<1+c<%MjutL*BUA{F9dc+7G`XykzJ{2bBXD;~BC&__Sk32dk=2Mso zwz&oq@1IQ4t*A5w-1P6(ZEcsV%cE1kX(R9almk{OsT4R7Qu{hJt}(!J_jLGdIH0KhKa4x2gTcFA4=*{VYAe#zlK}-GX1jT(F`k+M zH)fX}cd5jPpfxVIE;TUlQF^9tjg zrLg+k!~wJ0Wau{RB!!8Go)6hHl;tG4@9fZdN#S@;fmfglR=`6FR?Z(xeKufxi4=G% zzs{e35aW}j;Q7(8&OQ#~sGgv{w)sQO>u}V*s}z>+Hr+I+Kqo*DVkr!&_?b8UA;$G( zaAb8mk2S9_K34{^ZCwUQsxZDl2IawS^&P(Ha>^Ig(~fL?HL6xOz>k(eY2txchdPXB z%iwxYg|gKTT~1t;!7qQ~z#m^Qu9U&#q2q1zDluLlgP6#=y#t;ht{#7MP|W8i861i^ z^xLNdEAUqa>x|P}Zz?eURt7&09GoyL1LIjT5bXBbpA>;{u?!qsyvt3ubG#+fu)i#O z_V9xyWUiq5y(7!GC=+y&K{YL?`)ZGID;bPxsSu4b#W*Dc!TdjQ%WJVGa;ppsy=w2e z+`)LR49;9oxe#&br0$~{B!eASUR+%2hZR6y<4S^Y?RVKPmaS=U>Zz! zX*t;DH@5dlF8a+t*Fur61Mpfzupm2p^*F6UE_tI=b9t}=QoPu)#)P}Lg! zwl$a0Z(2?ecC6kb>zx?E#|36)H&+Wp{%A%Za>}t-qbR)?Macs;f71=X=P8~*9uWfJrEknUP zVCpRz7*9mLuDE@bd@RMs)sq@TI9uTwTHP zzaN(bAQKfCGwE3qlNP+-XZ)z`3ba(8FLYM!<0^8We)$oPLg(cwqojizkG}N9&0;UA z=*v`__eVHxqk7}<47ohMtKOV)D<-X)FE`etDAgU6ZgiunMX-Q3PSwNaIN!c zwQtoN;%0_seh~`7xb5qY1@Ro;I_r<~B4nJ!zxYvUsT>!7$|v3;`)3uY|8$_78c15&RjsLs3fCs}^yxN_x>`g6AxE;knK@5Q%r(0(uCp4C|K-usHu znN!LP+t1>-ZC1NhWbD6+UsJ6*&aqzA7@$m#PM&J|UGeKw!1tOJ{*7F)$~NGYS>L?< zM>FSNI=8El8=u>tobqshgJ?$Sw04UQG;(Llui~l!*s?}!1rLYEYr2%Nu8u^#q}ZNr z2l=GT-K;$!)4H6W06Rkh=C~Wk zbvYFeYqpH-tOM#tZ&vF5V3)5lI z_j`xix6N%Vz;I<6G*qojSg-=)r5Ug*ZNRb#a*T^JptgLKr1m$)g%T2~MlM}(dh!LV zflLU_`kk~O7~>{1O#NrWy2%9?=SyJ7`h^$BW*2qqv5`RRs2R=7$73A1w-y<`9#i~D zEP!ldt-$@>uLO)2Na4~^>-h`sVcbLp*4y?B^KHPmu@nqP?l5rfdr7xLNcv_D-daga z*Kkrh{diKad$2w-YCTo}b?Eryd|%TLj0Z_z&BX5UCz3EOL|>qz^$-&U#!)?=XM6lU zb6=N}#AFF{RyI_Qd8->BTqJPT-mm1%4~!Q{;M1(KaH&4%ezWOPSoa`#z;PptyGbG5 z>38gzP8iRU!sZS3WY;@gbpzCJ87wObs4(lM%ZWWQnD=R_Q#5uxaRm7xzratU@CFvk zfHz>FZ(SR#o{`7}7KevF)>Csd{^+2XPa7FTeXAJz^gH&AyUW0~$KS>EuQ9HaLjCmY zhW__3j&=ZE*G3Fk4;T-Y!Uj6-*V%+7yoI`DCuw%c$!SJpb z_Jp+}9ZM2qwUw@;{ z0b;B`sSL8rLXD^mIG4hD=Yy+y*kYV7g@p}n|BWCpj-JTsPd10L^0jkWYa7v%*C9N8 z`_8@Efad<7IVB2B2;1s_akS1B8U#p!>af+tn1=XoCVpfF#;Y@+nwb4);$n=GR3@A? zkH41K0t*OI;WypQV~Ye^9!sTAIuk^DXJZ^Ko0a;T|Atjz>#s@*9qoq95CmZy+0_T9 zj}?-MUGP9U^p)qD8zo=~fj}D^)>jXW>5uVJIn=w{iMg1HXB-LWQ7s}(dSe{zBW|KH z|0=_njK<6bO8v|cstm}r|2?D4Pb@W}TeIQT9M@qBF)mJq>32stI!Un{i#9xiypG-) zQ;+3pWdb-)Ie9@kswr2uuady?&RI_f7Gg7W3Aww&=s-`*aTAAOy@}_Gj<+#GOoV`m zf#am$`Pim5u@S5_dW@LK=&?MeVYJ8yHTrF~h|zCaP7r3S-Xr5qGlGu`j6n(!3B>P? zj6mdgg+@`%ViYCEH40R9lTn}?U&bm{!jw_0_L>e6MAall;S#LEZDJcWl31L_NMf!4 zU!$P~jE3g8SVwbnT%^(HHjGB+IBzzi=_%fCwWil_67{RzfHeVB8?_1G3T)N7hFZ02 z;JC3H>oWLr)GmYLsuzqaq4MUaT?xktjf)`|7sGMm8J8cCjO}@-wmn>+(w*^11OaNB z#PO}mG`=cS?W;H*6s+-KAJjgK<5nFtzO7#E+c=(oi}iU_eos?m^teFhvl?T#PHhaE z*hU^b!I@lB?YWr@w; zx0a*%(0q|}D>7l!g5u2jCax~J#YTs4WEc52>QYM4yEg4ne^sA~+NU51W$}Mky2f$= z_b#ucJCI!z6T1R(o47aL57R|FRIxafm+&)%yPiL@Pp9``hzq0E4@B?aw1-ok?ZXX` zsNpfgjeX8@Txj{e>m%d>3Aex~{)HyCQTU5rx*6F()ylQxCgD%#e+&%AoQ_yym#^r^ma3r3!(mzMDt9g@d*~MCC2>ELpaqRJiYhq+qIs zs~^=;Ti<10E-0d@b>4FW7IOub?D2mXb44-Wz@+MAVr>&Xe*UVM0)^hlBTv4@Y~*;> zPlH(p?vV*nc2B ztg2oyF8n{$l+leZ{|NEi>$A64TI3xG?RTNw@rcIj`8OZYW}br_KAfF6)+zTyBfl*Y zh1f1QqCKbBk=PA}Nvqe^O4xlw5HFxUF4Vp_4rZF#Jzey&F$b~*sNHsBk5;YR zZi6LdRRRdzUR({?geUhT`1k#^g|0D}sz4iwg+I3!oz28#3sQZ0#^m`e-zAv9LOC#Y z`Lb1LV-g!W2}~sC4XW9DS(o!u06csSu3W6p<;HS&vvcCBF_w9{oF@a1kCq=@DiJ3& z-)*t<)``N`sfHyIhG%#<(~Ip82*a>--e`ftahz>mkO=1g4E=Xc1s7oZC4t%d&2nOUT-B`z*+Ai=x3tS*jPsnMvQ!hWV-GuRK86@-H*^ z$BD`@?jnVnKl%f=zsGp06gnHHof+~|my>Ftwr15CN80eZ?l-QKfc5#|na%#ec%l?~ zuWET_s2Rr5TQP52Oa4epjH9<){ocIO|7S49d(#ly4@miaYuy0lK|^JAgV1j{#<$SW zCI6E0^DtdbY^GsiYthabLox13LrJ^+s{I2n?o7jnETdg#%+(x?KRPJpa}5ojdwic1 z-W@C8PJ`G&xMg{JjN74ys8^RvLLcKsG}QcCP~cyqJJduo8U`)gQ%9?s@SHi#^=2E9 zH^Se0-db)v+ix$%Lupvxc-5l86XO*$ zWcM2v=r{EmW*C(;#EhzvY_-4&@a1r!r$tl?0^?#D4(|~?X!{78OhOu7S&qsgWfi?^eYd!bJ{U)npxLw^-Mf6o))iU~mxIlR z9z2h63b`I1vBk&j7$>czVDi;hZf1`KkYO}AQy^>EfGvzXIrORxD4=pNjuu9zX01AS z3NcQ|p(xApREPz}#ps3TrQ1Krs}JxcJQH58B_xk2j0;i2pNe-!TjBgH0B?2iwkRyu zP&ABg-FLD611vYGG9m3(z~R9y7|zTBb`l7r@YFe-=R6ooa@I6h2Us2vJ7GzYmja60 zA0=)Juq28$W!+Qz-3)TavM!MTf>xQ%_A{DhX?6Q(g&l2Owe8>#EUk;>;51~(*+4x^ z1}Gz8M)O>WTYjT#V7~wn16i{>*c5Hl(HUqq#R3)4$K+HeY}1#>gxRF%&iD68nB}GR zLSXsCjHr=Ktu5*(6%1{k?mqhYEG~%r(7R+-iP@cFlvp0RT76JTjdFX+DmN`Bhy$$B zBlodVj|(&$e{~B_8jzz(ViUlVzsKA)v6qKW3_EyFr#fr zE}#*^d-gD5nB!XY?9ZrYj+?M*o9M-;ZH^mj)OkIl&h6QOK%XwGnpbUQ)Vzk1>cCG{ z{@XC}pDSQ!#rg%8d1}AFalXc1l#W*W3y!y7{fN?m@gp1;eQ)YtIBwYWwUksF9zsuT zc(_18KI4!G;=bA-alEuS>!_4@YDdNK&}JG3wp8uFIR04c*#1>JHjcN}I6T^Q1c@vj z7YNi?LP3Vw5^`J=_WGb0Sz|H1c&+6vg=R=8qAEuixCS*SdYZ~VaGT@GUdP01L(qB6 z-$PH6v>eT}*57Kzq8EkY4JM~LGQXBok3TwGj_q$=6^vfERZmIm-Ndq0zB#I@K)>@; zzEQ@EML(O=9?|XA?EQ@100#A|&#QmWap9@~tKNny2(Qs2)&w-+(RDMg??rDAKlMmz zA8z5Gt%h(Rlk0!goK%#qE~(Aa*IF|at`5=nxF}Y*OfIzWD|hD#c-=_dJ}go3z_>+< zYK14qt?7$(v8jr)lDA9ry9=A}=9b?DQpKTL75?sPw{YB8ls{NMThW|caeH@v@lGz_ zHDL-dGFS0-s?n&eH8O(cW5Ygz3Dl= z*Rvu;x1twan)eLjI30ebgU4vw6gd{F80c} zd2jGwhiP^Nkslr;HS!(V=I(1}L^zO|8$z*vQ;^_i{&Zdg?gza<*wF1|qy$?QiQQ0h zXsTDrUwnOafn$aj{X+AxEm1-Y*ULJ-a~|B72sG{U6YQcL_CGx1hGi5Y9=J>$BfIv%z`WdI4kn+JS+LsHaeWE-2n(oa zNdI@q)Y*$Mfr)Z-`S}*@Ey^)YrNQB8b9*8OqrJE6twg{1IlN^~NWcY*BcIsWCMP1j z&rRlf_4u;|&^L%Q3EOvOKO1P|=oToN*^G>SgK?e&T3)f>mpByYHq6Taqd~SEwnbu` zF9oBGPt&ix)#0dpB+vwt9TqA zw{;t)2BQe(MlN-(P)D%%=@9kToYg6GT`6WGrV!zIy`M7AA9$}6+m%`wg;|3Yd$2f9Fy?QUdpR@ww-O*k^WbNe|pLJLOdG*H^#ZIe) z7{5h>N#G+muu+#&wKTke<{nQmPJE!j^+nR|6@J+D3L1(Zc0Aa{o74>uDKzMBb?^Ce z6~<#|`1Gr`ed~o7_eaK3a%kD485rl&V6}Pa(D<GH^W> za0ZOA0$#}YwclpxU5DMvdMVtUQv1#73C59uoOvqw#D_~5r)bE9(v*}Fx|}3LG#v4| zeRAF=-2hQd!!w&#_bO*#oJK3-oP&XGJdE4OVUeC>SIAdvc5I~~^$Bmw_B@O`(GY0= zkqqq;f(1-yfB~z#r_I5*SOycU8hFG%80VpRTq1971@(_0T(HUkW?AVM0t$4dX0nqJ4Y1dvOLZ}Iot;!{|PqNGqA zv2Ew+E*Q6_q1Bhd;fWzw4x|#H{J_q(BkHkSDoBA}ZRY{H_XG5 zGFq5B-WMIM?TT@676?9IIqQ20u>1#p67jd@wHJ^unz!N|`Mia-L6R4cgAtb)@92txlHqxej$7{$l&sjNbDy~Zd+j=Qjmato^{Ij+&4!L0t| zxD~5cR~5Y=)q=H2fEBneS%J%OjUZm_zzAZF3t0iZXcQx$Ic~x#?m|{@bDYO2bk{;g zp(9SRV}Z5>7)dXbGLoJvP;i~G0D_K;1>pGBLyTqMPhl(r$6Z*9A@E`>2FGn!PqN`N z<4HJ9@^nm$y{0?JlW0s2#h4zBtKPCEN%U52k~r=Z#+oYPv)WW~++E|sC||V;<9HS8 z+H45wyV|yK0ZL=@giq8qkKR;iIZ(-F%! z&aYVTs^t;IsV?KbU9MZrabd}c`OaYq(t3Z_laJaoabn7bHcn$A6hn@$bEigc<_eU$ zFZr7grLeQOu~hzFAjhq5bo;O1q@thdecP596vqq3k9)RGte9kwuz0v-5Xb8cPE;RA zP;B&>Sf2CkK;t5YetzyM&s?9Pc;p*r zjhsL7TT1M84O!d72?9Q?eV zJYrIG<1((fKEqCa>d7(temdy@wT}|crS;RFcNS<9i{^SF-p+O9v#5pJiWkEL)T70SN8n>@$}R|Il6 zweESbpa|nc8o1oaKizx}CS6qL;99%wFKY*55=fa1pPvk*zLX-a9)EOD%%_-!?Wfu& zA6<`$HS{ai%2^wVSNy>^KNY&y-aG#MAf`f<5;##3rSxrghq=d%^&4kFQIBeoe<;V< z_Em9k+f1Be+pJi(071hgvx^n&wqRT=f&E^?ibuS}INC%HuDedZaw^fSM?iynVMF%Z zbew0A02|tUS!hs-6_A5l`tG}3hhm&}9*%WO9}(b=aefv|FEp+{NMamqO`AU+ze13R zaX~ix`g&_@tDATMQ5JOHT=F~Y9acb;4KCMCeQ43*u5L%g*{~{p`QVLxFm9LyinoG~ zDm#p;}-B7%!kK>Bctm08u0B8;Pk*Y8~FSXGAcP&q)k zt>Eo5jEm&pv1RLRv)35^BZtpn*T|DGl~}+7J*6urc)EYY_@OKa5%}^KRbf0L3j&7u z6^ZfdH)p}e78k7ty~nO!ngzXr2KV~SbO?=qW>_QSN{4#s!L!S00qi+fiwE|9}9$3)rdb4@toC`{xz@AA}+qKr)3I5ee6SlziQ z8h(wK94UN3XESU3q>ui}7R)EL`y*Zngw`_}X)Ud#}O^x>#Z0;b7b6~@XRuv@}7s}z2+rk!n zsg`RUg)thana{*0L$m?S`p82Aem~^3$^+vnDHOi79ngF{#(CLb(Z;G%Lr07gQph#> zX}IkUwj7bjD|Ieh;pij80%&_~*vXBlm)c>R%7R_@+iY-5#nwTTiiRC|FnUNMq;lc2^tH{0!umJi`h_hcsw_W!XTj5=@V2bS41ji*9H_m}Uo0naU zF2^#3l7__3sg<_)_5d=`?XEu`(c&VLqL|4*F+EaBVNvnKe;)V2au-@H#GRLPiP(qb zI<)Ut@N{@^mzQ{MOoF{ZFI!Ky!8mmqjs>sX);qXq?p3$1l!NV8a=iHN|7YvkhdbN6 z>5Oso<4{MRJ2S?+Vp*R$1}=&c^BEzSN}x`_(FkLcg$m5}DrK;U40zb8|JOzt!j1&t z4X0L-YghEgIR$g)E%sO!prdEdH}D3YMv%Q^1z8?5qG+L4jbH`bbXLG=IYFFf1t0mD zReW5a7)eB=5a+TAk>eUk`H_{B92c_^bOS3vId05KR(Dpia@>iPxNbifiAy#HsBl&j z3n~~*+{g(YE26zw5zTRp=&oQzH^*sKq$jc>o#QH2)W2Xwy@r!$py)Y_3wW@RaRFQb zWi!S$^x44J29D>lHls%~#%6H5^g3fpTK>z}5{_H5Hs(QJ#>O<^f7&>a$oFiGVtfx5 z;FmH+$?gE-lQ=FcXN;9cH^x|TJeoCPl^Ki?<9HEk+^Rn^#*O0@tkI)hZdhiDoSrs7 i5j$9CNMte2FfVGDnVy+kc~|d%^#i>e>j(O|)BXoYPCTgq diff --git a/src/docs/sphinx/advancedExamples/validationStudies/proppantSlotTest/Example.rst b/src/docs/sphinx/advancedExamples/validationStudies/proppantSlotTest/Example.rst index 627e7c7d7e5..d1ed7447c86 100644 --- a/src/docs/sphinx/advancedExamples/validationStudies/proppantSlotTest/Example.rst +++ b/src/docs/sphinx/advancedExamples/validationStudies/proppantSlotTest/Example.rst @@ -91,7 +91,7 @@ As demonstrated in this example, to setup a coupled proppant transport solver, w - the proppant transport solver for the fracture region, a solver of type ``ProppantTransport`` called here ``ProppantTransport`` (see :ref:`ProppantTransport` for more information), -.. literalinclude:: ../../../../../../inputFiles/proppant/ProppantSlotTest_base.xml +.. literalinclude:: ../../../../../../inputFiles/proppant/ProppantSlotTest_benchmark.xml :language: xml :start-after: :end-before: @@ -99,7 +99,7 @@ As demonstrated in this example, to setup a coupled proppant transport solver, w - the single-phase flow solver, a solver of type ``SinglePhaseProppantFVM`` called here ``SinglePhaseFVM``, -.. literalinclude:: ../../../../../../inputFiles/proppant/ProppantSlotTest_base.xml +.. literalinclude:: ../../../../../../inputFiles/proppant/ProppantSlotTest_benchmark.xml :language: xml :start-after: :end-before: @@ -107,7 +107,7 @@ As demonstrated in this example, to setup a coupled proppant transport solver, w - the coupling solver (``FlowProppantTransport``) that binds the two single-physics solvers above, which is named as ``FlowProppantTransport`` -.. literalinclude:: ../../../../../../inputFiles/proppant/ProppantSlotTest_base.xml +.. literalinclude:: ../../../../../../inputFiles/proppant/ProppantSlotTest_benchmark.xml :language: xml :start-after: :end-before: diff --git a/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/Example.rst b/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/Example.rst index f6d088dd3af..dbea2079f9a 100644 --- a/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/Example.rst +++ b/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/Example.rst @@ -25,7 +25,7 @@ Everything required is contained within two GEOSX input files and one mesh file .. code-block:: console - inputFiles/lagrangianContactMechanics/crackInPlane_ref.msh + inputFiles/lagrangianContactMechanics/crackInPlane_benchmark.msh ------------------------------------------------------------------ @@ -122,7 +122,7 @@ Constitutive laws For this specific problem, we simulate the elastic deformation and fracture slippage caused by uniaxial compression. A homogeneous and isotropic domain with one solid material is assumed, with mechanical properties specified in the ``Constitutive`` section. -Fracture surface slippage is assumed to be governed by the Coulomb failure criterion. The contact constitutive behavior is named ``fractureMaterial`` in the ``Coulomb`` block, where cohesion ``cohesion="0.0"`` and friction angle ``frictionAngle="0.523598776"`` are specified. +Fracture surface slippage is assumed to be governed by the Coulomb failure criterion. The contact constitutive behavior is named ``fractureMaterial`` in the ``Coulomb`` block, where cohesion ``cohesion="0.0"`` and friction coefficient ``frictionCoefficient="0.577350269"`` are specified. .. literalinclude:: ../../../../../../inputFiles/lagrangianContactMechanics/ContactMechanics_SingleFracCompression_base.xml :language: xml @@ -143,7 +143,7 @@ Time history function In the ``Tasks`` section, ``PackCollection`` tasks are defined to collect time history information from fields. Either the entire field or specified named sets of indices in the field can be collected. -In this example, ``tractionCollection`` and ``displacementJumpCollection`` tasks are specified to output the local traction ``fieldName="traction"`` and relative displacement ``fieldName="localJump"`` on the fracture surface. +In this example, ``tractionCollection`` and ``displacementJumpCollection`` tasks are specified to output the local traction ``fieldName="traction"`` and relative displacement ``fieldName="displacementJump"`` on the fracture surface. .. literalinclude:: ../../../../../../inputFiles/lagrangianContactMechanics/ContactMechanics_SingleFracCompression_base.xml :language: xml @@ -203,7 +203,7 @@ Inspecting results --------------------------------- We request VTK-format output files and use Paraview to visualize the results. -The following figure shows the distribution of :math:`u_{yy}` in the computational domain. +The following figure shows the distribution of :math:`u_{y}` in the computational domain. .. _problemVerificationFig1: .. figure:: displacement_yy.png @@ -211,7 +211,7 @@ The following figure shows the distribution of :math:`u_{yy}` in the computation :width: 1000 :figclass: align-center - Simulation result of :math:`u_{yy}` + Simulation result of :math:`u_{y}` The next figure shows the distribution of relative shear displacement values on the fracture surface. @@ -253,13 +253,13 @@ The figure below shows a comparison between the numerical predictions (marks) an self.inc = inclination; self.stress = stress; self.scaling = ( 4 * (1 - nu**2) ) / E; - self.frictionAngle = mechanicalParameters["frictionAngle"] + self.frictionCoefficient = mechanicalParameters["frictionCoefficient"] def computeNormalTraction(self, x): return -self.stress*pow(sin(self.inc),2); def computeShearDisplacement(self, x): - return self.scaling*(self.stress*sin(self.inc)*(cos(self.inc)-sin(self.inc)*tan(self.frictionAngle)))*pow((self.halfLength**2-(self.halfLength-x-1.)**2),0.5); + return self.scaling*(self.stress*sin(self.inc)*(cos(self.inc)-sin(self.inc)*self.frictionCoefficient))*pow((self.halfLength**2-(self.halfLength-x-1.)**2),0.5); def getMechanicalParametersFromXML( xmlFilePath ): @@ -267,12 +267,12 @@ The figure below shows a comparison between the numerical predictions (marks) an param = tree.find('Constitutive/ElasticIsotropic') - mechanicalParameters = dict.fromkeys(["bulkModulus", "shearModulus", "frictionAngle"]) + mechanicalParameters = dict.fromkeys(["bulkModulus", "shearModulus", "frictionCoefficient"]) mechanicalParameters["bulkModulus"] = float(param.get("defaultBulkModulus")) mechanicalParameters["shearModulus"] = float(param.get("defaultShearModulus")) param = tree.find('Constitutive/Coulomb') - mechanicalParameters["frictionAngle"] = float(param.get("frictionAngle")) + mechanicalParameters["frictionCoefficient"] = float(param.get("frictionCoefficient")) return mechanicalParameters @@ -331,7 +331,7 @@ The figure below shows a comparison between the numerical predictions (marks) an # Local Shear Displacement hf = h5py.File(hdf5File2Path, 'r') - jump = hf.get('localJump') + jump = hf.get('displacementJump') jump = np.array(jump) displacementJump = jump[0,:,1] diff --git a/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/displacementJump_history.hdf5 b/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/displacementJump_history.hdf5 index 6914bf2c0fbc8d21030b6f488fe5f978a2ee49a6..8808642e8d300d21f17fbfac6631187809424686 100644 GIT binary patch delta 12110 zcmZYFd0b83`Z(}yh)R^CG8Tm-R2m)j4oxbRgbYoZ(}ct)v5!n4M2VD&NF^zea_W?5 z_%w-<&_pDe2^rGwS!*x%d(Zvde?Is1?0wcc?X~u^p7(h)*NQdQibZ7)QqIX4KG~xF!?{^KkhzTg8W?FJp4TZf-ScC2mQVJzj0*`KYY&;xX)uVMg4!*?S1?`q9+Zx zIV8I#Habu?E;neXrc`wOJn`r>8Rh5_WAWU2nS?>;YHpyc?#SU$HLW2*sel_%%HK1~PtEVP^gr zg)A6{8~-j#CaBbq_!0m0;eRH0Kqlzgez5)M!}kA7P)H{5Zmw>~(mv1Qml#x@{F)^E zwkf;sP1h8r!8tO2c3-W4Qq*2~OV*#(pO$yW&q|-UEBED1l~S{STD&1mc~KH=TD@{% zfTIz^j*kqKIH}bjpz=T7;;r8!wPym`=LYO^y8+`HIA-5kLJxk@v8PvIC1dMu`Qv5CF^KQDEB}zSq@@;h z9}!bn#a!Rk7oHlN0vB4#1RIToXB-+l?#ZlXW)7X4Fuq&}6HI99DbW%dsa<%sXqW?I zR+%uR{qr#aMcv(aCSkU4?bn!HcHbQszvI7594FO5JXUd994(~F-`-mKat)K6T{~&t zQWQ@!k=v|GOU4vjJI2OQR#n=U~-xZ&$$p0M}igwBv~N2cLyVe{gtsW48U@w#1$=pgr& zVZYs+m|vE=gI=7z1@|A24;QzfN6qseu5awjJjl}D#ws6=fe$QvGR?$Bm{H)}U^?1` z5sJMx_s_Wl@lhXjES3s)dS|}mvo4Ixthn#33o~YNwMqN> zvoL{s@Bx)6^p%;9)fTOFWmxv4h@Nt|pJJm5 zj$JJ($?#g_GH(O3ENJ<`nEHCS@Z_|AyuMIDVdmo>i5nPp>AC1g>0B77#6QXG%fjC~ zT4SC_xG~lhnM(FwZbDpa!OTTgbimhIR<>GrJ%BYHCuio)+?Dv(QEFxbOnhyE*XQ|kz?s=v%~#!-6GyW5 zZ`y!%Z&2@nKN@snVzAgcMGt0vzvS*LZ?qXJw34K3>DsMz)HBwD8PfeYDkHua;+lur zQkKx~k9%!*>GELa#EYqgJjjQ5`MB1H>x2i3;&k(^JQ+pS#&y!;r3nIxikL9yw3hH_ zM}ou5Tu;X6@cNE_@51Xx@yAlTE$Kk9{!zOXy_hL$e=vg|OZH7x?iI-=@*ou!I(mT>Zgeu{Yy(BA6{I ztLCv3r5w+*l%<=HZpS-?SDS45$zSvBVhw(^d5UQSi5B-qc!b#cwF1R zFhR?0IZrKG|K(?E&53?YV~G2(n-tn~;@>v8*a_1{6&S2q!}>87ht-(oIF-SL4slyC zF@>lg#^j-5Myst7kF-hVOZrazOqZqHc7Yt=AN zQ~UmJCiE%O$q~kF{>*J}N0UJl&?epgqCCY|$O~Aqa^#Qzrmta%smrTu7$-=Ow_&_+ z!>l?7t7!qu2`2{|w;SlJS=GwwJTavooGi#;Oahq4OT!xsBCB8^e&Ur1GhyM!6Dge= z0vNlI_Epbkp(U{08Gl5HKBW--NPAZRlQvDFj~7`0@tWcnS~NYxa9HNpQvu9*@%Q0n z;`K0rx!C@5JfWj`y3eXB0Zc;2{)1}PC|(k%rXWQdRV-!ac-#(Pv==@2B3S$sF7PGm z-u_-_^|N!aSwjGm8!_pdmLr^6lu=3Pwca8PlW4`R=K+lPgxe95)2{L$GhSl8PN7#U zmGp4<7{HWAs(9B6&{@!TCg-;neKY84_mN)#%&BcwJtMYVf^q7PCPd8<4!pQ?VC&F8 zW_+92)P?2+k8^Fb4=b_;6W;t-EWEPo@q*uyflPXCv(2+bkKr>>J6(l(w6!g(xVCms@G(sjPI0xncW6vCJFqUG?HU9eYw(b!nD zI(-(N@W=i7_s}c!$4N@BzFaDCO#m;>^K^I^ewAr%=wT?k&Ku#s0KJ)fha1_wMfuky z70|=8SMp09IpYz;OE!G!`n}M1jo~8nuvzh6%~Ng#p{K`}dn+eJQ~zGmK&!LB>CxI< zvMAX}8S`K{)vPVO(Q=;A|Ht)RND;)B{T6E18)Da6?2A3IiC*l?x;zk$gehdjdM z_rL`MRsvpG-C?KjD=QziEpAf(JW~$N(^opN8;J)Fr8d@^`kVHrc>l-p~ zO4#dNQ?@q~sxj(%(JM$H)y>5?g^bAAU0tt_CZ;Cx2Z_ zH=PbiYW&1b{Z(uHn4Zt4qF1d!o8J^DwXU#!Ri1Jk$F^#q^&%;Uc-No)@)lsPsPoq1%ROtO}cX5)v!Q&le!%v{KPcxNQ zT_`L)K0*s+<$Knh=3X)f1n`%wJojv{Fm!xAPUGcz1@<$bn+I~U;h3`7ZD(IMGG9&k5+8dK}U7J*{#`04{pIg4OQ)MwA)swY(q!;=Pfx+ z^#||3{eH7hDIobEc%TDHf#&N;32~vQ>QdWv1WJeNm109t=|H`nJ10JN8H|&;%@azE zU-oHpQK?bLuKU*g))JjJw_l>-WUhI-0;)~49$v_d>}-elV&fJlX2iFy9)^mU!k&h4 z;<_lCo_>akpVFtM6H)Qw5R$7rqcxKU2}dIiiY2Ah11C_iq!elB6Y7TQPwk)pD6Sm7 z%zK22tC?=EJM;c&5kM(G1zkUSwP@MgwG67p^embUOx`!a2STe}L-{7}e$^C}Z@&}F zroEXgfVj>)RPG%sI5i!Wd&RL5Ci5@ug^4v}P(aLXwAZ}u;3*}_( zA;V5oPWn&Vy6$crS~9io(@ktx;jJ;P^{D<#Fr6a(=_*>|^OF0aV0}BFG#C}E)VavO zz`ILepz*^UpunBlYB>lMxL-dT*9=#_2J!CnAxb>q&&_LEQ9&HXFjw_r&}Ov%ItdDB z{oiJnQ335d=3>;vySL$f!SM@FaJvl7G+$A`u457(Um4|a2fdfgFUCWO9;!Ye^B7d< za_+NMygmQB#vJ3tJJtO!R$3_(S#?+DiHJWL>zQ+jAg`D5uAsCq|H|X^Il3Gibu?g(mduE8jvQSI@G;J0Sh;n zXs93-CXO8wobeLA5P#Y{D`2G6z&Zh9f~oeM@L!u@NttbmxwkCO}^Eva9Lh6DXj~IUp}0Kpv?jHs9y<*~;8|b{0~s zDW_y>qU5usX)`ml;N7p}kX%TRJiI}>M0YOa3jPj^K#Ai>0hR z*58NHyC{+$U4Aqsr~Wa-IV7_bQL^%#+r=j19>N3(7|A;ck`qk*a{eSi(kYpZk-VB9 zd7|`+(pKjSFwiB8WCeoc#xY?FWz zjh(FrnMG;V;E%eFUcdvmK=BchiwKfu8A@*)HY66}jTp&e z36fRRqJQf+peNLUk^GY&xuzjVe&k|Qm=3{6_9IB{>sdB+$4f-a4vgfP1j*k|x3F=W zFG7Cj`(Y(t3*eA^pz3sqqI5D$oGpUn5vsk5Oy8rm48}-qAV`jp)cO5({#lrSLvl4i za!BS2)m?{5AwCx)`5i&>(L4RMeXroj@mWsE5k$%D=hx*MZ9$KYLvkcRGA%YWbk+-W zPVB)*_9IBndupuSx4jMGb1;(436hg7Rm%_jLMAo9NbV*`w%l+>x%^Z)#6vKWhp|M- zEp5MR&iz1-Nc3kyDf?HnaTz*5M1Ll{?!=FGlY0vHbEtkuP@P!*$MVjI3W!%?RIewf z&RA1ca@-&N>=1-e?MhJ1dIz2B^_-11Q8HGw2~o9q%16HCtOSU2svb*J{d|1by@_II zph~1_p)^5thFZjwkDKct&Y^k)L3LYeh=+L>ssm*(s_~2C<#r>p<0umI=9$aDgR6+ zjH8B8y^Nr`Th>^i(*i9)1fZIoEsP|pHo6}Br^;g^T;NolOH^H`A@$O*9wi(ptm-79 z>W|Io)OIbjS2$F^A*h~^ATcE4pQA8NJw|l^L3N{jxYf@h^dy=ws-qFASwO>)4yX0? z4)@{0UaV>ZqUyBI$HaadN4wV+tJ;~UTJv;HV}&a!uU54pRNp74K9v!{#Dr!+JPf1y z7D0959@)J;At=#tsE#41zS?Hf#P(i6#RjM90Rv9emEpfemlU_a2duEF*AZ1a^t&%@ zHbZB4GFJ71ilrFUzrN&}26tvayac1#jG($&Q(Eev@dFeuMyOUJs1D<~8D5xC3~>h* ztJ;pJdiXo`wp3C%kD_|9s&k2|tqVJTTvSC*q8Y3D4^g#;!kt~3C(s0XSk!4m)CN}% z4qUlc1948&Rz%eHlDGYa+-!t6C+cQfmLqkQ?6}F1PnzI@CMLBtA+_zJ2>Y$?(s=Mq zF{ynBsjnryPaacr7vdbLONpqXa&GGe2vZ=Qk45c9MBOiAerZ=~4a9q~sQZYheTT=S zEVh-XLG;H3kGeyaiJO&vvaVjor$Vriyr74R6-io#HyZ7RPDPfXxI5O z=ONCix|XP#RhGFZZK{m&xG`pRGGVpni5C?Ln%5!DvD$&KI(}?xc)StHb_;;j+QR!p z)o0p2Ejg6~H3d<%4pDX6?oCfw{JVe=R`mj+YT1gH`OB(uP%`3J?Lb()W4=M%Nxer9 z&lX{IUpF0jWG1>O{n9P<874FP^(G!^5$v#}QRWsc-I!vP9=c8dh}zQT3HE z4yQhhLbU)=HETvo5>|Hx*r^_KL)ngFwH0CYf1!sWwu2VjX$+RoKy97qUu}k4;cEKc?jbKVO2jzs%GKW)Z`Nyfs5MC!UsAqt6K=G zHO}&*4y>wz_;$={bHeI?jAgFbi%=b?j8&aZRK4Z+p7DSB(2f`FW3B4nadu+bD~LCW z^s!zXPIh8t%1|Evg&Cep7#=a)Z_~j)=+W)P40j|9|Df8fDr=qwaYfAV-Gt$$^Pc65 z(QSos+AzbH5{6H-w*Bxq?K#BvV}{R5=M)|`_0FreWv~SNP!==1i7?!2<}AnXbK4F|{CIa0K46R)E=Cxxy2}2G`+3ChSj_Me!f;*Ryu#jZNVj~< z@X3VXGgoX-j(>%-BWCz&!f@NZ31&B39>e{d!mWtH=d<>IEF?amgCYboT#hijwEMc+ z0*7WE{AHNoM+w8n-reuOt3XSpjv1~@7(Sv(NiSzRn%E38yoNCR>Dj@{AKXV@6f<0y zPZX{v9+}=6REk;z=P<*22*a~wUpqg}4~7ZGVTLOchJQ}I?H@4)>PG4XX7~@n@Uz;7 zYRaZxhPW+exE5i!KxK-23({0G*aD#i-;!U|_sF>9W^hzY4Fgb$cuhDQ;GE5!{cxQCv zp?sJ)OoZXKn$3S=WU2%d{~~616=C>7?Iqt&M#0I**Z2Q#g`cqc;Mm7LLc84@GdzVb zJl2rf8hQ~lT*5KDlQ2AQ;#_@GSvbS_vqTskI@ekKW)5s#{!|f$n?&96@eR2vpprR; z2OcTI3V-pwaOHI|IC)PiRVW8N%?3^5*r<`p*TF1t)OJ>Xj^RR96;0 zjvgq2iPJcO3kbnWa(iw?gpYkX^M{pI=rxqTzQ$KSN5)Pju z_!!cswk$EW%lOs>OKBj|r!HP8<~QTz^6uPY2jF)Be!K|7f1P*Ue%`VZ2ICmMhA{k; z^LE`mUFhiL82-0cU9eV~%QjT1iT0|WeVIGT;1{|-0{5yVh{AWRnrK|x&gKcA zs1RXz!EuY$Ts`y`$Y6%=A`GuzbbpM~X(Xj=5r&8Agsax(l|$SCGdznh+_YgdUuRPz z#Px8m8ZjIxe4>B#kX_-@aE-0KuzXvO*v~2yL zj(#u@?NuL%ovkn=@d?DaUUd^;`12impV{87giXpZyoNA*)ZL;^)0Zb6)i>z(C=c;r@Sn)p1iC*DE}S zxG2LDya)eTJ_|h|HIZKRpVN^gPliKwq_&Fms%-WThX?;!KnC}!9}!k7f4p^aJ)&xD_j!3n2aydpRbL{iW(WE7h3OBV2{=}36IOTKbb4a! zj!JF~5mv8vnK3I9-sNp55tWGas%KV9j@+$y58_;}I)$iOWA3DY_Yaa- zxWKXcBVl#Uo>(*E+H)`g*Q*X9toH9)ZeN{^9yQ16SkkM$q}o>BU4ZI6PSt;V)tN0h zYUyItFb=0`SEA}wCz}&gwxB)a0IFt9=?21TEv4i;(eFxOAg)(kOjzyZXERf+4oxiD ztKK=K;l$6~C_!=& zC!zP4WA)!&b@6)n-L1ASAx??(s(-B$>zR2e3*rt~)hmgr^B-4+hSDfii}tE@pKR&% z9tSnYwc0!zEwGCml)#Mk?jmNx(ILGQ%(x^W1 z^JSZC*(->1s$Nc1y*j{Yr^j-1MywZURJ+Li`Y_lDebEjUcdE+?tG%hbEp#o~)%7Bc z>clFhcWELVy@b_239GxL`rZZ%MY%mnq){F3`K>gvx&h*%jp|Z4mnt1GG|t~fHOqCX zkDcnNG+tN$7m{(KdVr9c4&3x+eK6WwT%-Cgshvhkw_WQ&xm~nTJu5XYnzH#nQU7gJ zx3&w!R#>1+s*FWFl!&@%xL(t%_rfQ<-1>O zgw<(n4pXmL9fE-t;AXWRVfD8pdHaNN^fdUG)ihzXlzHcfQwN}!{hwyFi~cc1zhP(} zajLE%&FYy)C3fzAfR;y8)okg_q)AsB(JRHVdIDj!V4dQnkRG&yxn^}DVfC@8yEf0? za0l)`B+{%d^1M84%R)3kx6gk!tA$Duo}YR%VI0wBwN7|xL`PO9N=Bm1Y8$K%mDw@=gy?|PxXjAQlRW_9$LM9J`F2qukK)on!886SC<=9-|T%;pHA1l(V zw*FyLEx85lc&=G(MU;Fqk9TK_`bUU!&1zkwWEPs$LvzY?y`8?C{~$`R@MU=cnqqM39_ma)AlC_DFTU!@d)?Y^dl;gjf z)$5obHr3F%4w4c4b1>Yj4kJqLE*x~x!1OG{xn{KwQL<~_SKGMnDBC&UX7y{L3J{UfL0n-V3*5G5PG ze$!6hLhrqYNVEFU90gmIO9Ghq9}y+{C>PJufARuw%QdU(h>|V*ZF;Wo(7|PZl+4n) zq*=`m-Ml-@=`mce$4X8mN;W)YSz&1pn~OgRH>+O|CGS}K>)P!LWuRWJS?xiZ)rY4V z-pj6r#Kl*|O131;>d7iwe~dPOcp9hV%~;8H#>||l)y(pyComA#to9~KuB+&OQr88$ vJ(*MTbE4#+*)=JXKa~jhPMnfQ5hWk1NVnV=oXg9}$sdIOX}V+Kj*R~YSqqz^ delta 12102 zcmZA72|QI>`v>qNloTOJkyMlhb4AqNDnlV;$Q)%T*U+Sq?2}5a21GK3Mk+;AbT|}6 zR5Y0~)2u;71Lgm$wO8-^p8x%P?&o%&z0clf@4fa~&-eUld??!ZP&6i2NIoxb)CgxI z4*O5l2=WK=pMXtX>jKQT2X6lV|F7&5;1lQ*6ucb%_1Vh#&wk4Get|w5ju6>jJ}z52 zIqs71Y~g)-JmNOVB;{`w(Ha|9W+oPwC8Zo^v|KE|PAXLhZOz{#vp`~$%N~z)9L~nr zyudgu5z+i9%1gwV7@g}!bol|-h4-F5vyryknyuNhx73isiP_S7OpSUU8S{Nu#E+g^ zoAS{~4b{uO-+=m$kFvO4GeJyvvHNYP^KJ9sIQQZ%eUuhm(kp|CS*q*cNd9&6U_1*ub9PJ2}D8PfN8cdg}gjg1h7dp;ZzSw@xfH!r)|E%!kGal#1gIk7fyZBW(PXA6HZ%oTnBbr zx}H07$ZIV<`j^UVVTsF7UndtXW=_>CH5#R7>_G=trSD`+eT!j(WV5P?HJ{F0{nS+2 zlWtWl5!zu9cG{+~JHFG78+*&FA@l$dPEit&}}Xz$%4|Fli0gyV3S z14YqSOYZDnwbWC0J$-qE=k%lMk6^>K#K06iewu@1)6Y}u=@;iWBzxU0gL+wDy4lwy z64UO)H;?wBi@w_LsHe-|1Z{@1ms(Q0g}zL23-+R8wizmT9;$$P#p4&UI(#YS{V0t# zFIwUJ4ZZX6@Vau%y+!Xj^2IHgS(9YVyy>0h19i5R=ov>TZ1`e8J?|W+-FVfT{^jeh zl04}?)Q!F!`ZJH>+pH0FmG_|?mBxrmm{h`na-G4}H3+?_M39$K!D1 zquS0arxX-d?DBl&L(6V#8EorAW8&1L*5|JLsDj-K3N3x<7>4#7lO2g}#SR6bL~VYi zaj4Vmd|&z_GtcjIWI5E`Cvf&zPqa-y&fSU|poUF99eCpr5Hd9yOyuiuz3vi5B*y_ZTSh#G5TwqnE?9dnC6<1sdr&R znV5~JC>5d+GUZBK04Ygg#y6T!I#fvb}qM&EQ}8cD_gGW+2^Irx-J0 zTRt49usveHgkrqE9x`qVq{F71-zc4iE?|Any)(xA6^`-_62d{W!kFZW6LZlR(&F7% zKbdddecH)VHHemwNmAPrg4Ps+R%U*)DfMdVu{_!&h?ZJj{P5m0bj41maw^UE#x@(y zbgvJhqt#UvV$~l)U2AX3(W%rQ>kSP$VL|lp{i)%3T3&F1v!y-S6m@r1^Q8$VgXkxm zi>L29qA#i}8j)$p*IBaHZ%s}R&0W|kBVC9FBX^V9#Iclp`V>aP=XMbNNwvtOt?oG- zs7(A(@6eKag*TU(Jq@B8oaSZqf4l@A;FR6D_N~P1gRlInt|0o@@xZ%=N)1pqx(MLqbyVqa71IOt|&KuIEtoy^?932dz^&CVEsp)*EXBx{X*$YbikqXF;f>7LY-r&2X)8CIW5#Tr(_k`IsbdhWN9 z=WcCs=;m#yx$v;50u76@^?k2~mb{)Qu@v2GX6ea-im0}GZ~{-+UfHpfTxP^P^mMk) zDRgUEmO;QB4<8E~3ZZXP)IbgWnDH&y`1x zOr=gg{qYV>~=>Ok6RBeyNbqR z-sHeBDSoIG&{EIzoXnTms^f?Tu;UEr)VCL}paZ!*fdSvbpJk5*e3_iR^dX5TIF3qR z47?zbvJ8Gfjy7Z!Dc2W3eRFsyyiiGRuHzSq`zkElB&z}HYM#4o86Cc``VIUBPM)*j zdvn`UIDr&18eZ8sjR7yvD?77hLG*zw(ByD9qZ7E2RHa@&e#K!3tiIBKPGBQ^3Z{gm zTKn*nkTE=*?xGY6_4tz4Fokq*6Yvz`6qvL+SgZ)@WeQv&QL0DEWXcr==A2D_wcF1L zpMnj3R5nafV>aBnE7mp z){g_Gaw<#s;rt#vE63+ zq>C zOnmHTuXvpYuT zFMxKEem1QewUaZ;g!T?yMa#{vfte=O4Bu+-ZXN1BHHU z=k-s42D<#Y(k0YD+cb>eE?LNj{ZnJlLc^V-dSHcJ5#vhtR9@m7`Ap%WCQ0RfhYaCRaBqEHYCVSeQrVNJ?KAx zOcFih|7E-Zj8d+8U=biD(Aa1XLX7niJ7?$9PO!h_4l6*Xu-Wb!~^Vpq26BZd8| zSS#()jt1TQVq0Kas_!ok#I^&8YKr4*FT#PonK=OSY@$3<5c7^$S)^TkTnS%PVuK{G zFfwlB48+1E`Q|ZgAJFSJPS+9`xy#RhhZtGpHM!L84NP2WdfJx2PVRv$#u2&mpSzPa z9$&~aK!9r1r@6mFs_*bPYA&N10Jev7?S}mUw)O|Er@-L z@eDvXd866{1mS^@X^&3D!57kDfgDMIth_CIf%W@cJWeAEdI%ZKa1qO1j*t5UWmS=*9CPIjAZ5~QL@h1OX<&cw!v*>k-VB9neiSz_Rt00 zZWhV01j)mZy`tN2oI{YDHgT)jw#BHW48Tb4B}neER1NTOXU@WgNUUUgq-1yn_a48{@~jvM$^s*~ zkRZ9Z_F?&jx4E#tB}Q^QLGoD@rKm@T(fn?Xk*q?HoVxptb^iHdP`ATKUO>c6rU;V5ENkb*-A3)z2aM!T1j%oIPcD-Aw*%@d zlFJE_&+e#6vI&MCP6(2P36h-@|K${;TdyUFp_r?Bzu?7n%?*pO}{LX zB?*$p$15@;sY&oniIT-EStN6h)32w zvH+4DrkHIkyn{qH2_tzDLGrPVw$(e=mGd}UhE;MTQL>0~V*V`W^YDQ^0!SY1Bl*%P zxfSYe7|Edo$<`}ot)F$Y6YAqJlBW?QCp_QOeqV-X_!r6Wg8)YIgjoH}!)KpE-324L zfFVjASg7Py-j5`fh=0c0M1Ceb;-bkN>v06?8TeGtEY*=VDY#6I36#9j23V0IeVP0;p!nA~q#|OF``tt7<+`wY9IlZC%xAsAphR z>l0N^zh---Cl2Nb&RL{tel0<@_vuOFme->zV^O_=pt|p*5Kqwst&Bfx{ukAJyN^E? zRX;sM>#T(76d)(G`5csy=~L9Y9a8URLfdnPUhN z!>Ha#P`y!diGyA}dW~6BuP3N(%K37l<6JG&5vmz={uZKYMY$QTTh5`um4Q`lKvZ3z zK0hIE7kZYgs^f{O$4M)$oHFVf)Q74Nsuc*TJ$|>m8?hC2&@8Gi6IA~(d6}d#2aPQj z)u9O045<2Ad~eH&w(GFL7pvNos5XiTuGHY2Kj;_*u2QE;*$QZ+(#7eRH1 zZRIYpOVzNy8%Fg~g6e%U%?8Y;;p1Rb4-!=Gw3wB~h>N1BHv_A>jHr6!m(OeVccR5Z z5vy8*sQOJv-Uwa|`l1Z9zorR5m5D?=)9Lbk&4e&=FVKP9YQ{(F2)--2eSv#jnStj^2n zDA4dj)2tCz^?0J{FSMJ^%bA(5e-BpmFQV#8Q&tToU48)j|G=tlWC*JjHt%_Ma&0|q zU|F3`Se+QXJ5XyE`W<=*v-${O_4UF}a&EkQsLKeb`b)Ec^)_|1;3#8NOA=K#9XCjM zb?^cYPK;IEL{!a8&nj;cmqII`8fNuD!fJ!FKk~nxMm}I!oj_P^HC8)NWIUSf<^ij9 z_#=p_CppwI{3vwdu~^l!iK@q*32oQpp#j+;hE!caRIMMaXm`-!3OmxO0~GSJh%f)oM-;9L5}a0`+*T z>QJI;W{t$=$whbII2%FLj2ZQku)5)^xXwjsw1H){0%7&ti<+~&4xnCuW%X^sYTLMK z1E;a59S_B-<`Pv;dk`{XfgBnWtg2K0s(Sz1NrR!#6>~hXs-2Ol8DRB%BO#fpmRqo) z470j|usS58Wu1fQIXD5!>LJ2vPdTZX(lSY~zcN#olFIP?f^;T)@q#7x)K-Zn9-i_xUejv2m=FnrBev#eQaXmWAF3~wR~pH!zk9JlB? z?9VdXg)sc^j{Coku5O1q4>R16Fx(+WHq|vAEl@i!!_6dEg@v?V1_>@ z41X};!|ZRr&cFvsFvIr{hWFnYedx+G)cx3Eh94#j|FK@uR(Az@WKx*nNrd6IEPU@v zKSx~=%Wx0E@PaGz-HNi&+mwzKzE7258E!YvY_Z8Vw6@Q|41Y%$ZdJedcvBsE_M0%n z?-PcL?2Vt$bF32TWtia_gyFu&l60S{q843VfZ^hc{#D;{;RVz=!T+o9_sl`PCr>w) z!Ul89@G!z~zx&!Ve%wZbh-G*WVYswNOP_^2njJ@AhIbH#uZSq>e|O;m)LDj8gyE70 zeY!>#pf7|O&bK5AkCaF^8+1Hw2)_%k48K4aUiVY#hn7+%9EgJ%{)RC8m#ReX)=}t+ zS%%Lg4DWX=lacqqmc$G%BMetET=lN}AL#cu8JOW0F~ePHsf!=41XZGm>jqLdLzNST zyGT|nR-b^l#WGx;Fx*%xX!n*E^>84T;YNhv3;rz4uVv6g)QuS~Ll|BoHi}2-qb_O% zX1EApc>TV}O$s}cpaEqSz7Q*%SwnyD-QcR*ghu0B%bqm?myUqng=V)a5chk z$z?eOyreWk4#yEQT#GPV-sswnUNyJ?F3WHc!f^8qx8n5|qkd96@P8E^akS=(2=f80 zfLfU0$%NrOr7A)r>2x^3fB?gL!W}IR?1LpXLy+MHCZ!KL^J8HDv6$g|2*dw9Ch}hL zz%|hDLd@{616f$%vQ)Op`VN>GKfk%h{4c|eLJsf9On_%8#xndkVfezxJAbY@wBDP$SmOBg<&mKm5@+{uI79Ou;gg(wCG z)j!*N{pPP;YRoA&Nw1?cWu)Ec#V1v0pRy}8*WnSboG;OZH3{M~o zzjg15(GvJdQU3}n^igyH;?A$A_xO|XGwcq+-NN9y-g%~wP#Aj@z`!f^j( zZU%=2>!AJuGkgzWcxXzVQflE7sIv?o_cyCfd#m(i%~N>9Y*sxQ6waXEgXiyC)4IG2 ztz3};S@oCqH#`5)KnG$OUP>5#|AC~|u}FCK|1YbS7wzz|(ME$&7BgItFg)?sbE!}6 zH9QWNRrtR|;b~^3%#SZh=-F(=3_nA%>V39P#yVW>hPoibSB=}qdtBQCb-}E9uaMgp zhZ|Lfe;Mvg7_MOO^`P24{YG#ta>G3^`%t_(e(!#;6R@RSY0-CYi+VFx)T&uwI@+^dUmaDj}sbP zY*sB#RK2h_@%yw+WDHi-iA2?m?`N4CZMo=gY-C_o?;@;jxgvjBH#^S|ZYj>Hy$GvQ zCJ!Y0H=|o8m{r%$RN2;S+6?;(X4UP*J;hJF(S`L0WYydT?v_^BoeUg^&8n3Nt5u4l z#G0KExmZ@`5LTDD+DCNoGT=bBa8|vSWYzC=kG-F4S_k{HS@lYy>LVjEy#@3Y5?Ke^9t0It9AK7&vR`&^-&^)oK9gwOSNJE{9j_*C5gGRexRvjbf9&&GC zD}2BRXVohRtJnW97PXkv4Rw92>S-jaz9(ZSYt!Be$7vDBs&&5>l~-(e1a-lz`cuFC z0jBNrc{mWu>aT>=hC`jvYsTG!4+LOV2M|^(Hl%0IABzT~4Q6!-393`C58FC7qqa*h zsJ6cwHzw*EngQ9M`VdidqzdoROdoW?6%3nH6IL6(6kR1X@Dw(%td=IMUM%amYRy&j z%mjmKbCE5}j?|*x5d?$km4nZmgUdcaT`;I-`o218j_pEqFBDY2oXD_A^`6t!#Vu!G zY9v9mEFra@`Kx}5>O%Mc8&nSxQY+sX)U<9t^UFTXAYeix9!tPUn&^|N1g>W6C3b7omBO;}yJ)J1q~{1K=R z2!z#1ZyU|Kb8C5jRUJW8&586C8*vETRaVuhMAaLAHhe$Z`Wo$zRV~60RwvUbyaxqn z+GJThm#})0p0l1y!aJxd3xw5L)pphmUZ`nx!eO-$Q8jn>w}3r8Ua&tKR(BFr=RTVf z@rB8O{WEY_{a4jY>XG6^m99M4AQ)CJS{$H1*P|Zlf?;*n=E4H!C^WzjtIeo4MAbH@ z&reOt>wr3|YDJ=I^@(u<#UIc#o*@uc%lr4~m(>)Z$w-jZm!&-o3U8rVkY#n+Usm^D z4V`)q&2}uST}fEI)@)&@mjxO}f?@U9iPqEO1JO@8f?@TL=ZTe8pOM0msu>w7kFZ*I zPhi35KhI$U8&>-eB~OxH(Wdq2IULAMAgqo|coJ^qiSFDW4y)G^C99N3r}IqF^jnOT z>_U{B@2#%s^N@M?-nW+-R6K|6f?$QrWxxQ#R_~*syvpQF3nXbobJo zaK$97jwVVDT{Lxl*|i(6zlcCs-89s=;%o_OS|V^*?MajzbaS5xGyDUtn9GLM5hSd> zKiX4w^9$4!sR@MDZefQKxDtI(-z*STdyF?YE*Fo~t1J*!w`Why4EIC5hG1CzSe~aa zXCZ3qI1Fa89SN(~wk?W1ID~Gsl|WdXJlb?9O#*eef?>7xN$t#f8r3;i$=yWBONPre zF0`ZdV+IbZjfj#@&s3UgryK*vXO(O<$gp8GN6xTxWUxDI2*Y9ZUnPIft_oSZqYRw@ zE4h~_`Q+^6L+?K!8JoWxA#? zD=yKJXUO@?Dmff0+18lWm}GM8MehS1XMhc>Ge}rXZJV~eeGp;Q8Hd#|M9G|CVX0O2 h20RW?avD*x?pDL;50_RL=H(R%;lG;hUL11q{{Zh4WlI16 diff --git a/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/traction_history.hdf5 b/src/docs/sphinx/advancedExamples/validationStudies/singleFracCompression/traction_history.hdf5 index cac346ee8ae8c20d297708bddcaadc4bf16c5598..7096c10d3a3a789d09272d4854e4e34da3281182 100644 GIT binary patch delta 11992 zcmZA7c{~;0{|E3(J1R-2RMJWtDp4I=sid;Bx{?&#D3!=ksS%N~UD-uMvV812Ioz>D zWXo1sRFt$3DxrL5%)8$ozdxILoVjz(nfG}==T+O&No`Ljr8P~MkX94qe_kv!(|Y3Q zbovjO=fyTopTesNI?iHQ_@$rqSC}{{bAikjAtGQJUt#%fF8O6by`e}Ehs_fFCOgBt z08Mg>ORw3(C4~*Nln0ABY||xXS#~n9I40{|4t>2VNp~xKoiFns-TrMc>OW_#NRP8J z^Dc)T$8@2>{rQ%UkUoqb0pn|YTDmjkUL@|hF+M&)e${7gP;~zJhYVYIXMdlY>WLX*K z$o<(@gB$XWvy~Q@IF$7Z6q%cT3GWv;Nj6(I>3n7rhU_^Lb9yD;_27eClccAST=Ghs z)0vt@Mrk^i%tTB9vo(z`?7w(dU;yLne`uhE2e$p29PXLN{5iY#tB(f)+P-Z;yA zu${>Gfc|uGf?r#3$;tR~`OyvzTjZfwqOaHo6o10);_gx|SuFXr;<2_7n<$D85^rxp zNrRp`FYj~7L-(&|rIn-a&DY)$Kjzz=gS-fr6xTK}_ zrKw`SIc%>4Nnc|n5_zTRj%@VhlH8d1yD=h0Y>nf~E}p3J!|tA6XY2TI$#1(eH~I@3 zu}5Ry=o;A7;gy_(?jC|mo{F3KW_Xyxo*Gvgpjznk|uIg^?Rxltp+*sPk`MBawP zZ$T29RqVf(pvfiQyC3pU&!RSCa^frJL-}azdAXIR9+!Nh*b%p=l=`7^`vPx1c!0Xr z3?9(i$0fJ_@|bNtO>{8$KYL0R9-c!bIB#~Qa?u0s2fXM-5lYq*jBw`n=id8#_L5*)^*x*$%DG) z$v)I|l{tkP>m|}~%}NokzJpxy*OWLR7iul}yBwG0aD$L+mv@tmHkbVCZ!`5<0rf*Q zUsv3C$HS99sQ&DwmcV?CbOt+v!_K=ka^{{7AAKN7ufG+gUYpSmF?aw|PaM4jOB6pw zqI1pHR36}x$%UnjtExC`$0n7vp+q81w}}vcPR)d5*OL90sF?`)uj#$9LK^;F7;#66 zdM#(%c&56PdM(2@*r%Csit((&2NtoYy%j%Y;GOXsYW#h9?g~0t*thk^Ly^l|l5pdV zC~p|#u$?##u}Pkl=$M#ub27Cy{5m4sm|B|7y|n@FE>xkx9fK#|POox5oHA-k1y^59dXRvR=1y<$*v}=kU6W@#ddy+>`3*YC);z>3ygN3lQA<#G zDROr@wFIn3!^#Icz45jSGkAq;E~ysT(7z^=!{({zwzV1)7(Edmouf((WMn1q*Mu5K zV~5-2A1=B0fb8!zAB?zUgUdFFt@Rvs*q!^|H=_*XurJmBlL?pn&+CxY>n5rmqk=TvgGyQ71@{{Iy`$mbv-0Zb=4(m92S2^hMW+AyJpOa za3VNd5(mo$h1F7jv3`-GK}P}#T&syIskJoA*NE+<*0Pef!ZgRZ9G%Aj>1xyxtTlOa zdN#EL)?}+2*Q^+Af9TPAkJ{}9Y(uNUG!A=1|IEVU&vLQ4pk;JDwYO?~BUd(1CAni| z>4#5pS;%ywrKAJ(0D-?|Y$lATCy=SLlnJ?#i7qTX`{xw3_UCq({1m3vz9W-(x@1o> zZu0u}>@KzGD#Btzl&DR|n*X(HkDd)yOIQ3opIRDz)CXP#b=~xqO6o<`2k5WJn6WB# z<0C(gI>}NumO1Jfaz7~+rQEwVHEbuBT$Vv(4CHgz;$Az57gypFvDC(S0S9{uknLPyC)U>D!}{7Ppk+rp#FXFb>FMy z9JYD0p!|8WM>rxY^xS{cI1xlti{Jw4^>{hDWG`;2!0SWz^bJ!_T%mR(T#lNF5Fe2< z=Z=)&?<&SS#;7SZe3&+23N;g=YDR+7PK2RaJj245y7BFccea{PH|F~sU;dyp2K@-z z`1&|Cj{Dw~FCD3W?<_g_w%iqetka*T_>8J6rHf8^s!(-h%1R4|fiuU;Gxd~iNfF}tC2l45@oW0Dj=Fo9 zg!51@HGM1RWx5`}P=>3M)W6WzQ-*X#=`bC`$ETxk{pR9BDM)RC?GbwVN}`3N>FIOKR%jyj zmZGmE2PH?SaTXjoS0%?MIBY4eZ9?yYW6+HEMXvM$&D+ABPp{9X3YAYwTyxPc)sC6; zg6c0ezDO@<-u(RGZ{_hw;b~bQy#Zq5^p?{bfED_<@VfFr^zy9V!o}1$krMKI=?znM zGNW|)pHlQk-TpSc!S1ej9ZherVJEimMWQ1OwFm7}q<5rMU9vj8Bei4H1z0_Ch(EkX zi{8RV{K;eV7G~8g_j-FR5$*EIP@=c|g}JYKT&OM2y3v@-oo9^WSpj17D^gcsv5Q^CVx|TqQjp6G^sKua&MJ?n2l!aZJ05*dC<)KEqz?)WYuDAbyL{27%i6=++N-;$H+gNHo={ph3gt$SxVeUwH; zeH^%Yy%ue=3A;oey~OOu=zjX_&8rL8HuR_v9Y|rlp%3f3dN`Uotl7@m=4Mze7606S z(VjlsWz5bVqz`w|^4~I=pK{RevAzVl8TekP{EBV{qGYYKmCvT4ROyYU>E@wtM+oaF zwFIobtP9ary0~h<=>^?vbgF7bQ_Tj!mNBtn4|B6H5zL`lp!``koope9;ckVQj?#IN{yS95M z)nkjm_#wK1TdVjvi*De`ma#(ad1PXV5!6aId>5p>h3STmRUxN$R^u8Bd=ypbmX&2X|6FXL0%{l8_?~WY_x%tUrCVH?nqlEN+f&e}@(T{# z5*x7;=h7{)W4CRV@Y+m#(d-zPZlMb_oucR#x@(<7^zS>xC^s|W0^M@Y5J|X1&^`C) zy3!vfKh&aqVQu&6CVi{Q67z`m zIWz)RC4SvRBcOX>aqq}I5;ug{PE_{glBZKQJ*3ePFJEID=#heLl2Zd|WT1!BX41$Q zoN|HqP#PGERFe6 zX!h(f$qJy^W2$|`-mI}0+sO^+(o9m{=3BG9~?b}OH)o6)W*+;e^JH$7H z|912_zR~htcP#xJ={Kympn;-oo59U>_nlf%+o-s$FGb;6iR;c2C<=>*zIU3vNKj4Z zBSU1zL59fk4tK@cyvJ~nEkoqNEQZKaRIc1vd@-y)vu@um5#r-92FlyVp=`*GpZK8J z(ytNkJjFQKFP?Go%KB&v=kpzCCODaUh;g!4)#^UUM?J`OD&ypBM;RxFO&N(W8tFnx z;AClV^2rGaeJ?+MKs?6D1UU_$9N-tPFKhS~>4THi3mGS;N#^Dx|9Of|m@!Tcl46|9 z(h}IxDwl+Oz{%^u$%f8*UGfpf=7G8{# z2lg;dj-ULpD?%tA4H+^{UI$Lr@U|&-BZP7=XFdbvj8UU;Cp+gmRl4;&#+BualNJ6s z*8a9g5L{}hPaIzdYIVwF(PH0gw z`b9aJpsSALE(XfxUXykjStMg+aB|2M#>r8iH=h#iaY56;$@1W2`||~tZzN@-2yikV zoNSC@o7{gDqPkAT$@jp?T=%S7Rf_c}vx{-^#5K~yIF!5f#l(2QPtd+H#>tmHGER2B zmR!~)<%<%*$;U9`=I_B~8qpNjs1lS{zK7TMza zZQ}f}FF5%uIN3R0Ano0P96Sk}YyeKS9?}EIkRYR@=X z44fRXSaxfBS_SR~C%b`@%`Myp`X@Hvo8V*zaI)bUe%-Uxc{tyTak4r%IV9+6MuSlv z=7E!mAb_$p>M?qGw-D#Rm%P~%;Y%TZsox2w4788=l1FZV4|yK?z5d(})i@Dcy%AhJ z+i`DH+4)?27+l>1u6DkXcz(>j6d`c61>G&kNdv5<0M?azBb1acc%ttB z>w187z^c@>Wk*U-J`HQCfAa)an;$NTTs0k|72xWwJjT@_H-%b~(gINcxY`I@oi<(J zZTcSK4*nj?z`9q1f%TBA-MLetDR=_F`X<2I@#E#hhUMAF6=01iSkoPA;mqS3wtsnq zG{My>;A-pPkes`9p*R9ueG^WRI%_-!{sYBrF1k7(NGu+=0M0aC9az|@YjWg_l=Ex}*F)Jl_m%~vzG z_mO2-2V_lvtev0F=Dn{DMV${BS*!8ZjKiAMxQnCsxByR5Vqjebu$J2S%D*#^#L@t3 z2Y@vzAW|<^F%l6JtO;7yfgo#Ekl2dPKH10+WbF#FW+nN|Y?~O5&w;EfK-Tq3PpM_z zu0uZn)=dEG*P({5Es0uW0x$8v3WESd0<6mc*8F=rUH;f$WDi+WCWKj9yVjM+A8A8J zA#1vt!Gu{VJBdqOB@%q}0wm4@iGMlRyJF$0a=Zp4UJnxIAJ!>7KPL>ov|%Lf4-!8T za5dx3w0iUsBwh>>H#d3uxQy>Pm#J;pSnL2J zaW+WYSy-J=-xh)kLE;G@ac7RDp!{o5;y%hrLEN`6Pt!I5}%RANSt3{ZT2ar1o?o(kAcKR1&T~RY2~6h z0P$%Q#0gsBX=SI9miF;c5TB9w^;e99~G=vz5_Zl-2XL(%pDXqSS=gTt^ z{|geA%028w#5CY=koZD3M&gCfTkXmtoA9M@2I3eX{#xP$A-m>!4PF$+Nc^QJBk`rv z+Jl$Z*5H+27>SEGG7{G)w>*}AzZ%D!W+d)$pOLssiu##(ofY_02qST^K}O9nhYg6aUg`%@eo#T5c8^^uwA<7El7L{gwW-3?(iYoe|uThI!50>Xa)!lkp5v@~+Rp?45g--59Eo_y5DoS)y(D?s== zK={w43VnAS2GL3gt9dd^SUqK`fx9d*X)x3GCiQ9HJxIJ8ByMt!FFE4(6)l3qdNCx{ zMZHt6>6x}60wgZ`FR|Xb_0kc8LbNiKNvvHUvF_f`cYNXXbkzU<5^Lwg_L<9+ZsH8L zaflP-9Z4p!HXX3pbtEtwDS^aYb~1^zsC3&6dEIAdCM4F)AaO@E$rTD0O3^1stdD`j zof5tu5$r3$Pe9_s51GVz=>R|B6xoDrA+b&vp&?E+18s3VF~#;xcr_%}F(B~{!(+dc zEej9=iLU^OYkYaqEW4}}HG{;JAhE7zcU2E0kf^+hNvu8Nn8bQsWm3G9MG0CCiS;r_ zto_7!nd=CNOdJ3bp9qQdeov{jo18H|4idi&5@&ILf7IdxAyGLdvEDwFNvuyN2&@a! zCebQLtfvMri8W8l`?BWFS~T3rNPO*TCb2g9I$2%PzZt!y0&9Z)Li!UD>%vRt=EkN~ zAw!Tj3nZ?QIC1s1OOLUDEt6Q=LSn5j@mjOV#U^|VGl{hiB-V~^?6P;~*JC9}tm{GI zs_9enk1Q_5VF2+vyb)qNv3~h^#lvSys?jn?tgnE?oi}YC<3`pashvz>{RSkyVd%cl zq-{kg1|;qd5@$X7DQ_Zw8~cL9dqLt+yOvj24i}+^0P%&Z#uIC{$b4er-7j_-XbB|N zY9Mi~t{!pmu|}K^64wKXTXoC3dZ;#G9gw&ZNPP9d1@1OgB;E;$^}BzG^;ct#v1B2> z3=+Qv5NCNgC!Jqpfo>8YYY~uj+EL5tN2#f{0$G0rS$A){(j6XHgN}l%y&$pfh|#s( zn_G;+0M-cr>!G$fNyYqhTmrBT16X_fl74GrMxxIEYohd@tcSYSB>pW!+d$S6A+e6? z=pL?Cu0#`xn8f-8$XcV!bNc4`0(1%zYez_|8`NX-g?Obn0${DmV-jm?k;uxU@nt9w zVBNsLnqZflKbiO~^D&wSvYrOA=1X#$hURAD*C6XgkoB`b&$IF3*?1Nt*4_YX=joQ~ z-w-iKaypY(I{>UTg?S%k&OSmB0PEQRYmKov!uwhYPoxd9?lWQ%Yv&zR$p&J+csP?u ztZhKnrh#s2LV5~OC&=0!5^K|?uYZj!u178a>!ko|FRlC2f>-Ba9e}kqz?#=}Doe+$ z4zp=k6V#Wv&%R7zEw!5X+9Q#MgdwqR09h*-q#V<^QHaihtervD8uHH$R(y{~w;-`j zhr~MVz=2WGf8;W~hI3k7R}PDG2^7cV#vTZN~Atb-u2KA@m& zWL4LI>p<3u|787cso>J+P#g(~^#OqO;H>atk(q_)CnVN40oGEM{{=pzK8EZDSeF5; zrEJECt1~Pb@gk6QEy%j{P1%{WOZ9jjgw@wU*5^meLbz2;_zjNItjhq_ZdZ2jch?l6b)&?1T1_5f<)A!nn29QV)!fI>+e#Z1{Q*>^FY=-$+v|| z67x|SMAkYW>-Z;eua<32M-m`wWr(ape!ST^=HrD00M;S^>&bx^WaOs>BNd3OrA(Q~ zy6>;S=-T`!w1t5+L2d+yU9+Q{4b7GOhUFmqa81vVIA& zj=G?DK&~JM&jMMW0a=VkLmJ zE5KShTb7ticr~J>AnW%tnaJ8`-liv2^-s|(ko7Z&to64ycv(Ga#B)K`iy*Rg3>R@# zNC?BL0M@?%)+K{ovQ0lRvH)2B0$A&(HO!U|PDdvxSQB()eFS9f{9W^%)yfof2B0ho zP;UF+*3&ZDgy#U1vjECmBEEOShEm)LQ1%8WE7a`}kY8DgEC9+X0A=T3Q`OJ*YLHeDvN<{c6Z%Y0OVCjpcd0m^-X@@$*7G?Wiejs+-d zIBeQ!Ya5Gh0hG)BL0RA`|I}e;Tn|wG%tY2~eil)Eo{)>gh9KoUfO1j3N7W{+Hf#q_ z)&?kF+xM;UJ+~S2wV25I20+>OT#K3Z;v)P4pga#E>w2QzM|fr{b_6JI1t|AiKc@EN z{yR((Amz>Tn8-TMZ*o2sYr=y8Ok^Fez(m%0QbR6RPgfx|fbuIP-B5Q@cFWojCEJ3pX${!%I zww~{poKjGU_J6_g0Oi#HWzCcbpTX8X z9Cnw2GC@Vwk9ISW_2hb!i#dw#@mz?kM`tlmjtg9-5!Tm$k3nR;)PaGr{?BuM9-`0i zb%?BQLu5U1u9%*1Q!B<0S?fY%{i&#M|J<)HFajuVp`d(#j;w7?$W2f#{fp6%G?eB&58Tq`?=QsnpaT|kkXd|Gu&;dhkaN6ZHNl5=hwM@{yGrS_SY>Y46kvVU%Qi$;VxkcMr&&V^fkMjxzTkkaH z?`LL?eNua5B~Wz1=VSC|J_nvkn(#}6YLUavG6&x0_Qfl9%d?m#-2a-& zZXQPMpYrN#Hn4eny*p3Wr?8kpA^&7|*^Qv>J3o&gD>iRJ=itH4XDsHssx$54gwGJN z=CSVdII?-iS5B|6>t!)*nzy_eKmQt86<&7TQOf2OF7c?WG_YYZxD9$|7o9>g34g<` z7&dS7oSBzY-y{lvneoB@MW4dN>Z(W%E>n z%YJudv6#9e9f!X}7vt>P*Q$wfJvL8d;EGd59*fCQx1O2VnT6)BWCU;VV)NAIPn#kB zi^bHkyODp*p$_e{H2$r5gU!n<)rgK0wqfRX9loc1wj713eULB=V)Nb}-n2GE$c7o5 zvARu3HWMF|NP0I+uz3m>qh5`VlO1~nhU|0-Kp|p1X*uLb)XaTL*dBaN4(ZXIhxCaOUEH_dnPfXBE0WLNd5D{~Pp>( zJVk3>A&Yq`l6aT)*!eMTo{KkcKF8*@ubO7^dz8gI|7gX~mD4Ya__!tYnpM_BH@5hOE%9%UR~%CIhSHL-Z-i0#i6C20$-dmAa{q$U%`)0SWNFJ z4N1J&ap?GO?eCw+DG+;?kj>0yF-=>uj;_aC{F``o@wFJaZPqrdD*A%SU%E$V^>v4G zJWu@4$|?&sPrJ#uc||pg>9XKN_gCg)EOq*>WIH($2l~^^-N}*2f8Co^D4B;MOYYv1 zA-CnMQ+wAdlH2m%s;iCrcRfW9*H|oKkZViA)vM3;6^m)GJm`GC@MCl=@>_zi2b)Kv zn)t5M_{w66u0I?Z-^WE00^TiY4)Sh8<@8t%ywX}o66<`v!2n)S4jockm>g|Xa)>Ti#WnQvkgxh?Tt&`hPSW!SpUAo7=UIwbs^?>ky3nkRJ<`rYf#ZGh1kuM;$K5{)_L%xA?s-;^+N)BE<|JdKd1ZI}V{;U_=+=g-MyQjEj_V^Ze`jR?{*kHnYd$$OgPfB$E6C>;z9-hVSd^dwi3wY6 zvf~x6-kp~xJ04|k4NDoRMMlY9f|1+Uyczy8bG{UiFYInYNSzmo!85exg`V5V=4~_S zyjH+vF@uvMo{5g8<6HT+w_GMiqOC|jltYe0Z&stycq<2~#XG4ClMQ`jRq2?LbKL8x zG`21}8^?w|HMb_GQt?XQY#(weO@GQHO*xZ^t0&YyO1^HJ!I?%#6c zs$S?DyW|3oTy%o%f)gi9vEraYp1vWQ7Ztm~XePOhN5`ktxNhg5pppYh;b!FBQ7#;O zp`69sRXVUQu&w|p=0zM&A=~LCBKA*RKyHuAC+aq>n2~5ztXGOYl!-dtAUjUBS%CJE9p~#m^yxsiXL;}&H0WL6TMJCd)~Or9$ynxFl($a6)2`*W7I-pe~VChC4NMAm!B z@Veb>o?ydyq2wAC^Zj*cpLq`-R@tu0Ev!Z&a18uS5OZ*Pj-LQ$LrZcJ@Znmm+lW=j?In_3FO$ z{Gnd2s!mAio(C8Eoy|H&4Tq`T3KMEL?5FL!?I`*TFP(9E4>f!zg2QB~;d{}UZ8_?Z ziH9pJ=lmwy$u{~`y_`$1m{}_wbPmtYL7e^~A8LY}HEQNl^TTQH`Zy#Lh0WIW&Y~uC zTxrmin$Tw&gJ!39(m0RV zmhjk3BYSEI+Ybb6%TkX-yM43OsU>f>%yHxrx#SIwipY<8oyBaSP;qLD#BjbWq_#+@ z#INn+-(v8!)>+G`Ev0Po;0(2;3O~KR&GjzB7uAB#6Vx6Q5KTKq?Ln<^g6(R|Lsc3x zCnCs(^x_sJQkz!PMDTF^^eR+x>c-?IH~)2ba+7m2%k*yUjm6@LV(+O#p)tQ5aa{GColACD&B+`B6lI+BNuWm-NVD@>j`-ZkGZ>96s} zY6~uDQO8v5pGJG?l=5CT?ava)XzY&de5hk>f05ZV>R8iN{JbaLJs0`3W#6Ta!FQqa zl&NDdI7K|;-kAziVt&exIyR@T6-U&usq0dae1A0uFRw`}ppMx#ucR32nB}Y_?(=<~ z@&HM+wdI~C&*iKQ^4Zk6EGHv=sOv%$)`|SMlsd?-dOl=Q2YF%(j;#KR(Wl2%Nz}pr zUf}?u4u0FxUtfH}^U-kln_%jqSYVRiL|qg=zZ3=@4yeR8r|BtC7mM9=v02o`Vy{qU zeziCrwGyubB&nO|yI21o>Lya@|LVbbUV@g*R|%r7t}kY*$Ed5zUUtRwpV4txyU-jI!D;G`o4ZBHQrDa!7R8Uu` z?n3^Ub@LL@HOokM>gpvT7^}WeckeR(+h67w7vQ<)8Lz0z`o@Ss9C=wY862PM^@UzY z%+mENb-A1E`DsaA?xyb*OzjF&(EUYYNmMa#(vH_n6$6}H_0QjYIaq$B<`JrRaFA5s ztEHwOB46&fNDlh-?tBMTY}8uS#*)Pb!DMW|79_B)2$h#vrBdaI-BpaJ>cp+2-1Veu zHQqCCgCbSV2wzYdqRJW7+X2BxAGP5q!`|Ce`BRj>eG^swERC&JbsH_i(E>afs$6P5 zc-ERKmkd1CbE~eVV~N-$YE*fpukfIaDzE0!85LC_G zP%CU8d$|Jn2EUA*<^sr&pTRn&{MChR|1-hlrt z>6D@n5K`f;MIk^YTBh}LODQf!r}@|3VDnzomnKkXNX=NKa|9RTV@EQ=C}ecHh0UUn zA*nc(=+|UM;!&}4MU+Z*PcO2iRFb(SXWRJ70@Tscn@%xiAgp4TVhkgA=t6D0HnM)t z_k&{3k8PNY;vJDIPOcJk({$_6=MeaIJ_ z%m+^XWq&pX2IXXeTzQSZ<~waGMT&Q> zRZ}bS1~|F*)KT3JJ%vaSoQ%N9GU>bi9?asR#}>4cKb6o`?@k2PAsuk?4{zGZ-dAHP>WLrmXvb_C%A9#`C!MStqVk~iaT;c|(@yr-4o>dP z*efxXfl|Q9QQ+j@Bc9^&!8u3>oZLPkG3jKvrk!h>di>F1aB>tl+46zmw*x&Tc!lBg z8iG1?o&l78ue40T!IaFrff^z;2Tn0`y2Penc z4v(xi;G*h}w3GWz&`x&rlu21I^BJ-MC;u8uASR()#dWBP56{7G!O083$--;AjvWgw z#ObqXCl@x-POdPmjEenSf_9#wo$T31JGuYH=f}g-^HCx=Sq_}6+BL98=Ug6o3QkrA zCm%{B{#6Y5Jw=89<;&n?mjjKg(vk6zGN^}OC zOn3p5IYq&9&dkWcKJX>a>%T8~ktTVMSQqeZ_)<6xKIC!d&8ja>PQ+|*^#r)O%ucjS zGpGuOgR6Igt2K!#*X2Q6{8Wc_^%mOI1oP+nO2xYUmAD9CodB?A$Z(7LPTa!7el)DN z1FT2;#5n&h)gmQ664qq>RsybOe3)u~rlkx$09Utyt7TX6Z{0FK7k{gzUEQoiyV_ew zw&Ca=q7;8Aq+z`oVC`Km@^{!d7Fz+V9RSv&yHrig6pHXyIU3f3+L7z2ij}*p1{xIVCgk%fa`N6}UPET+OI{ny~O@B=!PVbHUZ#&z`&Q)d|53 zakQ%m($xf|2K(Tc_B}1Jm;XRg4$hn%Zu_EFl^N5IwL zhSx3Lr{>|c;Ob@t+ST^L_R2^)4POFR&jeTJ*R~N0bk`&!O@MVez`BO-=5qg=Jmd&*abm(~i^O#dXT2(Y#VSc_SS@`+kLK-YoPUG+4n zRkh=;|1b|jkAT!`fz;gGO|odyWn39flRBLkr%lax-yXCnEdqOksh5MPNAGnF*(*Ik zdSL3a;k2ojoy|^}TAzy#jZK=GXC+3HTB~zutX>Qc`v9qL0jU|e$9EUzZ$W2))I1=y zptqC%r@_zeI7jU8H5sA;WE}>wUKSF)Z*|o(%oC(#{rd(jYmLfV+VSn>xD8}|Z&KFe zCz=uWRo9NCpeBIz1AsN-kJkLVF#$LpU~RLEhV?ssx5I+6`N)WdHNpGsPs_U3X|HBT zGx?DTWGyC2%bGiPPk;9DOr!#`j^9Mf`nlu_C$St3S_iOp09a4i6@CAkIz~SM)(daZ zux^lzkJ~35inju+4JKhtRs#$nEly=i0WJbr3&hZ}=0sNpm8Iol-~W+yt{ZyHzBH<3QbS|py9 zwY~ndW0nUmqCk-KQjoRxLxIWwhg&EKWNna^KM89_S7h(*qFY!4VEqta-LE+I!}<*u z`v9zu1FXGMmi|IZvQRb&Yl4#XqA*(4_6O!(aZAWV;UMc)O*J;dDswOJqEDWl}lYCQ<07~0<8T2){G9r)NM~5p=5w{l)?dGQr6bmw~xPB zpNv*U(6T-PvgU5LYEHK;i}!VhsKV>DU+~&H#x!22Odh?a2%L93=h? zB%YYX7?RX4#-r0|i3@?m1%*|PuDhR)OF-hY6={jvw{9vOThfeQ_|XtInlcG-^3%W+ ztG;#WdH5Mfycr}eyO6oqX#-i=fy5m^;x2kN<)5cjqJ1E7V~{u_UMDs5S`1nb63^(Q zB`#;kZr@gnu{I@f65=}m;taVo;Y~q=KbioEpK_rk&NwHj{8K9m{Q`;4PoX8=5FV$< zzE+Bx)oF=8nE?`?HgBuySOcDWh?e*KZiB~Y33<6^fW(#DX^C^Zk5pgeMB;RSxDW|(f|9tPtMCggNgn>!N=sbh4lQxr zVur1qObRv_p(UE*l-$CNu?Cpbt3qo=4 zIU3??Fb#3*L<8c2=h?@&AefeTnhGuP+RUK%vhB$zP>_~5Lxz^P={!e&pLvhb9FVvW zNIWz2+!|I)3?e|{O|xl<4;xt6t~pwYYnIUx@A^tZeEeK$p<>@4nUoT=#HV=D64zsU z4t`lWg88*+iJKeK63<-c9`Y{gEtUj{9|DOBcAI`!Z`_OLfW)stSbb;6!}8$Nc}4vo z@yj4_4X+`ib7*Ff2N>Lx0E8p+g`ts0zhGfNxEUba<=NF68!Za)9tf)gA*@zZ-5%P{ zH;mX2R?BzL2-o`)QZqR69Zeaf!|EVF_^pID=iNX3MG;1HSgiqJwLqfAx6SGnzjAK) zlAi|RLE_~gaj|Yk2}!SEl>L-Wtp6#}iS^BN=SUU5XIK&>Zv0 zScl(Je&Lmpi!n%C77}Yl#z9@r$|&SSCe|dx3Ety=IxM7RK7RZqs2e2S0umQBM?NT7P{2 zIhEZc#0lyPspNl&wf4ZN-quF^7bGqXiFKjWrd*DG8sdk<+87dRjVD97%_5bk6eO+- z5?2?@ldkWtLMt`s#5x@$?&w;v`0$Qu^f!V|tW`{WiOIw|{KF+ZzYf{Wt- z;ue*Yi8V9iAn~w2Wq^yNAhA9K65o^9Y8&d(iVZ;GRUmPWgLc)^jcxc7NWAesi9gLg z6)gS~`GdqYLE;8V_h--TYesiK;tv7h!H;FnoU<*#Sp>-1(t}Q{^9{<(73*5Cm;{|z zzXn-*$J@+`=5NB%kXWZeVjWO@a!mGFH}3tP#9DA5hNakCjssZB@A%5-?thI= z0IUh=QaZ7Ip_#^~VAqTSK-L8y>xu8F$~8+Xa3{$65y-meUiOoch9DITXKlJW37I{Fa zTab0A4<}H0pcn^2Vtou?EvEnb=#l-E$O~Zo7GT}27~gL2uMu4aSQ`SYxm%8xaMloq zunNf91!V1A^;^_LHV^**SsNA8i8VtiBV|Qj06GAP^)eeevDVc4**!455Pt+%djhO` z>n9R*>Wc9Kfb|`KwP|TgRr9|hw2gu_L4KKg2(sp=`MI4b=HPIU^%h91xm(bAyPs2XIg2w}B8KE{#Vm5psd){UcdSY4Izb;4V= z6z7Ai?*gpFGDBBtp31}~0PC?XI;<8j$ro8;%R`0$>+=BX{Mmjdk4QG)17id&YYULI zWcHZC=UZI7D1#2Gw~o?bwYBUL!TIxxQ6R{=3uG;$e9c1BkcWqX)Wtw*;kv)$JC1hX z-#}^vVRetD^C8(eb@(@sx{?4>M~F8jNjY&*Czv`DOg;KgXJc1xJZ=M1-v(2M-p%O3 zIpwGm!fFnL)n8lhub3*>fwFMt)eNQFh1(u^>P4I4mtQ|kTUfOBcfZRaV??Bc+Mc18Kv8@e_fvm5C zti4zM+q~>)2v!1E5B(QeHymGSvC0hH2Uu?aSj&mkG@6`>#8UU@$hv$I)>Jj1AawKZ z3J!J!S$_su|ExXvxcg8UmIPUUz;tBYdpJP(WPJ&egvid+5>^%jV% z8@}fj9eUJ&{Q=en0PEhrkM*($<3wEEN=MeaLDs6%Si0(gP^(V5}l0BWr8*%a9C>(Ki4pav`iP|i9}N7i?Ow>@ZI_ZDvhDBA&)gMP>F;%#rj#SmGK1C&+b z;szj>M1C(O{$_$--7H`u7@g{&WVg8?#|76ZS zK6)7M1t>p;$Xa(=^mDC(CulD~*%2aZU83W}@>N_M43TvhMAnMVDeCR)4y*uBb^|E8 z$Q(#c8oiIDA+r8OLz!Ua7PIA5GwabHMAm~4S$oetwKH#3DmDNpUk50cge)h_oBFUb zMApLq<)SxIA>J9U@ne8;HAL2hB5OOAgqGpG0Oe;8S##GtZtZj-k}(UUoH&h+thpV} zxgWpA;2?l<&TWA5hG{&Bfn+=zB5P@gtX<-yO`=~v!^t^xWc@dlj;wXHPcnT!Rbdf; zatlD&{;jfNmRlb0rOBT^F>z3te3{C|ixojDKcuZLvT3wnH?UR&RumM_(iUD7CdH}fkQH^& z=w`rYif+W&Wean%jM|8(-(+PvquF9$SsZS}718MoL14};YIIk`WM|iZ-pjq8?|b+5 zy?buAPrlnHuWgpA-0t8JcDd~7@8XEz#_+|qWv}4JPD`&>I~Nc8ZRnD5VDRfIEZo89@R;yE9)rHH-R0DEG7g%!0k zf>uY5P2_~W#fl%)f31lBitpbUX@j-Q+S6#5$@$(I8^S3oK@dal+Hk+2_u=uvBwiHQ z5kxgi{8Vm7LaHp`{Ui-1s-D=fg4_v$Lcg;Z_i2hwP$c|Zj7sWesrI}Qq~E=9>7i1~ zrNS?jAeF)r1+iBxAvX7qrMJp>VMvuwN-0dJof1M^v2(Vc=LPmkaFBzEgfkL0-*h;$ z$LqLJnz|*lktDTN9By`%HvbGz~(>$EYf__u-LVt1Qu?$``ZIIBoyUoR4_nRAoV;Hvh=)Wn%M2)8m*0&xwl}*h< zG~Y4d$lCfZm;J(TyXGzROE&DX<`ZjO&szQ%^8hy@!E(HtMcA)sg*V|%AEK5V9^TmqU| zq6hxvQq&U8>;tInW=ZzH0>1(!8j zPHtFfw=fJ3#MY_ME#3|t{20D|d=*qp-s`RoQci%LmxS=4NDk@@q1z+c&*K-2uX0yS zer{s$eqoh~VQkGVJ5-yVa?9i?A>kKKJb&TZ&4;N^^4EoA)V zH@cVOZD@{TbCUT+oP|9tmW8pD5XKl$tgHCb@|Yg)oMFO|RZdsw(KyOSCz|jL@R2)u zC1rRvhHs3Vlt2k#UKt8wep?#XMUNlpEW^Wg^VJVB6_huIn6U)(@vKy`!HlT~ZawN) zkw}R~pBeQ~PeiS#92ciE@r{W}N_acVaWlAxD2=tCbY)hp><}#s#TI-IhKbM}v0&vL zZ~vo-D(W5sp;qKToWM$zRx4_Yf6cpYr$uMIm8_YD2;E65CbT^}zu_b;E`4XkeNaP$ zgW<6KT1{QS5TY!7HL@HU6vgNX>qMh-XS9}V9rpF=%q z{Hq-Kx6MS9*K!!UE-myUH7&XuIn01wBJQ_ym@F#{y;MSryWet{2|fiYxW%*KBN$F3 zb0@Q*Y)-2A_8Qt6!fdz`T#2lpX@tXhpeGS?io-srCy{3dhdpDFB%Q-)W52FH?_V+h z6{Ab6I1CXaG7eaZR9FXx)DDKIS5f#={Z;bumazO zLFJU7*~>A;zkq`3b<6M@;Hg-_jUP+M7+H3K(_V}YP?53w-X)mqe^~@gpB0jgY*MjO z+i?S4KIciUy+yxzMzH~_p_vGyW-$)T+;y$6l@`@m1^5>95^?ab9`~%(J&sPJMSe>@ zwt|lc`Kdhodeu80FZqSuM#g!$m;w<=Y?Sd{4z`pJeX(FQEj*Qr@VJT3oG|g-MM?FN za847rUqw^3Xak>?)JIZFOZNrtdFPfatbm9`tdyDbA|72GSU2uEGB6wTL=0Wj;OMNt zN;I_g1?+%&BI;5XVA9IKYR0tB$F1PJr-CW)mIdl3&Z~BI1`WAMS(T8j;F*2 zAl6NpE}4ZJx&zC!dQSp2fJR4>SQV(f9a!qs{n5AsYW$)m3gdl&?V=|<68AzINzxaN w$P4T^%pYNR7X}GfB*XI^flZ5P3B?e9TbstT|NiBQ> /etc/ssh/sshd_config - RUN echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config - RUN mkdir -p -m 700 /root/.ssh - # Put your own public key here! - RUN echo "ssh-rsa [#a public ssh key]" > /root/.ssh/authorized_keys +# I'm developing in a version of docker that requires root. +# So by default I use root. Feel free to adapt. +RUN echo "PermitRootLogin prohibit-password" >> /etc/ssh/sshd_config +RUN echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config +RUN mkdir -p -m 700 /root/.ssh +# Put your own public key here! +RUN echo "ssh-rsa [#a public ssh key]" > /root/.ssh/authorized_keys - # Some important variables are provided through the environment. - # You need to explicitly tell sshd to forward them. - # Using these variables and not paths will let you adapt to different installation locations in different containers. - # Feel free to adapt to your own convenience. - RUN touch /root/.ssh/environment &&\ - echo "CC=${CC}" >> /root/.ssh/environment &&\ - echo "CXX=${CXX}" >> /root/.ssh/environment &&\ - echo "MPICC=${MPICC}" >> /root/.ssh/environment &&\ - echo "MPICXX=${MPICXX}" >> /root/.ssh/environment &&\ - echo "MPIEXEC=${MPIEXEC}" >> /root/.ssh/environment &&\ - echo "OMPI_CC=${CC}" >> /root/.ssh/environment &&\ - echo "OMPI_CXX=${CXX}" >> /root/.ssh/environment &&\ - echo "GEOSX_TPL_DIR=${GEOSX_TPL_DIR}" >> /root/.ssh/environment +# Some important variables are provided through the environment. +# You need to explicitly tell sshd to forward them. +# Using these variables and not paths will let you adapt to different installation locations in different containers. +# Feel free to adapt to your own convenience. +RUN touch /root/.ssh/environment &&\ + echo "CC=${CC}" >> /root/.ssh/environment &&\ + echo "CXX=${CXX}" >> /root/.ssh/environment &&\ + echo "MPICC=${MPICC}" >> /root/.ssh/environment &&\ + echo "MPICXX=${MPICXX}" >> /root/.ssh/environment &&\ + echo "MPIEXEC=${MPIEXEC}" >> /root/.ssh/environment &&\ + echo "OMPI_CC=${CC}" >> /root/.ssh/environment &&\ + echo "OMPI_CXX=${CXX}" >> /root/.ssh/environment &&\ + echo "GEOSX_TPL_DIR=${GEOSX_TPL_DIR}" >> /root/.ssh/environment - # This is the default ssh port that we do not need to modify. - EXPOSE 22 - # sshd's option -D prevents it from detaching and becoming a daemon. - # Otherwise, sshd would not block the process and `docker run` would quit. - RUN mkdir -p /run/sshd - ENTRYPOINT ["/usr/sbin/sshd", "-D"] \ No newline at end of file +# This is the default ssh port that we do not need to modify. +EXPOSE 22 +# sshd's option -D prevents it from detaching and becoming a daemon. +# Otherwise, sshd would not block the process and `docker run` would quit. +RUN mkdir -p /run/sshd +ENTRYPOINT ["/usr/sbin/sshd", "-D"] From 59b59594cf762f190c6071134685a92c235ee580 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Mon, 10 Jan 2022 01:48:26 -0800 Subject: [PATCH 22/34] implemented thermal flux kernel in the new style --- .../physicsSolvers/CMakeLists.txt | 1 - ...malCompositionalMultiphaseBaseKernels.hpp# | 1388 +++++++++++++++++ .../fluidFlow/CompositionalMultiphaseBase.cpp | 28 +- .../fluidFlow/CompositionalMultiphaseFVM.cpp | 20 +- ...rmalCompositionalMultiphaseBaseKernels.hpp | 11 +- ...ermalCompositionalMultiphaseFVMKernels.hpp | 22 +- ...rmalCompositionalMultiphaseBaseKernels.hpp | 198 ++- ...ermalCompositionalMultiphaseFVMKernels.cpp | 878 ----------- ...ermalCompositionalMultiphaseFVMKernels.hpp | 752 +++++++-- 9 files changed, 2152 insertions(+), 1146 deletions(-) create mode 100644 src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# delete mode 100644 src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.cpp diff --git a/src/coreComponents/physicsSolvers/CMakeLists.txt b/src/coreComponents/physicsSolvers/CMakeLists.txt index f7c058565a4..4522047ba31 100644 --- a/src/coreComponents/physicsSolvers/CMakeLists.txt +++ b/src/coreComponents/physicsSolvers/CMakeLists.txt @@ -93,7 +93,6 @@ set( physicsSolvers_sources fluidFlow/CompositionalMultiphaseBase.cpp fluidFlow/CompositionalMultiphaseFVM.cpp fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.cpp - fluidFlow/ThermalCompositionalMultiphaseFVMKernels.cpp fluidFlow/CompositionalMultiphaseHybridFVM.cpp fluidFlow/CompositionalMultiphaseHybridFVMKernels.cpp fluidFlow/FlowSolverBase.cpp diff --git a/src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# b/src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# new file mode 100644 index 00000000000..633c6ad1a62 --- /dev/null +++ b/src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# @@ -0,0 +1,1388 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC + * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University + * Copyright (c) 2018-2020 TotalEnergies + * Copyright (c) 2019- GEOSX Contributors + * All rights reserved + * + * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. + * ------------------------------------------------------------------------------------------------------------ + */ + +/** + * @file IsothermalCompositionalMultiphaseBaseKernels.hpp + */ + +#ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_ISOTHERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP +#define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_ISOTHERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP + +#include "common/DataLayouts.hpp" +#include "common/DataTypes.hpp" +#include "common/GEOS_RAJA_Interface.hpp" +#include "constitutive/solid/CoupledSolidBase.hpp" +#include "constitutive/fluid/MultiFluidBase.hpp" +#include "functions/TableFunction.hpp" +#include "mesh/ElementSubRegionBase.hpp" +#include "mesh/ObjectManagerBase.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" +#include "physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp" + +namespace geosx +{ + +namespace IsothermalCompositionalMultiphaseBaseKernels +{ + +using namespace constitutive; + +static constexpr real64 minDensForDivision = 1e-10; + +/******************************** PropertyKernelBase ********************************/ + +/** + * @brief Internal struct to provide no-op defaults used in the inclusion + * of lambda functions into kernel component functions. + * @struct NoOpFunc + */ +struct NoOpFunc +{ + template< typename ... Ts > + GEOSX_HOST_DEVICE + constexpr void + operator()( Ts && ... ) const {} +}; + +/** + * @class PropertyKernelBase + * @tparam NUM_COMP number of fluid components + * @brief Define the base interface for the property update kernels + */ +template< integer NUM_COMP > +class PropertyKernelBase +{ +public: + + /// Compile time value for the number of components + static constexpr integer numComp = NUM_COMP; + + /** + * @brief Performs the kernel launch + * @tparam POLICY the policy used in the RAJA kernels + * @tparam KERNEL_TYPE the kernel type + * @param[in] numElems the number of elements + * @param[inout] kernelComponent the kernel component providing access to the compute function + */ + template< typename POLICY, typename KERNEL_TYPE > + static void + launch( localIndex const numElems, + KERNEL_TYPE const & kernelComponent ) + { + forAll< POLICY >( numElems, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + kernelComponent.compute( ei ); + } ); + } + + /** + * @brief Performs the kernel launch on a sorted array + * @tparam POLICY the policy used in the RAJA kernels + * @tparam KERNEL_TYPE the kernel type + * @param[in] targetSet the indices of the elements in which we compute the property + * @param[inout] kernelComponent the kernel component providing access to the compute function + */ + template< typename POLICY, typename KERNEL_TYPE > + static void + launch( SortedArrayView< localIndex const > const & targetSet, + KERNEL_TYPE const & kernelComponent ) + { + forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) + { + localIndex const ei = targetSet[ i ]; + kernelComponent.compute( ei ); + } ); + } + +}; + +namespace internal +{ + +template< typename T, typename LAMBDA > +void kernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) +{ + static_assert( std::is_integral< T >::value, "kernelLaunchSelectorCompSwitch: type should be integral" ); + + switch( value ) + { + case 1: + { lambda( std::integral_constant< T, 1 >() ); return; } + case 2: + { lambda( std::integral_constant< T, 2 >() ); return; } + case 3: + { lambda( std::integral_constant< T, 3 >() ); return; } + case 4: + { lambda( std::integral_constant< T, 4 >() ); return; } + case 5: + { lambda( std::integral_constant< T, 5 >() ); return; } + default: + { GEOSX_ERROR( "Unsupported number of components: " << value ); } + } +} + +} // namespace internal + + +/******************************** ComponentFractionKernel ********************************/ + +/** + * @class ComponentFractionKernel + * @tparam NUM_COMP number of fluid components + * @brief Define the interface for the update kernel in charge of computing the phase volume fractions + */ +template< integer NUM_COMP > +class ComponentFractionKernel : public PropertyKernelBase< NUM_COMP > +{ +public: + + using Base = PropertyKernelBase< NUM_COMP >; + using Base::numComp; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + ComponentFractionKernel( ObjectManagerBase & subRegion ) + : Base(), + m_compDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >() ), + m_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >() ), + m_compFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >() ), + m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ) + {} + + /** + * @brief Compute the phase volume fractions in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] phaseVolFractionKernelOp the function used to customize the kernel + */ + template< typename FUNC = NoOpFunc > + GEOSX_HOST_DEVICE + void compute( localIndex const ei, + FUNC && compFractionKernelOp = NoOpFunc{} ) const + { + arraySlice1d< real64 const, compflow::USD_COMP - 1 > const compDens = m_compDens[ei]; + arraySlice1d< real64 const, compflow::USD_COMP - 1 > const dCompDens = m_dCompDens[ei]; + arraySlice1d< real64, compflow::USD_COMP - 1 > const compFrac = m_compFrac[ei]; + arraySlice2d< real64, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; + + real64 totalDensity = 0.0; + + for( integer ic = 0; ic < numComp; ++ic ) + { + totalDensity += compDens[ic] + dCompDens[ic]; + } + + real64 const totalDensityInv = 1.0 / totalDensity; + + for( integer ic = 0; ic < numComp; ++ic ) + { + compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; + for( integer jc = 0; jc < numComp; ++jc ) + { + dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; + } + dCompFrac_dCompDens[ic][ic] += totalDensityInv; + } + + compFractionKernelOp( compFrac, dCompFrac_dCompDens ); + } + +protected: + + // inputs + + // Views on component densities + arrayView2d< real64 const, compflow::USD_COMP > m_compDens; + arrayView2d< real64 const, compflow::USD_COMP > m_dCompDens; + + // outputs + + // Views on component fraction + arrayView2d< real64, compflow::USD_COMP > m_compFrac; + arrayView3d< real64, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + +}; + +/** + * @class ComponentFractionKernelFactory + */ +class ComponentFractionKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + template< typename POLICY > + static void + createAndLaunch( integer const numComp, + ObjectManagerBase & subRegion ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + ComponentFractionKernel< NUM_COMP > kernel( subRegion ); + ComponentFractionKernel< NUM_COMP >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + +}; + +/******************************** PhaseVolumeFractionKernel ********************************/ + +/** + * @class PhaseVolumeFractionKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the phase volume fractions + */ +template< integer NUM_COMP, integer NUM_PHASE > +class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > +{ +public: + + using Base = PropertyKernelBase< NUM_COMP >; + using Base::numComp; + + /// Compile time value for the number of phases + static constexpr integer numPhase = NUM_PHASE; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + PhaseVolumeFractionKernel( ObjectManagerBase & subRegion, + MultiFluidBase const & fluid ) + : Base(), + m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), + m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), + m_dPhaseVolFrac_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >() ), + m_compDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >() ), + 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_phaseDens( fluid.phaseDensity() ), + m_dPhaseDens_dPres( fluid.dPhaseDensity_dPressure() ), + m_dPhaseDens_dComp( fluid.dPhaseDensity_dGlobalCompFraction() ) + {} + + /** + * @brief Compute the phase volume fractions in an element + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[in] phaseVolFractionKernelOp the function used to customize the kernel + */ + template< typename FUNC = NoOpFunc > + GEOSX_HOST_DEVICE + void compute( localIndex const ei, + FUNC && phaseVolFractionKernelOp = NoOpFunc{} ) const + { + 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]; + 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]; + 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]; + + real64 work[numComp]{}; + + // compute total density from component partial densities + real64 totalDensity = 0.0; + real64 const dTotalDens_dCompDens = 1.0; + for( integer ic = 0; ic < numComp; ++ic ) + { + totalDensity += compDens[ic] + dCompDens[ic]; + } + + for( integer ip = 0; ip < numPhase; ++ip ) + { + + // set the saturation to zero if the phase is absent + bool const phaseExists = (phaseFrac[ip] > 0); + if( !phaseExists ) + { + phaseVolFrac[ip] = 0.; + dPhaseVolFrac_dPres[ip] = 0.; + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] = 0.; + } + continue; + } + + // Expression for volume fractions: S_p = (nu_p / rho_p) * rho_t + real64 const phaseDensInv = 1.0 / phaseDens[ip]; + + // compute saturation and derivatives except multiplying by the total density + phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; + + dPhaseVolFrac_dPres[ip] = + (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; + + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] = + (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; + } + + // apply chain rule to convert derivatives from global component fractions to densities + applyChainRuleInPlace( numComp, dCompFrac_dCompDens, dPhaseVolFrac_dComp[ip], work ); + + // call the lambda in the phase loop to allow the reuse of the phaseVolFrac and totalDensity + // possible use: assemble the derivatives wrt temperature + phaseVolFractionKernelOp( ip, phaseVolFrac[ip], phaseDensInv, totalDensity ); + + // now finalize the computation by multiplying by total density + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseVolFrac_dComp[ip][jc] *= totalDensity; + dPhaseVolFrac_dComp[ip][jc] += phaseVolFrac[ip] * dTotalDens_dCompDens; + } + + phaseVolFrac[ip] *= totalDensity; + dPhaseVolFrac_dPres[ip] *= totalDensity; + } + } + +protected: + + // outputs + + /// Views on phase volume fractions + arrayView2d< real64, compflow::USD_PHASE > m_phaseVolFrac; + arrayView2d< real64, compflow::USD_PHASE > m_dPhaseVolFrac_dPres; + arrayView3d< real64, compflow::USD_PHASE_DC > m_dPhaseVolFrac_dComp; + + // inputs + + /// Views on component densities + arrayView2d< real64 const, compflow::USD_COMP > m_compDens; + arrayView2d< real64 const, compflow::USD_COMP > m_dCompDens; + arrayView3d< real64 const, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; + + /// 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; + + /// 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; + +}; + +/** + * @class PhaseVolumeFractionKernelFactory + */ +class PhaseVolumeFractionKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + template< typename POLICY > + static void + createAndLaunch( integer const numComp, + integer const numPhase, + ObjectManagerBase & subRegion, + MultiFluidBase const & fluid ) + { + if( numPhase == 2 ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseVolumeFractionKernel< NUM_COMP, 2 > kernel( subRegion, fluid ); + PhaseVolumeFractionKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseVolumeFractionKernel< NUM_COMP, 3 > kernel( subRegion, fluid ); + PhaseVolumeFractionKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } +}; + + +/******************************** RelativePermeabilityUpdateKernel ********************************/ + +struct RelativePermeabilityUpdateKernel +{ + template< typename POLICY, typename RELPERM_WRAPPER > + static void + launch( localIndex const size, + RELPERM_WRAPPER const & relPermWrapper, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) + { + forAll< POLICY >( size, [=] GEOSX_HOST_DEVICE ( localIndex const k ) + { + for( localIndex q = 0; q < relPermWrapper.numGauss(); ++q ) + { + relPermWrapper.update( k, q, phaseVolFrac[k] ); + } + } ); + } + + template< typename POLICY, typename RELPERM_WRAPPER > + static void + launch( SortedArrayView< localIndex const > const & targetSet, + RELPERM_WRAPPER const & relPermWrapper, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) + { + forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) + { + localIndex const k = targetSet[a]; + for( localIndex q = 0; q < relPermWrapper.numGauss(); ++q ) + { + relPermWrapper.update( k, q, phaseVolFrac[k] ); + } + } ); + } +}; + +/******************************** CapillaryPressureUpdateKernel ********************************/ + +struct CapillaryPressureUpdateKernel +{ + template< typename POLICY, typename CAPPRES_WRAPPER > + static void + launch( localIndex const size, + CAPPRES_WRAPPER const & capPresWrapper, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) + { + forAll< POLICY >( size, [=] GEOSX_HOST_DEVICE ( localIndex const k ) + { + for( localIndex q = 0; q < capPresWrapper.numGauss(); ++q ) + { + capPresWrapper.update( k, q, phaseVolFrac[k] ); + } + } ); + } + + template< typename POLICY, typename CAPPRES_WRAPPER > + static void + launch( SortedArrayView< localIndex const > const & targetSet, + CAPPRES_WRAPPER const & capPresWrapper, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) + { + forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) + { + localIndex const k = targetSet[a]; + for( localIndex q = 0; q < capPresWrapper.numGauss(); ++q ) + { + capPresWrapper.update( k, q, phaseVolFrac[k] ); + } + } ); + } +}; + +/******************************** ElementBasedAssemblyKernel ********************************/ + +/** + * @class ElementBasedAssemblyKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_DOF number of degrees of freedom + * @brief Define the interface for the assembly kernel in charge of accumulation and volume balance + */ +template< integer NUM_COMP, integer NUM_DOF > +class ElementBasedAssemblyKernel +{ +public: + + /// Compile time value for the number of components + static constexpr integer numComp = NUM_COMP; + + /// Compute time value for the number of degrees of freedom + static constexpr integer numDof = NUM_DOF; + + /// Compute time value for the number of equations + static constexpr integer numEqn = NUM_DOF; + + /** + * @brief Constructor + * @param[in] numPhases the number of fluid phases + * @param[in] rankOffset the offset of my MPI rank + * @param[in] dofKey the string key to retrieve the degress of freedom numbers + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] solid the solid model + * @param[inout] localMatrix the local CRS matrix + * @param[inout] localRhs the local right-hand side vector + */ + ElementBasedAssemblyKernel( localIndex const numPhases, + globalIndex const rankOffset, + string const dofKey, + ElementSubRegionBase const & subRegion, + MultiFluidBase const & fluid, + CoupledSolidBase const & solid, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) + : m_numPhases( numPhases ), + m_rankOffset( rankOffset ), + m_dofNumber( subRegion.getReference< array1d< globalIndex > >( dofKey ) ), + m_elemGhostRank( subRegion.ghostRank() ), + m_volume( subRegion.getElementVolume() ), + m_porosityOld( solid.getOldPorosity() ), + m_porosityNew( solid.getPorosity() ), + m_dPoro_dPres( solid.getDporosity_dPressure() ), + m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ), + m_phaseVolFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFractionOld >() ), + m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), + m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), + 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_phaseCompFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseComponentFractionOld >() ), + m_phaseCompFrac( fluid.phaseCompFraction() ), + m_dPhaseCompFrac_dPres( fluid.dPhaseCompFraction_dPressure() ), + m_dPhaseCompFrac_dComp( fluid.dPhaseCompFraction_dGlobalCompFraction() ), + m_localMatrix( localMatrix ), + m_localRhs( localRhs ) + {} + + /** + * @struct StackVariables + * @brief Kernel variables (dof numbers, jacobian and residual) located on the stack + */ + struct StackVariables + { +public: + + // Pore volume information (used by both accumulation and volume balance) + + /// Pore volume at time n+1 + real64 poreVolumeNew = 0.0; + + /// Pore volume at the previous converged time step + real64 poreVolumeOld = 0.0; + + /// Derivative of pore volume with respect to pressure + real64 dPoreVolume_dPres = 0.0; + + // Residual information + + /// Index of the local row corresponding to this element + localIndex localRow = -1; + + /// Indices of the matrix rows/columns corresponding to the dofs in this element + globalIndex dofIndices[numDof]{}; + + /// C-array storage for the element local residual vector (all equations except volume balance) + real64 localResidual[numEqn]{}; + + /// C-array storage for the element local Jacobian matrix (all equations except volume balance, all dofs) + real64 localJacobian[numEqn][numDof]{}; + + }; + + /** + * @brief Getter for the ghost rank of an element + * @param[in] ei the element index + * @return the ghost rank of the element + */ + GEOSX_HOST_DEVICE + integer elemGhostRank( localIndex const ei ) const + { return m_elemGhostRank( ei ); } + + + /** + * @brief Performs the setup phase for the kernel. + * @param[in] ei the element index + * @param[in] stack the stack variables + */ + GEOSX_HOST_DEVICE + void setup( localIndex const ei, + StackVariables & stack ) const + { + // initialize the pore volume + stack.poreVolumeNew = m_volume[ei] * m_porosityNew[ei][0]; + stack.poreVolumeOld = m_volume[ei] * m_porosityOld[ei][0]; + stack.dPoreVolume_dPres = m_volume[ei] * m_dPoro_dPres[ei][0]; + + // set row index and degrees of freedom indices for this element + stack.localRow = m_dofNumber[ei] - m_rankOffset; + for( integer idof = 0; idof < numDof; ++idof ) + { + stack.dofIndices[idof] = m_dofNumber[ei] + idof; + } + } + + /** + * @brief Compute the local accumulation contributions to the residual and Jacobian + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[inout] stack the stack variables + * @param[in] phaseAmountKernelOp the function used to customize the kernel + */ + template< typename FUNC = NoOpFunc > + GEOSX_HOST_DEVICE + void computeAccumulation( localIndex const ei, + StackVariables & stack, + FUNC && phaseAmountKernelOp = NoOpFunc{} ) const + { + // construct the slices for variables accessed multiple times + arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; + + arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFracOld = m_phaseVolFracOld[ei]; + 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]; + + 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, 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]; + + // temporary work arrays + real64 dPhaseAmount_dC[numComp]{}; + real64 dPhaseCompFrac_dC[numComp]{}; + + // sum contributions to component accumulation from each phase + for( integer ip = 0; ip < m_numPhases; ++ip ) + { + real64 const phaseAmountNew = stack.poreVolumeNew * phaseVolFrac[ip] * phaseDens[ip]; + 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]); + + // assemble density dependence + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); + for( integer jc = 0; jc < numComp; ++jc ) + { + dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] + + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][jc]; + dPhaseAmount_dC[jc] *= stack.poreVolumeNew; + } + + // ic - index of component whose conservation equation is assembled + // (i.e. row number in local matrix) + for( integer ic = 0; ic < numComp; ++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]; + + stack.localResidual[ic] += phaseCompAmountNew - phaseCompAmountOld; + stack.localJacobian[ic][0] += dPhaseCompAmount_dP; + + // jc - index of component w.r.t. whose compositional var the derivative is being taken + // (i.e. col number in local matrix) + + // assemble phase composition dependence + applyChainRule( numComp, dCompFrac_dCompDens, dPhaseCompFrac_dComp[ip][ic], dPhaseCompFrac_dC ); + for( integer jc = 0; jc < numComp; ++jc ) + { + real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew + + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; + stack.localJacobian[ic][jc + 1] += dPhaseCompAmount_dC; + } + } + + // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives + // possible use: assemble the derivatives wrt temperature, and the accumulation term of the energy equation for this phase + phaseAmountKernelOp( ip, stack.localResidual, stack.localJacobian, phaseAmountNew, phaseAmountOld, dPhaseAmount_dP, dPhaseAmount_dC ); + + } + } + + /** + * @brief Compute the local volume balance contributions to the residual and Jacobian + * @tparam FUNC the type of the function that can be used to customize the kernel + * @param[in] ei the element index + * @param[inout] stack the stack variables + * @param[in] phaseVolFractionSumKernelOp the function used to customize the kernel + */ + template< typename FUNC = NoOpFunc > + GEOSX_HOST_DEVICE + void computeVolumeBalance( localIndex const ei, + StackVariables & stack, + FUNC && phaseVolFractionSumKernelOp = NoOpFunc{} ) const + { + 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]; + + real64 oneMinusPhaseVolFracSum = 1.0; + + // sum contributions to component accumulation from each phase + for( integer ip = 0; ip < m_numPhases; ++ip ) + { + oneMinusPhaseVolFracSum -= phaseVolFrac[ip]; + stack.localJacobian[numComp][0] -= dPhaseVolFrac_dPres[ip]; + + for( integer jc = 0; jc < numComp; ++jc ) + { + stack.localJacobian[numComp][jc+1] -= dPhaseVolFrac_dCompDens[ip][jc]; + } + } + + // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) + stack.localResidual[numComp] = stack.poreVolumeNew * oneMinusPhaseVolFracSum; + for( integer idof = 0; idof < numComp+1; ++idof ) + { + stack.localJacobian[numComp][idof] *= stack.poreVolumeNew; + } + stack.localJacobian[numComp][0] += stack.dPoreVolume_dPres * oneMinusPhaseVolFracSum; + + // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives + // possible use: assemble the derivatives wrt temperature, and use oneMinusPhaseVolFracSum if poreVolumeNew depends on temperature + phaseVolFractionSumKernelOp( stack.localResidual, stack.localJacobian, oneMinusPhaseVolFracSum ); + } + + /** + * @brief Performs the complete phase for the kernel. + * @param[in] ei the element index + * @param[inout] stack the stack variables + */ + GEOSX_HOST_DEVICE + void complete( localIndex const GEOSX_UNUSED_PARAM( ei ), + StackVariables & stack ) const + { + using namespace CompositionalMultiphaseUtilities; + + // apply equation/variable change transformation to the component mass balance equations + real64 work[numDof]{}; + shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( numComp, numDof, stack.localJacobian, work ); + shiftElementsAheadByOneAndReplaceFirstElementWithSum( numComp, stack.localResidual ); + + // add contribution to residual and jacobian into: + // - the component mass balance equations (i = 0 to i = numComp-1) + // - the volume balance equations (i = numComp) + // note that numDof includes derivatives wrt temperature if this class is derived in ThermalKernels + for( integer i = 0; i < numComp+1; ++i ) + { + m_localRhs[stack.localRow + i] += stack.localResidual[i]; + m_localMatrix.addToRow< serialAtomic >( stack.localRow + i, + stack.dofIndices, + stack.localJacobian[i], + numDof ); + } + } + + /** + * @brief Performs the kernel launch + * @tparam POLICY the policy used in the RAJA kernels + * @tparam KERNEL_TYPE the kernel type + * @param[in] numElems the number of elements + * @param[inout] kernelComponent the kernel component providing access to setup/compute/complete functions and stack variables + */ + template< typename POLICY, typename KERNEL_TYPE > + static void + launch( localIndex const numElems, + KERNEL_TYPE const & kernelComponent ) + { + GEOSX_MARK_FUNCTION; + + forAll< POLICY >( numElems, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( kernelComponent.elemGhostRank( ei ) >= 0 ) + { + return; + } + + typename KERNEL_TYPE::StackVariables stack; + + kernelComponent.setup( ei, stack ); + kernelComponent.computeAccumulation( ei, stack ); + kernelComponent.computeVolumeBalance( ei, stack ); + kernelComponent.complete( ei, stack ); + } ); + } + +protected: + + /// Number of fluid phases + integer const m_numPhases; + + /// Offset for my MPI rank + globalIndex const m_rankOffset; + + /// View on the dof numbers + arrayView1d< globalIndex const > const m_dofNumber; + + /// View on the ghost ranks + arrayView1d< integer const > const m_elemGhostRank; + + /// View on the element volumes + arrayView1d< real64 const > const m_volume; + + /// Views on the porosity + arrayView2d< real64 const > const m_porosityOld; + arrayView2d< real64 const > const m_porosityNew; + arrayView2d< real64 const > const m_dPoro_dPres; + + /// 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) + 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) + 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; + + /// Views on the phase component fraction (excluding derivative wrt temperature) + 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; + + /// View on the local CRS matrix + CRSMatrixView< real64, globalIndex const > const m_localMatrix; + /// View on the local RHS + arrayView1d< real64 > const m_localRhs; + +}; + +/** + * @class ElementBasedAssemblyKernelFactory + */ +class ElementBasedAssemblyKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComps the number of fluid components + * @param[in] numPhases the number of fluid phases + * @param[in] rankOffset the offset of my MPI rank + * @param[in] dofKey the string key to retrieve the degress of freedom numbers + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] solid the solid model + * @param[inout] localMatrix the local CRS matrix + * @param[inout] localRhs the local right-hand side vector + */ + template< typename POLICY > + static void + createAndLaunch( integer const numComps, + integer const numPhases, + globalIndex const rankOffset, + string const dofKey, + ElementSubRegionBase const & subRegion, + MultiFluidBase const & fluid, + CoupledSolidBase const & solid, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) + { + internal::kernelLaunchSelectorCompSwitch( numComps, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + integer constexpr NUM_DOF = NC()+1; + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > + kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); + ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + +}; + +/******************************** ResidualNormKernel ********************************/ + +struct ResidualNormKernel +{ + + template< typename POLICY, typename REDUCE_POLICY > + static void launch( arrayView1d< real64 const > const & localResidual, + globalIndex const rankOffset, + integer const numComponents, + arrayView1d< globalIndex const > const & dofNumber, + arrayView1d< integer const > const & ghostRank, + arrayView1d< real64 const > const & refPoro, + arrayView1d< real64 const > const & volume, + arrayView1d< real64 const > const & totalDensOld, + real64 & localResidualNorm ) + { + RAJA::ReduceSum< REDUCE_POLICY, real64 > localSum( 0.0 ); + + forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( ghostRank[ei] < 0 ) + { + localIndex const localRow = dofNumber[ei] - rankOffset; + real64 const normalizer = totalDensOld[ei] * refPoro[ei] * volume[ei]; + + for( integer idof = 0; idof < numComponents + 1; ++idof ) + { + real64 const val = localResidual[localRow + idof] / normalizer; + localSum += val * val; + } + } + } ); + localResidualNorm += localSum.get(); + } + +}; + + +/******************************** SolutionCheckKernel ********************************/ + +struct SolutionCheckKernel +{ + template< typename POLICY, typename REDUCE_POLICY > + static localIndex + launch( arrayView1d< real64 const > const & localSolution, + globalIndex const rankOffset, + localIndex const numComponents, + arrayView1d< globalIndex const > const & dofNumber, + arrayView1d< integer const > const & ghostRank, + arrayView1d< real64 const > const & pres, + arrayView1d< real64 const > const & dPres, + arrayView2d< real64 const, compflow::USD_COMP > const & compDens, + arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, + integer const allowCompDensChopping, + real64 const scalingFactor ) + { + real64 constexpr eps = minDensForDivision; + + RAJA::ReduceMin< REDUCE_POLICY, integer > check( 1 ); + + forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) + { + if( ghostRank[ei] < 0 ) + { + localIndex const localRow = dofNumber[ei] - rankOffset; + { + real64 const newPres = pres[ei] + dPres[ei] + scalingFactor * localSolution[localRow]; + check.min( newPres >= 0.0 ); + } + + // if component density chopping is not allowed, the time step fails if a component density is negative + // otherwise, we just check that the total density is positive, and negative component densities + // will be chopped (i.e., set to zero) in ApplySystemSolution) + if( !allowCompDensChopping ) + { + for( integer ic = 0; ic < numComponents; ++ic ) + { + real64 const newDens = compDens[ei][ic] + dCompDens[ei][ic] + scalingFactor * localSolution[localRow + ic + 1]; + check.min( newDens >= 0.0 ); + } + } + else + { + real64 totalDens = 0.0; + for( integer ic = 0; ic < numComponents; ++ic ) + { + real64 const newDens = compDens[ei][ic] + dCompDens[ei][ic] + scalingFactor * localSolution[localRow + ic + 1]; + totalDens += (newDens > 0.0) ? newDens : 0.0; + } + check.min( totalDens >= eps ); + } + } + } ); + return check.get(); + } + +}; + +/******************************** HydrostaticPressureKernel ********************************/ + +struct HydrostaticPressureKernel +{ + + // TODO: this type of constants should be centralized somewhere or provided by fluid model + static real64 constexpr MIN_FOR_PHASE_PRESENCE = 1e-12; + + enum class ReturnType : integer + { + FAILED_TO_CONVERGE = 0, + DETECTED_MULTIPHASE_FLOW = 1, + SUCCESS = 2 + }; + + template< typename FLUID_WRAPPER > + static ReturnType + computeHydrostaticPressure( integer const numComps, + integer const numPhases, + integer const ipInit, + integer const maxNumEquilIterations, + real64 const & equilTolerance, + real64 const (&gravVector)[ 3 ], + FLUID_WRAPPER fluidWrapper, + arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers, + TableFunction::KernelWrapper tempTableWrapper, + real64 const & refElevation, + real64 const & refPres, + arraySlice1d< real64 const > const & refPhaseMassDens, + real64 const & newElevation, + real64 & newPres, + arraySlice1d< real64 > const & newPhaseMassDens ) + { + // fluid properties at this elevation + StackArray< real64, 2, constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, compflow::LAYOUT_COMP > compFrac( 1, numComps ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseFrac( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseDens( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseMassDens( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseVisc( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseEnthalpy( 1, 1, numPhases ); + StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseInternalEnergy( 1, 1, numPhases ); + StackArray< real64, 4, constitutive::MultiFluidBase::MAX_NUM_PHASES *constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, + multifluid::LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhases, numComps ); + real64 totalDens = 0.0; + + bool isSinglePhaseFlow = true; + + // Step 1: compute the hydrostatic pressure at the current elevation + + real64 const gravCoef = gravVector[2] * ( refElevation - newElevation ); + real64 const temp = tempTableWrapper.compute( &newElevation ); + for( integer ic = 0; ic < numComps; ++ic ) + { + compFrac[0][ic] = compFracTableWrappers[ic].compute( &newElevation ); + } + + // Step 2: guess the pressure with the refPhaseMassDensity + + real64 pres0 = refPres - refPhaseMassDens[ipInit] * gravCoef; + real64 pres1 = 0.0; + + // Step 3: compute the mass density at this elevation using the guess, and update pressure + + fluidWrapper.compute( pres0, + temp, + compFrac[0], + phaseFrac[0][0], + phaseDens[0][0], + phaseMassDens[0][0], + phaseVisc[0][0], + phaseEnthalpy[0][0], + phaseInternalEnergy[0][0], + phaseCompFrac[0][0], + totalDens ); + pres1 = refPres - 0.5 * ( refPhaseMassDens[ipInit] + phaseMassDens[0][0][ipInit] ) * gravCoef; + + // Step 4: fixed-point iteration until convergence + + bool equilHasConverged = false; + for( integer eqIter = 0; eqIter < maxNumEquilIterations; ++eqIter ) + { + + // check convergence + equilHasConverged = ( LvArray::math::abs( pres0 - pres1 ) < equilTolerance ); + pres0 = pres1; + + // if converged, check number of phases and move on + if( equilHasConverged ) + { + // make sure that the fluid is single-phase, other we have to issue a warning (for now) + // if only one phase is mobile, we are in good shape (unfortunately it is hard to access relperm from here) + localIndex numberOfPhases = 0; + for( integer ip = 0; ip < numPhases; ++ip ) + { + if( phaseFrac[0][0][ip] > MIN_FOR_PHASE_PRESENCE ) + { + numberOfPhases++; + } + } + if( numberOfPhases > 1 ) + { + isSinglePhaseFlow = false; + } + + break; + } + + // compute the mass density at this elevation using the previous pressure, and compute the new pressure + fluidWrapper.compute( pres0, + temp, + compFrac[0], + phaseFrac[0][0], + phaseDens[0][0], + phaseMassDens[0][0], + phaseVisc[0][0], + phaseEnthalpy[0][0], + phaseInternalEnergy[0][0], + phaseCompFrac[0][0], + totalDens ); + pres1 = refPres - 0.5 * ( refPhaseMassDens[ipInit] + phaseMassDens[0][0][ipInit] ) * gravCoef; + } + + // Step 5: save the hydrostatic pressure and the corresponding density + + newPres = pres1; + for( integer ip = 0; ip < numPhases; ++ip ) + { + newPhaseMassDens[ip] = phaseMassDens[0][0][ip]; + } + + if( !equilHasConverged ) + { + return ReturnType::FAILED_TO_CONVERGE; + } + else if( !isSinglePhaseFlow ) + { + return ReturnType::DETECTED_MULTIPHASE_FLOW; + } + else + { + return ReturnType::SUCCESS; + } + } + + template< typename FLUID_WRAPPER > + static ReturnType + launch( localIndex const size, + integer const numComps, + integer const numPhases, + integer const ipInit, + integer const maxNumEquilIterations, + real64 const equilTolerance, + real64 const (&gravVector)[ 3 ], + real64 const & minElevation, + real64 const & elevationIncrement, + real64 const & datumElevation, + real64 const & datumPres, + FLUID_WRAPPER fluidWrapper, + arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers, + TableFunction::KernelWrapper tempTableWrapper, + arrayView1d< arrayView1d< real64 > const > elevationValues, + arrayView1d< real64 > pressureValues ) + { + + ReturnType returnVal = ReturnType::SUCCESS; + + // Step 1: compute the phase mass densities at datum + + // datum fluid properties + array2d< real64, compflow::LAYOUT_COMP > datumCompFrac( 1, numComps ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseFrac( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseDens( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseMassDens( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseVisc( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseEnthalpy( 1, 1, numPhases ); + array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseInternalEnergy( 1, 1, numPhases ); + array4d< real64, multifluid::LAYOUT_PHASE_COMP > datumPhaseCompFrac( 1, 1, numPhases, numComps ); + real64 datumTotalDens = 0.0; + + real64 const datumTemp = tempTableWrapper.compute( &datumElevation ); + for( integer ic = 0; ic < numComps; ++ic ) + { + datumCompFrac[0][ic] = compFracTableWrappers[ic].compute( &datumElevation ); + } + fluidWrapper.compute( datumPres, + datumTemp, + datumCompFrac[0], + datumPhaseFrac[0][0], + datumPhaseDens[0][0], + datumPhaseMassDens[0][0], + datumPhaseVisc[0][0], + datumPhaseEnthalpy[0][0], + datumPhaseInternalEnergy[0][0], + datumPhaseCompFrac[0][0], + datumTotalDens ); + + // Step 2: find the closest elevation to datumElevation + + forAll< parallelHostPolicy >( size, [=] ( localIndex const i ) + { + real64 const elevation = minElevation + i * elevationIncrement; + elevationValues[0][i] = elevation; + } ); + integer const iRef = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(), + elevationValues[0].size(), + datumElevation ); + + // Step 3: compute the mass density and pressure at the reference elevation + + array2d< real64 > phaseMassDens( pressureValues.size(), numPhases ); + // temporary array without permutation to compile on Lassen + array1d< real64 > datumPhaseMassDensTmp( numPhases ); + for( integer ip = 0; ip < numPhases; ++ip ) + { + datumPhaseMassDensTmp[ip] = datumPhaseMassDens[0][0][ip]; + } + + ReturnType const refReturnVal = + computeHydrostaticPressure( numComps, + numPhases, + ipInit, + maxNumEquilIterations, + equilTolerance, + gravVector, + fluidWrapper, + compFracTableWrappers, + tempTableWrapper, + datumElevation, + datumPres, + datumPhaseMassDensTmp, + elevationValues[0][iRef], + pressureValues[iRef], + phaseMassDens[iRef] ); + if( refReturnVal == ReturnType::FAILED_TO_CONVERGE ) + { + return ReturnType::FAILED_TO_CONVERGE; + } + else if( refReturnVal == ReturnType::DETECTED_MULTIPHASE_FLOW ) + { + returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW; + } + + // Step 4: for each elevation above the reference elevation, compute the pressure + + localIndex const numEntriesAboveRef = size - iRef - 1; + forAll< serialPolicy >( numEntriesAboveRef, [=, &returnVal] ( localIndex const i ) + { + ReturnType const returnValAboveRef = + computeHydrostaticPressure( numComps, + numPhases, + ipInit, + maxNumEquilIterations, + equilTolerance, + gravVector, + fluidWrapper, + compFracTableWrappers, + tempTableWrapper, + elevationValues[0][iRef+i], + pressureValues[iRef+i], + phaseMassDens[iRef+i], + elevationValues[0][iRef+i+1], + pressureValues[iRef+i+1], + phaseMassDens[iRef+i+1] ); + if( returnValAboveRef == ReturnType::FAILED_TO_CONVERGE ) + { + returnVal = ReturnType::FAILED_TO_CONVERGE; + } + else if( ( returnValAboveRef == ReturnType::DETECTED_MULTIPHASE_FLOW ) && + ( returnVal != ReturnType::FAILED_TO_CONVERGE ) ) + { + returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW; + } + + } ); + + // Step 5: for each elevation below the reference elevation, compute the pressure + + localIndex const numEntriesBelowRef = iRef; + forAll< serialPolicy >( numEntriesBelowRef, [=, &returnVal] ( localIndex const i ) + { + ReturnType const returnValBelowRef = + computeHydrostaticPressure( numComps, + numPhases, + ipInit, + maxNumEquilIterations, + equilTolerance, + gravVector, + fluidWrapper, + compFracTableWrappers, + tempTableWrapper, + elevationValues[0][iRef-i], + pressureValues[iRef-i], + phaseMassDens[iRef-i], + elevationValues[0][iRef-i-1], + pressureValues[iRef-i-1], + phaseMassDens[iRef-i-1] ); + if( returnValBelowRef == ReturnType::FAILED_TO_CONVERGE ) + { + returnVal = ReturnType::FAILED_TO_CONVERGE; + } + else if( ( returnValBelowRef == ReturnType::DETECTED_MULTIPHASE_FLOW ) && + ( returnVal != ReturnType::FAILED_TO_CONVERGE ) ) + { + returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW; + } + + } ); + + return returnVal; + } + +}; + + +/******************************** Kernel launch machinery ********************************/ + +template< typename KERNELWRAPPER, typename ... ARGS > +void KernelLaunchSelector1( integer const numComp, ARGS && ... args ) +{ + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + KERNELWRAPPER::template launch< NC() >( std::forward< ARGS >( args )... ); + } ); +} + +template< typename KERNELWRAPPER, typename ... ARGS > +void KernelLaunchSelector2( integer const numComp, integer const numPhase, ARGS && ... args ) +{ + // Ideally this would be inside the dispatch, but it breaks on Summit with GCC 9.1.0 and CUDA 11.0.3. + if( numPhase == 2 ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + KERNELWRAPPER::template launch< NC(), 2 >( std::forward< ARGS >( args ) ... ); + } ); + } + else if( numPhase == 3 ) + { + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + KERNELWRAPPER::template launch< NC(), 3 >( std::forward< ARGS >( args ) ... ); + } ); + } + else + { + GEOSX_ERROR( "Unsupported number of phases: " << numPhase ); + } +} + +} // namespace IsothermalCompositionalMultiphaseBaseKernels + +} // namespace geosx + + +#endif //GEOSX_PHYSICSSOLVERS_FLUIDFLOW_ISOTHERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 10d43088512..90622d9a294 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -401,7 +401,7 @@ void CompositionalMultiphaseBase::updatePhaseVolumeFraction( ObjectManagerBase & } else { - IsothermalCompositionalMultiphaseBaseKernels:: // TODO FRANCOIS + ThermalCompositionalMultiphaseBaseKernels:: PhaseVolumeFractionKernelFactory:: createAndLaunch< parallelDevicePolicy<> >( m_numComponents, m_numPhases, @@ -1011,19 +1011,29 @@ void CompositionalMultiphaseBase::assembleAccumulationAndVolumeBalanceTerms( Dom { IsothermalCompositionalMultiphaseBaseKernels:: ElementBasedAssemblyKernelFactory:: - createAndLaunch< parallelDevicePolicy<> > - ( m_numComponents, m_numPhases, dofManager.rankOffset(), dofKey, - subRegion, fluid, solid, - localMatrix, localRhs ); + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dofManager.rankOffset(), + dofKey, + subRegion, + fluid, + solid, + localMatrix, + localRhs ); } else { ThermalCompositionalMultiphaseBaseKernels:: ElementBasedAssemblyKernelFactory:: - createAndLaunch< parallelDevicePolicy<> > - ( m_numComponents, m_numPhases, dofManager.rankOffset(), dofKey, - subRegion, fluid, solid, - localMatrix, localRhs ); + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dofManager.rankOffset(), + dofKey, + subRegion, + fluid, + solid, + localMatrix, + localRhs ); } } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 90bcbad83f8..978a395d52b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -126,7 +126,23 @@ void CompositionalMultiphaseFVM::assembleFluxTerms( real64 const dt, } else { - // TODO FRANCOIS + ThermalCompositionalMultiphaseFVMKernels:: + FaceBasedAssemblyKernelFactory:: + createAndLaunch< parallelDevicePolicy<> >( m_numComponents, + m_numPhases, + dofManager.rankOffset(), + elemDofKey, + m_capPressureFlag, + getName(), + mesh.getElemManager(), + stencilWrapper, + targetRegionNames(), + fluidModelNames(), + capPresModelNames(), + permeabilityModelNames(), + dt, + localMatrix.toViewConstSizes(), + localRhs.toView() ); } } ); } @@ -551,7 +567,7 @@ void CompositionalMultiphaseFVM::updatePhaseMobility( ObjectManagerBase & dataGr } else { - IsothermalCompositionalMultiphaseFVMKernels:: // TODO FRANCOIS + ThermalCompositionalMultiphaseFVMKernels:: PhaseMobilityKernelFactory:: createAndLaunch< parallelDevicePolicy<> >( m_numComponents, m_numPhases, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp index 7705bfd88eb..5c55eaeb80e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp @@ -357,7 +357,7 @@ class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > // call the lambda in the phase loop to allow the reuse of the phaseVolFrac and totalDensity // possible use: assemble the derivatives wrt temperature - phaseVolFractionKernelOp( ip, phaseVolFrac[ip], totalDensity ); + phaseVolFractionKernelOp( ip, phaseVolFrac[ip], phaseDensInv, totalDensity ); // now finalize the computation by multiplying by total density for( integer jc = 0; jc < numComp; ++jc ) @@ -730,7 +730,7 @@ class ElementBasedAssemblyKernel // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives // possible use: assemble the derivatives wrt temperature, and the accumulation term of the energy equation for this phase - phaseAmountKernelOp( ip, stack.localResidual, stack.localJacobian, phaseAmountNew, phaseAmountOld, dPhaseAmount_dP, dPhaseAmount_dC ); + phaseAmountKernelOp( ip, phaseAmountNew, phaseAmountOld, dPhaseAmount_dP, dPhaseAmount_dC ); } } @@ -776,7 +776,7 @@ class ElementBasedAssemblyKernel // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives // possible use: assemble the derivatives wrt temperature, and use oneMinusPhaseVolFracSum if poreVolumeNew depends on temperature - phaseVolFractionSumKernelOp( stack.localResidual, stack.localJacobian, oneMinusPhaseVolFracSum ); + phaseVolFractionSumKernelOp( oneMinusPhaseVolFracSum ); } /** @@ -796,8 +796,9 @@ class ElementBasedAssemblyKernel shiftElementsAheadByOneAndReplaceFirstElementWithSum( numComp, stack.localResidual ); // add contribution to residual and jacobian into: - // - the component mass balance equations - // - the volume balance equations + // - the component mass balance equations (i = 0 to i = numComp-1) + // - the volume balance equations (i = numComp) + // note that numDof includes derivatives wrt temperature if this class is derived in ThermalKernels for( integer i = 0; i < numComp+1; ++i ) { m_localRhs[stack.localRow + i] += stack.localResidual[i]; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index 4e369091761..a49e6752783 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -586,13 +586,11 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase * @param[in] phaseFluxKernelOp the function used to customize the computation of the phase fluxes * @param[in] localFluxJacobianKernelOp the function used to customize the computation of the assembly into the local Jacobian */ - template< typename FUNC1 = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc, - typename FUNC2 = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc > + template< typename FUNC = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc > GEOSX_HOST_DEVICE void computeFlux( localIndex const iconn, StackVariables & stack, - FUNC1 && phaseFluxKernelOp = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc{}, - FUNC2 && localFluxJacobianKernelOp = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc{} ) const + FUNC && compFluxKernelOp = IsothermalCompositionalMultiphaseBaseKernels::NoOpFunc{} ) const { // first, compute the transmissibilities at this face m_stencilWrapper.computeWeights( iconn, @@ -815,8 +813,7 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase // call the lambda in the phase loop to allow the reuse of the phase fluxes and their derivatives // possible use: assemble the derivatives wrt temperature, and the flux term of the energy equation for this phase - // note: more variables may need to be passed, but it is hard to tell which ones will be needed for now - phaseFluxKernelOp( ip, er_up, esr_up, ei_up, phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC ); + compFluxKernelOp( ip, k_up, er_up, esr_up, ei_up, potGrad, phaseFlux, dPhaseFlux_dP, dPhaseFlux_dC ); } @@ -842,13 +839,6 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase } } } - - // call the lambda to allow assembly into the localFluxJacobian - // possible uses: - assemble the derivatives of compFlux wrt temperature into localFluxJacobian; - // - assemble energyFlux into localFlux and localFluxJacobian - // TODO: this second kernelOp becomes unnecessary if we increment the residual/jacobian directly in the phase loop - localFluxJacobianKernelOp( stack.localFlux, stack.localFluxJacobian ); - } /** @@ -869,7 +859,9 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( numComp, stack.numFluxElems, stack.localFlux ); - // Add to residual/jacobian + // add contribution to residual and jacobian into: + // - the component mass balance equations (i = 0 to i = numComp-1) + // note that numDof includes derivatives wrt temperature if this class is derived in ThermalKernels for( integer i = 0; i < stack.numFluxElems; ++i ) { if( m_ghostRank[m_seri( iconn, i )][m_sesri( iconn, i )][m_sei( iconn, i )] < 0 ) @@ -917,7 +909,7 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase } ); } -private: +protected: // Stencil information diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index 3b65da33797..2e5f87623f8 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -19,13 +19,7 @@ #ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP #define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP -#include "common/DataLayouts.hpp" -#include "common/DataTypes.hpp" -#include "common/GEOS_RAJA_Interface.hpp" -#include "constitutive/fluid/layouts.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp" -#include "mesh/ElementRegionManager.hpp" - namespace geosx { @@ -39,68 +33,118 @@ using namespace constitutive; /******************************** PhaseVolumeFractionKernel ********************************/ /** - * @brief Functions to compute phase volume fractions (saturations) and derivatives + * @class PhaseVolumeFractionKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the phase volume fractions */ -struct PhaseVolumeFractionKernel +template< integer NUM_COMP, integer NUM_PHASE > +class PhaseVolumeFractionKernel : public IsothermalCompositionalMultiphaseBaseKernels::PhaseVolumeFractionKernel< NUM_COMP, NUM_PHASE > { - template< localIndex NC, localIndex NP > +public: + + using Base = IsothermalCompositionalMultiphaseBaseKernels::PhaseVolumeFractionKernel< NUM_COMP, NUM_PHASE >; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + PhaseVolumeFractionKernel( ObjectManagerBase & subRegion, + MultiFluidBase const & fluid ) + : Base( subRegion, fluid ), + m_dPhaseVolFrac_dTemp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature >() ), + m_dPhaseFrac_dTemp( fluid.dPhaseFraction_dTemperature() ), + m_dPhaseDens_dTemp( fluid.dPhaseDensity_dTemperature() ) + {} + + /** + * @brief Compute the phase volume fractions in an element + * @param[in] ei the element index + */ GEOSX_HOST_DEVICE + void compute( localIndex const ei ) const + { + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseDens_dTemp = m_dPhaseDens_dTemp[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseFrac_dTemp = m_dPhaseFrac_dTemp[ei][0]; + + arraySlice1d< real64, compflow::USD_PHASE - 1 > const dPhaseVolFrac_dTemp = m_dPhaseVolFrac_dTemp[ei]; + LvArray::forValuesInSlice( dPhaseVolFrac_dTemp, []( real64 & val ){ val = 0.0; } ); + + Base::compute( ei, [=] GEOSX_HOST_DEVICE ( localIndex const ip, + real64 const & phaseVolFrac, + real64 const & phaseDensInv, + real64 const & totalDensity ) + { + // for each phase, compute the derivative of phase volume fraction wrt temperature + dPhaseVolFrac_dTemp[ip] = (dPhaseFrac_dTemp[ip] - phaseVolFrac * dPhaseDens_dTemp[ip]) * phaseDensInv; + dPhaseVolFrac_dTemp[ip] *= totalDensity; + } ); + } + +protected: + + // outputs + + /// Views on thermal derivatives of phase volume fractions + arrayView2d< real64, compflow::USD_PHASE > m_dPhaseVolFrac_dTemp; + + // inputs + + /// Views on thermal derivatives of phase fractions + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseFrac_dTemp; + + /// Views on thermal derivatives of phase densities + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseDens_dTemp; + +}; + +/** + * @class PhaseVolumeFractionKernelFactory + */ +class PhaseVolumeFractionKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + */ + template< typename POLICY > static void - compute( arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & compDens, - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const & 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, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseFrac, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseFrac_dPres, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseFrac_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseFrac_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseFrac, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseFrac, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseFrac_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp ); + createAndLaunch( integer const numComp, + integer const numPhase, + ObjectManagerBase & subRegion, + MultiFluidBase const & fluid ) + { + if( numPhase == 2 ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseVolumeFractionKernel< NUM_COMP, 2 > kernel( subRegion, fluid ); + PhaseVolumeFractionKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseVolumeFractionKernel< NUM_COMP, 3 > kernel( subRegion, fluid ); + PhaseVolumeFractionKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } }; + /******************************** ElementBasedAssemblyKernel ********************************/ /** @@ -176,7 +220,6 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK m_rockDensity( solid.getDensity() ) {} - // This seems useless, but if I remove it, it does not compile struct StackVariables : public Base::StackVariables { public: @@ -243,9 +286,10 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK void computeAccumulation( localIndex const ei, StackVariables & stack ) const { + real64 * localResidualPtr = stack.localResidual; + real64 ( *localJacobianPtr )[numDof] = stack.localJacobian; + Base::computeAccumulation( ei, stack, [=] GEOSX_HOST_DEVICE ( localIndex const ip, - real64 (& localResidual)[numEqn], - real64 (& localJacobian)[numEqn][numDof], real64 const & phaseAmountNew, real64 const & phaseAmountOld, real64 const & dPhaseAmount_dP, @@ -278,8 +322,8 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] + phaseVolFrac[ip] * dPhaseDens_dTemp[ip]); for( integer ic = 0; ic < numComp; ++ic ) { - localJacobian[ic][numDof-1] += dPhaseAmount_dT * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; + localJacobianPtr[ic][numDof-1] += dPhaseAmount_dT * phaseCompFrac[ip][ic] + + phaseAmountNew * dPhaseCompFrac_dTemp[ip][ic]; } // Step 2: assemble the phase-dependent part of the accumulation term of the energy equation @@ -292,18 +336,18 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK + phaseAmountNew * dPhaseInternalEnergy_dTemp[ip]; // local accumulation - localResidual[numEqn-1] = phaseEnergyNew - phaseEnergyOld; + localResidualPtr[numEqn-1] = phaseEnergyNew - phaseEnergyOld; // derivatives w.r.t. pressure and temperature - localJacobian[numEqn-1][0] += dPhaseEnergy_dP; - localJacobian[numEqn-1][numDof-1] += dPhaseEnergy_dT; + localJacobianPtr[numEqn-1][0] += dPhaseEnergy_dP; + localJacobianPtr[numEqn-1][numDof-1] += dPhaseEnergy_dT; // derivatives w.r.t. component densities applyChainRule( numComp, dCompFrac_dCompDens, dPhaseInternalEnergy_dComp[ip], dPhaseInternalEnergy_dC ); for( integer jc = 0; jc < numComp; ++jc ) { - localJacobian[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] - + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; + localJacobianPtr[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; } } ); @@ -325,17 +369,17 @@ class ElementBasedAssemblyKernel : public IsothermalCompositionalMultiphaseBaseK void computeVolumeBalance( localIndex const ei, StackVariables & stack ) const { - Base::computeVolumeBalance( ei, stack, [=] GEOSX_HOST_DEVICE ( real64 (& localResidual)[numEqn], - real64 (& localJacobian)[numEqn][numDof], - real64 const & oneMinusPhaseVolFraction ) + real64 ( *localJacobianPtr )[numDof] = stack.localJacobian; + + Base::computeVolumeBalance( ei, stack, [=] GEOSX_HOST_DEVICE ( real64 const & oneMinusPhaseVolFraction ) { - GEOSX_UNUSED_VAR( localResidual, oneMinusPhaseVolFraction ); + GEOSX_UNUSED_VAR( oneMinusPhaseVolFraction ); arraySlice1d< real64 const, compflow::USD_PHASE - 1 > dPhaseVolFrac_dTemp = m_dPhaseVolFrac_dTemp[ei]; for( integer ip = 0; ip < m_numPhases; ++ip ) { - localJacobian[numEqn-2][numDof-1] -= dPhaseVolFrac_dTemp[ip]; + localJacobianPtr[numEqn-2][numDof-1] -= dPhaseVolFrac_dTemp[ip]; } } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.cpp deleted file mode 100644 index e00ea06206e..00000000000 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.cpp +++ /dev/null @@ -1,878 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 TotalEnergies - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file ThermalCompositionalMultiphaseFVMKernels.cpp - */ - -#include "ThermalCompositionalMultiphaseFVMKernels.hpp" -#include "CompositionalMultiphaseUtilities.hpp" - -#include "finiteVolume/CellElementStencilTPFA.hpp" -#include "finiteVolume/SurfaceElementStencil.hpp" -#include "finiteVolume/EmbeddedSurfaceToCellStencil.hpp" -#include "finiteVolume/FaceElementToCellStencil.hpp" -#include "mesh/utilities/MeshMapUtilities.hpp" - - -namespace geosx -{ - -namespace ThermalCompositionalMultiphaseFVMKernels -{ - -/******************************** PhaseMobilityKernel ********************************/ - -template< localIndex NC, localIndex NP > -GEOSX_HOST_DEVICE -void -PhaseMobilityKernel:: - compute( 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, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dPres, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseVisc_dComp, - arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & phaseRelPerm, - arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dPhaseRelPerm_dPhaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseMob, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dPres, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dTemp, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseMob_dComp ) -{ - real64 dRelPerm_dC[NC]; - real64 dDens_dC[NC]; - real64 dVisc_dC[NC]; - - for( localIndex ip = 0; ip < NP; ++ip ) - { - - // compute the phase mobility only if the phase is present - bool const phaseExists = (phaseVolFrac[ip] > 0); - if( !phaseExists ) - { - phaseMob[ip] = 0.; - dPhaseMob_dPres[ip] = 0.; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = 0.; - } - continue; - } - - real64 const density = phaseDens[ip]; - real64 const dDens_dP = dPhaseDens_dPres[ip]; - real64 const dDens_dT = dPhaseDens_dTemp[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dDens_dC ); - - real64 const viscosity = phaseVisc[ip]; - real64 const dVisc_dP = dPhaseVisc_dPres[ip]; - real64 const dVisc_dT = dPhaseVisc_dTemp[ip]; - applyChainRule( NC, dCompFrac_dCompDens, dPhaseVisc_dComp[ip], dVisc_dC ); - - real64 const relPerm = phaseRelPerm[ip]; - real64 dRelPerm_dT = 0.0; - real64 dRelPerm_dP = 0.0; - for( localIndex ic = 0; ic < NC; ++ic ) - { - dRelPerm_dC[ic] = 0.0; - } - - for( localIndex jp = 0; jp < NP; ++jp ) - { - real64 const dRelPerm_dS = dPhaseRelPerm_dPhaseVolFrac[ip][jp]; - dRelPerm_dP += dRelPerm_dS * dPhaseVolFrac_dPres[jp]; - dRelPerm_dT += dRelPerm_dS * dPhaseVolFrac_dTemp[jp]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dRelPerm_dC[jc] += dRelPerm_dS * dPhaseVolFrac_dComp[jp][jc]; - } - } - - real64 const mobility = relPerm * density / viscosity; - - phaseMob[ip] = mobility; - dPhaseMob_dPres[ip] = dRelPerm_dP * density / viscosity - + mobility * (dDens_dP / density - dVisc_dP / viscosity); - dPhaseMob_dTemp[ip] = dRelPerm_dT * density / viscosity - + mobility * (dDens_dT / density - dVisc_dT / viscosity); - - // compositional derivatives - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseMob_dComp[ip][jc] = dRelPerm_dC[jc] * density / viscosity - + mobility * (dDens_dC[jc] / density - dVisc_dC[jc] / viscosity); - } - } -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( localIndex const size, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dTemp, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( size, [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dTemp[a][0], - dPhaseDens_dComp[a][0], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dTemp[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dTemp[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dTemp[a], - dPhaseMob_dComp[a] ); - } ); -} - -template< localIndex NC, localIndex NP > -void PhaseMobilityKernel:: - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dTemp, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) -{ - forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const a = targetSet[ i ]; - compute< NC, NP >( dCompFrac_dCompDens[a], - phaseDens[a][0], - dPhaseDens_dPres[a][0], - dPhaseDens_dTemp[a][0], - dPhaseDens_dComp[a][0], - phaseVisc[a][0], - dPhaseVisc_dPres[a][0], - dPhaseVisc_dTemp[a][0], - dPhaseVisc_dComp[a][0], - phaseRelPerm[a][0], - dPhaseRelPerm_dPhaseVolFrac[a][0], - phaseVolFrac[a], - dPhaseVolFrac_dPres[a], - dPhaseVolFrac_dTemp[a], - dPhaseVolFrac_dComp[a], - phaseMob[a], - dPhaseMob_dPres[a], - dPhaseMob_dTemp[a], - dPhaseMob_dComp[a] ); - } ); -} - -#define INST_PhaseMobilityKernel( NC, NP ) \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( localIndex const size, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, \ - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dTemp, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); \ - template \ - void \ - PhaseMobilityKernel:: \ - launch< NC, NP >( SortedArrayView< localIndex const > const & targetSet, \ - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, \ - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp, \ - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, \ - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, \ - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, \ - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, \ - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, \ - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, \ - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dTemp, \ - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ) - -INST_PhaseMobilityKernel( 1, 1 ); -INST_PhaseMobilityKernel( 2, 1 ); -INST_PhaseMobilityKernel( 3, 1 ); -INST_PhaseMobilityKernel( 4, 1 ); -INST_PhaseMobilityKernel( 5, 1 ); - -INST_PhaseMobilityKernel( 1, 2 ); -INST_PhaseMobilityKernel( 2, 2 ); -INST_PhaseMobilityKernel( 3, 2 ); -INST_PhaseMobilityKernel( 4, 2 ); -INST_PhaseMobilityKernel( 5, 2 ); - -INST_PhaseMobilityKernel( 1, 3 ); -INST_PhaseMobilityKernel( 2, 3 ); -INST_PhaseMobilityKernel( 3, 3 ); -INST_PhaseMobilityKernel( 4, 3 ); -INST_PhaseMobilityKernel( 5, 3 ); - -#undef INST_PhaseMobilityKernel - -/******************************** FluxKernel ********************************/ - -template< localIndex NC, localIndex MAX_NUM_ELEMS, localIndex MAX_STENCIL_SIZE > -GEOSX_HOST_DEVICE -void -FluxKernel:: - compute( localIndex const numPhases, - localIndex const stencilSize, - localIndex const numFluxElems, - arraySlice1d< localIndex const > const seri, - arraySlice1d< localIndex const > const sesri, - arraySlice1d< localIndex const > const sei, - real64 const (&transmissibility)[2], - real64 const (&dTrans_dPres)[2], - ElementViewConst< arrayView1d< real64 const > > const & pres, - ElementViewConst< arrayView1d< real64 const > > const & dPres, - ElementViewConst< arrayView1d< real64 const > > const & temp, - ElementViewConst< arrayView1d< real64 const > > const & dTemp, - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dComp, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dComp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dTemp, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dComp, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseEnthalpy, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseEnthalpy_dComp, - ElementViewConst< arrayView3d< real64 const, cappres::USD_CAPPRES > > const & phaseCapPressure, - ElementViewConst< arrayView4d< real64 const, cappres::USD_CAPPRES_DS > > const & dPhaseCapPressure_dPhaseVolFrac, - integer const capPressureFlag, - real64 const dt, - arraySlice1d< real64 > const localFlux, - arraySlice2d< real64 > const localFluxJacobian ) -{ - localIndex constexpr NDOF = NC + 2; - - // they will be useful for conduction - GEOSX_UNUSED_VAR( temp ); - GEOSX_UNUSED_VAR( dTemp ); - - stackArray1d< real64, NC > compFlux( NC ); - stackArray2d< real64, MAX_STENCIL_SIZE * NC > dCompFlux_dP( stencilSize, NC ); - stackArray2d< real64, MAX_STENCIL_SIZE * NC > dCompFlux_dT( stencilSize, NC ); - stackArray3d< real64, MAX_STENCIL_SIZE * NC * NC > dCompFlux_dC( stencilSize, NC, NC ); - - real64 enthalpyFlux = 0.0; - stackArray1d< real64, MAX_STENCIL_SIZE > dEnthalpyFlux_dP( stencilSize ); - stackArray1d< real64, MAX_STENCIL_SIZE > dEnthalpyFlux_dT( stencilSize ); - stackArray2d< real64, MAX_STENCIL_SIZE * NC > dEnthalpyFlux_dC( stencilSize, NC ); - - // loop over phases, compute and upwind phase flux and sum contributions to each component's flux - for( localIndex ip = 0; ip < numPhases; ++ip ) - { - // clear working arrays - real64 densMean{}; - stackArray1d< real64, MAX_NUM_ELEMS > dDensMean_dP( numFluxElems ); - stackArray1d< real64, MAX_NUM_ELEMS > dDensMean_dT( numFluxElems ); - stackArray2d< real64, MAX_NUM_ELEMS * NC > dDensMean_dC( numFluxElems, NC ); - - // create local work arrays - real64 phaseFlux{}; - real64 dPhaseFlux_dP[MAX_STENCIL_SIZE]{}; - real64 dPhaseFlux_dT[MAX_STENCIL_SIZE]{}; - real64 dPhaseFlux_dC[MAX_STENCIL_SIZE][NC]{}; - - real64 presGrad{}; - stackArray1d< real64, MAX_STENCIL_SIZE > dPresGrad_dP( stencilSize ); - stackArray1d< real64, MAX_STENCIL_SIZE > dPresGrad_dT( stencilSize ); - stackArray2d< real64, MAX_STENCIL_SIZE *NC > dPresGrad_dC( stencilSize, NC ); - - real64 gravHead{}; - stackArray1d< real64, MAX_NUM_ELEMS > dGravHead_dP( numFluxElems ); - stackArray1d< real64, MAX_NUM_ELEMS > dGravHead_dT( numFluxElems ); - stackArray2d< real64, MAX_NUM_ELEMS * NC > dGravHead_dC( numFluxElems, NC ); - - real64 dCapPressure_dC[NC]{}; - - // Working array - real64 dProp_dC[NC]{}; - - // calculate quantities on primary connected cells - for( localIndex i = 0; i < numFluxElems; ++i ) - { - localIndex const er = seri[i]; - localIndex const esr = sesri[i]; - localIndex const ei = sei[i]; - - // density - real64 const density = phaseMassDens[er][esr][ei][0][ip]; - real64 const dDens_dP = dPhaseMassDens_dPres[er][esr][ei][0][ip]; - real64 const dDens_dT = dPhaseMassDens_dTemp[er][esr][ei][0][ip]; - - applyChainRule( NC, - dCompFrac_dCompDens[er][esr][ei], - dPhaseMassDens_dComp[er][esr][ei][0][ip], - dProp_dC ); - - // average density and derivatives - densMean += 0.5 * density; - dDensMean_dP[i] = 0.5 * dDens_dP; - dDensMean_dT[i] = 0.5 * dDens_dT; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dDensMean_dC[i][jc] = 0.5 * dProp_dC[jc]; - } - } - - //***** calculation of flux ***** - - // compute potential difference MPFA-style - for( localIndex i = 0; i < stencilSize; ++i ) - { - localIndex const er = seri[i]; - localIndex const esr = sesri[i]; - localIndex const ei = sei[i]; - - // capillary pressure - real64 capPressure = 0.0; - real64 dCapPressure_dP = 0.0; - real64 dCapPressure_dT = 0.0; - - for( localIndex ic = 0; ic < NC; ++ic ) - { - dCapPressure_dC[ic] = 0.0; - } - - if( capPressureFlag ) - { - capPressure = phaseCapPressure[er][esr][ei][0][ip]; - - for( localIndex jp = 0; jp < numPhases; ++jp ) - { - real64 const dCapPressure_dS = dPhaseCapPressure_dPhaseVolFrac[er][esr][ei][0][ip][jp]; - dCapPressure_dP += dCapPressure_dS * dPhaseVolFrac_dPres[er][esr][ei][jp]; - dCapPressure_dT += dCapPressure_dS * dPhaseVolFrac_dTemp[er][esr][ei][jp]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCapPressure_dC[jc] += dCapPressure_dS * dPhaseVolFrac_dComp[er][esr][ei][jp][jc]; - } - } - } - - presGrad += transmissibility[i] * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); - dPresGrad_dP[i] += transmissibility[i] * (1 - dCapPressure_dP) + dTrans_dPres[i] * (pres[er][esr][ei] + dPres[er][esr][ei] - capPressure); - dPresGrad_dP[i] += transmissibility[i] * (1 - dCapPressure_dT); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPresGrad_dC[i][jc] += -transmissibility[i] * dCapPressure_dC[jc]; - } - - real64 const gravD = transmissibility[i] * gravCoef[er][esr][ei]; - real64 const dGravD_dP = dTrans_dPres[i] * gravCoef[er][esr][ei]; - - // the density used in the potential difference is always a mass density - // unlike the density used in the phase mobility, which is a mass density - // if useMass == 1 and a molar density otherwise - gravHead += densMean * gravD; - - // need to add contributions from both cells the mean density depends on - for( localIndex j = 0; j < numFluxElems; ++j ) - { - dGravHead_dP[j] += dDensMean_dP[j] * gravD + dGravD_dP * densMean; - dGravHead_dT[j] += dDensMean_dT[j] * gravD; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dGravHead_dC[j][jc] += dDensMean_dC[j][jc] * gravD; - } - } - } - - // *** upwinding *** - - // use PPU currently; advanced stuff like IHU would go here - // TODO isolate into a kernel? - - // compute phase potential gradient - real64 const potGrad = presGrad - gravHead; - - // choose upstream cell - localIndex const k_up = (potGrad >= 0) ? 0 : 1; - - localIndex const er_up = seri[k_up]; - localIndex const esr_up = sesri[k_up]; - localIndex const ei_up = sei[k_up]; - - real64 const mobility = phaseMob[er_up][esr_up][ei_up][ip]; - - // skip the phase flux if phase not present or immobile upstream - if( LvArray::math::abs( mobility ) < 1e-20 ) // TODO better constant - { - continue; - } - - // pressure gradient depends on all points in the stencil - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dPhaseFlux_dP[ke] += dPresGrad_dP[ke]; - dPhaseFlux_dT[ke] += dPresGrad_dT[ke]; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[ke][jc] += dPresGrad_dC[ke][jc]; - } - - } - - // gravitational head depends only on the two cells connected (same as mean density) - for( localIndex ke = 0; ke < numFluxElems; ++ke ) - { - dPhaseFlux_dP[ke] -= dGravHead_dP[ke]; - dPhaseFlux_dT[ke] -= dGravHead_dT[ke]; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[ke][jc] -= dGravHead_dC[ke][jc]; - } - } - - // compute the phase flux and derivatives using upstream cell mobility - phaseFlux = mobility * potGrad; - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dPhaseFlux_dP[ke] *= mobility; - dPhaseFlux_dT[ke] *= mobility; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[ke][jc] *= mobility; - } - } - - real64 const dMob_dP = dPhaseMob_dPres[er_up][esr_up][ei_up][ip]; - real64 const dMob_dT = dPhaseMob_dTemp[er_up][esr_up][ei_up][ip]; - arraySlice1d< real64 const, compflow::USD_PHASE_DC - 2 > dPhaseMob_dCompSub = dPhaseMob_dComp[er_up][esr_up][ei_up][ip]; - - // add contribution from upstream cell mobility derivatives - dPhaseFlux_dP[k_up] += dMob_dP * potGrad; - dPhaseFlux_dT[k_up] += dMob_dT * potGrad; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dPhaseFlux_dC[k_up][jc] += dPhaseMob_dCompSub[jc] * potGrad; - } - - // slice some constitutive arrays to avoid too much indexing in component loop - arraySlice1d< real64 const, multifluid::USD_PHASE_COMP-3 > phaseCompFracSub = phaseCompFrac[er_up][esr_up][ei_up][0][ip]; - arraySlice1d< real64 const, multifluid::USD_PHASE_COMP-3 > dPhaseCompFrac_dPresSub = dPhaseCompFrac_dPres[er_up][esr_up][ei_up][0][ip]; - arraySlice1d< real64 const, multifluid::USD_PHASE_COMP-3 > dPhaseCompFrac_dTempSub = dPhaseCompFrac_dTemp[er_up][esr_up][ei_up][0][ip]; - arraySlice2d< real64 const, multifluid::USD_PHASE_COMP_DC-3 > dPhaseCompFrac_dCompSub = dPhaseCompFrac_dComp[er_up][esr_up][ei_up][0][ip]; - - // compute component fluxes and derivatives using upstream cell composition - for( localIndex ic = 0; ic < NC; ++ic ) - { - real64 const ycp = phaseCompFracSub[ic]; - compFlux[ic] += phaseFlux * ycp; - - // derivatives stemming from phase flux - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dCompFlux_dP[ke][ic] += dPhaseFlux_dP[ke] * ycp; - dCompFlux_dT[ke][ic] += dPhaseFlux_dT[ke] * ycp; - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFlux_dC[ke][ic][jc] += dPhaseFlux_dC[ke][jc] * ycp; - } - } - - // additional derivatives stemming from upstream cell phase composition - dCompFlux_dP[k_up][ic] += phaseFlux * dPhaseCompFrac_dPresSub[ic]; - dCompFlux_dT[k_up][ic] += phaseFlux * dPhaseCompFrac_dTempSub[ic]; - - // convert derivatives of component fraction w.r.t. component fractions to derivatives w.r.t. component - // densities - applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseCompFrac_dCompSub[ic], dProp_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dCompFlux_dC[k_up][ic][jc] += phaseFlux * dProp_dC[jc]; - } - } - - // compute enthalpy fluxes and derivatives - real64 const enthalpy = phaseEnthalpy[er_up][esr_up][ei_up][0][ip]; - enthalpyFlux = phaseFlux * enthalpy; - - // derivatives stemming from phase flux (it was upwinded previously) - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - dEnthalpyFlux_dP[ke] = dPhaseFlux_dP[ke] * enthalpy; - dEnthalpyFlux_dT[ke] = dPhaseFlux_dT[ke] * enthalpy; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - dEnthalpyFlux_dC[ke][jc] = dPhaseFlux_dC[ke][jc] * enthalpy; - } - } - - // add contribution from upstream cell enthalpy derivatives - dEnthalpyFlux_dP[k_up] += phaseFlux * dPhaseEnthalpy_dPres[er_up][esr_up][ei_up][0][ip]; - dEnthalpyFlux_dT[k_up] += phaseFlux * dPhaseEnthalpy_dTemp[er_up][esr_up][ei_up][0][ip]; - - applyChainRule( NC, dCompFrac_dCompDens[er_up][esr_up][ei_up], dPhaseEnthalpy_dComp[er_up][esr_up][ei_up][0][ip], dProp_dC ); - for( localIndex jc = 0; jc < NC; ++jc ) - { - dEnthalpyFlux_dC[k_up][jc] += phaseFlux * dProp_dC[jc]; - } - } - - // *** end of upwinding - - // mass/molar flux - for( localIndex ic = 0; ic < NC; ++ic ) - { - localFlux[ic] = dt * compFlux[ic]; - localFlux[NC + 1 + ic] = -dt * compFlux[ic]; - - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - localIndex const localDofIndexPres = ke * NDOF; - localFluxJacobian[ic][localDofIndexPres] = dt * dCompFlux_dP[ke][ic]; - localFluxJacobian[NC + 1 + ic][localDofIndexPres] = -dt * dCompFlux_dP[ke][ic]; - localIndex const localDofIndexTemp = localDofIndexPres + NC; - localFluxJacobian[ic][localDofIndexTemp] = dt * dCompFlux_dT[ke][ic]; - localFluxJacobian[NC + 1 + ic][localDofIndexTemp] = -dt * dCompFlux_dT[ke][ic]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - localIndex const localDofIndexComp = localDofIndexPres + jc + 1; - localFluxJacobian[ic][localDofIndexComp] = dt * dCompFlux_dC[ke][ic][jc]; - localFluxJacobian[NC + 1 + ic][localDofIndexComp] = -dt * dCompFlux_dC[ke][ic][jc]; - } - } - } - - // enthalpy flux - localFlux[NC] = dt * enthalpyFlux; - localFlux[2 * NC] = -dt * enthalpyFlux; - - for( localIndex ke = 0; ke < stencilSize; ++ke ) - { - localIndex const localDofIndexPres = ke * NDOF; - localFluxJacobian[NC][localDofIndexPres] = dt * dEnthalpyFlux_dP[ke]; - localFluxJacobian[2 * NC][localDofIndexPres] = -dt * dEnthalpyFlux_dP[ke]; - localIndex const localDofIndexTemp = localDofIndexPres + NC; - localFluxJacobian[NC][localDofIndexTemp] = dt * dEnthalpyFlux_dT[ke]; - localFluxJacobian[2 * NC][localDofIndexTemp] = -dt * dEnthalpyFlux_dT[ke]; - - for( localIndex jc = 0; jc < NC; ++jc ) - { - localIndex const localDofIndexComp = localDofIndexPres + jc + 1; - localFluxJacobian[NC][localDofIndexComp] = dt * dEnthalpyFlux_dC[ke][jc]; - localFluxJacobian[2 * NC][localDofIndexComp] = -dt * dEnthalpyFlux_dC[ke][jc]; - } - } -} - -template< localIndex NC, typename STENCILWRAPPER_TYPE > -void -FluxKernel:: - launch( localIndex const numPhases, - STENCILWRAPPER_TYPE const & stencilWrapper, - globalIndex const rankOffset, - ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, - ElementViewConst< arrayView1d< integer const > > const & ghostRank, - ElementViewConst< arrayView1d< real64 const > > const & pres, - ElementViewConst< arrayView1d< real64 const > > const & dPres, - ElementViewConst< arrayView1d< real64 const > > const & temp, - ElementViewConst< arrayView1d< real64 const > > const & dTemp, - ElementViewConst< arrayView3d< real64 const > > const & permeability, - ElementViewConst< arrayView3d< real64 const > > const & dPerm_dPres, - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dComp, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dComp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dTemp, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dComp, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseEnthalpy, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseEnthalpy_dComp, - ElementViewConst< arrayView3d< real64 const, cappres::USD_CAPPRES > > const & phaseCapPressure, - ElementViewConst< arrayView4d< real64 const, cappres::USD_CAPPRES_DS > > const & dPhaseCapPressure_dPhaseVolFrac, - integer const capPressureFlag, - real64 const dt, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) -{ - using namespace CompositionalMultiphaseUtilities; - - typename STENCILWRAPPER_TYPE::IndexContainerViewConstType const & seri = stencilWrapper.getElementRegionIndices(); - typename STENCILWRAPPER_TYPE::IndexContainerViewConstType const & sesri = stencilWrapper.getElementSubRegionIndices(); - typename STENCILWRAPPER_TYPE::IndexContainerViewConstType const & sei = stencilWrapper.getElementIndices(); - - constexpr localIndex MAX_NUM_ELEMS = STENCILWRAPPER_TYPE::NUM_POINT_IN_FLUX; - constexpr localIndex MAX_STENCIL_SIZE = STENCILWRAPPER_TYPE::MAX_STENCIL_SIZE; - - forAll< parallelDevicePolicy<> >( stencilWrapper.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iconn ) - { - localIndex const stencilSize = meshMapUtilities::size1( sei, iconn ); - localIndex const numFluxElems = stencilWrapper.numPointsInFlux( iconn ); - constexpr localIndex NDOF = NC + 2; - - // working arrays - stackArray1d< globalIndex, MAX_NUM_ELEMS * NDOF > dofColIndices( stencilSize * NDOF ); - stackArray1d< real64, MAX_NUM_ELEMS * ( NC + 1 ) > localFlux( numFluxElems * ( NC + 1 ) ); - stackArray2d< real64, MAX_NUM_ELEMS * ( NC + 1 ) * MAX_STENCIL_SIZE * NDOF > localFluxJacobian( numFluxElems * ( NC + 1 ), stencilSize * NDOF ); - - // compute transmissibility - 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, - transmissibility, - dTrans_dPres ); - - FluxKernel::compute< NC, MAX_NUM_ELEMS, MAX_STENCIL_SIZE >( numPhases, - stencilSize, - numFluxElems, - seri[iconn], - sesri[iconn], - sei[iconn], - transmissibility[0], - dTrans_dPres[0], - pres, - dPres, - temp, - dTemp, - gravCoef, - phaseMob, - dPhaseMob_dPres, - dPhaseMob_dTemp, - dPhaseMob_dComp, - dPhaseVolFrac_dPres, - dPhaseVolFrac_dTemp, - dPhaseVolFrac_dComp, - dCompFrac_dCompDens, - phaseMassDens, - dPhaseMassDens_dPres, - dPhaseMassDens_dTemp, - dPhaseMassDens_dComp, - phaseCompFrac, - dPhaseCompFrac_dPres, - dPhaseCompFrac_dTemp, - dPhaseCompFrac_dComp, - phaseEnthalpy, - dPhaseEnthalpy_dPres, - dPhaseEnthalpy_dTemp, - dPhaseEnthalpy_dComp, - phaseCapPressure, - dPhaseCapPressure_dPhaseVolFrac, - capPressureFlag, - dt, - localFlux, - localFluxJacobian ); - - // populate dof indices - for( localIndex i = 0; i < stencilSize; ++i ) - { - globalIndex const offset = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; - - for( localIndex jdof = 0; jdof < NDOF; ++jdof ) - { - dofColIndices[i * NDOF + jdof] = offset + jdof; - } - } - - // Apply equation/variable change transformation(s) - stackArray1d< real64, MAX_STENCIL_SIZE * (NDOF-1) > work( stencilSize * (NDOF-1) ); - shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, (NDOF-1)*stencilSize, numFluxElems, localFluxJacobian, work ); - shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( NC, numFluxElems, localFlux ); - - // Add to residual/jacobian - for( localIndex i = 0; i < numFluxElems; ++i ) - { - if( ghostRank[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )] < 0 ) - { - globalIndex const globalRow = dofNumber[seri( iconn, i )][sesri( iconn, i )][sei( iconn, i )]; - localIndex const localRow = LvArray::integerConversion< localIndex >( globalRow - rankOffset ); - GEOSX_ASSERT_GE( localRow, 0 ); - GEOSX_ASSERT_GT( localMatrix.numRows(), localRow + NC + 1 ); - - for( localIndex ic = 0; ic < NC + 1; ++ic ) - { - RAJA::atomicAdd( parallelDeviceAtomic{}, &localRhs[localRow + ic], localFlux[i * ( NC + 1) + ic] ); - localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic >( localRow + ic, - dofColIndices.data(), - localFluxJacobian[i * ( NC + 1 ) + ic].dataIfContiguous(), - stencilSize * NDOF ); - } - } - } - } ); -} - -#define INST_FluxKernel( NC, STENCILWRAPPER_TYPE ) \ - template \ - void FluxKernel:: \ - launch< NC, STENCILWRAPPER_TYPE >( localIndex const numPhases, \ - STENCILWRAPPER_TYPE const & stencilWrapper, \ - globalIndex const rankOffset, \ - ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, \ - ElementViewConst< arrayView1d< integer const > > const & ghostRank, \ - ElementViewConst< arrayView1d< real64 const > > const & pres, \ - ElementViewConst< arrayView1d< real64 const > > const & dPres, \ - ElementViewConst< arrayView1d< real64 const > > const & temp, \ - ElementViewConst< arrayView1d< real64 const > > const & dTemp, \ - ElementViewConst< arrayView3d< real64 const > > const & permeability, \ - ElementViewConst< arrayView3d< real64 const > > const & dPerm_dPres, \ - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, \ - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, \ - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, \ - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dTemp, \ - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dComp, \ - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dPres, \ - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dTemp, \ - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dComp, \ - ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dTemp, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dComp, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dTemp, \ - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dComp, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseEnthalpy, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dPres, \ - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dTemp, \ - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseEnthalpy_dComp, \ - ElementViewConst< arrayView3d< real64 const, cappres::USD_CAPPRES > > const & phaseCapPressure, \ - ElementViewConst< arrayView4d< real64 const, cappres::USD_CAPPRES_DS > > const & dPhaseCapPressure_dPhaseVolFrac, \ - integer const capPressureFlag, \ - real64 const dt, \ - CRSMatrixView< real64, globalIndex const > const & localMatrix, \ - arrayView1d< real64 > const & localRhs ) - -INST_FluxKernel( 1, CellElementStencilTPFAWrapper ); -INST_FluxKernel( 2, CellElementStencilTPFAWrapper ); -INST_FluxKernel( 3, CellElementStencilTPFAWrapper ); -INST_FluxKernel( 4, CellElementStencilTPFAWrapper ); -INST_FluxKernel( 5, CellElementStencilTPFAWrapper ); - -INST_FluxKernel( 1, SurfaceElementStencilWrapper ); -INST_FluxKernel( 2, SurfaceElementStencilWrapper ); -INST_FluxKernel( 3, SurfaceElementStencilWrapper ); -INST_FluxKernel( 4, SurfaceElementStencilWrapper ); -INST_FluxKernel( 5, SurfaceElementStencilWrapper ); - -INST_FluxKernel( 1, EmbeddedSurfaceToCellStencilWrapper ); -INST_FluxKernel( 2, EmbeddedSurfaceToCellStencilWrapper ); -INST_FluxKernel( 3, EmbeddedSurfaceToCellStencilWrapper ); -INST_FluxKernel( 4, EmbeddedSurfaceToCellStencilWrapper ); -INST_FluxKernel( 5, EmbeddedSurfaceToCellStencilWrapper ); - -INST_FluxKernel( 1, FaceElementToCellStencilWrapper ); -INST_FluxKernel( 2, FaceElementToCellStencilWrapper ); -INST_FluxKernel( 3, FaceElementToCellStencilWrapper ); -INST_FluxKernel( 4, FaceElementToCellStencilWrapper ); -INST_FluxKernel( 5, FaceElementToCellStencilWrapper ); - -#undef INST_FluxKernel - - - -} // namespace ThermalCompositionalMultiphaseFVMKernels - -} // namespace geosx diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index 8982d3c42e9..11210ce5927 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -19,13 +19,7 @@ #ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEFVMKERNELS_HPP #define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEFVMKERNELS_HPP -#include "common/DataLayouts.hpp" -#include "common/DataTypes.hpp" -#include "common/GEOS_RAJA_Interface.hpp" -#include "constitutive/fluid/layouts.hpp" -#include "constitutive/relativePermeability/layouts.hpp" -#include "constitutive/capillaryPressure/layouts.hpp" -#include "mesh/ElementRegionManager.hpp" +#include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp" namespace geosx { @@ -38,87 +32,155 @@ using namespace constitutive; /******************************** PhaseMobilityKernel ********************************/ /** - * @brief Functions to compute phase mobilities and derivatives from density, viscosity and relperm + * @class PhaseMobilityKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_PHASE number of fluid phases + * @brief Define the interface for the property kernel in charge of computing the phase mobilities */ -struct PhaseMobilityKernel +template< integer NUM_COMP, integer NUM_PHASE > +class PhaseMobilityKernel : public IsothermalCompositionalMultiphaseFVMKernels::PhaseMobilityKernel< NUM_COMP, NUM_PHASE > { - template< localIndex NC, localIndex NP > +public: + + using Base = IsothermalCompositionalMultiphaseFVMKernels::PhaseMobilityKernel< NUM_COMP, NUM_PHASE >; + using Base::numPhase; + using Base::m_phaseDens; + using Base::m_phaseVisc; + using Base::m_dPhaseRelPerm_dPhaseVolFrac; + + /** + * @brief Constructor + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] relperm the relperm model + */ + PhaseMobilityKernel( ObjectManagerBase & subRegion, + MultiFluidBase const & fluid, + RelativePermeabilityBase const & relperm ) + : Base( subRegion, fluid, relperm ), + m_dPhaseVolFrac_dTemp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature >() ), + m_dPhaseDens_dTemp( fluid.dPhaseDensity_dTemperature() ), + m_dPhaseVisc_dTemp( fluid.dPhaseViscosity_dTemperature() ), + m_dPhaseMob_dTemp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseMobility_dTemperature >() ) + {} + + /** + * @brief Compute the phase mobilities in an element + * @param[in] ei the element index + */ GEOSX_HOST_DEVICE + void compute( localIndex const ei ) const + { + + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseDens = m_phaseDens[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseDens_dTemp = m_dPhaseDens_dTemp[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const phaseVisc = m_phaseVisc[ei][0]; + arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const dPhaseVisc_dTemp = m_dPhaseVisc_dTemp[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 dPhaseVolFrac_dTemp = m_dPhaseVolFrac_dTemp[ei]; + + arraySlice1d< real64, compflow::USD_PHASE - 1 > const dPhaseMob_dTemp = m_dPhaseMob_dTemp[ei]; + LvArray::forValuesInSlice( dPhaseMob_dTemp, []( real64 & val ){ val = 0.0; } ); + + Base::compute( ei, [=] GEOSX_HOST_DEVICE ( localIndex const ip, + real64 const & phaseMob, + real64 const & GEOSX_UNUSED_PARAM( dPhaseMob_dPres ), + arraySlice1d< real64 const, compflow::USD_PHASE_DC - 2 > const & GEOSX_UNUSED_PARAM( dPhaseMob_dComp ) ) + { + // Step 1: compute the derivative of relPerm[ip] wrt temperature + real64 dRelPerm_dT = 0.0; + for( integer jp = 0; jp < numPhase; ++jp ) + { + dRelPerm_dT += dPhaseRelPerm_dPhaseVolFrac[ip][jp] * dPhaseVolFrac_dTemp[jp]; + } + + // Step 2: compute the derivative of phaseMob[ip] wrt temperature + dPhaseMob_dTemp[ip] = dRelPerm_dT * phaseDens[ip] / phaseVisc[ip] + + phaseMob * (dPhaseDens_dTemp[ip] / phaseDens[ip] - dPhaseVisc_dTemp[ip] / phaseVisc[ip] ); + } ); + } + +protected: + + // inputs + + /// Views on thermal derivatives of phase volume fractions + arrayView2d< real64 const, compflow::USD_PHASE > m_dPhaseVolFrac_dTemp; + + /// Views on thermal derivatives of phase densities + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseDens_dTemp; + + /// Views on thermal derivatives of phase viscosities + arrayView3d< real64 const, multifluid::USD_PHASE > m_dPhaseVisc_dTemp; + + // outputs + + /// Views on thermal derivatives of phase mobilities + arrayView2d< real64, compflow::USD_PHASE > m_dPhaseMob_dTemp; + +}; + +/** + * @class PhaseMobilityKernelFactory + */ +class PhaseMobilityKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @param[in] numComp the number of fluid components + * @param[in] numPhase the number of fluid phases + * @param[in] subRegion the element subregion + * @param[in] fluid the fluid model + * @param[in] relperm the relperm model + */ + template< typename POLICY > static void - compute( 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, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseDens_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseDens_dComp, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & phaseVisc, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dPres, - arraySlice1d< real64 const, multifluid::USD_PHASE - 2 > const & dPhaseVisc_dTemp, - arraySlice2d< real64 const, multifluid::USD_PHASE_DC - 2 > const & dPhaseVisc_dComp, - arraySlice1d< real64 const, relperm::USD_RELPERM - 2 > const & phaseRelPerm, - arraySlice2d< real64 const, relperm::USD_RELPERM_DS - 2 > const & dPhaseRelPerm_dPhaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & phaseVolFrac, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dPres, - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > const & dPhaseVolFrac_dTemp, - arraySlice2d< real64 const, compflow::USD_PHASE_DC - 1 > const & dPhaseVolFrac_dComp, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & phaseMob, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dPres, - arraySlice1d< real64, compflow::USD_PHASE - 1 > const & dPhaseMob_dTemp, - arraySlice2d< real64, compflow::USD_PHASE_DC - 1 > const & dPhaseMob_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( localIndex const size, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dTemp, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); - - template< localIndex NC, localIndex NP > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - arrayView3d< real64 const, compflow::USD_COMP_DC > const & dCompFrac_dCompDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseDens, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseDens_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseDens_dComp, - arrayView3d< real64 const, multifluid::USD_PHASE > const & phaseVisc, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dPres, - arrayView3d< real64 const, multifluid::USD_PHASE > const & dPhaseVisc_dTemp, - arrayView4d< real64 const, multifluid::USD_PHASE_DC > const & dPhaseVisc_dComp, - arrayView3d< real64 const, relperm::USD_RELPERM > const & phaseRelPerm, - arrayView4d< real64 const, relperm::USD_RELPERM_DS > const & dPhaseRelPerm_dPhaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dPres, - arrayView2d< real64 const, compflow::USD_PHASE > const & dPhaseVolFrac_dTemp, - arrayView3d< real64 const, compflow::USD_PHASE_DC > const & dPhaseVolFrac_dComp, - arrayView2d< real64, compflow::USD_PHASE > const & phaseMob, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dPres, - arrayView2d< real64, compflow::USD_PHASE > const & dPhaseMob_dTemp, - arrayView3d< real64, compflow::USD_PHASE_DC > const & dPhaseMob_dComp ); + createAndLaunch( integer const numComp, + integer const numPhase, + ObjectManagerBase & subRegion, + MultiFluidBase const & fluid, + RelativePermeabilityBase const & relperm ) + { + if( numPhase == 2 ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseMobilityKernel< NUM_COMP, 2 > kernel( subRegion, fluid, relperm ); + PhaseMobilityKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + else if( numPhase == 3 ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + PhaseMobilityKernel< NUM_COMP, 3 > kernel( subRegion, fluid, relperm ); + PhaseMobilityKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); + } ); + } + } }; -/******************************** FluxKernel ********************************/ + +/******************************** FaceBasedAssemblyKernel ********************************/ /** - * @brief Functions to assemble flux term contributions to residual and Jacobian + * @class FaceBasedAssemblyKernel + * @tparam NUM_COMP number of fluid components + * @tparam NUM_DOF number of degrees of freedom + * @tparam STENCILWRAPPER the type of the stencil wrapper + * @brief Define the interface for the assembly kernel in charge of flux terms */ -struct FluxKernel +template< integer NUM_COMP, integer NUM_DOF, typename STENCILWRAPPER > +class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, STENCILWRAPPER > { +public: /** * @brief The type for element-based data. Consists entirely of ArrayView's. @@ -129,89 +191,461 @@ struct FluxKernel template< typename VIEWTYPE > using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >; - template< localIndex NC, localIndex MAX_NUM_ELEMS, localIndex MAX_STENCIL_SIZE > + using AbstractBase = IsothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernelBase; + using DofNumberAccessor = AbstractBase::DofNumberAccessor; + using CompFlowAccessors = AbstractBase::CompFlowAccessors; + using MultiFluidAccessors = AbstractBase::MultiFluidAccessors; + using CapPressureAccessors = AbstractBase::CapPressureAccessors; + using PermeabilityAccessors = AbstractBase::PermeabilityAccessors; + + using AbstractBase::m_dt; + using AbstractBase::m_numPhases; + using AbstractBase::m_capPressureFlag; + using AbstractBase::m_rankOffset; + using AbstractBase::m_ghostRank; + using AbstractBase::m_dofNumber; + using AbstractBase::m_gravCoef; + using AbstractBase::m_phaseMob; + using AbstractBase::m_phaseCompFrac; + using AbstractBase::m_dCompFrac_dCompDens; + using AbstractBase::m_dPhaseCapPressure_dPhaseVolFrac; + + using Base = IsothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, STENCILWRAPPER >; + using Base::numComp; + using Base::numDof; + using Base::numEqn; + using Base::maxNumElems; + using Base::maxNumConns; + using Base::maxStencilSize; + using Base::m_seri; + using Base::m_sesri; + using Base::m_sei; + + + using ThermalCompFlowAccessors = + StencilAccessors< extrinsicMeshData::flow::dPhaseMobility_dTemperature, + extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature >; + + using ThermalMultiFluidAccessors = + StencilAccessors< extrinsicMeshData::multifluid::dPhaseMassDensity_dTemperature, + extrinsicMeshData::multifluid::dPhaseCompFraction_dTemperature, + extrinsicMeshData::multifluid::phaseEnthalpy, + extrinsicMeshData::multifluid::dPhaseEnthalpy_dPressure, + extrinsicMeshData::multifluid::dPhaseEnthalpy_dTemperature, + extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction >; + + /** + * @brief Constructor for the kernel interface + * @param[in] numPhases the number of fluid phases + * @param[in] rankOffset the offset of my MPI rank + * @param[in] capPressureFlag flag specifying whether capillary pressure is used or not + * @param[in] stencilWrapper reference to the stencil wrapper + * @param[in] dofNumberAccessor + * @param[in] compFlowAccessor + * @param[in] thermalCompFlowAccessors + * @param[in] multiFluidAccessor + * @param[in] thermalMultiFluidAccessors + * @param[in] capPressureAccessors + * @param[in] permeabilityAccessors + * @param[in] dt time step size + * @param[inout] localMatrix the local CRS matrix + * @param[inout] localRhs the local right-hand side vector + */ + FaceBasedAssemblyKernel( integer const numPhases, + globalIndex const rankOffset, + integer const capPressureFlag, + STENCILWRAPPER const & stencilWrapper, + DofNumberAccessor const & dofNumberAccessor, + CompFlowAccessors const & compFlowAccessors, + ThermalCompFlowAccessors const & thermalCompFlowAccessors, + MultiFluidAccessors const & multiFluidAccessors, + ThermalMultiFluidAccessors const & thermalMultiFluidAccessors, + CapPressureAccessors const & capPressureAccessors, + PermeabilityAccessors const & permeabilityAccessors, + real64 const & dt, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) + : Base( numPhases, + rankOffset, + capPressureFlag, + stencilWrapper, + dofNumberAccessor, + compFlowAccessors, + multiFluidAccessors, + capPressureAccessors, + permeabilityAccessors, + dt, + localMatrix, + localRhs ), + m_dPhaseMob_dTemp( thermalCompFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dTemperature {} ) ), + m_dPhaseVolFrac_dTemp( thermalCompFlowAccessors.get( extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature {} ) ), + m_dPhaseMassDens_dTemp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity_dTemperature {} ) ), + m_dPhaseCompFrac_dTemp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseCompFraction_dTemperature {} ) ), + m_phaseEnthalpy( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::phaseEnthalpy {} ) ), + m_dPhaseEnthalpy_dPres( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dPressure {} ) ), + m_dPhaseEnthalpy_dTemp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dTemperature {} ) ), + m_dPhaseEnthalpy_dComp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction {} ) ) + {} + + struct StackVariables : public Base::StackVariables + { +public: + + GEOSX_HOST_DEVICE + StackVariables( localIndex const size, localIndex numElems ) + : Base::StackVariables( size, numElems ), + dCompFlux_dT( size, numComp ), + energyFlux( 0.0 ), + dEnergyFlux_dP( size ), + dEnergyFlux_dT( size ), + dEnergyFlux_dC( size, numComp ) + {} + + using Base::StackVariables::stencilSize; + using Base::StackVariables::numFluxElems; + using Base::StackVariables::transmissibility; + using Base::StackVariables::dofColIndices; + using Base::StackVariables::localFlux; + using Base::StackVariables::localFluxJacobian; + + // Component fluxes and derivatives + + /// Derivatives of component fluxes wrt temperature + stackArray2d< real64, maxStencilSize * numComp > dCompFlux_dT; + + // Energy fluxes and derivatives + + /// Energy fluxes + real64 energyFlux; + /// Derivatives of energy fluxes wrt pressure + stackArray1d< real64, maxStencilSize > dEnergyFlux_dP; + /// Derivatives of energy fluxes wrt temperature + stackArray1d< real64, maxStencilSize > dEnergyFlux_dT; + /// Derivatives of energy fluxes wrt component densities + stackArray2d< real64, maxStencilSize * numComp > dEnergyFlux_dC; + + }; + + /** + * @brief Compute the local flux contributions to the residual and Jacobian + * @param[in] iconn the connection index + * @param[inout] stack the stack variables + */ GEOSX_HOST_DEVICE + void computeFlux( localIndex const iconn, + StackVariables & stack ) const + { + arraySlice2d< real64 > dCompFlux_dTSlice = stack.dCompFlux_dT.toSlice(); + + real64 * energyFluxPtr = &(stack.energyFlux); + arraySlice1d< real64 > dEnergyFlux_dPSlice = stack.dEnergyFlux_dP.toSlice(); + arraySlice1d< real64 > dEnergyFlux_dTSlice = stack.dEnergyFlux_dT.toSlice(); + arraySlice2d< real64 > dEnergyFlux_dCSlice = stack.dEnergyFlux_dC.toSlice(); + + // First, we call the base computeFlux to compute: + // 1) compFlux and its derivatives (including derivatives wrt temperature), + // 2) enthalpyFlux and its derivatives (including derivatives wrt temperature + // + // Computing dCompFlux_dT and the enthalpyFlux requires quantities already computed in the base computeFlux, + // such as potGrad, phaseFlux, and the indices of the upwind cell + // We use the lambda below (called **inside** the phase loop of the base computeFlux) to access these variables + Base::computeFlux( iconn, stack, [=] GEOSX_HOST_DEVICE ( localIndex const ip, + localIndex const k_up, + localIndex const er_up, + localIndex const esr_up, + localIndex const ei_up, + real64 const & potGrad, + real64 const & phaseFlux, + real64 const (&dPhaseFlux_dP)[maxStencilSize], + real64 const (&dPhaseFlux_dC)[maxStencilSize][numComp] ) + { + GEOSX_UNUSED_VAR( dPhaseFlux_dP, dPhaseFlux_dC ); + + // We are in the loop over phases, ip provides the current phase index. + + // Step 1: compute the derivatives of the mean density at the interface wrt temperature + + stackArray1d< real64, maxNumElems > dDensMean_dT( stack.numFluxElems ); + + for( integer i = 0; i < stack.numFluxElems; ++i ) + { + localIndex const er = m_seri( iconn, i ); + localIndex const esr = m_sesri( iconn, i ); + localIndex const ei = m_sei( iconn, i ); + + real64 const dDens_dT = m_dPhaseMassDens_dTemp[er][esr][ei][0][ip]; + dDensMean_dT[i] = 0.5 * dDens_dT; + } + + + // Step 2: compute the derivatives of the phase potential difference wrt temperature + //***** calculation of flux ***** + + stackArray1d< real64, maxStencilSize > dPresGrad_dT( stack.stencilSize ); + stackArray1d< real64, maxStencilSize > dGravHead_dT( stack.numFluxElems ); + + // compute potential difference MPFA-style + for( integer i = 0; i < stack.stencilSize; ++i ) + { + localIndex const er = m_seri( iconn, i ); + localIndex const esr = m_sesri( iconn, i ); + localIndex const ei = m_sei( iconn, i ); + + // Step 2.1: compute derivative of capillary pressure wrt temperature + real64 dCapPressure_dT = 0.0; + if( m_capPressureFlag ) + { + for( integer jp = 0; jp < m_numPhases; ++jp ) + { + real64 const dCapPressure_dS = m_dPhaseCapPressure_dPhaseVolFrac[er][esr][ei][0][ip][jp]; + dCapPressure_dT += dCapPressure_dS * m_dPhaseVolFrac_dTemp[er][esr][ei][jp]; + } + } + + // Step 2.2: compute derivative of phase pressure difference wrt temperature + dPresGrad_dT[i] += stack.transmissibility[0][i] * (1 - dCapPressure_dT); + real64 const gravD = stack.transmissibility[0][i] * m_gravCoef[er][esr][ei]; + + // Step 2.3: compute derivative of gravity potential difference wrt temperature + for( integer j = 0; j < stack.numFluxElems; ++j ) + { + dGravHead_dT[j] += dDensMean_dT[j] * gravD; + } + } + + + // Step 3: compute the derivatives of the (upwinded) compFlux wrt temperature + // *** upwinding *** + + // note: the upwinding is done in the base class, which is in charge of + // computing the following quantities: potGrad, phaseFlux, k_up, er_up, esr_up, ei_up + + real64 dPhaseFlux_dT[maxStencilSize]{}; + + // Step 3.1: compute the derivative of phase flux wrt temperature + for( integer ke = 0; ke < stack.stencilSize; ++ke ) + { + dPhaseFlux_dT[ke] += dPresGrad_dT[ke]; + } + for( integer ke = 0; ke < stack.numFluxElems; ++ke ) + { + dPhaseFlux_dT[ke] -= dGravHead_dT[ke]; + } + for( integer ke = 0; ke < stack.stencilSize; ++ke ) + { + dPhaseFlux_dT[ke] *= m_phaseMob[er_up][esr_up][ei_up][ip]; + } + dPhaseFlux_dT[k_up] += m_dPhaseMob_dTemp[er_up][esr_up][ei_up][ip] * potGrad; + + // Step 3.2: compute the derivative of component flux wrt temperature + + // 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_dTempSub = + m_dPhaseCompFrac_dTemp[er_up][esr_up][ei_up][0][ip]; + + for( integer ic = 0; ic < numComp; ++ic ) + { + real64 const ycp = phaseCompFracSub[ic]; + for( integer ke = 0; ke < stack.stencilSize; ++ke ) + { + dCompFlux_dTSlice[ke][ic] += dPhaseFlux_dT[ke] * ycp; + } + dCompFlux_dTSlice[k_up][ic] += phaseFlux * dPhaseCompFrac_dTempSub[ic]; + } + + + // Step 4: compute the enthalpy flux + + real64 const enthalpy = m_phaseEnthalpy[er_up][esr_up][ei_up][0][ip]; + *energyFluxPtr += phaseFlux * enthalpy; + + for( integer ke = 0; ke < stack.stencilSize; ++ke ) + { + dEnergyFlux_dPSlice[ke] += dPhaseFlux_dP[ke] * enthalpy; + dEnergyFlux_dTSlice[ke] += dPhaseFlux_dT[ke] * enthalpy; + + for( integer jc = 0; jc < numComp; ++jc ) + { + dEnergyFlux_dCSlice[ke][jc] += dPhaseFlux_dC[ke][jc] * enthalpy; + } + } + + dEnergyFlux_dPSlice[k_up] += phaseFlux * m_dPhaseEnthalpy_dPres[er_up][esr_up][ei_up][0][ip]; + dEnergyFlux_dTSlice[k_up] += phaseFlux * m_dPhaseEnthalpy_dTemp[er_up][esr_up][ei_up][0][ip]; + + real64 dProp_dC[numComp]{}; + applyChainRule( numComp, + m_dCompFrac_dCompDens[er_up][esr_up][ei_up], + m_dPhaseEnthalpy_dComp[er_up][esr_up][ei_up][0][ip], + dProp_dC ); + for( integer jc = 0; jc < numComp; ++jc ) + { + dEnergyFlux_dCSlice[k_up][jc] += phaseFlux * dProp_dC[jc]; + } + } ); + + + // TODO HERE: add conduction + + // At this point, we have computed the energyFlux and the compFlux for all components + // We have to do two things here: + // 1) Add dCompFlux_dTemp to the localFluxJacobian of the component mass balance equations + // 2) Add energyFlux and its derivatives to the localFlux(Jacobian) of the energy balance equation + + // Step 1: add dCompFlux_dTemp to localFluxJacobian + for( integer ic = 0; ic < numComp; ++ic ) + { + for( integer ke = 0; ke < stack.stencilSize; ++ke ) + { + integer const localDofIndexTemp = ke * numDof + numDof - 1; + stack.localFluxJacobian[ic][localDofIndexTemp] = m_dt * stack.dCompFlux_dT[ke][ic]; + stack.localFluxJacobian[numEqn + ic][localDofIndexTemp] = -m_dt * stack.dCompFlux_dT[ke][ic]; + } + } + + // Step 2: add energyFlux and its derivatives to localFlux and localFluxJacobian + integer const localRowIndexEnergy = numEqn-1; + stack.localFlux[localRowIndexEnergy] = m_dt * stack.energyFlux; + stack.localFlux[2 * localRowIndexEnergy] = -m_dt * stack.energyFlux; + + for( integer ke = 0; ke < stack.stencilSize; ++ke ) + { + integer const localDofIndexPres = ke * numDof; + stack.localFluxJacobian[localRowIndexEnergy][localDofIndexPres] = m_dt * stack.dEnergyFlux_dP[ke]; + stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexPres] = -m_dt * stack.dEnergyFlux_dP[ke]; + integer const localDofIndexTemp = localDofIndexPres + numDof; + stack.localFluxJacobian[localRowIndexEnergy][localDofIndexTemp] = m_dt * stack.dEnergyFlux_dT[ke]; + stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexTemp] = -m_dt * stack.dEnergyFlux_dT[ke]; + + for( integer jc = 0; jc < numComp; ++jc ) + { + integer const localDofIndexComp = localDofIndexPres + jc + 1; + stack.localFluxJacobian[localRowIndexEnergy][localDofIndexComp] = m_dt * stack.dEnergyFlux_dC[ke][jc]; + stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexComp] = -m_dt * stack.dEnergyFlux_dC[ke][jc]; + } + } + } + + /** + * @brief Performs the complete phase for the kernel. + * @param[in] iconn the connection index + * @param[inout] stack the stack variables + */ + GEOSX_HOST_DEVICE + void complete( localIndex const iconn, + StackVariables & stack ) const + { + // Step 1: assemble the component mass balance equations (i = 0 to i = numDof-2) + Base::complete( iconn, stack ); + + // Step 2: add contribution to residual and jacobian into the energy balance equation + for( integer i = 0; i < stack.numFluxElems; ++i ) + { + if( m_ghostRank[m_seri( iconn, i )][m_sesri( iconn, i )][m_sei( iconn, i )] < 0 ) + { + globalIndex const globalRow = m_dofNumber[m_seri( iconn, i )][m_sesri( iconn, i )][m_sei( iconn, i )]; + localIndex const localRow = LvArray::integerConversion< localIndex >( globalRow - m_rankOffset ); + GEOSX_ASSERT_GE( localRow, 0 ); + GEOSX_ASSERT_GT( AbstractBase::m_localMatrix.numRows(), localRow + numEqn ); + + // beware, there is volume balance eqn in m_localRhs and m_localMatrix! + RAJA::atomicAdd( parallelDeviceAtomic{}, &AbstractBase::m_localRhs[localRow + numEqn], stack.localFlux[i * numEqn + numEqn-1] ); + AbstractBase::m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic > + ( localRow + numEqn, + stack.dofColIndices.data(), + stack.localFluxJacobian[i * numEqn + numEqn-1].dataIfContiguous(), + stack.stencilSize * numDof ); + } + } + } + +protected: + + /// Views on derivatives of phase mobilities, volume fractions, mass densities and phase comp fractions + ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_dPhaseMob_dTemp; + ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_dPhaseVolFrac_dTemp; + ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_dPhaseMassDens_dTemp; + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const m_dPhaseCompFrac_dTemp; + + /// Views on phase enthalpies + ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_phaseEnthalpy; + ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_dPhaseEnthalpy_dPres; + ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_dPhaseEnthalpy_dTemp; + ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const m_dPhaseEnthalpy_dComp; + +}; + +/** + * @class FaceBasedAssemblyKernelFactory + */ +class FaceBasedAssemblyKernelFactory +{ +public: + + /** + * @brief Create a new kernel and launch + * @tparam POLICY the policy used in the RAJA kernel + * @tparam STENCILWRAPPER the type of the stencil wrapper + * @param[in] numComps the number of fluid components + * @param[in] numPhases the number of fluid phases + * @param[in] rankOffset the offset of my MPI rank + * @param[in] dofKey string to get the element degrees of freedom numbers + * @param[in] capPressureFlag flag specifying whether capillary pressure is used or not + * @param[in] solverName name of the solver (to name accessors) + * @param[in] elemManager reference to the element region manager + * @param[in] stencilWrapper reference to the stencil wrapper + * @param[in] targetRegionNames names of the target regions + * @param[in] fluidModelNames names of the fluid models + * @param[in] capPresModelNames names of the capillary pressure models + * @param[in] permeabilityModelNames names of the permeability models + * @param[in] dt time step size + * @param[inout] localMatrix the local CRS matrix + * @param[inout] localRhs the local right-hand side vector + */ + template< typename POLICY, typename STENCILWRAPPER > static void - compute( localIndex const numPhases, - localIndex const stencilSize, - localIndex const numFluxElems, - arraySlice1d< localIndex const > const seri, - arraySlice1d< localIndex const > const sesri, - arraySlice1d< localIndex const > const sei, - real64 const (&transmissibility)[2], - real64 const (&dTrans_dPres)[2], - ElementViewConst< arrayView1d< real64 const > > const & pres, - ElementViewConst< arrayView1d< real64 const > > const & dPres, - ElementViewConst< arrayView1d< real64 const > > const & temp, - ElementViewConst< arrayView1d< real64 const > > const & dTemp, - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dComp, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dComp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dTemp, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dComp, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseEnthalpy, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseEnthalpy_dComp, - ElementViewConst< arrayView3d< real64 const, cappres::USD_CAPPRES > > const & phaseCapPressure, - ElementViewConst< arrayView4d< real64 const, cappres::USD_CAPPRES_DS > > const & dPhaseCapPressure_dPhaseVolFrac, - integer const capPressureFlag, - real64 const dt, - arraySlice1d< real64 > const localFlux, - arraySlice2d< real64 > const localFluxJacobian ); - - template< localIndex NC, typename STENCILWRAPPER_TYPE > - static void - launch( localIndex const numPhases, - STENCILWRAPPER_TYPE const & stencilWrapper, - globalIndex const rankOffset, - ElementViewConst< arrayView1d< globalIndex const > > const & dofNumber, - ElementViewConst< arrayView1d< integer const > > const & ghostRank, - ElementViewConst< arrayView1d< real64 const > > const & pres, - ElementViewConst< arrayView1d< real64 const > > const & dPres, - ElementViewConst< arrayView1d< real64 const > > const & temp, - ElementViewConst< arrayView1d< real64 const > > const & dTemp, - ElementViewConst< arrayView3d< real64 const > > const & permeability, - ElementViewConst< arrayView3d< real64 const > > const & dPerm_dPres, - ElementViewConst< arrayView1d< real64 const > > const & gravCoef, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMob, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseMob_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseMob_dComp, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dPres, - ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & dPhaseVolFrac_dTemp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_PHASE_DC > > const & dPhaseVolFrac_dComp, - ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const & dCompFrac_dCompDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseMassDens, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseMassDens_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseMassDens_dComp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & phaseCompFrac, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dPres, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_COMP > > const & dPhaseCompFrac_dTemp, - ElementViewConst< arrayView5d< real64 const, multifluid::USD_PHASE_COMP_DC > > const & dPhaseCompFrac_dComp, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & phaseEnthalpy, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dPres, - ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const & dPhaseEnthalpy_dTemp, - ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const & dPhaseEnthalpy_dComp, - ElementViewConst< arrayView3d< real64 const, cappres::USD_CAPPRES > > const & phaseCapPressure, - ElementViewConst< arrayView4d< real64 const, cappres::USD_CAPPRES_DS > > const & dPhaseCapPressure_dPhaseVolFrac, - integer const capPressureFlag, - real64 const dt, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ); + createAndLaunch( integer const numComps, + integer const numPhases, + globalIndex const rankOffset, + string const & dofKey, + integer const capPressureFlag, + string const & solverName, + ElementRegionManager const & elemManager, + STENCILWRAPPER const & stencilWrapper, + arrayView1d< string const > const & targetRegionNames, + arrayView1d< string const > const & fluidModelNames, + arrayView1d< string const > const & capPresModelNames, + arrayView1d< string const > const & permeabilityModelNames, + real64 const & dt, + CRSMatrixView< real64, globalIndex const > const & localMatrix, + arrayView1d< real64 > const & localRhs ) + { + IsothermalCompositionalMultiphaseBaseKernels:: + internal::kernelLaunchSelectorCompSwitch( numComps, [&] ( auto NC ) + { + integer constexpr NUM_COMP = NC(); + integer constexpr NUM_DOF = NC()+2; + + ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > dofNumberAccessor = + elemManager.constructArrayViewAccessor< globalIndex, 1 >( dofKey ); + dofNumberAccessor.setName( solverName + "/accessors/" + dofKey ); + + using KERNEL_TYPE = FaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, STENCILWRAPPER >; + typename KERNEL_TYPE::CompFlowAccessors compFlowAccessors( elemManager, solverName ); + typename KERNEL_TYPE::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, solverName ); + typename KERNEL_TYPE::MultiFluidAccessors multiFluidAccessors( elemManager, solverName, targetRegionNames, fluidModelNames ); + typename KERNEL_TYPE::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, solverName, targetRegionNames, fluidModelNames ); + typename KERNEL_TYPE::CapPressureAccessors capPressureAccessors( elemManager, solverName, targetRegionNames, capPresModelNames ); + typename KERNEL_TYPE::PermeabilityAccessors permeabilityAccessors( elemManager, solverName, targetRegionNames, permeabilityModelNames ); + + KERNEL_TYPE kernel( numPhases, rankOffset, capPressureFlag, stencilWrapper, dofNumberAccessor, + compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, capPressureAccessors, permeabilityAccessors, + dt, localMatrix, localRhs ); + KERNEL_TYPE::template launch< POLICY >( stencilWrapper.size(), kernel ); + } ); + } }; From d33a78f0c7003c590e5fa7e5002c7a877a97238a Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Mon, 10 Jan 2022 08:53:14 -0800 Subject: [PATCH 23/34] some cleanup in the kernels --- ...malCompositionalMultiphaseBaseKernels.hpp# | 1388 ----------------- 1 file changed, 1388 deletions(-) delete mode 100644 src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# diff --git a/src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# b/src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# deleted file mode 100644 index 633c6ad1a62..00000000000 --- a/src/coreComponents/physicsSolvers/fluidFlow/#IsothermalCompositionalMultiphaseBaseKernels.hpp# +++ /dev/null @@ -1,1388 +0,0 @@ -/* - * ------------------------------------------------------------------------------------------------------------ - * SPDX-License-Identifier: LGPL-2.1-only - * - * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC - * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University - * Copyright (c) 2018-2020 TotalEnergies - * Copyright (c) 2019- GEOSX Contributors - * All rights reserved - * - * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details. - * ------------------------------------------------------------------------------------------------------------ - */ - -/** - * @file IsothermalCompositionalMultiphaseBaseKernels.hpp - */ - -#ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_ISOTHERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP -#define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_ISOTHERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP - -#include "common/DataLayouts.hpp" -#include "common/DataTypes.hpp" -#include "common/GEOS_RAJA_Interface.hpp" -#include "constitutive/solid/CoupledSolidBase.hpp" -#include "constitutive/fluid/MultiFluidBase.hpp" -#include "functions/TableFunction.hpp" -#include "mesh/ElementSubRegionBase.hpp" -#include "mesh/ObjectManagerBase.hpp" -#include "physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp" -#include "physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp" - -namespace geosx -{ - -namespace IsothermalCompositionalMultiphaseBaseKernels -{ - -using namespace constitutive; - -static constexpr real64 minDensForDivision = 1e-10; - -/******************************** PropertyKernelBase ********************************/ - -/** - * @brief Internal struct to provide no-op defaults used in the inclusion - * of lambda functions into kernel component functions. - * @struct NoOpFunc - */ -struct NoOpFunc -{ - template< typename ... Ts > - GEOSX_HOST_DEVICE - constexpr void - operator()( Ts && ... ) const {} -}; - -/** - * @class PropertyKernelBase - * @tparam NUM_COMP number of fluid components - * @brief Define the base interface for the property update kernels - */ -template< integer NUM_COMP > -class PropertyKernelBase -{ -public: - - /// Compile time value for the number of components - static constexpr integer numComp = NUM_COMP; - - /** - * @brief Performs the kernel launch - * @tparam POLICY the policy used in the RAJA kernels - * @tparam KERNEL_TYPE the kernel type - * @param[in] numElems the number of elements - * @param[inout] kernelComponent the kernel component providing access to the compute function - */ - template< typename POLICY, typename KERNEL_TYPE > - static void - launch( localIndex const numElems, - KERNEL_TYPE const & kernelComponent ) - { - forAll< POLICY >( numElems, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - kernelComponent.compute( ei ); - } ); - } - - /** - * @brief Performs the kernel launch on a sorted array - * @tparam POLICY the policy used in the RAJA kernels - * @tparam KERNEL_TYPE the kernel type - * @param[in] targetSet the indices of the elements in which we compute the property - * @param[inout] kernelComponent the kernel component providing access to the compute function - */ - template< typename POLICY, typename KERNEL_TYPE > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - KERNEL_TYPE const & kernelComponent ) - { - forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const i ) - { - localIndex const ei = targetSet[ i ]; - kernelComponent.compute( ei ); - } ); - } - -}; - -namespace internal -{ - -template< typename T, typename LAMBDA > -void kernelLaunchSelectorCompSwitch( T value, LAMBDA && lambda ) -{ - static_assert( std::is_integral< T >::value, "kernelLaunchSelectorCompSwitch: type should be integral" ); - - switch( value ) - { - case 1: - { lambda( std::integral_constant< T, 1 >() ); return; } - case 2: - { lambda( std::integral_constant< T, 2 >() ); return; } - case 3: - { lambda( std::integral_constant< T, 3 >() ); return; } - case 4: - { lambda( std::integral_constant< T, 4 >() ); return; } - case 5: - { lambda( std::integral_constant< T, 5 >() ); return; } - default: - { GEOSX_ERROR( "Unsupported number of components: " << value ); } - } -} - -} // namespace internal - - -/******************************** ComponentFractionKernel ********************************/ - -/** - * @class ComponentFractionKernel - * @tparam NUM_COMP number of fluid components - * @brief Define the interface for the update kernel in charge of computing the phase volume fractions - */ -template< integer NUM_COMP > -class ComponentFractionKernel : public PropertyKernelBase< NUM_COMP > -{ -public: - - using Base = PropertyKernelBase< NUM_COMP >; - using Base::numComp; - - /** - * @brief Constructor - * @param[in] subRegion the element subregion - * @param[in] fluid the fluid model - */ - ComponentFractionKernel( ObjectManagerBase & subRegion ) - : Base(), - m_compDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >() ), - m_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaGlobalCompDensity >() ), - m_compFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompFraction >() ), - m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ) - {} - - /** - * @brief Compute the phase volume fractions in an element - * @tparam FUNC the type of the function that can be used to customize the kernel - * @param[in] ei the element index - * @param[in] phaseVolFractionKernelOp the function used to customize the kernel - */ - template< typename FUNC = NoOpFunc > - GEOSX_HOST_DEVICE - void compute( localIndex const ei, - FUNC && compFractionKernelOp = NoOpFunc{} ) const - { - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const compDens = m_compDens[ei]; - arraySlice1d< real64 const, compflow::USD_COMP - 1 > const dCompDens = m_dCompDens[ei]; - arraySlice1d< real64, compflow::USD_COMP - 1 > const compFrac = m_compFrac[ei]; - arraySlice2d< real64, compflow::USD_COMP_DC - 1 > const dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; - - real64 totalDensity = 0.0; - - for( integer ic = 0; ic < numComp; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - real64 const totalDensityInv = 1.0 / totalDensity; - - for( integer ic = 0; ic < numComp; ++ic ) - { - compFrac[ic] = (compDens[ic] + dCompDens[ic]) * totalDensityInv; - for( integer jc = 0; jc < numComp; ++jc ) - { - dCompFrac_dCompDens[ic][jc] = -compFrac[ic] * totalDensityInv; - } - dCompFrac_dCompDens[ic][ic] += totalDensityInv; - } - - compFractionKernelOp( compFrac, dCompFrac_dCompDens ); - } - -protected: - - // inputs - - // Views on component densities - arrayView2d< real64 const, compflow::USD_COMP > m_compDens; - arrayView2d< real64 const, compflow::USD_COMP > m_dCompDens; - - // outputs - - // Views on component fraction - arrayView2d< real64, compflow::USD_COMP > m_compFrac; - arrayView3d< real64, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; - -}; - -/** - * @class ComponentFractionKernelFactory - */ -class ComponentFractionKernelFactory -{ -public: - - /** - * @brief Create a new kernel and launch - * @tparam POLICY the policy used in the RAJA kernel - * @param[in] numComp the number of fluid components - * @param[in] subRegion the element subregion - * @param[in] fluid the fluid model - */ - template< typename POLICY > - static void - createAndLaunch( integer const numComp, - ObjectManagerBase & subRegion ) - { - internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - integer constexpr NUM_COMP = NC(); - ComponentFractionKernel< NUM_COMP > kernel( subRegion ); - ComponentFractionKernel< NUM_COMP >::template launch< POLICY >( subRegion.size(), kernel ); - } ); - } - -}; - -/******************************** PhaseVolumeFractionKernel ********************************/ - -/** - * @class PhaseVolumeFractionKernel - * @tparam NUM_COMP number of fluid components - * @tparam NUM_PHASE number of fluid phases - * @brief Define the interface for the property kernel in charge of computing the phase volume fractions - */ -template< integer NUM_COMP, integer NUM_PHASE > -class PhaseVolumeFractionKernel : public PropertyKernelBase< NUM_COMP > -{ -public: - - using Base = PropertyKernelBase< NUM_COMP >; - using Base::numComp; - - /// Compile time value for the number of phases - static constexpr integer numPhase = NUM_PHASE; - - /** - * @brief Constructor - * @param[in] subRegion the element subregion - * @param[in] fluid the fluid model - */ - PhaseVolumeFractionKernel( ObjectManagerBase & subRegion, - MultiFluidBase const & fluid ) - : Base(), - m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), - m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), - m_dPhaseVolFrac_dComp( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dGlobalCompDensity >() ), - m_compDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::globalCompDensity >() ), - 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_phaseDens( fluid.phaseDensity() ), - m_dPhaseDens_dPres( fluid.dPhaseDensity_dPressure() ), - m_dPhaseDens_dComp( fluid.dPhaseDensity_dGlobalCompFraction() ) - {} - - /** - * @brief Compute the phase volume fractions in an element - * @tparam FUNC the type of the function that can be used to customize the kernel - * @param[in] ei the element index - * @param[in] phaseVolFractionKernelOp the function used to customize the kernel - */ - template< typename FUNC = NoOpFunc > - GEOSX_HOST_DEVICE - void compute( localIndex const ei, - FUNC && phaseVolFractionKernelOp = NoOpFunc{} ) const - { - 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]; - 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]; - 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]; - - real64 work[numComp]{}; - - // compute total density from component partial densities - real64 totalDensity = 0.0; - real64 const dTotalDens_dCompDens = 1.0; - for( integer ic = 0; ic < numComp; ++ic ) - { - totalDensity += compDens[ic] + dCompDens[ic]; - } - - for( integer ip = 0; ip < numPhase; ++ip ) - { - - // set the saturation to zero if the phase is absent - bool const phaseExists = (phaseFrac[ip] > 0); - if( !phaseExists ) - { - phaseVolFrac[ip] = 0.; - dPhaseVolFrac_dPres[ip] = 0.; - for( integer jc = 0; jc < numComp; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] = 0.; - } - continue; - } - - // Expression for volume fractions: S_p = (nu_p / rho_p) * rho_t - real64 const phaseDensInv = 1.0 / phaseDens[ip]; - - // compute saturation and derivatives except multiplying by the total density - phaseVolFrac[ip] = phaseFrac[ip] * phaseDensInv; - - dPhaseVolFrac_dPres[ip] = - (dPhaseFrac_dPres[ip] - phaseVolFrac[ip] * dPhaseDens_dPres[ip]) * phaseDensInv; - - for( integer jc = 0; jc < numComp; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] = - (dPhaseFrac_dComp[ip][jc] - phaseVolFrac[ip] * dPhaseDens_dComp[ip][jc]) * phaseDensInv; - } - - // apply chain rule to convert derivatives from global component fractions to densities - applyChainRuleInPlace( numComp, dCompFrac_dCompDens, dPhaseVolFrac_dComp[ip], work ); - - // call the lambda in the phase loop to allow the reuse of the phaseVolFrac and totalDensity - // possible use: assemble the derivatives wrt temperature - phaseVolFractionKernelOp( ip, phaseVolFrac[ip], phaseDensInv, totalDensity ); - - // now finalize the computation by multiplying by total density - for( integer jc = 0; jc < numComp; ++jc ) - { - dPhaseVolFrac_dComp[ip][jc] *= totalDensity; - dPhaseVolFrac_dComp[ip][jc] += phaseVolFrac[ip] * dTotalDens_dCompDens; - } - - phaseVolFrac[ip] *= totalDensity; - dPhaseVolFrac_dPres[ip] *= totalDensity; - } - } - -protected: - - // outputs - - /// Views on phase volume fractions - arrayView2d< real64, compflow::USD_PHASE > m_phaseVolFrac; - arrayView2d< real64, compflow::USD_PHASE > m_dPhaseVolFrac_dPres; - arrayView3d< real64, compflow::USD_PHASE_DC > m_dPhaseVolFrac_dComp; - - // inputs - - /// Views on component densities - arrayView2d< real64 const, compflow::USD_COMP > m_compDens; - arrayView2d< real64 const, compflow::USD_COMP > m_dCompDens; - arrayView3d< real64 const, compflow::USD_COMP_DC > m_dCompFrac_dCompDens; - - /// 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; - - /// 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; - -}; - -/** - * @class PhaseVolumeFractionKernelFactory - */ -class PhaseVolumeFractionKernelFactory -{ -public: - - /** - * @brief Create a new kernel and launch - * @tparam POLICY the policy used in the RAJA kernel - * @param[in] numComp the number of fluid components - * @param[in] numPhase the number of fluid phases - * @param[in] subRegion the element subregion - * @param[in] fluid the fluid model - */ - template< typename POLICY > - static void - createAndLaunch( integer const numComp, - integer const numPhase, - ObjectManagerBase & subRegion, - MultiFluidBase const & fluid ) - { - if( numPhase == 2 ) - { - internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - integer constexpr NUM_COMP = NC(); - PhaseVolumeFractionKernel< NUM_COMP, 2 > kernel( subRegion, fluid ); - PhaseVolumeFractionKernel< NUM_COMP, 2 >::template launch< POLICY >( subRegion.size(), kernel ); - } ); - } - else if( numPhase == 3 ) - { - internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - integer constexpr NUM_COMP = NC(); - PhaseVolumeFractionKernel< NUM_COMP, 3 > kernel( subRegion, fluid ); - PhaseVolumeFractionKernel< NUM_COMP, 3 >::template launch< POLICY >( subRegion.size(), kernel ); - } ); - } - } -}; - - -/******************************** RelativePermeabilityUpdateKernel ********************************/ - -struct RelativePermeabilityUpdateKernel -{ - template< typename POLICY, typename RELPERM_WRAPPER > - static void - launch( localIndex const size, - RELPERM_WRAPPER const & relPermWrapper, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) - { - forAll< POLICY >( size, [=] GEOSX_HOST_DEVICE ( localIndex const k ) - { - for( localIndex q = 0; q < relPermWrapper.numGauss(); ++q ) - { - relPermWrapper.update( k, q, phaseVolFrac[k] ); - } - } ); - } - - template< typename POLICY, typename RELPERM_WRAPPER > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - RELPERM_WRAPPER const & relPermWrapper, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) - { - forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - localIndex const k = targetSet[a]; - for( localIndex q = 0; q < relPermWrapper.numGauss(); ++q ) - { - relPermWrapper.update( k, q, phaseVolFrac[k] ); - } - } ); - } -}; - -/******************************** CapillaryPressureUpdateKernel ********************************/ - -struct CapillaryPressureUpdateKernel -{ - template< typename POLICY, typename CAPPRES_WRAPPER > - static void - launch( localIndex const size, - CAPPRES_WRAPPER const & capPresWrapper, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) - { - forAll< POLICY >( size, [=] GEOSX_HOST_DEVICE ( localIndex const k ) - { - for( localIndex q = 0; q < capPresWrapper.numGauss(); ++q ) - { - capPresWrapper.update( k, q, phaseVolFrac[k] ); - } - } ); - } - - template< typename POLICY, typename CAPPRES_WRAPPER > - static void - launch( SortedArrayView< localIndex const > const & targetSet, - CAPPRES_WRAPPER const & capPresWrapper, - arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFrac ) - { - forAll< POLICY >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) - { - localIndex const k = targetSet[a]; - for( localIndex q = 0; q < capPresWrapper.numGauss(); ++q ) - { - capPresWrapper.update( k, q, phaseVolFrac[k] ); - } - } ); - } -}; - -/******************************** ElementBasedAssemblyKernel ********************************/ - -/** - * @class ElementBasedAssemblyKernel - * @tparam NUM_COMP number of fluid components - * @tparam NUM_DOF number of degrees of freedom - * @brief Define the interface for the assembly kernel in charge of accumulation and volume balance - */ -template< integer NUM_COMP, integer NUM_DOF > -class ElementBasedAssemblyKernel -{ -public: - - /// Compile time value for the number of components - static constexpr integer numComp = NUM_COMP; - - /// Compute time value for the number of degrees of freedom - static constexpr integer numDof = NUM_DOF; - - /// Compute time value for the number of equations - static constexpr integer numEqn = NUM_DOF; - - /** - * @brief Constructor - * @param[in] numPhases the number of fluid phases - * @param[in] rankOffset the offset of my MPI rank - * @param[in] dofKey the string key to retrieve the degress of freedom numbers - * @param[in] subRegion the element subregion - * @param[in] fluid the fluid model - * @param[in] solid the solid model - * @param[inout] localMatrix the local CRS matrix - * @param[inout] localRhs the local right-hand side vector - */ - ElementBasedAssemblyKernel( localIndex const numPhases, - globalIndex const rankOffset, - string const dofKey, - ElementSubRegionBase const & subRegion, - MultiFluidBase const & fluid, - CoupledSolidBase const & solid, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) - : m_numPhases( numPhases ), - m_rankOffset( rankOffset ), - m_dofNumber( subRegion.getReference< array1d< globalIndex > >( dofKey ) ), - m_elemGhostRank( subRegion.ghostRank() ), - m_volume( subRegion.getElementVolume() ), - m_porosityOld( solid.getOldPorosity() ), - m_porosityNew( solid.getPorosity() ), - m_dPoro_dPres( solid.getDporosity_dPressure() ), - m_dCompFrac_dCompDens( subRegion.getExtrinsicData< extrinsicMeshData::flow::dGlobalCompFraction_dGlobalCompDensity >() ), - m_phaseVolFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFractionOld >() ), - m_phaseVolFrac( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFraction >() ), - m_dPhaseVolFrac_dPres( subRegion.getExtrinsicData< extrinsicMeshData::flow::dPhaseVolumeFraction_dPressure >() ), - 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_phaseCompFracOld( subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseComponentFractionOld >() ), - m_phaseCompFrac( fluid.phaseCompFraction() ), - m_dPhaseCompFrac_dPres( fluid.dPhaseCompFraction_dPressure() ), - m_dPhaseCompFrac_dComp( fluid.dPhaseCompFraction_dGlobalCompFraction() ), - m_localMatrix( localMatrix ), - m_localRhs( localRhs ) - {} - - /** - * @struct StackVariables - * @brief Kernel variables (dof numbers, jacobian and residual) located on the stack - */ - struct StackVariables - { -public: - - // Pore volume information (used by both accumulation and volume balance) - - /// Pore volume at time n+1 - real64 poreVolumeNew = 0.0; - - /// Pore volume at the previous converged time step - real64 poreVolumeOld = 0.0; - - /// Derivative of pore volume with respect to pressure - real64 dPoreVolume_dPres = 0.0; - - // Residual information - - /// Index of the local row corresponding to this element - localIndex localRow = -1; - - /// Indices of the matrix rows/columns corresponding to the dofs in this element - globalIndex dofIndices[numDof]{}; - - /// C-array storage for the element local residual vector (all equations except volume balance) - real64 localResidual[numEqn]{}; - - /// C-array storage for the element local Jacobian matrix (all equations except volume balance, all dofs) - real64 localJacobian[numEqn][numDof]{}; - - }; - - /** - * @brief Getter for the ghost rank of an element - * @param[in] ei the element index - * @return the ghost rank of the element - */ - GEOSX_HOST_DEVICE - integer elemGhostRank( localIndex const ei ) const - { return m_elemGhostRank( ei ); } - - - /** - * @brief Performs the setup phase for the kernel. - * @param[in] ei the element index - * @param[in] stack the stack variables - */ - GEOSX_HOST_DEVICE - void setup( localIndex const ei, - StackVariables & stack ) const - { - // initialize the pore volume - stack.poreVolumeNew = m_volume[ei] * m_porosityNew[ei][0]; - stack.poreVolumeOld = m_volume[ei] * m_porosityOld[ei][0]; - stack.dPoreVolume_dPres = m_volume[ei] * m_dPoro_dPres[ei][0]; - - // set row index and degrees of freedom indices for this element - stack.localRow = m_dofNumber[ei] - m_rankOffset; - for( integer idof = 0; idof < numDof; ++idof ) - { - stack.dofIndices[idof] = m_dofNumber[ei] + idof; - } - } - - /** - * @brief Compute the local accumulation contributions to the residual and Jacobian - * @tparam FUNC the type of the function that can be used to customize the kernel - * @param[in] ei the element index - * @param[inout] stack the stack variables - * @param[in] phaseAmountKernelOp the function used to customize the kernel - */ - template< typename FUNC = NoOpFunc > - GEOSX_HOST_DEVICE - void computeAccumulation( localIndex const ei, - StackVariables & stack, - FUNC && phaseAmountKernelOp = NoOpFunc{} ) const - { - // construct the slices for variables accessed multiple times - arraySlice2d< real64 const, compflow::USD_COMP_DC - 1 > dCompFrac_dCompDens = m_dCompFrac_dCompDens[ei]; - - arraySlice1d< real64 const, compflow::USD_PHASE - 1 > phaseVolFracOld = m_phaseVolFracOld[ei]; - 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]; - - 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, 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]; - - // temporary work arrays - real64 dPhaseAmount_dC[numComp]{}; - real64 dPhaseCompFrac_dC[numComp]{}; - - // sum contributions to component accumulation from each phase - for( integer ip = 0; ip < m_numPhases; ++ip ) - { - real64 const phaseAmountNew = stack.poreVolumeNew * phaseVolFrac[ip] * phaseDens[ip]; - 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]); - - // assemble density dependence - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseDens_dComp[ip], dPhaseAmount_dC ); - for( integer jc = 0; jc < numComp; ++jc ) - { - dPhaseAmount_dC[jc] = dPhaseAmount_dC[jc] * phaseVolFrac[ip] - + phaseDens[ip] * dPhaseVolFrac_dCompDens[ip][jc]; - dPhaseAmount_dC[jc] *= stack.poreVolumeNew; - } - - // ic - index of component whose conservation equation is assembled - // (i.e. row number in local matrix) - for( integer ic = 0; ic < numComp; ++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]; - - stack.localResidual[ic] += phaseCompAmountNew - phaseCompAmountOld; - stack.localJacobian[ic][0] += dPhaseCompAmount_dP; - - // jc - index of component w.r.t. whose compositional var the derivative is being taken - // (i.e. col number in local matrix) - - // assemble phase composition dependence - applyChainRule( numComp, dCompFrac_dCompDens, dPhaseCompFrac_dComp[ip][ic], dPhaseCompFrac_dC ); - for( integer jc = 0; jc < numComp; ++jc ) - { - real64 const dPhaseCompAmount_dC = dPhaseCompFrac_dC[jc] * phaseAmountNew - + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; - stack.localJacobian[ic][jc + 1] += dPhaseCompAmount_dC; - } - } - - // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives - // possible use: assemble the derivatives wrt temperature, and the accumulation term of the energy equation for this phase - phaseAmountKernelOp( ip, stack.localResidual, stack.localJacobian, phaseAmountNew, phaseAmountOld, dPhaseAmount_dP, dPhaseAmount_dC ); - - } - } - - /** - * @brief Compute the local volume balance contributions to the residual and Jacobian - * @tparam FUNC the type of the function that can be used to customize the kernel - * @param[in] ei the element index - * @param[inout] stack the stack variables - * @param[in] phaseVolFractionSumKernelOp the function used to customize the kernel - */ - template< typename FUNC = NoOpFunc > - GEOSX_HOST_DEVICE - void computeVolumeBalance( localIndex const ei, - StackVariables & stack, - FUNC && phaseVolFractionSumKernelOp = NoOpFunc{} ) const - { - 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]; - - real64 oneMinusPhaseVolFracSum = 1.0; - - // sum contributions to component accumulation from each phase - for( integer ip = 0; ip < m_numPhases; ++ip ) - { - oneMinusPhaseVolFracSum -= phaseVolFrac[ip]; - stack.localJacobian[numComp][0] -= dPhaseVolFrac_dPres[ip]; - - for( integer jc = 0; jc < numComp; ++jc ) - { - stack.localJacobian[numComp][jc+1] -= dPhaseVolFrac_dCompDens[ip][jc]; - } - } - - // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) - stack.localResidual[numComp] = stack.poreVolumeNew * oneMinusPhaseVolFracSum; - for( integer idof = 0; idof < numComp+1; ++idof ) - { - stack.localJacobian[numComp][idof] *= stack.poreVolumeNew; - } - stack.localJacobian[numComp][0] += stack.dPoreVolume_dPres * oneMinusPhaseVolFracSum; - - // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives - // possible use: assemble the derivatives wrt temperature, and use oneMinusPhaseVolFracSum if poreVolumeNew depends on temperature - phaseVolFractionSumKernelOp( stack.localResidual, stack.localJacobian, oneMinusPhaseVolFracSum ); - } - - /** - * @brief Performs the complete phase for the kernel. - * @param[in] ei the element index - * @param[inout] stack the stack variables - */ - GEOSX_HOST_DEVICE - void complete( localIndex const GEOSX_UNUSED_PARAM( ei ), - StackVariables & stack ) const - { - using namespace CompositionalMultiphaseUtilities; - - // apply equation/variable change transformation to the component mass balance equations - real64 work[numDof]{}; - shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( numComp, numDof, stack.localJacobian, work ); - shiftElementsAheadByOneAndReplaceFirstElementWithSum( numComp, stack.localResidual ); - - // add contribution to residual and jacobian into: - // - the component mass balance equations (i = 0 to i = numComp-1) - // - the volume balance equations (i = numComp) - // note that numDof includes derivatives wrt temperature if this class is derived in ThermalKernels - for( integer i = 0; i < numComp+1; ++i ) - { - m_localRhs[stack.localRow + i] += stack.localResidual[i]; - m_localMatrix.addToRow< serialAtomic >( stack.localRow + i, - stack.dofIndices, - stack.localJacobian[i], - numDof ); - } - } - - /** - * @brief Performs the kernel launch - * @tparam POLICY the policy used in the RAJA kernels - * @tparam KERNEL_TYPE the kernel type - * @param[in] numElems the number of elements - * @param[inout] kernelComponent the kernel component providing access to setup/compute/complete functions and stack variables - */ - template< typename POLICY, typename KERNEL_TYPE > - static void - launch( localIndex const numElems, - KERNEL_TYPE const & kernelComponent ) - { - GEOSX_MARK_FUNCTION; - - forAll< POLICY >( numElems, [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( kernelComponent.elemGhostRank( ei ) >= 0 ) - { - return; - } - - typename KERNEL_TYPE::StackVariables stack; - - kernelComponent.setup( ei, stack ); - kernelComponent.computeAccumulation( ei, stack ); - kernelComponent.computeVolumeBalance( ei, stack ); - kernelComponent.complete( ei, stack ); - } ); - } - -protected: - - /// Number of fluid phases - integer const m_numPhases; - - /// Offset for my MPI rank - globalIndex const m_rankOffset; - - /// View on the dof numbers - arrayView1d< globalIndex const > const m_dofNumber; - - /// View on the ghost ranks - arrayView1d< integer const > const m_elemGhostRank; - - /// View on the element volumes - arrayView1d< real64 const > const m_volume; - - /// Views on the porosity - arrayView2d< real64 const > const m_porosityOld; - arrayView2d< real64 const > const m_porosityNew; - arrayView2d< real64 const > const m_dPoro_dPres; - - /// 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) - 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) - 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; - - /// Views on the phase component fraction (excluding derivative wrt temperature) - 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; - - /// View on the local CRS matrix - CRSMatrixView< real64, globalIndex const > const m_localMatrix; - /// View on the local RHS - arrayView1d< real64 > const m_localRhs; - -}; - -/** - * @class ElementBasedAssemblyKernelFactory - */ -class ElementBasedAssemblyKernelFactory -{ -public: - - /** - * @brief Create a new kernel and launch - * @tparam POLICY the policy used in the RAJA kernel - * @param[in] numComps the number of fluid components - * @param[in] numPhases the number of fluid phases - * @param[in] rankOffset the offset of my MPI rank - * @param[in] dofKey the string key to retrieve the degress of freedom numbers - * @param[in] subRegion the element subregion - * @param[in] fluid the fluid model - * @param[in] solid the solid model - * @param[inout] localMatrix the local CRS matrix - * @param[inout] localRhs the local right-hand side vector - */ - template< typename POLICY > - static void - createAndLaunch( integer const numComps, - integer const numPhases, - globalIndex const rankOffset, - string const dofKey, - ElementSubRegionBase const & subRegion, - MultiFluidBase const & fluid, - CoupledSolidBase const & solid, - CRSMatrixView< real64, globalIndex const > const & localMatrix, - arrayView1d< real64 > const & localRhs ) - { - internal::kernelLaunchSelectorCompSwitch( numComps, [&] ( auto NC ) - { - integer constexpr NUM_COMP = NC(); - integer constexpr NUM_DOF = NC()+1; - ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF > - kernel( numPhases, rankOffset, dofKey, subRegion, fluid, solid, localMatrix, localRhs ); - ElementBasedAssemblyKernel< NUM_COMP, NUM_DOF >::template launch< POLICY >( subRegion.size(), kernel ); - } ); - } - -}; - -/******************************** ResidualNormKernel ********************************/ - -struct ResidualNormKernel -{ - - template< typename POLICY, typename REDUCE_POLICY > - static void launch( arrayView1d< real64 const > const & localResidual, - globalIndex const rankOffset, - integer const numComponents, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & ghostRank, - arrayView1d< real64 const > const & refPoro, - arrayView1d< real64 const > const & volume, - arrayView1d< real64 const > const & totalDensOld, - real64 & localResidualNorm ) - { - RAJA::ReduceSum< REDUCE_POLICY, real64 > localSum( 0.0 ); - - forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( ghostRank[ei] < 0 ) - { - localIndex const localRow = dofNumber[ei] - rankOffset; - real64 const normalizer = totalDensOld[ei] * refPoro[ei] * volume[ei]; - - for( integer idof = 0; idof < numComponents + 1; ++idof ) - { - real64 const val = localResidual[localRow + idof] / normalizer; - localSum += val * val; - } - } - } ); - localResidualNorm += localSum.get(); - } - -}; - - -/******************************** SolutionCheckKernel ********************************/ - -struct SolutionCheckKernel -{ - template< typename POLICY, typename REDUCE_POLICY > - static localIndex - launch( arrayView1d< real64 const > const & localSolution, - globalIndex const rankOffset, - localIndex const numComponents, - arrayView1d< globalIndex const > const & dofNumber, - arrayView1d< integer const > const & ghostRank, - arrayView1d< real64 const > const & pres, - arrayView1d< real64 const > const & dPres, - arrayView2d< real64 const, compflow::USD_COMP > const & compDens, - arrayView2d< real64 const, compflow::USD_COMP > const & dCompDens, - integer const allowCompDensChopping, - real64 const scalingFactor ) - { - real64 constexpr eps = minDensForDivision; - - RAJA::ReduceMin< REDUCE_POLICY, integer > check( 1 ); - - forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) - { - if( ghostRank[ei] < 0 ) - { - localIndex const localRow = dofNumber[ei] - rankOffset; - { - real64 const newPres = pres[ei] + dPres[ei] + scalingFactor * localSolution[localRow]; - check.min( newPres >= 0.0 ); - } - - // if component density chopping is not allowed, the time step fails if a component density is negative - // otherwise, we just check that the total density is positive, and negative component densities - // will be chopped (i.e., set to zero) in ApplySystemSolution) - if( !allowCompDensChopping ) - { - for( integer ic = 0; ic < numComponents; ++ic ) - { - real64 const newDens = compDens[ei][ic] + dCompDens[ei][ic] + scalingFactor * localSolution[localRow + ic + 1]; - check.min( newDens >= 0.0 ); - } - } - else - { - real64 totalDens = 0.0; - for( integer ic = 0; ic < numComponents; ++ic ) - { - real64 const newDens = compDens[ei][ic] + dCompDens[ei][ic] + scalingFactor * localSolution[localRow + ic + 1]; - totalDens += (newDens > 0.0) ? newDens : 0.0; - } - check.min( totalDens >= eps ); - } - } - } ); - return check.get(); - } - -}; - -/******************************** HydrostaticPressureKernel ********************************/ - -struct HydrostaticPressureKernel -{ - - // TODO: this type of constants should be centralized somewhere or provided by fluid model - static real64 constexpr MIN_FOR_PHASE_PRESENCE = 1e-12; - - enum class ReturnType : integer - { - FAILED_TO_CONVERGE = 0, - DETECTED_MULTIPHASE_FLOW = 1, - SUCCESS = 2 - }; - - template< typename FLUID_WRAPPER > - static ReturnType - computeHydrostaticPressure( integer const numComps, - integer const numPhases, - integer const ipInit, - integer const maxNumEquilIterations, - real64 const & equilTolerance, - real64 const (&gravVector)[ 3 ], - FLUID_WRAPPER fluidWrapper, - arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers, - TableFunction::KernelWrapper tempTableWrapper, - real64 const & refElevation, - real64 const & refPres, - arraySlice1d< real64 const > const & refPhaseMassDens, - real64 const & newElevation, - real64 & newPres, - arraySlice1d< real64 > const & newPhaseMassDens ) - { - // fluid properties at this elevation - StackArray< real64, 2, constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, compflow::LAYOUT_COMP > compFrac( 1, numComps ); - StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseFrac( 1, 1, numPhases ); - StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseDens( 1, 1, numPhases ); - StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseMassDens( 1, 1, numPhases ); - StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseVisc( 1, 1, numPhases ); - StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseEnthalpy( 1, 1, numPhases ); - StackArray< real64, 3, constitutive::MultiFluidBase::MAX_NUM_PHASES, multifluid::LAYOUT_PHASE > phaseInternalEnergy( 1, 1, numPhases ); - StackArray< real64, 4, constitutive::MultiFluidBase::MAX_NUM_PHASES *constitutive::MultiFluidBase::MAX_NUM_COMPONENTS, - multifluid::LAYOUT_PHASE_COMP > phaseCompFrac( 1, 1, numPhases, numComps ); - real64 totalDens = 0.0; - - bool isSinglePhaseFlow = true; - - // Step 1: compute the hydrostatic pressure at the current elevation - - real64 const gravCoef = gravVector[2] * ( refElevation - newElevation ); - real64 const temp = tempTableWrapper.compute( &newElevation ); - for( integer ic = 0; ic < numComps; ++ic ) - { - compFrac[0][ic] = compFracTableWrappers[ic].compute( &newElevation ); - } - - // Step 2: guess the pressure with the refPhaseMassDensity - - real64 pres0 = refPres - refPhaseMassDens[ipInit] * gravCoef; - real64 pres1 = 0.0; - - // Step 3: compute the mass density at this elevation using the guess, and update pressure - - fluidWrapper.compute( pres0, - temp, - compFrac[0], - phaseFrac[0][0], - phaseDens[0][0], - phaseMassDens[0][0], - phaseVisc[0][0], - phaseEnthalpy[0][0], - phaseInternalEnergy[0][0], - phaseCompFrac[0][0], - totalDens ); - pres1 = refPres - 0.5 * ( refPhaseMassDens[ipInit] + phaseMassDens[0][0][ipInit] ) * gravCoef; - - // Step 4: fixed-point iteration until convergence - - bool equilHasConverged = false; - for( integer eqIter = 0; eqIter < maxNumEquilIterations; ++eqIter ) - { - - // check convergence - equilHasConverged = ( LvArray::math::abs( pres0 - pres1 ) < equilTolerance ); - pres0 = pres1; - - // if converged, check number of phases and move on - if( equilHasConverged ) - { - // make sure that the fluid is single-phase, other we have to issue a warning (for now) - // if only one phase is mobile, we are in good shape (unfortunately it is hard to access relperm from here) - localIndex numberOfPhases = 0; - for( integer ip = 0; ip < numPhases; ++ip ) - { - if( phaseFrac[0][0][ip] > MIN_FOR_PHASE_PRESENCE ) - { - numberOfPhases++; - } - } - if( numberOfPhases > 1 ) - { - isSinglePhaseFlow = false; - } - - break; - } - - // compute the mass density at this elevation using the previous pressure, and compute the new pressure - fluidWrapper.compute( pres0, - temp, - compFrac[0], - phaseFrac[0][0], - phaseDens[0][0], - phaseMassDens[0][0], - phaseVisc[0][0], - phaseEnthalpy[0][0], - phaseInternalEnergy[0][0], - phaseCompFrac[0][0], - totalDens ); - pres1 = refPres - 0.5 * ( refPhaseMassDens[ipInit] + phaseMassDens[0][0][ipInit] ) * gravCoef; - } - - // Step 5: save the hydrostatic pressure and the corresponding density - - newPres = pres1; - for( integer ip = 0; ip < numPhases; ++ip ) - { - newPhaseMassDens[ip] = phaseMassDens[0][0][ip]; - } - - if( !equilHasConverged ) - { - return ReturnType::FAILED_TO_CONVERGE; - } - else if( !isSinglePhaseFlow ) - { - return ReturnType::DETECTED_MULTIPHASE_FLOW; - } - else - { - return ReturnType::SUCCESS; - } - } - - template< typename FLUID_WRAPPER > - static ReturnType - launch( localIndex const size, - integer const numComps, - integer const numPhases, - integer const ipInit, - integer const maxNumEquilIterations, - real64 const equilTolerance, - real64 const (&gravVector)[ 3 ], - real64 const & minElevation, - real64 const & elevationIncrement, - real64 const & datumElevation, - real64 const & datumPres, - FLUID_WRAPPER fluidWrapper, - arrayView1d< TableFunction::KernelWrapper const > compFracTableWrappers, - TableFunction::KernelWrapper tempTableWrapper, - arrayView1d< arrayView1d< real64 > const > elevationValues, - arrayView1d< real64 > pressureValues ) - { - - ReturnType returnVal = ReturnType::SUCCESS; - - // Step 1: compute the phase mass densities at datum - - // datum fluid properties - array2d< real64, compflow::LAYOUT_COMP > datumCompFrac( 1, numComps ); - array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseFrac( 1, 1, numPhases ); - array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseDens( 1, 1, numPhases ); - array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseMassDens( 1, 1, numPhases ); - array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseVisc( 1, 1, numPhases ); - array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseEnthalpy( 1, 1, numPhases ); - array3d< real64, multifluid::LAYOUT_PHASE > datumPhaseInternalEnergy( 1, 1, numPhases ); - array4d< real64, multifluid::LAYOUT_PHASE_COMP > datumPhaseCompFrac( 1, 1, numPhases, numComps ); - real64 datumTotalDens = 0.0; - - real64 const datumTemp = tempTableWrapper.compute( &datumElevation ); - for( integer ic = 0; ic < numComps; ++ic ) - { - datumCompFrac[0][ic] = compFracTableWrappers[ic].compute( &datumElevation ); - } - fluidWrapper.compute( datumPres, - datumTemp, - datumCompFrac[0], - datumPhaseFrac[0][0], - datumPhaseDens[0][0], - datumPhaseMassDens[0][0], - datumPhaseVisc[0][0], - datumPhaseEnthalpy[0][0], - datumPhaseInternalEnergy[0][0], - datumPhaseCompFrac[0][0], - datumTotalDens ); - - // Step 2: find the closest elevation to datumElevation - - forAll< parallelHostPolicy >( size, [=] ( localIndex const i ) - { - real64 const elevation = minElevation + i * elevationIncrement; - elevationValues[0][i] = elevation; - } ); - integer const iRef = LvArray::sortedArrayManipulation::find( elevationValues[0].begin(), - elevationValues[0].size(), - datumElevation ); - - // Step 3: compute the mass density and pressure at the reference elevation - - array2d< real64 > phaseMassDens( pressureValues.size(), numPhases ); - // temporary array without permutation to compile on Lassen - array1d< real64 > datumPhaseMassDensTmp( numPhases ); - for( integer ip = 0; ip < numPhases; ++ip ) - { - datumPhaseMassDensTmp[ip] = datumPhaseMassDens[0][0][ip]; - } - - ReturnType const refReturnVal = - computeHydrostaticPressure( numComps, - numPhases, - ipInit, - maxNumEquilIterations, - equilTolerance, - gravVector, - fluidWrapper, - compFracTableWrappers, - tempTableWrapper, - datumElevation, - datumPres, - datumPhaseMassDensTmp, - elevationValues[0][iRef], - pressureValues[iRef], - phaseMassDens[iRef] ); - if( refReturnVal == ReturnType::FAILED_TO_CONVERGE ) - { - return ReturnType::FAILED_TO_CONVERGE; - } - else if( refReturnVal == ReturnType::DETECTED_MULTIPHASE_FLOW ) - { - returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW; - } - - // Step 4: for each elevation above the reference elevation, compute the pressure - - localIndex const numEntriesAboveRef = size - iRef - 1; - forAll< serialPolicy >( numEntriesAboveRef, [=, &returnVal] ( localIndex const i ) - { - ReturnType const returnValAboveRef = - computeHydrostaticPressure( numComps, - numPhases, - ipInit, - maxNumEquilIterations, - equilTolerance, - gravVector, - fluidWrapper, - compFracTableWrappers, - tempTableWrapper, - elevationValues[0][iRef+i], - pressureValues[iRef+i], - phaseMassDens[iRef+i], - elevationValues[0][iRef+i+1], - pressureValues[iRef+i+1], - phaseMassDens[iRef+i+1] ); - if( returnValAboveRef == ReturnType::FAILED_TO_CONVERGE ) - { - returnVal = ReturnType::FAILED_TO_CONVERGE; - } - else if( ( returnValAboveRef == ReturnType::DETECTED_MULTIPHASE_FLOW ) && - ( returnVal != ReturnType::FAILED_TO_CONVERGE ) ) - { - returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW; - } - - } ); - - // Step 5: for each elevation below the reference elevation, compute the pressure - - localIndex const numEntriesBelowRef = iRef; - forAll< serialPolicy >( numEntriesBelowRef, [=, &returnVal] ( localIndex const i ) - { - ReturnType const returnValBelowRef = - computeHydrostaticPressure( numComps, - numPhases, - ipInit, - maxNumEquilIterations, - equilTolerance, - gravVector, - fluidWrapper, - compFracTableWrappers, - tempTableWrapper, - elevationValues[0][iRef-i], - pressureValues[iRef-i], - phaseMassDens[iRef-i], - elevationValues[0][iRef-i-1], - pressureValues[iRef-i-1], - phaseMassDens[iRef-i-1] ); - if( returnValBelowRef == ReturnType::FAILED_TO_CONVERGE ) - { - returnVal = ReturnType::FAILED_TO_CONVERGE; - } - else if( ( returnValBelowRef == ReturnType::DETECTED_MULTIPHASE_FLOW ) && - ( returnVal != ReturnType::FAILED_TO_CONVERGE ) ) - { - returnVal = ReturnType::DETECTED_MULTIPHASE_FLOW; - } - - } ); - - return returnVal; - } - -}; - - -/******************************** Kernel launch machinery ********************************/ - -template< typename KERNELWRAPPER, typename ... ARGS > -void KernelLaunchSelector1( integer const numComp, ARGS && ... args ) -{ - internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - KERNELWRAPPER::template launch< NC() >( std::forward< ARGS >( args )... ); - } ); -} - -template< typename KERNELWRAPPER, typename ... ARGS > -void KernelLaunchSelector2( integer const numComp, integer const numPhase, ARGS && ... args ) -{ - // Ideally this would be inside the dispatch, but it breaks on Summit with GCC 9.1.0 and CUDA 11.0.3. - if( numPhase == 2 ) - { - internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - KERNELWRAPPER::template launch< NC(), 2 >( std::forward< ARGS >( args ) ... ); - } ); - } - else if( numPhase == 3 ) - { - internal::kernelLaunchSelectorCompSwitch( numComp, [&] ( auto NC ) - { - KERNELWRAPPER::template launch< NC(), 3 >( std::forward< ARGS >( args ) ... ); - } ); - } - else - { - GEOSX_ERROR( "Unsupported number of phases: " << numPhase ); - } -} - -} // namespace IsothermalCompositionalMultiphaseBaseKernels - -} // namespace geosx - - -#endif //GEOSX_PHYSICSSOLVERS_FLUIDFLOW_ISOTHERMALCOMPOSITIONALMULTIPHASEBASEKERNELS_HPP From faeb418906012b0ee35a818fd7ac165c252afc6f Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Tue, 25 Jan 2022 22:33:49 -0800 Subject: [PATCH 24/34] added conduction term --- .../fluidFlow/CompositionalMultiphaseFVM.cpp | 1 + ...ermalCompositionalMultiphaseFVMKernels.hpp | 61 +++++++++++++++++-- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 4d997bd3c66..406108e7e2f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -120,6 +120,7 @@ void CompositionalMultiphaseFVM::assembleFluxTerms( real64 const dt, fluidModelNames(), capPresModelNames(), permeabilityModelNames(), + thermalConductivityModelNames(), dt, localMatrix.toViewConstSizes(), localRhs.toView() ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index 11210ce5927..2429d38afc6 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -19,6 +19,7 @@ #ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEFVMKERNELS_HPP #define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEFVMKERNELS_HPP +#include "constitutive/thermalConductivity/ThermalConductivityExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp" namespace geosx @@ -217,13 +218,15 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne using Base::maxNumElems; using Base::maxNumConns; using Base::maxStencilSize; + using Base::m_stencilWrapper; using Base::m_seri; using Base::m_sesri; using Base::m_sei; - using ThermalCompFlowAccessors = - StencilAccessors< extrinsicMeshData::flow::dPhaseMobility_dTemperature, + StencilAccessors< extrinsicMeshData::flow::temperature, + extrinsicMeshData::flow::deltaTemperature, + extrinsicMeshData::flow::dPhaseMobility_dTemperature, extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature >; using ThermalMultiFluidAccessors = @@ -234,6 +237,10 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne extrinsicMeshData::multifluid::dPhaseEnthalpy_dTemperature, extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction >; + using ThermalConductivityAccessors = + StencilAccessors< extrinsicMeshData::thermalconductivity::effectiveConductivity >; + // for now, we treat thermal conductivity explicitly + /** * @brief Constructor for the kernel interface * @param[in] numPhases the number of fluid phases @@ -247,6 +254,7 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne * @param[in] thermalMultiFluidAccessors * @param[in] capPressureAccessors * @param[in] permeabilityAccessors + * @param[in] thermalConductivityAccessors * @param[in] dt time step size * @param[inout] localMatrix the local CRS matrix * @param[inout] localRhs the local right-hand side vector @@ -262,6 +270,7 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne ThermalMultiFluidAccessors const & thermalMultiFluidAccessors, CapPressureAccessors const & capPressureAccessors, PermeabilityAccessors const & permeabilityAccessors, + ThermalConductivityAccessors const & thermalConductivityAccessors, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -277,6 +286,8 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne dt, localMatrix, localRhs ), + m_temp( thermalCompFlowAccessors.get( extrinsicMeshData::flow::temperature {} ) ), + m_dTemp( thermalCompFlowAccessors.get( extrinsicMeshData::flow::deltaTemperature {} ) ), m_dPhaseMob_dTemp( thermalCompFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dTemperature {} ) ), m_dPhaseVolFrac_dTemp( thermalCompFlowAccessors.get( extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature {} ) ), m_dPhaseMassDens_dTemp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseMassDensity_dTemperature {} ) ), @@ -284,7 +295,8 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne m_phaseEnthalpy( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::phaseEnthalpy {} ) ), m_dPhaseEnthalpy_dPres( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dPressure {} ) ), m_dPhaseEnthalpy_dTemp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dTemperature {} ) ), - m_dPhaseEnthalpy_dComp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction {} ) ) + m_dPhaseEnthalpy_dComp( thermalMultiFluidAccessors.get( extrinsicMeshData::multifluid::dPhaseEnthalpy_dGlobalCompFraction {} ) ), + m_thermalConductivity( thermalConductivityAccessors.get( extrinsicMeshData::thermalconductivity::effectiveConductivity {} ) ) {} struct StackVariables : public Base::StackVariables @@ -304,6 +316,7 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne using Base::StackVariables::stencilSize; using Base::StackVariables::numFluxElems; using Base::StackVariables::transmissibility; + using Base::StackVariables::dTrans_dPres; using Base::StackVariables::dofColIndices; using Base::StackVariables::localFlux; using Base::StackVariables::localFluxJacobian; @@ -313,6 +326,10 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne /// Derivatives of component fluxes wrt temperature stackArray2d< real64, maxStencilSize * numComp > dCompFlux_dT; + // Thermal transmissibility (for now, no derivatives) + + real64 thermalTransmissibility[maxNumConns][2]{}; + // Energy fluxes and derivatives /// Energy fluxes @@ -342,6 +359,7 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne arraySlice1d< real64 > dEnergyFlux_dTSlice = stack.dEnergyFlux_dT.toSlice(); arraySlice2d< real64 > dEnergyFlux_dCSlice = stack.dEnergyFlux_dC.toSlice(); + // *********************************************** // First, we call the base computeFlux to compute: // 1) compFlux and its derivatives (including derivatives wrt temperature), // 2) enthalpyFlux and its derivatives (including derivatives wrt temperature @@ -455,7 +473,6 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne dCompFlux_dTSlice[k_up][ic] += phaseFlux * dPhaseCompFrac_dTempSub[ic]; } - // Step 4: compute the enthalpy flux real64 const enthalpy = m_phaseEnthalpy[er_up][esr_up][ei_up][0][ip]; @@ -487,8 +504,28 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne } ); - // TODO HERE: add conduction + // ***************************************************** + // Computation of the conduction term in the energy flux + // Note that this term is computed using an explicit treatment of conductivity for now + // Step 1: compute the thermal transmissibilities at this face + m_stencilWrapper.computeWeights( iconn, + m_thermalConductivity, + m_thermalConductivity, // unused for now + stack.thermalTransmissibility, + stack.dTrans_dPres ); // unused for now + // Step 2: compute temperature difference at the interface + for( integer i = 0; i < stack.stencilSize; ++i ) + { + localIndex const er = m_seri( iconn, i ); + localIndex const esr = m_sesri( iconn, i ); + localIndex const ei = m_sei( iconn, i ); + + stack.energyFlux += stack.thermalTransmissibility[0][i] * ( m_temp[er][esr][ei] + m_dTemp[er][esr][ei] ); + stack.dEnergyFlux_dT[i] += stack.thermalTransmissibility[0][i]; + } + + // ********************************************************************************** // At this point, we have computed the energyFlux and the compFlux for all components // We have to do two things here: // 1) Add dCompFlux_dTemp to the localFluxJacobian of the component mass balance equations @@ -563,6 +600,10 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne protected: + /// Views on temperature + ElementViewConst< arrayView1d< real64 const > > const m_temp; + ElementViewConst< arrayView1d< real64 const > > const m_dTemp; + /// Views on derivatives of phase mobilities, volume fractions, mass densities and phase comp fractions ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_dPhaseMob_dTemp; ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_dPhaseVolFrac_dTemp; @@ -575,6 +616,10 @@ class FaceBasedAssemblyKernel : public IsothermalCompositionalMultiphaseFVMKerne ElementViewConst< arrayView3d< real64 const, multifluid::USD_PHASE > > const m_dPhaseEnthalpy_dTemp; ElementViewConst< arrayView4d< real64 const, multifluid::USD_PHASE_DC > > const m_dPhaseEnthalpy_dComp; + /// View on thermal conductivity + ElementViewConst< arrayView3d< real64 const > > m_thermalConductivity; + // for now, we treat thermal conductivity explicitly + }; /** @@ -600,6 +645,7 @@ class FaceBasedAssemblyKernelFactory * @param[in] fluidModelNames names of the fluid models * @param[in] capPresModelNames names of the capillary pressure models * @param[in] permeabilityModelNames names of the permeability models + * @param[in] thermalConductivityNames names of the thermal conductivity models * @param[in] dt time step size * @param[inout] localMatrix the local CRS matrix * @param[inout] localRhs the local right-hand side vector @@ -618,6 +664,7 @@ class FaceBasedAssemblyKernelFactory arrayView1d< string const > const & fluidModelNames, arrayView1d< string const > const & capPresModelNames, arrayView1d< string const > const & permeabilityModelNames, + arrayView1d< string const > const & thermalConductivityModelNames, real64 const & dt, CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) @@ -639,9 +686,11 @@ class FaceBasedAssemblyKernelFactory typename KERNEL_TYPE::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, solverName, targetRegionNames, fluidModelNames ); typename KERNEL_TYPE::CapPressureAccessors capPressureAccessors( elemManager, solverName, targetRegionNames, capPresModelNames ); typename KERNEL_TYPE::PermeabilityAccessors permeabilityAccessors( elemManager, solverName, targetRegionNames, permeabilityModelNames ); + typename KERNEL_TYPE::ThermalConductivityAccessors thermalConductivityAccessors( elemManager, solverName, targetRegionNames, thermalConductivityModelNames ); KERNEL_TYPE kernel( numPhases, rankOffset, capPressureFlag, stencilWrapper, dofNumberAccessor, - compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, capPressureAccessors, permeabilityAccessors, + compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, + capPressureAccessors, permeabilityAccessors, thermalConductivityAccessors, dt, localMatrix, localRhs ); KERNEL_TYPE::template launch< POLICY >( stencilWrapper.size(), kernel ); } ); From 01b24783ded557e72adac9842b3354b4b08344a9 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Sun, 27 Feb 2022 11:23:25 -0800 Subject: [PATCH 25/34] implemented temperature BC --- .../fluidFlow/CompositionalMultiphaseBase.cpp | 142 ++++++++++++++---- .../fluidFlow/CompositionalMultiphaseBase.hpp | 4 +- ...mpositionalMultiphaseBaseExtrinsicData.hpp | 9 ++ .../fluidFlow/CompositionalMultiphaseFVM.cpp | 10 +- .../wells/CompositionalMultiphaseWell.hpp | 11 -- 5 files changed, 130 insertions(+), 46 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 20d627062c6..84b4046ca84 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -60,7 +60,7 @@ CompositionalMultiphaseBase::CompositionalMultiphaseBase( const string & name, m_numComponents( 0 ), m_computeCFLNumbers( 0 ), m_capPressureFlag( 0 ), - m_thermalFlag( 0 ), + m_isThermal( 0 ), m_maxCompFracChange( 1.0 ), m_minScalingFactor( 0.01 ), m_allowCompDensChopping( 1 ) @@ -75,7 +75,7 @@ CompositionalMultiphaseBase::CompositionalMultiphaseBase( const string & name, setInputFlag( InputFlags::OPTIONAL ). setDescription( "Use mass formulation instead of molar" ); - this->registerWrapper( viewKeyStruct::thermalFlagString(), &m_thermalFlag ). + this->registerWrapper( viewKeyStruct::isThermalString(), &m_isThermal ). setApplyDefaultValue( 0 ). setInputFlag( InputFlags::OPTIONAL ). setDescription( "Flag indicating whether the problem is thermal or not." ); @@ -150,7 +150,7 @@ void CompositionalMultiphaseBase::registerDataOnMesh( Group & meshBodies ) m_numComponents = referenceFluid.numFluidComponents(); } // n_c components + one pressure ( + one temperature if needed ) - m_numDofPerCell = m_thermalFlag ? m_numComponents + 2 : m_numComponents + 1; + m_numDofPerCell = m_isThermal ? m_numComponents + 2 : m_numComponents + 1; // 2. Register and resize all fields as necessary forMeshTargets( meshBodies, [&]( string const &, @@ -186,12 +186,14 @@ void CompositionalMultiphaseBase::registerDataOnMesh( Group & meshBodies ) subRegion.registerExtrinsicData< initialPressure >( getName() ); subRegion.registerExtrinsicData< deltaPressure >( getName() ); - subRegion.registerExtrinsicData< bcPressure >( getName() ); + subRegion.registerExtrinsicData< bcPressure >( getName() ); // needed for the application of boundary conditions // these fields are always registered for the evaluation of the fluid properties subRegion.registerExtrinsicData< temperature >( getName() ); subRegion.registerExtrinsicData< deltaTemperature >( getName() ); + subRegion.registerExtrinsicData< bcTemperature >( getName() ); // needed for the application of boundary conditions + // The resizing of the arrays needs to happen here, before the call to initializePreSubGroups, // to make sure that the dimensions are properly set before the timeHistoryOutput starts its initialization. @@ -223,7 +225,7 @@ void CompositionalMultiphaseBase::registerDataOnMesh( Group & meshBodies ) subRegion.registerExtrinsicData< dPhaseMobility_dGlobalCompDensity >( getName() ). reference().resizeDimension< 1, 2 >( m_numPhases, m_numComponents ); - if( m_thermalFlag ) + if( m_isThermal ) { subRegion.registerExtrinsicData< dPhaseVolumeFraction_dTemperature >( getName() ). reference().resizeDimension< 1 >( m_numPhases ); @@ -301,7 +303,7 @@ void CompositionalMultiphaseBase::setConstitutiveNames( ElementSubRegionBase & s InputError ); } - if( m_thermalFlag ) + if( m_isThermal ) { string & thermalConductivityName = subRegion.registerWrapper< string >( viewKeyStruct::thermalConductivityNamesString() ). setPlotLevel( PlotLevel::NOPLOT ). @@ -315,8 +317,6 @@ void CompositionalMultiphaseBase::setConstitutiveNames( ElementSubRegionBase & s GEOSX_FMT( "Thermal Conductivity model not found on subregion {}", subRegion.getName() ), InputError ); } - - } @@ -432,7 +432,7 @@ void CompositionalMultiphaseBase::updatePhaseVolumeFraction( ObjectManagerBase & string const & fluidName = dataGroup.getReference< string >( viewKeyStruct::fluidNamesString() ); MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( dataGroup, fluidName ); - if( m_thermalFlag ) + if( m_isThermal ) { thermalCompositionalMultiphaseBaseKernels:: PhaseVolumeFractionKernelFactory:: @@ -663,7 +663,7 @@ void CompositionalMultiphaseBase::initializeFluidState( MeshLevel & mesh, // - This must be called after updatePorosityAndPermeability and updatePhaseVolumeFraction // - This step depends on porosity and phaseVolFraction // - Energy balance is not supported yet, so the following flag is always false for now - if( m_thermalFlag ) + if( m_isThermal ) { // initialized porosity arrayView2d< real64 const > const porosity = porousMaterial.getPorosity(); @@ -1069,7 +1069,7 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh, totalDensOld[ei] = totalDens[ei][0]; } ); - if( m_thermalFlag ) + if( m_isThermal ) { arrayView3d< real64 const, multifluid::USD_PHASE > const phaseInternalEnergy = fluid.phaseInternalEnergy(); @@ -1155,7 +1155,7 @@ void CompositionalMultiphaseBase::assembleAccumulationAndVolumeBalanceTerms( Dom MultiFluidBase const & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidName ); CoupledSolidBase const & solid = getConstitutiveModel< CoupledSolidBase >( subRegion, solidName ); - if( m_thermalFlag ) + if( m_isThermal ) { thermalCompositionalMultiphaseBaseKernels:: ElementBasedAssemblyKernelFactory:: @@ -1314,13 +1314,16 @@ namespace { bool validateDirichletBC( DomainPartition & domain, + integer const isThermal, integer const numComp, real64 const time ) { constexpr integer MAX_NC = MultiFluidBase::MAX_NUM_COMPONENTS; FieldSpecificationManager & fsManager = FieldSpecificationManager::getInstance(); - map< string, map< string, map< string, ComponentMask< MAX_NC > > > > bcStatusMap; // map to check consistent application of BC + // maps to check consistent application of BC + map< string, map< string, map< string, ComponentMask< MAX_NC > > > > bcStatusMap; + map< string, map< string, set< string > > > bcTempStatusMap; bool bcConsistent = true; // 1. Check pressure Dirichlet BCs @@ -1334,7 +1337,7 @@ bool validateDirichletBC( DomainPartition & domain, Group & subRegion, string const & ) { - // 1.0. Check whether pressure has already been applied to this set + // Check whether pressure has already been applied to this set string const & subRegionName = subRegion.getName(); string const & regionName = subRegion.getParent().getParent().getName(); @@ -1347,7 +1350,44 @@ bool validateDirichletBC( DomainPartition & domain, subRegionSetMap[setName].setNumComp( numComp ); } ); - // 2. Check composition BC (global component fraction) + // 2. Check temperature Dirichlet BCs + if( isThermal ) + { + fsManager.apply( time, + domain, + "ElementRegions", + extrinsicMeshData::flow::temperature::key(), + [&]( FieldSpecificationBase const &, + string const & setName, + SortedArrayView< localIndex const > const &, + Group & subRegion, + string const & ) + { + + string const & subRegionName = subRegion.getName(); + string const & regionName = subRegion.getParent().getParent().getName(); + + // 2.1 Check whether temperature has already been applied to this set + auto & tempSubRegionSetMap = bcTempStatusMap[regionName][subRegionName]; + if( tempSubRegionSetMap.count( setName ) > 0 ) + { + bcConsistent = false; + GEOSX_WARNING( GEOSX_FMT( "Conflicting pressure boundary conditions on set {}/{}/{}", regionName, subRegionName, setName ) ); + } + + // 2.2 Check that there is pressure bc applied to this set + auto & presSubRegionSetMap = bcStatusMap[regionName][subRegionName]; + if( presSubRegionSetMap.count( setName ) == 0 ) + { + bcConsistent = false; + GEOSX_WARNING( GEOSX_FMT( "Pressure boundary condition not prescribed on set {}/{}/{}", regionName, subRegionName, setName ) ); + } + + // no need to set the number of components here, it was done while checking pressure + } ); + } + + // 3. Check composition BC (global component fraction) fsManager.apply( time, domain, "ElementRegions", @@ -1358,7 +1398,7 @@ bool validateDirichletBC( DomainPartition & domain, Group & subRegion, string const & ) { - // 2.0. Check pressure and record composition bc application + // 3.1 Check pressure, temperature, and record composition bc application string const & subRegionName = subRegion.getName(); string const & regionName = subRegion.getParent().getParent().getName(); integer const comp = fs.getComponent(); @@ -1369,6 +1409,15 @@ bool validateDirichletBC( DomainPartition & domain, bcConsistent = false; GEOSX_WARNING( GEOSX_FMT( "Pressure boundary condition not prescribed on set {}/{}/{}", regionName, subRegionName, setName ) ); } + if( isThermal ) + { + auto & tempSubRegionSetMap = bcTempStatusMap[regionName][subRegionName]; + if( tempSubRegionSetMap.count( setName ) == 0 ) + { + bcConsistent = false; + GEOSX_WARNING( GEOSX_FMT( "Temperature boundary condition not prescribed on set {}/{}/{}", regionName, subRegionName, setName ) ); + } + } if( comp < 0 || comp >= numComp ) { bcConsistent = false; @@ -1385,7 +1434,7 @@ bool validateDirichletBC( DomainPartition & domain, compMask.set( comp ); } ); - // 2.3 Check consistency between composition BC applied to sets + // 3.2 Check consistency between composition BC applied to sets for( auto const & regionEntry : bcStatusMap ) { for( auto const & subRegionEntry : regionEntry.second ) @@ -1424,7 +1473,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, // Only validate BC at the beginning of Newton loop if( m_nonlinearSolverParameters.m_numNewtonIterations == 0 ) { - bool const bcConsistent = validateDirichletBC( domain, m_numComponents, time + dt ); + bool const bcConsistent = validateDirichletBC( domain, m_isThermal, m_numComponents, time + dt ); GEOSX_ERROR_IF( !bcConsistent, GEOSX_FMT( "CompositionalMultiphaseBase {}: inconsistent boundary conditions", getName() ) ); } @@ -1455,7 +1504,27 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, extrinsicMeshData::flow::bcPressure::key() ); } ); - // 2. Apply composition BC (global component fraction) and store them for constitutive call + // 2. Apply temperature Dirichlet BCs, store in a separate field + if( m_isThermal ) + { + fsManager.apply( time + dt, + domain, + "ElementRegions", + extrinsicMeshData::flow::temperature::key(), + [&]( FieldSpecificationBase const & fs, + string const & setName, + SortedArrayView< localIndex const > const & targetSet, + Group & subRegion, + string const & ) + { + fs.applyFieldValue< FieldSpecificationEqual, parallelDevicePolicy<> >( targetSet, + time + dt, + subRegion, + extrinsicMeshData::flow::bcTemperature::key() ); + } ); + } + + // 3. Apply composition BC (global component fraction) and store them for constitutive call fsManager.apply( time + dt, domain, "ElementRegions", @@ -1475,7 +1544,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, globalIndex const rankOffset = dofManager.rankOffset(); string const dofKey = dofManager.getKey( viewKeyStruct::elemDofFieldString() ); - // 3. Call constitutive update, back-calculate target global component densities and apply to the system + // 4. Call constitutive update, back-calculate target global component densities and apply to the system fsManager.apply( time + dt, domain, "ElementRegions", @@ -1491,8 +1560,8 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, arrayView1d< real64 const > const bcPres = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::bcPressure::key() ); - arrayView1d< real64 const > const temp = - subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::temperature::key() ); + arrayView1d< real64 const > const bcTemp = + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::bcTemperature::key() ); arrayView2d< real64 const, compflow::USD_COMP > const compFrac = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::globalCompFraction::key() ); @@ -1507,7 +1576,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, launch< ExecPolicy >( targetSet, fluidWrapper, bcPres, - temp, + bcTemp, compFrac ); } ); @@ -1519,6 +1588,10 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::pressure::key() ); arrayView1d< real64 const > const dPres = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaPressure::key() ); + arrayView1d< real64 const > const temp = + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::temperature::key() ); + arrayView1d< real64 const > const dTemp = + subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::deltaTemperature::key() ); arrayView2d< real64 const, compflow::USD_COMP > const compDens = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::globalCompDensity::key() ); arrayView2d< real64 const, compflow::USD_COMP > const dCompDens = @@ -1526,6 +1599,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, arrayView2d< real64 const, multifluid::USD_FLUID > const totalDens = fluid.totalDensity(); integer const numComp = m_numComponents; + integer const isThermal = m_isThermal; forAll< parallelDevicePolicy<> >( targetSet.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) { localIndex const ei = targetSet[a]; @@ -1538,7 +1612,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, localIndex const localRow = dofIndex - rankOffset; real64 rhsValue; - // 3.1. Apply pressure value to the matrix/rhs + // 4.1. Apply pressure value to the matrix/rhs FieldSpecificationEqual::SpecifyFieldValue( dofIndex, rankOffset, localMatrix, @@ -1547,7 +1621,19 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, pres[ei] + dPres[ei] ); localRhs[localRow] = rhsValue; - // 3.2. For each component, apply target global density value + // 4.2. Apply temperature value to the matrix/rhs + if( isThermal ) + { + FieldSpecificationEqual::SpecifyFieldValue( dofIndex + numComp + 1, + rankOffset, + localMatrix, + rhsValue, + bcTemp[ei], + temp[ei] + dTemp[ei] ); + localRhs[localRow + numComp + 1] = rhsValue; + } + + // 4.3. For each component, apply target global density value for( integer ic = 0; ic < numComp; ++ic ) { FieldSpecificationEqual::SpecifyFieldValue( dofIndex + ic + 1, @@ -1638,7 +1724,7 @@ void CompositionalMultiphaseBase::resetStateToBeginningOfStep( DomainPartition & dPres.zero(); dCompDens.zero(); - if( m_thermalFlag ) + if( m_isThermal ) { arrayView1d< real64 > const & dTemp = subRegion.template getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); @@ -1693,7 +1779,7 @@ void CompositionalMultiphaseBase::implicitStepComplete( real64 const & time, } } ); - if( m_thermalFlag ) + if( m_isThermal ) { arrayView1d< real64 const > const dTemp = subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); @@ -1738,7 +1824,7 @@ void CompositionalMultiphaseBase::implicitStepComplete( real64 const & time, // Step 6: if the thermal option is on, send the converged porosity and phase volume fraction to the thermal conductivity model // note: this is needed because the phaseVolFrac-weighted thermal conductivity treats phaseVolumeFraction explicitly for now - if( m_thermalFlag ) + if( m_isThermal ) { arrayView2d< real64 const > const porosity = porousMaterial.getPorosity(); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp index cf9e767b2a7..fd87f9fb530 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp @@ -213,7 +213,7 @@ class CompositionalMultiphaseBase : public FlowSolverBase static constexpr char const * useMassFlagString() { return "useMass"; } - static constexpr char const * thermalFlagString() { return "thermalFlag"; } + static constexpr char const * isThermalString() { return "isThermal"; } static constexpr char const * computeCFLNumbersString() { return "computeCFLNumbers"; } @@ -338,7 +338,7 @@ class CompositionalMultiphaseBase : public FlowSolverBase integer m_capPressureFlag; /// flag to determine whether or not this is a thermal simulation - integer m_thermalFlag; + integer m_isThermal; /// maximum (absolute) change in a component fraction between two Newton iterations real64 m_maxCompFracChange; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp index 1851829c1be..301a95c985c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBaseExtrinsicData.hpp @@ -247,6 +247,15 @@ EXTRINSIC_MESH_DATA_TRAIT( bcPressure, WRITE_AND_READ, "Boundary condition pressure" ); +EXTRINSIC_MESH_DATA_TRAIT( bcTemperature, + "bcTemperature", + array1d< real64 >, + 0, + NOPLOT, + WRITE_AND_READ, + "Boundary temperature" ); + + } } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 7f67daeafe9..5c850c3c112 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -108,7 +108,7 @@ void CompositionalMultiphaseFVM::assembleFluxTerms( real64 const dt, { typename TYPEOFREF( stencil ) ::KernelWrapper stencilWrapper = stencil.createKernelWrapper(); - if( m_thermalFlag ) + if( m_isThermal ) { thermalCompositionalMultiphaseFVMKernels:: FaceBasedAssemblyKernelFactory:: @@ -339,7 +339,7 @@ real64 CompositionalMultiphaseFVM::calculateResidualNorm( DomainPartition const real64 subRegionFlowResidualNorm = 0.0; real64 subRegionEnergyResidualNorm = 0.0; - if( m_thermalFlag ) + if( m_isThermal ) { thermalCompositionalMultiphaseBaseKernels:: ResidualNormKernel:: @@ -377,7 +377,7 @@ real64 CompositionalMultiphaseFVM::calculateResidualNorm( DomainPartition const // compute global residual norms real64 residual = 0.0; - if( m_thermalFlag ) + if( m_isThermal ) { real64 const flowResidual = std::sqrt( MpiWrapper::sum( localFlowResidualNorm ) ); real64 const energyResidual = std::sqrt( MpiWrapper::sum( localEnergyResidualNorm ) ); @@ -568,7 +568,7 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaPressure::key() ); fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaGlobalCompDensity::key() ); - if( m_thermalFlag ) + if( m_isThermal ) { fieldNames["elems"].emplace_back( extrinsicMeshData::flow::deltaTemperature::key() ); } @@ -588,7 +588,7 @@ void CompositionalMultiphaseFVM::updatePhaseMobility( ObjectManagerBase & dataGr string const & relpermName = dataGroup.getReference< string >( viewKeyStruct::relPermNamesString() ); RelativePermeabilityBase const & relperm = getConstitutiveModel< RelativePermeabilityBase >( dataGroup, relpermName ); - if( m_thermalFlag ) + if( m_isThermal ) { thermalCompositionalMultiphaseFVMKernels:: PhaseMobilityKernelFactory:: diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp index f1cf6a48c4e..64eae60bced 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.hpp @@ -301,17 +301,6 @@ class CompositionalMultiphaseWell : public WellSolverBase virtual void initializePostInitialConditionsPreSubGroups() override; - /** - * @brief Checks constitutive models for consistency - * @param meshLevel reference to the mesh - * @param cm reference to the global constitutive model manager - * - * This function will produce an error if one of the well constitutive models - * (fluid, relperm) is incompatible with the corresponding models in reservoir - * regions connected to that particular well. - */ - // void validateConstitutiveModels( MeshLevel const & meshLevel, constitutive::ConstitutiveManager const & cm ) const; - /** * @brief Checks injection streams for validity (compositions sum to one) * @param meshLevel reference to the mesh From 2e694fd2d0e05db250a28c80de9d2f40c9419eaf Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Mon, 28 Feb 2022 10:37:04 -0800 Subject: [PATCH 26/34] removed unused variable --- .../physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 84b4046ca84..8c5a486c52b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -1512,7 +1512,7 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, "ElementRegions", extrinsicMeshData::flow::temperature::key(), [&]( FieldSpecificationBase const & fs, - string const & setName, + string const &, SortedArrayView< localIndex const > const & targetSet, Group & subRegion, string const & ) From d609aff1ef236a847b2778e44f4c220a9c29cecb Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Tue, 1 Mar 2022 23:50:30 -0800 Subject: [PATCH 27/34] various fixes --- .../constitutive/fluid/multiFluidSelector.hpp | 8 ++- .../solid/SolidInternalEnergy.cpp | 12 ++-- .../fluidFlow/CompositionalMultiphaseBase.cpp | 62 ++++++++++++++++--- .../fluidFlow/CompositionalMultiphaseBase.hpp | 18 ++++-- .../fluidFlow/CompositionalMultiphaseFVM.cpp | 13 +++- ...rmalCompositionalMultiphaseBaseKernels.hpp | 19 ++++++ ...ermalCompositionalMultiphaseFVMKernels.hpp | 14 ++--- .../docs/CompositionalMultiphaseFVM.rst | 2 +- .../docs/CompositionalMultiphaseHybridFVM.rst | 2 +- .../schema/docs/Constitutive.rst | 1 + .../schema/docs/Constitutive_other.rst | 1 + .../schema/docs/SolidInternalEnergy.rst | 12 ++++ .../schema/docs/SolidInternalEnergy_other.rst | 11 ++++ src/coreComponents/schema/schema.xsd | 19 ++++-- src/coreComponents/schema/schema.xsd.other | 9 +++ src/docs/sphinx/CompleteXMLSchema.rst | 14 +++++ 16 files changed, 182 insertions(+), 35 deletions(-) create mode 100644 src/coreComponents/schema/docs/SolidInternalEnergy.rst create mode 100644 src/coreComponents/schema/docs/SolidInternalEnergy_other.rst diff --git a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp index 96321059c35..aef78489012 100644 --- a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp @@ -44,7 +44,9 @@ void constitutiveUpdatePassThru( MultiFluidBase const & fluid, CompositionalMultiphaseFluid, #endif CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid >::execute( fluid, std::forward< LAMBDA >( lambda ) ); + CO2BrineEzrokhiFluid, + CO2BrinePhillipsThermalFluid, + CO2BrineEzrokhiThermalFluid >::execute( fluid, std::forward< LAMBDA >( lambda ) ); } template< typename LAMBDA > @@ -57,7 +59,9 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid, CompositionalMultiphaseFluid, #endif CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid >::execute( fluid, std::forward< LAMBDA >( lambda ) ); + CO2BrineEzrokhiFluid, + CO2BrinePhillipsThermalFluid, + CO2BrineEzrokhiThermalFluid >::execute( fluid, std::forward< LAMBDA >( lambda ) ); } } // namespace constitutive diff --git a/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp b/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp index 618574f28d3..d593611d9fe 100644 --- a/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp +++ b/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp @@ -48,15 +48,15 @@ SolidInternalEnergy::SolidInternalEnergy( string const & name, Group * const par setDescription( "Derivative of the solid internal energy w.r.t. temperature" ); registerWrapper( viewKeyStruct::specificHeatCapacityString(), &m_specificHeatCapacity ). - setApplyDefaultValue( 0.0 ). + setInputFlag( InputFlags::REQUIRED ). setDescription( "Solid specific heat capacity" ); registerWrapper( viewKeyStruct::referenceTemperatureString(), &m_referenceTemperature ). - setApplyDefaultValue( 0.0 ). + setInputFlag( InputFlags::REQUIRED ). setDescription( "Reference temperature" ); registerWrapper( viewKeyStruct::referenceInternalEnergyString(), &m_referenceInternalEnergy ). - setApplyDefaultValue( 0.0 ). + setInputFlag( InputFlags::REQUIRED ). setDescription( "Internal energy at the reference temperature" ); } @@ -81,6 +81,8 @@ void SolidInternalEnergy::saveConvergedState() const } ); } -} +REGISTER_CATALOG_ENTRY( ConstitutiveBase, SolidInternalEnergy, string const &, Group * const ) -} +} /* namespace constitutive */ + +} /* namespace geosx */ diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 8c5a486c52b..2770c7443fc 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -29,6 +29,7 @@ #include "constitutive/relativePermeability/RelativePermeabilityExtrinsicData.hpp" #include "constitutive/relativePermeability/relativePermeabilitySelector.hpp" #include "constitutive/solid/SolidBase.hpp" +#include "constitutive/solid/SolidInternalEnergy.hpp" #include "constitutive/thermalConductivity/thermalConductivitySelector.hpp" #include "constitutive/permeability/PermeabilityExtrinsicData.hpp" #include "fieldSpecification/AquiferBoundaryCondition.hpp" @@ -305,6 +306,18 @@ void CompositionalMultiphaseBase::setConstitutiveNames( ElementSubRegionBase & s if( m_isThermal ) { + string & solidInternalEnergyName = subRegion.registerWrapper< string >( viewKeyStruct::solidInternalEnergyNamesString() ). + setPlotLevel( PlotLevel::NOPLOT ). + setRestartFlags( RestartFlags::NO_WRITE ). + setSizedFromParent( 0 ). + setDescription( "Name of the solid internal energy constitutive model to use" ). + reference(); + + solidInternalEnergyName = getConstitutiveName< SolidInternalEnergy >( subRegion ); + GEOSX_THROW_IF( solidInternalEnergyName.empty(), + GEOSX_FMT( "Solid internal energy model not found on subregion {}", subRegion.getName() ), + InputError ); + string & thermalConductivityName = subRegion.registerWrapper< string >( viewKeyStruct::thermalConductivityNamesString() ). setPlotLevel( PlotLevel::NOPLOT ). setRestartFlags( RestartFlags::NO_WRITE ). @@ -313,8 +326,8 @@ void CompositionalMultiphaseBase::setConstitutiveNames( ElementSubRegionBase & s reference(); thermalConductivityName = getConstitutiveName< ThermalConductivityBase >( subRegion ); - GEOSX_THROW_IF( relPermName.empty(), - GEOSX_FMT( "Thermal Conductivity model not found on subregion {}", subRegion.getName() ), + GEOSX_THROW_IF( thermalConductivityName.empty(), + GEOSX_FMT( "Thermal conductivity model not found on subregion {}", subRegion.getName() ), InputError ); } } @@ -531,6 +544,29 @@ void CompositionalMultiphaseBase::updateCapPressureModel( ObjectManagerBase & da } } +void CompositionalMultiphaseBase::updateSolidInternalEnergyModel( ObjectManagerBase & dataGroup ) const +{ + if( m_isThermal ) + { + arrayView1d< real64 const > const temp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::temperature >(); + arrayView1d< real64 const > const dTemp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); + + string const & solidInternalEnergyName = dataGroup.getReference< string >( viewKeyStruct::solidInternalEnergyNamesString() ); + SolidInternalEnergy & solidInternalEnergy = getConstitutiveModel< SolidInternalEnergy >( dataGroup, solidInternalEnergyName ); + + SolidInternalEnergy::KernelWrapper solidInternalEnergyWrapper = solidInternalEnergy.createKernelUpdates(); + + // TODO: this should go somewhere, handle the case of flow in fracture, etc + + thermalCompositionalMultiphaseBaseKernels:: + SolidInternalEnergyUpdateKernel:: + launch< parallelDevicePolicy<> >( dataGroup.size(), + solidInternalEnergyWrapper, + temp, + dTemp ); + } +} + void CompositionalMultiphaseBase::updateFluidState( ObjectManagerBase & subRegion ) const { GEOSX_MARK_FUNCTION; @@ -657,12 +693,11 @@ void CompositionalMultiphaseBase::initializeFluidState( MeshLevel & mesh, // - This step depends phaseRelPerm updatePhaseMobility( subRegion ); - // 4.6 Finally, we initialize the thermal conductivity + // 4.6 Finally, we initialize the rock thermal quantities: conductivity and solid internal energy // // Note: // - This must be called after updatePorosityAndPermeability and updatePhaseVolumeFraction // - This step depends on porosity and phaseVolFraction - // - Energy balance is not supported yet, so the following flag is always false for now if( m_isThermal ) { // initialized porosity @@ -673,6 +708,13 @@ void CompositionalMultiphaseBase::initializeFluidState( MeshLevel & mesh, getConstitutiveModel< ThermalConductivityBase >( subRegion, thermalConductivityName ); conductivityMaterial.initializeRockFluidState( porosity, phaseVolFrac ); // note that there is nothing to update here because thermal conductivity is explicit for now + + updateSolidInternalEnergyModel( subRegion ); + string const & solidInternalEnergyName = subRegion.template getReference< string >( viewKeyStruct::solidInternalEnergyNamesString() ); + SolidInternalEnergy const & solidInternalEnergyMaterial = + getConstitutiveModel< SolidInternalEnergy >( subRegion, solidInternalEnergyName ); + solidInternalEnergyMaterial.saveConvergedState(); + } } ); @@ -1083,7 +1125,7 @@ void CompositionalMultiphaseBase::backupFields( MeshLevel & mesh, return; } - for( localIndex ip = 0; ip < numPhase; ++ip ) + for( integer ip = 0; ip < numPhase; ++ip ) { phaseInternalEnergyOld[ei][ip] = phaseInternalEnergy[ei][0][ip]; } @@ -1363,7 +1405,6 @@ bool validateDirichletBC( DomainPartition & domain, Group & subRegion, string const & ) { - string const & subRegionName = subRegion.getName(); string const & regionName = subRegion.getParent().getParent().getName(); @@ -1374,6 +1415,7 @@ bool validateDirichletBC( DomainPartition & domain, bcConsistent = false; GEOSX_WARNING( GEOSX_FMT( "Conflicting pressure boundary conditions on set {}/{}/{}", regionName, subRegionName, setName ) ); } + tempSubRegionSetMap.insert( setName ); // 2.2 Check that there is pressure bc applied to this set auto & presSubRegionSetMap = bcStatusMap[regionName][subRegionName]; @@ -1731,8 +1773,9 @@ void CompositionalMultiphaseBase::resetStateToBeginningOfStep( DomainPartition & dTemp.zero(); } - // update porosity and permeability + // update porosity, permeability, and solid internal energy updatePorosityAndPermeability( subRegion ); + updateSolidInternalEnergyModel( subRegion ); // update all fluid properties updateFluidState( subRegion ); } ); @@ -1773,7 +1816,7 @@ void CompositionalMultiphaseBase::implicitStepComplete( real64 const & time, forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { pres[ei] += dPres[ei]; - for( localIndex ic = 0; ic < numComp; ++ic ) + for( integer ic = 0; ic < numComp; ++ic ) { compDens[ei][ic] += dCompDens[ei][ic]; } @@ -1847,8 +1890,9 @@ void CompositionalMultiphaseBase::updateState( DomainPartition & domain ) SurfaceElementSubRegion >( regionNames, [&]( localIndex const, auto & subRegion ) { - // update porosity and permeability + // update porosity, permeability, and solid internal energy updatePorosityAndPermeability( subRegion ); + updateSolidInternalEnergyModel( subRegion ); // update all fluid properties updateFluidState( subRegion ); } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp index fd87f9fb530..0aadeee6b45 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp @@ -138,19 +138,25 @@ class CompositionalMultiphaseBase : public FlowSolverBase /** * @brief Update all relevant relperm models using current values of phase volume fraction - * @param castedRelPerm the group storing the required fields + * @param dataGroup the group storing the required fields */ - void updateRelPermModel( ObjectManagerBase & castedRelPerm ) const; + void updateRelPermModel( ObjectManagerBase & dataGroup ) const; /** * @brief Update all relevant capillary pressure models using current values of phase volume fraction - * @param castedCapPres the group storing the required fields + * @param dataGroup the group storing the required fields + */ + void updateCapPressureModel( ObjectManagerBase & dataGroup ) const; + + /** + * @brief Update all relevant solid internal energy models using current values of temperature + * @param dataGroup the group storing the required fields */ - void updateCapPressureModel( ObjectManagerBase & castedCapPres ) const; + void updateSolidInternalEnergyModel( ObjectManagerBase & dataGroup ) const; /** * @brief Recompute phase mobility from constitutive and primary variables - * @param domain the domain containing the mesh and fields + * @param dataGroup the group storing the required field */ virtual void updatePhaseMobility( ObjectManagerBase & dataGroup ) const = 0; @@ -223,6 +229,8 @@ class CompositionalMultiphaseBase : public FlowSolverBase static constexpr char const * thermalConductivityNamesString() { return "thermalConductivityNames"; } + static constexpr char const * solidInternalEnergyNamesString() { return "solidInternalEnergyNames"; } + static constexpr char const * maxCompFracChangeString() { return "maxCompFractionChange"; } static constexpr char const * allowLocalCompDensChoppingString() { return "allowLocalCompDensityChopping"; } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 5c850c3c112..35462f489d0 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -540,6 +540,7 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana GEOSX_MARK_FUNCTION; DofManager::CompMask pressureMask( m_numDofPerCell, 0, 1 ); + DofManager::CompMask componentMask( m_numDofPerCell, 1, m_numComponents ); dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), @@ -551,7 +552,17 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana viewKeyStruct::elemDofFieldString(), extrinsicMeshData::flow::deltaGlobalCompDensity::key(), scalingFactor, - ~pressureMask ); + componentMask ); + + if( m_isThermal ) + { + DofManager::CompMask temperatureMask( m_numDofPerCell, m_numComponents, m_numComponents+1 ); + dofManager.addVectorToField( localSolution, + viewKeyStruct::elemDofFieldString(), + extrinsicMeshData::flow::deltaTemperature::key(), + scalingFactor, + temperatureMask ); + } // if component density chopping is allowed, some component densities may be negative after the update // these negative component densities are set to zero in this function diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index 12e690c7d33..270d5fccb03 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -534,6 +534,25 @@ struct FluidUpdateKernel } }; +/******************************** SolidInternalEnergyUpdateKernel ********************************/ + +struct SolidInternalEnergyUpdateKernel +{ + + template< typename POLICY, typename SOLID_INTERNAL_ENERGY_WRAPPER > + static void + launch( localIndex const size, + SOLID_INTERNAL_ENERGY_WRAPPER const & solidInternalEnergyWrapper, + arrayView1d< real64 const > const & temp, + arrayView1d< real64 const > const & dTemp ) + { + forAll< POLICY >( size, [=] GEOSX_HOST_DEVICE ( localIndex const k ) + { + solidInternalEnergyWrapper.update( k, temp[k] + dTemp[k] ); + } ); + } +}; + /******************************** ResidualNormKernel ********************************/ struct ResidualNormKernel diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index 1abbe748d18..e0219f4c45c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -19,6 +19,7 @@ #ifndef GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEFVMKERNELS_HPP #define GEOSX_PHYSICSSOLVERS_FLUIDFLOW_THERMALCOMPOSITIONALMULTIPHASEFVMKERNELS_HPP +#include "constitutive/thermalConductivity/ThermalConductivityBase.hpp" #include "constitutive/thermalConductivity/ThermalConductivityExtrinsicData.hpp" #include "physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp" @@ -227,11 +228,13 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne extrinsicMeshData::flow::dPhaseVolumeFraction_dTemperature >; using ThermalMultiFluidAccessors = - StencilAccessors< extrinsicMeshData::multifluid::phaseEnthalpy, - extrinsicMeshData::multifluid::dPhaseEnthalpy >; + StencilMaterialAccessors< MultiFluidBase, + extrinsicMeshData::multifluid::phaseEnthalpy, + extrinsicMeshData::multifluid::dPhaseEnthalpy >; using ThermalConductivityAccessors = - StencilAccessors< extrinsicMeshData::thermalconductivity::effectiveConductivity >; + StencilMaterialAccessors< ThermalConductivityBase, + extrinsicMeshData::thermalconductivity::effectiveConductivity >; // for now, we treat thermal conductivity explicitly /** @@ -386,7 +389,6 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne dDensMean_dT[i] = 0.5 * dDens_dT; } - // Step 2: compute the derivatives of the phase potential difference wrt temperature //***** calculation of flux ***** @@ -422,7 +424,6 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne } } - // Step 3: compute the derivatives of the (upwinded) compFlux wrt temperature // *** upwinding *** @@ -495,7 +496,6 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne } } ); - // ***************************************************** // Computation of the conduction term in the energy flux // Note that this term is computed using an explicit treatment of conductivity for now @@ -544,7 +544,7 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne integer const localDofIndexPres = ke * numDof; stack.localFluxJacobian[localRowIndexEnergy][localDofIndexPres] = m_dt * stack.dEnergyFlux_dP[ke]; stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexPres] = -m_dt * stack.dEnergyFlux_dP[ke]; - integer const localDofIndexTemp = localDofIndexPres + numDof; + integer const localDofIndexTemp = localDofIndexPres + numDof - 1; stack.localFluxJacobian[localRowIndexEnergy][localDofIndexTemp] = m_dt * stack.dEnergyFlux_dT[ke]; stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexTemp] = -m_dt * stack.dEnergyFlux_dT[ke]; diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseFVM.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFVM.rst index 63d9fb54f87..ddbc407ff2b 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFVM.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFVM.rst @@ -9,12 +9,12 @@ computeCFLNumbers integer 0 Flag indicating whether CFL discretization string required Name of discretization object to use for this solver. initialDt real64 1e+99 Initial time-step value required by the solver to the event manager. inputFluxEstimate real64 1 Initial estimate of the input flux used only for residual scaling. This should be essentially equivalent to the input flux * dt. +isThermal integer 0 Flag indicating whether the problem is thermal or not. logLevel integer 0 Log level maxCompFractionChange real64 1 Maximum (absolute) change in a component fraction between two Newton iterations name string required A name is required for any non-unique nodes targetRegions string_array required Allowable regions that the solver may be applied to. Note that this does not indicate that the solver will be applied to these regions, only that allocation will occur such that the solver may be applied to these regions. The decision about what regions this solver will beapplied to rests in the EventManager. temperature real64 required Temperature -thermalFlag integer 0 Flag indicating whether the problem is thermal or not. useMass integer 0 Use mass formulation instead of molar LinearSolverParameters node unique :ref:`XML_LinearSolverParameters` NonlinearSolverParameters node unique :ref:`XML_NonlinearSolverParameters` diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM.rst index 6dc5a722e83..9ac6d8bda01 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM.rst @@ -9,13 +9,13 @@ computeCFLNumbers integer 0 Flag indicating whether CFL discretization string required Name of discretization object to use for this solver. initialDt real64 1e+99 Initial time-step value required by the solver to the event manager. inputFluxEstimate real64 1 Initial estimate of the input flux used only for residual scaling. This should be essentially equivalent to the input flux * dt. +isThermal integer 0 Flag indicating whether the problem is thermal or not. logLevel integer 0 Log level maxCompFractionChange real64 1 Maximum (absolute) change in a component fraction between two Newton iterations maxRelativePressureChange real64 1 Maximum (relative) change in (face) pressure between two Newton iterations name string required A name is required for any non-unique nodes targetRegions string_array required Allowable regions that the solver may be applied to. Note that this does not indicate that the solver will be applied to these regions, only that allocation will occur such that the solver may be applied to these regions. The decision about what regions this solver will beapplied to rests in the EventManager. temperature real64 required Temperature -thermalFlag integer 0 Flag indicating whether the problem is thermal or not. useMass integer 0 Use mass formulation instead of molar LinearSolverParameters node unique :ref:`XML_LinearSolverParameters` NonlinearSolverParameters node unique :ref:`XML_NonlinearSolverParameters` diff --git a/src/coreComponents/schema/docs/Constitutive.rst b/src/coreComponents/schema/docs/Constitutive.rst index 6fa3cfd19db..cee410140ac 100644 --- a/src/coreComponents/schema/docs/Constitutive.rst +++ b/src/coreComponents/schema/docs/Constitutive.rst @@ -51,6 +51,7 @@ ProppantPorosity node :ref:`XML_ProppantPoros ProppantSlurryFluid node :ref:`XML_ProppantSlurryFluid` ProppantSolidProppantPermeability node :ref:`XML_ProppantSolidProppantPermeability` SlipDependentPermeability node :ref:`XML_SlipDependentPermeability` +SolidInternalEnergy node :ref:`XML_SolidInternalEnergy` TableCapillaryPressure node :ref:`XML_TableCapillaryPressure` TableRelativePermeability node :ref:`XML_TableRelativePermeability` TableRelativePermeabilityHysteresis node :ref:`XML_TableRelativePermeabilityHysteresis` diff --git a/src/coreComponents/schema/docs/Constitutive_other.rst b/src/coreComponents/schema/docs/Constitutive_other.rst index 2ca2f51060a..68a9ddde2d0 100644 --- a/src/coreComponents/schema/docs/Constitutive_other.rst +++ b/src/coreComponents/schema/docs/Constitutive_other.rst @@ -51,6 +51,7 @@ ProppantPorosity node :ref:`DATASTRUCTURE_ProppantPor ProppantSlurryFluid node :ref:`DATASTRUCTURE_ProppantSlurryFluid` ProppantSolidProppantPermeability node :ref:`DATASTRUCTURE_ProppantSolidProppantPermeability` SlipDependentPermeability node :ref:`DATASTRUCTURE_SlipDependentPermeability` +SolidInternalEnergy node :ref:`DATASTRUCTURE_SolidInternalEnergy` TableCapillaryPressure node :ref:`DATASTRUCTURE_TableCapillaryPressure` TableRelativePermeability node :ref:`DATASTRUCTURE_TableRelativePermeability` TableRelativePermeabilityHysteresis node :ref:`DATASTRUCTURE_TableRelativePermeabilityHysteresis` diff --git a/src/coreComponents/schema/docs/SolidInternalEnergy.rst b/src/coreComponents/schema/docs/SolidInternalEnergy.rst new file mode 100644 index 00000000000..623cdbe96cb --- /dev/null +++ b/src/coreComponents/schema/docs/SolidInternalEnergy.rst @@ -0,0 +1,12 @@ + + +======================= ====== ======== ============================================ +Name Type Default Description +======================= ====== ======== ============================================ +name string required A name is required for any non-unique nodes +referenceInternalEnergy real64 required Internal energy at the reference temperature +referenceTemperature real64 required Reference temperature +specificHeatCapacity real64 required Solid specific heat capacity +======================= ====== ======== ============================================ + + diff --git a/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst b/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst new file mode 100644 index 00000000000..7c5982d4de7 --- /dev/null +++ b/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst @@ -0,0 +1,11 @@ + + +============================ ============== ========================================================== +Name Type Description +============================ ============== ========================================================== +dInternalEnergy_dTemperature real64_array2d Derivative of the solid internal energy w.r.t. temperature +internalEnergy real64_array2d Internal energy of the solid +oldInternalEnergy real64_array2d Internal energy of the solid at the previous time-step +============================ ============== ========================================================== + + diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index b2d940ff58d..578043960f0 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -1120,6 +1120,8 @@ the relative residual norm satisfies: + + @@ -1128,8 +1130,6 @@ the relative residual norm satisfies: - - @@ -1152,6 +1152,8 @@ the relative residual norm satisfies: + + @@ -1162,8 +1164,6 @@ the relative residual norm satisfies: - - @@ -1896,6 +1896,7 @@ Equal to 1 for surface conditions, and to 0 for reservoir conditions--> + @@ -2703,6 +2704,16 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia + + + + + + + + + + + + + + + + + + diff --git a/src/docs/sphinx/CompleteXMLSchema.rst b/src/docs/sphinx/CompleteXMLSchema.rst index 03a6fe10490..d8f086217b0 100644 --- a/src/docs/sphinx/CompleteXMLSchema.rst +++ b/src/docs/sphinx/CompleteXMLSchema.rst @@ -813,6 +813,13 @@ Element: SlipDependentPermeability .. include:: ../../coreComponents/schema/docs/SlipDependentPermeability.rst +.. _XML_SolidInternalEnergy: + +Element: SolidInternalEnergy +============================ +.. include:: ../../coreComponents/schema/docs/SolidInternalEnergy.rst + + .. _XML_SolidMechanicsEmbeddedFractures: Element: SolidMechanicsEmbeddedFractures @@ -1846,6 +1853,13 @@ Datastructure: SlipDependentPermeability .. include:: ../../coreComponents/schema/docs/SlipDependentPermeability_other.rst +.. _DATASTRUCTURE_SolidInternalEnergy: + +Datastructure: SolidInternalEnergy +================================== +.. include:: ../../coreComponents/schema/docs/SolidInternalEnergy_other.rst + + .. _DATASTRUCTURE_SolidMechanicsEmbeddedFractures: Datastructure: SolidMechanicsEmbeddedFractures From f0d3e9a623a6ca7f2d5446764b7e00716cbfd909 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 2 Mar 2022 20:01:40 -0800 Subject: [PATCH 28/34] first working version --- .../constitutive/fluid/multiFluidSelector.hpp | 8 ++-- .../solid/SolidInternalEnergy.cpp | 16 +++---- .../solid/SolidInternalEnergy.hpp | 20 ++++----- .../ConstantThermalConductivity.cpp | 2 +- .../fluidFlow/CompositionalMultiphaseBase.cpp | 2 - .../fluidFlow/CompositionalMultiphaseFVM.cpp | 28 +++++++++--- ...rmalCompositionalMultiphaseBaseKernels.hpp | 1 + ...ermalCompositionalMultiphaseFVMKernels.hpp | 16 +++---- ...rmalCompositionalMultiphaseBaseKernels.hpp | 45 ++++++++++++------- ...ermalCompositionalMultiphaseFVMKernels.hpp | 16 +++---- .../docs/ConstantThermalConductivity.rst | 14 +++--- .../schema/docs/SolidInternalEnergy.rst | 16 +++---- .../schema/docs/SolidInternalEnergy_other.rst | 14 +++--- src/coreComponents/schema/schema.xsd | 10 ++--- src/coreComponents/schema/schema.xsd.other | 6 +-- 15 files changed, 120 insertions(+), 94 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp index aef78489012..dbd298bb035 100644 --- a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp @@ -44,9 +44,9 @@ void constitutiveUpdatePassThru( MultiFluidBase const & fluid, CompositionalMultiphaseFluid, #endif CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid, + CO2BrineEzrokhiFluid/*, CO2BrinePhillipsThermalFluid, - CO2BrineEzrokhiThermalFluid >::execute( fluid, std::forward< LAMBDA >( lambda ) ); + CO2BrineEzrokhiThermalFluid*/ >::execute( fluid, std::forward< LAMBDA >( lambda ) ); } template< typename LAMBDA > @@ -59,9 +59,9 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid, CompositionalMultiphaseFluid, #endif CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid, + CO2BrineEzrokhiFluid/*, CO2BrinePhillipsThermalFluid, - CO2BrineEzrokhiThermalFluid >::execute( fluid, std::forward< LAMBDA >( lambda ) ); + CO2BrineEzrokhiThermalFluid*/ >::execute( fluid, std::forward< LAMBDA >( lambda ) ); } } // namespace constitutive diff --git a/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp b/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp index d593611d9fe..add71a381c9 100644 --- a/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp +++ b/src/coreComponents/constitutive/solid/SolidInternalEnergy.cpp @@ -30,34 +30,34 @@ SolidInternalEnergy::SolidInternalEnergy( string const & name, Group * const par ConstitutiveBase( name, parent ), m_internalEnergy(), m_dInternalEnergy_dTemperature(), - m_specificHeatCapacity(), + m_volumetricHeatCapacity(), m_referenceTemperature(), m_referenceInternalEnergy() { registerWrapper( viewKeyStruct::internalEnergyString(), &m_internalEnergy ). setPlotLevel( PlotLevel::LEVEL_0 ). setApplyDefaultValue( 0.0 ). - setDescription( "Internal energy of the solid" ); + setDescription( "Internal energy of the solid per unit volume [J/m^3]" ); registerWrapper( viewKeyStruct::oldInternalEnergyString(), &m_oldInternalEnergy ). setApplyDefaultValue( 0.0 ). - setDescription( "Internal energy of the solid at the previous time-step" ); + setDescription( "Internal energy of the solid per unit volume at the previous time-step [J/m^3]" ); registerWrapper( viewKeyStruct::dInternalEnergy_dTemperatureString(), &m_dInternalEnergy_dTemperature ). setApplyDefaultValue( 0.0 ). - setDescription( "Derivative of the solid internal energy w.r.t. temperature" ); + setDescription( "Derivative of the solid internal energy w.r.t. temperature [J/(m^3.K)]" ); - registerWrapper( viewKeyStruct::specificHeatCapacityString(), &m_specificHeatCapacity ). + registerWrapper( viewKeyStruct::volumetricHeatCapacityString(), &m_volumetricHeatCapacity ). setInputFlag( InputFlags::REQUIRED ). - setDescription( "Solid specific heat capacity" ); + setDescription( "Solid volumetric heat capacity [J/(kg.K)]" ); registerWrapper( viewKeyStruct::referenceTemperatureString(), &m_referenceTemperature ). setInputFlag( InputFlags::REQUIRED ). - setDescription( "Reference temperature" ); + setDescription( "Reference temperature [K]" ); registerWrapper( viewKeyStruct::referenceInternalEnergyString(), &m_referenceInternalEnergy ). setInputFlag( InputFlags::REQUIRED ). - setDescription( "Internal energy at the reference temperature" ); + setDescription( "Internal energy at the reference temperature [J/kg]" ); } void SolidInternalEnergy::allocateConstitutiveData( Group & parent, diff --git a/src/coreComponents/constitutive/solid/SolidInternalEnergy.hpp b/src/coreComponents/constitutive/solid/SolidInternalEnergy.hpp index aff61795562..ada374344bd 100644 --- a/src/coreComponents/constitutive/solid/SolidInternalEnergy.hpp +++ b/src/coreComponents/constitutive/solid/SolidInternalEnergy.hpp @@ -35,12 +35,12 @@ class SolidInternalEnergyUpdates SolidInternalEnergyUpdates( arrayView2d< real64 > const & internalEnergy, arrayView2d< real64 > const & dInternalEnergy_dTemperature, - real64 const & specificHeatCapacity, + real64 const & volumetricHeatCapacity, real64 const & referenceTemperature, real64 const & referenceInternalEnergy ): m_internalEnergy( internalEnergy ), m_dInternalEnergy_dTemperature( dInternalEnergy_dTemperature ), - m_specificHeatCapacity( specificHeatCapacity ), + m_volumetricHeatCapacity( volumetricHeatCapacity ), m_referenceTemperature( referenceTemperature ), m_referenceInternalEnergy( referenceInternalEnergy ) {} @@ -59,8 +59,8 @@ class SolidInternalEnergyUpdates real64 & internalEnergy, real64 & dInternalEnergy_dTemperature ) const { - internalEnergy = m_referenceInternalEnergy + m_specificHeatCapacity * ( temperature - m_referenceTemperature ); - dInternalEnergy_dTemperature = m_specificHeatCapacity; + internalEnergy = m_referenceInternalEnergy + m_volumetricHeatCapacity * ( temperature - m_referenceTemperature ); + dInternalEnergy_dTemperature = m_volumetricHeatCapacity; } private: @@ -71,8 +71,8 @@ class SolidInternalEnergyUpdates /// Derivative of the solid internal energy w.r.t. the temperature arrayView2d< real64 > m_dInternalEnergy_dTemperature; - /// Solid specific heat capacity - real64 m_specificHeatCapacity; + /// Solid volumetric heat capacity + real64 m_volumetricHeatCapacity; /// Reference temperature real64 m_referenceTemperature; @@ -99,7 +99,7 @@ class SolidInternalEnergy : public ConstitutiveBase static constexpr char const * internalEnergyString() { return "internalEnergy"; } static constexpr char const * oldInternalEnergyString() { return "oldInternalEnergy"; } static constexpr char const * dInternalEnergy_dTemperatureString() { return "dInternalEnergy_dTemperature"; } - static constexpr char const * specificHeatCapacityString() { return "specificHeatCapacity"; } + static constexpr char const * volumetricHeatCapacityString() { return "volumetricHeatCapacity"; } static constexpr char const * referenceTemperatureString() { return "referenceTemperature"; } static constexpr char const * referenceInternalEnergyString() { return "referenceInternalEnergy"; } } viewKeys; @@ -114,7 +114,7 @@ class SolidInternalEnergy : public ConstitutiveBase { return KernelWrapper( m_internalEnergy, m_dInternalEnergy_dTemperature, - m_specificHeatCapacity, + m_volumetricHeatCapacity, m_referenceTemperature, m_referenceInternalEnergy ); } @@ -152,8 +152,8 @@ class SolidInternalEnergy : public ConstitutiveBase /// Derivative of the solid internal energy w.r.t. the temperature array2d< real64 > m_dInternalEnergy_dTemperature; - /// Solid specific heat capacity - real64 m_specificHeatCapacity; + /// Solid volumetric heat capacity + real64 m_volumetricHeatCapacity; /// Reference temperature real64 m_referenceTemperature; diff --git a/src/coreComponents/constitutive/thermalConductivity/ConstantThermalConductivity.cpp b/src/coreComponents/constitutive/thermalConductivity/ConstantThermalConductivity.cpp index 2170d1dff33..11fd59865a0 100644 --- a/src/coreComponents/constitutive/thermalConductivity/ConstantThermalConductivity.cpp +++ b/src/coreComponents/constitutive/thermalConductivity/ConstantThermalConductivity.cpp @@ -32,7 +32,7 @@ ConstantThermalConductivity::ConstantThermalConductivity( string const & name, G registerWrapper( viewKeyStruct::thermalConductivityComponentsString(), &m_thermalConductivityComponents ). setInputFlag( InputFlags::REQUIRED ). setRestartFlags( RestartFlags::NO_WRITE ). - setDescription( "xx, yy, and zz components of a diagonal thermal conductivity tensor [W/(m.K)]" ); + setDescription( "xx, yy, and zz components of a diagonal thermal conductivity tensor [J/(s.m.K)]" ); } std::unique_ptr< ConstitutiveBase > diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index f6bf40eddb7..225183ba64b 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -1231,8 +1231,6 @@ void CompositionalMultiphaseBase::assembleSystem( real64 const GEOSX_UNUSED_PARA dofManager, localMatrix, localRhs ); - - } void CompositionalMultiphaseBase::assembleAccumulationAndVolumeBalanceTerms( DomainPartition & domain, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 8d97a366058..b689954e046 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -327,31 +327,47 @@ real64 CompositionalMultiphaseFVM::calculateResidualNorm( DomainPartition const { arrayView1d< globalIndex const > dofNumber = subRegion.getReference< array1d< globalIndex > >( dofKey ); - arrayView1d< integer const > const & elemGhostRank = subRegion.ghostRank(); - arrayView1d< real64 const > const & volume = subRegion.getElementVolume(); - arrayView1d< real64 const > const & totalDensOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::totalDensityOld >(); + arrayView1d< integer const > const elemGhostRank = subRegion.ghostRank(); + arrayView1d< real64 const > const volume = subRegion.getElementVolume(); + arrayView1d< real64 const > const totalDensOld = subRegion.getExtrinsicData< extrinsicMeshData::flow::totalDensityOld >(); string const & solidName = subRegion.getReference< string >( viewKeyStruct::solidNamesString() ); CoupledSolidBase const & solidModel = getConstitutiveModel< CoupledSolidBase >( subRegion, solidName ); - arrayView1d< real64 const > const & referencePorosity = solidModel.getReferencePorosity(); + arrayView1d< real64 const > const referencePorosity = solidModel.getReferencePorosity(); real64 subRegionFlowResidualNorm = 0.0; real64 subRegionEnergyResidualNorm = 0.0; if( m_isThermal ) { + arrayView2d< real64 const, compflow::USD_PHASE > const phaseDensOld = + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseDensityOld >(); + arrayView2d< real64 const, compflow::USD_PHASE > const phaseVolFracOld = + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseVolumeFractionOld >(); + arrayView2d< real64 const, compflow::USD_PHASE > const phaseInternalEnergyOld = + subRegion.getExtrinsicData< extrinsicMeshData::flow::phaseInternalEnergyOld >(); + + string const & solidInternalEnergyName = subRegion.getReference< string >( viewKeyStruct::solidInternalEnergyNamesString() ); + SolidInternalEnergy const & solidInternalEnergy = getConstitutiveModel< SolidInternalEnergy >( subRegion, solidInternalEnergyName ); + arrayView2d< real64 const > const solidInternalEnergyOld = solidInternalEnergy.getOldInternalEnergy(); + thermalCompositionalMultiphaseBaseKernels:: ResidualNormKernel:: launch< parallelDevicePolicy<>, parallelDeviceReduce >( localRhs, rankOffset, + numFluidPhases(), numFluidComponents(), dofNumber, elemGhostRank, referencePorosity, volume, + solidInternalEnergyOld, totalDensOld, + phaseDensOld, + phaseVolFracOld, + phaseInternalEnergyOld, subRegionFlowResidualNorm, subRegionEnergyResidualNorm ); } @@ -540,7 +556,7 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana GEOSX_MARK_FUNCTION; DofManager::CompMask pressureMask( m_numDofPerCell, 0, 1 ); - DofManager::CompMask componentMask( m_numDofPerCell, 1, m_numComponents ); + DofManager::CompMask componentMask( m_numDofPerCell, 1, m_numComponents+1 ); dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), @@ -556,7 +572,7 @@ void CompositionalMultiphaseFVM::applySystemSolution( DofManager const & dofMana if( m_isThermal ) { - DofManager::CompMask temperatureMask( m_numDofPerCell, m_numComponents, m_numComponents+1 ); + DofManager::CompMask temperatureMask( m_numDofPerCell, m_numComponents+1, m_numComponents+2 ); dofManager.addVectorToField( localSolution, viewKeyStruct::elemDofFieldString(), extrinsicMeshData::flow::deltaTemperature::key(), diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp index 9fd960b76a9..2d0641378d3 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp @@ -720,6 +720,7 @@ class ElementBasedAssemblyKernel + phaseCompFrac[ip][ic] * dPhaseAmount_dC[jc]; stack.localJacobian[ic][jc + 1] += dPhaseCompAmount_dC; } + } // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index 857c2171fb4..e7576461b24 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -817,20 +817,20 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase // populate local flux vector and derivatives for( integer ic = 0; ic < numComp; ++ic ) { - stack.localFlux[ic] = m_dt * stack.compFlux[ic]; - stack.localFlux[numComp + ic] = -m_dt * stack.compFlux[ic]; + stack.localFlux[ic] = m_dt * stack.compFlux[ic]; + stack.localFlux[numEqn + ic] = -m_dt * stack.compFlux[ic]; for( integer ke = 0; ke < stack.stencilSize; ++ke ) { localIndex const localDofIndexPres = ke * numDof; - stack.localFluxJacobian[ic][localDofIndexPres] = m_dt * stack.dCompFlux_dP[ke][ic]; - stack.localFluxJacobian[numComp + ic][localDofIndexPres] = -m_dt * stack.dCompFlux_dP[ke][ic]; + stack.localFluxJacobian[ic][localDofIndexPres] = m_dt * stack.dCompFlux_dP[ke][ic]; + stack.localFluxJacobian[numEqn + ic][localDofIndexPres] = -m_dt * stack.dCompFlux_dP[ke][ic]; for( integer jc = 0; jc < numComp; ++jc ) { localIndex const localDofIndexComp = localDofIndexPres + jc + 1; - stack.localFluxJacobian[ic][localDofIndexComp] = m_dt * stack.dCompFlux_dC[ke][ic][jc]; - stack.localFluxJacobian[numComp + ic][localDofIndexComp] = -m_dt * stack.dCompFlux_dC[ke][ic][jc]; + stack.localFluxJacobian[ic][localDofIndexComp] = m_dt * stack.dCompFlux_dC[ke][ic][jc]; + stack.localFluxJacobian[numEqn + ic][localDofIndexComp] = -m_dt * stack.dCompFlux_dC[ke][ic][jc]; } } } @@ -868,11 +868,11 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase for( integer ic = 0; ic < numComp; ++ic ) { - RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[localRow + ic], stack.localFlux[i * numComp + ic] ); + RAJA::atomicAdd( parallelDeviceAtomic{}, &m_localRhs[localRow + ic], stack.localFlux[i * numEqn + ic] ); m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic > ( localRow + ic, stack.dofColIndices.data(), - stack.localFluxJacobian[i * numComp + ic].dataIfContiguous(), + stack.localFluxJacobian[i * numEqn + ic].dataIfContiguous(), stack.stencilSize * numDof ); } } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index 270d5fccb03..af0bc73aa87 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -206,8 +206,7 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK m_dPhaseInternalEnergy( fluid.dPhaseInternalEnergy() ), m_rockInternalEnergyOld( solid.getOldInternalEnergy() ), m_rockInternalEnergy( solid.getInternalEnergy() ), - m_dRockInternalEnergy_dTemp( solid.getDinternalEnergy_dTemperature() ), - m_rockDensity( solid.getDensity() ) + m_dRockInternalEnergy_dTemp( solid.getDinternalEnergy_dTemperature() ) {} struct StackVariables : public Base::StackVariables @@ -260,10 +259,10 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK real64 const dSolidVolume_dPres = -m_volume[ei] * m_dPoro_dPres[ei][0]; // initialize the solid internal energy - stack.solidEnergyNew = solidVolumeNew * m_rockInternalEnergy[ei][0] * m_rockDensity[ei][0]; - stack.solidEnergyOld = solidVolumeOld * m_rockInternalEnergyOld[ei][0] * m_rockDensity[ei][0]; - stack.dSolidEnergy_dPres = dSolidVolume_dPres * m_rockInternalEnergy[ei][0] * m_rockDensity[ei][0]; - stack.dSolidEnergy_dTemp = solidVolumeNew * m_dRockInternalEnergy_dTemp[ei][0] * m_rockDensity[ei][0]; + stack.solidEnergyNew = solidVolumeNew * m_rockInternalEnergy[ei][0]; + stack.solidEnergyOld = solidVolumeOld * m_rockInternalEnergyOld[ei][0]; + stack.dSolidEnergy_dPres = dSolidVolume_dPres * m_rockInternalEnergy[ei][0]; + stack.dSolidEnergy_dTemp = solidVolumeNew * m_dRockInternalEnergy_dTemp[ei][0]; } /** @@ -326,7 +325,7 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK + phaseAmountNew * dPhaseInternalEnergy[ip][Deriv::dT]; // local accumulation - localResidualPtr[numEqn-1] = phaseEnergyNew - phaseEnergyOld; + localResidualPtr[numEqn-1] += phaseEnergyNew - phaseEnergyOld; // derivatives w.r.t. pressure and temperature localJacobianPtr[numEqn-1][0] += dPhaseEnergy_dP; @@ -347,6 +346,7 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK stack.localResidual[numEqn-1] += stack.solidEnergyNew - stack.solidEnergyOld; stack.localJacobian[numEqn-1][0] += stack.dSolidEnergy_dPres; stack.localJacobian[numEqn-1][numDof-1] += stack.dSolidEnergy_dTemp; + } /** @@ -382,10 +382,10 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK Base::complete( ei, stack ); // Step 2: assemble the energy equation - m_localRhs[stack.localRow + numDof-1] += stack.localResidual[numDof-1]; - m_localMatrix.template addToRow< serialAtomic >( stack.localRow + numDof-1, + m_localRhs[stack.localRow + numEqn-1] += stack.localResidual[numEqn-1]; + m_localMatrix.template addToRow< serialAtomic >( stack.localRow + numEqn-1, stack.dofIndices, - stack.localJacobian[numDof-1], + stack.localJacobian[numEqn-1], numDof ); } @@ -404,9 +404,6 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK arrayView2d< real64 const > m_rockInternalEnergy; arrayView2d< real64 const > m_dRockInternalEnergy_dTemp; - /// View on rock density - arrayView2d< real64 const > m_rockDensity; - }; /** @@ -561,12 +558,17 @@ struct ResidualNormKernel template< typename POLICY, typename REDUCE_POLICY > static void launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, - localIndex const numComponents, + integer const numComponents, + integer const numPhases, arrayView1d< globalIndex const > const & dofNumber, arrayView1d< integer const > const & ghostRank, arrayView1d< real64 const > const & refPoro, arrayView1d< real64 const > const & volume, + arrayView2d< real64 const > const & solidInternalEnergyOld, arrayView1d< real64 const > const & totalDensOld, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseDensOld, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseVolFracOld, + arrayView2d< real64 const, compflow::USD_PHASE > const & phaseInternalEnergyOld, real64 & localFlowResidualNorm, real64 & localEnergyResidualNorm ) { @@ -578,10 +580,19 @@ struct ResidualNormKernel if( ghostRank[ei] < 0 ) { localIndex const localRow = dofNumber[ei] - rankOffset; - real64 const flowNormalizer = totalDensOld[ei] * refPoro[ei] * volume[ei]; - real64 const energyNormalizer = 1.0; // TODO: find a good value for that - for( localIndex idof = 0; idof < numComponents + 1; ++idof ) + // first, compute the normalizers for the component mass balance and energy balance equations + // TODO: apply a separate treatment to the volume balance equation + real64 const poreVolume = refPoro[ei] * volume[ei]; + real64 const flowNormalizer = totalDensOld[ei] * poreVolume; + real64 energyNormalizer = solidInternalEnergyOld[ei][0] * ( 1.0 - refPoro[ei] ) * volume[ei]; + for( integer ip = 0; ip < numPhases; ++ip ) + { + energyNormalizer += phaseInternalEnergyOld[ei][ip] * phaseDensOld[ei][ip] * phaseVolFracOld[ei][ip] * poreVolume; + } + + // then, compute the normalized residual + for( integer idof = 0; idof < numComponents + 1; ++idof ) { real64 const val = localResidual[localRow + idof] / flowNormalizer; localFlowSum += val * val; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index fc16f52ebc0..f67ad88ea77 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -536,23 +536,23 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne // Step 2: add energyFlux and its derivatives to localFlux and localFluxJacobian integer const localRowIndexEnergy = numEqn-1; - stack.localFlux[localRowIndexEnergy] = m_dt * stack.energyFlux; - stack.localFlux[2 * localRowIndexEnergy] = -m_dt * stack.energyFlux; + stack.localFlux[localRowIndexEnergy] = m_dt * stack.energyFlux; + stack.localFlux[numEqn + localRowIndexEnergy] = -m_dt * stack.energyFlux; for( integer ke = 0; ke < stack.stencilSize; ++ke ) { integer const localDofIndexPres = ke * numDof; - stack.localFluxJacobian[localRowIndexEnergy][localDofIndexPres] = m_dt * stack.dEnergyFlux_dP[ke]; - stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexPres] = -m_dt * stack.dEnergyFlux_dP[ke]; + stack.localFluxJacobian[localRowIndexEnergy][localDofIndexPres] = m_dt * stack.dEnergyFlux_dP[ke]; + stack.localFluxJacobian[numEqn + localRowIndexEnergy][localDofIndexPres] = -m_dt * stack.dEnergyFlux_dP[ke]; integer const localDofIndexTemp = localDofIndexPres + numDof - 1; - stack.localFluxJacobian[localRowIndexEnergy][localDofIndexTemp] = m_dt * stack.dEnergyFlux_dT[ke]; - stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexTemp] = -m_dt * stack.dEnergyFlux_dT[ke]; + stack.localFluxJacobian[localRowIndexEnergy][localDofIndexTemp] = m_dt * stack.dEnergyFlux_dT[ke]; + stack.localFluxJacobian[numEqn + localRowIndexEnergy][localDofIndexTemp] = -m_dt * stack.dEnergyFlux_dT[ke]; for( integer jc = 0; jc < numComp; ++jc ) { integer const localDofIndexComp = localDofIndexPres + jc + 1; - stack.localFluxJacobian[localRowIndexEnergy][localDofIndexComp] = m_dt * stack.dEnergyFlux_dC[ke][jc]; - stack.localFluxJacobian[2 * localRowIndexEnergy][localDofIndexComp] = -m_dt * stack.dEnergyFlux_dC[ke][jc]; + stack.localFluxJacobian[localRowIndexEnergy][localDofIndexComp] = m_dt * stack.dEnergyFlux_dC[ke][jc]; + stack.localFluxJacobian[numEqn + localRowIndexEnergy][localDofIndexComp] = -m_dt * stack.dEnergyFlux_dC[ke][jc]; } } } diff --git a/src/coreComponents/schema/docs/ConstantThermalConductivity.rst b/src/coreComponents/schema/docs/ConstantThermalConductivity.rst index f3c7c40593e..a3d9cd2129f 100644 --- a/src/coreComponents/schema/docs/ConstantThermalConductivity.rst +++ b/src/coreComponents/schema/docs/ConstantThermalConductivity.rst @@ -1,11 +1,11 @@ -============================= ============ ======== ============================================================================= -Name Type Default Description -============================= ============ ======== ============================================================================= -name string required A name is required for any non-unique nodes -phaseNames string_array required List of fluid phases -thermalConductivityComponents R1Tensor required xx, yy, and zz components of a diagonal thermal conductivity tensor [W/(m.K)] -============================= ============ ======== ============================================================================= +============================= ============ ======== =============================================================================== +Name Type Default Description +============================= ============ ======== =============================================================================== +name string required A name is required for any non-unique nodes +phaseNames string_array required List of fluid phases +thermalConductivityComponents R1Tensor required xx, yy, and zz components of a diagonal thermal conductivity tensor [J/(s.m.K)] +============================= ============ ======== =============================================================================== diff --git a/src/coreComponents/schema/docs/SolidInternalEnergy.rst b/src/coreComponents/schema/docs/SolidInternalEnergy.rst index 623cdbe96cb..32cad1e4e49 100644 --- a/src/coreComponents/schema/docs/SolidInternalEnergy.rst +++ b/src/coreComponents/schema/docs/SolidInternalEnergy.rst @@ -1,12 +1,12 @@ -======================= ====== ======== ============================================ -Name Type Default Description -======================= ====== ======== ============================================ -name string required A name is required for any non-unique nodes -referenceInternalEnergy real64 required Internal energy at the reference temperature -referenceTemperature real64 required Reference temperature -specificHeatCapacity real64 required Solid specific heat capacity -======================= ====== ======== ============================================ +======================= ====== ======== =================================================== +Name Type Default Description +======================= ====== ======== =================================================== +name string required A name is required for any non-unique nodes +referenceInternalEnergy real64 required Internal energy at the reference temperature [J/kg] +referenceTemperature real64 required Reference temperature [K] +volumetricHeatCapacity real64 required Solid volumetric heat capacity [J/(kg.K)] +======================= ====== ======== =================================================== diff --git a/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst b/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst index 7c5982d4de7..e245ee67a7a 100644 --- a/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst +++ b/src/coreComponents/schema/docs/SolidInternalEnergy_other.rst @@ -1,11 +1,11 @@ -============================ ============== ========================================================== -Name Type Description -============================ ============== ========================================================== -dInternalEnergy_dTemperature real64_array2d Derivative of the solid internal energy w.r.t. temperature -internalEnergy real64_array2d Internal energy of the solid -oldInternalEnergy real64_array2d Internal energy of the solid at the previous time-step -============================ ============== ========================================================== +============================ ============== ============================================================================== +Name Type Description +============================ ============== ============================================================================== +dInternalEnergy_dTemperature real64_array2d Derivative of the solid internal energy w.r.t. temperature [J/(m^3.K)] +internalEnergy real64_array2d Internal energy of the solid per unit volume [J/m^3] +oldInternalEnergy real64_array2d Internal energy of the solid per unit volume at the previous time-step [J/m^3] +============================ ============== ============================================================================== diff --git a/src/coreComponents/schema/schema.xsd b/src/coreComponents/schema/schema.xsd index 578043960f0..54a4e4cc119 100644 --- a/src/coreComponents/schema/schema.xsd +++ b/src/coreComponents/schema/schema.xsd @@ -2165,7 +2165,7 @@ The expected format is "{ waterMax, oilMax }", in that order--> - + @@ -2705,12 +2705,12 @@ If you want to do a three-phase simulation, please use instead wettingIntermedia - + - + - - + + diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index 9461d777539..83d47e28c03 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -1607,11 +1607,11 @@ - + - + - + From c697f85d99e6884fb2a0d59e640dc0459a009b0f Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Sat, 5 Mar 2022 20:04:44 -0800 Subject: [PATCH 29/34] added integrated test; made ready for review --- inputFiles/thermal/co2_thermal_2d.xml | 223 ++++++++++++++++++ inputFiles/thermal/co2flash.txt | 1 + inputFiles/thermal/pvtgas.txt | 4 + inputFiles/thermal/pvtliquid.txt | 4 + .../constitutive/fluid/multiFluidSelector.hpp | 14 +- .../CompositionalMultiphaseUtilities.hpp | 83 ++++--- ...ermalCompositionalMultiphaseFVMKernels.hpp | 4 +- ...rmalCompositionalMultiphaseBaseKernels.hpp | 3 +- ...ermalCompositionalMultiphaseFVMKernels.hpp | 3 +- .../CompositionalMultiphaseWellKernels.cpp | 6 +- .../CompositionalMultiphaseReservoir.cpp | 4 +- 11 files changed, 298 insertions(+), 51 deletions(-) create mode 100644 inputFiles/thermal/co2_thermal_2d.xml create mode 100644 inputFiles/thermal/co2flash.txt create mode 100644 inputFiles/thermal/pvtgas.txt create mode 100644 inputFiles/thermal/pvtliquid.txt diff --git a/inputFiles/thermal/co2_thermal_2d.xml b/inputFiles/thermal/co2_thermal_2d.xml new file mode 100644 index 00000000000..b13b4336d30 --- /dev/null +++ b/inputFiles/thermal/co2_thermal_2d.xml @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/thermal/co2flash.txt b/inputFiles/thermal/co2flash.txt new file mode 100644 index 00000000000..af702698fb3 --- /dev/null +++ b/inputFiles/thermal/co2flash.txt @@ -0,0 +1 @@ +FlashModel CO2Solubility 1e6 7.5e7 5e4 299.15 370.15 1 0 diff --git a/inputFiles/thermal/pvtgas.txt b/inputFiles/thermal/pvtgas.txt new file mode 100644 index 00000000000..354a3fa63ae --- /dev/null +++ b/inputFiles/thermal/pvtgas.txt @@ -0,0 +1,4 @@ +DensityFun SpanWagnerCO2Density 1e6 7.5e7 5e4 299.15 370.15 1 +ViscosityFun FenghourCO2Viscosity 1e6 7.5e7 5e4 299.15 370.15 1 +EnthalpyFun CO2Enthalpy 1e6 7.5e7 5e4 299.15 370.15 1 +InternalEnergyFun CO2InternalEnergy 1e6 7.5e7 5e4 299.15 370.15 1 diff --git a/inputFiles/thermal/pvtliquid.txt b/inputFiles/thermal/pvtliquid.txt new file mode 100644 index 00000000000..82bead2dde4 --- /dev/null +++ b/inputFiles/thermal/pvtliquid.txt @@ -0,0 +1,4 @@ +DensityFun PhillipsBrineDensity 1e6 7.5e7 5e4 299.15 370.15 1 0 +ViscosityFun PhillipsBrineViscosity 0 +EnthalpyFun BrineEnthalpy 1e6 7.5e7 5e4 299.15 370.15 1 0 +InternalEnergyFun BrineInternalEnergy diff --git a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp index dbd298bb035..6977c38f81f 100644 --- a/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multiFluidSelector.hpp @@ -44,9 +44,10 @@ void constitutiveUpdatePassThru( MultiFluidBase const & fluid, CompositionalMultiphaseFluid, #endif CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid/*, - CO2BrinePhillipsThermalFluid, - CO2BrineEzrokhiThermalFluid*/ >::execute( fluid, std::forward< LAMBDA >( lambda ) ); + CO2BrineEzrokhiFluid, + CO2BrinePhillipsThermalFluid /*, // if I uncomment the two models at the same time, the compiler segfaults on + Lassen! + CO2BrineEzrokhiThermalFluid*/>::execute( fluid, std::forward< LAMBDA >( lambda ) ); } template< typename LAMBDA > @@ -59,9 +60,10 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid, CompositionalMultiphaseFluid, #endif CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid/*, - CO2BrinePhillipsThermalFluid, - CO2BrineEzrokhiThermalFluid*/ >::execute( fluid, std::forward< LAMBDA >( lambda ) ); + CO2BrineEzrokhiFluid, + CO2BrinePhillipsThermalFluid /*, // if I uncomment the two models at the same time, the compiler segfaults on + Lassen! + CO2BrineEzrokhiThermalFluid*/>::execute( fluid, std::forward< LAMBDA >( lambda ) ); } } // namespace constitutive diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp index 8b28e24f829..502261eaf38 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp @@ -28,31 +28,36 @@ namespace compositionalMultiphaseUtilities { /** - * @brief Shifts all elements one position ahead and replaces the first element - * with the sum of all elements in each block of the input block one-dimensional - * array of values. + * @brief In each block, shift the elements from 0 to numRowsToShift-1 one position ahead and replaces the first element + * with the sum of all elements from 0 to numRowsToShift-1 of the input block one-dimensional array of values. * * @tparam VEC type of one-dimensional array of values - * @param N block size - * @param NB number of blocks + * @param numRowsToShift number of rows to shift in each block + * @param numRowsInBlock block size + * @param numBlocks number of blocks * @param v block one-dimensional array of values + * + * @detail numRowsToShift is different from numRowsInBlock if there is an equation that we do *not* want to + * modify, like the energy flux for thermal simulations. In that specific case, numRowsToShift + * is set to numRowsInBlock-1 to make sure that we don't modify the last row of each block (the energy flux) */ template< typename VEC > GEOSX_HOST_DEVICE -void shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( integer const N, - integer const NB, +void shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( integer const numRowsToShift, + integer const numRowsInBlock, + integer const numBlocks, VEC && v ) { - for( integer i = 0; i < NB; ++i ) + for( integer i = 0; i < numBlocks; ++i ) { - integer const ind = i * N + N - 1; + integer const ind = i * numRowsInBlock + numRowsToShift - 1; real64 tmp = v[ind]; - for( int j = ind - 1; j >= i * N; --j ) + for( int j = ind - 1; j >= i * numRowsInBlock; --j ) { v[j+1] = v[j]; tmp += v[j]; } - v[i*N] = tmp; + v[i*numRowsInBlock] = tmp; } } @@ -61,56 +66,62 @@ void shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( integer const N, * with the sum of all elements in the input one-dimensional array of values. * * @tparam VEC type of one-dimensional array of values - * @param N vector size + * @param numRows vector size * @param v one-dimensional array of values */ template< typename VEC > GEOSX_HOST_DEVICE -void shiftElementsAheadByOneAndReplaceFirstElementWithSum( integer const N, +void shiftElementsAheadByOneAndReplaceFirstElementWithSum( integer const numRows, VEC && v ) { - shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( N, 1, v ); + shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( numRows, numRows, 1, v ); } /** - * @brief Shifts all rows one position ahead and replaces the first row - * with the sum of all rows in each block of the input block row + * @brief In each block, shift the elements from 0 to numRowsToShift-1, shifts all rows one position ahead + * and replaces the first row with the sum of all rows from 0 to numRowsToShift-1 of the input block row * two-dimensional array of values. * * @tparam MATRIX type of two-dimensional array of values * @tparam VEC type of one-dimensional array of values - * @param M block number of rows - * @param N block number of columns - * @param NB number of row blocks + * @param numRowsToShift number of rows to shift in each block + * @param numRowsInBlock block number of rows + * @param numColsInBlock block number of columns + * @param numBlocks number of row blocks * @param mat block row two-dimensional array of values - * @param work one-dimensional working array of values of size N + * @param work one-dimensional working array of values of size numColsInBlock + * + * @detail numRowsToShift is different from numRowsInBlock if there is an equation that we do *not* want to + * modify, like the energy flux for thermal simulations. In that specific case, numRowsToShift + * is set to numRowsInBlock-1 to make sure that we don't modify the last row of each block (the energy flux) */ template< typename MATRIX, typename VEC > GEOSX_HOST_DEVICE -void shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( integer const M, - integer const N, - integer const NB, +void shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( integer const numRowsToShift, + integer const numRowsInBlock, + integer const numColsInBlock, + integer const numBlocks, MATRIX && mat, VEC && work ) { - for( integer k = 0; k < NB; ++k ) + for( integer k = 0; k < numBlocks; ++k ) { - integer const ind = k * M + M - 1; - for( integer j = 0; j < N; ++j ) + integer const ind = k * numRowsInBlock + numRowsToShift - 1; + for( integer j = 0; j < numColsInBlock; ++j ) { work[j] = mat[ind][j]; } - for( integer i = ind - 1; i >= k * M; --i ) + for( integer i = ind - 1; i >= k * numRowsInBlock; --i ) { - for( integer j = 0; j < N; ++j ) + for( integer j = 0; j < numColsInBlock; ++j ) { mat[i+1][j] = mat[i][j]; work[j] += mat[i][j]; } } - for( integer j = 0; j < N; ++j ) + for( integer j = 0; j < numColsInBlock; ++j ) { - mat[k*M][j] = work[j]; + mat[k*numRowsInBlock][j] = work[j]; } } } @@ -122,19 +133,19 @@ void shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( integer const M, * * @tparam MATRIX type of two-dimensional array of values * @tparam VEC type of one-dimensional array of values - * @param M number of rows - * @param N number of columns + * @param numRowsInBlock number of rows + * @param numColsInBlock number of columns * @param mat block row two-dimensional array of values - * @param work one-dimensional working array of values of size N + * @param work one-dimensional working array of values of size numColsInBlock */ template< typename MATRIX, typename VEC > GEOSX_HOST_DEVICE -void shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( integer const M, - integer const N, +void shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum( integer const numRowsInBlock, + integer const numColsInBlock, MATRIX && mat, VEC && work ) { - shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( M, N, 1, mat, work ); + shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numRowsInBlock, numRowsInBlock, numColsInBlock, 1, mat, work ); } } // namespace compositionalMultiphaseUtilities diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index e7576461b24..89a8fc7b430 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -849,9 +849,9 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase // Apply equation/variable change transformation(s) stackArray1d< real64, maxStencilSize * numDof > work( stack.stencilSize * numDof ); - shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numComp, numDof*stack.stencilSize, stack.numFluxElems, + shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numComp, numEqn, numDof*stack.stencilSize, stack.numFluxElems, stack.localFluxJacobian, work ); - shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( numComp, stack.numFluxElems, + shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( numComp, numEqn, stack.numFluxElems, stack.localFlux ); // add contribution to residual and jacobian into: diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index af0bc73aa87..70191739f2e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -277,10 +277,11 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK { using Deriv = multifluid::DerivativeOffset; + // I did not find another way to pass the stack.localResidual to the lambda real64 * localResidualPtr = stack.localResidual; real64 ( *localJacobianPtr )[numDof] = stack.localJacobian; - Base::computeAccumulation( ei, stack, [=] GEOSX_HOST_DEVICE ( localIndex const ip, + Base::computeAccumulation( ei, stack, [=] GEOSX_HOST_DEVICE ( integer const ip, real64 const & phaseAmountNew, real64 const & phaseAmountOld, real64 const & dPhaseAmount_dP, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index f67ad88ea77..3eec09ae5fd 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -348,6 +348,7 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne arraySlice2d< real64 > dCompFlux_dTSlice = stack.dCompFlux_dT.toSlice(); + // I did not find another way to pass the stack.energyFlux to the lambda... real64 * energyFluxPtr = &(stack.energyFlux); arraySlice1d< real64 > dEnergyFlux_dPSlice = stack.dEnergyFlux_dP.toSlice(); arraySlice1d< real64 > dEnergyFlux_dTSlice = stack.dEnergyFlux_dT.toSlice(); @@ -361,7 +362,7 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne // Computing dCompFlux_dT and the enthalpyFlux requires quantities already computed in the base computeFlux, // such as potGrad, phaseFlux, and the indices of the upwind cell // We use the lambda below (called **inside** the phase loop of the base computeFlux) to access these variables - Base::computeFlux( iconn, stack, [=] GEOSX_HOST_DEVICE ( localIndex const ip, + Base::computeFlux( iconn, stack, [=] GEOSX_HOST_DEVICE ( integer const ip, localIndex const k_up, localIndex const er_up, localIndex const esr_up, diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp index 8d2565598d0..5297df49324 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.cpp @@ -482,9 +482,9 @@ FluxKernel:: // Apply equation/variable change transformation(s) real64 work[NC+1]{}; - shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, 1, 2, localFluxJacobian_dRate, work ); - shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, NC + 1, 2, localFluxJacobian_dPresCompUp, work ); - shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( NC, 2, localFlux ); + shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, NC, 1, 2, localFluxJacobian_dRate, work ); + shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( NC, NC, NC + 1, 2, localFluxJacobian_dPresCompUp, work ); + shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( NC, NC, 2, localFlux ); for( integer i = 0; i < 2*NC; ++i ) { diff --git a/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoir.cpp b/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoir.cpp index 2addaae1b63..78f2a2d70ac 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoir.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/CompositionalMultiphaseReservoir.cpp @@ -302,8 +302,8 @@ void CompositionalMultiphaseReservoir::assembleCouplingTerms( real64 const time_ // Apply equation/variable change transformation(s) stackArray1d< real64, 2 * MAX_NUM_DOF > work( 2 * resNumDofs ); - shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numComps, resNumDofs*2, 2, localPerfJacobian, work ); - shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( numComps, 2, localPerf ); + shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numComps, numComps, resNumDofs*2, 2, localPerfJacobian, work ); + shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum( numComps, numComps, 2, localPerf ); for( localIndex i = 0; i < localPerf.size(); ++i ) { From 3481c7fb01a5ffab66e69baab3cb18bd79b73739 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 9 Mar 2022 18:09:51 -0800 Subject: [PATCH 30/34] passing unit test for thermal compositional --- .../IsothermalCompositionalMultiphaseBaseKernels.hpp | 10 +++++----- .../ThermalCompositionalMultiphaseBaseKernels.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp index 2d0641378d3..aeadc15ec58 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp @@ -761,17 +761,17 @@ class ElementBasedAssemblyKernel } } + // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives + // possible use: assemble the derivatives wrt temperature, and use oneMinusPhaseVolFracSum if poreVolumeNew depends on temperature + phaseVolFractionSumKernelOp( oneMinusPhaseVolFracSum ); + // scale saturation-based volume balance by pore volume (for better scaling w.r.t. other equations) stack.localResidual[numComp] = stack.poreVolumeNew * oneMinusPhaseVolFracSum; - for( integer idof = 0; idof < numComp+1; ++idof ) + for( integer idof = 0; idof < numDof; ++idof ) { stack.localJacobian[numComp][idof] *= stack.poreVolumeNew; } stack.localJacobian[numComp][0] += stack.dPoreVolume_dPres * oneMinusPhaseVolFracSum; - - // call the lambda in the phase loop to allow the reuse of the phase amounts and their derivatives - // possible use: assemble the derivatives wrt temperature, and use oneMinusPhaseVolFracSum if poreVolumeNew depends on temperature - phaseVolFractionSumKernelOp( oneMinusPhaseVolFracSum ); } /** diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index 70191739f2e..4e61f08aaf1 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -379,7 +379,7 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK void complete( localIndex const ei, StackVariables & stack ) const { - // Step 1: assemble the component mass balance equations + // Step 1: assemble the component mass balance equations and volume balance equations Base::complete( ei, stack ); // Step 2: assemble the energy equation From 320f685adf34c9e383d71d21d91db49c8979a0a6 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 9 Mar 2022 21:42:49 -0800 Subject: [PATCH 31/34] start addressing Matteo's comments --- .../fluidFlow/CompositionalMultiphaseBase.cpp | 42 +++++++++++-------- .../fluidFlow/CompositionalMultiphaseBase.hpp | 4 +- .../CompositionalMultiphaseUtilities.hpp | 35 ++++++++++++++++ ...ermalCompositionalMultiphaseFVMKernels.hpp | 10 ++--- ...ermalCompositionalMultiphaseFVMKernels.hpp | 29 +++++++------ 5 files changed, 83 insertions(+), 37 deletions(-) diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 225183ba64b..0b36982a8f9 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -606,25 +606,22 @@ void CompositionalMultiphaseBase::updateCapPressureModel( ObjectManagerBase & da void CompositionalMultiphaseBase::updateSolidInternalEnergyModel( ObjectManagerBase & dataGroup ) const { - if( m_isThermal ) - { - arrayView1d< real64 const > const temp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::temperature >(); - arrayView1d< real64 const > const dTemp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); + arrayView1d< real64 const > const temp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::temperature >(); + arrayView1d< real64 const > const dTemp = dataGroup.getExtrinsicData< extrinsicMeshData::flow::deltaTemperature >(); - string const & solidInternalEnergyName = dataGroup.getReference< string >( viewKeyStruct::solidInternalEnergyNamesString() ); - SolidInternalEnergy & solidInternalEnergy = getConstitutiveModel< SolidInternalEnergy >( dataGroup, solidInternalEnergyName ); + string const & solidInternalEnergyName = dataGroup.getReference< string >( viewKeyStruct::solidInternalEnergyNamesString() ); + SolidInternalEnergy & solidInternalEnergy = getConstitutiveModel< SolidInternalEnergy >( dataGroup, solidInternalEnergyName ); - SolidInternalEnergy::KernelWrapper solidInternalEnergyWrapper = solidInternalEnergy.createKernelUpdates(); + SolidInternalEnergy::KernelWrapper solidInternalEnergyWrapper = solidInternalEnergy.createKernelUpdates(); - // TODO: this should go somewhere, handle the case of flow in fracture, etc + // TODO: this should go somewhere, handle the case of flow in fracture, etc - thermalCompositionalMultiphaseBaseKernels:: - SolidInternalEnergyUpdateKernel:: - launch< parallelDevicePolicy<> >( dataGroup.size(), - solidInternalEnergyWrapper, - temp, - dTemp ); - } + thermalCompositionalMultiphaseBaseKernels:: + SolidInternalEnergyUpdateKernel:: + launch< parallelDevicePolicy<> >( dataGroup.size(), + solidInternalEnergyWrapper, + temp, + dTemp ); } void CompositionalMultiphaseBase::updateFluidState( ObjectManagerBase & subRegion ) const @@ -1831,11 +1828,16 @@ void CompositionalMultiphaseBase::resetStateToBeginningOfStep( DomainPartition & dTemp.zero(); } - // update porosity, permeability, and solid internal energy + // update porosity, permeability updatePorosityAndPermeability( subRegion ); - updateSolidInternalEnergyModel( subRegion ); // update all fluid properties updateFluidState( subRegion ); + // for thermal simulations, update solid internal energy + if( m_isThermal ) + { + updateSolidInternalEnergyModel( subRegion ); + } + } ); } ); } @@ -1950,9 +1952,13 @@ void CompositionalMultiphaseBase::updateState( DomainPartition & domain ) { // update porosity, permeability, and solid internal energy updatePorosityAndPermeability( subRegion ); - updateSolidInternalEnergyModel( subRegion ); // update all fluid properties updateFluidState( subRegion ); + // for thermal, update solid internal energy + if( m_isThermal ) + { + updateSolidInternalEnergyModel( subRegion ); + } } ); } ); } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp index 7f8e781a469..7e19f6cdf5f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp @@ -168,13 +168,13 @@ class CompositionalMultiphaseBase : public FlowSolverBase * @brief Getter for the number of fluid components (species) * @return the number of components */ - localIndex numFluidComponents() const { return m_numComponents; } + integer numFluidComponents() const { return m_numComponents; } /** * @brief Getter for the number of fluid phases * @return the number of phases */ - localIndex numFluidPhases() const { return m_numPhases; } + integer numFluidPhases() const { return m_numPhases; } /** * @brief Getter for the name of the reference fluid model name diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp index 502261eaf38..d4c53d24842 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseUtilities.hpp @@ -40,6 +40,22 @@ namespace compositionalMultiphaseUtilities * @detail numRowsToShift is different from numRowsInBlock if there is an equation that we do *not* want to * modify, like the energy flux for thermal simulations. In that specific case, numRowsToShift * is set to numRowsInBlock-1 to make sure that we don't modify the last row of each block (the energy flux) + * + * Let's consider the following blocks arising when computing the localFlux in the thermal compositional solver (for two-component flow) + * + * + * (mass_comp_1)_1 \ + * (mass_comp_2)_1 |=> block 1 + * (energy)_1 / + * + * (mass_comp_1)_2 \ + * (mass_comp_2)_2 |=> block 2 + * (energy)_2 / + * + * In this case: + * - numRowsToShift = 2 + * - numRowsInBlock = 3 + * - numBlocks = 2 */ template< typename VEC > GEOSX_HOST_DEVICE @@ -94,6 +110,25 @@ void shiftElementsAheadByOneAndReplaceFirstElementWithSum( integer const numRows * @detail numRowsToShift is different from numRowsInBlock if there is an equation that we do *not* want to * modify, like the energy flux for thermal simulations. In that specific case, numRowsToShift * is set to numRowsInBlock-1 to make sure that we don't modify the last row of each block (the energy flux) + * + * Let's consider the following blocks arising when computing the localFluxJacobian in the thermal compositional solver (for two-component + * flow) + * + * p \rho_1 \rho_2 T + * (mass_comp_1)_1 . . . . \ + * (mass_comp_2)_1 . . . . |=> block 1 + * (energy)_1 . . . . / + * + * (mass_comp_1)_2 . . . . \ + * (mass_comp_2)_2 . . . . |=> block 2 + * (energy)_2 . . . . / + * + * In this case: + * - numRowsToShift = 2 + * - numRowsInBlock = 3 + * - numColsInBlock = 4 + * - numBlocks = 2 + * */ template< typename MATRIX, typename VEC > GEOSX_HOST_DEVICE diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index 89a8fc7b430..2e91e2e7797 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -314,11 +314,11 @@ class FaceBasedAssemblyKernelBase * @param[in] numPhases the number of fluid phases * @param[in] rankOffset the offset of my MPI rank * @param[in] hasCapPressure flag specifying whether capillary pressure is used or not - * @param[in] dofNumberAccessor - * @param[in] compFlowAccessors - * @param[in] multiFluidAccessors - * @param[in] capPressureAccessors - * @param[in] permeabilityAccessors + * @param[in] dofNumberAccessor accessor for the dof numbers + * @param[in] compFlowAccessors accessor for wrappers registered by the solver + * @param[in] multiFluidAccessors accessor for wrappers registered by the multifluid model + * @param[in] capPressureAccessors accessor for wrappers registered by the cap pressure model + * @param[in] permeabilityAccessors accessor for wrappers registered by the permeability model * @param[in] dt time step size * @param[inout] localMatrix the local CRS matrix * @param[inout] localRhs the local right-hand side vector diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index 3eec09ae5fd..168300a6c89 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -243,14 +243,14 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne * @param[in] rankOffset the offset of my MPI rank * @param[in] hasCapPressure flag specifying whether capillary pressure is used or not * @param[in] stencilWrapper reference to the stencil wrapper - * @param[in] dofNumberAccessor - * @param[in] compFlowAccessor - * @param[in] thermalCompFlowAccessors - * @param[in] multiFluidAccessor - * @param[in] thermalMultiFluidAccessors - * @param[in] capPressureAccessors - * @param[in] permeabilityAccessors - * @param[in] thermalConductivityAccessors + * @param[in] dofNumberAccessor accessor for the dofs numbers + * @param[in] compFlowAccessor accessor for wrappers registered by the solver + * @param[in] thermalCompFlowAccessors accessor for *thermal* wrappers registered by the solver + * @param[in] multiFluidAccessor accessor for wrappers registered by the multifluid model + * @param[in] thermalMultiFluidAccessors accessor for *thermal* wrappers registered by the multifluid model + * @param[in] capPressureAccessors accessor for wrappers registered by the cap pressure model + * @param[in] permeabilityAccessors accessor for wrappers registered by the permeability model + * @param[in] thermalConductivityAccessors accessor for wrappers registered by the thermal conductivity model * @param[in] dt time step size * @param[inout] localMatrix the local CRS matrix * @param[inout] localRhs the local right-hand side vector @@ -357,9 +357,9 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne // *********************************************** // First, we call the base computeFlux to compute: // 1) compFlux and its derivatives (including derivatives wrt temperature), - // 2) enthalpyFlux and its derivatives (including derivatives wrt temperature + // 2) enthalpy part of energyFlux and its derivatives (including derivatives wrt temperature) // - // Computing dCompFlux_dT and the enthalpyFlux requires quantities already computed in the base computeFlux, + // Computing dCompFlux_dT and the enthalpy flux requires quantities already computed in the base computeFlux, // such as potGrad, phaseFlux, and the indices of the upwind cell // We use the lambda below (called **inside** the phase loop of the base computeFlux) to access these variables Base::computeFlux( iconn, stack, [=] GEOSX_HOST_DEVICE ( integer const ip, @@ -499,13 +499,18 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne // ***************************************************** // Computation of the conduction term in the energy flux + // Note that the phase enthalpy term in the energy was computed above // Note that this term is computed using an explicit treatment of conductivity for now + // Step 1: compute the thermal transmissibilities at this face + // Below, the thermal conductivity used to compute (explicitly) the thermal conducivity + // To avoid modifying the signature of the "computeWeights" function for now, we pass m_thermalConductivity twice + // TODO: modify computeWeights to accomodate explicit coefficients m_stencilWrapper.computeWeights( iconn, m_thermalConductivity, - m_thermalConductivity, // unused for now + m_thermalConductivity, // we have to pass something here, so we just use thermal conductivity stack.thermalTransmissibility, - stack.dTrans_dPres ); // unused for now + stack.dTrans_dPres ); // again, we have to pass something here, but this is unused for now // Step 2: compute temperature difference at the interface for( integer i = 0; i < stack.stencilSize; ++i ) From d5ce276c37fa015ab7aeed26fc53ba36c9563e76 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Fri, 18 Mar 2022 19:49:31 -0700 Subject: [PATCH 32/34] passing all integrated tests --- inputFiles/thermal/co2_thermal_2d.xml | 4 ++-- integratedTests | 2 +- .../physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/inputFiles/thermal/co2_thermal_2d.xml b/inputFiles/thermal/co2_thermal_2d.xml index b13b4336d30..d23b8900942 100644 --- a/inputFiles/thermal/co2_thermal_2d.xml +++ b/inputFiles/thermal/co2_thermal_2d.xml @@ -9,7 +9,7 @@ temperature="368.15" useMass="1" isThermal="1" - initialDt="1" + initialDt="1e3" maxCompFractionChange="0.5" targetRegions="{ region }"> diff --git a/integratedTests b/integratedTests index 10661e49f24..8ca8f9412ea 160000 --- a/integratedTests +++ b/integratedTests @@ -1 +1 @@ -Subproject commit 10661e49f2410cc0f2434bcde16edfe3f11c99be +Subproject commit 8ca8f9412eab3a4b968d7a3200aaa5f79dbe7b2d diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp index 7a9800da611..2ca71a1c7f7 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseBase.cpp @@ -1645,10 +1645,13 @@ void CompositionalMultiphaseBase::applyDirichletBC( real64 const time, string const & fluidName = subRegion.getReference< string >( viewKeyStruct::fluidNamesString() ); MultiFluidBase & fluid = getConstitutiveModel< MultiFluidBase >( subRegion, fluidName ); + // in the isothermal case, we use the reservoir temperature to enforce the boundary condition + string const temperatureKey = m_isThermal ? extrinsicMeshData::flow::bcTemperature::key() : extrinsicMeshData::flow::temperature::key(); + arrayView1d< real64 const > const bcPres = subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::bcPressure::key() ); arrayView1d< real64 const > const bcTemp = - subRegion.getReference< array1d< real64 > >( extrinsicMeshData::flow::bcTemperature::key() ); + subRegion.getReference< array1d< real64 > >( temperatureKey ); arrayView2d< real64 const, compflow::USD_COMP > const compFrac = subRegion.getReference< array2d< real64, compflow::LAYOUT_COMP > >( extrinsicMeshData::flow::globalCompFraction::key() ); From ba77f5bf778c489e78d6c184a20096bf654d8cec Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Wed, 30 Mar 2022 02:30:42 -0700 Subject: [PATCH 33/34] removed enum string in CO2-brine fluid --- .../constitutive/fluid/CO2BrineFluid.cpp | 6 +-- .../constitutive/fluid/CO2BrineFluid.hpp | 19 ------- .../schema/docs/AcousticSEM_other.rst | 32 ++++++------ .../docs/CompositionalMultiphaseFVM_other.rst | 16 +++--- ...CompositionalMultiphaseHybridFVM_other.rst | 20 +++---- ...CompositionalMultiphaseReservoir_other.rst | 18 +++---- .../CompositionalMultiphaseWell_other.rst | 20 +++---- .../docs/EmbeddedSurfaceGenerator_other.rst | 20 +++---- .../docs/FlowProppantTransport_other.rst | 18 +++---- .../schema/docs/Hydrofracture_other.rst | 16 +++--- .../schema/docs/LagrangianContact_other.rst | 18 +++---- .../schema/docs/LaplaceFEM_other.rst | 16 +++--- .../docs/MultiphasePoromechanics_other.rst | 16 +++--- .../schema/docs/PhaseFieldDamageFEM_other.rst | 16 +++--- .../schema/docs/PhaseFieldFracture_other.rst | 16 +++--- .../schema/docs/ProppantTransport_other.rst | 16 +++--- .../schema/docs/SinglePhaseFVM_other.rst | 16 +++--- .../docs/SinglePhaseHybridFVM_other.rst | 18 +++---- ...sePoromechanicsEmbeddedFractures_other.rst | 18 +++---- .../docs/SinglePhasePoromechanics_other.rst | 16 +++--- .../docs/SinglePhaseProppantFVM_other.rst | 16 +++--- .../docs/SinglePhaseReservoir_other.rst | 18 +++---- .../schema/docs/SinglePhaseWell_other.rst | 20 +++---- .../SolidMechanicsEmbeddedFractures_other.rst | 18 +++---- .../SolidMechanicsLagrangianSSLE_other.rst | 18 +++---- .../SolidMechanics_LagrangianFEM_other.rst | 18 +++---- .../schema/docs/SurfaceGenerator_other.rst | 28 +++++----- .../docs/TwoPointFluxApproximation_other.rst | 22 ++++---- src/coreComponents/schema/schema.xsd.other | 52 +++++++++---------- .../testThermalCompMultiphaseFlow.cpp | 8 +-- 30 files changed, 275 insertions(+), 294 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp index 1567cf15be2..48b20435d01 100644 --- a/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.cpp @@ -185,7 +185,7 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() { string_array const strs = stringutilities::tokenize( str, " " ); - if( strs[0] == toString( SubModelInputNames::DENSITY ) ) + if( strs[0] == "DensityFun" ) { if( strs[1] == PHASE1::Density::catalogName() ) { @@ -196,7 +196,7 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() phase2InputParams[PHASE2::InputParamOrder::DENSITY] = strs; } } - else if( strs[0] == toString( SubModelInputNames::VISCOSITY ) ) + else if( strs[0] == "ViscosityFun" ) { if( strs[1] == PHASE1::Viscosity::catalogName() ) { @@ -207,7 +207,7 @@ void CO2BrineFluid< PHASE1, PHASE2, FLASH >::createPVTModels() phase2InputParams[PHASE2::InputParamOrder::VISCOSITY] = strs; } } - else if( strs[0] == toString( SubModelInputNames::ENTHALPY ) ) + else if( strs[0] == "EnthalpyFun" ) { if( strs[1] == PHASE1::Enthalpy::catalogName() ) { diff --git a/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp index 875b3f2085b..c2752fdd8e6 100644 --- a/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/CO2BrineFluid.hpp @@ -569,25 +569,6 @@ CO2BrineFluid< PHASE1, PHASE2, FLASH >::KernelWrapper:: m_totalDensity( k, q ) ); } -/// Declare strings associated with enumeration values -/// Needed for now, because we don't use the catalogNames for input (yet) -ENUM_STRINGS( CO2BrinePhillipsFluid::SubModelInputNames, - "DensityFun", - "ViscosityFun", - "EnthalpyFun" ); -ENUM_STRINGS( CO2BrinePhillipsThermalFluid::SubModelInputNames, - "DensityFun", - "ViscosityFun", - "EnthalpyFun" ); -ENUM_STRINGS( CO2BrineEzrokhiFluid::SubModelInputNames, - "DensityFun", - "ViscosityFun", - "EnthalpyFun" ); -ENUM_STRINGS( CO2BrineEzrokhiThermalFluid::SubModelInputNames, - "DensityFun", - "ViscosityFun", - "EnthalpyFun" ); - } // namespace constitutive diff --git a/src/coreComponents/schema/docs/AcousticSEM_other.rst b/src/coreComponents/schema/docs/AcousticSEM_other.rst index 71642d4c7ae..edd823f6468 100644 --- a/src/coreComponents/schema/docs/AcousticSEM_other.rst +++ b/src/coreComponents/schema/docs/AcousticSEM_other.rst @@ -1,20 +1,20 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================= -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================= -indexSeismoTrace integer Count for output pressure at receivers -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -pressureNp1AtReceivers real64_array2d Pressure value at each receiver for each timestep -receiverIsLocal integer_array Flag that indicates whether the receiver is local to this MPI rank -receiverNodeIds integer_array2d Indices of the nodes (in the right order) for each receiver point -sourceConstants real64_array2d Constant part of the receiver for the nodes listed in m_receiverNodeIds -sourceIsLocal integer_array Flag that indicates whether the source is local to this MPI rank -sourceNodeIds integer_array2d Indices of the nodes (in the right order) for each source point -sourceValue real64_array2d Source Value of the sources -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================= +========================= =================================================================================================================================================== ======================================================================= +Name Type Description +========================= =================================================================================================================================================== ======================================================================= +indexSeismoTrace integer Count for output pressure at receivers +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +pressureNp1AtReceivers real64_array2d Pressure value at each receiver for each timestep +receiverIsLocal integer_array Flag that indicates whether the receiver is local to this MPI rank +receiverNodeIds integer_array2d Indices of the nodes (in the right order) for each receiver point +sourceConstants real64_array2d Constant part of the receiver for the nodes listed in m_receiverNodeIds +sourceIsLocal integer_array Flag that indicates whether the source is local to this MPI rank +sourceNodeIds integer_array2d Indices of the nodes (in the right order) for each source point +sourceValue real64_array2d Source Value of the sources +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================= diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseFVM_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst index bf32e9bac59..8e2f2eb6a85 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseHybridFVM_other.rst @@ -1,14 +1,14 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================ ================================================================ -Name Type Registered On Description -========================= =============================================================================================================================================================================================================================================================================================== ================================ ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -deltaFacePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Accumulated face pressure updates -mimGravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Mimetic gravity coefficient -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================ ================================================================ +========================= =================================================================================================================================================== ================================ ================================================================ +Name Type Registered On Description +========================= =================================================================================================================================================== ================================ ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +deltaFacePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Accumulated face pressure updates +mimGravityCoefficient real64_array :ref:`DATASTRUCTURE_FaceManager` Mimetic gravity coefficient +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================ ================================================================ diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseReservoir_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseReservoir_other.rst index aa08bcefbb0..7acea5a6dbf 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseReservoir_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseReservoir_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/CompositionalMultiphaseWell_other.rst b/src/coreComponents/schema/docs/CompositionalMultiphaseWell_other.rst index b3804961a57..48a09333642 100644 --- a/src/coreComponents/schema/docs/CompositionalMultiphaseWell_other.rst +++ b/src/coreComponents/schema/docs/CompositionalMultiphaseWell_other.rst @@ -1,14 +1,14 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -WellControls node :ref:`DATASTRUCTURE_WellControls` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +WellControls node :ref:`DATASTRUCTURE_WellControls` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/EmbeddedSurfaceGenerator_other.rst b/src/coreComponents/schema/docs/EmbeddedSurfaceGenerator_other.rst index 8bd71bf6b41..b53cb9d3cce 100644 --- a/src/coreComponents/schema/docs/EmbeddedSurfaceGenerator_other.rst +++ b/src/coreComponents/schema/docs/EmbeddedSurfaceGenerator_other.rst @@ -1,14 +1,14 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================ ======================================================================================================================================================================================================================================================================================================================== -Name Type Registered On Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================ ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -parentEdgeIndex integer_array :ref:`DATASTRUCTURE_embeddedSurfacesNodeManager` Index of parent edge within the mesh object it is registered on. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================ ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ================================================ ======================================================================================================================================================================================================================================================================================================================== +Name Type Registered On Description +========================= =================================================================================================================================================== ================================================ ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +parentEdgeIndex integer_array :ref:`DATASTRUCTURE_embeddedSurfacesNodeManager` Index of parent edge within the mesh object it is registered on. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================ ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/FlowProppantTransport_other.rst b/src/coreComponents/schema/docs/FlowProppantTransport_other.rst index aa08bcefbb0..7acea5a6dbf 100644 --- a/src/coreComponents/schema/docs/FlowProppantTransport_other.rst +++ b/src/coreComponents/schema/docs/FlowProppantTransport_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/Hydrofracture_other.rst b/src/coreComponents/schema/docs/Hydrofracture_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/Hydrofracture_other.rst +++ b/src/coreComponents/schema/docs/Hydrofracture_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/LagrangianContact_other.rst b/src/coreComponents/schema/docs/LagrangianContact_other.rst index aa08bcefbb0..7acea5a6dbf 100644 --- a/src/coreComponents/schema/docs/LagrangianContact_other.rst +++ b/src/coreComponents/schema/docs/LagrangianContact_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/LaplaceFEM_other.rst b/src/coreComponents/schema/docs/LaplaceFEM_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/LaplaceFEM_other.rst +++ b/src/coreComponents/schema/docs/LaplaceFEM_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/MultiphasePoromechanics_other.rst b/src/coreComponents/schema/docs/MultiphasePoromechanics_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/MultiphasePoromechanics_other.rst +++ b/src/coreComponents/schema/docs/MultiphasePoromechanics_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/PhaseFieldDamageFEM_other.rst b/src/coreComponents/schema/docs/PhaseFieldDamageFEM_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/PhaseFieldDamageFEM_other.rst +++ b/src/coreComponents/schema/docs/PhaseFieldDamageFEM_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/PhaseFieldFracture_other.rst b/src/coreComponents/schema/docs/PhaseFieldFracture_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/PhaseFieldFracture_other.rst +++ b/src/coreComponents/schema/docs/PhaseFieldFracture_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/ProppantTransport_other.rst b/src/coreComponents/schema/docs/ProppantTransport_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/ProppantTransport_other.rst +++ b/src/coreComponents/schema/docs/ProppantTransport_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst b/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseFVM_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst b/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst index 7cd3eeef08a..56309599fa0 100644 --- a/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseHybridFVM_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================ ================================================================ -Name Type Registered On Description -========================= =============================================================================================================================================================================================================================================================================================== ================================ ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -deltaFacePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Accumulated face pressure updates -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================ ================================================================ +========================= =================================================================================================================================================== ================================ ================================================================ +Name Type Registered On Description +========================= =================================================================================================================================================== ================================ ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +deltaFacePressure real64_array :ref:`DATASTRUCTURE_FaceManager` Accumulated face pressure updates +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================ ================================================================ diff --git a/src/coreComponents/schema/docs/SinglePhasePoromechanicsEmbeddedFractures_other.rst b/src/coreComponents/schema/docs/SinglePhasePoromechanicsEmbeddedFractures_other.rst index aa08bcefbb0..7acea5a6dbf 100644 --- a/src/coreComponents/schema/docs/SinglePhasePoromechanicsEmbeddedFractures_other.rst +++ b/src/coreComponents/schema/docs/SinglePhasePoromechanicsEmbeddedFractures_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/SinglePhasePoromechanics_other.rst b/src/coreComponents/schema/docs/SinglePhasePoromechanics_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/SinglePhasePoromechanics_other.rst +++ b/src/coreComponents/schema/docs/SinglePhasePoromechanics_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst b/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst index c874c188464..5b4f62fa9a3 100644 --- a/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseProppantFVM_other.rst @@ -1,12 +1,12 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/SinglePhaseReservoir_other.rst b/src/coreComponents/schema/docs/SinglePhaseReservoir_other.rst index aa08bcefbb0..7acea5a6dbf 100644 --- a/src/coreComponents/schema/docs/SinglePhaseReservoir_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseReservoir_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/SinglePhaseWell_other.rst b/src/coreComponents/schema/docs/SinglePhaseWell_other.rst index b3804961a57..48a09333642 100644 --- a/src/coreComponents/schema/docs/SinglePhaseWell_other.rst +++ b/src/coreComponents/schema/docs/SinglePhaseWell_other.rst @@ -1,14 +1,14 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -WellControls node :ref:`DATASTRUCTURE_WellControls` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +WellControls node :ref:`DATASTRUCTURE_WellControls` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/SolidMechanicsEmbeddedFractures_other.rst b/src/coreComponents/schema/docs/SolidMechanicsEmbeddedFractures_other.rst index aa08bcefbb0..7acea5a6dbf 100644 --- a/src/coreComponents/schema/docs/SolidMechanicsEmbeddedFractures_other.rst +++ b/src/coreComponents/schema/docs/SolidMechanicsEmbeddedFractures_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/SolidMechanicsLagrangianSSLE_other.rst b/src/coreComponents/schema/docs/SolidMechanicsLagrangianSSLE_other.rst index d6506d6fedf..8ab18aa4617 100644 --- a/src/coreComponents/schema/docs/SolidMechanicsLagrangianSSLE_other.rst +++ b/src/coreComponents/schema/docs/SolidMechanicsLagrangianSSLE_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxForce real64 The maximum force contribution in the problem domain. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxForce real64 The maximum force contribution in the problem domain. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/SolidMechanics_LagrangianFEM_other.rst b/src/coreComponents/schema/docs/SolidMechanics_LagrangianFEM_other.rst index d6506d6fedf..8ab18aa4617 100644 --- a/src/coreComponents/schema/docs/SolidMechanics_LagrangianFEM_other.rst +++ b/src/coreComponents/schema/docs/SolidMechanics_LagrangianFEM_other.rst @@ -1,13 +1,13 @@ -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ -maxForce real64 The maximum force contribution in the problem domain. -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ================================================================ +========================= =================================================================================================================================================== ================================================================ +Name Type Description +========================= =================================================================================================================================================== ================================================================ +maxForce real64 The maximum force contribution in the problem domain. +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ================================================================ diff --git a/src/coreComponents/schema/docs/SurfaceGenerator_other.rst b/src/coreComponents/schema/docs/SurfaceGenerator_other.rst index 37b9b97583d..96cfc6ecec7 100644 --- a/src/coreComponents/schema/docs/SurfaceGenerator_other.rst +++ b/src/coreComponents/schema/docs/SurfaceGenerator_other.rst @@ -1,18 +1,18 @@ -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -Name Type Description -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== -discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. -failCriterion integer (no description available) -maxStableDt real64 Value of the Maximum Stable Timestep for this solver. -meshTargets geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. -tipEdges LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the tip edges -tipFaces LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the tip faces -tipNodes LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the nodes at the fracture tip -trailingFaces LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the trailing faces -LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` -NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` -========================= =============================================================================================================================================================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +Name Type Description +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== +discretization string Name of discretization object (defined in the :ref:`NumericalMethodsManager`) to use for this solver. For instance, if this is a Finite Element Solver, the name of a :ref:`FiniteElement` should be specified. If this is a Finite Volume Method, the name of a :ref:`FiniteVolume` discretization should be specified. +failCriterion integer (no description available) +maxStableDt real64 Value of the Maximum Stable Timestep for this solver. +meshTargets geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > MeshBody/Region combinations that the solver will be applied to. +tipEdges LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the tip edges +tipFaces LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the tip faces +tipNodes LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the nodes at the fracture tip +trailingFaces LvArray_SortedArray< int, int, LvArray_ChaiBuffer > Set containing all the trailing faces +LinearSolverParameters node :ref:`DATASTRUCTURE_LinearSolverParameters` +NonlinearSolverParameters node :ref:`DATASTRUCTURE_NonlinearSolverParameters` +========================= =================================================================================================================================================== ======================================================================================================================================================================================================================================================================================================================== diff --git a/src/coreComponents/schema/docs/TwoPointFluxApproximation_other.rst b/src/coreComponents/schema/docs/TwoPointFluxApproximation_other.rst index b1b2c45ed80..825f9d230d6 100644 --- a/src/coreComponents/schema/docs/TwoPointFluxApproximation_other.rst +++ b/src/coreComponents/schema/docs/TwoPointFluxApproximation_other.rst @@ -1,15 +1,15 @@ -======================== =============================================================================================================================================================================================================================================================================================== ======================================== -Name Type Description -======================== =============================================================================================================================================================================================================================================================================================== ======================================== -cellStencil geosx_CellElementStencilTPFA (no description available) -coefficientName string Name of coefficient field -edfmStencil geosx_EmbeddedSurfaceToCellStencil (no description available) -faceElementToCellStencil geosx_FaceElementToCellStencil (no description available) -fieldName string Name of primary solution field -fractureStencil geosx_SurfaceElementStencil (no description available) -targetRegions geosx_mapBase< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, LvArray_Array< std___cxx11_basic_string< char, std_char_traits< char >, std_allocator< char > >, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > List of regions to build the stencil for -======================== =============================================================================================================================================================================================================================================================================================== ======================================== +======================== =================================================================================================================================================== ======================================== +Name Type Description +======================== =================================================================================================================================================== ======================================== +cellStencil geosx_CellElementStencilTPFA (no description available) +coefficientName string Name of coefficient field +edfmStencil geosx_EmbeddedSurfaceToCellStencil (no description available) +faceElementToCellStencil geosx_FaceElementToCellStencil (no description available) +fieldName string Name of primary solution field +fractureStencil geosx_SurfaceElementStencil (no description available) +targetRegions geosx_mapBase< std_string, LvArray_Array< std_string, 1, camp_int_seq< long, 0l >, int, LvArray_ChaiBuffer >, std_integral_constant< bool, true > > List of regions to build the stencil for +======================== =================================================================================================================================================== ======================================== diff --git a/src/coreComponents/schema/schema.xsd.other b/src/coreComponents/schema/schema.xsd.other index f490d88124d..fe4e94b4dfa 100644 --- a/src/coreComponents/schema/schema.xsd.other +++ b/src/coreComponents/schema/schema.xsd.other @@ -412,7 +412,7 @@ - + @@ -480,7 +480,7 @@ - + @@ -504,7 +504,7 @@ - + @@ -514,7 +514,7 @@ - + @@ -526,7 +526,7 @@ - + @@ -539,7 +539,7 @@ - + @@ -552,7 +552,7 @@ - + @@ -564,7 +564,7 @@ - + @@ -574,7 +574,7 @@ - + @@ -586,7 +586,7 @@ - + @@ -596,7 +596,7 @@ - + @@ -606,7 +606,7 @@ - + @@ -616,7 +616,7 @@ - + @@ -626,7 +626,7 @@ - + @@ -636,7 +636,7 @@ - + @@ -646,7 +646,7 @@ - + @@ -656,7 +656,7 @@ - + @@ -666,7 +666,7 @@ - + @@ -678,7 +678,7 @@ - + @@ -688,7 +688,7 @@ - + @@ -700,7 +700,7 @@ - + @@ -713,7 +713,7 @@ - + @@ -725,7 +725,7 @@ - + @@ -737,7 +737,7 @@ - + @@ -749,7 +749,7 @@ - + @@ -763,7 +763,7 @@ - + diff --git a/src/coreComponents/unitTests/fluidFlowTests/testThermalCompMultiphaseFlow.cpp b/src/coreComponents/unitTests/fluidFlowTests/testThermalCompMultiphaseFlow.cpp index aef3e69601b..4d2f2a6b86e 100644 --- a/src/coreComponents/unitTests/fluidFlowTests/testThermalCompMultiphaseFlow.cpp +++ b/src/coreComponents/unitTests/fluidFlowTests/testThermalCompMultiphaseFlow.cpp @@ -35,13 +35,11 @@ CommandLineOptions g_commandLineOptions; char const * pvtLiquid = "DensityFun PhillipsBrineDensity 1e6 7.5e7 5e5 295.15 370.15 25 0\n" "ViscosityFun PhillipsBrineViscosity 0\n" - "EnthalpyFun BrineEnthalpy 1e6 7.5e7 5e5 295.15 370.15 25 0\n" - "InternalEnergyFun BrineInternalEnergy\n"; + "EnthalpyFun BrineEnthalpy 1e6 7.5e7 5e5 295.15 370.15 25 0\n"; char const * pvtGas = "DensityFun SpanWagnerCO2Density 1e6 7.5e7 5e5 295.15 370.15 25\n" "ViscosityFun FenghourCO2Viscosity 1e6 7.5e7 5e5 295.15 370.15 25\n" - "EnthalpyFun CO2Enthalpy 1e6 7.5e7 5e5 295.15 370.15 25\n" - "InternalEnergyFun CO2InternalEnergy 1e6 7.5e7 5e5 295.15 370.15 25\n"; + "EnthalpyFun CO2Enthalpy 1e6 7.5e7 5e5 295.15 370.15 25\n"; char const * co2flash = "FlashModel CO2Solubility 1e6 7.5e7 5e5 295.15 370.15 25 0"; @@ -396,6 +394,7 @@ TEST_F( ThermalCompositionalMultiphaseFlowTest, jacobianNumericalCheck_flux ) } ); } +#if 0 TEST_F( ThermalCompositionalMultiphaseFlowTest, jacobianNumericalCheck_accumulationVolumeBalance ) { real64 const perturb = sqrt( eps ); @@ -410,6 +409,7 @@ TEST_F( ThermalCompositionalMultiphaseFlowTest, jacobianNumericalCheck_accumulat solver->assembleAccumulationAndVolumeBalanceTerms( domain, solver->getDofManager(), localMatrix, localRhs ); } ); } +#endif int main( int argc, char * * argv ) { From 7abf516d6e4ccb1538a97cfb87effb8a5928fcc8 Mon Sep 17 00:00:00 2001 From: Francois Hamon Date: Sat, 9 Apr 2022 14:13:17 -0700 Subject: [PATCH 34/34] addressed Sergey's comments --- inputFiles/thermal/co2flash.txt | 1 - inputFiles/thermal/pvtgas.txt | 4 - inputFiles/thermal/pvtliquid.txt | 4 - .../co2_thermal_2d.xml | 0 inputFiles/thermalMultiphaseFlow/co2flash.txt | 1 + inputFiles/thermalMultiphaseFlow/pvtgas.txt | 3 + .../thermalMultiphaseFlow/pvtliquid.txt | 3 + .../fluidFlow/CompositionalMultiphaseFVM.cpp | 73 ++++++----- .../CompositionalMultiphaseHybridFVM.cpp | 82 ++++++------ ...ompositionalMultiphaseHybridFVMKernels.hpp | 8 +- ...rmalCompositionalMultiphaseBaseKernels.hpp | 8 +- ...ermalCompositionalMultiphaseFVMKernels.hpp | 7 +- .../fluidFlow/SinglePhaseBaseKernels.hpp | 16 +-- .../fluidFlow/SinglePhaseFVM.cpp | 16 +-- .../fluidFlow/SinglePhaseHybridFVM.cpp | 72 +++++------ .../fluidFlow/SinglePhaseHybridFVMKernels.hpp | 6 +- ...rmalCompositionalMultiphaseBaseKernels.hpp | 48 ++++--- ...ermalCompositionalMultiphaseFVMKernels.hpp | 117 ++++++++---------- .../wells/CompositionalMultiphaseWell.cpp | 83 ++++++------- .../CompositionalMultiphaseWellKernels.hpp | 18 +-- .../fluidFlow/wells/SinglePhaseWell.cpp | 43 ++++--- .../wells/SinglePhaseWellKernels.hpp | 12 +- .../fluidFlowTests/testCompFlowUtils.hpp | 1 - 23 files changed, 297 insertions(+), 329 deletions(-) delete mode 100644 inputFiles/thermal/co2flash.txt delete mode 100644 inputFiles/thermal/pvtgas.txt delete mode 100644 inputFiles/thermal/pvtliquid.txt rename inputFiles/{thermal => thermalMultiphaseFlow}/co2_thermal_2d.xml (100%) create mode 100644 inputFiles/thermalMultiphaseFlow/co2flash.txt create mode 100644 inputFiles/thermalMultiphaseFlow/pvtgas.txt create mode 100644 inputFiles/thermalMultiphaseFlow/pvtliquid.txt diff --git a/inputFiles/thermal/co2flash.txt b/inputFiles/thermal/co2flash.txt deleted file mode 100644 index af702698fb3..00000000000 --- a/inputFiles/thermal/co2flash.txt +++ /dev/null @@ -1 +0,0 @@ -FlashModel CO2Solubility 1e6 7.5e7 5e4 299.15 370.15 1 0 diff --git a/inputFiles/thermal/pvtgas.txt b/inputFiles/thermal/pvtgas.txt deleted file mode 100644 index 354a3fa63ae..00000000000 --- a/inputFiles/thermal/pvtgas.txt +++ /dev/null @@ -1,4 +0,0 @@ -DensityFun SpanWagnerCO2Density 1e6 7.5e7 5e4 299.15 370.15 1 -ViscosityFun FenghourCO2Viscosity 1e6 7.5e7 5e4 299.15 370.15 1 -EnthalpyFun CO2Enthalpy 1e6 7.5e7 5e4 299.15 370.15 1 -InternalEnergyFun CO2InternalEnergy 1e6 7.5e7 5e4 299.15 370.15 1 diff --git a/inputFiles/thermal/pvtliquid.txt b/inputFiles/thermal/pvtliquid.txt deleted file mode 100644 index 82bead2dde4..00000000000 --- a/inputFiles/thermal/pvtliquid.txt +++ /dev/null @@ -1,4 +0,0 @@ -DensityFun PhillipsBrineDensity 1e6 7.5e7 5e4 299.15 370.15 1 0 -ViscosityFun PhillipsBrineViscosity 0 -EnthalpyFun BrineEnthalpy 1e6 7.5e7 5e4 299.15 370.15 1 0 -InternalEnergyFun BrineInternalEnergy diff --git a/inputFiles/thermal/co2_thermal_2d.xml b/inputFiles/thermalMultiphaseFlow/co2_thermal_2d.xml similarity index 100% rename from inputFiles/thermal/co2_thermal_2d.xml rename to inputFiles/thermalMultiphaseFlow/co2_thermal_2d.xml diff --git a/inputFiles/thermalMultiphaseFlow/co2flash.txt b/inputFiles/thermalMultiphaseFlow/co2flash.txt new file mode 100644 index 00000000000..4c5a766d852 --- /dev/null +++ b/inputFiles/thermalMultiphaseFlow/co2flash.txt @@ -0,0 +1 @@ +FlashModel CO2Solubility 1e6 7.5e7 5e5 299.15 369.15 10 0 diff --git a/inputFiles/thermalMultiphaseFlow/pvtgas.txt b/inputFiles/thermalMultiphaseFlow/pvtgas.txt new file mode 100644 index 00000000000..ccd4e817f67 --- /dev/null +++ b/inputFiles/thermalMultiphaseFlow/pvtgas.txt @@ -0,0 +1,3 @@ +DensityFun SpanWagnerCO2Density 1e6 7.5e7 5e5 299.15 369.15 10 +ViscosityFun FenghourCO2Viscosity 1e6 7.5e7 5e5 299.15 369.15 10 +EnthalpyFun CO2Enthalpy 1e6 7.5e7 5e5 299.15 369.15 10 diff --git a/inputFiles/thermalMultiphaseFlow/pvtliquid.txt b/inputFiles/thermalMultiphaseFlow/pvtliquid.txt new file mode 100644 index 00000000000..4df0c25f042 --- /dev/null +++ b/inputFiles/thermalMultiphaseFlow/pvtliquid.txt @@ -0,0 +1,3 @@ +DensityFun PhillipsBrineDensity 1e6 7.5e7 5e5 299.15 369.15 10 0 +ViscosityFun PhillipsBrineViscosity 0 +EnthalpyFun BrineEnthalpy 1e6 7.5e7 5e5 299.15 369.15 10 0 diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp index 59c284df640..1352c293da8 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp @@ -354,37 +354,35 @@ real64 CompositionalMultiphaseFVM::calculateResidualNorm( DomainPartition const thermalCompositionalMultiphaseBaseKernels:: ResidualNormKernel:: - launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - numFluidPhases(), - numFluidComponents(), - dofNumber, - elemGhostRank, - referencePorosity, - volume, - solidInternalEnergyOld, - phaseVolFracOld, - totalDensOld, - phaseDensOld, - phaseInternalEnergyOld, - subRegionFlowResidualNorm, - subRegionEnergyResidualNorm ); + launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + numFluidPhases(), + numFluidComponents(), + dofNumber, + elemGhostRank, + referencePorosity, + volume, + solidInternalEnergyOld, + phaseVolFracOld, + totalDensOld, + phaseDensOld, + phaseInternalEnergyOld, + subRegionFlowResidualNorm, + subRegionEnergyResidualNorm ); } else { isothermalCompositionalMultiphaseBaseKernels:: ResidualNormKernel:: - launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - numFluidComponents(), - dofNumber, - elemGhostRank, - referencePorosity, - volume, - totalDensOld, - subRegionFlowResidualNorm ); + launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + numFluidComponents(), + dofNumber, + elemGhostRank, + referencePorosity, + volume, + totalDensOld, + subRegionFlowResidualNorm ); } localFlowResidualNorm += subRegionFlowResidualNorm; localEnergyResidualNorm += subRegionEnergyResidualNorm; @@ -528,18 +526,17 @@ bool CompositionalMultiphaseFVM::checkSystemSolution( DomainPartition const & do localIndex const subRegionSolutionCheck = isothermalCompositionalMultiphaseBaseKernels:: - SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - dofManager.rankOffset(), - numFluidComponents(), - dofNumber, - elemGhostRank, - pres, - dPres, - compDens, - dCompDens, - m_allowCompDensChopping, - scalingFactor ); + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + dofManager.rankOffset(), + numFluidComponents(), + dofNumber, + elemGhostRank, + pres, + dPres, + compDens, + dCompDens, + m_allowCompDensChopping, + scalingFactor ); localCheck = std::min( localCheck, subRegionSolutionCheck ); } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp index d26ddd99eac..215ab9690ca 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.cpp @@ -676,18 +676,17 @@ bool CompositionalMultiphaseHybridFVM::checkSystemSolution( DomainPartition cons localIndex const subRegionSolutionCheck = isothermalCompositionalMultiphaseBaseKernels:: - SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - dofManager.rankOffset(), - numFluidComponents(), - elemDofNumber, - elemGhostRank, - elemPres, - dElemPres, - compDens, - dCompDens, - m_allowCompDensChopping, - scalingFactor ); + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + dofManager.rankOffset(), + numFluidComponents(), + elemDofNumber, + elemGhostRank, + elemPres, + dElemPres, + compDens, + dCompDens, + m_allowCompDensChopping, + scalingFactor ); localCheck = std::min( localCheck, subRegionSolutionCheck ); } ); @@ -705,14 +704,13 @@ bool CompositionalMultiphaseHybridFVM::checkSystemSolution( DomainPartition cons localIndex const faceSolutionCheck = compositionalMultiphaseHybridFVMKernels:: - SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - dofManager.rankOffset(), - faceDofNumber, - faceGhostRank, - facePres, - dFacePres, - scalingFactor ); + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + dofManager.rankOffset(), + faceDofNumber, + faceGhostRank, + facePres, + dFacePres, + scalingFactor ); localCheck = std::min( localCheck, faceSolutionCheck ); } ); @@ -810,16 +808,15 @@ real64 CompositionalMultiphaseHybridFVM::calculateResidualNorm( DomainPartition real64 subRegionResidualNorm = 0.0; isothermalCompositionalMultiphaseBaseKernels:: - ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - numFluidComponents(), - elemDofNumber, - elemGhostRank, - referencePorosity, - volume, - totalDensOld, - subRegionResidualNorm ); + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + numFluidComponents(), + elemDofNumber, + elemGhostRank, + referencePorosity, + volume, + totalDensOld, + subRegionResidualNorm ); localResidualNorm += subRegionResidualNorm; } ); @@ -834,19 +831,18 @@ real64 CompositionalMultiphaseHybridFVM::calculateResidualNorm( DomainPartition // 2. Compute the residual for the face-based constraints real64 faceResidualNorm = 0.0; compositionalMultiphaseHybridFVMKernels:: - ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - numFluidPhases(), - faceDofNumber.toNestedViewConst(), - faceGhostRank.toNestedViewConst(), - m_regionFilter.toViewConst(), - elemRegionList.toNestedViewConst(), - elemSubRegionList.toNestedViewConst(), - elemList.toNestedViewConst(), - compFlowAccessors.get( extrinsicMeshData::elementVolume{} ), - compFlowAccessors.get( extrinsicMeshData::flow::phaseMobilityOld{} ), - faceResidualNorm ); + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + numFluidPhases(), + faceDofNumber.toNestedViewConst(), + faceGhostRank.toNestedViewConst(), + m_regionFilter.toViewConst(), + elemRegionList.toNestedViewConst(), + elemSubRegionList.toNestedViewConst(), + elemList.toNestedViewConst(), + compFlowAccessors.get( extrinsicMeshData::elementVolume{} ), + compFlowAccessors.get( extrinsicMeshData::flow::phaseMobilityOld{} ), + faceResidualNorm ); localResidualNorm += faceResidualNorm; } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp index e48e61ba297..22830ba8096 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVMKernels.hpp @@ -868,7 +868,7 @@ struct ResidualNormKernel template< typename VIEWTYPE > using ElementViewConst = ElementRegionManager::ElementViewConst< VIEWTYPE >; - template< typename POLICY, typename REDUCE_POLICY > + template< typename POLICY > static void launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, @@ -883,7 +883,7 @@ struct ResidualNormKernel ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const & phaseMobOld, real64 & localResidualNorm ) { - RAJA::ReduceSum< REDUCE_POLICY, real64 > sumScaled( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > sumScaled( 0.0 ); forAll< POLICY >( facePresDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iface ) { @@ -933,7 +933,7 @@ struct ResidualNormKernel struct SolutionCheckKernel { - template< typename POLICY, typename REDUCE_POLICY > + template< typename POLICY > static localIndex launch( arrayView1d< real64 const > const & localSolution, globalIndex const rankOffset, @@ -943,7 +943,7 @@ struct SolutionCheckKernel arrayView1d< real64 const > const & dFacePres, real64 const scalingFactor ) { - RAJA::ReduceMin< REDUCE_POLICY, integer > check( 1 ); + RAJA::ReduceMin< ReducePolicy< POLICY >, integer > check( 1 ); forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iface ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp index 3834dc0a491..d1e6004547f 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseBaseKernels.hpp @@ -931,7 +931,7 @@ class ElementBasedAssemblyKernelFactory struct ResidualNormKernel { - template< typename POLICY, typename REDUCE_POLICY > + template< typename POLICY > static void launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, integer const numComponents, @@ -942,7 +942,7 @@ struct ResidualNormKernel arrayView2d< real64 const, multifluid::USD_FLUID > const & totalDensOld, real64 & localResidualNorm ) { - RAJA::ReduceSum< REDUCE_POLICY, real64 > localSum( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > localSum( 0.0 ); forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { @@ -968,7 +968,7 @@ struct ResidualNormKernel struct SolutionCheckKernel { - template< typename POLICY, typename REDUCE_POLICY > + template< typename POLICY > static localIndex launch( arrayView1d< real64 const > const & localSolution, globalIndex const rankOffset, @@ -984,7 +984,7 @@ struct SolutionCheckKernel { real64 constexpr eps = minDensForDivision; - RAJA::ReduceMin< REDUCE_POLICY, integer > check( 1 ); + RAJA::ReduceMin< ReducePolicy< POLICY >, integer > check( 1 ); forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index 2e91e2e7797..ae27f201998 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -841,9 +841,11 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase * @param[in] iconn the connection index * @param[inout] stack the stack variables */ + template< typename FUNC = isothermalCompositionalMultiphaseBaseKernels::NoOpFunc > GEOSX_HOST_DEVICE void complete( localIndex const iconn, - StackVariables & stack ) const + StackVariables & stack, + FUNC && assemblyKernelOp = isothermalCompositionalMultiphaseBaseKernels::NoOpFunc{} ) const { using namespace compositionalMultiphaseUtilities; @@ -875,6 +877,9 @@ class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase stack.localFluxJacobian[i * numEqn + ic].dataIfContiguous(), stack.stencilSize * numDof ); } + + // call the lambda to assemble additional terms, such as thermal terms + assemblyKernelOp( i, localRow ); } } } diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.hpp index 4f940401491..fe0316ad1ef 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseBaseKernels.hpp @@ -274,8 +274,8 @@ struct FluidUpdateKernel struct ResidualNormKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > - static void launch( LOCAL_VECTOR const localResidual, + template< typename POLICY > + static void launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, arrayView1d< globalIndex const > const & presDofNumber, arrayView1d< integer const > const & ghostRank, @@ -284,9 +284,9 @@ struct ResidualNormKernel arrayView2d< real64 const > const & poroOld, real64 * localResidualNorm ) { - RAJA::ReduceSum< REDUCE_POLICY, real64 > localSum( 0.0 ); - RAJA::ReduceSum< REDUCE_POLICY, real64 > normSum( 0.0 ); - RAJA::ReduceSum< REDUCE_POLICY, localIndex > count( 0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > localSum( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > normSum( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, localIndex > count( 0 ); forAll< POLICY >( presDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const a ) { @@ -310,8 +310,8 @@ struct ResidualNormKernel struct SolutionCheckKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > - static localIndex launch( LOCAL_VECTOR const localSolution, + template< typename POLICY > + static localIndex launch( arrayView1d< real64 const > const & localSolution, globalIndex const rankOffset, arrayView1d< globalIndex const > const & presDofNumber, arrayView1d< integer const > const & ghostRank, @@ -319,7 +319,7 @@ struct SolutionCheckKernel arrayView1d< real64 const > const & dPres, real64 const scalingFactor ) { - RAJA::ReduceMin< REDUCE_POLICY, localIndex > minVal( 1 ); + RAJA::ReduceMin< ReducePolicy< POLICY >, localIndex > minVal( 1 ); forAll< POLICY >( presDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp index b3a849e626c..5f304c1fd3c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp @@ -137,14 +137,14 @@ real64 SinglePhaseFVM< BASE >::calculateResidualNorm( DomainPartition const & do arrayView2d< real64 const > const & porosityOld = solidModel.getOldPorosity(); - ResidualNormKernel::launch< parallelDevicePolicy<>, parallelDeviceReduce >( localRhs, - rankOffset, - dofNumber, - elemGhostRank, - volume, - densOld, - porosityOld, - localResidualNorm ); + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + dofNumber, + elemGhostRank, + volume, + densOld, + porosityOld, + localResidualNorm ); } ); diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp index 6c7b867463e..fbeebaf2527 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVM.cpp @@ -478,15 +478,15 @@ real64 SinglePhaseHybridFVM::calculateResidualNorm( DomainPartition const & doma { arrayView2d< real64 const > const & porosityOld = castedSolidModel.getOldPorosity(); - singlePhaseBaseKernels::ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - elemDofNumber, - elemGhostRank, - volume, - densOld, - porosityOld, - localResidualNorm ); + singlePhaseBaseKernels:: + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + elemDofNumber, + elemGhostRank, + volume, + densOld, + porosityOld, + localResidualNorm ); } ); string const & fluidName = subRegion.getReference< string >( viewKeyStruct::fluidNamesString() ); @@ -506,17 +506,17 @@ real64 SinglePhaseHybridFVM::calculateResidualNorm( DomainPartition const & doma defaultViscosity /= subRegionCounter; // 2. Compute the residual for the face-based constraints - singlePhaseHybridFVMKernels::ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - rankOffset, - faceDofNumber.toNestedViewConst(), - faceGhostRank.toNestedViewConst(), - elemRegionList.toNestedViewConst(), - elemSubRegionList.toNestedViewConst(), - elemList.toNestedViewConst(), - flowAccessors.get( extrinsicMeshData::elementVolume{} ), - defaultViscosity, - &localResidualNorm[3] ); + singlePhaseHybridFVMKernels:: + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + rankOffset, + faceDofNumber.toNestedViewConst(), + faceGhostRank.toNestedViewConst(), + elemRegionList.toNestedViewConst(), + elemSubRegionList.toNestedViewConst(), + elemList.toNestedViewConst(), + flowAccessors.get( extrinsicMeshData::elementVolume{} ), + defaultViscosity, + &localResidualNorm[3] ); } ); @@ -572,14 +572,14 @@ bool SinglePhaseHybridFVM::checkSystemSolution( DomainPartition const & domain, subRegion.getExtrinsicData< extrinsicMeshData::flow::deltaPressure >(); localIndex const subRegionSolutionCheck = - singlePhaseBaseKernels::SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - rankOffset, - elemDofNumber, - elemGhostRank, - pres, - dPres, - scalingFactor ); + singlePhaseBaseKernels:: + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + rankOffset, + elemDofNumber, + elemGhostRank, + pres, + dPres, + scalingFactor ); if( subRegionSolutionCheck == 0 ) { @@ -599,14 +599,14 @@ bool SinglePhaseHybridFVM::checkSystemSolution( DomainPartition const & domain, localIndex const faceSolutionCheck = - singlePhaseBaseKernels::SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - rankOffset, - faceDofNumber, - faceGhostRank, - facePres, - dFacePres, - scalingFactor ); + singlePhaseBaseKernels:: + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + rankOffset, + faceDofNumber, + faceGhostRank, + facePres, + dFacePres, + scalingFactor ); if( faceSolutionCheck == 0 ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp index 56e7108b826..02b7159afe4 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseHybridFVMKernels.hpp @@ -638,9 +638,9 @@ struct ResidualNormKernel template< typename VIEWTYPE > using ElementViewConst = typename ElementRegionManager::ElementViewConst< VIEWTYPE >; - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > + template< typename POLICY > static void - launch( LOCAL_VECTOR const localResidual, + launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, arrayView1d< globalIndex const > const & facePresDofNumber, arrayView1d< integer const > const & faceGhostRank, @@ -652,7 +652,7 @@ struct ResidualNormKernel real64 * localResidualNorm ) { - RAJA::ReduceSum< REDUCE_POLICY, real64 > sumScaled( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > sumScaled( 0.0 ); forAll< POLICY >( facePresDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iface ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp index eca03741985..83c2021756e 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseBaseKernels.hpp @@ -74,10 +74,10 @@ class PhaseVolumeFractionKernel : public isothermalCompositionalMultiphaseBaseKe LvArray::forValuesInSlice( dPhaseVolFrac_dTemp, []( real64 & val ){ val = 0.0; } ); // Call the base compute the compute the phase volume fraction - Base::compute( ei, [=] GEOSX_HOST_DEVICE ( localIndex const ip, - real64 const & phaseVolFrac, - real64 const & phaseDensInv, - real64 const & totalDensity ) + Base::compute( ei, [&] ( localIndex const ip, + real64 const & phaseVolFrac, + real64 const & phaseDensInv, + real64 const & totalDensity ) { // when this lambda is called, we are in the phase loop // for each phase ip, compute the derivative of phase volume fraction wrt temperature @@ -277,15 +277,11 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK { using Deriv = multifluid::DerivativeOffset; - // I did not find another way to pass the stack.localResidual to the lambda - real64 * localResidualPtr = stack.localResidual; - real64 ( *localJacobianPtr )[numDof] = stack.localJacobian; - - Base::computeAccumulation( ei, stack, [=] GEOSX_HOST_DEVICE ( integer const ip, - real64 const & phaseAmountNew, - real64 const & phaseAmountOld, - real64 const & dPhaseAmount_dP, - real64 const (&dPhaseAmount_dC)[numComp] ) + Base::computeAccumulation( ei, stack, [&] ( integer const ip, + real64 const & phaseAmountNew, + real64 const & phaseAmountOld, + real64 const & dPhaseAmount_dP, + real64 const (&dPhaseAmount_dC)[numComp] ) { // We are in the loop over phases, ip provides the current phase index. // We have to do two things: @@ -312,8 +308,8 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK * (dPhaseVolFrac_dTemp[ip] * phaseDens[ip] + phaseVolFrac[ip] * dPhaseDens[ip][Deriv::dT] ); for( integer ic = 0; ic < numComp; ++ic ) { - localJacobianPtr[ic][numDof-1] += dPhaseAmount_dT * phaseCompFrac[ip][ic] - + phaseAmountNew * dPhaseCompFrac[ip][ic][Deriv::dT]; + stack.localJacobian[ic][numDof-1] += dPhaseAmount_dT * phaseCompFrac[ip][ic] + + phaseAmountNew * dPhaseCompFrac[ip][ic][Deriv::dT]; } // Step 2: assemble the phase-dependent part of the accumulation term of the energy equation @@ -326,18 +322,18 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK + phaseAmountNew * dPhaseInternalEnergy[ip][Deriv::dT]; // local accumulation - localResidualPtr[numEqn-1] += phaseEnergyNew - phaseEnergyOld; + stack.localResidual[numEqn-1] += phaseEnergyNew - phaseEnergyOld; // derivatives w.r.t. pressure and temperature - localJacobianPtr[numEqn-1][0] += dPhaseEnergy_dP; - localJacobianPtr[numEqn-1][numDof-1] += dPhaseEnergy_dT; + stack.localJacobian[numEqn-1][0] += dPhaseEnergy_dP; + stack.localJacobian[numEqn-1][numDof-1] += dPhaseEnergy_dT; // derivatives w.r.t. component densities applyChainRule( numComp, dCompFrac_dCompDens, dPhaseInternalEnergy[ip], dPhaseInternalEnergy_dC, Deriv::dC ); for( integer jc = 0; jc < numComp; ++jc ) { - localJacobianPtr[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] - + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; + stack.localJacobian[numEqn-1][jc + 1] += phaseInternalEnergy[ip] * dPhaseAmount_dC[jc] + + dPhaseInternalEnergy_dC[jc] * phaseAmountNew; } } ); @@ -360,9 +356,7 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK void computeVolumeBalance( localIndex const ei, StackVariables & stack ) const { - real64 ( *localJacobianPtr )[numDof] = stack.localJacobian; - - Base::computeVolumeBalance( ei, stack, [=] GEOSX_HOST_DEVICE ( real64 const & oneMinusPhaseVolFraction ) + Base::computeVolumeBalance( ei, stack, [&] ( real64 const & oneMinusPhaseVolFraction ) { GEOSX_UNUSED_VAR( oneMinusPhaseVolFraction ); @@ -370,7 +364,7 @@ class ElementBasedAssemblyKernel : public isothermalCompositionalMultiphaseBaseK for( integer ip = 0; ip < m_numPhases; ++ip ) { - localJacobianPtr[numEqn-2][numDof-1] -= dPhaseVolFrac_dTemp[ip]; + stack.localJacobian[numEqn-2][numDof-1] -= dPhaseVolFrac_dTemp[ip]; } } ); } @@ -556,7 +550,7 @@ struct SolidInternalEnergyUpdateKernel struct ResidualNormKernel { - template< typename POLICY, typename REDUCE_POLICY > + template< typename POLICY > static void launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, integer const numComponents, @@ -573,8 +567,8 @@ struct ResidualNormKernel real64 & localFlowResidualNorm, real64 & localEnergyResidualNorm ) { - RAJA::ReduceSum< REDUCE_POLICY, real64 > localFlowSum( 0.0 ); - RAJA::ReduceSum< REDUCE_POLICY, real64 > localEnergySum( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > localFlowSum( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > localEnergySum( 0.0 ); forAll< POLICY >( dofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index 168300a6c89..0006f5919fa 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -85,10 +85,10 @@ class PhaseMobilityKernel : public isothermalCompositionalMultiphaseFVMKernels:: arraySlice1d< real64, compflow::USD_PHASE - 1 > const dPhaseMob_dTemp = m_dPhaseMob_dTemp[ei]; LvArray::forValuesInSlice( dPhaseMob_dTemp, []( real64 & val ){ val = 0.0; } ); - Base::compute( ei, [=] GEOSX_HOST_DEVICE ( localIndex const ip, - real64 const & phaseMob, - real64 const & GEOSX_UNUSED_PARAM( dPhaseMob_dPres ), - arraySlice1d< real64 const, compflow::USD_PHASE_DC - 2 > const & GEOSX_UNUSED_PARAM( dPhaseMob_dComp ) ) + Base::compute( ei, [&] ( localIndex const ip, + real64 const & phaseMob, + real64 const & GEOSX_UNUSED_PARAM( dPhaseMob_dPres ), + arraySlice1d< real64 const, compflow::USD_PHASE_DC - 2 > const & GEOSX_UNUSED_PARAM( dPhaseMob_dComp ) ) { // Step 1: compute the derivative of relPerm[ip] wrt temperature real64 dRelPerm_dT = 0.0; @@ -199,7 +199,6 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne using AbstractBase::m_numPhases; using AbstractBase::m_hasCapPressure; using AbstractBase::m_rankOffset; - using AbstractBase::m_ghostRank; using AbstractBase::m_dofNumber; using AbstractBase::m_gravCoef; using AbstractBase::m_phaseMob; @@ -346,14 +345,6 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne { using Deriv = multifluid::DerivativeOffset; - arraySlice2d< real64 > dCompFlux_dTSlice = stack.dCompFlux_dT.toSlice(); - - // I did not find another way to pass the stack.energyFlux to the lambda... - real64 * energyFluxPtr = &(stack.energyFlux); - arraySlice1d< real64 > dEnergyFlux_dPSlice = stack.dEnergyFlux_dP.toSlice(); - arraySlice1d< real64 > dEnergyFlux_dTSlice = stack.dEnergyFlux_dT.toSlice(); - arraySlice2d< real64 > dEnergyFlux_dCSlice = stack.dEnergyFlux_dC.toSlice(); - // *********************************************** // First, we call the base computeFlux to compute: // 1) compFlux and its derivatives (including derivatives wrt temperature), @@ -362,15 +353,15 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne // Computing dCompFlux_dT and the enthalpy flux requires quantities already computed in the base computeFlux, // such as potGrad, phaseFlux, and the indices of the upwind cell // We use the lambda below (called **inside** the phase loop of the base computeFlux) to access these variables - Base::computeFlux( iconn, stack, [=] GEOSX_HOST_DEVICE ( integer const ip, - localIndex const k_up, - localIndex const er_up, - localIndex const esr_up, - localIndex const ei_up, - real64 const & potGrad, - real64 const & phaseFlux, - real64 const (&dPhaseFlux_dP)[maxStencilSize], - real64 const (&dPhaseFlux_dC)[maxStencilSize][numComp] ) + Base::computeFlux( iconn, stack, [&] ( integer const ip, + localIndex const k_up, + localIndex const er_up, + localIndex const esr_up, + localIndex const ei_up, + real64 const & potGrad, + real64 const & phaseFlux, + real64 const (&dPhaseFlux_dP)[maxStencilSize], + real64 const (&dPhaseFlux_dC)[maxStencilSize][numComp] ) { GEOSX_UNUSED_VAR( dPhaseFlux_dP, dPhaseFlux_dC ); @@ -415,7 +406,7 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne } // Step 2.2: compute derivative of phase pressure difference wrt temperature - dPresGrad_dT[i] += stack.transmissibility[0][i] * (1 - dCapPressure_dT); + dPresGrad_dT[i] -= stack.transmissibility[0][i] * dCapPressure_dT; real64 const gravD = stack.transmissibility[0][i] * m_gravCoef[er][esr][ei]; // Step 2.3: compute derivative of gravity potential difference wrt temperature @@ -461,29 +452,29 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne real64 const ycp = phaseCompFracSub[ic]; for( integer ke = 0; ke < stack.stencilSize; ++ke ) { - dCompFlux_dTSlice[ke][ic] += dPhaseFlux_dT[ke] * ycp; + stack.dCompFlux_dT[ke][ic] += dPhaseFlux_dT[ke] * ycp; } - dCompFlux_dTSlice[k_up][ic] += phaseFlux * dPhaseCompFracSub[ic][Deriv::dT]; + stack.dCompFlux_dT[k_up][ic] += phaseFlux * dPhaseCompFracSub[ic][Deriv::dT]; } // Step 4: compute the enthalpy flux real64 const enthalpy = m_phaseEnthalpy[er_up][esr_up][ei_up][0][ip]; - *energyFluxPtr += phaseFlux * enthalpy; + stack.energyFlux += phaseFlux * enthalpy; for( integer ke = 0; ke < stack.stencilSize; ++ke ) { - dEnergyFlux_dPSlice[ke] += dPhaseFlux_dP[ke] * enthalpy; - dEnergyFlux_dTSlice[ke] += dPhaseFlux_dT[ke] * enthalpy; + stack.dEnergyFlux_dP[ke] += dPhaseFlux_dP[ke] * enthalpy; + stack.dEnergyFlux_dT[ke] += dPhaseFlux_dT[ke] * enthalpy; for( integer jc = 0; jc < numComp; ++jc ) { - dEnergyFlux_dCSlice[ke][jc] += dPhaseFlux_dC[ke][jc] * enthalpy; + stack.dEnergyFlux_dC[ke][jc] += dPhaseFlux_dC[ke][jc] * enthalpy; } } - dEnergyFlux_dPSlice[k_up] += phaseFlux * m_dPhaseEnthalpy[er_up][esr_up][ei_up][0][ip][Deriv::dP]; - dEnergyFlux_dTSlice[k_up] += phaseFlux * m_dPhaseEnthalpy[er_up][esr_up][ei_up][0][ip][Deriv::dT]; + stack.dEnergyFlux_dP[k_up] += phaseFlux * m_dPhaseEnthalpy[er_up][esr_up][ei_up][0][ip][Deriv::dP]; + stack.dEnergyFlux_dT[k_up] += phaseFlux * m_dPhaseEnthalpy[er_up][esr_up][ei_up][0][ip][Deriv::dT]; real64 dProp_dC[numComp]{}; applyChainRule( numComp, @@ -493,7 +484,7 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne Deriv::dC ); for( integer jc = 0; jc < numComp; ++jc ) { - dEnergyFlux_dCSlice[k_up][jc] += phaseFlux * dProp_dC[jc]; + stack.dEnergyFlux_dC[k_up][jc] += phaseFlux * dProp_dC[jc]; } } ); @@ -572,28 +563,20 @@ class FaceBasedAssemblyKernel : public isothermalCompositionalMultiphaseFVMKerne void complete( localIndex const iconn, StackVariables & stack ) const { - // Step 1: assemble the component mass balance equations (i = 0 to i = numDof-2) - Base::complete( iconn, stack ); - - // Step 2: add contribution to residual and jacobian into the energy balance equation - for( integer i = 0; i < stack.numFluxElems; ++i ) + // Call Case::complete to assemble the component mass balance equations (i = 0 to i = numDof-2) + // In the lambda, add contribution to residual and jacobian into the energy balance equation + Base::complete( iconn, stack, [&] ( integer const i, + localIndex const localRow ) { - if( m_ghostRank[m_seri( iconn, i )][m_sesri( iconn, i )][m_sei( iconn, i )] < 0 ) - { - globalIndex const globalRow = m_dofNumber[m_seri( iconn, i )][m_sesri( iconn, i )][m_sei( iconn, i )]; - localIndex const localRow = LvArray::integerConversion< localIndex >( globalRow - m_rankOffset ); - GEOSX_ASSERT_GE( localRow, 0 ); - GEOSX_ASSERT_GT( AbstractBase::m_localMatrix.numRows(), localRow + numEqn ); - - // beware, there is volume balance eqn in m_localRhs and m_localMatrix! - RAJA::atomicAdd( parallelDeviceAtomic{}, &AbstractBase::m_localRhs[localRow + numEqn], stack.localFlux[i * numEqn + numEqn-1] ); - AbstractBase::m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic > - ( localRow + numEqn, - stack.dofColIndices.data(), - stack.localFluxJacobian[i * numEqn + numEqn-1].dataIfContiguous(), - stack.stencilSize * numDof ); - } - } + // beware, there is volume balance eqn in m_localRhs and m_localMatrix! + RAJA::atomicAdd( parallelDeviceAtomic{}, &AbstractBase::m_localRhs[localRow + numEqn], stack.localFlux[i * numEqn + numEqn-1] ); + AbstractBase::m_localMatrix.addToRowBinarySearchUnsorted< parallelDeviceAtomic > + ( localRow + numEqn, + stack.dofColIndices.data(), + stack.localFluxJacobian[i * numEqn + numEqn-1].dataIfContiguous(), + stack.stencilSize * numDof ); + + } ); } protected: @@ -663,20 +646,20 @@ class FaceBasedAssemblyKernelFactory elemManager.constructArrayViewAccessor< globalIndex, 1 >( dofKey ); dofNumberAccessor.setName( solverName + "/accessors/" + dofKey ); - using KERNEL_TYPE = FaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, STENCILWRAPPER >; - typename KERNEL_TYPE::CompFlowAccessors compFlowAccessors( elemManager, solverName ); - typename KERNEL_TYPE::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, solverName ); - typename KERNEL_TYPE::MultiFluidAccessors multiFluidAccessors( elemManager, solverName ); - typename KERNEL_TYPE::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, solverName ); - typename KERNEL_TYPE::CapPressureAccessors capPressureAccessors( elemManager, solverName ); - typename KERNEL_TYPE::PermeabilityAccessors permeabilityAccessors( elemManager, solverName ); - typename KERNEL_TYPE::ThermalConductivityAccessors thermalConductivityAccessors( elemManager, solverName ); - - KERNEL_TYPE kernel( numPhases, rankOffset, hasCapPressure, stencilWrapper, dofNumberAccessor, - compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, - capPressureAccessors, permeabilityAccessors, thermalConductivityAccessors, - dt, localMatrix, localRhs ); - KERNEL_TYPE::template launch< POLICY >( stencilWrapper.size(), kernel ); + using KernelType = FaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, STENCILWRAPPER >; + typename KernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName ); + typename KernelType::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, solverName ); + typename KernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName ); + typename KernelType::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, solverName ); + typename KernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName ); + typename KernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName ); + typename KernelType::ThermalConductivityAccessors thermalConductivityAccessors( elemManager, solverName ); + + KernelType kernel( numPhases, rankOffset, hasCapPressure, stencilWrapper, dofNumberAccessor, + compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, + capPressureAccessors, permeabilityAccessors, thermalConductivityAccessors, + dt, localMatrix, localRhs ); + KernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); } ); } }; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp index b2bf31f37d0..d6a4421f16c 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWell.cpp @@ -1184,25 +1184,24 @@ CompositionalMultiphaseWell::calculateResidualNorm( DomainPartition const & doma WellControls const & wellControls = getWellControls( subRegion ); - ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - dofManager.rankOffset(), - subRegion.isLocallyOwned(), - subRegion.getTopWellElementIndex(), - m_numComponents, - numDofPerWellElement(), - m_targetPhaseIndex, - wellControls, - wellElemDofNumber, - wellElemGhostRank, - wellElemVolume, - wellElemPhaseDensOld, - wellElemTotalDensOld, - m_currentTime + m_currentDt, // residual normalized with rate of the end of the - // time - // interval - m_currentDt, - &localResidualNorm ); + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + dofManager.rankOffset(), + subRegion.isLocallyOwned(), + subRegion.getTopWellElementIndex(), + m_numComponents, + numDofPerWellElement(), + m_targetPhaseIndex, + wellControls, + wellElemDofNumber, + wellElemGhostRank, + wellElemVolume, + wellElemPhaseDensOld, + wellElemTotalDensOld, + m_currentTime + m_currentDt, // residual normalized with rate of the end of the + // time + // interval + m_currentDt, + &localResidualNorm ); } ); } ); return sqrt( MpiWrapper::sum( localResidualNorm, MPI_COMM_GEOSX ) ); @@ -1253,18 +1252,17 @@ CompositionalMultiphaseWell::scalingForSystemSolution( DomainPartition const & d real64 const subRegionScalingFactor = - SolutionScalingKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - dofManager.rankOffset(), - numFluidComponents(), - wellElemDofNumber, - wellElemGhostRank, - wellElemPressure, - dWellElemPressure, - wellElemCompDens, - dWellElemCompDens, - m_maxRelativePresChange, - m_maxCompFracChange ); + SolutionScalingKernel::launch< parallelDevicePolicy<> >( localSolution, + dofManager.rankOffset(), + numFluidComponents(), + wellElemDofNumber, + wellElemGhostRank, + wellElemPressure, + dWellElemPressure, + wellElemCompDens, + dWellElemCompDens, + m_maxRelativePresChange, + m_maxCompFracChange ); if( subRegionScalingFactor < scalingFactor ) @@ -1316,18 +1314,17 @@ CompositionalMultiphaseWell::checkSystemSolution( DomainPartition const & domain subRegion.getExtrinsicData< extrinsicMeshData::well::deltaGlobalCompDensity >(); localIndex const subRegionSolutionCheck = - SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - dofManager.rankOffset(), - numFluidComponents(), - wellElemDofNumber, - wellElemGhostRank, - wellElemPressure, - dWellElemPressure, - wellElemCompDens, - dWellElemCompDens, - m_allowCompDensChopping, - scalingFactor ); + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + dofManager.rankOffset(), + numFluidComponents(), + wellElemDofNumber, + wellElemGhostRank, + wellElemPressure, + dWellElemPressure, + wellElemCompDens, + dWellElemCompDens, + m_allowCompDensChopping, + scalingFactor ); if( subRegionSolutionCheck == 0 ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp index 2ecc6eeccc1..361938c0c68 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellKernels.hpp @@ -658,9 +658,9 @@ class TotalMassDensityKernelFactory struct ResidualNormKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > + template< typename POLICY > static void - launch( LOCAL_VECTOR const localResidual, + launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, bool const isLocallyOwned, localIndex const iwelemControl, @@ -687,7 +687,7 @@ struct ResidualNormKernel real64 const absTargetTotalRate = LvArray::math::abs( targetTotalRate ); real64 const absTargetPhaseRate = LvArray::math::abs( targetPhaseRate ); - RAJA::ReduceSum< REDUCE_POLICY, real64 > sumScaled( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > sumScaled( 0.0 ); forAll< POLICY >( wellElemDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { @@ -774,9 +774,9 @@ struct ResidualNormKernel struct SolutionScalingKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > + template< typename POLICY > static real64 - launch( LOCAL_VECTOR const localSolution, + launch( arrayView1d< real64 const > const & localSolution, globalIndex const rankOffset, integer const numComponents, arrayView1d< globalIndex const > const & wellElemDofNumber, @@ -790,7 +790,7 @@ struct SolutionScalingKernel { real64 constexpr eps = minDensForDivision; - RAJA::ReduceMin< REDUCE_POLICY, real64 > minVal( 1.0 ); + RAJA::ReduceMin< ReducePolicy< POLICY >, real64 > minVal( 1.0 ); forAll< POLICY >( wellElemDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { @@ -847,9 +847,9 @@ struct SolutionScalingKernel struct SolutionCheckKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > + template< typename POLICY > static localIndex - launch( LOCAL_VECTOR const localSolution, + launch( arrayView1d< real64 const > const & localSolution, globalIndex const rankOffset, integer const numComponents, arrayView1d< globalIndex const > const & wellElemDofNumber, @@ -865,7 +865,7 @@ struct SolutionCheckKernel real64 constexpr eps = minDensForDivision; - RAJA::ReduceMin< REDUCE_POLICY, localIndex > minVal( 1 ); + RAJA::ReduceMin< ReducePolicy< POLICY >, localIndex > minVal( 1 ); forAll< POLICY >( wellElemDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp index 2d98c8d903d..a9148c91aa3 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWell.cpp @@ -707,20 +707,19 @@ SinglePhaseWell::calculateResidualNorm( DomainPartition const & domain, WellControls const & wellControls = getWellControls( subRegion ); - ResidualNormKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localRhs, - dofManager.rankOffset(), - subRegion.isLocallyOwned(), - subRegion.getTopWellElementIndex(), - wellControls, - wellElemDofNumber, - wellElemGhostRank, - wellElemVolume, - wellElemDensityOld, - m_currentTime + m_currentDt, // residual normalized with rate of the end of the - // time interval - m_currentDt, - &localResidualNorm ); + ResidualNormKernel::launch< parallelDevicePolicy<> >( localRhs, + dofManager.rankOffset(), + subRegion.isLocallyOwned(), + subRegion.getTopWellElementIndex(), + wellControls, + wellElemDofNumber, + wellElemGhostRank, + wellElemVolume, + wellElemDensityOld, + m_currentTime + m_currentDt, // residual normalized with rate of the end of the + // time interval + m_currentDt, + &localResidualNorm ); } ); } ); @@ -763,14 +762,14 @@ bool SinglePhaseWell::checkSystemSolution( DomainPartition const & domain, // here we can reuse the flow solver kernel checking that pressures are positive localIndex const subRegionSolutionCheck = - singlePhaseWellKernels::SolutionCheckKernel::launch< parallelDevicePolicy<>, - parallelDeviceReduce >( localSolution, - dofManager.rankOffset(), - wellElemDofNumber, - wellElemGhostRank, - wellElemPressure, - dWellElemPressure, - scalingFactor ); + singlePhaseWellKernels:: + SolutionCheckKernel::launch< parallelDevicePolicy<> >( localSolution, + dofManager.rankOffset(), + wellElemDofNumber, + wellElemGhostRank, + wellElemPressure, + dWellElemPressure, + scalingFactor ); if( subRegionSolutionCheck == 0 ) { diff --git a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWellKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWellKernels.hpp index 3b0e1cfc980..4c502b1e477 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWellKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/wells/SinglePhaseWellKernels.hpp @@ -308,9 +308,9 @@ struct RateInitializationKernel struct ResidualNormKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > + template< typename POLICY > static void - launch( LOCAL_VECTOR const localResidual, + launch( arrayView1d< real64 const > const & localResidual, globalIndex const rankOffset, bool const isLocallyOwned, localIndex const iwelemControl, @@ -328,7 +328,7 @@ struct ResidualNormKernel real64 const targetRate = wellControls.getTargetTotalRate( timeAtEndOfStep ); real64 const absTargetRate = LvArray::math::abs( targetRate ); - RAJA::ReduceSum< REDUCE_POLICY, real64 > sumScaled( 0.0 ); + RAJA::ReduceSum< ReducePolicy< POLICY >, real64 > sumScaled( 0.0 ); forAll< POLICY >( wellElemDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const iwelem ) { @@ -379,9 +379,9 @@ struct ResidualNormKernel struct SolutionCheckKernel { - template< typename POLICY, typename REDUCE_POLICY, typename LOCAL_VECTOR > + template< typename POLICY > static localIndex - launch( LOCAL_VECTOR const localSolution, + launch( arrayView1d< real64 const > const & localSolution, globalIndex const rankOffset, arrayView1d< globalIndex const > const & presDofNumber, arrayView1d< integer const > const & ghostRank, @@ -389,7 +389,7 @@ struct SolutionCheckKernel arrayView1d< real64 const > const & dPres, real64 const scalingFactor ) { - RAJA::ReduceMin< REDUCE_POLICY, localIndex > minVal( 1 ); + RAJA::ReduceMin< ReducePolicy< POLICY >, localIndex > minVal( 1 ); forAll< POLICY >( presDofNumber.size(), [=] GEOSX_HOST_DEVICE ( localIndex const ei ) { diff --git a/src/coreComponents/unitTests/fluidFlowTests/testCompFlowUtils.hpp b/src/coreComponents/unitTests/fluidFlowTests/testCompFlowUtils.hpp index 52dcf0665f0..6b48b5cf2db 100644 --- a/src/coreComponents/unitTests/fluidFlowTests/testCompFlowUtils.hpp +++ b/src/coreComponents/unitTests/fluidFlowTests/testCompFlowUtils.hpp @@ -780,7 +780,6 @@ void fillCellCenteredNumericalJacobian( COMPOSITIONAL_SOLVER & solver, elemDofNumber[ei] + numComp + 1, dT, jacobianFD.toViewConstSizes() ); - } }