-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
226 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
src/coreComponents/constitutive/unitTests/testMultiFluidSelector.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |