From cf50957924f39576165d839a0eb3f254ea335e39 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Thu, 3 Oct 2024 14:06:06 +0200 Subject: [PATCH] Added documentation and added minimumNumberOfComponents template argument. --- flowexperimental/comp/flowexp_comp.cpp | 31 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/flowexperimental/comp/flowexp_comp.cpp b/flowexperimental/comp/flowexp_comp.cpp index a047ec529..55d36d2e5 100644 --- a/flowexperimental/comp/flowexp_comp.cpp +++ b/flowexperimental/comp/flowexp_comp.cpp @@ -307,21 +307,38 @@ struct EnableThermalFluxBoundaries { } // namespace Opm::Properties -template +//! @brief Runs the simulator with the correct number of components +//! +//! This function will compile-time recurse from numComponentsCompileTime +//! down to (inclusive) minimumNumberOfComponents and check if +//! +//! numComponentsCompileTime == numComponentsRuntime +//! +//! and if this is the case, it will star the simulator with numComponentsRuntime. +//! +//! @tparam minimumNumberOfComponents the minimum number of components supported +//! @tparam numCompnentsCompileTime the maximum number of components supported +//! @param numComponentsRuntime the number of components found the in the deck file +//! @param argc argc argument from CLI +//! @param argv argv argument from CLI +//! +//! @return error code +template int startSimulationComponents(int numComponentsRuntime, int argc, char** argv) { - OPM_ERROR_IF(numComponentsCompileTime < numComponentsRuntime || numComponentsRuntime <= 0, + OPM_ERROR_IF(numComponentsCompileTime < numComponentsRuntime || numComponentsRuntime < minimumNumberOfComponents, fmt::format("Deck has {} components, not supported. We support a maximum of {} components, " - "and a minimum of 1.", + "and a minimum of {}.", numComponentsRuntime, - numComponentsCompileTime)); + numComponentsCompileTime, + minimumNumberOfComponents)); if (numComponentsCompileTime == numComponentsRuntime) { return Opm::start>(argc, argv, false); } - if constexpr (numComponentsCompileTime > 1) { - return startSimulationComponents(numComponentsRuntime, argc, argv); + if constexpr (numComponentsCompileTime > minimumNumberOfComponents) { + return startSimulationComponents(numComponentsRuntime, argc, argv); } // It will never actually reach this, but the compiler does not seem to realize, so keeping // this to avoid warnings. @@ -349,6 +366,6 @@ main(int argc, char** argv) Opm::FlowGenericVanguard::readDeck(inputFilename); Opm::FlowGenericVanguard vanguard; const auto numComps = vanguard.eclState().compositionalConfig().numComps(); - return startSimulationComponents<10>(numComps, argc, argv); + return startSimulationComponents<2, 7>(numComps, argc, argv); }