mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add Water Phase Saturation Function Consistency Checks
This commit introduces a set of consistency checks for the water
phase saturation functions. These plug into the framework
introduced in commit c3939c544 (PR #5438). We implement the
following three checks
- 0 <= SWL < 1
- 0 < SWU <= 1
- SWL <= SWCR < SWU
which collectively enable a non-negative oil saturation in the two
phase oil/water system.
This commit is contained in:
128
opm/simulators/utils/satfunc/WaterPhaseConsistencyChecks.cpp
Normal file
128
opm/simulators/utils/satfunc/WaterPhaseConsistencyChecks.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
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/WaterPhaseConsistencyChecks.hpp>
|
||||
|
||||
#include <opm/simulators/utils/satfunc/PhaseCheckBase.hpp>
|
||||
|
||||
#include <opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename Scalar>
|
||||
void Opm::Satfunc::PhaseChecks::Water::SWmin<Scalar>::
|
||||
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
|
||||
{
|
||||
// 0 <= SWL < 1
|
||||
|
||||
this->swl_ = endPoints.Swl;
|
||||
|
||||
if (! std::isfinite(this->swl_)) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto low = this->swl_ < Scalar{0};
|
||||
const auto high = ! (this->swl_ < Scalar{1});
|
||||
|
||||
if (low || high) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename Scalar>
|
||||
void Opm::Satfunc::PhaseChecks::Water::SWmax<Scalar>::
|
||||
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
|
||||
{
|
||||
// 0 < SWU <= 1
|
||||
|
||||
this->swu_ = endPoints.Swu;
|
||||
|
||||
if (! std::isfinite(this->swu_)) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto low = ! (this->swu_ > Scalar{0});
|
||||
const auto high = this->swu_ > Scalar{1};
|
||||
|
||||
if (low || high) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template <typename Scalar>
|
||||
void Opm::Satfunc::PhaseChecks::Water::SWcr<Scalar>::
|
||||
testImpl(const EclEpsScalingPointsInfo<Scalar>& endPoints)
|
||||
{
|
||||
// SWL <= SWCR < SWU
|
||||
|
||||
this->swl_ = endPoints.Swl;
|
||||
this->swcr_ = endPoints.Swcr;
|
||||
this->swu_ = endPoints.Swu;
|
||||
|
||||
if (! std::isfinite(this->swl_) ||
|
||||
! std::isfinite(this->swcr_) ||
|
||||
! std::isfinite(this->swu_))
|
||||
{
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto low = this->swcr_ < this->swl_;
|
||||
const auto high = ! (this->swcr_ < this->swu_);
|
||||
|
||||
if (low || high) {
|
||||
this->setViolated();
|
||||
this->setCritical();
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// Explicit Specialisations of Individual Check Templates
|
||||
//
|
||||
// No other code below this separator
|
||||
// ===========================================================================
|
||||
|
||||
template class Opm::Satfunc::PhaseChecks::Water::SWmin<float>;
|
||||
template class Opm::Satfunc::PhaseChecks::Water::SWmin<double>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template class Opm::Satfunc::PhaseChecks::Water::SWmax<float>;
|
||||
template class Opm::Satfunc::PhaseChecks::Water::SWmax<double>;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
template class Opm::Satfunc::PhaseChecks::Water::SWcr<float>;
|
||||
template class Opm::Satfunc::PhaseChecks::Water::SWcr<double>;
|
||||
205
opm/simulators/utils/satfunc/WaterPhaseConsistencyChecks.hpp
Normal file
205
opm/simulators/utils/satfunc/WaterPhaseConsistencyChecks.hpp
Normal file
@@ -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 WATER_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
|
||||
#define WATER_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::Water {
|
||||
|
||||
/// Verify that minimum gas saturation is in valid range
|
||||
///
|
||||
/// \tparam Scalar Element type. Typically \c float or \c double.
|
||||
template <typename Scalar>
|
||||
class SWmin : 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->swl_;
|
||||
}
|
||||
|
||||
/// Descriptive textual summary of this check.
|
||||
std::string description() const override
|
||||
{
|
||||
return { "Non-negative minimum water saturation" };
|
||||
}
|
||||
|
||||
/// Textual representation of the consistency condition.
|
||||
std::string condition() const override
|
||||
{
|
||||
return { "0 <= SWL < 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";
|
||||
}
|
||||
|
||||
private:
|
||||
/// Minimum (connate) water saturation.
|
||||
Scalar swl_;
|
||||
|
||||
/// 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 SWmax : 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->swu_;
|
||||
}
|
||||
|
||||
/// Descriptive textual summary of this check.
|
||||
std::string description() const override
|
||||
{
|
||||
return { "Positive maximum water saturation" };
|
||||
}
|
||||
|
||||
/// Textual representation of the consistency condition.
|
||||
std::string condition() const override
|
||||
{
|
||||
return { "0 < 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] = "SWU";
|
||||
}
|
||||
|
||||
private:
|
||||
/// Maximum water 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 gas saturation is in valid range.
|
||||
///
|
||||
/// \tparam Scalar Element type. Typically \c float or \c double.
|
||||
template <typename Scalar>
|
||||
class SWcr : 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->swcr_;
|
||||
exportedCheckValues[2] = this->swu_;
|
||||
}
|
||||
|
||||
/// Descriptive textual summary of this check.
|
||||
std::string description() const override
|
||||
{
|
||||
return { "Mobile water saturation" };
|
||||
}
|
||||
|
||||
/// Textual representation of the consistency condition.
|
||||
std::string condition() const override
|
||||
{
|
||||
return { "SWL <= SWCR < SWU" };
|
||||
}
|
||||
|
||||
/// 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] = "SWCR";
|
||||
headers[2] = "SWU";
|
||||
}
|
||||
|
||||
private:
|
||||
/// Minimum (connate) water saturation.
|
||||
Scalar swl_;
|
||||
|
||||
/// Critical water saturation.
|
||||
Scalar swcr_;
|
||||
|
||||
/// Maximum water 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;
|
||||
};
|
||||
|
||||
} // namespace Opm::Satfunc::PhaseChecks::Water
|
||||
|
||||
#endif // WATER_PHASE_CONSISTENCY_CHECKS_HPP_INCLUDED
|
||||
Reference in New Issue
Block a user