Merge pull request #4766 from akva2/eclsolution_containers

Add containers for polymer and MICP solution components
This commit is contained in:
Markus Blatt 2023-08-02 09:33:54 +02:00 committed by GitHub
commit 81c6eac6a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 243 additions and 88 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,18 +113,12 @@ serializationTestObject(const EclipseState& eclState,
{
EclGenericProblem result(eclState, schedule, gridView);
result.maxOilSaturation_ = {1.0, 2.0};
result.maxPolymerAdsorption_ = {3.0, 4.0, 5.0};
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};
result.ureaConcentration_ = {18.0};
result.biofilmConcentration_ = {19.0};
result.calciteConcentration_ = {20.0};
result.polymer_ = PolymerSolutionContainer<Scalar>::serializationTestObject();
result.micp_ = MICPSolutionContainer<Scalar>::serializationTestObject();
result.lastRv_ = {21.0};
result.maxDRv_ = {22.0, 23.0};
result.convectiveDrs_ = {24.0, 25.0, 26.0};
@ -575,39 +569,39 @@ 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) {
if (eclState_.fieldProps().has_double("SMICR"))
microbialConcentration_ = eclState_.fieldProps().get_double("SMICR");
micp_.microbialConcentration = eclState_.fieldProps().get_double("SMICR");
else
microbialConcentration_.resize(numDof, 0.0);
micp_.microbialConcentration.resize(numDof, 0.0);
if (eclState_.fieldProps().has_double("SOXYG"))
oxygenConcentration_ = eclState_.fieldProps().get_double("SOXYG");
micp_.oxygenConcentration = eclState_.fieldProps().get_double("SOXYG");
else
oxygenConcentration_.resize(numDof, 0.0);
micp_.oxygenConcentration.resize(numDof, 0.0);
if (eclState_.fieldProps().has_double("SUREA"))
ureaConcentration_ = eclState_.fieldProps().get_double("SUREA");
micp_.ureaConcentration = eclState_.fieldProps().get_double("SUREA");
else
ureaConcentration_.resize(numDof, 0.0);
micp_.ureaConcentration.resize(numDof, 0.0);
if (eclState_.fieldProps().has_double("SBIOF"))
biofilmConcentration_ = eclState_.fieldProps().get_double("SBIOF");
micp_.biofilmConcentration = eclState_.fieldProps().get_double("SBIOF");
else
biofilmConcentration_.resize(numDof, 0.0);
micp_.biofilmConcentration.resize(numDof, 0.0);
if (eclState_.fieldProps().has_double("SCALC"))
calciteConcentration_ = eclState_.fieldProps().get_double("SCALC");
micp_.calciteConcentration = eclState_.fieldProps().get_double("SCALC");
else
calciteConcentration_.resize(numDof, 0.0);
micp_.calciteConcentration.resize(numDof, 0.0);
}
}
@ -671,70 +665,77 @@ 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>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
microbialConcentration(unsigned elemIdx) const
{
if (microbialConcentration_.empty())
if (micp_.microbialConcentration.empty()) {
return 0;
}
return microbialConcentration_[elemIdx];
return micp_.microbialConcentration[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
oxygenConcentration(unsigned elemIdx) const
{
if (oxygenConcentration_.empty())
if (micp_.oxygenConcentration.empty()) {
return 0;
}
return oxygenConcentration_[elemIdx];
return micp_.oxygenConcentration[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
ureaConcentration(unsigned elemIdx) const
{
if (ureaConcentration_.empty())
if (micp_.ureaConcentration.empty()) {
return 0;
}
return ureaConcentration_[elemIdx];
return micp_.ureaConcentration[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
biofilmConcentration(unsigned elemIdx) const
{
if (biofilmConcentration_.empty())
if (micp_.biofilmConcentration.empty()) {
return 0;
}
return biofilmConcentration_[elemIdx];
return micp_.biofilmConcentration[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
Scalar EclGenericProblem<GridView,FluidSystem,Scalar>::
calciteConcentration(unsigned elemIdx) const
{
if (calciteConcentration_.empty())
if (micp_.calciteConcentration.empty()) {
return 0;
}
return calciteConcentration_[elemIdx];
return micp_.calciteConcentration[elemIdx];
}
template<class GridView, class FluidSystem, class Scalar>
@ -781,10 +782,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,18 +819,12 @@ 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_ &&
this->ureaConcentration_ == rhs.ureaConcentration_ &&
this->biofilmConcentration_ == rhs.biofilmConcentration_ &&
this->calciteConcentration_ == rhs.calciteConcentration_ &&
this->micp_ == rhs.micp_ &&
this->lastRv_ == rhs.lastRv_ &&
this->maxDRv_ == rhs.maxDRv_ &&
this->convectiveDrs_ == rhs.convectiveDrs_ &&

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,18 +284,12 @@ 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_);
serializer(ureaConcentration_);
serializer(biofilmConcentration_);
serializer(calciteConcentration_);
serializer(micp_);
serializer(lastRv_);
serializer(maxDRv_);
serializer(convectiveDrs_);
@ -377,19 +373,13 @@ 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_;
std::vector<Scalar> ureaConcentration_;
std::vector<Scalar> biofilmConcentration_;
std::vector<Scalar> calciteConcentration_;
MICPSolutionContainer<Scalar> micp_;
std::vector<Scalar> lastRv_;
std::vector<Scalar> maxDRv_;

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) {
@ -1765,11 +1765,11 @@ public:
}
if constexpr (enableMICP){
values[Indices::microbialConcentrationIdx]= this->microbialConcentration_[globalDofIdx];
values[Indices::oxygenConcentrationIdx]= this->oxygenConcentration_[globalDofIdx];
values[Indices::ureaConcentrationIdx]= this->ureaConcentration_[globalDofIdx];
values[Indices::calciteConcentrationIdx]= this->calciteConcentration_[globalDofIdx];
values[Indices::biofilmConcentrationIdx]= this->biofilmConcentration_[globalDofIdx];
values[Indices::microbialConcentrationIdx] = this->micp_.microbialConcentration[globalDofIdx];
values[Indices::oxygenConcentrationIdx]= this->micp_.oxygenConcentration[globalDofIdx];
values[Indices::ureaConcentrationIdx]= this->micp_.ureaConcentration[globalDofIdx];
values[Indices::calciteConcentrationIdx]= this->micp_.calciteConcentration[globalDofIdx];
values[Indices::biofilmConcentrationIdx]= this->micp_.biofilmConcentration[globalDofIdx];
}
values.checkDefined();
@ -2540,22 +2540,18 @@ 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) {
this->microbialConcentration_.resize(numElems, 0.0);
this->oxygenConcentration_.resize(numElems, 0.0);
this->ureaConcentration_.resize(numElems, 0.0);
this->biofilmConcentration_.resize(numElems, 0.0);
this->calciteConcentration_.resize(numElems, 0.0);
this->micp_.resize(numElems);
}
for (size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) {
@ -2590,13 +2586,13 @@ 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);
this->ureaConcentration_[elemIdx] = eclWriter_->eclOutputModule().getUreaConcentration(elemIdx);
this->biofilmConcentration_[elemIdx] = eclWriter_->eclOutputModule().getBiofilmConcentration(elemIdx);
this->calciteConcentration_[elemIdx] = eclWriter_->eclOutputModule().getCalciteConcentration(elemIdx);
this->micp_.microbialConcentration[elemIdx] = eclWriter_->eclOutputModule().getMicrobialConcentration(elemIdx);
this->micp_.oxygenConcentration[elemIdx] = eclWriter_->eclOutputModule().getOxygenConcentration(elemIdx);
this->micp_.ureaConcentration[elemIdx] = eclWriter_->eclOutputModule().getUreaConcentration(elemIdx);
this->micp_.biofilmConcentration[elemIdx] = eclWriter_->eclOutputModule().getBiofilmConcentration(elemIdx);
this->micp_.calciteConcentration[elemIdx] = eclWriter_->eclOutputModule().getCalciteConcentration(elemIdx);
}
// if we need to restart for polymer molecular weight simulation, we need to add related here
}
@ -2900,7 +2896,7 @@ protected:
bool updateMaxPolymerAdsorption_(unsigned compressedDofIdx, const IntensiveQuantities& iq)
{
const Scalar pa = scalarValue(iq.polymerAdsorption());
auto& mpa = this->maxPolymerAdsorption_;
auto& mpa = this->polymer_.maxAdsorption;
if (mpa[compressedDofIdx] < pa) {
mpa[compressedDofIdx] = pa;
return true;
@ -2908,6 +2904,7 @@ protected:
return false;
}
}
private:
struct PffDofData_
{

View File

@ -0,0 +1,86 @@
// -*- 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<class Scalar>
MICPSolutionContainer<Scalar>
MICPSolutionContainer<Scalar>::serializationTestObject()
{
return {{16.0},
{17.0},
{18.0},
{19.0},
{20.0}};
}
template<class Scalar>
void MICPSolutionContainer<Scalar>::resize(const unsigned numElems)
{
microbialConcentration.resize(numElems, 0.0);
oxygenConcentration.resize(numElems, 0.0);
ureaConcentration.resize(numElems, 0.0);
biofilmConcentration.resize(numElems, 0.0);
calciteConcentration.resize(numElems, 0.0);
}
template<class Scalar>
bool MICPSolutionContainer<Scalar>::
operator==(const MICPSolutionContainer<Scalar>& rhs) const
{
return this->microbialConcentration == rhs.microbialConcentration &&
this->oxygenConcentration == rhs.oxygenConcentration &&
this->ureaConcentration == rhs.ureaConcentration &&
this->biofilmConcentration == rhs.biofilmConcentration &&
this->calciteConcentration == rhs.calciteConcentration;
}
template struct PolymerSolutionContainer<double>;
template struct MICPSolutionContainer<double>;
} // namespace Opm

View File

@ -0,0 +1,84 @@
// -*- 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;
};
//! \brief Struct holding MICP extension data.
template<class Scalar>
struct MICPSolutionContainer {
std::vector<Scalar> microbialConcentration;
std::vector<Scalar> oxygenConcentration;
std::vector<Scalar> ureaConcentration;
std::vector<Scalar> biofilmConcentration;
std::vector<Scalar> calciteConcentration;
static MICPSolutionContainer serializationTestObject();
//! \brief Resize vectors and zero initialize.
void resize(const unsigned numElems);
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(microbialConcentration);
serializer(oxygenConcentration);
serializer(ureaConcentration);
serializer(biofilmConcentration);
serializer(calciteConcentration);
}
bool operator==(const MICPSolutionContainer& rhs) const;
};
} // namespace Opm
#endif