mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move allocation of tracer data into TracerContainer
This commit is contained in:
@@ -123,6 +123,7 @@ GenericOutputBlackoilModule(const EclipseState& eclState,
|
||||
, enableSaltPrecipitation_(enableSaltPrecipitation)
|
||||
, enableExtbo_(enableExtbo)
|
||||
, enableMICP_(enableMICP)
|
||||
, tracerC_(eclState_)
|
||||
, local_data_valid_(false)
|
||||
{
|
||||
const auto& fp = eclState_.fieldProps();
|
||||
@@ -789,8 +790,6 @@ doAllocBuffers(const unsigned bufferSize,
|
||||
const bool enablePCHysteresis,
|
||||
const bool enableNonWettingHysteresis,
|
||||
const bool enableWettingHysteresis,
|
||||
const unsigned numTracers,
|
||||
const std::vector<bool>& enableSolTracers,
|
||||
const unsigned numOutputNnc,
|
||||
std::map<std::string, int> rstKeywords)
|
||||
{
|
||||
@@ -1220,19 +1219,7 @@ doAllocBuffers(const unsigned bufferSize,
|
||||
}
|
||||
|
||||
// tracers
|
||||
if (numTracers > 0) {
|
||||
tracerC_.freeConcentrations_.resize(numTracers);
|
||||
for (unsigned tracerIdx = 0; tracerIdx < numTracers; ++tracerIdx)
|
||||
{
|
||||
tracerC_.freeConcentrations_[tracerIdx].resize(bufferSize, 0.0);
|
||||
}
|
||||
tracerC_.solConcentrations_.resize(numTracers);
|
||||
for (unsigned tracerIdx = 0; tracerIdx < numTracers; ++tracerIdx)
|
||||
{
|
||||
if (enableSolTracers[tracerIdx])
|
||||
tracerC_.solConcentrations_[tracerIdx].resize(bufferSize, 0.0);
|
||||
}
|
||||
}
|
||||
this->tracerC_.allocate(bufferSize);
|
||||
|
||||
if (rstKeywords["RESIDUAL"] > 0) {
|
||||
rstKeywords["RESIDUAL"] = 0;
|
||||
|
||||
@@ -331,8 +331,6 @@ protected:
|
||||
const bool enablePCHysteresis = false,
|
||||
const bool enableNonWettingHysteresis = false,
|
||||
const bool enableWettingHysteresis = false,
|
||||
const unsigned numTracers = 0,
|
||||
const std::vector<bool>& enableSolTracers = {},
|
||||
unsigned numOutputNnc = 0,
|
||||
std::map<std::string, int> rstKeywords = {});
|
||||
|
||||
|
||||
@@ -188,8 +188,6 @@ public:
|
||||
problem.materialLawManager()->enablePCHysteresis(),
|
||||
problem.materialLawManager()->enableNonWettingHysteresis(),
|
||||
problem.materialLawManager()->enableWettingHysteresis(),
|
||||
problem.tracerModel().numTracers(),
|
||||
problem.tracerModel().enableSolTracers(),
|
||||
problem.eclWriter()->getOutputNnc().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +166,6 @@ public:
|
||||
/* enablePCHysteresis = */ false,
|
||||
/* enableNonWettingHysteresis =*/ false,
|
||||
/* enableWettingHysteresis =*/ false,
|
||||
/* numTracers = */ 0,
|
||||
/* enableSoltracers =*/ {},
|
||||
/* numOutputNnc =*/ 0,
|
||||
std::move(rstKeywords));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,70 @@
|
||||
#include <config.h>
|
||||
#include <opm/simulators/flow/TracerContainer.hpp>
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
|
||||
#include <opm/material/fluidsystems/BlackOilDefaultIndexTraits.hpp>
|
||||
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
||||
#include <opm/material/fluidsystems/GenericOilGasWaterFluidSystem.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class FluidSystem>
|
||||
void TracerContainer<FluidSystem>::
|
||||
allocate(const unsigned bufferSize)
|
||||
{
|
||||
const auto& tracers = eclState_.tracer();
|
||||
if (!tracers.empty()) {
|
||||
allocated_ = true;
|
||||
freeConcentrations_.resize(tracers.size());
|
||||
solConcentrations_.resize(tracers.size());
|
||||
std::for_each(tracers.begin(), tracers.end(),
|
||||
[idx = 0, bufferSize, this](const auto& tracer) mutable
|
||||
{
|
||||
freeConcentrations_[idx].resize(bufferSize, 0.0);
|
||||
if (((tracer.phase == Phase::GAS && FluidSystem::enableDissolvedGas()) ||
|
||||
(tracer.phase == Phase::OIL && FluidSystem::enableVaporizedOil())) &&
|
||||
(tracer.solution_concentration.has_value() ||
|
||||
tracer.solution_tvdp.has_value()))
|
||||
{
|
||||
solConcentrations_[idx].resize(bufferSize, 0.0);
|
||||
}
|
||||
++idx;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> using FS = BlackOilFluidSystem<T,BlackOilDefaultIndexTraits>;
|
||||
|
||||
#define INSTANTIATE_TYPE(T) \
|
||||
template class TracerContainer<FS<T>>;
|
||||
|
||||
INSTANTIATE_TYPE(double)
|
||||
|
||||
#if FLOW_INSTANTIATE_FLOAT
|
||||
INSTANTIATE_TYPE(float)
|
||||
#endif
|
||||
|
||||
#define INSTANTIATE_COMP_THREEPHASE(NUM) \
|
||||
template<class T> using FS##NUM = GenericOilGasWaterFluidSystem<T, NUM, true>; \
|
||||
template class TracerContainer<FS##NUM<double>>;
|
||||
|
||||
#define INSTANTIATE_COMP_TWOPHASE(NUM) \
|
||||
template<class T> using GFS##NUM = GenericOilGasWaterFluidSystem<T, NUM, false>; \
|
||||
template class TracerContainer<GFS##NUM<double>>;
|
||||
|
||||
#define INSTANTIATE_COMP(NUM) \
|
||||
INSTANTIATE_COMP_THREEPHASE(NUM) \
|
||||
INSTANTIATE_COMP_TWOPHASE(NUM)
|
||||
|
||||
INSTANTIATE_COMP_THREEPHASE(0) // \Note: to register the parameter ForceDisableFluidInPlaceOutput
|
||||
INSTANTIATE_COMP(2)
|
||||
INSTANTIATE_COMP(3)
|
||||
INSTANTIATE_COMP(4)
|
||||
INSTANTIATE_COMP(5)
|
||||
INSTANTIATE_COMP(6)
|
||||
INSTANTIATE_COMP(7)
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class EclipseState;
|
||||
|
||||
template<class FluidSystem>
|
||||
class TracerContainer
|
||||
{
|
||||
@@ -37,8 +39,17 @@ class TracerContainer
|
||||
using ScalarBuffer = std::vector<Scalar>;
|
||||
|
||||
public:
|
||||
std::vector<ScalarBuffer> freeConcentrations_;
|
||||
std::vector<ScalarBuffer> solConcentrations_;
|
||||
TracerContainer(const EclipseState& eclState)
|
||||
: eclState_(eclState)
|
||||
{}
|
||||
|
||||
void allocate(const unsigned bufferSize);
|
||||
|
||||
const EclipseState& eclState_;
|
||||
|
||||
std::vector<ScalarBuffer> freeConcentrations_{};
|
||||
std::vector<ScalarBuffer> solConcentrations_{};
|
||||
bool allocated_{false};
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
Reference in New Issue
Block a user