mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
blackoilbrineparams: introduce translation unit
move code for loading parameters from eclipse state into it
This commit is contained in:
parent
99d64ff7ec
commit
a51e13c244
@ -55,6 +55,7 @@ endmacro()
|
||||
# originally generated with the command:
|
||||
# find opm -name '*.c*' -printf '\t%p\n' | sort
|
||||
list (APPEND MAIN_SOURCE_FILES
|
||||
opm/models/blackoil/blackoilbrineparams.cpp
|
||||
opm/simulators/flow/ActionHandler.cpp
|
||||
opm/simulators/flow/Banners.cpp
|
||||
opm/simulators/flow/BlackoilModelParameters.cpp
|
||||
|
@ -35,16 +35,6 @@
|
||||
|
||||
#include <opm/models/utils/basicproperties.hh>
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/PvtwsaltTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/PcfactTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/PermfactTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/SaltSolubilityTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/SimpleTable.hpp>
|
||||
#endif
|
||||
|
||||
#include <dune/common/fvector.hh>
|
||||
|
||||
#include <string>
|
||||
@ -87,79 +77,11 @@ class BlackOilBrineModule
|
||||
static constexpr unsigned numPhases = FluidSystem::numPhases;
|
||||
|
||||
public:
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
/*!
|
||||
* \brief Initialize all internal data structures needed by the brine module
|
||||
*/
|
||||
static void initFromState(const EclipseState& eclState)
|
||||
//! \brief Set parameters.
|
||||
static void setParams(BlackOilBrineParams<Scalar>&& params)
|
||||
{
|
||||
// some sanity checks: if brine are enabled, the BRINE keyword must be
|
||||
// present, if brine are disabled the keyword must not be present.
|
||||
if (enableBrine && !eclState.runspec().phases().active(Phase::BRINE)) {
|
||||
throw std::runtime_error("Non-trivial brine treatment requested at compile time, but "
|
||||
"the deck does not contain the BRINE keyword");
|
||||
}
|
||||
else if (!enableBrine && eclState.runspec().phases().active(Phase::BRINE)) {
|
||||
throw std::runtime_error("Brine treatment disabled at compile time, but the deck "
|
||||
"contains the BRINE keyword");
|
||||
}
|
||||
|
||||
if (!eclState.runspec().phases().active(Phase::BRINE))
|
||||
return; // brine treatment is supposed to be disabled
|
||||
|
||||
const auto& tableManager = eclState.getTableManager();
|
||||
|
||||
unsigned numPvtRegions = tableManager.getTabdims().getNumPVTTables();
|
||||
params_.referencePressure_.resize(numPvtRegions);
|
||||
|
||||
const auto& pvtwsaltTables = tableManager.getPvtwSaltTables();
|
||||
|
||||
// initialize the objects which deal with the BDENSITY keyword
|
||||
const auto& bdensityTables = tableManager.getBrineDensityTables();
|
||||
if (!bdensityTables.empty()) {
|
||||
params_.bdensityTable_.resize(numPvtRegions);
|
||||
assert(numPvtRegions == bdensityTables.size());
|
||||
for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++ pvtRegionIdx) {
|
||||
const auto& bdensityTable = bdensityTables[pvtRegionIdx];
|
||||
const auto& pvtwsaltTable = pvtwsaltTables[pvtRegionIdx];
|
||||
const auto& c = pvtwsaltTable.getSaltConcentrationColumn();
|
||||
params_.bdensityTable_[pvtRegionIdx].setXYContainers(c, bdensityTable);
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (enableSaltPrecipitation) {
|
||||
const TableContainer& permfactTables = tableManager.getPermfactTables();
|
||||
params_.permfactTable_.resize(numPvtRegions);
|
||||
for (size_t i = 0; i < permfactTables.size(); ++i) {
|
||||
const PermfactTable& permfactTable = permfactTables.getTable<PermfactTable>(i);
|
||||
params_.permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), permfactTable.getPermeabilityMultiplierColumn());
|
||||
}
|
||||
|
||||
const TableContainer& saltsolTables = tableManager.getSaltsolTables();
|
||||
if (!saltsolTables.empty()) {
|
||||
params_.saltsolTable_.resize(numPvtRegions);
|
||||
params_.saltdenTable_.resize(numPvtRegions);
|
||||
assert(numPvtRegions == saltsolTables.size());
|
||||
for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++ pvtRegionIdx) {
|
||||
const SaltsolTable& saltsolTable = saltsolTables.getTable<SaltsolTable>(pvtRegionIdx );
|
||||
params_.saltsolTable_[pvtRegionIdx] = saltsolTable.getSaltsolColumn().front();
|
||||
params_.saltdenTable_[pvtRegionIdx] = saltsolTable.getSaltdenColumn().front();
|
||||
}
|
||||
}
|
||||
|
||||
const TableContainer& pcfactTables = tableManager.getPcfactTables();
|
||||
if (!pcfactTables.empty()) {
|
||||
unsigned numSatRegions = tableManager.getTabdims().getNumSatTables();
|
||||
params_.pcfactTable_.resize(numSatRegions);
|
||||
for (size_t i = 0; i < pcfactTables.size(); ++i) {
|
||||
const PcfactTable& pcfactTable = pcfactTables.getTable<PcfactTable>(i);
|
||||
params_.pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), pcfactTable.getPcMultiplierColumn());
|
||||
}
|
||||
}
|
||||
}
|
||||
params_ = params;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Register all run-time parameters for the black-oil brine module.
|
||||
|
134
opm/models/blackoil/blackoilbrineparams.cpp
Normal file
134
opm/models/blackoil/blackoilbrineparams.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
// -*- 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.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/models/blackoil/blackoilbrineparams.hpp>
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/PvtwsaltTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/PcfactTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/PermfactTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/SaltSolubilityTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/SimpleTable.hpp>
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
template<class Scalar>
|
||||
template<bool enableBrine, bool enableSaltPrecipitation>
|
||||
void BlackOilBrineParams<Scalar>::
|
||||
initFromState(const EclipseState& eclState)
|
||||
{
|
||||
// some sanity checks: if brine are enabled, the BRINE keyword must be
|
||||
// present, if brine are disabled the keyword must not be present.
|
||||
if constexpr (enableBrine) {
|
||||
if (!eclState.runspec().phases().active(Phase::BRINE)) {
|
||||
throw std::runtime_error("Non-trivial brine treatment requested at compile time, but "
|
||||
"the deck does not contain the BRINE keyword");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (eclState.runspec().phases().active(Phase::BRINE)) {
|
||||
throw std::runtime_error("Brine treatment disabled at compile time, but the deck "
|
||||
"contains the BRINE keyword");
|
||||
}
|
||||
}
|
||||
|
||||
if (!eclState.runspec().phases().active(Phase::BRINE)) {
|
||||
return; // brine treatment is supposed to be disabled
|
||||
}
|
||||
|
||||
const auto& tableManager = eclState.getTableManager();
|
||||
|
||||
unsigned numPvtRegions = tableManager.getTabdims().getNumPVTTables();
|
||||
referencePressure_.resize(numPvtRegions);
|
||||
|
||||
const auto& pvtwsaltTables = tableManager.getPvtwSaltTables();
|
||||
|
||||
// initialize the objects which deal with the BDENSITY keyword
|
||||
const auto& bdensityTables = tableManager.getBrineDensityTables();
|
||||
if (!bdensityTables.empty()) {
|
||||
bdensityTable_.resize(numPvtRegions);
|
||||
assert(numPvtRegions == bdensityTables.size());
|
||||
for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) {
|
||||
const auto& bdensityTable = bdensityTables[pvtRegionIdx];
|
||||
const auto& pvtwsaltTable = pvtwsaltTables[pvtRegionIdx];
|
||||
const auto& c = pvtwsaltTable.getSaltConcentrationColumn();
|
||||
bdensityTable_[pvtRegionIdx].setXYContainers(c, bdensityTable);
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (enableSaltPrecipitation) {
|
||||
const TableContainer& permfactTables = tableManager.getPermfactTables();
|
||||
permfactTable_.resize(numPvtRegions);
|
||||
for (std::size_t i = 0; i < permfactTables.size(); ++i) {
|
||||
const PermfactTable& permfactTable = permfactTables.getTable<PermfactTable>(i);
|
||||
permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), permfactTable.getPermeabilityMultiplierColumn());
|
||||
}
|
||||
|
||||
const TableContainer& saltsolTables = tableManager.getSaltsolTables();
|
||||
if (!saltsolTables.empty()) {
|
||||
saltsolTable_.resize(numPvtRegions);
|
||||
saltdenTable_.resize(numPvtRegions);
|
||||
assert(numPvtRegions == saltsolTables.size());
|
||||
for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) {
|
||||
const SaltsolTable& saltsolTable = saltsolTables.getTable<SaltsolTable>(pvtRegionIdx );
|
||||
saltsolTable_[pvtRegionIdx] = saltsolTable.getSaltsolColumn().front();
|
||||
saltdenTable_[pvtRegionIdx] = saltsolTable.getSaltdenColumn().front();
|
||||
}
|
||||
}
|
||||
|
||||
const TableContainer& pcfactTables = tableManager.getPcfactTables();
|
||||
if (!pcfactTables.empty()) {
|
||||
unsigned numSatRegions = tableManager.getTabdims().getNumSatTables();
|
||||
pcfactTable_.resize(numSatRegions);
|
||||
for (std::size_t i = 0; i < pcfactTables.size(); ++i) {
|
||||
const PcfactTable& pcfactTable = pcfactTables.getTable<PcfactTable>(i);
|
||||
pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), pcfactTable.getPcMultiplierColumn());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define INSTANTIATE_TYPE(T) \
|
||||
template struct BlackOilBrineParams<T>; \
|
||||
template void BlackOilBrineParams<T>::initFromState<false,false>(const EclipseState&); \
|
||||
template void BlackOilBrineParams<T>::initFromState<true,false>(const EclipseState&); \
|
||||
template void BlackOilBrineParams<T>::initFromState<false,true>(const EclipseState&); \
|
||||
template void BlackOilBrineParams<T>::initFromState<true,true>(const EclipseState&);
|
||||
|
||||
INSTANTIATE_TYPE(double)
|
||||
|
||||
#if FLOW_INSTANTIATE_FLOAT
|
||||
INSTANTIATE_TYPE(float)
|
||||
#endif
|
||||
|
||||
} // namespace Opm
|
@ -34,9 +34,19 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
class EclipseState;
|
||||
#endif
|
||||
|
||||
//! \brief Struct holding the parameters for the BlackoilBrineModule class.
|
||||
template<class Scalar>
|
||||
struct BlackOilBrineParams {
|
||||
struct BlackOilBrineParams
|
||||
{
|
||||
#if HAVE_ECL_INPUT
|
||||
template<bool enableBrine, bool enableSaltPrecipitation>
|
||||
void initFromState(const EclipseState& eclState);
|
||||
#endif
|
||||
|
||||
using TabulatedFunction = Tabulated1DFunction<Scalar>;
|
||||
|
||||
std::vector<TabulatedFunction> bdensityTable_;
|
||||
|
@ -276,8 +276,13 @@ public:
|
||||
const auto& vanguard = simulator.vanguard();
|
||||
SolventModule::initFromState(vanguard.eclState(), vanguard.schedule());
|
||||
PolymerModule::initFromState(vanguard.eclState());
|
||||
|
||||
BlackOilBrineParams<Scalar> brineParams;
|
||||
brineParams.template initFromState<enableBrine,
|
||||
enableSaltPrecipitation>(vanguard.eclState());
|
||||
BrineModule::setParams(std::move(brineParams));
|
||||
|
||||
FoamModule::initFromState(vanguard.eclState());
|
||||
BrineModule::initFromState(vanguard.eclState());
|
||||
ExtboModule::initFromState(vanguard.eclState());
|
||||
MICPModule::initFromState(vanguard.eclState());
|
||||
DispersionModule::initFromState(vanguard.eclState());
|
||||
|
Loading…
Reference in New Issue
Block a user