From 0c898691f71d5c13c8df0347ccd1ea05d4171b98 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 12:39:58 -0500 Subject: [PATCH 01/13] Add component selector --- .../multifluid/CO2Brine/CO2BrineFluid.cpp | 8 -- .../multifluid/CO2Brine/CO2BrineFluid.hpp | 11 +- .../fluid/multifluid/MultiFluidSelector.hpp | 97 +++++++++++++++ .../multifluid/blackOil/BlackOilFluid.hpp | 2 + .../multifluid/blackOil/DeadOilFluid.hpp | 2 + .../CompositionalMultiphaseFluid.hpp | 2 + ...CompositionalMultiphaseFluidPVTPackage.hpp | 2 + .../constitutive/unitTests/CMakeLists.txt | 1 + .../unitTests/testMultiFluidSelector.cpp | 110 ++++++++++++++++++ 9 files changed, 226 insertions(+), 9 deletions(-) create mode 100644 src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp index 87cbcdcec4..6c0d9c2e99 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.cpp @@ -114,14 +114,6 @@ CO2BrineFluid( string const & name, Group * const parent ): } } -template< typename PHASE1, typename PHASE2, typename FLASH > -bool CO2BrineFluid< PHASE1, PHASE2, FLASH >::isThermal() const -{ - return ( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() && - PHASE2::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() ); -} - - template< typename PHASE1, typename PHASE2, typename FLASH > std::unique_ptr< ConstitutiveBase > CO2BrineFluid< PHASE1, PHASE2, FLASH >:: diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp index 612d01e1fc..28efbf818d 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp @@ -62,7 +62,16 @@ class CO2BrineFluid : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } - virtual bool isThermal() const override; + static constexpr bool thermal() + { + return !( std::is_same< typename PHASE1::Enthalpy, PVTProps::NoOpPVTFunction >::value || + std::is_same< typename PHASE2::Enthalpy, PVTProps::NoOpPVTFunction >::value ); + } + + virtual bool isThermal() const override + { + return thermal(); + } /** * @brief Kernel wrapper class for CO2BrineFluid. diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 2e1eb17f92..590b899369 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -79,6 +79,103 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid, >::execute( fluid, std::forward< LAMBDA >( lambda ) ); } +namespace internal +{ +// Lists the possible numbers of components supported by a fluid type +// Most of the fluid types support only 2 components so this is the default +template< typename FluidType > +struct Components +{ + using type = camp::int_seq< integer, 2 >; +}; + +// Blackoiub fluid models support anything from 2 or 3 components +template<> +struct Components< DeadOilFluid > +{ + using type = camp::int_seq< integer, 2, 3 >; +}; +template<> +struct Components< BlackOilFluid > +{ + using type = camp::int_seq< integer, 2, 3 >; +}; + +// Compositional fluid models support anything from 2 to 5 components +template<> +struct Components< CompositionalMultiphaseFluidPVTPackage > +{ + using type = camp::int_seq< integer, 2, 3, 4, 5 >; +}; +template<> +struct Components< CompositionalTwoPhaseLohrenzBrayClarkViscosity > +{ + using type = camp::int_seq< integer, 2, 3, 4, 5 >; +}; +template<> +struct Components< CompositionalTwoPhaseConstantViscosity > +{ + using type = camp::int_seq< integer, 2, 3, 4, 5 >; +}; + +template< typename Components > +struct ComponentSelector +{}; + +template< integer ... Is > +struct ComponentSelector< camp::int_seq< integer, Is ... > > +{ + template< typename FluidType, typename LAMBDA > + static void select( int numComps, FluidType & fluid, LAMBDA && lambda ) + { + bool notSupported = false; +// With gcc8, the fold expression below issues a spurious warning +// warning: suggest parentheses around '&&' within '||' [-Wparentheses] +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94505 +#if (defined(__GNUC__) && (__GNUC__ < 10)) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wparentheses" +#endif + ( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...) || (notSupported = true, false); +#if (defined(__GNUC__) && (__GNUC__ < 10)) +#pragma GCC diagnostic pop +#endif + if( notSupported ) + { + GEOS_THROW( "Unsupported number of components: " << numComps << " for fluid " << FluidType::catalogName(), SimulationError ); + } + } +}; + +} + +template< bool THERMAL = false, typename LAMBDA = NoOpFunc > +void constitutiveComponentUpdatePassThru( MultiFluidBase & fluidBase, + integer const numComps, + LAMBDA && lambda ) +{ + ConstitutivePassThruHandler< DeadOilFluid, + BlackOilFluid, +#ifdef GEOSX_USE_PVTPackage + CompositionalMultiphaseFluidPVTPackage, +#endif + CO2BrinePhillipsFluid, + CO2BrineEzrokhiFluid, + CO2BrinePhillipsThermalFluid, + CO2BrineEzrokhiThermalFluid, + CompositionalTwoPhaseLohrenzBrayClarkViscosity, + CompositionalTwoPhaseConstantViscosity + >::execute( fluidBase, [&]( auto & fluid ) + { + using FluidType = TYPEOFREF( fluid ); + if constexpr (!THERMAL || FluidType::thermal()) + { + using Components = typename internal::Components< FluidType >::type; + internal::ComponentSelector< Components >::select( numComps, fluid, std::forward< LAMBDA >( lambda )); + } + } ); +} + } // namespace constitutive } // namespace geos diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp index 97bbc5003e..cf2d853349 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp @@ -51,6 +51,8 @@ class BlackOilFluid : public BlackOilFluidBase virtual string getCatalogName() const override { return catalogName(); } + static constexpr bool thermal(){ return false; } + /** * @brief Kernel wrapper class for BlackOilFluid * This kernel can be called on the GPU diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp index c651f9baf5..ad5c7734b7 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp @@ -37,6 +37,8 @@ class DeadOilFluid : public BlackOilFluidBase virtual string getCatalogName() const override { return catalogName(); } + static constexpr bool thermal(){ return false; } + /** * @brief Kernel wrapper class for DeadOilFluid * This kernel can be called on the GPU diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp index 2c07718445..4c487e96ea 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp @@ -67,6 +67,8 @@ class CompositionalMultiphaseFluid : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } + static constexpr bool thermal(){ return false; } + // TODO: This method should be implemented if an incorrect extrapolation of the pressure and temperature is encountered in the kernel /** * @copydoc MultiFluidBase::checkTablesParameters( real64 pressure, real64 temperature ) diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp index 34c08cddad..c7fe078661 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp @@ -45,6 +45,8 @@ class CompositionalMultiphaseFluidPVTPackage : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } + static constexpr bool thermal(){ return false; } + // TODO: This method should be implemented if an incorrect extrapolation of the pressure and temperature is encountered in the kernel /** * @copydoc MultiFluidBase::checkTablesParameters( real64 pressure, real64 temperature ) diff --git a/src/coreComponents/constitutive/unitTests/CMakeLists.txt b/src/coreComponents/constitutive/unitTests/CMakeLists.txt index 09f808eeb2..a4d541ee37 100644 --- a/src/coreComponents/constitutive/unitTests/CMakeLists.txt +++ b/src/coreComponents/constitutive/unitTests/CMakeLists.txt @@ -9,6 +9,7 @@ set( gtest_geosx_tests testKValueInitialization.cpp testLohrenzBrayClarkViscosity.cpp testModifiedCamClay.cpp + testMultiFluidSelector.cpp testNegativeTwoPhaseFlash.cpp testNegativeTwoPhaseFlash9Comp.cpp testParticleFluidEnums.cpp diff --git a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp new file mode 100644 index 0000000000..4e8363f711 --- /dev/null +++ b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp @@ -0,0 +1,110 @@ +/* + * ------------------------------------------------------------------------------------------------------------ + * 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 "codingUtilities/UnitTestUtilities.hpp" +#include "constitutive/fluid/multifluid/MultiFluidSelector.hpp" + +using namespace geos; +using namespace geos::testing; +using namespace geos::constitutive; + +template< typename FluidType > +class MultiFluidSelectorTest : public ::testing::Test +{ +public: + MultiFluidSelectorTest(): + m_node(), + m_parent( "parent", m_node ) + { + m_model = &m_parent.registerGroup< FluidType >( "fluid" ); + } + ~MultiFluidSelectorTest() override = default; + + MultiFluidBase & getFluid() const { return *m_model; } + +protected: + conduit::Node m_node; + dataRepository::Group m_parent; + FluidType * m_model{}; +}; + +using MultiFluidSelectorTestDeadOilFluid = MultiFluidSelectorTest< DeadOilFluid >; +using MultiFluidSelectorTestCO2BrinePhillipsThermalFluid = MultiFluidSelectorTest< CO2BrinePhillipsThermalFluid >; + +TEST_F( MultiFluidSelectorTestDeadOilFluid, testValidComponents ) +{ + constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ){ + integer constexpr numComps = NC(); + EXPECT_EQ( numComps, 2 ); + } ); + + constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto NC ){ + integer constexpr numComps = NC(); + EXPECT_EQ( numComps, 3 ); + } ); +} + +TEST_F( MultiFluidSelectorTestDeadOilFluid, testInvalidComponents ) +{ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ){ + FAIL(); // Shouldn't be called + } ), SimulationError ); + + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 4, []( auto &, auto ){ + FAIL(); // Shouldn't be called + } ), SimulationError ); +} + +TEST_F( MultiFluidSelectorTestDeadOilFluid, testThermal ) +{ + constitutiveComponentUpdatePassThru< true >( getFluid(), 2, []( auto &, auto ){ + FAIL(); // Shouldn't be called + } ); +} + +TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testValidComponents ) +{ + constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ){ + integer constexpr numComps = NC(); + EXPECT_EQ( numComps, 2 ); + } ); +} + +TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testInvalidComponents ) +{ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ){ + FAIL(); // Shouldn't be called + } ), SimulationError ); + + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto ){ + FAIL(); // Shouldn't be called + } ), SimulationError ); +} + +TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testThermal ) +{ + bool isTested = false; + constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ){ + isTested = true; + } ); + EXPECT_TRUE( isTested ); +} + +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} From a3e9d855d066f31ebded87765056f4ed11564560 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 13:17:01 -0500 Subject: [PATCH 02/13] Use in kernels --- .../fluid/multifluid/MultiFluidSelector.hpp | 6 +- .../multifluid/blackOil/BlackOilFluidBase.cpp | 7 +++ .../multifluid/blackOil/DeadOilFluid.cpp | 10 ++++ .../multifluid/blackOil/DeadOilFluid.hpp | 4 ++ ...ermalCompositionalMultiphaseFVMKernels.hpp | 49 ++++++++-------- ...ermalCompositionalMultiphaseFVMKernels.hpp | 58 +++++++++---------- 6 files changed, 75 insertions(+), 59 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 590b899369..6900d78c9e 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -89,16 +89,18 @@ struct Components using type = camp::int_seq< integer, 2 >; }; -// Blackoiub fluid models support anything from 2 or 3 components +// Dead oil fluid models support 2 or 3 components template<> struct Components< DeadOilFluid > { using type = camp::int_seq< integer, 2, 3 >; }; + +// Blackoil fluid model supports 3 components template<> struct Components< BlackOilFluid > { - using type = camp::int_seq< integer, 2, 3 >; + using type = camp::int_seq< integer, 3 >; }; // Compositional fluid models support anything from 2 to 5 components diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluidBase.cpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluidBase.cpp index de7ac866c2..54cbc67a04 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluidBase.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluidBase.cpp @@ -186,6 +186,13 @@ void BlackOilFluidBase::postInputInitialization() m_phaseOrder[m_phaseTypes[ip]] = ip; } + // Number of components should be at least equal to number of phases + GEOS_THROW_IF_LT_MSG( numFluidComponents(), numFluidPhases(), + GEOS_FMT( "{}: {} number of components ({}) must be at least number of phases ({})", + getFullName(), viewKeyStruct::componentNamesString(), + numFluidComponents(), numFluidPhases() ), + InputError ); + auto const checkInputSize = [&]( auto const & array, auto const & attribute ) { GEOS_THROW_IF_NE_MSG( array.size(), m_phaseNames.size(), diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.cpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.cpp index 6973c41320..d78d429cec 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.cpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.cpp @@ -32,6 +32,16 @@ DeadOilFluid::DeadOilFluid( string const & name, BlackOilFluidBase( name, parent ) {} +void DeadOilFluid::postInputInitialization() +{ + BlackOilFluidBase::postInputInitialization(); + + integer const numComps = numFluidComponents(); + GEOS_THROW_IF( numComps != 2 && numComps != 3, + GEOS_FMT( "{}: this model only supports 2 or 3 components", getFullName() ), + InputError ); +} + void DeadOilFluid::readInputDataFromPVTFiles() { GEOS_THROW_IF_NE_MSG( m_tableFiles.size(), numFluidPhases(), diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp index ad5c7734b7..11e8540536 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp @@ -132,6 +132,10 @@ class DeadOilFluid : public BlackOilFluidBase */ KernelWrapper createKernelWrapper(); +protected: + + virtual void postInputInitialization() override; + private: /** diff --git a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp index 7efdb9aa8d..2e8645c0b9 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/IsothermalCompositionalMultiphaseFVMKernels.hpp @@ -2124,36 +2124,33 @@ class DirichletFaceBasedAssemblyKernelFactory CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { - constitutive::constitutiveUpdatePassThru( fluidBase, [&]( auto & fluid ) + constitutive::constitutiveComponentUpdatePassThru( fluidBase, numComps, [&]( auto & fluid, auto NC ) { using FluidType = TYPEOFREF( fluid ); typename FluidType::KernelWrapper const fluidWrapper = fluid.createKernelWrapper(); - isothermalCompositionalMultiphaseBaseKernels::internal::kernelLaunchSelectorCompSwitch( numComps, [&]( auto NC ) - { - integer constexpr NUM_COMP = NC(); - integer constexpr NUM_DOF = NC() + 1; - - ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > dofNumberAccessor = - elemManager.constructArrayViewAccessor< globalIndex, 1 >( dofKey ); - dofNumberAccessor.setName( solverName + "/accessors/" + dofKey ); - - // for now, we neglect capillary pressure in the kernel - BitFlags< FaceBasedAssemblyKernelFlags > kernelFlags; - if( useTotalMassEquation ) - kernelFlags.set( FaceBasedAssemblyKernelFlags::TotalMassEquation ); - - using kernelType = DirichletFaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, typename FluidType::KernelWrapper >; - typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName ); - typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName ); - typename kernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName ); - typename kernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName ); - - kernelType kernel( numPhases, rankOffset, faceManager, stencilWrapper, fluidWrapper, - dofNumberAccessor, compFlowAccessors, multiFluidAccessors, capPressureAccessors, permeabilityAccessors, - dt, localMatrix, localRhs, kernelFlags ); - kernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); - } ); + integer constexpr NUM_COMP = NC(); + integer constexpr NUM_DOF = NC() + 1; + + ElementRegionManager::ElementViewAccessor< arrayView1d< globalIndex const > > dofNumberAccessor = + elemManager.constructArrayViewAccessor< globalIndex, 1 >( dofKey ); + dofNumberAccessor.setName( solverName + "/accessors/" + dofKey ); + + // for now, we neglect capillary pressure in the kernel + BitFlags< FaceBasedAssemblyKernelFlags > kernelFlags; + if( useTotalMassEquation ) + kernelFlags.set( FaceBasedAssemblyKernelFlags::TotalMassEquation ); + + using kernelType = DirichletFaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, typename FluidType::KernelWrapper >; + typename kernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName ); + typename kernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName ); + typename kernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName ); + typename kernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName ); + + kernelType kernel( numPhases, rankOffset, faceManager, stencilWrapper, fluidWrapper, + dofNumberAccessor, compFlowAccessors, multiFluidAccessors, capPressureAccessors, permeabilityAccessors, + dt, localMatrix, localRhs, kernelFlags ); + kernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); } ); } }; diff --git a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp index 28bd1d26eb..32a9182027 100644 --- a/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp +++ b/src/coreComponents/physicsSolvers/fluidFlow/ThermalCompositionalMultiphaseFVMKernels.hpp @@ -1394,41 +1394,37 @@ class DirichletFaceBasedAssemblyKernelFactory CRSMatrixView< real64, globalIndex const > const & localMatrix, arrayView1d< real64 > const & localRhs ) { - constitutive::constitutiveUpdatePassThru( fluidBase, [&]( auto & fluid ) + constitutive::constitutiveComponentUpdatePassThru< true >( fluidBase, numComps, [&]( auto & fluid, auto NC ) { using FluidType = TYPEOFREF( fluid ); typename FluidType::KernelWrapper const fluidWrapper = fluid.createKernelWrapper(); - 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 ); - - // for now, we neglect capillary pressure in the kernel - BitFlags< isothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernelFlags > kernelFlags; - if( useTotalMassEquation ) - kernelFlags.set( isothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernelFlags::TotalMassEquation ); - - using KernelType = DirichletFaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, typename FluidType::KernelWrapper >; - 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, faceManager, stencilWrapper, fluidWrapper, - dofNumberAccessor, compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, - capPressureAccessors, permeabilityAccessors, thermalConductivityAccessors, - dt, localMatrix, localRhs, kernelFlags ); - KernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); - } ); + 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 ); + + // for now, we neglect capillary pressure in the kernel + BitFlags< isothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernelFlags > kernelFlags; + if( useTotalMassEquation ) + kernelFlags.set( isothermalCompositionalMultiphaseFVMKernels::FaceBasedAssemblyKernelFlags::TotalMassEquation ); + + using KernelType = DirichletFaceBasedAssemblyKernel< NUM_COMP, NUM_DOF, typename FluidType::KernelWrapper >; + 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, faceManager, stencilWrapper, fluidWrapper, + dofNumberAccessor, compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors, + capPressureAccessors, permeabilityAccessors, thermalConductivityAccessors, + dt, localMatrix, localRhs, kernelFlags ); + KernelType::template launch< POLICY >( stencilWrapper.size(), kernel ); } ); } }; From ed5e6de1c128184c8014281fb8f2ff25e1f2c641 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 14:41:50 -0500 Subject: [PATCH 03/13] Add test cases --- .../co2_flux_dirichlet.xml | 227 ++++++++++++++++ .../compositionalMultiphaseFlow.ats | 8 + .../co2_thermal_dirichlet.xml | 252 ++++++++++++++++++ .../thermalMultiphaseFlow.ats | 8 + 4 files changed, 495 insertions(+) create mode 100644 inputFiles/compositionalMultiphaseFlow/co2_flux_dirichlet.xml create mode 100644 inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml diff --git a/inputFiles/compositionalMultiphaseFlow/co2_flux_dirichlet.xml b/inputFiles/compositionalMultiphaseFlow/co2_flux_dirichlet.xml new file mode 100644 index 0000000000..00f64a5bab --- /dev/null +++ b/inputFiles/compositionalMultiphaseFlow/co2_flux_dirichlet.xml @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats b/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats index 319422346c..931a056a10 100644 --- a/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats +++ b/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats @@ -93,6 +93,14 @@ decks = [ restart_step=10, check_step=20, restartcheck_params=RestartcheckParameters(**restartcheck_params)), + TestDeck( + name="co2_flux_dirichlet", + description= + "Compositional co2-brine flow test (2D co2 injection, 2-phase co2-brine, Table 2-phase relperm curves, Dirichlet boundary)", + partitions=((1, 1, 1), (2, 2, 2)), + restart_step=23, + check_step=46, + restartcheck_params=RestartcheckParameters(**restartcheck_params)), TestDeck( name="deadoil_3ph_staircase_obl_3d", description= diff --git a/inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml b/inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml new file mode 100644 index 0000000000..fcc977ff93 --- /dev/null +++ b/inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats b/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats index ea6193427d..4afeeb1360 100644 --- a/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats +++ b/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats @@ -13,6 +13,14 @@ decks = [ restart_step=9, check_step=11, restartcheck_params=RestartcheckParameters(**restartcheck_params)), + TestDeck( + name="co2_thermal_dirichlet", + description= + 'Thermal compositional co2-brine flow test (2D co2 injection, 2-phase co2-brine, Brooks-Corey relperm curves, thermal, Dirichlet boundary)', + partitions=((1, 1, 1), (2, 2, 1)), + restart_step=24, + check_step=43, + restartcheck_params=RestartcheckParameters(**restartcheck_params)), TestDeck( name="co2_thermal_obl_3d", description= From f2e559f5e6df0a8d8330a47a8b0194065fdad44e Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 17:48:33 -0500 Subject: [PATCH 04/13] Rename select -> expand --- .../fluid/multifluid/MultiFluidSelector.hpp | 53 ++++++++-------- .../unitTests/testMultiFluidSelector.cpp | 61 ++++++++++++++++--- 2 files changed, 81 insertions(+), 33 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 6900d78c9e..178feba2c7 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -79,17 +79,18 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid, >::execute( fluid, std::forward< LAMBDA >( lambda ) ); } -namespace internal +namespace detail { + // Lists the possible numbers of components supported by a fluid type // Most of the fluid types support only 2 components so this is the default -template< typename FluidType > +template< typename FLUID_TYPE > struct Components { using type = camp::int_seq< integer, 2 >; }; -// Dead oil fluid models support 2 or 3 components +// Dead oil fluid model supports 2 or 3 components template<> struct Components< DeadOilFluid > { @@ -120,15 +121,31 @@ struct Components< CompositionalTwoPhaseConstantViscosity > using type = camp::int_seq< integer, 2, 3, 4, 5 >; }; -template< typename Components > +/** + * @brief Structure to execute a lambda on a fluid model depending on the number of components + * @tparam THERMAL_ACTIVE Determines if the call has been deactivated due to the lambda being thermal + * but the fluid model not being thermal + * @tparam COMPONENT_LIST Type listing the components to expand over + */ +template< bool THERMAL_ACTIVE, typename COMPONENT_LIST > struct ComponentSelector {}; +/** @brief If the call is deactivated due to the fluid not being thermal + */ +template< typename COMPONENT_LIST > +struct ComponentSelector< false, COMPONENT_LIST > +{ + template< typename FluidType, typename LAMBDA > + static void execute( int GEOS_UNUSED_PARAM( numComps ), FluidType & GEOS_UNUSED_PARAM( fluid ), LAMBDA && GEOS_UNUSED_PARAM( lambda ) ) + {} +}; + template< integer ... Is > -struct ComponentSelector< camp::int_seq< integer, Is ... > > +struct ComponentSelector< true, camp::int_seq< integer, Is ... > > { template< typename FluidType, typename LAMBDA > - static void select( int numComps, FluidType & fluid, LAMBDA && lambda ) + static void execute( int numComps, FluidType & fluid, LAMBDA && lambda ) { bool notSupported = false; // With gcc8, the fold expression below issues a spurious warning @@ -138,7 +155,8 @@ struct ComponentSelector< camp::int_seq< integer, Is ... > > #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wparentheses" #endif - ( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...) || (notSupported = true, false); + GEOS_UNUSED_VAR(( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...) || + (notSupported = true, false)); #if (defined(__GNUC__) && (__GNUC__ < 10)) #pragma GCC diagnostic pop #endif @@ -156,25 +174,12 @@ void constitutiveComponentUpdatePassThru( MultiFluidBase & fluidBase, integer const numComps, LAMBDA && lambda ) { - ConstitutivePassThruHandler< DeadOilFluid, - BlackOilFluid, -#ifdef GEOSX_USE_PVTPackage - CompositionalMultiphaseFluidPVTPackage, -#endif - CO2BrinePhillipsFluid, - CO2BrineEzrokhiFluid, - CO2BrinePhillipsThermalFluid, - CO2BrineEzrokhiThermalFluid, - CompositionalTwoPhaseLohrenzBrayClarkViscosity, - CompositionalTwoPhaseConstantViscosity - >::execute( fluidBase, [&]( auto & fluid ) + constitutiveUpdatePassThru( fluidBase, [&]( auto & fluid ) { using FluidType = TYPEOFREF( fluid ); - if constexpr (!THERMAL || FluidType::thermal()) - { - using Components = typename internal::Components< FluidType >::type; - internal::ComponentSelector< Components >::select( numComps, fluid, std::forward< LAMBDA >( lambda )); - } + using Components = typename detail::Components< FluidType >::type; + constexpr bool active = !THERMAL || FluidType::thermal(); + detail::ComponentSelector< active, Components >::execute( numComps, fluid, std::forward< LAMBDA >( lambda )); } ); } diff --git a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp index 4e8363f711..3bb1ee7463 100644 --- a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp +++ b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp @@ -42,15 +42,18 @@ class MultiFluidSelectorTest : public ::testing::Test using MultiFluidSelectorTestDeadOilFluid = MultiFluidSelectorTest< DeadOilFluid >; using MultiFluidSelectorTestCO2BrinePhillipsThermalFluid = MultiFluidSelectorTest< CO2BrinePhillipsThermalFluid >; +using MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity = MultiFluidSelectorTest< CompositionalTwoPhaseConstantViscosity >; TEST_F( MultiFluidSelectorTestDeadOilFluid, testValidComponents ) { - constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ){ + constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ) + { integer constexpr numComps = NC(); EXPECT_EQ( numComps, 2 ); } ); - constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto NC ){ + constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto NC ) + { integer constexpr numComps = NC(); EXPECT_EQ( numComps, 3 ); } ); @@ -58,25 +61,29 @@ TEST_F( MultiFluidSelectorTestDeadOilFluid, testValidComponents ) TEST_F( MultiFluidSelectorTestDeadOilFluid, testInvalidComponents ) { - EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ){ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ) + { FAIL(); // Shouldn't be called } ), SimulationError ); - EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 4, []( auto &, auto ){ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 4, []( auto &, auto ) + { FAIL(); // Shouldn't be called } ), SimulationError ); } TEST_F( MultiFluidSelectorTestDeadOilFluid, testThermal ) { - constitutiveComponentUpdatePassThru< true >( getFluid(), 2, []( auto &, auto ){ + constitutiveComponentUpdatePassThru< true >( getFluid(), 2, []( auto &, auto ) + { FAIL(); // Shouldn't be called } ); } TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testValidComponents ) { - constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ){ + constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ) + { integer constexpr numComps = NC(); EXPECT_EQ( numComps, 2 ); } ); @@ -84,11 +91,13 @@ TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testValidComponents TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testInvalidComponents ) { - EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ){ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ) + { FAIL(); // Shouldn't be called } ), SimulationError ); - EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto ){ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto ) + { FAIL(); // Shouldn't be called } ), SimulationError ); } @@ -96,12 +105,46 @@ TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testInvalidComponent TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testThermal ) { bool isTested = false; - constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ){ + constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ) + { isTested = true; } ); EXPECT_TRUE( isTested ); } +TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testValidComponents ) +{ + for( integer nc = 2; nc <= 5; nc++ ) + { + constitutiveComponentUpdatePassThru( getFluid(), nc, [&]( auto &, auto NC ) + { + integer constexpr numComps = NC(); + EXPECT_EQ( numComps, nc ); + } ); + } +} + +TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testInvalidComponents ) +{ + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ) + { + FAIL(); // Shouldn't be called + } ), SimulationError ); + + EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 6, []( auto &, auto ) + { + FAIL(); // Shouldn't be called + } ), SimulationError ); +} + +TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testThermal ) +{ + constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ) + { + FAIL(); // Shouldn't be called + } ); +} + int main( int argc, char * * argv ) { ::testing::InitGoogleTest( &argc, argv ); From 180bece1f82e7e6c8e3627a743852da42a7054f3 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 18:01:05 -0500 Subject: [PATCH 05/13] Further changes --- .../multifluid/CO2Brine/CO2BrineFluid.hpp | 4 ++-- .../unitTests/testMultiFluidSelector.cpp | 24 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp index 28efbf818d..61e719a7ba 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp @@ -64,8 +64,8 @@ class CO2BrineFluid : public MultiFluidBase static constexpr bool thermal() { - return !( std::is_same< typename PHASE1::Enthalpy, PVTProps::NoOpPVTFunction >::value || - std::is_same< typename PHASE2::Enthalpy, PVTProps::NoOpPVTFunction >::value ); + return !( std::is_same_v< typename PHASE1::Enthalpy, PVTProps::NoOpPVTFunction > || + std::is_same_v< typename PHASE2::Enthalpy, PVTProps::NoOpPVTFunction > ); } virtual bool isThermal() const override diff --git a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp index 3bb1ee7463..db2083fe0d 100644 --- a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp +++ b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp @@ -46,17 +46,23 @@ using MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity = MultiFluidS TEST_F( MultiFluidSelectorTestDeadOilFluid, testValidComponents ) { - constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ) + bool isExecuted = false; + constitutiveComponentUpdatePassThru( getFluid(), 2, [&]( auto &, auto NC ) { integer constexpr numComps = NC(); EXPECT_EQ( numComps, 2 ); + isExecuted = true; } ); + EXPECT_TRUE( isExecuted ); - constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto NC ) + isExecuted = false; + constitutiveComponentUpdatePassThru( getFluid(), 3, [&]( auto &, auto NC ) { integer constexpr numComps = NC(); EXPECT_EQ( numComps, 3 ); + isExecuted = true; } ); + EXPECT_TRUE( isExecuted ); } TEST_F( MultiFluidSelectorTestDeadOilFluid, testInvalidComponents ) @@ -82,11 +88,14 @@ TEST_F( MultiFluidSelectorTestDeadOilFluid, testThermal ) TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testValidComponents ) { - constitutiveComponentUpdatePassThru( getFluid(), 2, []( auto &, auto NC ) + bool isExecuted = false; + constitutiveComponentUpdatePassThru( getFluid(), 2, [&]( auto &, auto NC ) { integer constexpr numComps = NC(); EXPECT_EQ( numComps, 2 ); + isExecuted = true; } ); + EXPECT_TRUE( isExecuted ); } TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testInvalidComponents ) @@ -104,23 +113,26 @@ TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testInvalidComponent TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testThermal ) { - bool isTested = false; + bool isExecuted = false; constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ) { - isTested = true; + isExecuted = true; } ); - EXPECT_TRUE( isTested ); + EXPECT_TRUE( isExecuted ); } TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testValidComponents ) { for( integer nc = 2; nc <= 5; nc++ ) { + bool isExecuted = false; constitutiveComponentUpdatePassThru( getFluid(), nc, [&]( auto &, auto NC ) { integer constexpr numComps = NC(); EXPECT_EQ( numComps, nc ); + isExecuted = true; } ); + EXPECT_TRUE( isExecuted ); } } From 11e249bf66723d122bff6e4974b857d44d6be318 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 18:27:11 -0500 Subject: [PATCH 06/13] Fix integrated tests --- .../compositionalMultiphaseFlow.ats | 2 +- inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats | 2 +- .../constitutive/fluid/multifluid/MultiFluidSelector.hpp | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats b/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats index 931a056a10..39689e8798 100644 --- a/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats +++ b/inputFiles/compositionalMultiphaseFlow/compositionalMultiphaseFlow.ats @@ -97,7 +97,7 @@ decks = [ name="co2_flux_dirichlet", description= "Compositional co2-brine flow test (2D co2 injection, 2-phase co2-brine, Table 2-phase relperm curves, Dirichlet boundary)", - partitions=((1, 1, 1), (2, 2, 2)), + partitions=((1, 1, 1), (2, 1, 3)), restart_step=23, check_step=46, restartcheck_params=RestartcheckParameters(**restartcheck_params)), diff --git a/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats b/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats index 4afeeb1360..0b31921654 100644 --- a/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats +++ b/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats @@ -17,7 +17,7 @@ decks = [ name="co2_thermal_dirichlet", description= 'Thermal compositional co2-brine flow test (2D co2 injection, 2-phase co2-brine, Brooks-Corey relperm curves, thermal, Dirichlet boundary)', - partitions=((1, 1, 1), (2, 2, 1)), + partitions=((1, 1, 1), (2, 1, 3)), restart_step=24, check_step=43, restartcheck_params=RestartcheckParameters(**restartcheck_params)), diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 178feba2c7..4cdabf706e 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -147,7 +147,6 @@ struct ComponentSelector< true, camp::int_seq< integer, Is ... > > template< typename FluidType, typename LAMBDA > static void execute( int numComps, FluidType & fluid, LAMBDA && lambda ) { - bool notSupported = false; // With gcc8, the fold expression below issues a spurious warning // warning: suggest parentheses around '&&' within '||' [-Wparentheses] // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94505 @@ -155,12 +154,11 @@ struct ComponentSelector< true, camp::int_seq< integer, Is ... > > #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wparentheses" #endif - GEOS_UNUSED_VAR(( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...) || - (notSupported = true, false)); + bool const supported = ( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...) || false; #if (defined(__GNUC__) && (__GNUC__ < 10)) #pragma GCC diagnostic pop #endif - if( notSupported ) + if( !supported ) { GEOS_THROW( "Unsupported number of components: " << numComps << " for fluid " << FluidType::catalogName(), SimulationError ); } From d9c90816308427eac88bfeab24a89fa69366d200 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 5 Jul 2024 18:28:36 -0500 Subject: [PATCH 07/13] Fix integrated tests --- .../constitutive/fluid/multifluid/MultiFluidSelector.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 4cdabf706e..6fa20b9136 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -154,7 +154,7 @@ struct ComponentSelector< true, camp::int_seq< integer, Is ... > > #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wparentheses" #endif - bool const supported = ( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...) || false; + bool const supported = ( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...); #if (defined(__GNUC__) && (__GNUC__ < 10)) #pragma GCC diagnostic pop #endif From 17bc38d51222c31302d88e016a2f9cc65c561526 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Sat, 6 Jul 2024 09:30:22 -0500 Subject: [PATCH 08/13] Remove thermal test --- .../co2_thermal_dirichlet.xml | 252 ------------------ .../thermalMultiphaseFlow.ats | 8 - .../fluid/multifluid/MultiFluidSelector.hpp | 13 +- .../unitTests/testMultiFluidSelector.cpp | 12 +- 4 files changed, 14 insertions(+), 271 deletions(-) delete mode 100644 inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml diff --git a/inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml b/inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml deleted file mode 100644 index fcc977ff93..0000000000 --- a/inputFiles/thermalMultiphaseFlow/co2_thermal_dirichlet.xml +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats b/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats index 0b31921654..ea6193427d 100644 --- a/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats +++ b/inputFiles/thermalMultiphaseFlow/thermalMultiphaseFlow.ats @@ -13,14 +13,6 @@ decks = [ restart_step=9, check_step=11, restartcheck_params=RestartcheckParameters(**restartcheck_params)), - TestDeck( - name="co2_thermal_dirichlet", - description= - 'Thermal compositional co2-brine flow test (2D co2 injection, 2-phase co2-brine, Brooks-Corey relperm curves, thermal, Dirichlet boundary)', - partitions=((1, 1, 1), (2, 1, 3)), - restart_step=24, - check_step=43, - restartcheck_params=RestartcheckParameters(**restartcheck_params)), TestDeck( name="co2_thermal_obl_3d", description= diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 6fa20b9136..199e8f6958 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -137,7 +137,9 @@ template< typename COMPONENT_LIST > struct ComponentSelector< false, COMPONENT_LIST > { template< typename FluidType, typename LAMBDA > - static void execute( int GEOS_UNUSED_PARAM( numComps ), FluidType & GEOS_UNUSED_PARAM( fluid ), LAMBDA && GEOS_UNUSED_PARAM( lambda ) ) + static void execute( int GEOS_UNUSED_PARAM( numComps ), + FluidType & GEOS_UNUSED_PARAM( fluid ), + LAMBDA && GEOS_UNUSED_PARAM( lambda ) ) {} }; @@ -154,14 +156,15 @@ struct ComponentSelector< true, camp::int_seq< integer, Is ... > > #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wparentheses" #endif + bool const supported = ( ((numComps == Is) && (lambda( fluid, std::integral_constant< integer, Is >() ), true)) || ...); + #if (defined(__GNUC__) && (__GNUC__ < 10)) #pragma GCC diagnostic pop #endif - if( !supported ) - { - GEOS_THROW( "Unsupported number of components: " << numComps << " for fluid " << FluidType::catalogName(), SimulationError ); - } + GEOS_THROW_IF( !supported, + "Unsupported number of components: " << numComps << " for fluid " << FluidType::catalogName(), + InputError ); } }; diff --git a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp index db2083fe0d..5922dc8855 100644 --- a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp +++ b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp @@ -70,12 +70,12 @@ TEST_F( MultiFluidSelectorTestDeadOilFluid, testInvalidComponents ) EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ), SimulationError ); + } ), InputError ); EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 4, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ), SimulationError ); + } ), InputError ); } TEST_F( MultiFluidSelectorTestDeadOilFluid, testThermal ) @@ -103,12 +103,12 @@ TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testInvalidComponent EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ), SimulationError ); + } ), InputError ); EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 3, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ), SimulationError ); + } ), InputError ); } TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testThermal ) @@ -141,12 +141,12 @@ TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testInvali EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 1, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ), SimulationError ); + } ), InputError ); EXPECT_THROW( constitutiveComponentUpdatePassThru( getFluid(), 6, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ), SimulationError ); + } ), InputError ); } TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testThermal ) From 0349ae82b0455588f7fc6acbbceba88323e5c107 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Sat, 6 Jul 2024 11:58:41 -0500 Subject: [PATCH 09/13] Rebaseline --- .integrated_tests.yaml | 2 +- BASELINE_NOTES.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index 352b2b972a..1c83497093 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,6 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr3006-5860-947a907 + baseline: integratedTests/baseline_integratedTests-pr3213-6002-8736c9d allow_fail: all: '' diff --git a/BASELINE_NOTES.md b/BASELINE_NOTES.md index 7d44e61640..3338de82db 100644 --- a/BASELINE_NOTES.md +++ b/BASELINE_NOTES.md @@ -6,6 +6,10 @@ This file is designed to track changes to the integrated test baselines. Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining. These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD). +PR #3213 (2024-07-06) +====================== +Added baselines for new tests on Dirichlet boundary conditions for multiphase flow. + PR #3006 (2024-07-01) ====================== Added baselines for new tests. Relaxing tolerances for singlePhasePoromechanics_FaultModel_smoke. From 0928d390f2d46ee3e86b6ab5bed7bbd872d8061e Mon Sep 17 00:00:00 2001 From: dkachuma Date: Fri, 12 Jul 2024 11:43:45 -0500 Subject: [PATCH 10/13] Use integer sequence generator --- src/coreComponents/common/TypeDispatch.hpp | 10 +++- .../multifluid/CO2Brine/CO2BrineFluid.hpp | 3 ++ .../fluid/multifluid/MultiFluidBase.hpp | 14 +++++ .../fluid/multifluid/MultiFluidSelector.hpp | 52 +++---------------- .../multifluid/blackOil/BlackOilFluid.hpp | 3 ++ .../multifluid/blackOil/DeadOilFluid.hpp | 3 ++ 6 files changed, 37 insertions(+), 48 deletions(-) diff --git a/src/coreComponents/common/TypeDispatch.hpp b/src/coreComponents/common/TypeDispatch.hpp index c7f30afdf1..2dfcfb4bd9 100644 --- a/src/coreComponents/common/TypeDispatch.hpp +++ b/src/coreComponents/common/TypeDispatch.hpp @@ -153,6 +153,12 @@ using Increment = typename IncrementImpl< T, N >::type; } // namespace internal +/** + * @brief Generate a sequence of integers from @p Begin up to (and including) @p End. + */ +template< integer Begin, integer End > +using IntegerSequence = internal::Increment< camp::make_idx_seq_t< End - Begin + 1 >, Begin >; + /** * @brief Construct a list of types. */ @@ -189,10 +195,10 @@ using IntegralTypes = TypeList< integer, localIndex, globalIndex >; using RealTypes = TypeList< real32, real64 >; /** - * @brief Generate a list of types representing array dimensionalities from M up to (and including) @p N. + * @brief Generate a list of types representing array dimensionalities from @p M up to (and including) @p N. */ template< int M, int N > -using DimsRange = camp::as_list< internal::Increment< camp::make_idx_seq_t< N - M + 1 >, M > >; +using DimsRange = camp::as_list< IntegerSequence< M, N > >; /** * @brief Generate a list of types representing array dimensionality exactly @p N. diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp index 61e719a7ba..b6764dd9a2 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp @@ -68,6 +68,9 @@ class CO2BrineFluid : public MultiFluidBase std::is_same_v< typename PHASE2::Enthalpy, PVTProps::NoOpPVTFunction > ); } + static constexpr integer min_n_components = 2; + static constexpr integer max_n_components = 2; + virtual bool isThermal() const override { return thermal(); diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidBase.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidBase.hpp index 6dbf9e1543..f2e2fe7878 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidBase.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidBase.hpp @@ -56,6 +56,20 @@ class MultiFluidBase : public ConstitutiveBase */ static constexpr integer MAX_NUM_PHASES = MultiFluidConstants::MAX_NUM_PHASES; + /** + * @brief Minimum supported number of fluid components (species) for dispatch + * @note This is the mininum number of components that can be used for dispatch in a kernel launch specific for + * this fluid type. + */ + static constexpr integer min_n_components = 2; + + /** + * @brief Maximum supported number of fluid components (species) for dispatch + * @note This is the maxinum number of components that can be used for dispatch in a kernel launch specific for + * this fluid type. + */ + static constexpr integer max_n_components = 5; + /** * @return number of fluid components (species) in the model */ diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index 199e8f6958..ea71fdcc44 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -23,7 +23,7 @@ #include "constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp" #include "constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp" -#include "common/GeosxConfig.hpp" +#include "common/TypeDispatch.hpp" #ifdef GEOSX_USE_PVTPackage #include "constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp" #endif @@ -81,46 +81,6 @@ void constitutiveUpdatePassThru( MultiFluidBase & fluid, namespace detail { - -// Lists the possible numbers of components supported by a fluid type -// Most of the fluid types support only 2 components so this is the default -template< typename FLUID_TYPE > -struct Components -{ - using type = camp::int_seq< integer, 2 >; -}; - -// Dead oil fluid model supports 2 or 3 components -template<> -struct Components< DeadOilFluid > -{ - using type = camp::int_seq< integer, 2, 3 >; -}; - -// Blackoil fluid model supports 3 components -template<> -struct Components< BlackOilFluid > -{ - using type = camp::int_seq< integer, 3 >; -}; - -// Compositional fluid models support anything from 2 to 5 components -template<> -struct Components< CompositionalMultiphaseFluidPVTPackage > -{ - using type = camp::int_seq< integer, 2, 3, 4, 5 >; -}; -template<> -struct Components< CompositionalTwoPhaseLohrenzBrayClarkViscosity > -{ - using type = camp::int_seq< integer, 2, 3, 4, 5 >; -}; -template<> -struct Components< CompositionalTwoPhaseConstantViscosity > -{ - using type = camp::int_seq< integer, 2, 3, 4, 5 >; -}; - /** * @brief Structure to execute a lambda on a fluid model depending on the number of components * @tparam THERMAL_ACTIVE Determines if the call has been deactivated due to the lambda being thermal @@ -128,8 +88,7 @@ struct Components< CompositionalTwoPhaseConstantViscosity > * @tparam COMPONENT_LIST Type listing the components to expand over */ template< bool THERMAL_ACTIVE, typename COMPONENT_LIST > -struct ComponentSelector -{}; +struct ComponentSelector; /** @brief If the call is deactivated due to the fluid not being thermal */ @@ -143,8 +102,8 @@ struct ComponentSelector< false, COMPONENT_LIST > {} }; -template< integer ... Is > -struct ComponentSelector< true, camp::int_seq< integer, Is ... > > +template< camp::idx_t ... Is > +struct ComponentSelector< true, camp::idx_seq< Is ... > > { template< typename FluidType, typename LAMBDA > static void execute( int numComps, FluidType & fluid, LAMBDA && lambda ) @@ -178,7 +137,8 @@ void constitutiveComponentUpdatePassThru( MultiFluidBase & fluidBase, constitutiveUpdatePassThru( fluidBase, [&]( auto & fluid ) { using FluidType = TYPEOFREF( fluid ); - using Components = typename detail::Components< FluidType >::type; + static_assert( FluidType::min_n_components <= FluidType::max_n_components ); + using Components = typename types::IntegerSequence< FluidType::min_n_components, FluidType::max_n_components >::type; constexpr bool active = !THERMAL || FluidType::thermal(); detail::ComponentSelector< active, Components >::execute( numComps, fluid, std::forward< LAMBDA >( lambda )); } ); diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp index cf2d853349..97f62144ad 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp @@ -53,6 +53,9 @@ class BlackOilFluid : public BlackOilFluidBase static constexpr bool thermal(){ return false; } + static constexpr integer min_n_components = 3; + static constexpr integer max_n_components = 3; + /** * @brief Kernel wrapper class for BlackOilFluid * This kernel can be called on the GPU diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp index 11e8540536..6ab8d6fe2c 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp @@ -39,6 +39,9 @@ class DeadOilFluid : public BlackOilFluidBase static constexpr bool thermal(){ return false; } + static constexpr integer min_n_components = 2; + static constexpr integer max_n_components = 3; + /** * @brief Kernel wrapper class for DeadOilFluid * This kernel can be called on the GPU From f259c4ec6a84a41f3e0d450a181f634993bb351b Mon Sep 17 00:00:00 2001 From: dkachuma Date: Mon, 15 Jul 2024 13:33:40 -0500 Subject: [PATCH 11/13] Use constexpr if --- .../fluid/multifluid/MultiFluidSelector.hpp | 29 +++++++------------ .../unitTests/testMultiFluidSelector.cpp | 15 +++------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index ea71fdcc44..dc1dbc5939 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -83,27 +83,13 @@ namespace detail { /** * @brief Structure to execute a lambda on a fluid model depending on the number of components - * @tparam THERMAL_ACTIVE Determines if the call has been deactivated due to the lambda being thermal - * but the fluid model not being thermal * @tparam COMPONENT_LIST Type listing the components to expand over */ -template< bool THERMAL_ACTIVE, typename COMPONENT_LIST > -struct ComponentSelector; - -/** @brief If the call is deactivated due to the fluid not being thermal - */ template< typename COMPONENT_LIST > -struct ComponentSelector< false, COMPONENT_LIST > -{ - template< typename FluidType, typename LAMBDA > - static void execute( int GEOS_UNUSED_PARAM( numComps ), - FluidType & GEOS_UNUSED_PARAM( fluid ), - LAMBDA && GEOS_UNUSED_PARAM( lambda ) ) - {} -}; +struct ComponentSelector; template< camp::idx_t ... Is > -struct ComponentSelector< true, camp::idx_seq< Is ... > > +struct ComponentSelector< camp::idx_seq< Is ... > > { template< typename FluidType, typename LAMBDA > static void execute( int numComps, FluidType & fluid, LAMBDA && lambda ) @@ -139,8 +125,15 @@ void constitutiveComponentUpdatePassThru( MultiFluidBase & fluidBase, using FluidType = TYPEOFREF( fluid ); static_assert( FluidType::min_n_components <= FluidType::max_n_components ); using Components = typename types::IntegerSequence< FluidType::min_n_components, FluidType::max_n_components >::type; - constexpr bool active = !THERMAL || FluidType::thermal(); - detail::ComponentSelector< active, Components >::execute( numComps, fluid, std::forward< LAMBDA >( lambda )); + if constexpr (!THERMAL || FluidType::thermal()) + { + detail::ComponentSelector< Components >::execute( numComps, fluid, std::forward< LAMBDA >( lambda )); + } + else + { + GEOS_THROW( "Unsupported thermal call for fluid " << FluidType::catalogName(), + InputError ); + } } ); } diff --git a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp index 5922dc8855..12d05d769b 100644 --- a/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp +++ b/src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp @@ -80,10 +80,10 @@ TEST_F( MultiFluidSelectorTestDeadOilFluid, testInvalidComponents ) TEST_F( MultiFluidSelectorTestDeadOilFluid, testThermal ) { - constitutiveComponentUpdatePassThru< true >( getFluid(), 2, []( auto &, auto ) + EXPECT_THROW( constitutiveComponentUpdatePassThru< true >( getFluid(), 2, []( auto &, auto ) { FAIL(); // Shouldn't be called - } ); + } ), InputError ); } TEST_F( MultiFluidSelectorTestCO2BrinePhillipsThermalFluid, testValidComponents ) @@ -151,15 +151,8 @@ TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testInvali TEST_F( MultiFluidSelectorTestCompositionalTwoPhaseConstantViscosity, testThermal ) { - constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ) + EXPECT_THROW( constitutiveComponentUpdatePassThru< true >( getFluid(), 2, [&]( auto &, auto ) { FAIL(); // Shouldn't be called - } ); -} - -int main( int argc, char * * argv ) -{ - ::testing::InitGoogleTest( &argc, argv ); - int const result = RUN_ALL_TESTS(); - return result; + } ), InputError ); } From d31835ed28abd05321e3a6ab30e55e9397357838 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Tue, 16 Jul 2024 09:54:31 -0500 Subject: [PATCH 12/13] Rebaseline --- .integrated_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.integrated_tests.yaml b/.integrated_tests.yaml index 89ea94460e..faf2510c6d 100644 --- a/.integrated_tests.yaml +++ b/.integrated_tests.yaml @@ -1,6 +1,6 @@ baselines: bucket: geosx - baseline: integratedTests/baseline_integratedTests-pr3194-6060-e5ba0ce + baseline: integratedTests/baseline_integratedTests-pr3213-6170-5c2c0bf allow_fail: all: '' From 1d74597bfa35b4fa92599c69e3cebc782d655001 Mon Sep 17 00:00:00 2001 From: dkachuma Date: Thu, 18 Jul 2024 11:59:22 -0500 Subject: [PATCH 13/13] thermal -> isThermalType --- .../constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp | 4 ++-- .../constitutive/fluid/multifluid/MultiFluidSelector.hpp | 2 +- .../constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp | 2 +- .../constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp | 2 +- .../multifluid/compositional/CompositionalMultiphaseFluid.hpp | 2 +- .../compositional/CompositionalMultiphaseFluidPVTPackage.hpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp index b6764dd9a2..1758aa2110 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/CO2Brine/CO2BrineFluid.hpp @@ -62,7 +62,7 @@ class CO2BrineFluid : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } - static constexpr bool thermal() + static constexpr bool isThermalType() { return !( std::is_same_v< typename PHASE1::Enthalpy, PVTProps::NoOpPVTFunction > || std::is_same_v< typename PHASE2::Enthalpy, PVTProps::NoOpPVTFunction > ); @@ -73,7 +73,7 @@ class CO2BrineFluid : public MultiFluidBase virtual bool isThermal() const override { - return thermal(); + return isThermalType(); } /** diff --git a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp index dc1dbc5939..3b0ad60373 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/MultiFluidSelector.hpp @@ -125,7 +125,7 @@ void constitutiveComponentUpdatePassThru( MultiFluidBase & fluidBase, using FluidType = TYPEOFREF( fluid ); static_assert( FluidType::min_n_components <= FluidType::max_n_components ); using Components = typename types::IntegerSequence< FluidType::min_n_components, FluidType::max_n_components >::type; - if constexpr (!THERMAL || FluidType::thermal()) + if constexpr (!THERMAL || FluidType::isThermalType()) { detail::ComponentSelector< Components >::execute( numComps, fluid, std::forward< LAMBDA >( lambda )); } diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp index 97f62144ad..936a499adb 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/BlackOilFluid.hpp @@ -51,7 +51,7 @@ class BlackOilFluid : public BlackOilFluidBase virtual string getCatalogName() const override { return catalogName(); } - static constexpr bool thermal(){ return false; } + static constexpr bool isThermalType(){ return false; } static constexpr integer min_n_components = 3; static constexpr integer max_n_components = 3; diff --git a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp index 6ab8d6fe2c..4005971356 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/blackOil/DeadOilFluid.hpp @@ -37,7 +37,7 @@ class DeadOilFluid : public BlackOilFluidBase virtual string getCatalogName() const override { return catalogName(); } - static constexpr bool thermal(){ return false; } + static constexpr bool isThermalType(){ return false; } static constexpr integer min_n_components = 2; static constexpr integer max_n_components = 3; diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp index 4c487e96ea..fc50f202e7 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluid.hpp @@ -67,7 +67,7 @@ class CompositionalMultiphaseFluid : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } - static constexpr bool thermal(){ return false; } + static constexpr bool isThermalType(){ return false; } // TODO: This method should be implemented if an incorrect extrapolation of the pressure and temperature is encountered in the kernel /** diff --git a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp index c7fe078661..c2a06ef2e9 100644 --- a/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp +++ b/src/coreComponents/constitutive/fluid/multifluid/compositional/CompositionalMultiphaseFluidPVTPackage.hpp @@ -45,7 +45,7 @@ class CompositionalMultiphaseFluidPVTPackage : public MultiFluidBase virtual string getCatalogName() const override { return catalogName(); } - static constexpr bool thermal(){ return false; } + static constexpr bool isThermalType(){ return false; } // TODO: This method should be implemented if an incorrect extrapolation of the pressure and temperature is encountered in the kernel /**