move CompositionalContainer member into OutputCompositionalModule

This commit is contained in:
Arne Morten Kvarving
2025-02-12 15:07:36 +01:00
parent 3b819349f8
commit c8209c39a7
5 changed files with 41 additions and 53 deletions

View File

@@ -23,8 +23,6 @@
#include <config.h>
#include <opm/simulators/flow/CompositionalContainer.hpp>
#include <opm/material/fluidsystems/BlackOilDefaultIndexTraits.hpp>
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
#include <opm/material/fluidsystems/GenericOilGasFluidSystem.hpp>
#include <opm/output/data/Solution.hpp>
@@ -42,8 +40,8 @@ allocate(const unsigned bufferSize,
std::map<std::string, int>& rstKeywords)
{
if (auto& zmf = rstKeywords["ZMF"]; zmf > 0) {
zmf = 0;
this->allocated_ = true;
zmf = 0;
for (int i = 0; i < numComponents; ++i) {
moleFractions_[i].resize(bufferSize, 0.0);
}
@@ -112,7 +110,8 @@ assignOilFractions(const unsigned globalDofIdx,
template<class FluidSystem>
void CompositionalContainer<FluidSystem>::
outputRestart(data::Solution& sol)
outputRestart(data::Solution& sol,
ScalarBuffer& oil_saturation)
{
using DataEntry =
std::tuple<std::string, UnitSystem::measure, std::vector<Scalar>&>;
@@ -158,6 +157,10 @@ outputRestart(data::Solution& sol)
}
}
if (!oil_saturation.empty()) {
entries.emplace_back("SOIL", UnitSystem::measure::identity, oil_saturation);
}
std::for_each(entries.begin(), entries.end(),
[&doInsert](auto& array)
{ doInsert(array, data::TargetType::RESTART_SOLUTION); });
@@ -165,17 +168,6 @@ outputRestart(data::Solution& sol)
this->allocated_ = false;
}
template<class T> using FS = BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>;
#define INSTANTIATE_TYPE(T) \
template class CompositionalContainer<FS<T>>;
INSTANTIATE_TYPE(double)
#if FLOW_INSTANTIATE_FLOAT
INSTANTIATE_TYPE(float)
#endif
#define INSTANTIATE_COMP(NUM) \
template<class T> using FS##NUM = GenericOilGasFluidSystem<T, NUM>; \
template class CompositionalContainer<FS##NUM<double>>;

View File

@@ -64,7 +64,8 @@ public:
void assignOilFractions(const unsigned globalDofIdx,
const AssignFunction& fractions);
void outputRestart(data::Solution& sol);
void outputRestart(data::Solution& sol,
ScalarBuffer& oil_saturation);
bool allocated() const
{ return allocated_; }

View File

@@ -104,8 +104,7 @@ GenericOutputBlackoilModule(const EclipseState& eclState,
bool enableBrine,
bool enableSaltPrecipitation,
bool enableExtbo,
bool enableMICP,
bool isCompositional)
bool enableMICP)
: eclState_(eclState)
, schedule_(schedule)
, summaryState_(summaryState)
@@ -124,7 +123,6 @@ GenericOutputBlackoilModule(const EclipseState& eclState,
, enableSaltPrecipitation_(enableSaltPrecipitation)
, enableExtbo_(enableExtbo)
, enableMICP_(enableMICP)
, isCompositional_(isCompositional)
, local_data_valid_(false)
{
const auto& fp = eclState_.fieldProps();
@@ -527,10 +525,6 @@ assignToSolution(data::Solution& sol)
DataEntry{"TMULT_RC", UnitSystem::measure::identity, rockCompTransMultiplier_},
};
if (this->isCompositional_) {
this->compC_.outputRestart(sol);
}
for (auto& array : baseSolutionVector) {
doInsert(array, data::TargetType::RESTART_SOLUTION);
}
@@ -574,15 +568,6 @@ assignToSolution(data::Solution& sol)
data::TargetType::RESTART_SOLUTION);
}
if (this->isCompositional_ && FluidSystem::phaseIsActive(oilPhaseIdx) &&
! this->saturation_[oilPhaseIdx].empty())
{
sol.insert("SOIL", UnitSystem::measure::identity,
std::move(this->saturation_[oilPhaseIdx]),
data::TargetType::RESTART_SOLUTION);
}
if ((eclState_.runspec().co2Storage() || eclState_.runspec().h2Storage()) && !rsw_.empty()) {
auto mfrac = std::vector<double>(this->rsw_.size(), 0.0);
@@ -806,10 +791,14 @@ doAllocBuffers(const unsigned bufferSize,
const bool enableWettingHysteresis,
const unsigned numTracers,
const std::vector<bool>& enableSolTracers,
const unsigned numOutputNnc)
const unsigned numOutputNnc,
std::map<std::string, int> rstKeywords)
{
if (rstKeywords.empty()) {
rstKeywords = schedule_.rst_keywords(reportStepNum);
}
// Output RESTART_OPM_EXTENDED only when explicitly requested by user.
std::map<std::string, int> rstKeywords = schedule_.rst_keywords(reportStepNum);
for (auto& [keyword, should_write] : rstKeywords) {
if (this->isOutputCreationDirective_(keyword)) {
// 'BASIC', 'FREQ' and similar. Don't attempt to create
@@ -1265,11 +1254,6 @@ doAllocBuffers(const unsigned bufferSize,
overburdenPressure_.resize(bufferSize, 0.0);
}
if (this->isCompositional_) {
this->compC_.allocate(bufferSize, rstKeywords);
}
//Warn for any unhandled keyword
if (log) {
for (auto& keyValue: rstKeywords) {

View File

@@ -32,7 +32,6 @@
#include <opm/output/data/Wells.hpp>
#include <opm/output/eclipse/Inplace.hpp>
#include <opm/simulators/flow/CompositionalContainer.hpp>
#include <opm/simulators/flow/ExtboContainer.hpp>
#include <opm/simulators/flow/FIPContainer.hpp>
#include <opm/simulators/flow/FlowsData.hpp>
@@ -320,8 +319,7 @@ protected:
bool enableBrine,
bool enableSaltPrecipitation,
bool enableExtbo,
bool enableMICP,
bool isCompositional = false);
bool enableMICP);
void doAllocBuffers(unsigned bufferSize,
unsigned reportStepNum,
@@ -330,11 +328,12 @@ protected:
const bool isRestart,
const bool vapparsActive = false,
const bool enablePCHysteresis = false,
const bool enableNonWettingHysteresis =false,
const bool enableNonWettingHysteresis = false,
const bool enableWettingHysteresis = false,
unsigned numTracers = 0,
const std::vector<bool>& enableSolTracers = {},
unsigned numOutputNnc = 0);
unsigned numOutputNnc = 0,
std::map<std::string, int> rstKeywords = {});
void makeRegionSum(Inplace& inplace,
const std::string& region_name,
@@ -391,7 +390,6 @@ protected:
bool enableSaltPrecipitation_{false};
bool enableExtbo_{false};
bool enableMICP_{false};
bool isCompositional_{false};
bool forceDisableFipOutput_{false};
bool forceDisableFipresvOutput_{false};
@@ -469,7 +467,6 @@ protected:
std::array<ScalarBuffer, numPhases> viscosity_;
std::array<ScalarBuffer, numPhases> relativePermeability_;
CompositionalContainer<FluidSystem> compC_;
std::vector<ScalarBuffer> freeTracerConcentrations_;
std::vector<ScalarBuffer> solTracerConcentrations_;

View File

@@ -45,6 +45,7 @@
#include <opm/models/utils/parametersystem.hpp>
#include <opm/models/utils/propertysystem.hh>
#include <opm/simulators/flow/CompositionalContainer.hpp>
#include <opm/simulators/flow/FlowBaseVanguard.hpp>
#include <opm/simulators/flow/GenericOutputBlackoilModule.hpp>
@@ -105,8 +106,7 @@ public:
getPropValue<TypeTag, Properties::EnableBrine>(),
getPropValue<TypeTag, Properties::EnableSaltPrecipitation>(),
getPropValue<TypeTag, Properties::EnableExtbo>(),
getPropValue<TypeTag, Properties::EnableMICP>(),
true)
getPropValue<TypeTag, Properties::EnableMICP>())
, simulator_(simulator)
{
for (auto& region_pair : this->regions_) {
@@ -158,11 +158,24 @@ public:
return;
}
this->doAllocBuffers(bufferSize,
reportStepNum,
substep,
log,
isRestart);
auto rstKeywords = this->schedule_.rst_keywords(reportStepNum);
this->compC_.allocate(bufferSize, rstKeywords);
this->doAllocBuffers(bufferSize, reportStepNum, substep, log, isRestart,
/* vapparsActive =*/ false,
/* enablePCHysteresis = */ false,
/* enableNonWettingHysteresis =*/ false,
/* enableWettingHysteresis =*/ false,
/* numTracers = */ 0,
/* enableSoltracers =*/ {},
/* numOutputNnc =*/ 0,
std::move(rstKeywords));
}
void assignToSolution(data::Solution& sol)
{
this->compC_.outputRestart(sol, this->saturation_[oilPhaseIdx]);
BaseType::assignToSolution(sol);
}
/*!
@@ -336,6 +349,7 @@ private:
}
const Simulator& simulator_;
CompositionalContainer<FluidSystem> compC_;
};
} // namespace Opm