Added stand alone test for primary variables. #7046
Conversation
…he difficult cases.
|
jenkins build this please |
There was a problem hiding this comment.
Pull request overview
Adds a new Boost.Test unit test module to exercise Opm::BlackOilPrimaryVariables::adaptPrimaryVariables() switching logic (Sw/Sg/Rs/Rv) using a stub Problem and a zero-capillary material law, and wires the new test into the CMake test sources list.
Changes:
- Introduces
tests/test_blackoilprimaryvariables.cppwith several focused test cases for primary-variable meaning switching. - Adds the new test file to
TEST_SOURCE_FILESinCMakeLists_files.cmake.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/test_blackoilprimaryvariables.cpp | New standalone unit tests for adaptPrimaryVariables() switching between Sg/Rs/Rv and pressure meaning updates under controlled FluidSystem settings. |
| CMakeLists_files.cmake | Registers the new test source so it is built and run with the existing unit test suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #include <stdexcept> | ||
| #include <tuple> | ||
| #include <vector> |
| BOOST_CHECK(changed); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::waterSwitchIdx], 1.0, 1e-12); | ||
| BOOST_CHECK_SMALL(priVars[Indices::compositionSwitchIdx], 1e-12); | ||
| } |
There was a problem hiding this comment.
I think these should be fine since there is no calculation of them. But you can decide.
| BOOST_CHECK(changed); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rs); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Po); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::compositionSwitchIdx], 0.25, 1e-12); |
| BOOST_CHECK(changed); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Rv); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Pg); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::compositionSwitchIdx], 0.15, 1e-12); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::pressureSwitchIdx], 1.5e5, 1e-12); | ||
| } |
| BOOST_CHECK(changed); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg); | ||
| BOOST_CHECK(priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Po); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::compositionSwitchIdx], 0.8, 1e-12); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::pressureSwitchIdx], 1.5e5, 1e-12); |
| BOOST_CHECK(priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Po); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::compositionSwitchIdx], 0.8, 1e-12); | ||
| BOOST_CHECK_CLOSE(priVars[Indices::pressureSwitchIdx], 1.5e5, 1e-12); | ||
| } No newline at end of file |
There was a problem hiding this comment.
missing an end-of-file, something like that.
There was a problem hiding this comment.
end of line at end of file. this is a POSIX requirement, https://dev.to/documendous/why-you-should-end-your-source-files-with-a-new-line-156g
can be fixed by setting https://stackoverflow.com/questions/44704968/visual-studio-code-insert-newline-at-the-end-of-files
| , gasPvt(FluidSystem::gasPvt()) | ||
| , oilPvt(FluidSystem::oilPvt()) | ||
| { | ||
| } |
There was a problem hiding this comment.
not important, while since you defined a non-default constructor. suggested by the ide.
+ FluidSystemGuard(const FluidSystemGuard&) = delete;
+ FluidSystemGuard& operator=(const FluidSystemGuard&) = delete;
+ FluidSystemGuard(FluidSystemGuard&&) = delete;
+ FluidSystemGuard& operator=(FluidSystemGuard&&) = delete;
GitPaean
left a comment
There was a problem hiding this comment.
I went through the tests, it looks sensible and appears to test what the function adaptPrimaryVariables() is supposed to do.
The PR can go in after the few small comments are addressed.
Added standalone test for primaryvariable switching. It will be extended later.