Merge pull request #5645 from kjetilly/flowexp_components

Support for 2 to 7 components in flowexp_comp
This commit is contained in:
Bård Skaflestad
2024-10-08 09:25:08 +02:00
committed by GitHub
14 changed files with 615 additions and 326 deletions

View File

@@ -52,13 +52,6 @@ class EclipseState;
class Schedule;
template<typename Grid, typename GridView> class LookUpData;
int eclPositionalParameter(std::function<void(const std::string&,
const std::string&)> addKey,
std::set<std::string>& seenParams,
std::string& errorMsg,
const char** argv,
int paramIdx);
/*!
* \ingroup BlackOilSimulator
*

View File

@@ -39,45 +39,11 @@
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <algorithm>
#include <iostream>
#include <stdexcept>
namespace Opm {
int eclPositionalParameter(std::function<void(const std::string&, const std::string&)> addKey,
std::set<std::string>& seenParams,
std::string& errorMsg,
const char** argv,
int paramIdx)
{
std::string param = argv[paramIdx];
std::size_t i = param.find('=');
if (i != std::string::npos) {
std::string oldParamName = param.substr(0, i);
std::string oldParamValue = param.substr(i+1);
std::string newParamName = "--" + oldParamName;
std::replace(newParamName.begin(),
newParamName.end(), '_' , '-');
errorMsg =
"The old syntax to specify parameters on the command line is no longer supported: "
"Try replacing '" + oldParamName + "=" + oldParamValue + "' with "+
"'" + newParamName + "=" + oldParamValue + "'!";
return 0;
}
if (seenParams.count("EclDeckFileName") > 0) {
errorMsg =
"Parameter 'EclDeckFileName' specified multiple times"
" as a command line parameter";
return 0;
}
addKey("EclDeckFileName", argv[paramIdx]);
seenParams.insert("EclDeckFileName");
return 1;
}
template<class GridView, class FluidSystem>
FlowGenericProblem<GridView,FluidSystem>::
FlowGenericProblem(const EclipseState& eclState,

View File

@@ -59,6 +59,7 @@
#include <opm/simulators/flow/FlowGenericProblem.hpp>
// TODO: maybe we can name it FlowProblemProperties.hpp
#include <opm/simulators/flow/FlowBaseProblemProperties.hpp>
#include <opm/simulators/flow/FlowUtils.hpp>
#include <opm/simulators/flow/TracerModel.hpp>
#include <opm/simulators/flow/Transmissibility.hpp>
#include <opm/simulators/timestepping/AdaptiveTimeStepping.hpp>
@@ -195,11 +196,11 @@ public:
int paramIdx,
int)
{
return eclPositionalParameter(addKey,
seenParams,
errorMsg,
argv,
paramIdx);
return detail::eclPositionalParameter(addKey,
seenParams,
errorMsg,
argv,
paramIdx);
}
/*!

View File

@@ -262,6 +262,39 @@ void hideUnusedParameters()
Parameters::Hide<Parameters::UseAverageDensityMsWells>();
}
int eclPositionalParameter(std::function<void(const std::string&, const std::string&)> addKey,
std::set<std::string>& seenParams,
std::string& errorMsg,
const char** argv,
int paramIdx)
{
std::string param = argv[paramIdx];
std::size_t i = param.find('=');
if (i != std::string::npos) {
std::string oldParamName = param.substr(0, i);
std::string oldParamValue = param.substr(i+1);
std::string newParamName = "--" + oldParamName;
std::replace(newParamName.begin(),
newParamName.end(), '_' , '-');
errorMsg =
"The old syntax to specify parameters on the command line is no longer supported: "
"Try replacing '" + oldParamName + "=" + oldParamValue + "' with "+
"'" + newParamName + "=" + oldParamValue + "'!";
return 0;
}
if (seenParams.count("EclDeckFileName") > 0) {
errorMsg =
"Parameter 'EclDeckFileName' specified multiple times"
" as a command line parameter";
return 0;
}
addKey("EclDeckFileName", argv[paramIdx]);
seenParams.insert("EclDeckFileName");
return 1;
}
template void hideUnusedParameters<double>();
#if FLOW_INSTANTIATE_FLOAT

View File

@@ -22,6 +22,8 @@
#ifndef OPM_FLOW_UTILS_HEADER_INCLUDED
#define OPM_FLOW_UTILS_HEADER_INCLUDED
#include <functional>
#include <set>
#include <string_view>
namespace Opm { struct SimulatorReport; }
@@ -44,6 +46,13 @@ void handleExtraConvergenceOutput(SimulatorReport& report,
template<class Scalar>
void hideUnusedParameters();
int eclPositionalParameter(std::function<void(const std::string&,
const std::string&)> addKey,
std::set<std::string>& seenParams,
std::string& errorMsg,
const char** argv,
int paramIdx);
} // namespace Opm::detail
#endif // OPM_FLOW_UTILS_HEADER_INCLUDED