Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize translation between deal.II and VTK numbering for pyramids. #14674

Merged
merged 1 commit into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/deal.II/grid/reference_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,12 @@ class ReferenceCell
const std::array<unsigned, dim> &nodes_per_direction,
const bool legacy_format) const;

/**
* Map a VTK vertex number to a deal.II vertex number.
*/
unsigned int
vtk_vertex_to_deal_vertex(const unsigned int vertex_index) const;

/**
* Return the GMSH element type code that corresponds to the reference cell.
*/
Expand Down
14 changes: 4 additions & 10 deletions source/base/data_out_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,7 @@ namespace DataOutBase
patch.reference_cell);
first_vertex_of_patch += patch.data.n_cols();
}
else
else // hypercube cell
{
const unsigned int n_subdivisions = patch.n_subdivisions;
const unsigned int n = n_subdivisions + 1;
Expand Down Expand Up @@ -5900,8 +5900,6 @@ namespace DataOutBase
Assert(patch.n_subdivisions == 1, ExcNotImplemented());

const unsigned int n_points = patch.data.n_cols();
static const std::array<unsigned int, 5>
pyramid_index_translation_table = {{0, 1, 3, 2, 4}};

if (deal_ii_with_zlib &&
(flags.compression_level !=
Expand All @@ -5910,18 +5908,14 @@ namespace DataOutBase
for (unsigned int i = 0; i < n_points; ++i)
cells.push_back(
first_vertex_of_patch +
(patch.reference_cell == ReferenceCells::Pyramid ?
pyramid_index_translation_table[i] :
i));
patch.reference_cell.vtk_vertex_to_deal_vertex(i));
}
else
{
for (unsigned int i = 0; i < n_points; ++i)
o << '\t'
<< first_vertex_of_patch +
(patch.reference_cell == ReferenceCells::Pyramid ?
pyramid_index_translation_table[i] :
i);
<< (first_vertex_of_patch +
patch.reference_cell.vtk_vertex_to_deal_vertex(i));
o << '\n';
}

Expand Down
52 changes: 52 additions & 0 deletions source/grid/reference_cell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,58 @@ ReferenceCell::vtk_lexicographic_to_node_index<3>(



unsigned int
ReferenceCell::vtk_vertex_to_deal_vertex(const unsigned int vertex_index) const
{
AssertIndexRange(vertex_index, n_vertices());

// For some of the following, deal.II uses the same ordering as VTK
// and in that case, we only need to return 'vertex_index' (i.e.,
// use the identity mapping). For some others, we need to translate.
//
// For the ordering, see the VTK manual (for example at
// http://www.princeton.edu/~efeibush/viscourse/vtk.pdf, page 9).
if (*this == ReferenceCells::Vertex)
return vertex_index;
else if (*this == ReferenceCells::Line)
return vertex_index;
else if (*this == ReferenceCells::Triangle)
return vertex_index;
else if (*this == ReferenceCells::Quadrilateral)
{
static constexpr std::array<unsigned int, 4> index_translation_table = {
{0, 1, 3, 2}};
return index_translation_table[vertex_index];
}
else if (*this == ReferenceCells::Tetrahedron)
return vertex_index;
else if (*this == ReferenceCells::Pyramid)
{
static constexpr std::array<unsigned int, 5> index_translation_table = {
{0, 1, 3, 2, 4}};
return index_translation_table[vertex_index];
}
else if (*this == ReferenceCells::Wedge)
return vertex_index;
else if (*this == ReferenceCells::Hexahedron)
{
static constexpr std::array<unsigned int, 8> index_translation_table = {
{0, 1, 3, 2, 4, 5, 7, 6}};
return index_translation_table[vertex_index];
}
else if (*this == ReferenceCells::Invalid)
{
Assert(false, ExcNotImplemented());
return numbers::invalid_unsigned_int;
}

Assert(false, ExcNotImplemented());

return numbers::invalid_unsigned_int;
}



unsigned int
ReferenceCell::gmsh_element_type() const
{
Expand Down