mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-09-05 04:40:19 -05:00
eclproblem: move core of handlePositionalParameter
make it a typetag independent helper function in generic problem source
This commit is contained in:
@@ -33,6 +33,9 @@
|
||||
|
||||
#include <opm/grid/CpGrid.hpp>
|
||||
#include <opm/grid/polyhedralgrid.hh>
|
||||
|
||||
#include <dune/common/parametertree.hh>
|
||||
|
||||
#if HAVE_DUNE_ALUGRID
|
||||
#include <dune/alugrid/grid.hh>
|
||||
#include <dune/alugrid/3d/gridview.hh>
|
||||
@@ -47,12 +50,46 @@
|
||||
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
int eclPositionalParameter(Dune::ParameterTree& tree,
|
||||
std::set<std::string>& seenParams,
|
||||
std::string& errorMsg,
|
||||
const char** argv,
|
||||
int paramIdx)
|
||||
{
|
||||
std::string param = argv[paramIdx];
|
||||
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;
|
||||
}
|
||||
|
||||
tree["EclDeckFileName"] = argv[paramIdx];
|
||||
seenParams.insert("EclDeckFileName");
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<class GridView, class FluidSystem, class Scalar>
|
||||
EclGenericProblem<GridView,FluidSystem,Scalar>::
|
||||
EclGenericProblem(const EclipseState& eclState,
|
||||
|
||||
@@ -32,15 +32,26 @@
|
||||
#include <opm/material/common/Tabulated1DFunction.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Dune {
|
||||
class ParameterTree;
|
||||
}
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class Deck;
|
||||
class EclipseState;
|
||||
class Schedule;
|
||||
|
||||
int eclPositionalParameter(Dune::ParameterTree& tree,
|
||||
std::set<std::string>& seenParams,
|
||||
std::string& errorMsg,
|
||||
const char** argv,
|
||||
int paramIdx);
|
||||
|
||||
/*!
|
||||
* \ingroup EclBlackOilSimulator
|
||||
*
|
||||
|
||||
+5
-27
@@ -734,33 +734,11 @@ public:
|
||||
{
|
||||
using ParamsMeta = GetProp<TypeTag, Properties::ParameterMetaData>;
|
||||
Dune::ParameterTree& tree = ParamsMeta::tree();
|
||||
|
||||
std::string param = argv[paramIdx];
|
||||
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;
|
||||
for (size_t j = 0; j < newParamName.size(); ++j)
|
||||
if (newParamName[j] == '_')
|
||||
newParamName[j] = '-';
|
||||
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;
|
||||
}
|
||||
|
||||
tree["EclDeckFileName"] = argv[paramIdx];
|
||||
seenParams.insert("EclDeckFileName");
|
||||
return 1;
|
||||
return eclPositionalParameter(tree,
|
||||
seenParams,
|
||||
errorMsg,
|
||||
argv,
|
||||
paramIdx);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user