Linearised Table: Add Constructor with User-Defined Fill Value

Reimplement original constructor in terms of the new constructor.
The main purpose of the new constructor is to support PVT tables
which use a fill/padding value different from 1.0e+20.
This commit is contained in:
Bård Skaflestad 2019-03-28 11:25:14 +01:00
parent 78170ccfce
commit bd73bb6c55
3 changed files with 103 additions and 1 deletions

View File

@ -1,4 +1,5 @@
/* /*
Copyright 2019 Equinor.
Copyright 2017 Statoil ASA. Copyright 2017 Statoil ASA.
This file is part of the Open Porous Media project (OPM). This file is part of the Open Porous Media project (OPM).
@ -35,6 +36,8 @@ namespace Opm {
public: public:
/// Constructor. /// Constructor.
/// ///
/// Padded table entries set to +1.0e+20.
///
/// \param[in] numTables Number of tables managed by internal /// \param[in] numTables Number of tables managed by internal
/// buffer. Typically corresponds to maximum value of a region /// buffer. Typically corresponds to maximum value of a region
/// ID vector such as SATNUM, IMBNUM, or PVTNUM. /// ID vector such as SATNUM, IMBNUM, or PVTNUM.
@ -57,6 +60,33 @@ namespace Opm {
const std::size_t numRows, const std::size_t numRows,
const std::size_t numCols); const std::size_t numCols);
/// Constructor.
///
/// \param[in] numTables Number of tables managed by internal
/// buffer. Typically corresponds to maximum value of a region
/// ID vector such as SATNUM, IMBNUM, or PVTNUM.
///
/// \param[in] numPrimary Number of primary look-up keys for the
/// tabular data managed by the internal buffer. Mostly relevant
/// (i.e., greater than one) for miscible oil ("PVTO") or
/// miscible gas ("PVTG") tables and typically corresponds to the
/// number of Rs/Rv entries from the TABDIMS keyword.
///
/// \param[in] numRows Number of rows in each sub-table
/// corresponding to a single primary look-up key. Typically the
/// number of nodes (e.g., NSSFUN or NPPVT) of the corresponding
/// input keyword.
///
/// \param[in] numCols Number of columns in each sub-table (and main
/// table). Typically 5.
///
/// \param[in] fillValue Data element value for padded table entries.
LinearisedOutputTable(const std::size_t numTables,
const std::size_t numPrimary,
const std::size_t numRows,
const std::size_t numCols,
const double fillValue);
/// Retrieve iterator to start of \c numRows (contiguous) column /// Retrieve iterator to start of \c numRows (contiguous) column
/// elements of a particular sub-table of a particular main table. /// elements of a particular sub-table of a particular main table.
/// ///

View File

@ -1,3 +1,23 @@
/*
Copyright 2019 Equinor.
Copyright 2017 Statoil ASA.
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 <opm/output/eclipse/LinearisedOutputTable.hpp> #include <opm/output/eclipse/LinearisedOutputTable.hpp>
#include <algorithm> #include <algorithm>
@ -10,7 +30,17 @@ LinearisedOutputTable(const std::size_t numTables0,
const std::size_t numPrimary0, const std::size_t numPrimary0,
const std::size_t numRows0, const std::size_t numRows0,
const std::size_t numCols0) const std::size_t numCols0)
: data (numTables0 * numPrimary0 * numRows0 * numCols0, 1.0e20) : LinearisedOutputTable(numTables0, numPrimary0,
numRows0, numCols0, 1.0e20)
{}
Opm::LinearisedOutputTable::
LinearisedOutputTable(const std::size_t numTables0,
const std::size_t numPrimary0,
const std::size_t numRows0,
const std::size_t numCols0,
const double fillValue)
: data (numTables0 * numPrimary0 * numRows0 * numCols0, fillValue)
, numTables (numTables0) , numTables (numTables0)
, numPrimary(numPrimary0) , numPrimary(numPrimary0)
, numRows (numRows0) , numRows (numRows0)

View File

@ -125,6 +125,48 @@ namespace {
} }
} // Anonymous } // Anonymous
// ---------------------------------------------------------------------
// Constructors
BOOST_AUTO_TEST_SUITE (Basic_Operations)
BOOST_AUTO_TEST_CASE (Construct_Defaulted_FillVal)
{
const auto numTables = std::size_t{2};
const auto numPrimary = std::size_t{3};
const auto numRows = std::size_t{4};
const auto numCols = std::size_t{5};
auto linTable = ::Opm::LinearisedOutputTable {
numTables, numPrimary, numRows, numCols
};
const auto expect_initial = std::vector<double>(
numTables * numPrimary * numRows * numCols, 1.0e20);
check_is_close(linTable.getData(), expect_initial);
}
BOOST_AUTO_TEST_CASE (Construct_UserDefined_FillVal)
{
const auto numTables = std::size_t{2};
const auto numPrimary = std::size_t{3};
const auto numRows = std::size_t{4};
const auto numCols = std::size_t{5};
const auto fillVal = 1.234e-5;
auto linTable = ::Opm::LinearisedOutputTable {
numTables, numPrimary, numRows, numCols, fillVal
};
const auto expect_initial = std::vector<double>(
numTables * numPrimary * numRows * numCols, fillVal);
check_is_close(linTable.getData(), expect_initial);
}
BOOST_AUTO_TEST_SUITE_END ()
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Saturation Functions // Saturation Functions