added: RST CONV support for polymer, solvent and brine

This commit is contained in:
Arne Morten Kvarving 2024-01-22 09:58:06 +01:00
parent e585e14ef6
commit 873102e9ea
5 changed files with 35 additions and 30 deletions

View File

@ -1504,8 +1504,9 @@ void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
assignGlobalFieldsToSolution(data::Solution& sol)
{
if (!this->cnvData_.empty()) {
constexpr std::array names = {"CNV_OIL", "CNV_GAS", "CNV_WAT"};
for (size_t i = 0; i < 3; ++i) {
constexpr const std::array names{"CNV_OIL", "CNV_GAS", "CNV_WAT",
"CNV_PLY", "CNV_SAL", "CNV_SOL"};
for (std::size_t i = 0; i < names.size(); ++i) {
if (!this->cnvData_[i].empty()) {
sol.insert(names[i], this->cnvData_[i], data::TargetType::RESTART_SOLUTION);
}

View File

@ -320,7 +320,10 @@ namespace Opm {
schedule[timer.reportStepNum()].rst_config(),
{getIdx(FluidSystem::oilPhaseIdx),
getIdx(FluidSystem::gasPhaseIdx),
getIdx(FluidSystem::waterPhaseIdx)});
getIdx(FluidSystem::waterPhaseIdx),
contiPolymerEqIdx,
contiBrineEqIdx,
contiSolventEqIdx});
return report;
}

View File

@ -34,7 +34,7 @@ namespace Opm {
void RSTConv::init(const std::size_t numCells,
const RSTConfig& rst_config,
const std::array<int,3>& compIdx)
const std::array<int,6>& compIdx)
{
const auto kw = rst_config.keywords.find("CONV");
if (kw == rst_config.keywords.end()) {
@ -46,9 +46,9 @@ void RSTConv::init(const std::size_t numCells,
N_ = kw->second;
compIdx_ = compIdx;
cnv_X_.resize(3);
for (std::size_t i = 0; i < 3; ++i) {
if (compIdx_[i] != -1) {
cnv_X_.resize(6);
for (std::size_t i = 0; i < 6; ++i) {
if (compIdx_[i] > -1) {
cnv_X_[i].resize(numCells);
}
}

View File

@ -45,10 +45,10 @@ public:
//! \brief Init state at beginning of step.
//! \param numCells Global number of active cells in the model
//! \param rst_config RPTRST configuration
//! \param compIdx Component index for phases {OIL, GAS, WAT}, -1 if inactive
//! \param compIdx Component index for phases {OIL, GAS, WAT, POLYMER, BRINE, SOLVENT}, negative if inactive
void init(const std::size_t numCells,
const RSTConfig& rst_config,
const std::array<int,3>& compIdx);
const std::array<int,6>& compIdx);
//! \brief Adds the CONV output for given residual vector.
template<class ResidualVector>
@ -71,7 +71,7 @@ private:
const std::vector<int>& globalCell_; //!< Global cell indices
Parallel::Communication comm_; //!< Communicator
std::vector<std::vector<int>> cnv_X_; //!< Counts of worst cells for RPTRST CONV
std::array<int,3> compIdx_; //!< Component indices
std::array<int,6> compIdx_; //!< Component indices
int N_ = 0; //!< Number of cells to consider
};

View File

@ -68,7 +68,7 @@ init_unit_test_func()
struct TestCase {
std::size_t N;
std::array<int,3> phase;
std::array<int,6> phase;
};
std::ostream& operator<<(std::ostream& os, const TestCase& t)
@ -82,12 +82,15 @@ std::ostream& operator<<(std::ostream& os, const TestCase& t)
}
static const std::vector<TestCase> tests = {
{1, {0, 1, 2}},
{3, {0, 1, 2}},
{1, {0, -1, 1}},
{5, {0, -1, 1}},
{1, {-1, -1, 0}},
{4, {-1, -1, 0}},
{1, { 0, 1, 2, -1, -1, -1}},
{3, { 0, 1, 2, -1, -1, -1}},
{1, { 0, -1, 1, -1, -1, -1}},
{5, { 0, -1, 1, -1, -1, -1}},
{1, {-1, -1, 0, -1, -1, -1}},
{4, {-1, -1, 0, -1, -1, -1}},
{1, { 0, 1, -1, 2, -1, -1}},
{1, { 0, 1, -1, -1, 2, -1}},
{1, { 0, 1, -1, -1, -1, 2}},
};
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66
@ -107,16 +110,16 @@ BOOST_AUTO_TEST_CASE(RstConvTest)
std::vector<int> cellMapping(10);
std::iota(cellMapping.begin(), cellMapping.end(), cc.rank()*10);
Dune::BlockVector<Dune::FieldVector<double,3>> residual(10);
Dune::BlockVector<Dune::FieldVector<double,6>> residual(10);
// generate data
std::vector<std::vector<int>> max(3);
std::vector<std::vector<int>> max(6);
if (cc.rank() == 0) {
std::random_device rng_device;
std::mt19937 mersenne_engine{rng_device()};
std::uniform_int_distribution<int> dist{0, 10*cc.size()-1};
for (int c = 0; c < 3; ++c) {
for (int c = 0; c < 6; ++c) {
if (sample.phase[c] == -1) {
continue;
}
@ -130,7 +133,7 @@ BOOST_AUTO_TEST_CASE(RstConvTest)
}
}
for (int c = 0; c < 3; ++c) {
for (int c = 0; c < 6; ++c) {
std::size_t size = max[c].size();
cc.broadcast(&size, 1, 0);
if (cc.rank() != 0) {
@ -140,7 +143,7 @@ BOOST_AUTO_TEST_CASE(RstConvTest)
}
for (int i = 0; i < 10; ++i) {
for (int c = 0; c < 3; ++c) {
for (int c = 0; c < 6; ++c) {
if (sample.phase[c] != -1) {
bool inMax = std::find(max[c].begin(),
max[c].end(),
@ -157,16 +160,14 @@ BOOST_AUTO_TEST_CASE(RstConvTest)
cnv.update(residual);
if (cc.rank() == 0) {
BOOST_CHECK_EQUAL(cnv.getData().size(), 3);
BOOST_CHECK_EQUAL(cnv.getData()[0].size(),
sample.phase[0] == -1 ? 0 : cc.size() * 10);
BOOST_CHECK_EQUAL(cnv.getData()[1].size(),
sample.phase[1] == -1 ? 0 : cc.size() * 10);
BOOST_CHECK_EQUAL(cnv.getData()[2].size(),
sample.phase[2] == -1 ? 0 : cc.size() * 10);
BOOST_CHECK_EQUAL(cnv.getData().size(), 6);
for (std::size_t i = 0; i < 6; ++i) {
BOOST_CHECK_EQUAL(cnv.getData()[i].size(),
sample.phase[i] == -1 ? 0 : cc.size() * 10);
}
for (int i = 0; i < cc.size() * 10; ++i) {
for (int c = 0; c < 3; ++c) {
for (int c = 0; c < 6; ++c) {
if (sample.phase[c] != -1) {
bool inMax = std::find(max[c].begin(),
max[c].end(), i) != max[c].end();