Skip to content
Snippets Groups Projects
Commit 33b3de4e authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Use links to avoid duplication of item numbers storage

parent 3e277d18
No related branches found
No related tags found
1 merge request!176Add HDF5 support
......@@ -195,6 +195,25 @@ class ParallelChecker
return table;
}
size_t
_getConnectivityId(const std::shared_ptr<const IConnectivity>& i_connectivity) const
{
switch (i_connectivity->dimension()) {
case 1: {
return dynamic_cast<const Connectivity<1>&>(*i_connectivity).id();
}
case 2: {
return dynamic_cast<const Connectivity<2>&>(*i_connectivity).id();
}
case 3: {
return dynamic_cast<const Connectivity<3>&>(*i_connectivity).id();
}
default: {
throw UnexpectedError("unexpected connectivity dimension");
}
}
}
template <ItemType item_type>
Array<const int>
_getItemNumber(const std::shared_ptr<const IConnectivity>& i_connectivity) const
......@@ -243,9 +262,20 @@ class ParallelChecker
template <ItemType item_type>
void
_writeItemNumbers(const std::shared_ptr<const IConnectivity> i_connectivity, HighFive::Group group) const
_writeItemNumbers(const std::shared_ptr<const IConnectivity> i_connectivity,
HighFive::File file,
HighFive::Group group) const
{
this->_writeArray(group, "numbers", this->_getItemNumber<item_type>(i_connectivity));
std::string item_number_path = "/connectivities/" + std::to_string(this->_getConnectivityId(i_connectivity)) + '/' +
std::string{itemName(item_type)};
if (not file.exist(item_number_path)) {
HighFive::Group item_number_group = file.createGroup(item_number_path);
this->_writeArray(item_number_group, "numbers", this->_getItemNumber<item_type>(i_connectivity));
}
HighFive::DataSet item_numbers = file.getDataSet(item_number_path + "/numbers");
group.createHardLink("numbers", item_numbers);
}
template <typename DataType, ItemType item_type>
......@@ -358,7 +388,7 @@ class ParallelChecker
this->_writeArray(group, name, item_value.arrayView());
this->_writeItemNumbers<item_type>(i_connectivity, group);
this->_writeItemNumbers<item_type>(i_connectivity, file, group);
++m_tag;
......@@ -395,7 +425,7 @@ class ParallelChecker
this->_writeTable(group, name, item_array.tableView());
this->_writeItemNumbers<item_type>(i_connectivity, group);
this->_writeItemNumbers<item_type>(i_connectivity, file, group);
++m_tag;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment