mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-12 01:11:55 -06:00
blackoilfoamparams: introduce translation unit
move code for loading parameters from eclipse state into it
This commit is contained in:
parent
6bb6e3db43
commit
f6d3893093
@ -57,6 +57,7 @@ endmacro()
|
||||
list (APPEND MAIN_SOURCE_FILES
|
||||
opm/models/blackoil/blackoilbrineparams.cpp
|
||||
opm/models/blackoil/blackoilextboparams.cpp
|
||||
opm/models/blackoil/blackoilfoamparams.cpp
|
||||
opm/simulators/flow/ActionHandler.cpp
|
||||
opm/simulators/flow/Banners.cpp
|
||||
opm/simulators/flow/BlackoilModelParameters.cpp
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Phase.hpp>
|
||||
|
||||
#include <opm/models/blackoil/blackoilfoamparams.hpp>
|
||||
#include <opm/models/blackoil/blackoilproperties.hh>
|
||||
|
||||
@ -86,93 +88,11 @@ class BlackOilFoamModule
|
||||
enum { enableSolvent = getPropValue<TypeTag, Properties::EnableSolvent>() };
|
||||
|
||||
public:
|
||||
#if HAVE_ECL_INPUT
|
||||
/*!
|
||||
* \brief Initialize all internal data structures needed by the foam module
|
||||
*/
|
||||
static void initFromState(const EclipseState& eclState)
|
||||
//! \brief Set parameters.
|
||||
static void setParams(BlackOilFoamParams<Scalar>&& params)
|
||||
{
|
||||
// some sanity checks: if foam is enabled, the FOAM keyword must be
|
||||
// present, if foam is disabled the keyword must not be present.
|
||||
if (enableFoam && !eclState.runspec().phases().active(Phase::FOAM)) {
|
||||
throw std::runtime_error("Non-trivial foam treatment requested at compile time, but "
|
||||
"the deck does not contain the FOAM keyword");
|
||||
}
|
||||
else if (!enableFoam && eclState.runspec().phases().active(Phase::FOAM)) {
|
||||
throw std::runtime_error("Foam treatment disabled at compile time, but the deck "
|
||||
"contains the FOAM keyword");
|
||||
}
|
||||
|
||||
if (!eclState.runspec().phases().active(Phase::FOAM)) {
|
||||
return; // foam treatment is supposed to be disabled
|
||||
}
|
||||
|
||||
params_.transport_phase_ = eclState.getInitConfig().getFoamConfig().getTransportPhase();
|
||||
|
||||
if (eclState.getInitConfig().getFoamConfig().getMobilityModel() != FoamConfig::MobilityModel::TAB) {
|
||||
throw std::runtime_error("In FOAMOPTS, only TAB is allowed for the gas mobility factor reduction model.");
|
||||
}
|
||||
|
||||
const auto& tableManager = eclState.getTableManager();
|
||||
const unsigned int numSatRegions = tableManager.getTabdims().getNumSatTables();
|
||||
params_.setNumSatRegions(numSatRegions);
|
||||
const unsigned int numPvtRegions = tableManager.getTabdims().getNumPVTTables();
|
||||
params_.gasMobilityMultiplierTable_.resize(numPvtRegions);
|
||||
|
||||
// Get and check FOAMROCK data.
|
||||
const FoamConfig& foamConf = eclState.getInitConfig().getFoamConfig();
|
||||
if (numSatRegions != foamConf.size()) {
|
||||
throw std::runtime_error("Inconsistent sizes, number of saturation regions differ from the number of elements "
|
||||
"in FoamConfig, which typically corresponds to the number of records in FOAMROCK.");
|
||||
}
|
||||
|
||||
// Get and check FOAMADS data.
|
||||
const auto& foamadsTables = tableManager.getFoamadsTables();
|
||||
if (foamadsTables.empty()) {
|
||||
throw std::runtime_error("FOAMADS must be specified in FOAM runs");
|
||||
}
|
||||
if (numSatRegions != foamadsTables.size()) {
|
||||
throw std::runtime_error("Inconsistent sizes, number of saturation regions differ from the "
|
||||
"number of FOAMADS tables.");
|
||||
}
|
||||
|
||||
// Set data that vary with saturation region.
|
||||
for (std::size_t satReg = 0; satReg < numSatRegions; ++satReg) {
|
||||
const auto& rec = foamConf.getRecord(satReg);
|
||||
params_.foamCoefficients_[satReg] = typename BlackOilFoamParams<Scalar>::FoamCoefficients();
|
||||
params_.foamCoefficients_[satReg].fm_min = rec.minimumSurfactantConcentration();
|
||||
params_.foamCoefficients_[satReg].fm_surf = rec.referenceSurfactantConcentration();
|
||||
params_.foamCoefficients_[satReg].ep_surf = rec.exponent();
|
||||
params_.foamRockDensity_[satReg] = rec.rockDensity();
|
||||
params_.foamAllowDesorption_[satReg] = rec.allowDesorption();
|
||||
const auto& foamadsTable = foamadsTables.template getTable<FoamadsTable>(satReg);
|
||||
const auto& conc = foamadsTable.getFoamConcentrationColumn();
|
||||
const auto& ads = foamadsTable.getAdsorbedFoamColumn();
|
||||
params_.adsorbedFoamTable_[satReg].setXYContainers(conc, ads);
|
||||
}
|
||||
|
||||
// Get and check FOAMMOB data.
|
||||
const auto& foammobTables = tableManager.getFoammobTables();
|
||||
if (foammobTables.empty()) {
|
||||
// When in the future adding support for the functional
|
||||
// model, FOAMMOB will not be required anymore (functional
|
||||
// family of keywords can be used instead, FOAMFSC etc.).
|
||||
throw std::runtime_error("FOAMMOB must be specified in FOAM runs");
|
||||
}
|
||||
if (numPvtRegions != foammobTables.size()) {
|
||||
throw std::runtime_error("Inconsistent sizes, number of PVT regions differ from the "
|
||||
"number of FOAMMOB tables.");
|
||||
}
|
||||
|
||||
// Set data that vary with PVT region.
|
||||
for (std::size_t pvtReg = 0; pvtReg < numPvtRegions; ++pvtReg) {
|
||||
const auto& foammobTable = foammobTables.template getTable<FoammobTable>(pvtReg);
|
||||
const auto& conc = foammobTable.getFoamConcentrationColumn();
|
||||
const auto& mobMult = foammobTable.getMobilityMultiplierColumn();
|
||||
params_.gasMobilityMultiplierTable_[pvtReg].setXYContainers(conc, mobMult);
|
||||
}
|
||||
params_ = params;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Register all run-time parameters for the black-oil foam module.
|
||||
|
150
opm/models/blackoil/blackoilfoamparams.cpp
Normal file
150
opm/models/blackoil/blackoilfoamparams.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
// -*- 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/blackoilfoamparams.hpp>
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/FoamadsTable.hpp>
|
||||
#include <opm/input/eclipse/EclipseState/Tables/FoammobTable.hpp>
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
template<class Scalar>
|
||||
template<bool enableFoam>
|
||||
void BlackOilFoamParams<Scalar>::
|
||||
initFromState(const EclipseState& eclState)
|
||||
{
|
||||
// some sanity checks: if foam is enabled, the FOAM keyword must be
|
||||
// present, if foam is disabled the keyword must not be present.
|
||||
if constexpr (enableFoam) {
|
||||
if (!eclState.runspec().phases().active(Phase::FOAM)) {
|
||||
throw std::runtime_error("Non-trivial foam treatment requested at compile time, but "
|
||||
"the deck does not contain the FOAM keyword");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (eclState.runspec().phases().active(Phase::FOAM)) {
|
||||
throw std::runtime_error("Foam treatment disabled at compile time, but the deck "
|
||||
"contains the FOAM keyword");
|
||||
}
|
||||
}
|
||||
|
||||
if (!eclState.runspec().phases().active(Phase::FOAM)) {
|
||||
return; // foam treatment is supposed to be disabled
|
||||
}
|
||||
|
||||
transport_phase_ = eclState.getInitConfig().getFoamConfig().getTransportPhase();
|
||||
|
||||
if (eclState.getInitConfig().getFoamConfig().getMobilityModel() != FoamConfig::MobilityModel::TAB) {
|
||||
throw std::runtime_error("In FOAMOPTS, only TAB is allowed for the gas mobility factor reduction model.");
|
||||
}
|
||||
|
||||
const auto& tableManager = eclState.getTableManager();
|
||||
const unsigned int numSatRegions = tableManager.getTabdims().getNumSatTables();
|
||||
setNumSatRegions(numSatRegions);
|
||||
const unsigned int numPvtRegions = tableManager.getTabdims().getNumPVTTables();
|
||||
gasMobilityMultiplierTable_.resize(numPvtRegions);
|
||||
|
||||
// Get and check FOAMROCK data.
|
||||
const FoamConfig& foamConf = eclState.getInitConfig().getFoamConfig();
|
||||
if (numSatRegions != foamConf.size()) {
|
||||
throw std::runtime_error("Inconsistent sizes, number of saturation regions differ from the number of elements "
|
||||
"in FoamConfig, which typically corresponds to the number of records in FOAMROCK.");
|
||||
}
|
||||
|
||||
// Get and check FOAMADS data.
|
||||
const auto& foamadsTables = tableManager.getFoamadsTables();
|
||||
if (foamadsTables.empty()) {
|
||||
throw std::runtime_error("FOAMADS must be specified in FOAM runs");
|
||||
}
|
||||
if (numSatRegions != foamadsTables.size()) {
|
||||
throw std::runtime_error("Inconsistent sizes, number of saturation regions differ from the "
|
||||
"number of FOAMADS tables.");
|
||||
}
|
||||
|
||||
// Set data that vary with saturation region.
|
||||
for (std::size_t satReg = 0; satReg < numSatRegions; ++satReg) {
|
||||
const auto& rec = foamConf.getRecord(satReg);
|
||||
foamCoefficients_[satReg] = FoamCoefficients();
|
||||
foamCoefficients_[satReg].fm_min = rec.minimumSurfactantConcentration();
|
||||
foamCoefficients_[satReg].fm_surf = rec.referenceSurfactantConcentration();
|
||||
foamCoefficients_[satReg].ep_surf = rec.exponent();
|
||||
foamRockDensity_[satReg] = rec.rockDensity();
|
||||
foamAllowDesorption_[satReg] = rec.allowDesorption();
|
||||
const auto& foamadsTable = foamadsTables.template getTable<FoamadsTable>(satReg);
|
||||
const auto& conc = foamadsTable.getFoamConcentrationColumn();
|
||||
const auto& ads = foamadsTable.getAdsorbedFoamColumn();
|
||||
adsorbedFoamTable_[satReg].setXYContainers(conc, ads);
|
||||
}
|
||||
|
||||
// Get and check FOAMMOB data.
|
||||
const auto& foammobTables = tableManager.getFoammobTables();
|
||||
if (foammobTables.empty()) {
|
||||
// When in the future adding support for the functional
|
||||
// model, FOAMMOB will not be required anymore (functional
|
||||
// family of keywords can be used instead, FOAMFSC etc.).
|
||||
throw std::runtime_error("FOAMMOB must be specified in FOAM runs");
|
||||
}
|
||||
if (numPvtRegions != foammobTables.size()) {
|
||||
throw std::runtime_error("Inconsistent sizes, number of PVT regions differ from the "
|
||||
"number of FOAMMOB tables.");
|
||||
}
|
||||
|
||||
// Set data that vary with PVT region.
|
||||
for (std::size_t pvtReg = 0; pvtReg < numPvtRegions; ++pvtReg) {
|
||||
const auto& foammobTable = foammobTables.template getTable<FoammobTable>(pvtReg);
|
||||
const auto& conc = foammobTable.getFoamConcentrationColumn();
|
||||
const auto& mobMult = foammobTable.getMobilityMultiplierColumn();
|
||||
gasMobilityMultiplierTable_[pvtReg].setXYContainers(conc, mobMult);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Scalar>
|
||||
void BlackOilFoamParams<Scalar>::setNumSatRegions(unsigned numRegions)
|
||||
{
|
||||
foamCoefficients_.resize(numRegions);
|
||||
foamRockDensity_.resize(numRegions);
|
||||
foamAllowDesorption_.resize(numRegions);
|
||||
adsorbedFoamTable_.resize(numRegions);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_TYPE(T) \
|
||||
template struct BlackOilFoamParams<T>; \
|
||||
template void BlackOilFoamParams<T>::initFromState<false>(const EclipseState&); \
|
||||
template void BlackOilFoamParams<T>::initFromState<true>(const EclipseState&);
|
||||
|
||||
INSTANTIATE_TYPE(double)
|
||||
|
||||
#if FLOW_INSTANTIATE_FLOAT
|
||||
INSTANTIATE_TYPE(float)
|
||||
#endif
|
||||
|
||||
} // namespace Opm
|
@ -28,28 +28,33 @@
|
||||
#ifndef OPM_BLACK_OIL_FOAM_PARAMS_HPP
|
||||
#define OPM_BLACK_OIL_FOAM_PARAMS_HPP
|
||||
|
||||
#include <opm/input/eclipse/EclipseState/Phase.hpp>
|
||||
#include <opm/material/common/Tabulated1DFunction.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
enum class Phase;
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
class EclipseState;
|
||||
#endif
|
||||
|
||||
//! \brief Struct holding the parameters for the BlackoilFoamModule class.
|
||||
template<class Scalar>
|
||||
struct BlackOilFoamParams {
|
||||
struct BlackOilFoamParams
|
||||
{
|
||||
using TabulatedFunction = Tabulated1DFunction<Scalar>;
|
||||
|
||||
#if HAVE_ECL_INPUT
|
||||
template<bool enableFoam>
|
||||
void initFromState(const EclipseState& eclState);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Specify the number of saturation regions.
|
||||
*/
|
||||
void setNumSatRegions(unsigned numRegions)
|
||||
{
|
||||
foamCoefficients_.resize(numRegions);
|
||||
foamRockDensity_.resize(numRegions);
|
||||
foamAllowDesorption_.resize(numRegions);
|
||||
adsorbedFoamTable_.resize(numRegions);
|
||||
}
|
||||
void setNumSatRegions(unsigned numRegions);
|
||||
|
||||
// a struct containing constants to calculate change to relative permeability,
|
||||
// based on model (1-9) in Table 1 of
|
||||
|
@ -286,7 +286,9 @@ public:
|
||||
extboParams.template initFromState<enableExtbo>(vanguard.eclState());
|
||||
ExtboModule::setParams(std::move(extboParams));
|
||||
|
||||
FoamModule::initFromState(vanguard.eclState());
|
||||
BlackOilFoamParams<Scalar> foamParams;
|
||||
foamParams.template initFromState<enableFoam>(vanguard.eclState());
|
||||
FoamModule::setParams(std::move(foamParams));
|
||||
|
||||
MICPModule::initFromState(vanguard.eclState());
|
||||
DispersionModule::initFromState(vanguard.eclState());
|
||||
|
Loading…
Reference in New Issue
Block a user