2024-09-11 14:35:05 +02:00
|
|
|
/*
|
|
|
|
|
Copyright 2024, SINTEF Digital
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
#include "config.h"
|
2024-10-03 11:26:07 +02:00
|
|
|
|
|
|
|
|
#include <opm/input/eclipse/Deck/Deck.hpp>
|
2024-10-03 16:16:46 +02:00
|
|
|
#include <opm/input/eclipse/Parser/ParseContext.hpp>
|
2024-10-08 20:35:42 +02:00
|
|
|
#include <opm/input/eclipse/Parser/Parser.hpp>
|
2024-10-03 11:26:07 +02:00
|
|
|
|
2024-10-04 15:03:31 +02:00
|
|
|
#include <opm/models/utils/start.hh>
|
|
|
|
|
|
|
|
|
|
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
|
|
|
|
|
|
2024-10-08 14:51:07 +02:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
|
2024-10-09 13:56:06 +02:00
|
|
|
#include <array>
|
2024-10-09 10:16:08 +02:00
|
|
|
#include <cstdlib>
|
2024-10-08 20:35:42 +02:00
|
|
|
#include <tuple>
|
|
|
|
|
|
2024-10-03 15:34:35 +02:00
|
|
|
#include "flowexp_comp.hpp"
|
2024-10-03 16:16:46 +02:00
|
|
|
|
2024-10-08 20:35:42 +02:00
|
|
|
template <int compileTimeComponent>
|
|
|
|
|
std::tuple<bool, int>
|
|
|
|
|
runComponent(int runtimeComponent, int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
if (runtimeComponent == compileTimeComponent) {
|
|
|
|
|
return std::make_tuple(true, Opm::dispatchFlowExpComp<compileTimeComponent>(argc, argv));
|
|
|
|
|
}
|
|
|
|
|
return std::make_tuple(false, EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Runs a specified runtime component.
|
|
|
|
|
*
|
|
|
|
|
* This function checks if the provided runtime component matches the current compile-time component.
|
|
|
|
|
* If they match, it dispatches the simulator for the number of components and returns
|
|
|
|
|
* a tuple where the second element is the result of the execution.
|
|
|
|
|
*
|
|
|
|
|
* Otherwise, it recursively calls itself with the next component in the list.
|
|
|
|
|
*
|
|
|
|
|
* @param runtimecomponent The runtime component identifier to be executed.
|
|
|
|
|
* @param argc The number of command-line arguments.
|
|
|
|
|
* @param argv The array of command-line arguments.
|
|
|
|
|
* @return A tuple containing a boolean indicating if the component was executed and an integer result of the execution.
|
|
|
|
|
*
|
|
|
|
|
* @note We have two non-variadic templates to be able to properly overload for the base case.
|
|
|
|
|
*/
|
|
|
|
|
template <int currentCompileTimeComponent, int nextComponent, int... components>
|
|
|
|
|
std::tuple<bool, int>
|
|
|
|
|
runComponent(int runtimecomponent, int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
if (currentCompileTimeComponent == runtimecomponent) {
|
|
|
|
|
return std::make_tuple(true, Opm::dispatchFlowExpComp<currentCompileTimeComponent>(argc, argv));
|
|
|
|
|
}
|
|
|
|
|
return runComponent<nextComponent, components...>(runtimecomponent, argc, argv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char** argv)
|
2024-09-11 14:35:05 +02:00
|
|
|
{
|
2024-10-03 13:55:57 +02:00
|
|
|
using TypeTag = Opm::Properties::TTag::FlowExpCompProblem<0>;
|
2024-09-11 14:35:05 +02:00
|
|
|
Opm::registerEclTimeSteppingParameters<double>();
|
2024-10-03 11:26:07 +02:00
|
|
|
|
2024-10-03 16:16:46 +02:00
|
|
|
// At the moment, this is probably as optimal as can be.
|
|
|
|
|
// We only read the RUNSPEC of the Deck file to get the numComp,
|
|
|
|
|
// and for this we need to first read the CLI arguments.
|
2024-10-03 11:26:07 +02:00
|
|
|
Opm::setupParameters_<TypeTag>(argc, const_cast<const char**>(argv), true);
|
|
|
|
|
|
2024-10-03 13:55:57 +02:00
|
|
|
auto inputFilename
|
|
|
|
|
= Opm::FlowGenericVanguard::canonicalDeckPath(Opm::Parameters::Get<Opm::Parameters::EclDeckFileName>());
|
2024-10-03 16:16:46 +02:00
|
|
|
|
|
|
|
|
// Only read the RUNSPEC section of the deck
|
2024-10-08 20:35:42 +02:00
|
|
|
const auto deck
|
|
|
|
|
= Opm::Parser {}.parseFile(inputFilename, Opm::ParseContext {}, std::vector {Opm::Ecl::SectionType::RUNSPEC});
|
2024-10-03 16:16:46 +02:00
|
|
|
const auto runspec = Opm::Runspec(deck);
|
|
|
|
|
const auto numComps = runspec.numComps();
|
|
|
|
|
|
2024-10-09 10:16:08 +02:00
|
|
|
auto [componentSupported, executionStatus]
|
2024-10-08 20:35:42 +02:00
|
|
|
= runComponent<OPM_COMPILE_COMPONENTS_TEMPLATE_LIST>(numComps, argc, argv);
|
|
|
|
|
|
|
|
|
|
if (!componentSupported) {
|
2024-10-09 16:29:02 +02:00
|
|
|
fmt::print("Deck has {} components, not supported. In this build of the simulator, we support the "
|
|
|
|
|
"following number of components:\n\n\t{}.\n\n Note that the supported components can be changed "
|
|
|
|
|
"when configuring CMake through the OPM_COMPILE_COMPONENTS options. Exiting.\n",
|
2024-10-08 20:35:42 +02:00
|
|
|
numComps,
|
2024-10-09 13:56:06 +02:00
|
|
|
fmt::join(std::array {OPM_COMPILE_COMPONENTS_TEMPLATE_LIST}, ", "));
|
2024-10-03 15:34:35 +02:00
|
|
|
}
|
2024-10-09 10:16:08 +02:00
|
|
|
return executionStatus;
|
2024-09-11 14:35:05 +02:00
|
|
|
}
|