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
3 changed files with 58 additions and 32 deletions

View File

@@ -33,6 +33,9 @@
#include <opm/grid/CpGrid.hpp> #include <opm/grid/CpGrid.hpp>
#include <opm/grid/polyhedralgrid.hh> #include <opm/grid/polyhedralgrid.hh>
#include <dune/common/parametertree.hh>
#if HAVE_DUNE_ALUGRID #if HAVE_DUNE_ALUGRID
#include <dune/alugrid/grid.hh> #include <dune/alugrid/grid.hh>
#include <dune/alugrid/3d/gridview.hh> #include <dune/alugrid/3d/gridview.hh>
@@ -47,12 +50,46 @@
#include <boost/date_time.hpp> #include <boost/date_time.hpp>
#include <algorithm>
#include <limits> #include <limits>
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
namespace Opm { 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> template<class GridView, class FluidSystem, class Scalar>
EclGenericProblem<GridView,FluidSystem,Scalar>:: EclGenericProblem<GridView,FluidSystem,Scalar>::
EclGenericProblem(const EclipseState& eclState, EclGenericProblem(const EclipseState& eclState,

View File

@@ -32,15 +32,26 @@
#include <opm/material/common/Tabulated1DFunction.hpp> #include <opm/material/common/Tabulated1DFunction.hpp>
#include <array> #include <array>
#include <set>
#include <string> #include <string>
#include <vector> #include <vector>
namespace Dune {
class ParameterTree;
}
namespace Opm { namespace Opm {
class Deck; class Deck;
class EclipseState; class EclipseState;
class Schedule; class Schedule;
int eclPositionalParameter(Dune::ParameterTree& tree,
std::set<std::string>& seenParams,
std::string& errorMsg,
const char** argv,
int paramIdx);
/*! /*!
* \ingroup EclBlackOilSimulator * \ingroup EclBlackOilSimulator
* *

View File

@@ -734,33 +734,11 @@ public:
{ {
using ParamsMeta = GetProp<TypeTag, Properties::ParameterMetaData>; using ParamsMeta = GetProp<TypeTag, Properties::ParameterMetaData>;
Dune::ParameterTree& tree = ParamsMeta::tree(); Dune::ParameterTree& tree = ParamsMeta::tree();
return eclPositionalParameter(tree,
std::string param = argv[paramIdx]; seenParams,
size_t i = param.find('='); errorMsg,
if (i != std::string::npos) { argv,
std::string oldParamName = param.substr(0, i); paramIdx);
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;
} }
/*! /*!
@@ -801,7 +779,7 @@ public:
MICPModule::initFromState(vanguard.eclState()); MICPModule::initFromState(vanguard.eclState());
// create the ECL writer // create the ECL writer
eclWriter_.reset(new EclWriterType(simulator)); eclWriter_ = std::make_unique<EclWriterType>(simulator);
enableDriftCompensation_ = EWOMS_GET_PARAM(TypeTag, bool, EclEnableDriftCompensation); enableDriftCompensation_ = EWOMS_GET_PARAM(TypeTag, bool, EclEnableDriftCompensation);
@@ -2211,10 +2189,10 @@ private:
this->updateProperty_("EclProblem::updateMinPressure_() failed:", this->updateProperty_("EclProblem::updateMinPressure_() failed:",
[this](unsigned compressedDofIdx, const IntensiveQuantities& iq) [this](unsigned compressedDofIdx, const IntensiveQuantities& iq)
{ {
const auto& fs = iq.fluidState(); const auto& fs = iq.fluidState();
const Scalar mo = getValue(fs.pressure(oilPhaseIdx)); const Scalar mo = getValue(fs.pressure(oilPhaseIdx));
auto& mos = this->minOilPressure_; auto& mos = this->minOilPressure_;
mos[compressedDofIdx] = std::min(mos[compressedDofIdx], mo); mos[compressedDofIdx] = std::min(mos[compressedDofIdx], mo);
}); });
return true; return true;
} }