changed: add a container for polymer solution components

makes it easy to pass data around to enable some refactoring
This commit is contained in:
Arne Morten Kvarving 2023-08-01 10:55:59 +02:00
parent 2728d30185
commit 841d11efed
6 changed files with 141 additions and 31 deletions

View File

@ -33,6 +33,7 @@ list (APPEND MAIN_SOURCE_FILES
ebos/eclgenericvanguard.cc
ebos/eclgenericwriter.cc
ebos/eclinterregflows.cc
ebos/eclsolutioncontainers.cc
ebos/ecltransmissibility.cc
ebos/equil/equilibrationhelpers.cc
ebos/equil/initstateequil.cc
@ -386,6 +387,7 @@ list (APPEND PUBLIC_HEADER_FILES
ebos/ecloutputblackoilmodule.hh
ebos/eclpolyhedralgridvanguard.hh
ebos/eclproblem.hh
ebos/eclsolutioncontainers.hh
ebos/eclthresholdpressure.hh
ebos/ecltracermodel.hh
ebos/ecltransmissibility.hh

View File

@ -113,12 +113,10 @@ serializationTestObject(const EclipseState& eclState,
{
EclGenericProblem result(eclState, schedule, gridView);
result.maxOilSaturation_ = {1.0, 2.0};
result.maxPolymerAdsorption_ = {3.0, 4.0, 5.0};
result.polymer_ = PolymerSolutionContainer<Scalar>::serializationTestObject();
result.maxWaterSaturation_ = {6.0};
result.minOilPressure_ = {7.0, 8.0, 9.0, 10.0};
result.overburdenPressure_ = {11.0};
result.polymerConcentration_ = {12.0};
result.polymerMoleWeight_ = {13.0, 14.0};
result.solventSaturation_ = {15.0};
result.microbialConcentration_ = {16.0};
result.oxygenConcentration_ = {17.0};
@ -575,16 +573,16 @@ readBlackoilExtentionsInitialConditions_(size_t numDof,
if (enablePolymer) {
if (eclState_.fieldProps().has_double("SPOLY"))
polymerConcentration_ = eclState_.fieldProps().get_double("SPOLY");
polymer_.concentration = eclState_.fieldProps().get_double("SPOLY");
else
polymerConcentration_.resize(numDof, 0.0);
polymer_.concentration.resize(numDof, 0.0);
}
if (enablePolymerMolarWeight) {
if (eclState_.fieldProps().has_double("SPOLYMW"))
polymerMoleWeight_ = eclState_.fieldProps().get_double("SPOLYMW");
polymer_.moleWeight = eclState_.fieldProps().get_double("SPOLYMW");
else
polymerMoleWeight_.resize(numDof, 0.0);
polymer_.moleWeight.resize(numDof, 0.0);
}
if (enableMICP) {
@ -671,20 +669,22 @@ template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
polymerConcentration(unsigned elemIdx) const
{
if (polymerConcentration_.empty())
if (polymer_.concentration.empty()) {
return 0;
}
return polymerConcentration_[elemIdx];
return polymer_.concentration[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
polymerMolecularWeight(const unsigned elemIdx) const
{
if (polymerMoleWeight_.empty())
if (polymer_.moleWeight.empty()) {
return 0.0;
}
return polymerMoleWeight_[elemIdx];
return polymer_.moleWeight[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
@ -781,10 +781,11 @@ template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
maxPolymerAdsorption(unsigned elemIdx) const
{
if (maxPolymerAdsorption_.empty())
if (polymer_.maxAdsorption.empty()) {
return 0;
}
return maxPolymerAdsorption_[elemIdx];
return polymer_.maxAdsorption[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
@ -817,12 +818,10 @@ bool EclGenericProblem<GridView,FluidSystem,Scalar>::
operator==(const EclGenericProblem& rhs) const
{
return this->maxOilSaturation_ == rhs.maxOilSaturation_ &&
this->maxPolymerAdsorption_ == rhs.maxPolymerAdsorption_ &&
this->maxWaterSaturation_ == rhs.maxWaterSaturation_ &&
this->minOilPressure_ == rhs.minOilPressure_ &&
this->overburdenPressure_ == rhs.overburdenPressure_ &&
this->polymerConcentration_ == rhs.polymerConcentration_ &&
this->polymerMoleWeight_ == rhs.polymerMoleWeight_ &&
this->polymer_ == rhs.polymer_ &&
this->solventSaturation_ == rhs.solventSaturation_ &&
this->microbialConcentration_ == rhs.microbialConcentration_ &&
this->oxygenConcentration_ == rhs.oxygenConcentration_ &&

View File

@ -28,6 +28,8 @@
#ifndef EWOMS_GENERIC_ECL_PROBLEM_HH
#define EWOMS_GENERIC_ECL_PROBLEM_HH
#include <ebos/eclsolutioncontainers.hh>
#include <opm/material/common/UniformXTabulated2DFunction.hpp>
#include <opm/material/common/Tabulated1DFunction.hpp>
@ -282,12 +284,10 @@ public:
void serializeOp(Serializer& serializer)
{
serializer(maxOilSaturation_);
serializer(maxPolymerAdsorption_);
serializer(polymer_);
serializer(maxWaterSaturation_);
serializer(minOilPressure_);
serializer(overburdenPressure_);
serializer(polymerConcentration_);
serializer(polymerMoleWeight_);
serializer(solventSaturation_);
serializer(microbialConcentration_);
serializer(oxygenConcentration_);
@ -377,13 +377,11 @@ protected:
std::vector<TabulatedFunction> rockCompPoroMult_;
std::vector<TabulatedFunction> rockCompTransMult_;
PolymerSolutionContainer<Scalar> polymer_;
std::vector<Scalar> maxOilSaturation_;
std::vector<Scalar> maxPolymerAdsorption_;
std::vector<Scalar> maxWaterSaturation_;
std::vector<Scalar> minOilPressure_;
std::vector<Scalar> overburdenPressure_;
std::vector<Scalar> polymerConcentration_;
std::vector<Scalar> polymerMoleWeight_; // polymer molecular weight
std::vector<Scalar> solventSaturation_;
std::vector<Scalar> microbialConcentration_;
std::vector<Scalar> oxygenConcentration_;

View File

@ -914,7 +914,7 @@ public:
const auto& vanguard = this->simulator().vanguard();
const auto& gridView = vanguard.gridView();
int numElements = gridView.size(/*codim=*/0);
this->maxPolymerAdsorption_.resize(numElements, 0.0);
this->polymer_.maxAdsorption.resize(numElements, 0.0);
}
readBoundaryConditions_();
@ -1750,10 +1750,10 @@ public:
values[Indices::solventSaturationIdx] = this->solventSaturation_[globalDofIdx];
if constexpr (enablePolymer)
values[Indices::polymerConcentrationIdx] = this->polymerConcentration_[globalDofIdx];
values[Indices::polymerConcentrationIdx] = this->polymer_.concentration[globalDofIdx];
if constexpr (enablePolymerMolarWeight)
values[Indices::polymerMoleWeightIdx]= this->polymerMoleWeight_[globalDofIdx];
values[Indices::polymerMoleWeightIdx]= this->polymer_.moleWeight[globalDofIdx];
if constexpr (enableBrine) {
if (enableSaltPrecipitation && values.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) {
@ -2540,14 +2540,14 @@ protected:
this->solventSaturation_.resize(numElems, 0.0);
if constexpr (enablePolymer)
this->polymerConcentration_.resize(numElems, 0.0);
this->polymer_.concentration.resize(numElems, 0.0);
if constexpr (enablePolymerMolarWeight) {
const std::string msg {"Support of the RESTART for polymer molecular weight "
"is not implemented yet. The polymer weight value will be "
"zero when RESTART begins"};
OpmLog::warning("NO_POLYMW_RESTART", msg);
this->polymerMoleWeight_.resize(numElems, 0.0);
this->polymer_.moleWeight.resize(numElems, 0.0);
}
if constexpr (enableMICP){
@ -2590,7 +2590,7 @@ protected:
}
if constexpr (enablePolymer)
this->polymerConcentration_[elemIdx] = eclWriter_->eclOutputModule().getPolymerConcentration(elemIdx);
this->polymer_.concentration[elemIdx] = eclWriter_->eclOutputModule().getPolymerConcentration(elemIdx);
if constexpr (enableMICP){
this->microbialConcentration_[elemIdx] = eclWriter_->eclOutputModule().getMicrobialConcentration(elemIdx);
this->oxygenConcentration_[elemIdx] = eclWriter_->eclOutputModule().getOxygenConcentration(elemIdx);
@ -2900,14 +2900,15 @@ protected:
bool updateMaxPolymerAdsorption_(unsigned compressedDofIdx, const IntensiveQuantities& iq)
{
const Scalar pa = scalarValue(iq.polymerAdsorption());
auto& mpa = this->maxPolymerAdsorption_;
if(mpa[compressedDofIdx]<pa){
auto& mpa = this->polymer_.maxAdsorption;
if (mpa[compressedDofIdx] < pa) {
mpa[compressedDofIdx] = pa;
return true;
}else{
} else {
return false;
}
}
private:
struct PffDofData_
{

View File

@ -0,0 +1,53 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
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 2 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/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/*!
* \file
*
* \copydoc Opm::EclProblem
*/
#include <config.h>
#include <ebos/eclsolutioncontainers.hh>
namespace Opm {
template<class Scalar>
PolymerSolutionContainer<Scalar>
PolymerSolutionContainer<Scalar>::serializationTestObject()
{
return {{3.0, 4.0, 5.0},
{12.0},
{13.0, 14.0}};
}
template<class Scalar>
bool PolymerSolutionContainer<Scalar>::
operator==(const PolymerSolutionContainer<Scalar>& rhs) const
{
return this->maxAdsorption == rhs.maxAdsorption &&
this->concentration == rhs.concentration &&
this->moleWeight == rhs.moleWeight;
}
template struct PolymerSolutionContainer<double>;
} // namespace Opm

View File

@ -0,0 +1,57 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
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 2 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/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/*!
* \file
*
* \copydoc Opm::EclProblem
*/
#ifndef ECL_SOLUTION_CONTAINERS_HH
#define ECL_SOLUTION_CONTAINERS_HH
#include <vector>
namespace Opm {
//! \brief Struct holding polymer extension data.
template<class Scalar>
struct PolymerSolutionContainer {
std::vector<Scalar> maxAdsorption;
std::vector<Scalar> concentration;
std::vector<Scalar> moleWeight; // polymer molecular weight
static PolymerSolutionContainer serializationTestObject();
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(maxAdsorption);
serializer(concentration);
serializer(moleWeight);
}
bool operator==(const PolymerSolutionContainer& rhs) const;
};
} // namespace Opm
#endif