mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed: use EclMpiSerializer to distribute transmissibilities
This commit is contained in:
parent
42384c8052
commit
e93e18a55d
@ -109,6 +109,18 @@ public:
|
||||
void apply_tran(const std::string& keyword, std::vector<double>& trans) const override;
|
||||
|
||||
void deserialize_tran(const std::vector<char>& buffer) override;
|
||||
|
||||
void copyTran(const FieldPropsManager& from)
|
||||
{
|
||||
m_tran = from.getTran();
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer.map(m_tran);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::map<std::string, Fieldprops::FieldData<int>> m_intProps; //!< Map of integer properties in process-local compressed indices.
|
||||
std::map<std::string, Fieldprops::FieldData<double>> m_doubleProps; //!< Map of double properties in process-local compressed indices.
|
||||
|
@ -65,37 +65,27 @@ public:
|
||||
const EclipseGrid* eclGridOnRoot,
|
||||
std::vector<double>& centroids,
|
||||
const typename Dune::CartesianIndexMapper<Grid>& cartMapper)
|
||||
: m_grid(grid), m_distributed_fieldProps(eclState.m_fieldProps),
|
||||
: m_grid(grid),
|
||||
m_distributed_fieldProps(eclState.m_fieldProps),
|
||||
m_centroids(centroids)
|
||||
{
|
||||
// Scatter the keys
|
||||
const Parallel::Communication comm = m_grid.comm();
|
||||
if (comm.rank() == 0)
|
||||
{
|
||||
const auto& globalProps = eclState.globalFieldProps();
|
||||
const FieldPropsManager& globalProps = eclState.globalFieldProps();
|
||||
m_intKeys = globalProps.keys<int>();
|
||||
m_doubleKeys = globalProps.keys<double>();
|
||||
std::size_t packSize = Mpi::packSize(m_intKeys, comm) +
|
||||
Mpi::packSize(m_doubleKeys,comm);
|
||||
std::vector<char> buffer(packSize);
|
||||
int position = 0;
|
||||
Mpi::pack(m_intKeys, buffer, position, comm);
|
||||
Mpi::pack(m_doubleKeys, buffer, position, comm);
|
||||
int calcStart = position;
|
||||
{
|
||||
std::vector<char> tran_buffer = globalProps.serialize_tran();
|
||||
position += tran_buffer.size();
|
||||
buffer.insert(buffer.end(), std::make_move_iterator(tran_buffer.begin()), std::make_move_iterator(tran_buffer.end()));
|
||||
m_distributed_fieldProps.copyTran(globalProps);
|
||||
}
|
||||
comm.broadcast(&position, 1, 0);
|
||||
comm.broadcast(buffer.data(), position, 0);
|
||||
|
||||
// Unpack Calculator as we need it here, too.
|
||||
m_distributed_fieldProps.deserialize_tran( std::vector<char>(buffer.begin() + calcStart, buffer.end()) );
|
||||
EclMpiSerializer ser(comm);
|
||||
ser.broadcast(*this);
|
||||
|
||||
// copy data to persistent map based on local id
|
||||
m_no_data = m_intKeys.size() + m_doubleKeys.size() +
|
||||
Grid::dimensionworld;
|
||||
m_no_data = m_intKeys.size() + m_doubleKeys.size() + Grid::dimensionworld;
|
||||
|
||||
if (comm.rank() == 0) {
|
||||
const FieldPropsManager& globalProps = eclState.globalFieldProps();
|
||||
const auto& idSet = m_grid.localIdSet();
|
||||
const auto& gridView = m_grid.levelGridView(0);
|
||||
using ElementMapper =
|
||||
@ -132,19 +122,6 @@ public:
|
||||
data.emplace_back(center[dim], '1'); // write garbage for value_status
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int bufferSize;
|
||||
comm.broadcast(&bufferSize, 1, 0);
|
||||
std::vector<char> buffer(bufferSize);
|
||||
comm.broadcast(buffer.data(), bufferSize, 0);
|
||||
int position{};
|
||||
Mpi::unpack(m_intKeys, buffer, position, comm);
|
||||
Mpi::unpack(m_doubleKeys, buffer, position, comm);
|
||||
m_distributed_fieldProps.deserialize_tran( std::vector<char>(buffer.begin() + position, buffer.end()) );
|
||||
m_no_data = m_intKeys.size() + m_doubleKeys.size() +
|
||||
Grid::dimensionworld;
|
||||
}
|
||||
}
|
||||
|
||||
~PropsCentroidsDataHandle()
|
||||
@ -243,6 +220,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(m_intKeys);
|
||||
serializer(m_doubleKeys);
|
||||
m_distributed_fieldProps.serializeOp(serializer);
|
||||
}
|
||||
|
||||
private:
|
||||
using LocalIdSet = typename Grid::LocalIdSet;
|
||||
const Grid& m_grid;
|
||||
|
Loading…
Reference in New Issue
Block a user