From c14ccdb17608b9bfbcc8db4773b14c28a51a3c8a Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Thu, 28 Jan 2021 13:50:46 +0100 Subject: [PATCH] Move make_triangulation into ReferenceCell::Type --- include/deal.II/fe/fe_tools.templates.h | 4 ++-- include/deal.II/grid/reference_cell.h | 17 ++++++++--------- source/grid/reference_cell.cc | 17 +++++++---------- source/grid/reference_cell.inst.in | 5 ++--- tests/simplex/orientation_02.cc | 2 +- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/include/deal.II/fe/fe_tools.templates.h b/include/deal.II/fe/fe_tools.templates.h index 4e3edf8a92..eb13a193d4 100644 --- a/include/deal.II/fe/fe_tools.templates.h +++ b/include/deal.II/fe/fe_tools.templates.h @@ -1605,7 +1605,7 @@ namespace FETools // First, create a local mass matrix for the unit cell Triangulation tr; - ReferenceCell::make_triangulation(reference_cell_type, tr); + reference_cell_type.make_triangulation(tr); const auto &mapping = reference_cell_type.template get_default_linear_mapping(); @@ -1814,7 +1814,7 @@ namespace FETools // Set up meshes, one with a single // reference cell and refine it once Triangulation tria; - ReferenceCell::make_triangulation(reference_cell_type, tria); + reference_cell_type.make_triangulation(tria); tria.begin_active()->set_refine_flag(RefinementCase(ref_case)); tria.execute_coarsening_and_refinement(); diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 9c969b6cd4..0f9e664bc5 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -240,6 +240,14 @@ namespace ReferenceCell ArrayView faces_for_given_vertex(const unsigned int vertex) const; + /* + * Create a (coarse) grid with a single cell of the shape of this + * reference cell. + */ + template + void + make_triangulation(Triangulation &tria) const; + private: /** * The variable that stores what this object actually corresponds to. @@ -712,15 +720,6 @@ namespace ReferenceCell return {}; } - /* - * Create a (coarse) grid with a single cell of the shape of the provided - * reference cell. - */ - template - void - make_triangulation(const Type & reference_cell, - Triangulation &tria); - /** * Return a default linear mapping that works for the given triangulation. * Internally, this function calls the function above for the reference diff --git a/source/grid/reference_cell.cc b/source/grid/reference_cell.cc index 6d30097984..b4db7849e1 100644 --- a/source/grid/reference_cell.cc +++ b/source/grid/reference_cell.cc @@ -94,16 +94,13 @@ namespace ReferenceCell template void - make_triangulation(const Type & reference_cell, - Triangulation &tria) + Type::make_triangulation(Triangulation &tria) const { - AssertDimension(dim, reference_cell.get_dimension()); - - if (reference_cell == Type::get_hypercube()) + if (this->is_hyper_cube()) { GridGenerator::hyper_cube(tria, 0, 1); } - else if ((dim == 2) && (reference_cell == Type::Tri)) + else if ((dim == 2) && (*this == Tri)) { const std::vector> vertices = { Point(), // the origin @@ -116,7 +113,7 @@ namespace ReferenceCell tria.create_triangulation(vertices, cells, {}); } - else if ((dim == 3) && (reference_cell == Type::Tet)) + else if ((dim == 3) && (*this == Tet)) { AssertDimension(spacedim, 3); @@ -128,7 +125,7 @@ namespace ReferenceCell tria.create_triangulation(vertices, cells, {}); } - else if ((dim == 3) && (reference_cell == Type::Pyramid)) + else if ((dim == 3) && (*this == Pyramid)) { AssertDimension(spacedim, 3); @@ -144,7 +141,7 @@ namespace ReferenceCell tria.create_triangulation(vertices, cells, {}); } - else if ((dim == 3) && (reference_cell == Type::Wedge)) + else if ((dim == 3) && (*this == Wedge)) { AssertDimension(spacedim, 3); @@ -285,7 +282,7 @@ namespace ReferenceCell const auto create_quadrature = [](const Type &reference_cell) { Triangulation tria; - make_triangulation(reference_cell, tria); + reference_cell.make_triangulation(tria); return Quadrature(tria.get_vertices()); }; diff --git a/source/grid/reference_cell.inst.in b/source/grid/reference_cell.inst.in index b232ba517a..51149bca8b 100644 --- a/source/grid/reference_cell.inst.in +++ b/source/grid/reference_cell.inst.in @@ -16,9 +16,8 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension - template void make_triangulation( - const Type & reference_cell, - Triangulation &tria); + template void Type::make_triangulation( + Triangulation & tria) const; template std::unique_ptr< Mapping> diff --git a/tests/simplex/orientation_02.cc b/tests/simplex/orientation_02.cc index c81eb0903f..7916800d7f 100644 --- a/tests/simplex/orientation_02.cc +++ b/tests/simplex/orientation_02.cc @@ -29,7 +29,7 @@ test(const unsigned int orientation) Triangulation<3> dummy, tria; - ReferenceCell::make_triangulation(ReferenceCell::Type::Tet, dummy); + ReferenceCell::Type::Tet.make_triangulation(dummy); auto vertices = dummy.get_vertices(); -- 2.39.5