Add Oil Phase Saturation Function Consistency Checks

This commit introduces a set of consistency checks for the oil phase
saturation functions.  These plug into the framework introduced in
commit c3939c544 (PR #5438).  We implement the following four checks
for the gas/oil two-phase system

  - 0 <= SOGCR < 1
  - SWL + SGU <= 1
  - SOGCR < 1 - SWL - SGL
  - SOGCR < 1 - SWL - SGCR

which all guarantee a non-negative (mobile) oil saturation in the
gas/oil system.  Similarly, we implement the following four checks
for the oil/water two-phase system

  - 0 <= SOWCR < 1
  - SGL + SWU <= 1
  - SOWCR < 1 - SWL - SGL
  - SOWCR < 1 - SWCR - SGL

which provide the same guarantees as outlined above, but for the
oil/water system.

We add a base class, PhaseCheckBase<Scalar>, which provides a common
representation of the violated/critical predicates and implement the
specific checks as derived types of this base class.
This commit is contained in:
Bård Skaflestad
2024-09-02 18:40:59 +02:00
parent f3db66057f
commit 2e70fc407e
7 changed files with 3166 additions and 1 deletions

View File

@@ -188,6 +188,8 @@ list (APPEND MAIN_SOURCE_FILES
if (HAVE_ECL_INPUT)
list (APPEND MAIN_SOURCE_FILES
opm/simulators/utils/satfunc/OilPhaseConsistencyChecks.cpp
opm/simulators/utils/satfunc/PhaseCheckBase.cpp
opm/simulators/utils/satfunc/SatfuncConsistencyChecks.cpp
)
endif()
@@ -372,6 +374,7 @@ list (APPEND TEST_SOURCE_FILES
if (HAVE_ECL_INPUT)
list(APPEND TEST_SOURCE_FILES
tests/test_nonnc.cpp
tests/test_OilSatfuncConsistencyChecks.cpp
tests/test_SatfuncConsistencyChecks.cpp
tests/test_SatfuncConsistencyChecks_parallel.cpp
)
@@ -977,6 +980,8 @@ endif()
if (HAVE_ECL_INPUT)
list (APPEND PUBLIC_HEADER_FILES
opm/simulators/utils/satfunc/OilPhaseConsistencyChecks.hpp
opm/simulators/utils/satfunc/PhaseCheckBase.hpp
opm/simulators/utils/satfunc/SatfuncConsistencyChecks.hpp
)
endif()

View File

@@ -0,0 +1,264 @@
/*
Copyright 2024 Equinor AS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <opm/simulators/utils/satfunc/OilPhaseConsistencyChecks.hpp>
#include <opm/simulators/utils/satfunc/PhaseCheckBase.hpp>
#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::SOcr_GO<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->sogcr_ = endPoints.Sogcr;
if (! std::isfinite(this->sogcr_)) {
this->setViolated();
this->setCritical();
return;
}
const auto low = this->sogcr_ < Scalar{0};
const auto high = ! (this->sogcr_ < Scalar{1});
if (low || high) {
this->setViolated();
this->setCritical();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::SOmin_GO<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->swl_ = endPoints.Swl;
this->sgu_ = endPoints.Sgu;
if (! std::isfinite(this->swl_) ||
! std::isfinite(this->sgu_))
{
this->setViolated();
this->setCritical();
return;
}
if (this->swl_ + this->sgu_ > Scalar{1}) {
this->setViolated();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::MobileOil_GO_SGmin<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->swl_ = endPoints.Swl;
this->sgl_ = endPoints.Sgl;
this->sogcr_ = endPoints.Sogcr;
if (! std::isfinite(this->swl_) ||
! std::isfinite(this->sgl_) ||
! std::isfinite(this->sogcr_))
{
this->setViolated();
this->setCritical();
return;
}
if (! (this->sogcr_ < Scalar{1} - this->swl_ - this->sgl_)) {
this->setViolated();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::MobileOil_GO_SGcr<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->swl_ = endPoints.Swl;
this->sgcr_ = endPoints.Sgcr;
this->sogcr_ = endPoints.Sogcr;
if (! std::isfinite(this->swl_) ||
! std::isfinite(this->sgcr_) ||
! std::isfinite(this->sogcr_))
{
this->setViolated();
this->setCritical();
return;
}
if (! (this->sogcr_ < Scalar{1} - this->swl_ - this->sgcr_)) {
this->setViolated();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::SOcr_OW<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->sowcr_ = endPoints.Sowcr;
if (! std::isfinite(this->sowcr_)) {
this->setViolated();
this->setCritical();
return;
}
const auto low = this->sowcr_ < Scalar{0};
const auto high = ! (this->sowcr_ < Scalar{1});
if (low || high) {
this->setViolated();
this->setCritical();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::SOmin_OW<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->sgl_ = endPoints.Sgl;
this->swu_ = endPoints.Swu;
if (! std::isfinite(this->sgl_) ||
! std::isfinite(this->swu_))
{
this->setViolated();
this->setCritical();
return;
}
if (this->sgl_ + this->swu_ > Scalar{1}) {
this->setViolated();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::MobileOil_OW_SWmin<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->swl_ = endPoints.Swl;
this->sgl_ = endPoints.Sgl;
this->sowcr_ = endPoints.Sowcr;
if (! std::isfinite(this->swl_) ||
! std::isfinite(this->sgl_) ||
! std::isfinite(this->sowcr_))
{
this->setViolated();
this->setCritical();
return;
}
if (! (this->sowcr_ < Scalar{1} - this->swl_ - this->sgl_)) {
this->setViolated();
}
}
// ---------------------------------------------------------------------------
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::Oil::MobileOil_OW_SWcr<Scalar>::
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->sgl_ = endPoints.Sgl;
this->swcr_ = endPoints.Swcr;
this->sowcr_ = endPoints.Sowcr;
if (! std::isfinite(this->sgl_) ||
! std::isfinite(this->swcr_) ||
! std::isfinite(this->sowcr_))
{
this->setViolated();
this->setCritical();
return;
}
if (! (this->sowcr_ < Scalar{1} - this->swcr_ - this->sgl_)) {
this->setViolated();
}
}
// ===========================================================================
// Explicit Specialisations of Individual Check Templates
//
// No other code below this separator
// ===========================================================================
template class Opm::Satfunc::PhaseChecks::Oil::SOcr_GO<float>;
template class Opm::Satfunc::PhaseChecks::Oil::SOcr_GO<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::SOmin_GO<float>;
template class Opm::Satfunc::PhaseChecks::Oil::SOmin_GO<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_GO_SGmin<float>;
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_GO_SGmin<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_GO_SGcr<float>;
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_GO_SGcr<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::SOcr_OW<float>;
template class Opm::Satfunc::PhaseChecks::Oil::SOcr_OW<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::SOmin_OW<float>;
template class Opm::Satfunc::PhaseChecks::Oil::SOmin_OW<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_OW_SWmin<float>;
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_OW_SWmin<double>;
// ---------------------------------------------------------------------------
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_OW_SWcr<float>;
template class Opm::Satfunc::PhaseChecks::Oil::MobileOil_OW_SWcr<double>;

View File

@@ -0,0 +1,533 @@
/*
Copyright 2024 Equinor AS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OIL_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
#define OIL_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
#include <opm/simulators/utils/satfunc/SatfuncConsistencyChecks.hpp>
#include <opm/simulators/utils/satfunc/PhaseCheckBase.hpp>
#include <cstddef>
#include <string>
namespace Opm::Satfunc::PhaseChecks::Oil {
/// Verify that critical oil saturation in gas/oil system is in valid range
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class SOcr_GO : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 1; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->sogcr_;
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Non-negative critical oil saturation in G/O system" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "0 <= SOGCR < 1" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SOGCR";
}
private:
/// Critical oil saturation in gas/oil system.
Scalar sogcr_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
/// Verify that minimum oil saturation in gas/oil system is in valid range
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class SOmin_GO : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 3; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->swl_;
exportedCheckValues[1] = this->sgu_;
exportedCheckValues[2] = this->swl_ + this->sgu_;
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Non-negative minimum oil saturation in G/O system" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "SWL + SGU <= 1" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SWL";
headers[1] = "SGU";
headers[2] = "SWL + SGU";
}
private:
/// Minimum (connate) water saturation in gas/oil system.
Scalar swl_;
/// Maximum gas saturation in gas/oil system.
Scalar sgu_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
/// Verify that critical oil saturation in gas/oil system is strictly
/// smaller than maximum oil saturation.
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class MobileOil_GO_SGmin : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 4; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->swl_;
exportedCheckValues[1] = this->sgl_;
exportedCheckValues[2] = this->sogcr_;
exportedCheckValues[3] = Scalar{1} - (this->swl_ + this->sgl_);
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Mobile oil saturation in G/O system at minimum gas saturation" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "SOGCR < 1 - SWL - SGL" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SWL";
headers[1] = "SGL";
headers[2] = "SOGCR";
headers[3] = "1 - SWL - SGL";
}
private:
/// Minimum water saturation.
Scalar swl_;
/// Minimum gas saturation.
Scalar sgl_;
/// Critical oil saturation in gas/oil system.
Scalar sogcr_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
/// Verify that critical oil saturation in gas/oil system is strictly
/// smaller than oil saturation at critical gas saturation.
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class MobileOil_GO_SGcr : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 4; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->swl_;
exportedCheckValues[1] = this->sgcr_;
exportedCheckValues[2] = this->sogcr_;
exportedCheckValues[3] = Scalar{1} - (this->swl_ + this->sgcr_);
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Mobile oil saturation in G/O system at critical gas saturation" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "SOGCR < 1 - SWL - SGCR" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SWL";
headers[1] = "SGCR";
headers[2] = "SOGCR";
headers[3] = "1 - SWL - SGCR";
}
private:
/// Minimum water saturation.
Scalar swl_;
/// Critical gas saturation.
Scalar sgcr_;
/// Critical oil saturation in gas/oil system
Scalar sogcr_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
// -----------------------------------------------------------------------
/// Verify that critical oil saturation in oil/water system is in valid range
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class SOcr_OW : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 1; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->sowcr_;
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Non-negative critical oil saturation in O/W system" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "0 <= SOWCR < 1" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SOWCR";
}
private:
/// Critical oil saturation in oil/water system.
Scalar sowcr_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
/// Verify that minimum oil saturation in oil/water system is in valid range
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class SOmin_OW : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 3; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->sgl_;
exportedCheckValues[1] = this->swu_;
exportedCheckValues[2] = this->sgl_ + this->swu_;
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Non-negative minimum oil saturation in G/O system" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "SGL + SWU <= 1" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SGL";
headers[1] = "SWU";
headers[2] = "SGL + SWU";
}
private:
/// Minimum gas saturation. Typically zero.
Scalar sgl_;
/// Minimum (connate) saturation.
Scalar swu_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
/// Verify that critical oil saturation in oil/water system is strictly
/// smaller than maximum oil saturation.
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class MobileOil_OW_SWmin : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 4; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->swl_;
exportedCheckValues[1] = this->sgl_;
exportedCheckValues[2] = this->sowcr_;
exportedCheckValues[3] = Scalar{1} - (this->swl_ + this->sgl_);
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Mobile oil saturation in O/W system at minimum water saturation" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "SOWCR < 1 - SWL - SGL" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SWL";
headers[1] = "SGL";
headers[2] = "SOWCR";
headers[3] = "1 - SWL - SGL";
}
private:
/// Minimum (connate) water saturation.
Scalar swl_;
/// Minimum gas saturation. Typically zero.
Scalar sgl_;
/// Critical oil saturation in oil/water system.
Scalar sowcr_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
/// Verify that critical oil saturation in oil/water system is strictly
/// smaller than oil saturation at critical water saturation.
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class MobileOil_OW_SWcr : public PhaseCheckBase<Scalar>
{
public:
/// Number of \c Scalar values involved in the check.
std::size_t numExportedCheckValues() const override { return 4; };
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.
void exportCheckValues(Scalar* exportedCheckValues) const override
{
exportedCheckValues[0] = this->sgl_;
exportedCheckValues[1] = this->swcr_;
exportedCheckValues[2] = this->sowcr_;
exportedCheckValues[3] = Scalar{1} - this->swcr_ - this->sgl_;
}
/// Descriptive textual summary of this check.
std::string description() const override
{
return { "Mobile oil saturation in O/W system at critical water saturation" };
}
/// Textual representation of the consistency condition.
std::string condition() const override
{
return { "SOWCR < 1 - SWCR - SGL" };
}
/// Retrieve names of the exported check values.
///
/// \param[in,out] headers Pointer to contiguous sequence of at
/// least numExportedCheckValues() strings.
void columnNames(std::string* headers) const override
{
headers[0] = "SGL";
headers[1] = "SWCR";
headers[2] = "SOWCR";
headers[3] = "1 - SWCR - SGL";
}
private:
/// Minimum gas saturation. Typically zero.
Scalar sgl_;
/// Critical water saturation.
Scalar swcr_;
/// Critical oil saturation in oil/water system.
Scalar sowcr_;
/// Run check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
};
} // namespace Opm::Satfunc::PhaseChecks::Oil
#endif // OIL_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED

View File

@@ -0,0 +1,72 @@
/*
Copyright 2024 Equinor AS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <opm/simulators/utils/satfunc/PhaseCheckBase.hpp>
namespace {
constexpr auto one_bit = static_cast<unsigned char>(1);
constexpr auto failed_bit = one_bit << 0u;
constexpr auto critical_bit = one_bit << 1u;
}
// ===========================================================================
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::PhaseCheckBase<Scalar>::
test(const EclEpsScalingPointsInfo<Scalar>& endPoints)
{
this->flags_ = static_cast<unsigned char>(0);
this->testImpl(endPoints);
}
template <typename Scalar>
bool Opm::Satfunc::PhaseChecks::PhaseCheckBase<Scalar>::isViolated() const
{
return (this->flags_ & failed_bit) != 0;
}
template <typename Scalar>
bool Opm::Satfunc::PhaseChecks::PhaseCheckBase<Scalar>::isCritical() const
{
return (this->flags_ & critical_bit) != 0;
}
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::PhaseCheckBase<Scalar>::setViolated()
{
this->flags_ |= failed_bit;
}
template <typename Scalar>
void Opm::Satfunc::PhaseChecks::PhaseCheckBase<Scalar>::setCritical()
{
this->flags_ |= critical_bit;
}
// ===========================================================================
// Explicit Specialisations of PhaseCheckBase Templates
//
// No other code below this separator
// ===========================================================================
template class Opm::Satfunc::PhaseChecks::PhaseCheckBase<float>;
template class Opm::Satfunc::PhaseChecks::PhaseCheckBase<double>;

View File

@@ -0,0 +1,88 @@
/*
Copyright 2024 Equinor AS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PHASE_CHECK_BASE_HPP_INCLUDED
#define PHASE_CHECK_BASE_HPP_INCLUDED
#include <opm/simulators/utils/satfunc/SatfuncConsistencyChecks.hpp>
namespace Opm::Satfunc::PhaseChecks {
/// Base class for all phase saturation function consistency checks.
///
/// Provides common implementation of parts of the public Check
/// interface in terms of packed flags.
///
/// \tparam Scalar Element type. Typically \c float or \c double.
template <typename Scalar>
class PhaseCheckBase : public SatfuncConsistencyChecks<Scalar>::Check
{
public:
/// Run specific check against a set of saturation function end-points.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
void test(const EclEpsScalingPointsInfo<Scalar>& endPoints) override;
/// Whether or not last set of end-points violated this particular
/// check.
bool isViolated() const override;
/// Whether or not this check is critical to the simulator's ability
/// to run the case.
///
/// Violating critical checks should typically stop the run.
bool isCritical() const override;
protected:
/// Mark check as violated.
///
/// Intended to be called by derived types only.
void setViolated();
/// Mark check as violated at critical level.
///
/// Intended to be called by derived types only.
void setCritical();
private:
/// Collection of violation flags.
///
/// Packed bit fields.
unsigned char flags_{0};
/// Run specific check against a set of saturation function end-points.
///
/// Actual test function. Implemented in derived types and called
/// from the test() member function.
///
/// \param[in] endPoints Set of saturation function end-points.
/// Might for instance be the scaled end-points of the drainage
/// functions in a single grid block or the unscaled end-points
/// of the tabulated saturation functions in a single saturation
/// region.
virtual void testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints) = 0;
};
} // namespace Opm::Satfunc::PhaseChecks
#endif // PHASE_CHECK_BASE_HPP_INCLUDED

View File

@@ -75,7 +75,7 @@ namespace Opm {
/// Number of \c Scalar values involved in the check.
virtual std::size_t numExportedCheckValues() const = 0;
/// Get a linearised copy of the \c Sclar values involved in the check.
/// Get a linearised copy of the \c Scalar values involved in the check.
///
/// \param[in,out] exportedCheckValues Pointer to contiguous
/// sequence of at least numExportedCheckValues() \c Scalars.

File diff suppressed because it is too large Load Diff