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

Add cell_owner and node_owner (mesh->item_value) functions

This is useful to check mesh partition/load balance
parent e1dee840
No related branches found
No related tags found
1 merge request!202Prepare PTScotch integration
...@@ -308,6 +308,46 @@ MeshModule::MeshModule() ...@@ -308,6 +308,46 @@ MeshModule::MeshModule()
return DualMeshManager::instance().getMedianDualMesh(mesh_v); return DualMeshManager::instance().getMedianDualMesh(mesh_v);
} }
));
this->_addBuiltinFunction("cell_owner", std::function(
[](const std::shared_ptr<const MeshVariant>& mesh_v)
-> std::shared_ptr<const ItemValueVariant> {
return std::visit(
[&](auto&& mesh) {
const auto& connectivity = mesh->connectivity();
auto cell_owner = connectivity.cellOwner();
CellValue<long int> cell_owner_long{connectivity};
parallel_for(
connectivity.numberOfCells(), PUGS_LAMBDA(const CellId cell_id) {
cell_owner_long[cell_id] = cell_owner[cell_id];
});
return std::make_shared<const ItemValueVariant>(cell_owner_long);
},
mesh_v->variant());
}
));
this->_addBuiltinFunction("node_owner", std::function(
[](const std::shared_ptr<const MeshVariant>& mesh_v)
-> std::shared_ptr<const ItemValueVariant> {
return std::visit(
[&](auto&& mesh) {
const auto& connectivity = mesh->connectivity();
auto node_owner = connectivity.nodeOwner();
NodeValue<long int> node_owner_long{connectivity};
parallel_for(
connectivity.numberOfNodes(), PUGS_LAMBDA(const NodeId node_id) {
node_owner_long[node_id] = node_owner[node_id];
});
return std::make_shared<const ItemValueVariant>(node_owner_long);
},
mesh_v->variant());
}
)); ));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment