Loading...
Searching...
No Matches
ParallelEclipseState.hpp
/*
Copyright 2019 Equinor 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 <http://www.gnu.org/licenses/>.
*/
#ifndef PARALLEL_ECLIPSE_STATE_HPP
#define PARALLEL_ECLIPSE_STATE_HPP
#include <dune/common/version.hh>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/Grid/TranCalculator.hpp>
#include <dune/common/parallel/mpihelper.hh>
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <functional>
namespace Opm {
class ParallelFieldPropsManager : public FieldPropsManager {
public:
friend class ParallelEclipseState;
template<class Grid>
friend class PropsDataHandle;
explicit ParallelFieldPropsManager(FieldPropsManager& manager);
ParallelFieldPropsManager(FieldPropsManager& manager, Parallel::Communication comm);
std::vector<int> actnum() const override;
void reset_actnum(const std::vector<int>& actnum) override;
std::vector<double> porv(bool global = false) const override;
const std::vector<int>& get_int(const std::string& keyword) const override;
const std::vector<double>& get_double(const std::string& keyword) const override;
std::vector<int> get_global_int(const std::string& keyword) const override;
std::vector<double> get_global_double(const std::string& keyword) const override;
bool has_int(const std::string& keyword) const override;
bool has_double(const std::string& keyword) const override;
std::vector<std::string> fip_regions() const override;
template<class T>
void resetCartesianMapper(const T* mapper)
{
// Note: mapper would usually be a CartesianIndexMapper. However, to support also
// the case of a distributed level zero grid in a CpGrid with LGRs, mapper will be
// Opm::LevelCartesianIndexMapper. This change allows access to the Cartesian indices
// of the distributed level zero grid, where the field properties are given - for now.
// In case of supporting LGR field properties, this need to be adapted, to access instead
// each local/level Cartesian index set.
m_activeSize = [mapper]() { return mapper->compressedSize(/*level = */ 0); };
m_local2Global = [mapper](int localIdx) { return mapper->cartesianIndex(localIdx, /* level = */ 0); };
}
bool tran_active(const std::string& keyword) const override;
void apply_tran(const std::string& keyword, std::vector<double>& trans) const override;
void copyTran(const FieldPropsManager& from)
{
m_tran = from.getTran();
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_tran);
}
protected:
std::map<std::string, Fieldprops::FieldData<int>> m_intProps;
std::map<std::string, Fieldprops::FieldData<double>> m_doubleProps;
FieldPropsManager& m_manager;
Parallel::Communication m_comm;
std::function<int(void)> m_activeSize;
std::function<int(const int)> m_local2Global;
std::unordered_map<std::string, Fieldprops::TranCalculator> m_tran;
};
class ParallelEclipseState : public EclipseState {
template<class Grid>
friend class PropsDataHandle;
public:
ParallelEclipseState(Parallel::Communication comm);
ParallelEclipseState(const Deck& deck);
ParallelEclipseState(const Deck& deck, Parallel::Communication comm);
void switchToGlobalProps();
void switchToDistributedProps();
const FieldPropsManager& fieldProps() const override;
const FieldPropsManager& globalFieldProps() const override;
void computeFipRegionStatistics() override;
const EclipseGrid& getInputGrid() const override;
template<class T>
void resetCartesianMapper(const T* mapper)
{
m_fieldProps.resetCartesianMapper(mapper);
}
private:
bool m_parProps = false;
ParallelFieldPropsManager m_fieldProps;
Parallel::Communication m_comm;
};
} // end namespace Opm
#endif // PARALLEL_ECLIPSE_STATE_HPP
Opm::ParallelEclipseState::switchToGlobalProps
void switchToGlobalProps()
Switch to global field properties.
Definition ParallelEclipseState.cpp:310
Opm::ParallelEclipseState::getInputGrid
const EclipseGrid & getInputGrid() const override
Returns a const ref to the eclipse grid.
Definition ParallelEclipseState.cpp:302
Opm::ParallelEclipseState::fieldProps
const FieldPropsManager & fieldProps() const override
Returns a const ref to current field properties.
Definition ParallelEclipseState.cpp:268
Opm::ParallelEclipseState::ParallelEclipseState
ParallelEclipseState(Parallel::Communication comm)
Default constructor.
Definition ParallelEclipseState.cpp:248
Opm::ParallelEclipseState::computeFipRegionStatistics
void computeFipRegionStatistics() override
Compute basic descriptive statistics about all FIP region sets.
Definition ParallelEclipseState.cpp:288
Opm::ParallelEclipseState::PropsDataHandle
friend class PropsDataHandle
Friend to set up props.
Definition ParallelEclipseState.hpp:156
Opm::ParallelEclipseState::switchToDistributedProps
void switchToDistributedProps()
Switch to distributed field properies.
Definition ParallelEclipseState.cpp:316
Opm::ParallelEclipseState::globalFieldProps
const FieldPropsManager & globalFieldProps() const override
Returns a const ref to global field properties.
Definition ParallelEclipseState.cpp:280
Opm::ParallelEclipseState::resetCartesianMapper
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition ParallelEclipseState.hpp:205
Opm::ParallelFieldPropsManager
Parallel frontend to the field properties.
Definition ParallelEclipseState.hpp:42
Opm::ParallelFieldPropsManager::resetCartesianMapper
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition ParallelEclipseState.hpp:104
Opm::ParallelFieldPropsManager::ParallelEclipseState
friend class ParallelEclipseState
Friend so props can be setup.
Definition ParallelEclipseState.hpp:44
Opm::ParallelFieldPropsManager::m_tran
std::unordered_map< std::string, Fieldprops::TranCalculator > m_tran
calculators map
Definition ParallelEclipseState.hpp:138
Opm::ParallelFieldPropsManager::m_intProps
std::map< std::string, Fieldprops::FieldData< int > > m_intProps
Map of integer properties in process-local compressed indices.
Definition ParallelEclipseState.hpp:132
Opm::ParallelFieldPropsManager::has_double
bool has_double(const std::string &keyword) const override
Check if a double property is available.
Definition ParallelEclipseState.cpp:228
Opm::ParallelFieldPropsManager::fip_regions
std::vector< std::string > fip_regions() const override
Returns a list of registered FIP regions.
Definition ParallelEclipseState.cpp:234
Opm::ParallelFieldPropsManager::actnum
std::vector< int > actnum() const override
Returns actnum vector.
Definition ParallelEclipseState.cpp:60
Opm::ParallelFieldPropsManager::porv
std::vector< double > porv(bool global=false) const override
Returns the pore volume vector.
Definition ParallelEclipseState.cpp:77
Opm::ParallelFieldPropsManager::get_global_double
std::vector< double > get_global_double(const std::string &keyword) const override
Returns a double property using global cartesian indices.
Definition ParallelEclipseState.cpp:179
Opm::ParallelFieldPropsManager::PropsDataHandle
friend class PropsDataHandle
Friend to set up props.
Definition ParallelEclipseState.hpp:47
Opm::ParallelFieldPropsManager::ParallelFieldPropsManager
ParallelFieldPropsManager(FieldPropsManager &manager)
Constructor.
Definition ParallelEclipseState.cpp:46
Opm::ParallelFieldPropsManager::has_int
bool has_int(const std::string &keyword) const override
Check if an integer property is available.
Definition ParallelEclipseState.cpp:222
Opm::ParallelFieldPropsManager::m_local2Global
std::function< int(const int)> m_local2Global
mapping from local to global cartesian indices
Definition ParallelEclipseState.hpp:137
Opm::ParallelFieldPropsManager::get_global_int
std::vector< int > get_global_int(const std::string &keyword) const override
Returns an int property using global cartesian indices.
Definition ParallelEclipseState.cpp:121
Opm::ParallelFieldPropsManager::get_double
const std::vector< double > & get_double(const std::string &keyword) const override
Returns a double property using compressed indices.
Definition ParallelEclipseState.cpp:157
Opm::ParallelFieldPropsManager::reset_actnum
void reset_actnum(const std::vector< int > &actnum) override
Reset the actnum vector.
Definition ParallelEclipseState.cpp:69
Opm::ParallelFieldPropsManager::m_manager
FieldPropsManager & m_manager
Underlying field property manager (only used on root process).
Definition ParallelEclipseState.hpp:134
Opm::ParallelFieldPropsManager::m_doubleProps
std::map< std::string, Fieldprops::FieldData< double > > m_doubleProps
Map of double properties in process-local compressed indices.
Definition ParallelEclipseState.hpp:133
Opm::ParallelFieldPropsManager::m_comm
Parallel::Communication m_comm
Collective communication handler.
Definition ParallelEclipseState.hpp:135
Opm::ParallelFieldPropsManager::get_int
const std::vector< int > & get_int(const std::string &keyword) const override
Returns an int property using compressed indices.
Definition ParallelEclipseState.cpp:99
Opm::ParallelFieldPropsManager::m_activeSize
std::function< int(void)> m_activeSize
active size function of the grid
Definition ParallelEclipseState.hpp:136
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43