mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move allocation of compositional data into CompositionalContainer
This commit is contained in:
@@ -23,7 +23,63 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <opm/simulators/flow/CompositionalContainer.hpp>
|
#include <opm/simulators/flow/CompositionalContainer.hpp>
|
||||||
|
|
||||||
|
#include <opm/material/fluidsystems/BlackOilDefaultIndexTraits.hpp>
|
||||||
|
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
||||||
|
#include <opm/material/fluidsystems/GenericOilGasFluidSystem.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
|
template<class FluidSystem>
|
||||||
|
void CompositionalContainer<FluidSystem>::
|
||||||
|
allocate(const unsigned bufferSize,
|
||||||
|
std::map<std::string, int>& rstKeywords)
|
||||||
|
{
|
||||||
|
if (auto& zmf = rstKeywords["ZMF"]; zmf > 0) {
|
||||||
|
zmf = 0;
|
||||||
|
this->allocated_ = true;
|
||||||
|
for (int i = 0; i < numComponents; ++i) {
|
||||||
|
moleFractions_[i].resize(bufferSize, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto& xmf = rstKeywords["XMF"]; xmf > 0 && FluidSystem::phaseIsActive(oilPhaseIdx)) {
|
||||||
|
this->allocated_ = true;
|
||||||
|
xmf = 0;
|
||||||
|
for (int i = 0; i < numComponents; ++i) {
|
||||||
|
phaseMoleFractions_[oilPhaseIdx][i].resize(bufferSize, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto& ymf = rstKeywords["YMF"]; ymf > 0 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
|
||||||
|
this->allocated_ = true;
|
||||||
|
ymf = 0;
|
||||||
|
for (int i = 0; i < numComponents; ++i) {
|
||||||
|
phaseMoleFractions_[gasPhaseIdx][i].resize(bufferSize, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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>>;
|
||||||
|
|
||||||
|
INSTANTIATE_COMP(0)
|
||||||
|
INSTANTIATE_COMP(2)
|
||||||
|
INSTANTIATE_COMP(3)
|
||||||
|
INSTANTIATE_COMP(4)
|
||||||
|
INSTANTIATE_COMP(5)
|
||||||
|
INSTANTIATE_COMP(6)
|
||||||
|
INSTANTIATE_COMP(7)
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#define OPM_COMPOSITIONAL_CONTAINER_HPP
|
#define OPM_COMPOSITIONAL_CONTAINER_HPP
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
@@ -38,9 +40,17 @@ class CompositionalContainer
|
|||||||
using ScalarBuffer = std::vector<Scalar>;
|
using ScalarBuffer = std::vector<Scalar>;
|
||||||
|
|
||||||
static constexpr int numComponents = FluidSystem::numComponents;
|
static constexpr int numComponents = FluidSystem::numComponents;
|
||||||
|
|
||||||
static constexpr int numPhases = FluidSystem::numPhases;
|
static constexpr int numPhases = FluidSystem::numPhases;
|
||||||
|
static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
|
||||||
|
static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
|
||||||
|
static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void allocate(const unsigned bufferSize,
|
||||||
|
std::map<std::string, int>& rstKeywords);
|
||||||
|
|
||||||
|
bool allocated_ = false;
|
||||||
// total mole fractions for each component
|
// total mole fractions for each component
|
||||||
std::array<ScalarBuffer, numComponents> moleFractions_;
|
std::array<ScalarBuffer, numComponents> moleFractions_;
|
||||||
// mole fractions for each component in each phase
|
// mole fractions for each component in each phase
|
||||||
|
|||||||
@@ -1294,26 +1294,7 @@ doAllocBuffers(const unsigned bufferSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->isCompositional_) {
|
if (this->isCompositional_) {
|
||||||
if (rstKeywords["ZMF"] > 0) {
|
this->compC_.allocate(bufferSize, rstKeywords);
|
||||||
rstKeywords["ZMF"] = 0;
|
|
||||||
for (int i = 0; i < numComponents; ++i) {
|
|
||||||
compC_.moleFractions_[i].resize(bufferSize, 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rstKeywords["XMF"] > 0 && FluidSystem::phaseIsActive(oilPhaseIdx)) {
|
|
||||||
rstKeywords["XMF"] = 0;
|
|
||||||
for (int i = 0; i < numComponents; ++i) {
|
|
||||||
compC_.phaseMoleFractions_[oilPhaseIdx][i].resize(bufferSize, 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rstKeywords["YMF"] > 0 && FluidSystem::phaseIsActive(gasPhaseIdx)) {
|
|
||||||
rstKeywords["YMF"] = 0;
|
|
||||||
for (int i = 0; i < numComponents; ++i) {
|
|
||||||
compC_.phaseMoleFractions_[gasPhaseIdx][i].resize(bufferSize, 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user