Use FieldData in ParallelEclipseState.

We will need the values_status for the TranCalculator in parallel.
This commit is contained in:
Markus Blatt
2020-09-17 12:12:14 +02:00
parent d5bc4d539c
commit 9b997aea8c
3 changed files with 50 additions and 22 deletions

View File

@@ -68,17 +68,18 @@ const std::vector<int>& ParallelFieldPropsManager::get_int(const std::string& ke
// Some of the keywords might be defaulted. // Some of the keywords might be defaulted.
// We will let rank 0 create them and distribute them using get_global_int // We will let rank 0 create them and distribute them using get_global_int
auto data = get_global_int(keyword); auto data = get_global_int(keyword);
auto& local_data = const_cast<std::map<std::string, std::vector<int>>&>(m_intProps)[keyword]; auto& local_data = const_cast<std::map<std::string, FieldData<int>>&>(m_intProps)[keyword];
local_data.resize(m_activeSize()); local_data.data.resize(m_activeSize());
local_data.value_status.resize(m_activeSize());
for (int i = 0; i < m_activeSize(); ++i) for (int i = 0; i < m_activeSize(); ++i)
{ {
local_data[i] = data[m_local2Global(i)]; local_data.data[i] = data[m_local2Global(i)];
} }
return local_data; return local_data.data;
} }
return it->second; return it->second.data;
} }
std::vector<int> ParallelFieldPropsManager::get_global_int(const std::string& keyword) const std::vector<int> ParallelFieldPropsManager::get_global_int(const std::string& keyword) const
@@ -121,16 +122,17 @@ const std::vector<double>& ParallelFieldPropsManager::get_double(const std::stri
// Some of the keywords might be defaulted. // Some of the keywords might be defaulted.
// We will let rank 0 create them and distribute them using get_global_int // We will let rank 0 create them and distribute them using get_global_int
auto data = get_global_double(keyword); auto data = get_global_double(keyword);
auto& local_data = const_cast<std::map<std::string, std::vector<double>>&>(m_doubleProps)[keyword]; auto& local_data = const_cast<std::map<std::string, FieldData<double>>&>(m_doubleProps)[keyword];
local_data.resize(m_activeSize()); local_data.data.resize(m_activeSize());
local_data.value_status.resize(m_activeSize());
for (int i = 0; i < m_activeSize(); ++i) for (int i = 0; i < m_activeSize(); ++i)
{ {
local_data[i] = data[m_local2Global(i)]; local_data.data[i] = data[m_local2Global(i)];
} }
return local_data; return local_data.data;
} }
return it->second; return it->second.data;
} }

View File

@@ -96,8 +96,8 @@ public:
std::placeholders::_1); std::placeholders::_1);
} }
protected: protected:
std::map<std::string, std::vector<int>> m_intProps; //!< Map of integer properties in process-local compressed indices. std::map<std::string, Opm::FieldData<int>> m_intProps; //!< Map of integer properties in process-local compressed indices.
std::map<std::string, std::vector<double>> m_doubleProps; //!< Map of double properties in process-local compressed indices. std::map<std::string, Opm::FieldData<double>> m_doubleProps; //!< Map of double properties in process-local compressed indices.
FieldPropsManager& m_manager; //!< Underlying field property manager (only used on root process). FieldPropsManager& m_manager; //!< Underlying field property manager (only used on root process).
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> m_comm; //!< Collective communication handler. Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> m_comm; //!< Collective communication handler.
std::function<int(void)> m_activeSize; //!< active size function of the grid std::function<int(void)> m_activeSize; //!< active size function of the grid

View File

@@ -50,7 +50,7 @@ class PropsCentroidsDataHandle
{ {
public: public:
//! \brief the data type we send (ints are converted to double) //! \brief the data type we send (ints are converted to double)
using DataType = double; using DataType = std::pair<double, unsigned char>;
//! \brief Constructor //! \brief Constructor
//! \param grid The grid where the loadbalancing is happening. //! \param grid The grid where the loadbalancing is happening.
@@ -106,15 +106,23 @@ public:
data.reserve(m_no_data); data.reserve(m_no_data);
for (const auto& intKey : m_intKeys) for (const auto& intKey : m_intKeys)
data.push_back(globalProps.get_int(intKey)[index]); {
const auto& fieldData = globalProps.get_int_field_data(intKey);
data.push_back(std::make_pair(fieldData.data[index],
static_cast<unsigned char>(fieldData.value_status[index])));
}
for (const auto& doubleKey : m_doubleKeys) for (const auto& doubleKey : m_doubleKeys)
data.push_back(globalProps.get_double(doubleKey)[index]); {
const auto& fieldData = globalProps.get_double_field_data(doubleKey);
data.push_back(std::make_pair(fieldData.data[index],
static_cast<unsigned char>(fieldData.value_status[index])));
}
auto cartIndex = cartMapper.cartesianIndex(index); auto cartIndex = cartMapper.cartesianIndex(index);
const auto& center = eclGridOnRoot->getCellCenter(cartIndex); const auto& center = eclGridOnRoot->getCellCenter(cartIndex);
for (int dim = 0; dim < Grid::dimensionworld; ++dim) for (int dim = 0; dim < Grid::dimensionworld; ++dim)
data.push_back(center[dim]); data.push_back(std::make_pair(center[dim], '1')); // write garbage for value_status
} }
} }
else else
@@ -136,10 +144,16 @@ public:
{ {
// distributed grid is now correctly set up. // distributed grid is now correctly set up.
for(const auto& intKey : m_intKeys) for(const auto& intKey : m_intKeys)
m_distributed_fieldProps.m_intProps[intKey].resize(m_grid.size(0)); {
m_distributed_fieldProps.m_intProps[intKey].data.resize(m_grid.size(0));
m_distributed_fieldProps.m_intProps[intKey].value_status.resize(m_grid.size(0));
}
for(const auto& doubleKey : m_doubleKeys) for(const auto& doubleKey : m_doubleKeys)
m_distributed_fieldProps.m_doubleProps[doubleKey].resize(m_grid.size(0)); {
m_distributed_fieldProps.m_doubleProps[doubleKey].data.resize(m_grid.size(0));
m_distributed_fieldProps.m_doubleProps[doubleKey].value_status.resize(m_grid.size(0));
}
m_centroids.resize(m_grid.size(0) * Grid::dimensionworld); m_centroids.resize(m_grid.size(0) * Grid::dimensionworld);
@@ -159,15 +173,23 @@ public:
assert(data != elementData_.end()); assert(data != elementData_.end());
for(const auto& intKey : m_intKeys) for(const auto& intKey : m_intKeys)
m_distributed_fieldProps.m_intProps[intKey][index] = static_cast<int>(data->second[counter++]); {
const auto& pair = data->second[counter++];
m_distributed_fieldProps.m_intProps[intKey].data[index] = static_cast<int>(pair.first);
m_distributed_fieldProps.m_intProps[intKey].value_status[index] = static_cast<value::status>(pair.second);
}
for(const auto& doubleKey : m_doubleKeys) for(const auto& doubleKey : m_doubleKeys)
m_distributed_fieldProps.m_doubleProps[doubleKey][index] = data->second[counter++]; {
const auto& pair = data->second[counter++];
m_distributed_fieldProps.m_doubleProps[doubleKey].data[index] = pair.first;
m_distributed_fieldProps.m_doubleProps[doubleKey].value_status[index] = static_cast<value::status>(pair.second);
}
auto centroidIter = m_centroids.begin() + Grid::dimensionworld * index; auto centroidIter = m_centroids.begin() + Grid::dimensionworld * index;
auto centroidIterEnd = centroidIter + Grid::dimensionworld; auto centroidIterEnd = centroidIter + Grid::dimensionworld;
for ( ; centroidIter != centroidIterEnd; ++centroidIter ) for ( ; centroidIter != centroidIterEnd; ++centroidIter )
*centroidIter = data->second[counter++]; *centroidIter = data->second[counter++].first; // value_status discarded
} }
} }
@@ -197,7 +219,9 @@ public:
auto iter = elementData_.find(m_grid.localIdSet().id(e)); auto iter = elementData_.find(m_grid.localIdSet().id(e));
assert(iter != elementData_.end()); assert(iter != elementData_.end());
for(const auto& data : iter->second) for(const auto& data : iter->second)
{
buffer.write(data); buffer.write(data);
}
} }
template<class BufferType, class EntityType> template<class BufferType, class EntityType>
@@ -222,7 +246,9 @@ private:
//! \brief The names of the keys of the double fields. //! \brief The names of the keys of the double fields.
std::vector<std::string> m_doubleKeys; std::vector<std::string> m_doubleKeys;
/// \brief The data per element as a vector mapped from the local id. /// \brief The data per element as a vector mapped from the local id.
std::unordered_map<typename LocalIdSet::IdType, std::vector<double> > elementData_; ///
/// each entry is a pair of data and value_status.
std::unordered_map<typename LocalIdSet::IdType, std::vector<std::pair<double,unsigned char> > > elementData_;
/// \brief The cell centroids of the distributed grid. /// \brief The cell centroids of the distributed grid.
std::vector<double>& m_centroids; std::vector<double>& m_centroids;
/// \brief The amount of data to send for each element /// \brief The amount of data to send for each element