From 51da91c1ad62ad310c70657efb842267480bb509 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 27 Nov 2018 11:00:13 +0100 Subject: [PATCH] remove files moved to opm-simulators-legacy --- opm/autodiff/Compat.cpp | 285 ------- opm/autodiff/Compat.hpp | 75 -- opm/autodiff/RateConverterLegacy.hpp | 776 ------------------ .../props/BlackoilPropertiesInterface.hpp | 184 ----- opm/core/simulator/BlackoilState.cpp | 52 -- opm/core/simulator/BlackoilState.hpp | 94 --- .../simulator/BlackoilStateToFluidState.hpp | 94 --- opm/core/utility/initHydroCarbonState.hpp | 44 - opm/polymer/PolymerBlackoilState.cpp | 42 - opm/polymer/PolymerBlackoilState.hpp | 47 -- tests/testBlackoilState1.DATA | 18 - tests/testBlackoilState2.DATA | 14 - tests/test_blackoilstate.cpp | 140 ---- 13 files changed, 1865 deletions(-) delete mode 100644 opm/autodiff/Compat.cpp delete mode 100644 opm/autodiff/Compat.hpp delete mode 100644 opm/autodiff/RateConverterLegacy.hpp delete mode 100644 opm/core/props/BlackoilPropertiesInterface.hpp delete mode 100644 opm/core/simulator/BlackoilState.cpp delete mode 100644 opm/core/simulator/BlackoilState.hpp delete mode 100644 opm/core/simulator/BlackoilStateToFluidState.hpp delete mode 100644 opm/core/utility/initHydroCarbonState.hpp delete mode 100644 opm/polymer/PolymerBlackoilState.cpp delete mode 100644 opm/polymer/PolymerBlackoilState.hpp delete mode 100644 tests/testBlackoilState1.DATA delete mode 100644 tests/testBlackoilState2.DATA delete mode 100644 tests/test_blackoilstate.cpp diff --git a/opm/autodiff/Compat.cpp b/opm/autodiff/Compat.cpp deleted file mode 100644 index c337547d4..000000000 --- a/opm/autodiff/Compat.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - Copyright 2016 Statoil ASA - Copyright 2016 IRIS - Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. - - 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 3 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 . -*/ - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Opm { - -std::vector< double > destripe( const std::vector< double >& v, - size_t stride, - size_t offset ) { - - std::vector< double > dst( v.size() / stride ); - - size_t di = 0; - for( size_t i = offset; i < v.size(); i += stride ) { - dst[ di++ ] = v[ i ]; - } - - return dst; -} - - - - - - -std::vector< double >& stripe( const std::vector< double >& v, - size_t stride, - size_t offset, - std::vector< double >& dst ) { - - /* does little range checking etc; for future revisions */ - size_t vi = 0; - for( size_t i = offset; i < dst.size(); i += stride ) { - dst[ i ] = v[ vi++ ]; - } - - return dst; -} - - - - - - -data::Solution simToSolution( const SimulationDataContainer& reservoir, - const bool use_si_units, - PhaseUsage phases ) { - - // Set up unit system to use to suppress conversion if use_si_units is true. - const UnitSystem::measure press_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::pressure; - const UnitSystem::measure temp_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::temperature; - const UnitSystem::measure rs_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::gas_oil_ratio; - const UnitSystem::measure rv_unit = use_si_units ? UnitSystem::measure::identity : UnitSystem::measure::oil_gas_ratio; - - data::Solution sol; - sol.insert( "PRESSURE", press_unit, reservoir.pressure() , data::TargetType::RESTART_SOLUTION); - sol.insert( "TEMP" , temp_unit, reservoir.temperature() , data::TargetType::RESTART_SOLUTION ); - - const auto ph = reservoir.numPhases(); - const auto& sat = reservoir.saturation(); - - const auto aqua = BlackoilPhases::Aqua; - const auto vapour = BlackoilPhases::Vapour; - - if( phases.phase_used[ aqua ] ) { - sol.insert( "SWAT", UnitSystem::measure::identity, destripe( sat, ph, phases.phase_pos[ aqua ] ) , data::TargetType::RESTART_SOLUTION ); - } - - if( phases.phase_used[ vapour ] ) { - sol.insert( "SGAS", UnitSystem::measure::identity, destripe( sat, ph, phases.phase_pos[ vapour ] ) , data::TargetType::RESTART_SOLUTION ); - } - - if( reservoir.hasCellData( BlackoilState::GASOILRATIO ) ) { - sol.insert( "RS", rs_unit, reservoir.getCellData( BlackoilState::GASOILRATIO ) , data::TargetType::RESTART_SOLUTION ); - } - - if( reservoir.hasCellData( BlackoilState::RV ) ) { - sol.insert( "RV", rv_unit, reservoir.getCellData( BlackoilState::RV ) , data::TargetType::RESTART_SOLUTION ); - } - - if (phases.has_solvent) { - sol.insert( "SSOL", UnitSystem::measure::identity, reservoir.getCellData( BlackoilState::SSOL ) , data::TargetType::RESTART_SOLUTION ); - } - - if (phases.has_polymer) { - if (reservoir.hasCellData( PolymerBlackoilState::CONCENTRATION )) { // compatibility with legacy polymer - sol.insert( "POLYMER", UnitSystem::measure::identity, reservoir.getCellData( PolymerBlackoilState::CONCENTRATION ) , data::TargetType::RESTART_SOLUTION ); - } else { - sol.insert( "POLYMER", UnitSystem::measure::identity, reservoir.getCellData( BlackoilState::POLYMER ) , data::TargetType::RESTART_SOLUTION ); - } - - } - - return sol; -} - - - - - - -void solutionToSim( const RestartValue& restart_value, - PhaseUsage phases, - SimulationDataContainer& state ) { - - const auto& sol = restart_value.solution; - const auto stride = phases.num_phases; - - if( sol.has( "SWAT" ) ) { - stripe( sol.data( "SWAT" ), - stride, - phases.phase_pos[ BlackoilPhases::Aqua ], - state.saturation() ); - } - - if( sol.has( "SGAS" ) ) { - stripe( sol.data( "SGAS" ), - stride, - phases.phase_pos[ BlackoilPhases::Vapour ], - state.saturation() ); - } - - for (size_t c = 0; c < state.numCells(); ++c) { - double& so = state.saturation()[phases.num_phases*c + phases.phase_pos[ BlackoilPhases::Liquid ]]; - so = 1.0; - if (phases.phase_used[ BlackoilPhases::Aqua]) { - so -= state.saturation()[phases.num_phases*c + phases.phase_pos[ BlackoilPhases::Aqua ]]; - } - if (phases.phase_used[ BlackoilPhases::Vapour]) { - so -= state.saturation()[phases.num_phases*c + phases.phase_pos[ BlackoilPhases::Vapour ]]; - } - } - - - if( sol.has( "PRESSURE" ) ) { - state.pressure() = sol.data( "PRESSURE" ); - } - - if( sol.has( "TEMP" ) ) { - state.temperature() = sol.data( "TEMP" ); - } - - if( sol.has( "RS" ) ) { - state.registerCellData("GASOILRATIO", 1); - state.getCellData( "GASOILRATIO" ) = sol.data( "RS" ); - } - - if( sol.has( "RV" ) ) { - state.registerCellData("RV", 1); - state.getCellData( "RV" ) = sol.data( "RV" ); - } - - if ( sol.has( "SSOL" ) ) { - state.registerCellData("SSOL", 1); - state.getCellData("SSOL") = sol.data("SSOL"); - } - - if ( sol.has("SOMAX" ) ) { - state.registerCellData("SOMAX", 1); - state.getCellData("SOMAX") = sol.data("SOMAX"); - } - - if ( sol.has("PCSWM_OW" ) ) { - state.registerCellData("PCSWMDC_OW", 1); - state.getCellData("PCSWMDC_OW") = sol.data("PCSWM_OW"); - } - - if ( sol.has("KRNSW_OW" ) ) { - state.registerCellData("KRNSWMDC_OW", 1); - state.getCellData("KRNSWMDC_OW") = sol.data("KRNSW_OW"); - } - - if ( sol.has("PCSWM_GO" ) ) { - state.registerCellData("PCSWMDC_GO", 1); - state.getCellData("PCSWMDC_GO") = sol.data("PCSWM_GO"); - } - - if ( sol.has("KRNSW_GO" ) ) { - state.registerCellData("KRNSWMDC_GO", 1); - state.getCellData("KRNSWMDC_GO") = sol.data("KRNSW_GO"); - } -} - - - - - - -void wellsToState( const data::Wells& wells, - PhaseUsage phases, - WellStateFullyImplicitBlackoil& state ) { - - using rt = data::Rates::opt; - - const auto np = phases.num_phases; - - std::vector< rt > phs( np ); - if( phases.phase_used[BlackoilPhases::Aqua] ) { - phs.at( phases.phase_pos[BlackoilPhases::Aqua] ) = rt::wat; - } - - if( phases.phase_used[BlackoilPhases::Liquid] ) { - phs.at( phases.phase_pos[BlackoilPhases::Liquid] ) = rt::oil; - } - - if( phases.phase_used[BlackoilPhases::Vapour] ) { - phs.at( phases.phase_pos[BlackoilPhases::Vapour] ) = rt::gas; - } - - for( const auto& wm : state.wellMap() ) { - const auto well_index = wm.second[ 0 ]; - const auto& well = wells.at( wm.first ); - - state.bhp()[ well_index ] = well.bhp; - state.temperature()[ well_index ] = well.temperature; - state.currentControls()[ well_index ] = well.control; - - const auto wellrate_index = well_index * np; - for( size_t i = 0; i < phs.size(); ++i ) { - assert( well.rates.has( phs[ i ] ) ); - state.wellRates()[ wellrate_index + i ] = well.rates.get( phs[ i ] ); - } - - const auto perforation_pressure = []( const data::Connection& comp ) { - return comp.pressure; - }; - - const auto perforation_reservoir_rate = []( const data::Connection& comp ) { - return comp.reservoir_rate; - }; - - std::transform( well.connections.begin(), - well.connections.end(), - state.perfPress().begin() + wm.second[ 1 ], - perforation_pressure ); - - std::transform( well.connections.begin(), - well.connections.end(), - state.perfRates().begin() + wm.second[ 1 ], - perforation_reservoir_rate ); - - int local_comp_index = 0; - for (const data::Connection& comp : well.connections) { - const int global_comp_index = wm.second[1] + local_comp_index; - for (int phase_index = 0; phase_index < np; ++phase_index) { - state.perfPhaseRates()[global_comp_index*np + phase_index] = comp.rates.get(phs[phase_index]); - } - ++local_comp_index; - } - } -} - -} // namespace Opm diff --git a/opm/autodiff/Compat.hpp b/opm/autodiff/Compat.hpp deleted file mode 100644 index 3a6ca0f45..000000000 --- a/opm/autodiff/Compat.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright 2016 Statoil ASA - 2016 IRIS - - 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 3 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 . - */ - -#ifndef OPM_SIMULATORS_COMPAT_HPP -#define OPM_SIMULATORS_COMPAT_HPP - -#include -#include -#include -#include -#include - -namespace Opm { - - // Forward declarations - class SimulationDataContainer; - class WellStateFullyImplicitBlackoil; - - /// Extract single data vector from striped data. - /// \return u such that u[i] = v[offset + i*stride]. - std::vector< double > destripe( const std::vector< double >& v, - size_t stride, - size_t offset ); - - /// Inject single data vector into striped data. - /// \return reference to dst input, that is changed so that - /// dst[offset + i*stride] = v[i]. This is done for - /// i = 0..(dst.size()/stride). - std::vector< double >& stripe( const std::vector< double >& v, - size_t stride, - size_t offset, - std::vector< double >& dst ); - - /// Returns Solution with the following fields: - /// PRESSURE, TEMP (unconditionally) - /// SWAT, SGAS, RS, RV, SSOL (if appropriate fields present in input) - /// If use_si_units is true, the fields will have the measure UnitSystem::measure::identity, - /// and therefore *not* be converted to customary units (depending on family) upon output. - data::Solution simToSolution( const SimulationDataContainer& reservoir, - const bool use_si_units, - PhaseUsage phases ); - - /// Copies the following fields from sol into state (all conditionally): - /// PRESSURE, TEMP, SWAT, SGAS, RS, RV, SSOL - /// Also handles extra data such as hysteresis parameters, SOMAX, etc. - void solutionToSim( const RestartValue& restart_value, - PhaseUsage phases, - SimulationDataContainer& state ); - - /// Copies the following fields from wells into state. - /// bhp, temperature, currentControls, wellRates, perfPress, perfRates, perfPhaseRates - void wellsToState( const data::Wells& wells, - PhaseUsage phases, - WellStateFullyImplicitBlackoil& state ); - -} - -#endif //OPM_SIMULATORS_COMPAT_HPP diff --git a/opm/autodiff/RateConverterLegacy.hpp b/opm/autodiff/RateConverterLegacy.hpp deleted file mode 100644 index e3c9ea6b8..000000000 --- a/opm/autodiff/RateConverterLegacy.hpp +++ /dev/null @@ -1,776 +0,0 @@ -/* - Copyright 2014, 2015 SINTEF ICT, Applied Mathematics. - Copyright 2014, 2015 Statoil ASA. - Copyright 2017, IRIS - - 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 3 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 . -*/ - -#ifndef OPM_RATECONVERTER_HPP_HEADER_INCLUDED -#define OPM_RATECONVERTER_HPP_HEADER_INCLUDED - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -/** - * \file - * Facility for converting component rates at surface conditions to - * phase (voidage) rates at reservoir conditions. - * - * This uses the average hydrocarbon pressure to define fluid - * properties. The facility is intended to support Reservoir Voidage - * rates only ('RESV'). - */ - -namespace Opm { - namespace RateConverter { - /** - * Convenience tools for implementing the rate conversion - * facility. - */ - namespace Details { - namespace Select { - template - struct RegionIDParameter - { - using type = - typename std::remove_reference::type &; - }; - - template - struct RegionIDParameter - { - using type = RegionID; - }; - } // Select - - /** - * \brief Computes the temperature, pressure, and counter increment. - * - * In a parallel run only cells owned contribute to the cell average. - * \tparam is_parallel Whether this is a parallel run. - */ - template - struct AverageIncrementCalculator - { - /** - * \brief Computes the temperature, pressure, and counter increment. - * \param pressure The pressure. - * \param temperature The temperature. - * \param rs The rs. - * \param rv The rv. - * \param cell The current cell index. - * \param ownership A vector indicating whether a cell is owned - * by this process (value 1), or not (value 0). - * \param cell The cell index. - */ - std::tuple - operator()(const std::vector& pressure, - const std::vector& temperature, - const std::vector& rs, - const std::vector& rv, - const std::vector& ownership, - std::size_t cell){ - if ( ownership[cell] ) - { - return std::make_tuple(pressure[cell], - temperature[cell], - rs[cell], - rv[cell], - 1); - } - else - { - return std::make_tuple(0, 0, 0, 0, 0); - } - } - }; - template<> - struct AverageIncrementCalculator - { - std::tuple - operator()(const std::vector& pressure, - const std::vector& temperature, - const std::vector& rs, - const std::vector& rv, - const std::vector&, - std::size_t cell){ - return std::make_tuple(pressure[cell], - temperature[cell], - rs[cell], - rv[cell], - 1); - } - }; - /** - * Provide mapping from Region IDs to user-specified collection - * of per-region attributes. - * - * \tparam RegionId Region identifier type. Must be hashable by - * \code std::hash<> \endcode. Typically a built-in integer - * type--e.g., \c int. - * - * \tparam Attributes User-defined type that represents - * collection of attributes that have meaning in a per-region - * aggregate sense. Must be copy-constructible. - */ - template - class RegionAttributes - { - public: - /** - * Expose \c RegionId as a vocabulary type for use in query - * methods. - */ - using RegionID = - typename Select::RegionIDParameter - ::value>::type; - - /** - * Constructor. - * - * \tparam RMap Class type that implements the RegionMapping - * protocol. Typically an instantiation of \code - * Opm::RegionMapping<> \endcode. - * - * \param[in] rmap Specific region mapping that provides - * reverse lookup from regions to cells. - * - * \param[in] attr Pre-constructed initialiser for \c - * Attributes. - */ - template - RegionAttributes(const RMap& rmap, - const Attributes& attr) - { - using VT = typename AttributeMap::value_type; - - for (const auto& r : rmap.activeRegions()) { - auto v = std::unique_ptr(new Value(attr)); - - const auto stat = attr_.insert(VT(r, std::move(v))); - - if (stat.second) { - // New value inserted. - const auto& cells = rmap.cells(r); - - assert (! cells.empty()); - - // Region's representative cell. - stat.first->second->cell_ = cells[0]; - } - } - } - - /** - * Retrieve representative cell in region. - * - * \param[in] reg Specific region. - * - * \return Representative cell in region \p reg. - */ - int cell(const RegionID reg) const - { - return this->find(reg).cell_; - } - - /** - * Request read-only access to region's attributes. - * - * \param[in] reg Specific region. - * - * \return Read-only access to region \p reg's per-region - * attributes. - */ - const Attributes& attributes(const RegionID reg) const - { - return this->find(reg).attr_; - } - - /** - * Request modifiable access to region's attributes. - * - * \param[in] reg Specific region. - * - * \return Read-write access to region \p reg's per-region - * attributes. - */ - Attributes& attributes(const RegionID reg) - { - return this->find(reg).attr_; - } - - private: - /** - * Aggregate per-region attributes along with region's - * representative cell. - */ - struct Value { - Value(const Attributes& attr) - : attr_(attr) - , cell_(-1) - {} - - Attributes attr_; - int cell_; - }; - - using ID = - typename std::remove_reference::type; - - using AttributeMap = - std::unordered_map>; - - AttributeMap attr_; - - /** - * Read-only access to region's properties. - */ - const Value& find(const RegionID reg) const - { - const auto& i = attr_.find(reg); - - if (i == attr_.end()) { - throw std::invalid_argument("Unknown region ID"); - } - - return *i->second; - } - - /** - * Read-write access to region's properties. - */ - Value& find(const RegionID reg) - { - const auto& i = attr_.find(reg); - - if (i == attr_.end()) { - throw std::invalid_argument("Unknown region ID"); - } - - return *i->second; - } - }; - - /** - * Convenience functions for querying presence/absence of - * active phases. - */ - namespace PhaseUsed { - /** - * Active water predicate. - * - * \param[in] pu Active phase object. - * - * \return Whether or not water is an active phase. - */ - inline bool - water(const PhaseUsage& pu) - { - return pu.phase_used[ BlackoilPhases::Aqua ] != 0; - } - - /** - * Active oil predicate. - * - * \param[in] pu Active phase object. - * - * \return Whether or not oil is an active phase. - */ - inline bool - oil(const PhaseUsage& pu) - { - return pu.phase_used[ BlackoilPhases::Liquid ] != 0; - } - - /** - * Active gas predicate. - * - * \param[in] pu Active phase object. - * - * \return Whether or not gas is an active phase. - */ - inline bool - gas(const PhaseUsage& pu) - { - return pu.phase_used[ BlackoilPhases::Vapour ] != 0; - } - } // namespace PhaseUsed - - /** - * Convenience functions for querying numerical IDs - * ("positions") of active phases. - */ - namespace PhasePos { - /** - * Numerical ID of active water phase. - * - * \param[in] pu Active phase object. - * - * \return Non-negative index/position of water if - * active, -1 if not. - */ - inline int - water(const PhaseUsage& pu) - { - int p = -1; - - if (PhaseUsed::water(pu)) { - p = pu.phase_pos[ BlackoilPhases::Aqua ]; - } - - return p; - } - - /** - * Numerical ID of active oil phase. - * - * \param[in] pu Active phase object. - * - * \return Non-negative index/position of oil if - * active, -1 if not. - */ - inline int - oil(const PhaseUsage& pu) - { - int p = -1; - - if (PhaseUsed::oil(pu)) { - p = pu.phase_pos[ BlackoilPhases::Liquid ]; - } - - return p; - } - - /** - * Numerical ID of active gas phase. - * - * \param[in] pu Active phase object. - * - * \return Non-negative index/position of gas if - * active, -1 if not. - */ - inline int - gas(const PhaseUsage& pu) - { - int p = -1; - - if (PhaseUsed::gas(pu)) { - p = pu.phase_pos[ BlackoilPhases::Vapour ]; - } - - return p; - } - } // namespace PhasePos - } // namespace Details - - /** - * Convert component rates at surface conditions to phase - * (voidage) rates at reservoir conditions. - * - * The conversion uses fluid properties evaluated at average - * hydrocarbon pressure in regions or field. - * - * \tparam FluidSystem Fluid system class. Expected to be a BlackOilFluidSystem - * - * \tparam Region Type of a forward region mapping. Expected - * to provide indexed access through \code operator[]() - * \endcode as well as inner types \c value_type, \c - * size_type, and \c const_iterator. Typically \code - * std::vector \endcode. - */ - template - class SurfaceToReservoirVoidage { - public: - /** - * Constructor. - * - * \param[in] region Forward region mapping. Often - * corresponds to the "FIPNUM" mapping of an ECLIPSE input - * deck. - */ - SurfaceToReservoirVoidage(const PhaseUsage& phaseUsage, - const Region& region) - : phaseUsage_(phaseUsage) - , rmap_ (region) - , attr_ (rmap_, Attributes()) - { - } - - /** - * Compute average hydrocarbon pressure and maximum - * dissolution and evaporation at average hydrocarbon - * pressure in all regions in field. - * - * Fluid properties are evaluated at average hydrocarbon - * pressure for purpose of conversion from surface rate to - * reservoir voidage rate. - * - * \param[in] state Dynamic reservoir state. - * \param[in] any The information and communication utilities - * about/of the parallelization. in any parallel - * it wraps a ParallelISTLInformation. Parameter - * is optional. - */ - void - defineState(const BlackoilState& state, - const boost::any& info = boost::any()) - { -#if HAVE_MPI - if( info.type() == typeid(ParallelISTLInformation) ) - { - const auto& ownership = - boost::any_cast(info) - .updateOwnerMask(state.pressure()); - calcAverages(state, info, ownership); - } - else -#endif - { - std::vector dummyOwnership; // not actually used - calcAverages(state, info, dummyOwnership); - } - } - - /** - * Region identifier. - * - * Integral type. - */ - typedef typename RegionMapping::RegionId RegionId; - - /** - * Compute coefficients for surface-to-reservoir voidage - * conversion. - * - * \tparam Input Type representing contiguous collection - * of component rates at surface conditions. Must support - * direct indexing through \code operator[]()\endcode. - * - * \tparam Coeff Type representing contiguous collection - * of surface-to-reservoir conversion coefficients. Must - * support direct indexing through \code operator[]() - * \endcode. - * - * - * \param[in] r Fluid-in-place region of the well - * \param[in] pvtRegionIdx PVT region of the well - * - * - * \param[out] coeff Surface-to-reservoir conversion - * coefficients that can be used to compute total reservoir - * volumes from surface volumes with the formula - * q_{rT} = \sum_p coeff[p] q_{sp}. - * However, individual phase reservoir volumes cannot be calculated from - * these coefficients (i.e. q_{rp} is not equal to coeff[p] q_{sp}) - * since they can depend on more than one surface volume rate when - * we have dissolved gas or vaporized oil. - */ - template - void - calcCoeff(const RegionId r, const int pvtRegionIdx, Coeff& coeff) const - { - const auto& pu = phaseUsage_; - const auto& ra = attr_.attributes(r); - const double p = ra.pressure; - const double T = ra.temperature; - - const int iw = Details::PhasePos::water(pu); - const int io = Details::PhasePos::oil (pu); - const int ig = Details::PhasePos::gas (pu); - - std::fill(& coeff[0], & coeff[0] + phaseUsage_.num_phases, 0.0); - - if (Details::PhaseUsed::water(pu)) { - // q[w]_r = q[w]_s / bw - - const double bw = FluidSystem::waterPvt().inverseFormationVolumeFactor(pvtRegionIdx, T, p); - - coeff[iw] = 1.0 / bw; - } - - // Actual Rs and Rv: - double Rs = ra.rs; - double Rv = ra.rv; - - // Determinant of 'R' matrix - const double detR = 1.0 - (Rs * Rv); - - if (Details::PhaseUsed::oil(pu)) { - // q[o]_r = 1/(bo * (1 - rs*rv)) * (q[o]_s - rv*q[g]_s) - - const double bo = FluidSystem::oilPvt().inverseFormationVolumeFactor(pvtRegionIdx, T, p, Rs); - const double den = bo * detR; - - coeff[io] += 1.0 / den; - - if (Details::PhaseUsed::gas(pu)) { - coeff[ig] -= ra.rv / den; - } - } - - if (Details::PhaseUsed::gas(pu)) { - // q[g]_r = 1/(bg * (1 - rs*rv)) * (q[g]_s - rs*q[o]_s) - - const double bg = FluidSystem::gasPvt().inverseFormationVolumeFactor(pvtRegionIdx, T, p, Rv); - const double den = bg * detR; - - coeff[ig] += 1.0 / den; - - if (Details::PhaseUsed::oil(pu)) { - coeff[io] -= ra.rs / den; - } - } - } - - - /** - * Converting surface volume rates to reservoir voidage rates - * - * \tparam Rates Type representing contiguous collection - * of surface-to-reservoir conversion coefficients. Must - * support direct indexing through \code operator[]() - * \endcode. - * - * - * \param[in] r Fluid-in-place region of the well - * \param[in] pvtRegionIdx PVT region of the well - * \param[in] surface_rates surface voluem rates for - * all active phases - * - * \param[out] voidage_rates reservoir volume rates for - * all active phases - */ - template - void - calcReservoirVoidageRates(const RegionId r, const int pvtRegionIdx, const Rates& surface_rates, - Rates& voidage_rates) const - { - assert(voidage_rates.size() == surface_rates.size()); - - std::fill(voidage_rates.begin(), voidage_rates.end(), 0.0); - - const auto& pu = phaseUsage_; - const auto& ra = attr_.attributes(r); - const double p = ra.pressure; - const double T = ra.temperature; - - const int iw = Details::PhasePos::water(pu); - const int io = Details::PhasePos::oil (pu); - const int ig = Details::PhasePos::gas (pu); - - if (Details::PhaseUsed::water(pu)) { - // q[w]_r = q[w]_s / bw - - const double bw = FluidSystem::waterPvt().inverseFormationVolumeFactor(pvtRegionIdx, T, p); - - voidage_rates[iw] = surface_rates[iw] / bw; - } - - // Use average Rs and Rv: - auto a = ra.rs; - auto b = a; - if (io >= 0 && ig >= 0) { - b = surface_rates[ig]/(surface_rates[io]+1.0e-15); - } - - double Rs = std::min(a, b); - - a = ra.rv; - b = a; - if (io >= 0 && ig >= 0) { - b = surface_rates[io]/(surface_rates[ig]+1.0e-15); - } - - double Rv = std::min(a, b); - - // Determinant of 'R' matrix - const double detR = 1.0 - (Rs * Rv); - - if (Details::PhaseUsed::oil(pu)) { - // q[o]_r = 1/(bo * (1 - rs*rv)) * (q[o]_s - rv*q[g]_s) - - const double bo = FluidSystem::oilPvt().inverseFormationVolumeFactor(pvtRegionIdx, T, p, Rs); - const double den = bo * detR; - - voidage_rates[io] = surface_rates[io]; - - if (Details::PhaseUsed::gas(pu)) { - voidage_rates[io] -= Rv * surface_rates[ig]; - } - - voidage_rates[io] /= den; - } - - if (Details::PhaseUsed::gas(pu)) { - // q[g]_r = 1/(bg * (1 - rs*rv)) * (q[g]_s - rs*q[o]_s) - - const double bg = FluidSystem::gasPvt().inverseFormationVolumeFactor(pvtRegionIdx, T, p, Rv); - const double den = bg * detR; - - voidage_rates[ig] = surface_rates[ig]; - - if (Details::PhaseUsed::oil(pu)) { - voidage_rates[ig] -= Rs * surface_rates[io]; - } - - voidage_rates[ig] /= den; - } - } - - - /** - * Compute coefficients for surface-to-reservoir voidage - * conversion for solvent. - * - * - * \param[in] r Fluid-in-place region of the well - * \param[in] pvtRegionIdx PVT region of the well - * - * - * \param[out] double Surface-to-reservoir conversion - * coefficients for solvent. - */ - template - void - calcCoeffSolvent(const RegionId r, const int pvtRegionIdx, double& coeff) const - { - const auto& ra = attr_.attributes(r); - const double p = ra.pressure; - const double T = ra.temperature; - const auto& solventPvt = SolventModule::solventPvt(); - const double bs = solventPvt.inverseFormationVolumeFactor(pvtRegionIdx, T, p); - coeff = 1.0 / bs; - } - - private: - /** - * Fluid property object. - */ - const PhaseUsage phaseUsage_; - - /** - * "Fluid-in-place" region mapping (forward and reverse). - */ - const RegionMapping rmap_; - - /** - * Derived property attributes for each active region. - */ - struct Attributes { - Attributes() - : pressure (0.0) - , temperature(0.0) - , rs(0.0) - , rv(0.0) - , pv(0.0) - {} - - double pressure; - double temperature; - double rs; - double rv; - double pv; - }; - - Details::RegionAttributes attr_; - - - /** - * Compute average hydrocarbon pressure and temperatures in all - * regions. - * - * \param[in] state Dynamic reservoir state. - * \param[in] info The information and communication utilities - * about/of the parallelization. - * \param[in] ownership In a parallel run this is vector containing - * 1 for every owned unknown, zero otherwise. - * Not used in a sequential run. - * \tparam is_parallel True if the run is parallel. In this case - * info has to contain a ParallelISTLInformation - * object. - */ - template - void - calcAverages(const BlackoilState& state, const boost::any& info, - const std::vector& ownerShip) - { - const auto& press = state.pressure(); - const auto& temp = state.temperature(); - const auto& Rv = state.rv(); - const auto& Rs = state.gasoilratio(); - - for (const auto& reg : rmap_.activeRegions()) { - auto& ra = attr_.attributes(reg); - auto& p = ra.pressure; - auto& T = ra.temperature; - auto& rs = ra.rs; - auto& rv = ra.rv; - - std::size_t n = 0; - p = T = 0.0; - for (const auto& cell : rmap_.cells(reg)) { - auto increment = Details:: - AverageIncrementCalculator()(press, temp, Rs, Rv, - ownerShip, - cell); - p += std::get<0>(increment); - T += std::get<1>(increment); - rs += std::get<2>(increment); - rv += std::get<3>(increment); - n += std::get<4>(increment); - } - std::size_t global_n = n; - double global_p = p; - double global_T = T; - double global_rs = rs; - double global_rv = rv; -#if HAVE_MPI - if ( is_parallel ) - { - const auto& real_info = boost::any_cast(info); - global_n = real_info.communicator().sum(n); - global_p = real_info.communicator().sum(p); - global_rs = real_info.communicator().sum(rs); - global_rv = real_info.communicator().sum(rv); - global_T = real_info.communicator().sum(T); - } -#endif - p = global_p / global_n; - rs = global_rs / global_n; - rv = global_rv / global_n; - T = global_T / global_n; - } - } - - - - }; - } // namespace RateConverter -} // namespace Opm - -#endif /* OPM_RATECONVERTER_HPP_HEADER_INCLUDED */ diff --git a/opm/core/props/BlackoilPropertiesInterface.hpp b/opm/core/props/BlackoilPropertiesInterface.hpp deleted file mode 100644 index 9ce61ac3d..000000000 --- a/opm/core/props/BlackoilPropertiesInterface.hpp +++ /dev/null @@ -1,184 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - 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 3 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 . -*/ - -#ifndef OPM_BLACKOILPROPERTIESINTERFACE_HEADER_INCLUDED -#define OPM_BLACKOILPROPERTIESINTERFACE_HEADER_INCLUDED - -namespace Opm -{ - - struct PhaseUsage; - - /// Abstract base class for blackoil fluid and reservoir properties. - /// Supports variable number of spatial dimensions, called D. - /// Supports variable number of phases, but assumes that - /// the number of components is equal to the number of phases, called P. - /// In general, when arguments call for n values of some vector or - /// matrix property, such as saturation, they shall always be - /// ordered cellwise: - /// [s^1_0 s^2_0 s^3_0 s^1_1 s^2_2 ... ] - /// in which s^i_j denotes saturation of phase i in cell j. - class BlackoilPropertiesInterface - { - public: - virtual ~BlackoilPropertiesInterface() {} - - // ---- Rock interface ---- - - /// \return D, the number of spatial dimensions. - virtual int numDimensions() const = 0; - - /// \return N, the number of cells. - virtual int numCells() const = 0; - - /// Return an array containing the PVT table index for each - /// grid cell - virtual const int* cellPvtRegionIndex() const = 0; - - /// \return Array of N porosity values. - virtual const double* porosity() const = 0; - - /// \return Array of ND^2 permeability values. - /// The D^2 permeability values for a cell are organized as a matrix, - /// which is symmetric (so ordering does not matter). - virtual const double* permeability() const = 0; - - - // ---- Fluid interface ---- - - /// \return P, the number of phases (also the number of components). - virtual int numPhases() const = 0; - - /// \return Object describing the active phases. - virtual PhaseUsage phaseUsage() const = 0; - - /// \param[in] n Number of data points. - /// \param[in] p Array of n pressure values. - /// \param[in] T Array of n temperature values. - /// \param[in] z Array of nP surface volume values. - /// \param[in] cells Array of n cell indices to be associated with the p and z values. - /// \param[out] mu Array of nP viscosity values, array must be valid before calling. - /// \param[out] dmudp If non-null: array of nP viscosity derivative values, - /// array must be valid before calling. - virtual void viscosity(const int n, - const double* p, - const double* T, - const double* z, - const int* cells, - double* mu, - double* dmudp) const = 0; - - /// \param[in] n Number of data points. - /// \param[in] p Array of n pressure values. - /// \param[in] T Array of n temperature values. - /// \param[in] z Array of nP surface volume values. - /// \param[in] cells Array of n cell indices to be associated with the p and z values. - /// \param[out] A Array of nP^2 values, array must be valid before calling. - /// The P^2 values for a cell give the matrix A = RB^{-1} which - /// relates z to u by z = Au. The matrices are output in Fortran order. - /// \param[out] dAdp If non-null: array of nP^2 matrix derivative values, - /// array must be valid before calling. The matrices are output - /// in Fortran order. - virtual void matrix(const int n, - const double* p, - const double* T, - const double* z, - const int* cells, - double* A, - double* dAdp) const = 0; - - - /// Densities of stock components at reservoir conditions. - /// \param[in] n Number of data points. - /// \param[in] A Array of nP^2 values, where the P^2 values for a cell give the - /// matrix A = RB^{-1} which relates z to u by z = Au. The matrices - /// are assumed to be in Fortran order, and are typically the result - /// of a call to the method matrix(). - /// \param[in] cells The index of the grid cell of each data point. - /// \param[out] rho Array of nP density values, array must be valid before calling. - virtual void density(const int n, - const double* A, - const int* cells, - double* rho) const = 0; - - /// Densities of stock components at surface conditions. - /// \return Array of P density values. - virtual const double* surfaceDensity(int regionIdx = 0) const = 0; - - /// \param[in] n Number of data points. - /// \param[in] s Array of nP saturation values. - /// \param[in] cells Array of n cell indices to be associated with the s values. - /// \param[out] kr Array of nP relperm values, array must be valid before calling. - /// \param[out] dkrds If non-null: array of nP^2 relperm derivative values, - /// array must be valid before calling. - /// The P^2 derivative matrix is - /// m_{ij} = \frac{dkr_i}{ds^j}, - /// and is output in Fortran order (m_00 m_10 m_20 m_01 ...) - virtual void relperm(const int n, - const double* s, - const int* cells, - double* kr, - double* dkrds) const = 0; - - - /// \param[in] n Number of data points. - /// \param[in] s Array of nP saturation values. - /// \param[in] cells Array of n cell indices to be associated with the s values. - /// \param[out] pc Array of nP capillary pressure values, array must be valid before calling. - /// \param[out] dpcds If non-null: array of nP^2 derivative values, - /// array must be valid before calling. - /// The P^2 derivative matrix is - /// m_{ij} = \frac{dpc_i}{ds^j}, - /// and is output in Fortran order (m_00 m_10 m_20 m_01 ...) - virtual void capPress(const int n, - const double* s, - const int* cells, - double* pc, - double* dpcds) const = 0; - - - /// Obtain the range of allowable saturation values. - /// In cell cells[i], saturation of phase p is allowed to be - /// in the interval [smin[i*P + p], smax[i*P + p]]. - /// \param[in] n Number of data points. - /// \param[in] cells Array of n cell indices. - /// \param[out] smin Array of nP minimum s values, array must be valid before calling. - /// \param[out] smax Array of nP maximum s values, array must be valid before calling. - virtual void satRange(const int n, - const int* cells, - double* smin, - double* smax) const = 0; - - - /// Update capillary pressure scaling according to pressure diff. and initial water saturation. - /// \param[in] cell Cell index. - /// \param[in] pcow P_oil - P_water. - /// \param[in/out] swat Water saturation. / Possibly modified Water saturation. - virtual void swatInitScaling(const int cell, - const double pcow, - double & swat) = 0; - - }; - - - -} // namespace Opm - - -#endif // OPM_BLACKOILPROPERTIESINTERFACE_HEADER_INCLUDED diff --git a/opm/core/simulator/BlackoilState.cpp b/opm/core/simulator/BlackoilState.cpp deleted file mode 100644 index 599a7cce4..000000000 --- a/opm/core/simulator/BlackoilState.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "BlackoilState.hpp" -#include -#include -#include -#include - - -using namespace Opm; - - -const std::string BlackoilState::GASOILRATIO = "GASOILRATIO"; -const std::string BlackoilState::RV = "RV"; -const std::string BlackoilState::SURFACEVOL = "SURFACEVOL"; -const std::string BlackoilState::SSOL = "SSOL"; -const std::string BlackoilState::POLYMER = "POLYMER"; - - -BlackoilState::BlackoilState( size_t num_cells , size_t num_faces , size_t num_phases) - : SimulationDataContainer( num_cells , num_faces , num_phases) -{ - registerCellData( GASOILRATIO , 1 ); - registerCellData( RV, 1 ); - registerCellData( SURFACEVOL, num_phases ); - registerCellData( SSOL , 1 ); - registerCellData( POLYMER , 1 ); - setBlackoilStateReferencePointers(); -} - -BlackoilState::BlackoilState( const BlackoilState& other ) - : SimulationDataContainer(other), - hydrocarbonstate_(other.hydroCarbonState()) -{ - setBlackoilStateReferencePointers(); - -} - -BlackoilState& BlackoilState::operator=( const BlackoilState& other ) -{ - SimulationDataContainer::operator=(other); - setBlackoilStateReferencePointers(); - hydrocarbonstate_ = other.hydroCarbonState(); - return *this; -} - -void BlackoilState::setBlackoilStateReferencePointers() -{ - // This sets the reference pointers for the fast - // accessors, the fields must have been created first. - gasoilratio_ref_ = &getCellData(GASOILRATIO); - rv_ref_ = &getCellData(RV); - surfacevol_ref_ = &getCellData(SURFACEVOL); -} diff --git a/opm/core/simulator/BlackoilState.hpp b/opm/core/simulator/BlackoilState.hpp deleted file mode 100644 index e70f6c08e..000000000 --- a/opm/core/simulator/BlackoilState.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - Copyright 2015 IRIS AS - - 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 3 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 . -*/ - -#ifndef OPM_BLACKOILSTATE_HEADER_INCLUDED -#define OPM_BLACKOILSTATE_HEADER_INCLUDED - -#include - -#include -#include -#include - -namespace Opm -{ - - enum HydroCarbonState { - GasOnly = 0, - GasAndOil = 1, - OilOnly = 2 - }; - - /// Simulator state for a blackoil simulator. - class BlackoilState : public SimulationDataContainer - { - public: - static const std::string GASOILRATIO; - static const std::string RV; - static const std::string SURFACEVOL; - static const std::string SSOL; - static const std::string POLYMER; - - /// Main constructor setting the sizes for the contained data - /// types. - /// \param num_cells number of elements in cell data vectors - /// \param num_faces number of elements in face data vectors - /// \param num_phases number of phases, the number of components - /// in any data vector must equal 1 or this - /// number (this behaviour and argument is deprecated). - BlackoilState(size_t num_cells, size_t num_faces, size_t num_phases); - - /// Copy constructor. - /// Must be defined explicitly because class contains non-value objects - /// (the reference pointers rv_ref_ etc.) that should not simply - /// be copied. - BlackoilState(const BlackoilState& other); - - /// Copy assignment operator. - /// Must be defined explicitly because class contains non-value objects - /// (the reference pointers rv_ref_ etc.) that should not simply - /// be copied. - BlackoilState& operator=(const BlackoilState& other); - - std::vector& surfacevol () { return *surfacevol_ref_; } - std::vector& gasoilratio () { return *gasoilratio_ref_; } - std::vector& rv () { return *rv_ref_; } - std::vector& hydroCarbonState() { return hydrocarbonstate_; } - - const std::vector& surfacevol () const { return *surfacevol_ref_; } - const std::vector& gasoilratio () const { return *gasoilratio_ref_; } - const std::vector& rv () const { return *rv_ref_; } - const std::vector& hydroCarbonState() const { return hydrocarbonstate_; } - - private: - void setBlackoilStateReferencePointers(); - std::vector* surfacevol_ref_; - std::vector* gasoilratio_ref_; - std::vector* rv_ref_; - - // A vector storing the hydro carbon state. - std::vector hydrocarbonstate_; - - - }; -} // namespace Opm - - -#endif // OPM_BLACKOILSTATE_HEADER_INCLUDED diff --git a/opm/core/simulator/BlackoilStateToFluidState.hpp b/opm/core/simulator/BlackoilStateToFluidState.hpp deleted file mode 100644 index 470c5ef7a..000000000 --- a/opm/core/simulator/BlackoilStateToFluidState.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - Copyright 2015 Andreas Lauser - - 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 3 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 . -*/ - -#ifndef OPM_BLACKOIL_STATE_TO_FLUID_STATE_HEADER_INCLUDED -#define OPM_BLACKOIL_STATE_TO_FLUID_STATE_HEADER_INCLUDED - -#include - -namespace Opm -{ - -/*! - * \brief This is an light weight "impedance adaption" class with a well defined API for - * saturation and PVT functions. - * - * It uses a stripped down version of opm-material's FluidState API and takes an - * Opm::BlackoilState plus a cell index. - * - * Note that this class requires that is underlying BlackoilState must valid for at least - * as long as an object of BlackoilStateToFluidState is used. - */ -class BlackoilStateToFluidState -{ -public: - typedef double Scalar; - - enum { numPhases = 3 }; - enum { numComponents = 3 }; - - /*! - * \brief Create a BlackoilState to Fluid state wrapper object. - * - * Note that this class requires that is underlying BlackoilState must valid for at least - * as long as an object of BlackoilStateToFluidState is used. - */ - BlackoilStateToFluidState(const BlackoilState& blackoilState) - : blackoilState_(blackoilState) - { - if (blackoilState_.numPhases() != numPhases) { - OPM_THROW(std::runtime_error, - "Only " << numPhases << " are supported, but the deck specifies " << blackoilState_.numPhases()); - } - } - - /*! - * \brief Sets the index of the currently used cell. - * - * After calling this, the values returned by the other methods are specific for this - * cell. - */ - void setCurrentCellIndex(unsigned cellIdx) - { cellIdx_ = cellIdx; } - - /*! - * \brief Returns the saturation of a phase for the current cell index. - */ - Scalar saturation(int phaseIdx) const - { return blackoilState_.saturation()[numPhases*cellIdx_ + phaseIdx]; } - - /*! - * \brief Returns the temperature [K] of a phase for the current cell index. - */ - Scalar temperature(int phaseIdx) const - { return blackoilState_.temperature()[cellIdx_]; } - - // TODO (?) pressure, composition, etc - -private: - size_t numCells() const - { return blackoilState_.pressure().size(); } - - const BlackoilState& blackoilState_; - unsigned cellIdx_; -} - -} // namespace Opm - -#endif // OPM_SIMULATORTIMER_HEADER_INCLUDED diff --git a/opm/core/utility/initHydroCarbonState.hpp b/opm/core/utility/initHydroCarbonState.hpp deleted file mode 100644 index f35d8e792..000000000 --- a/opm/core/utility/initHydroCarbonState.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef INITHYDROCARBONSTATE_HPP -#define INITHYDROCARBONSTATE_HPP - -#include "opm/core/simulator/BlackoilState.hpp" - -namespace Opm -{ - -inline void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int num_cells, const bool has_disgas, const bool has_vapoil) { - enum { Oil = BlackoilPhases::Liquid, Gas = BlackoilPhases::Vapour, Water = BlackoilPhases::Aqua }; - // hydrocarbonstate is only used when gas and oil is present - assert(pu.phase_used[Oil]); - std::vector& hydroCarbonState = state.hydroCarbonState(); - hydroCarbonState.resize(num_cells); - if (!pu.phase_used[Gas]) { - // hydroCarbonState should only be used when oil and gas is present. Return OilOnly to avoid potential trouble. - std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::OilOnly); - return; - } - const int np = pu.num_phases; - std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::GasAndOil); - - // set hydrocarbon state - const double epsilon = std::sqrt(std::numeric_limits::epsilon()); - const std::vector& saturation = state.saturation(); - for (int c = 0; c < num_cells; ++c) { - if (pu.phase_used[Water]) { - if ( saturation[c*np + pu.phase_pos[ Water ]] > (1.0 - epsilon)) { - continue; // cases (almost) filled with water is treated as GasAndOil case; - } - } - if ( saturation[c*np + pu.phase_pos[ Gas ]] == 0.0 && has_disgas) { - hydroCarbonState[c] = HydroCarbonState::OilOnly; - continue; - } - if ( saturation[c*np + pu.phase_pos[ Oil ]] == 0.0 && has_vapoil) { - hydroCarbonState[c] = HydroCarbonState::GasOnly; - } - } -} - - -} // namespace Opm -#endif // INITHYDROCARBONSTATE_HPP diff --git a/opm/polymer/PolymerBlackoilState.cpp b/opm/polymer/PolymerBlackoilState.cpp deleted file mode 100644 index e89d16c29..000000000 --- a/opm/polymer/PolymerBlackoilState.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - 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 3 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 . -*/ - - -#include - -#include - -namespace Opm -{ - const std::string PolymerBlackoilState::CONCENTRATION = "CONCENTRATION"; - const std::string PolymerBlackoilState::CMAX = "CMAX"; - - PolymerBlackoilState::PolymerBlackoilState(int number_of_cells, int number_of_faces, int num_phases) : - BlackoilState( number_of_cells , number_of_faces, num_phases) - { - registerCellData(CONCENTRATION , 1 , 0 ); - registerCellData(CMAX , 1 , 0 ); - } - - -} // namespace Opm - - - - diff --git a/opm/polymer/PolymerBlackoilState.hpp b/opm/polymer/PolymerBlackoilState.hpp deleted file mode 100644 index 597de8869..000000000 --- a/opm/polymer/PolymerBlackoilState.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - 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 3 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 . -*/ - -#ifndef OPM_POLYMERBLACKOILSTATE_HEADER_INCLUDED -#define OPM_POLYMERBLACKOILSTATE_HEADER_INCLUDED - - -#include -#include -#include - -namespace Opm -{ - - /// Simulator state for a compressible two-phase simulator with polymer. - /// We use the Blackoil state parameters. - class PolymerBlackoilState : public BlackoilState - { - public: - static const std::string CONCENTRATION; - static const std::string CMAX; - - PolymerBlackoilState(int number_of_cells, int number_of_faces, int num_phases); - }; - -} // namespace Opm - - - - -#endif // OPM_POLYMERBLACKOILSTATE_HEADER_INCLUDED diff --git a/tests/testBlackoilState1.DATA b/tests/testBlackoilState1.DATA deleted file mode 100644 index 4220b5b45..000000000 --- a/tests/testBlackoilState1.DATA +++ /dev/null @@ -1,18 +0,0 @@ -DIMENS -10 10 10 / - -DXV -10*10 / - -DYV -10*10 / - -DZV -10*10 / - -ACTNUM - 1 998*2 3 / - - -DEPTHZ -121*2000 / diff --git a/tests/testBlackoilState2.DATA b/tests/testBlackoilState2.DATA deleted file mode 100644 index 64af44f01..000000000 --- a/tests/testBlackoilState2.DATA +++ /dev/null @@ -1,14 +0,0 @@ -DIMENS -9 10 10 / - -DXV -9*10 / - -DYV -10*10 / - -DZV -10*10 / - -DEPTHZ -110*2000 / diff --git a/tests/test_blackoilstate.cpp b/tests/test_blackoilstate.cpp deleted file mode 100644 index ec49a520a..000000000 --- a/tests/test_blackoilstate.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include - -#include -#include -#include - -#include -#include -#include - -#define NVERBOSE // to suppress our messages when throwing -#define BOOST_TEST_MODULE BlackoilStateTest -#define BOOST_TEST_MAIN -#include -#include -#include -#include -#include -#include - -#include "opm/grid/GridManager.hpp" -#include "opm/core/simulator/BlackoilState.hpp" - -using namespace Opm; -using namespace std; - - -// ACTNUM 1 998*2 3 -std::vector get_testBlackoilStateActnum() { - std::vector actnum(10 * 10 * 10, 2); - actnum.front() = 1; - actnum.back() = 3; - return actnum; -} - -BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { - const string filename1 = "testBlackoilState1.DATA"; - const string filename2 = "testBlackoilState2.DATA"; - - const auto es1 = Opm::Parser::parse(filename1); - auto eg1 = es1.getInputGrid(); - std::vector actnum = get_testBlackoilStateActnum(); - eg1.resetACTNUM(actnum.data()); - - const auto es2 = Opm::Parser::parse(filename2); - const auto& eg2 = es2.getInputGrid(); - - GridManager vanguard1(eg1); - const UnstructuredGrid& grid1 = *vanguard1.c_grid(); - - GridManager vanguard2(eg2); - const UnstructuredGrid& grid2 = *vanguard2.c_grid(); - - BlackoilState state1( UgGridHelpers::numCells( grid1 ) , UgGridHelpers::numFaces( grid1 ) , 3); - BlackoilState state2( UgGridHelpers::numCells( grid2 ) , UgGridHelpers::numFaces( grid2 ) , 3); - - BOOST_CHECK( ! state1.equal(state2) ); -} - - - - -BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { - - const string filename = "testBlackoilState1.DATA"; - - const auto es = Opm::Parser::parse(filename); - auto eg = es.getInputGrid(); - - std::vector actnum = get_testBlackoilStateActnum(); - eg.resetACTNUM(actnum.data()); - - GridManager vanguard(eg); - const UnstructuredGrid& grid = *vanguard.c_grid(); - - BlackoilState state1( UgGridHelpers::numCells( grid ) , UgGridHelpers::numFaces( grid ) , 3); - BlackoilState state2( UgGridHelpers::numCells( grid ) , UgGridHelpers::numFaces( grid ) , 3); - - - BOOST_CHECK( state1.equal(state2) ); - { - std::vector& p1 = state1.pressure(); - std::vector& p2 = state2.pressure(); - p1[0] = p1[0] * 2 + 1; - - BOOST_CHECK( ! state1.equal(state2) ); - p1[0] = p2[0]; - BOOST_CHECK( state1.equal(state2) ); - } - { - std::vector& gor1 = state1.gasoilratio(); - std::vector& gor2 = state2.gasoilratio(); - gor1[0] = gor1[0] * 2 + 1; - - BOOST_CHECK( ! state1.equal(state2) ); - gor1[0] = gor2[0]; - BOOST_CHECK( state1.equal(state2) ); - } - { - std::vector& p1 = state1.facepressure(); - std::vector& p2 = state2.facepressure(); - p1[0] = p1[0] * 2 + 1; - - BOOST_CHECK( ! state1.equal(state2) ); - p1[0] = p2[0]; - BOOST_CHECK( state1.equal(state2) ); - } - - { - std::vector& f1 = state1.faceflux(); - std::vector& f2 = state2.faceflux(); - if (f1.size() > 0 ) { - f1[0] = f1[0] * 2 + 1; - - BOOST_CHECK( ! state1.equal(state2) ); - f1[0] = f2[0]; - BOOST_CHECK( state1.equal(state2) ); - } - } - { - std::vector& sv1 = state1.surfacevol(); - std::vector& sv2 = state2.surfacevol(); - if (sv1.size() > 0) { - sv1[0] = sv1[0] * 2 + 1; - - BOOST_CHECK( ! state1.equal(state2) ); - sv1[0] = sv2[0]; - BOOST_CHECK( state1.equal(state2) ); - } - } - { - std::vector& sat1 = state1.saturation(); - std::vector& sat2 = state2.saturation(); - sat1[0] = sat1[0] * 2 + 1; - - BOOST_CHECK( ! state1.equal(state2) ); - sat1[0] = sat2[0]; - BOOST_CHECK( state1.equal(state2) ); - } -}