EPS Grid Properties: Prefer Single Assignments

This commit is contained in:
Bård Skaflestad 2020-12-09 09:10:35 +01:00
parent ce4cbafe95
commit fb5bdc1302

View File

@ -44,13 +44,13 @@
#include <opm/material/common/Means.hpp> #include <opm/material/common/Means.hpp>
#include <array>
#include <vector>
#include <string>
#include <iostream>
#include <cassert>
#include <algorithm> #include <algorithm>
#include <array>
#include <cassert>
#include <memory> #include <memory>
#include <string>
#include <vector>
namespace Opm { namespace Opm {
/*! /*!
* \brief Collects all grid properties which are relevant for end point scaling. * \brief Collects all grid properties which are relevant for end point scaling.
@ -81,14 +81,12 @@ public:
EclEpsGridProperties(const Opm::EclipseState& eclState, EclEpsGridProperties(const Opm::EclipseState& eclState,
bool useImbibition) bool useImbibition)
{ {
std::string kwPrefix = useImbibition?"I":""; const std::string kwPrefix = useImbibition ? "I" : "";
const auto& fp = eclState.fieldProps(); const auto& fp = eclState.fieldProps();
if (useImbibition) compressed_satnum = useImbibition
compressed_satnum = fp.get_int("IMBNUM"); ? fp.get_int("IMBNUM") : fp.get_int("SATNUM");
else
compressed_satnum = fp.get_int("SATNUM");
this->compressed_swl = try_get( fp, kwPrefix+"SWL"); this->compressed_swl = try_get( fp, kwPrefix+"SWL");
this->compressed_sgl = try_get( fp, kwPrefix+"SGL"); this->compressed_sgl = try_get( fp, kwPrefix+"SGL");
@ -108,20 +106,15 @@ public:
if (fp.has_double("PORO")) if (fp.has_double("PORO"))
this->compressed_poro = fp.get_double("PORO"); this->compressed_poro = fp.get_double("PORO");
if (fp.has_double("PERMX")) this->compressed_permx = fp.has_double("PERMX")
this->compressed_permx = fp.get_double("PERMX"); ? fp.get_double("PERMX")
else : std::vector<double>(this->compressed_satnum.size());
this->compressed_permx = std::vector<double>(this->compressed_satnum.size());
if (fp.has_double("PERMY")) this->compressed_permy = fp.has_double("PERMY")
this->compressed_permy = fp.get_double("PERMY"); ? fp.get_double("PERMY") : this->compressed_permx;
else
this->compressed_permy = this->compressed_permx;
if (fp.has_double("PERMZ")) this->compressed_permz = fp.has_double("PERMZ")
this->compressed_permz = fp.get_double("PERMZ"); ? fp.get_double("PERMZ") : this->compressed_permx;
else
this->compressed_permz= this->compressed_permx;
} }
#endif #endif
@ -202,11 +195,11 @@ public:
private: private:
const double *
const double * satfunc(const std::vector<double>& data, std::size_t active_index) const { satfunc(const std::vector<double>& data,
if (data.empty()) const std::size_t active_index) const
return nullptr; {
return &(data[active_index]); return data.empty() ? nullptr : &data[active_index];
} }