From: Luca Heltai Date: Mon, 23 Apr 2018 15:01:54 +0000 (+0200) Subject: Added optional mapping to minimal/maximal grid diameter. X-Git-Tag: v9.0.0-rc1~129^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7fd0746372ef91f254604fdf21a77974e9fd81e;p=dealii.git Added optional mapping to minimal/maximal grid diameter. --- diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 7c57c3d4a5..1ce036b808 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -158,14 +158,16 @@ namespace GridTools */ template double - minimal_cell_diameter (const Triangulation &triangulation); + minimal_cell_diameter (const Triangulation &triangulation, + const Mapping &mapping = (StaticMappingQ1::mapping)); /** * Return the diameter of the largest active cell of a triangulation. */ template double - maximal_cell_diameter (const Triangulation &triangulation); + maximal_cell_diameter (const Triangulation &triangulation, + const Mapping &mapping = (StaticMappingQ1::mapping)); /** * Given a list of vertices (typically obtained using diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 0d6b768e27..ed6e97e30a 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -2770,15 +2770,43 @@ next_cell: + namespace + { + template + double diameter(const typename Triangulation::cell_iterator &cell, + const Mapping &mapping) + { + auto vertices = mapping.get_vertices(cell); + switch (dim) + { + case 1: + return (vertices[1]-vertices[0]).norm(); + case 2: + return std::max((vertices[3]-vertices[0]).norm(), + (vertices[2]-vertices[1]).norm()); + case 3: + return std::max( std::max((vertices[7]-vertices[0]).norm(), + (vertices[6]-vertices[1]).norm()), + std::max((vertices[2]-vertices[5]).norm(), + (vertices[3]-vertices[4]).norm()) ); + default: + Assert (false, ExcNotImplemented()); + return -1e10; + } + } + } + + template double - minimal_cell_diameter (const Triangulation &triangulation) + minimal_cell_diameter (const Triangulation &triangulation, + const Mapping &mapping) { double min_diameter = std::numeric_limits::max(); for (const auto &cell: triangulation.active_cell_iterators()) if (!cell->is_artificial()) min_diameter = std::min (min_diameter, - cell->diameter()); + diameter(cell, mapping)); double global_min_diameter = 0; @@ -2797,13 +2825,14 @@ next_cell: template double - maximal_cell_diameter (const Triangulation &triangulation) + maximal_cell_diameter (const Triangulation &triangulation, + const Mapping &mapping) { double max_diameter = 0.; for (const auto &cell: triangulation.active_cell_iterators()) if (!cell->is_artificial()) max_diameter = std::max (max_diameter, - cell->diameter()); + diameter(cell, mapping)); double global_max_diameter = 0; diff --git a/source/grid/grid_tools.inst.in b/source/grid/grid_tools.inst.in index b84264dcb9..3a33c28abc 100644 --- a/source/grid/grid_tools.inst.in +++ b/source/grid/grid_tools.inst.in @@ -245,11 +245,13 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS template double - minimal_cell_diameter (const Triangulation &triangulation); + minimal_cell_diameter (const Triangulation &triangulation, + const Mapping &); template double - maximal_cell_diameter (const Triangulation &triangulation); + maximal_cell_diameter (const Triangulation &triangulation, + const Mapping &); template std::map >