From a28ead0e55c340a37314030b11917a2c7810d254 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 6 Dec 2020 18:30:09 -0700 Subject: [PATCH] Move a function into the appropriate namespace. --- .../deal.II/grid/tria_accessor.templates.h | 142 +++++++++--------- 1 file changed, 73 insertions(+), 69 deletions(-) diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index 74bd8db5e6..f0656f1e15 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -40,74 +40,77 @@ DEAL_II_NAMESPACE_OPEN namespace internal { - /** - * Compute the diameter for a given set of vertices. The vertices are - * interpreted, depending on their count, as the vertices of a particular - * reference cell. - */ - template - inline double - diameter( - const boost::container::small_vector, - GeometryInfo::vertices_per_cell> - vertices) + namespace TriaAccessorImplementation { - switch (ReferenceCell::n_vertices_to_type(dim, vertices.size())) - { - case ReferenceCell::Type::Line: - // Return the distance between the two vertices - return (vertices[1] - vertices[0]).norm(); - - case ReferenceCell::Type::Tri: - // Return the longest of the three edges - return std::max({(vertices[1] - vertices[0]).norm(), - (vertices[2] - vertices[1]).norm(), - (vertices[2] - vertices[0]).norm()}); - - case ReferenceCell::Type::Quad: - // Return the longer one of the two diagonals of the quadrilateral - return std::max({(vertices[3] - vertices[0]).norm(), - (vertices[2] - vertices[1]).norm()}); - - case ReferenceCell::Type::Tet: - // Return the longest of the six edges of the tetrahedron - return std::max({(vertices[1] - vertices[0]).norm(), - (vertices[2] - vertices[0]).norm(), - (vertices[2] - vertices[1]).norm(), - (vertices[3] - vertices[0]).norm(), - (vertices[3] - vertices[1]).norm(), - (vertices[3] - vertices[2]).norm()}); - - case ReferenceCell::Type::Wedge: - // Return ... - return std::max({// the longest of the 2*3=6 diagonals of the three - // quadrilateral sides of the wedge or ... - (vertices[4] - vertices[0]).norm(), - (vertices[3] - vertices[1]).norm(), - (vertices[5] - vertices[1]).norm(), - (vertices[4] - vertices[2]).norm(), - (vertices[5] - vertices[0]).norm(), - (vertices[3] - vertices[2]).norm(), - // the longest of the 3*2=6 edges of the two - // triangular faces of the wedge - (vertices[1] - vertices[0]).norm(), - (vertices[2] - vertices[1]).norm(), - (vertices[2] - vertices[0]).norm(), - (vertices[4] - vertices[3]).norm(), - (vertices[5] - vertices[4]).norm(), - (vertices[5] - vertices[3]).norm()}); - - case ReferenceCell::Type::Hex: - // Return the longest of the four diagonals of the hexahedron - return std::max({(vertices[7] - vertices[0]).norm(), - (vertices[6] - vertices[1]).norm(), - (vertices[2] - vertices[5]).norm(), - (vertices[3] - vertices[4]).norm()}); - default: - Assert(false, ExcNotImplemented()); - return -1e10; - } - } + /** + * Compute the diameter for a given set of vertices. The vertices are + * interpreted, depending on their count, as the vertices of a particular + * reference cell. + */ + template + inline double + diameter( + const boost::container::small_vector, + GeometryInfo::vertices_per_cell> + vertices) + { + switch (ReferenceCell::n_vertices_to_type(dim, vertices.size())) + { + case ReferenceCell::Type::Line: + // Return the distance between the two vertices + return (vertices[1] - vertices[0]).norm(); + + case ReferenceCell::Type::Tri: + // Return the longest of the three edges + return std::max({(vertices[1] - vertices[0]).norm(), + (vertices[2] - vertices[1]).norm(), + (vertices[2] - vertices[0]).norm()}); + + case ReferenceCell::Type::Quad: + // Return the longer one of the two diagonals of the quadrilateral + return std::max({(vertices[3] - vertices[0]).norm(), + (vertices[2] - vertices[1]).norm()}); + + case ReferenceCell::Type::Tet: + // Return the longest of the six edges of the tetrahedron + return std::max({(vertices[1] - vertices[0]).norm(), + (vertices[2] - vertices[0]).norm(), + (vertices[2] - vertices[1]).norm(), + (vertices[3] - vertices[0]).norm(), + (vertices[3] - vertices[1]).norm(), + (vertices[3] - vertices[2]).norm()}); + + case ReferenceCell::Type::Wedge: + // Return ... + return std::max({// the longest of the 2*3=6 diagonals of the three + // quadrilateral sides of the wedge or ... + (vertices[4] - vertices[0]).norm(), + (vertices[3] - vertices[1]).norm(), + (vertices[5] - vertices[1]).norm(), + (vertices[4] - vertices[2]).norm(), + (vertices[5] - vertices[0]).norm(), + (vertices[3] - vertices[2]).norm(), + // the longest of the 3*2=6 edges of the two + // triangular faces of the wedge + (vertices[1] - vertices[0]).norm(), + (vertices[2] - vertices[1]).norm(), + (vertices[2] - vertices[0]).norm(), + (vertices[4] - vertices[3]).norm(), + (vertices[5] - vertices[4]).norm(), + (vertices[5] - vertices[3]).norm()}); + + case ReferenceCell::Type::Hex: + // Return the longest of the four diagonals of the hexahedron + return std::max({(vertices[7] - vertices[0]).norm(), + (vertices[6] - vertices[1]).norm(), + (vertices[2] - vertices[5]).norm(), + (vertices[3] - vertices[4]).norm()}); + default: + Assert(false, ExcNotImplemented()); + return -1e10; + } + } + } // namespace TriaAccessorImplementation } // namespace internal @@ -1965,7 +1968,8 @@ TriaAccessor::diameter() const for (unsigned int v = 0; v < vertices.size(); ++v) vertices[v] = this->vertex(v); - return internal::diameter(vertices); + return internal::TriaAccessorImplementation::diameter( + vertices); } @@ -1975,7 +1979,7 @@ double CellAccessor::diameter( const Mapping &mapping) const { - return internal::diameter( + return internal::TriaAccessorImplementation::diameter( mapping.get_vertices(typename Triangulation::cell_iterator( this->tria, this->level(), this->index()))); } -- 2.39.5