Merge pull request #4348 from akva2/small_eclproblem_improvements

Small eclproblem improvements
This commit is contained in:
Atgeirr Flø Rasmussen 2023-01-06 09:06:24 +01:00 committed by GitHub
commit 967378c1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 32 deletions

View File

@ -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,

View File

@ -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
*

View File

@ -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);
}
/*!
@ -801,7 +779,7 @@ public:
MICPModule::initFromState(vanguard.eclState());
// create the ECL writer
eclWriter_.reset(new EclWriterType(simulator));
eclWriter_ = std::make_unique<EclWriterType>(simulator);
enableDriftCompensation_ = EWOMS_GET_PARAM(TypeTag, bool, EclEnableDriftCompensation);
@ -2211,10 +2189,10 @@ private:
this->updateProperty_("EclProblem::updateMinPressure_() failed:",
[this](unsigned compressedDofIdx, const IntensiveQuantities& iq)
{
const auto& fs = iq.fluidState();
const Scalar mo = getValue(fs.pressure(oilPhaseIdx));
auto& mos = this->minOilPressure_;
mos[compressedDofIdx] = std::min(mos[compressedDofIdx], mo);
const auto& fs = iq.fluidState();
const Scalar mo = getValue(fs.pressure(oilPhaseIdx));
auto& mos = this->minOilPressure_;
mos[compressedDofIdx] = std::min(mos[compressedDofIdx], mo);
});
return true;
}