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

Change Change VTK output for general polyhedral meshes

Now the polyhedral connectivity is only stored when needed (that is
when general polyhedrons are present). This improves a lot the
creation of output files.
parent 5d2a53bd
Branches
Tags
1 merge request!45Feature/diamond dual mesh manager
...@@ -322,6 +322,8 @@ class VTKWriter ...@@ -322,6 +322,8 @@ class VTKWriter
{ {
Array<int8_t> types(mesh->numberOfCells()); Array<int8_t> types(mesh->numberOfCells());
const auto& cell_type = mesh->connectivity().cellType(); const auto& cell_type = mesh->connectivity().cellType();
const auto& cell_to_node_matrix = mesh->connectivity().cellToNodeMatrix();
parallel_for( parallel_for(
mesh->numberOfCells(), PUGS_LAMBDA(CellId j) { mesh->numberOfCells(), PUGS_LAMBDA(CellId j) {
switch (cell_type[j]) { switch (cell_type[j]) {
...@@ -342,7 +344,11 @@ class VTKWriter ...@@ -342,7 +344,11 @@ class VTKWriter
break; break;
} }
case CellType::Pyramid: { case CellType::Pyramid: {
types[j] = 14; if (cell_to_node_matrix[j].size() == 5) {
types[j] = 14; // quadrangle basis
} else {
types[j] = 41; // polygonal basis
}
break; break;
} }
case CellType::Prism: { case CellType::Prism: {
...@@ -365,10 +371,16 @@ class VTKWriter ...@@ -365,10 +371,16 @@ class VTKWriter
} }
}); });
_write_array(fout, "types", types); _write_array(fout, "types", types);
}
if constexpr (MeshType::Dimension == 3) { if constexpr (MeshType::Dimension == 3) {
const bool has_general_polyhedron = [&] {
for (size_t i = 0; i < types.size(); ++i) {
if (types[i] == 41)
return true;
}
return false;
}();
if (has_general_polyhedron) {
const auto& cell_to_face_matrix = mesh->connectivity().cellToFaceMatrix(); const auto& cell_to_face_matrix = mesh->connectivity().cellToFaceMatrix();
const auto& cell_to_node_matrix = mesh->connectivity().cellToNodeMatrix();
const auto& face_to_node_matrix = mesh->connectivity().faceToNodeMatrix(); const auto& face_to_node_matrix = mesh->connectivity().faceToNodeMatrix();
const auto& cell_face_is_reversed = mesh->connectivity().cellFaceIsReversed(); const auto& cell_face_is_reversed = mesh->connectivity().cellFaceIsReversed();
...@@ -422,6 +434,9 @@ class VTKWriter ...@@ -422,6 +434,9 @@ class VTKWriter
} }
fout << "</DataArray>\n"; fout << "</DataArray>\n";
} }
}
}
fout << "</Cells>\n"; fout << "</Cells>\n";
fout << "</Piece>\n"; fout << "</Piece>\n";
fout << "</UnstructuredGrid>\n"; fout << "</UnstructuredGrid>\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment