Merge pull request #412 from akva2/no_serialization_matman
Get rid of deck usage setting up MaterialLawManager
This commit is contained in:
commit
a003a21d5c
@ -161,9 +161,8 @@ public:
|
||||
*
|
||||
* This requires that the opm-parser module is available.
|
||||
*/
|
||||
void initFromDeck(const Opm::Deck& deck OPM_UNUSED,
|
||||
const Opm::EclipseState& eclState,
|
||||
Opm::EclTwoPhaseSystemType twoPhaseSystemType)
|
||||
void initFromState(const Opm::EclipseState& eclState,
|
||||
Opm::EclTwoPhaseSystemType twoPhaseSystemType)
|
||||
{
|
||||
const auto& endscale = eclState.runspec().endpointScaling();
|
||||
// find out if endpoint scaling is used in the first place
|
||||
@ -222,41 +221,6 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Serializer>
|
||||
std::size_t packSize(Serializer& serializer) const
|
||||
{
|
||||
return serializer.packSize(enableSatScaling_) +
|
||||
serializer.packSize(enableThreePointKrSatScaling_) +
|
||||
serializer.packSize(enablePcScaling_) +
|
||||
serializer.packSize(enableLeverettScaling_) +
|
||||
serializer.packSize(enableKrwScaling_) +
|
||||
serializer.packSize(enableKrnScaling_);
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void pack(std::vector<char>& buffer, int& position,
|
||||
Serializer& serializer) const
|
||||
{
|
||||
serializer.pack(enableSatScaling_, buffer, position);
|
||||
serializer.pack(enableThreePointKrSatScaling_, buffer, position);
|
||||
serializer.pack(enablePcScaling_, buffer, position);
|
||||
serializer.pack(enableLeverettScaling_, buffer, position);
|
||||
serializer.pack(enableKrwScaling_, buffer, position);
|
||||
serializer.pack(enableKrnScaling_, buffer, position);
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void unpack(std::vector<char>& buffer, int& position,
|
||||
Serializer& serializer)
|
||||
{
|
||||
serializer.unpack(enableSatScaling_, buffer, position);
|
||||
serializer.unpack(enableThreePointKrSatScaling_, buffer, position);
|
||||
serializer.unpack(enablePcScaling_, buffer, position);
|
||||
serializer.unpack(enableLeverettScaling_, buffer, position);
|
||||
serializer.unpack(enableKrwScaling_, buffer, position);
|
||||
serializer.unpack(enableKrnScaling_, buffer, position);
|
||||
}
|
||||
|
||||
private:
|
||||
// enable scaling of the input saturations (i.e., rescale the x-Axis)
|
||||
bool enableSatScaling_;
|
||||
|
@ -156,18 +156,13 @@ struct EclEpsScalingPointsInfo
|
||||
* I.e., the values which are used for the nested Fluid-Matrix interactions and which
|
||||
* are produced by them.
|
||||
*/
|
||||
void extractUnscaled(const Opm::Deck& deck,
|
||||
const Opm::EclipseState& eclState,
|
||||
void extractUnscaled(const Opm::EclipseState& eclState,
|
||||
unsigned satRegionIdx)
|
||||
{
|
||||
// determine the value of the relative permeability below which the corresponding
|
||||
// saturation is considered to be critical
|
||||
krCriticalEps = Opm::ParserKeywords::TOLCRIT::VALUE::defaultValue;
|
||||
if (deck.hasKeyword("TOLCRIT")) {
|
||||
const Opm::DeckKeyword& tolcritKeyword = deck.getKeyword("TOLCRIT");
|
||||
|
||||
krCriticalEps = tolcritKeyword.getRecord(0).getItem("VALUE").getSIDouble(0);
|
||||
}
|
||||
const auto& satFuncCtrls = eclState.runspec().saturationFunctionControls();
|
||||
krCriticalEps = satFuncCtrls.minimumRelpermMobilityThreshold();
|
||||
|
||||
const auto& tables = eclState.getTableManager();
|
||||
const TableContainer& swofTables = tables.getSwofTables();
|
||||
@ -179,9 +174,9 @@ struct EclEpsScalingPointsInfo
|
||||
const TableContainer& sof2Tables = tables.getSof2Tables();
|
||||
|
||||
|
||||
bool hasWater = deck.hasKeyword("WATER");
|
||||
bool hasGas = deck.hasKeyword("GAS");
|
||||
bool hasOil = deck.hasKeyword("OIL");
|
||||
bool hasWater = eclState.runspec().phases().active(Phase::WATER);
|
||||
bool hasGas = eclState.runspec().phases().active(Phase::GAS);
|
||||
bool hasOil = eclState.runspec().phases().active(Phase::OIL);
|
||||
|
||||
if (!hasWater) {
|
||||
Swl = 0.0;
|
||||
|
@ -113,91 +113,20 @@ public:
|
||||
*
|
||||
* This requires that the opm-parser module is available.
|
||||
*/
|
||||
void initFromDeck(const Opm::Deck& deck)
|
||||
void initFromState(const Opm::Runspec& runspec)
|
||||
{
|
||||
enableHysteresis_ = false;
|
||||
|
||||
if (!deck.hasKeyword("SATOPTS"))
|
||||
return;
|
||||
|
||||
const auto& satoptsItem = deck.getKeyword("SATOPTS").getRecord(0).getItem(0);
|
||||
for (unsigned i = 0; i < satoptsItem.data_size(); ++i) {
|
||||
std::string satoptsValue = satoptsItem.get< std::string >(0);
|
||||
std::transform(satoptsValue.begin(),
|
||||
satoptsValue.end(),
|
||||
satoptsValue.begin(),
|
||||
::toupper);
|
||||
|
||||
if (satoptsValue == "HYSTER")
|
||||
enableHysteresis_ = true;
|
||||
}
|
||||
|
||||
// check for the (deprecated) HYST keyword
|
||||
if (deck.hasKeyword("HYST"))
|
||||
enableHysteresis_ = true;
|
||||
enableHysteresis_ = runspec.hysterPar().active();
|
||||
|
||||
if (!enableHysteresis_)
|
||||
return;
|
||||
|
||||
if (!deck.hasKeyword("EHYSTR"))
|
||||
throw std::runtime_error("Enabling hysteresis via the HYST parameter for SATOPTS requires the "
|
||||
"presence of the EHYSTR keyword");
|
||||
|
||||
const auto& ehystrKeyword = deck.getKeyword("EHYSTR");
|
||||
if (deck.hasKeyword("NOHYKR"))
|
||||
krHysteresisModel_ = -1;
|
||||
else {
|
||||
krHysteresisModel_ = ehystrKeyword.getRecord(0).getItem("relative_perm_hyst").get<int>(0);
|
||||
|
||||
if (krHysteresisModel_ != 0 && krHysteresisModel_ != 1)
|
||||
throw std::runtime_error(
|
||||
"Only the Carlson relative permeability hystersis models (indicated by '0' or "
|
||||
"'1' for the second item of the 'EHYSTR' keyword) are supported");
|
||||
}
|
||||
|
||||
// this is slightly screwed: it is possible to specify contradicting hysteresis
|
||||
// models with HYPC/NOHYPC and the fifth item of EHYSTR. Let's ignore that for
|
||||
// now.
|
||||
std::string whereFlag =
|
||||
ehystrKeyword.getRecord(0).getItem("limiting_hyst_flag").getTrimmedString(0);
|
||||
if (deck.hasKeyword("NOHYPC") || whereFlag == "KR")
|
||||
pcHysteresisModel_ = -1;
|
||||
else {
|
||||
// if capillary pressure hysteresis is enabled, Eclipse always uses the
|
||||
// Killough model
|
||||
pcHysteresisModel_ = 0;
|
||||
|
||||
throw std::runtime_error("Capillary pressure hysteresis is not supported yet");
|
||||
}
|
||||
krHysteresisModel_ = runspec.hysterPar().krHysteresisModel();
|
||||
pcHysteresisModel_ = runspec.hysterPar().pcHysteresisModel();
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Serializer>
|
||||
std::size_t packSize(Serializer& serializer) const
|
||||
{
|
||||
return serializer.packSize(enableHysteresis_) +
|
||||
serializer.packSize(pcHysteresisModel_) +
|
||||
serializer.packSize(krHysteresisModel_);
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void pack(std::vector<char>& buffer, int& position,
|
||||
Serializer& serializer) const
|
||||
{
|
||||
serializer.pack(enableHysteresis_, buffer, position);
|
||||
serializer.pack(pcHysteresisModel_, buffer, position);
|
||||
serializer.pack(krHysteresisModel_, buffer, position);
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void unpack(std::vector<char>& buffer, int& position,
|
||||
Serializer& serializer)
|
||||
{
|
||||
serializer.unpack(enableHysteresis_, buffer, position);
|
||||
serializer.unpack(pcHysteresisModel_, buffer, position);
|
||||
serializer.unpack(krHysteresisModel_, buffer, position);
|
||||
}
|
||||
|
||||
private:
|
||||
// enable hysteresis at all
|
||||
bool enableHysteresis_;
|
||||
|
@ -50,7 +50,6 @@
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -116,8 +115,7 @@ public:
|
||||
EclMaterialLawManager()
|
||||
{}
|
||||
|
||||
void initFromDeck(const Opm::Deck& deck,
|
||||
const Opm::EclipseState& eclState)
|
||||
void initFromState(const Opm::EclipseState& eclState)
|
||||
{
|
||||
// get the number of saturation regions and the number of cells in the deck
|
||||
const size_t numSatRegions = eclState.runspec().tabdims().getNumSatTables();
|
||||
@ -127,24 +125,25 @@ public:
|
||||
hasOil = ph.active(Phase::OIL);
|
||||
hasWater = ph.active(Phase::WATER);
|
||||
|
||||
readGlobalEpsOptions_(deck, eclState);
|
||||
readGlobalHysteresisOptions_(deck);
|
||||
readGlobalThreePhaseOptions_(deck);
|
||||
readGlobalEpsOptions_(eclState);
|
||||
readGlobalHysteresisOptions_(eclState);
|
||||
readGlobalThreePhaseOptions_(eclState.runspec());
|
||||
|
||||
// read the end point scaling configuration. this needs to be done only once per
|
||||
// deck.
|
||||
gasOilConfig = std::make_shared<Opm::EclEpsConfig>();
|
||||
oilWaterConfig = std::make_shared<Opm::EclEpsConfig>();
|
||||
gasOilConfig->initFromDeck(deck, eclState, Opm::EclGasOilSystem);
|
||||
oilWaterConfig->initFromDeck(deck, eclState, Opm::EclOilWaterSystem);
|
||||
gasOilConfig->initFromState(eclState, Opm::EclGasOilSystem);
|
||||
oilWaterConfig->initFromState(eclState, Opm::EclOilWaterSystem);
|
||||
|
||||
unscaledEpsInfo_.resize(numSatRegions);
|
||||
if (deck.hasKeyword("STONE1EX"))
|
||||
const auto& stone1exTable = eclState.getTableManager().getStone1exTable();
|
||||
if (!stone1exTable.empty())
|
||||
stoneEtas.resize(numSatRegions);
|
||||
for (unsigned satRegionIdx = 0; satRegionIdx < numSatRegions; ++satRegionIdx) {
|
||||
unscaledEpsInfo_[satRegionIdx].extractUnscaled(deck, eclState, satRegionIdx);
|
||||
unscaledEpsInfo_[satRegionIdx].extractUnscaled(eclState, satRegionIdx);
|
||||
if (!stoneEtas.empty())
|
||||
stoneEtas[satRegionIdx] = deck.getKeyword("STONE1EX").getRecord(satRegionIdx).getItem(0).getSIDouble(0);
|
||||
stoneEtas[satRegionIdx] = stone1exTable[satRegionIdx].eta;
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,7 +353,7 @@ public:
|
||||
* \brief Modify the initial condition according to the SWATINIT keyword.
|
||||
*
|
||||
* The method returns the water saturation which yields a givenn capillary
|
||||
* pressure. The reason this method is not folded directly into initFromDeck() is
|
||||
* pressure. The reason this method is not folded directly into initFromState() is
|
||||
* that the capillary pressure given depends on the particuars of how the simulator
|
||||
* calculates its initial condition.
|
||||
*/
|
||||
@ -613,84 +612,26 @@ public:
|
||||
std::shared_ptr<EclEpsScalingPointsInfo<Scalar> >& oilWaterScaledEpsInfoDrainagePointerReferenceHack(unsigned elemIdx)
|
||||
{ return oilWaterScaledEpsInfoDrainage_[elemIdx]; }
|
||||
|
||||
template<class Serializer>
|
||||
std::size_t packSize(Serializer& serializer) const
|
||||
{
|
||||
return serializer.packSize(enableEndPointScaling_) +
|
||||
hysteresisConfig_->packSize(serializer) +
|
||||
oilWaterEclEpsConfig_->packSize(serializer) +
|
||||
serializer.packSize(unscaledEpsInfo_) +
|
||||
serializer.packSize(threePhaseApproach_) +
|
||||
serializer.packSize(twoPhaseApproach_) +
|
||||
gasOilConfig->packSize(serializer) +
|
||||
oilWaterConfig->packSize(serializer) +
|
||||
serializer.packSize(stoneEtas) +
|
||||
serializer.packSize(hasGas) +
|
||||
serializer.packSize(hasOil) +
|
||||
serializer.packSize(hasWater);
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void pack(std::vector<char>& buffer, int& position,
|
||||
Serializer& serializer) const
|
||||
{
|
||||
serializer.pack(enableEndPointScaling_, buffer, position);
|
||||
hysteresisConfig_->pack(buffer, position, serializer);
|
||||
oilWaterEclEpsConfig_->pack(buffer, position, serializer);
|
||||
serializer.pack(unscaledEpsInfo_, buffer, position);
|
||||
serializer.pack(threePhaseApproach_, buffer, position);
|
||||
serializer.pack(twoPhaseApproach_, buffer, position);
|
||||
gasOilConfig->pack(buffer, position, serializer);
|
||||
oilWaterConfig->pack(buffer, position, serializer);
|
||||
serializer.pack(stoneEtas, buffer, position);
|
||||
serializer.pack(hasGas, buffer, position);
|
||||
serializer.pack(hasOil, buffer, position);
|
||||
serializer.pack(hasWater, buffer, position);
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void unpack(std::vector<char>& buffer, int& position,
|
||||
Serializer& serializer)
|
||||
{
|
||||
oilWaterEclEpsConfig_ = std::make_shared<Opm::EclEpsConfig>();
|
||||
hysteresisConfig_ = std::make_shared<Opm::EclHysteresisConfig>();
|
||||
gasOilConfig = std::make_shared<Opm::EclEpsConfig>();
|
||||
oilWaterConfig = std::make_shared<Opm::EclEpsConfig>();
|
||||
|
||||
serializer.unpack(enableEndPointScaling_, buffer, position);
|
||||
hysteresisConfig_->unpack(buffer, position, serializer);
|
||||
oilWaterEclEpsConfig_->unpack(buffer, position, serializer);
|
||||
serializer.unpack(unscaledEpsInfo_, buffer, position);
|
||||
serializer.unpack(threePhaseApproach_, buffer, position);
|
||||
serializer.unpack(twoPhaseApproach_, buffer, position);
|
||||
gasOilConfig->unpack(buffer, position, serializer);
|
||||
oilWaterConfig->unpack(buffer, position, serializer);
|
||||
serializer.unpack(stoneEtas, buffer, position);
|
||||
serializer.unpack(hasGas, buffer, position);
|
||||
serializer.unpack(hasOil, buffer, position);
|
||||
serializer.unpack(hasWater, buffer, position);
|
||||
}
|
||||
|
||||
private:
|
||||
void readGlobalEpsOptions_(const Opm::Deck& deck, const Opm::EclipseState& eclState)
|
||||
void readGlobalEpsOptions_(const Opm::EclipseState& eclState)
|
||||
{
|
||||
oilWaterEclEpsConfig_ = std::make_shared<Opm::EclEpsConfig>();
|
||||
oilWaterEclEpsConfig_-> initFromDeck(deck, eclState, Opm::EclOilWaterSystem);
|
||||
oilWaterEclEpsConfig_->initFromState(eclState, Opm::EclOilWaterSystem);
|
||||
|
||||
enableEndPointScaling_ = deck.hasKeyword("ENDSCALE");
|
||||
enableEndPointScaling_ = eclState.getTableManager().hasTables("ENKRVD");
|
||||
}
|
||||
|
||||
void readGlobalHysteresisOptions_(const Opm::Deck& deck)
|
||||
void readGlobalHysteresisOptions_(const Opm::EclipseState& state)
|
||||
{
|
||||
hysteresisConfig_ = std::make_shared<Opm::EclHysteresisConfig>();
|
||||
hysteresisConfig_->initFromDeck(deck);
|
||||
hysteresisConfig_->initFromState(state.runspec());
|
||||
}
|
||||
|
||||
void readGlobalThreePhaseOptions_(const Opm::Deck& deck)
|
||||
void readGlobalThreePhaseOptions_(const Opm::Runspec& runspec)
|
||||
{
|
||||
bool gasEnabled = deck.hasKeyword("GAS");
|
||||
bool oilEnabled = deck.hasKeyword("OIL");
|
||||
bool waterEnabled = deck.hasKeyword("WATER");
|
||||
bool gasEnabled = runspec.phases().active(Phase::GAS);
|
||||
bool oilEnabled = runspec.phases().active(Phase::OIL);
|
||||
bool waterEnabled = runspec.phases().active(Phase::WATER);
|
||||
|
||||
int numEnabled =
|
||||
(gasEnabled?1:0)
|
||||
@ -714,9 +655,9 @@ private:
|
||||
assert(numEnabled == 3);
|
||||
|
||||
threePhaseApproach_ = EclMultiplexerApproach::EclDefaultApproach;
|
||||
if (deck.hasKeyword("STONE") || deck.hasKeyword("STONE2"))
|
||||
if (runspec.stoneType() == Runspec::StoneType::STONE2)
|
||||
threePhaseApproach_ = EclMultiplexerApproach::EclStone2Approach;
|
||||
else if (deck.hasKeyword("STONE1"))
|
||||
else if (runspec.stoneType() == Runspec::StoneType::STONE1)
|
||||
threePhaseApproach_ = EclMultiplexerApproach::EclStone1Approach;
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ inline void testAll()
|
||||
size_t n = eclGrid.getCartesianSize();
|
||||
|
||||
MaterialLawManager materialLawManager;
|
||||
materialLawManager.initFromDeck(deck, eclState);
|
||||
materialLawManager.initFromState(eclState);
|
||||
materialLawManager.initParamsForElements(eclState, n);
|
||||
|
||||
if (materialLawManager.enableEndPointScaling())
|
||||
@ -463,7 +463,7 @@ inline void testAll()
|
||||
const Opm::EclipseState fam2EclState(fam2Deck);
|
||||
|
||||
Opm::EclMaterialLawManager<MaterialTraits> fam2MaterialLawManager;
|
||||
fam2MaterialLawManager.initFromDeck(fam2Deck, fam2EclState);
|
||||
fam2MaterialLawManager.initFromState(fam2EclState);
|
||||
fam2MaterialLawManager.initParamsForElements(fam2EclState, n);
|
||||
|
||||
if (fam2MaterialLawManager.enableEndPointScaling())
|
||||
@ -476,7 +476,7 @@ inline void testAll()
|
||||
const Opm::EclipseState hysterEclState(hysterDeck);
|
||||
|
||||
Opm::EclMaterialLawManager<MaterialTraits> hysterMaterialLawManager;
|
||||
hysterMaterialLawManager.initFromDeck(hysterDeck, hysterEclState);
|
||||
hysterMaterialLawManager.initFromState(hysterEclState);
|
||||
hysterMaterialLawManager.initParamsForElements(hysterEclState, n);
|
||||
|
||||
if (hysterMaterialLawManager.enableEndPointScaling())
|
||||
@ -569,14 +569,14 @@ inline void testAll()
|
||||
const Opm::EclipseState fam1EclState(fam1Deck);
|
||||
|
||||
MaterialLawManager fam1materialLawManager;
|
||||
fam1materialLawManager.initFromDeck(fam1Deck, fam1EclState);
|
||||
fam1materialLawManager.initFromState(fam1EclState);
|
||||
fam1materialLawManager.initParamsForElements(fam1EclState, n);
|
||||
|
||||
const auto fam2Deck = parser.parseString(fam2DeckStringGasOil);
|
||||
const Opm::EclipseState fam2EclState(fam2Deck);
|
||||
|
||||
Opm::EclMaterialLawManager<MaterialTraits> fam2MaterialLawManager;
|
||||
fam2MaterialLawManager.initFromDeck(fam2Deck, fam2EclState);
|
||||
fam2MaterialLawManager.initFromState(fam2EclState);
|
||||
fam2MaterialLawManager.initParamsForElements(fam2EclState, n);
|
||||
|
||||
for (unsigned elemIdx = 0; elemIdx < n; ++ elemIdx) {
|
||||
|
Loading…
Reference in New Issue
Block a user