mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-07-30 09:27:56 -05:00
Add Gas Phase Saturation Function Consistency Checks
This commit introduces a set of consistency checks for the gas phase
saturation functions. These plug into the framework introduced in
commit c3939c544 (PR #5438). We implement the following three checks
- 0 <= SGL < 1
- 0 <= SGU < 1
- SGL <= SGCR < SGU
which collectively enable a non-negative oil saturation in the two
phase gas/oil system.
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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/GasPhaseConsistencyChecks.hpp>
|
||||
|
||||
#include <opm/simulators/utils/satfunc/PhaseCheckBase.hpp>
|
||||
|
||||
#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename Scalar>
|
||||
void Opm::Satfunc::PhaseChecks::Gas::SGmin<Scalar>::
|
||||
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
|
||||
{
|
||||
this->sgl_ = endPoints.Sgl;
|
||||
|
||||
if (! std::isfinite(this->sgl_)) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto low = this->sgl_ < Scalar{0};
|
||||
const auto high = ! (this->sgl_ < Scalar{1});
|
||||
|
||||
if (low || high) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename Scalar>
|
||||
void Opm::Satfunc::PhaseChecks::Gas::SGmax<Scalar>::
|
||||
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
|
||||
{
|
||||
this->sgu_ = endPoints.Sgu;
|
||||
|
||||
if (! std::isfinite(this->sgu_)) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto low = this->sgu_ < Scalar{0};
|
||||
const auto high = ! (this->sgu_ < Scalar{1});
|
||||
|
||||
if (low || high) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename Scalar>
|
||||
void Opm::Satfunc::PhaseChecks::Gas::SGcr<Scalar>::
|
||||
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
|
||||
{
|
||||
this->sgl_ = endPoints.Sgl;
|
||||
this->sgcr_ = endPoints.Sgcr;
|
||||
this->sgu_ = endPoints.Sgu;
|
||||
|
||||
if (! std::isfinite(this->sgl_) ||
|
||||
! std::isfinite(this->sgcr_) ||
|
||||
! std::isfinite(this->sgu_))
|
||||
{
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto low = this->sgcr_ < this->sgl_;
|
||||
const auto high = ! (this->sgcr_ < this->sgu_);
|
||||
|
||||
if (low || high) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Explicit Specialisations of Individual Check Templates
|
||||
//
|
||||
// No other code below this separator
|
||||
// ===========================================================================
|
||||
|
||||
template class Opm::Satfunc::PhaseChecks::Gas::SGmin<float>;
|
||||
template class Opm::Satfunc::PhaseChecks::Gas::SGmin<double>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template class Opm::Satfunc::PhaseChecks::Gas::SGmax<float>;
|
||||
template class Opm::Satfunc::PhaseChecks::Gas::SGmax<double>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template class Opm::Satfunc::PhaseChecks::Gas::SGcr<float>;
|
||||
template class Opm::Satfunc::PhaseChecks::Gas::SGcr<double>;
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
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 GAS_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
|
||||
#define GAS_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
|
||||
|
||||
#include <opm/simulators/utils/satfunc/PhaseCheckBase.hpp>
|
||||
#include <opm/simulators/utils/satfunc/SatfuncConsistencyChecks.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
namespace Opm::Satfunc::PhaseChecks::Gas {
|
||||
|
||||
/// Verify that minimum gas saturation is in valid range
|
||||
///
|
||||
/// \tparam Scalar Element type. Typically \c float or \c double.
|
||||
template <typename Scalar>
|
||||
class SGmin : 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->sgl_;
|
||||
}
|
||||
|
||||
/// Descriptive textual summary of this check.
|
||||
std::string description() const override
|
||||
{
|
||||
return { "Non-negative minimum gas saturation" };
|
||||
}
|
||||
|
||||
/// Textual representation of the consistency condition.
|
||||
std::string condition() const override
|
||||
{
|
||||
return { "0 <= SGL < 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";
|
||||
}
|
||||
|
||||
private:
|
||||
/// Minimum gas saturation.
|
||||
Scalar sgl_;
|
||||
|
||||
/// 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 maximum gas saturation is in valid range.
|
||||
///
|
||||
/// \tparam Scalar Element type. Typically \c float or \c double.
|
||||
template <typename Scalar>
|
||||
class SGmax : 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->sgu_;
|
||||
}
|
||||
|
||||
/// Descriptive textual summary of this check.
|
||||
std::string description() const override
|
||||
{
|
||||
return { "Non-negative maximum gas saturation strictly less than one" };
|
||||
}
|
||||
|
||||
/// Textual representation of the consistency condition.
|
||||
std::string condition() const override
|
||||
{
|
||||
return { "0 <= 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] = "SGU";
|
||||
}
|
||||
|
||||
private:
|
||||
/// Maximum gas saturation.
|
||||
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 gas saturation is in valid range.
|
||||
///
|
||||
/// \tparam Scalar Element type. Typically \c float or \c double.
|
||||
template <typename Scalar>
|
||||
class SGcr : 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->sgcr_;
|
||||
exportedCheckValues[2] = this->sgu_;
|
||||
}
|
||||
|
||||
/// Descriptive textual summary of this check.
|
||||
std::string description() const override
|
||||
{
|
||||
return { "Mobile gas saturation" };
|
||||
}
|
||||
|
||||
/// Textual representation of the consistency condition.
|
||||
std::string condition() const override
|
||||
{
|
||||
return { "SGL <= SGCR < SGU" };
|
||||
}
|
||||
|
||||
/// 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] = "SGCR";
|
||||
headers[2] = "SGU";
|
||||
}
|
||||
|
||||
private:
|
||||
/// Minimum gas saturation.
|
||||
Scalar sgl_;
|
||||
|
||||
/// Critical gas saturation.
|
||||
Scalar sgcr_;
|
||||
|
||||
/// Maximum gas saturation.
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace Opm::Satfunc::PhaseChecks::Gas
|
||||
|
||||
#endif // GAS_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
|
||||
Reference in New Issue
Block a user