Skip to content

Commit

Permalink
OilPvtMultiplexer: put initFromState in separate compile unit
Browse files Browse the repository at this point in the history
thus encapsulating EclipseState, Schedule and TableManager
  • Loading branch information
akva2 committed Dec 22, 2022
1 parent 0855259 commit 4e17a57
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 25 deletions.
1 change: 1 addition & 0 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ if(ENABLE_ECL_INPUT)
src/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.cpp
src/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp
src/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp
src/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.cpp
src/opm/material/fluidsystems/blackoilpvt/SolventPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/WaterPvtThermal.cpp
Expand Down
30 changes: 5 additions & 25 deletions opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
#include "OilPvtThermal.hpp"
#include "BrineCo2Pvt.hpp"

namespace Opm {

#if HAVE_ECL_INPUT
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
class EclipseState;
class Schedule;
#endif

namespace Opm {
#define OPM_OIL_PVT_MULTIPLEXER_CALL(codeToCall) \
switch (approach_) { \
case OilPvtApproach::ConstantCompressibilityOil: { \
Expand Down Expand Up @@ -146,26 +147,7 @@ class OilPvtMultiplexer
*
* This method assumes that the deck features valid DENSITY and PVTO/PVDO/PVCDO keywords.
*/
void initFromState(const EclipseState& eclState, const Schedule& schedule)
{
if (!eclState.runspec().phases().active(Phase::OIL))
return;

// The co2Storage option both works with oil + gas
// and water/brine + gas
if (eclState.runspec().co2Storage())
setApproach(OilPvtApproach::BrineCo2);
else if (enableThermal && eclState.getSimulationConfig().isThermal())
setApproach(OilPvtApproach::ThermalOil);
else if (!eclState.getTableManager().getPvcdoTable().empty())
setApproach(OilPvtApproach::ConstantCompressibilityOil);
else if (eclState.getTableManager().hasTables("PVDO"))
setApproach(OilPvtApproach::DeadOil);
else if (!eclState.getTableManager().getPvtoTables().empty())
setApproach(OilPvtApproach::LiveOil);

OPM_OIL_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
}
void initFromState(const EclipseState& eclState, const Schedule& schedule);
#endif // HAVE_ECL_INPUT


Expand Down Expand Up @@ -418,8 +400,6 @@ class OilPvtMultiplexer
void* realOilPvt_;
};

#undef OPM_OIL_PVT_MULTIPLEXER_CALL

} // namespace Opm

#endif
60 changes: 60 additions & 0 deletions src/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// -*- 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/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp>

#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>

namespace Opm {

template <class Scalar, bool enableThermal>
void OilPvtMultiplexer<Scalar,enableThermal>::
initFromState(const EclipseState& eclState, const Schedule& schedule)
{
if (!eclState.runspec().phases().active(Phase::OIL))
return;

// The co2Storage option both works with oil + gas
// and water/brine + gas
if (eclState.runspec().co2Storage())
setApproach(OilPvtApproach::BrineCo2);
else if (enableThermal && eclState.getSimulationConfig().isThermal())
setApproach(OilPvtApproach::ThermalOil);
else if (!eclState.getTableManager().getPvcdoTable().empty())
setApproach(OilPvtApproach::ConstantCompressibilityOil);
else if (eclState.getTableManager().hasTables("PVDO"))
setApproach(OilPvtApproach::DeadOil);
else if (!eclState.getTableManager().getPvtoTables().empty())
setApproach(OilPvtApproach::LiveOil);

OPM_OIL_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
}

template class OilPvtMultiplexer<double,false>;
template class OilPvtMultiplexer<double,true>;
template class OilPvtMultiplexer<float,false>;
template class OilPvtMultiplexer<float,true>;

} // namespace Opm

0 comments on commit 4e17a57

Please sign in to comment.