From 4cd0c551269aca646eb6ddcd9ebbd4356e082df5 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 5 Sep 2007 04:12:14 +0000 Subject: [PATCH] Unify a bunch of functions that were previously independent explicit specializations. This resolves a TODO. Since this is an ABI change, let's do it before 6.0 instead of waiting. git-svn-id: https://svn.dealii.org/trunk@15124 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria.h | 26 +++--- deal.II/deal.II/source/grid/tria.cc | 133 +++++++++++++--------------- 2 files changed, 75 insertions(+), 84 deletions(-) diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index 3a878d4121..8422115c73 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -2716,16 +2716,21 @@ class Triangulation : public Subscriptor /** * Return total number of used faces, - * active or not. - * Maps to n_lines() in two space - * dimensions and so on. + * active or not. In 2d, the result + * equals n_lines(), while in 3d it + * equals n_quads(). Since there are no + * face objects in 1d, the function + * returns zero in 1d. */ unsigned int n_faces () const; /** - * Return total number of active faces. - * Maps to n_active_lines() in two space - * dimensions and so on. + * Return total number of active faces, + * active or not. In 2d, the result + * equals n_active_lines(), while in 3d + * it equals n_active_quads(). Since + * there are no face objects in 1d, the + * function returns zero in 1d. */ unsigned int n_active_faces () const; @@ -3399,15 +3404,6 @@ template <> Triangulation<3>::raw_face_iterator Triangulation<3>::last_raw_face template <> Triangulation<3>::face_iterator Triangulation<3>::last_face () const; template <> Triangulation<3>::active_face_iterator Triangulation<3>::last_active_face () const; template <> Triangulation<3>::raw_quad_iterator Triangulation<3>::begin_raw_quad (const unsigned int level) const; -template <> unsigned int Triangulation<1>::n_raw_cells (const unsigned int level) const; -template <> unsigned int Triangulation<1>::n_cells (const unsigned int level) const; -template <> unsigned int Triangulation<1>::n_active_cells (const unsigned int level) const; -template <> unsigned int Triangulation<2>::n_raw_cells (const unsigned int level) const; -template <> unsigned int Triangulation<2>::n_cells (const unsigned int level) const; -template <> unsigned int Triangulation<2>::n_active_cells (const unsigned int level) const; -template <> unsigned int Triangulation<3>::n_raw_cells (const unsigned int level) const; -template <> unsigned int Triangulation<3>::n_cells (const unsigned int level) const; -template <> unsigned int Triangulation<3>::n_active_cells (const unsigned int level) const; template <> unsigned int Triangulation<1>::n_raw_lines (const unsigned int level) const; template <> unsigned int Triangulation<1>::n_quads () const; template <> unsigned int Triangulation<1>::n_quads (const unsigned int level) const; diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 367e211b01..4ed530d32e 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -4399,9 +4399,17 @@ unsigned int Triangulation::n_active_cells () const template unsigned int Triangulation::n_faces () const { - Assert (dim<=3, ExcNotImplemented()); - if (dim==2) return n_lines(); - if (dim==3) return n_quads(); + switch (dim) + { + case 1: + return 0; + case 2: + return n_lines(); + case 3: + return n_quads(); + default: + Assert (false, ExcNotImplemented()); + } return 0; } @@ -4409,89 +4417,76 @@ unsigned int Triangulation::n_faces () const template unsigned int Triangulation::n_active_faces () const { - Assert (dim<=3, ExcNotImplemented()); - if (dim==2) return n_active_lines(); - if (dim==3) return n_active_quads(); + switch (dim) + { + case 1: + return 0; + case 2: + return n_active_lines(); + case 3: + return n_active_quads(); + default: + Assert (false, ExcNotImplemented()); + } return 0; } -//TODO:[GK] Implement this like above and remove specialization declaration in tria.h -//TODO:[GK] Add a remark to Triangulation doc telling 1d-Triangulations have no face - -#if deal_II_dimension == 1 - -template <> -unsigned int Triangulation<1>::n_raw_cells (const unsigned int level) const -{ - return n_raw_lines (level); -} - -template <> -unsigned int Triangulation<1>::n_cells (const unsigned int level) const -{ - return n_lines (level); -} - - -template <> -unsigned int Triangulation<1>::n_active_cells (const unsigned int level) const -{ - return n_active_lines (level); -} - - -#endif - - -#if deal_II_dimension == 2 - -template <> -unsigned int Triangulation<2>::n_raw_cells (const unsigned int level) const -{ - return n_raw_quads (level); -} - - -template <> -unsigned int Triangulation<2>::n_cells (const unsigned int level) const -{ - return n_quads (level); -} - - -template <> -unsigned int Triangulation<2>::n_active_cells (const unsigned int level) const +template +unsigned int Triangulation::n_raw_cells (const unsigned int level) const { - return n_active_quads (level); + switch (dim) + { + case 1: + return n_raw_lines(level); + case 2: + return n_raw_quads(level); + case 3: + return n_raw_hexs(level); + default: + Assert (false, ExcNotImplemented()); + } + return 0; } -#endif - -#if deal_II_dimension == 3 -template <> -unsigned int Triangulation<3>::n_raw_cells (const unsigned int level) const +template +unsigned int Triangulation::n_cells (const unsigned int level) const { - return n_raw_hexs (level); + switch (dim) + { + case 1: + return n_lines(level); + case 2: + return n_quads(level); + case 3: + return n_hexs(level); + default: + Assert (false, ExcNotImplemented()); + } + return 0; } -template <> -unsigned int Triangulation<3>::n_cells (const unsigned int level) const -{ - return n_hexs (level); -} - -template <> -unsigned int Triangulation<3>::n_active_cells (const unsigned int level) const +template +unsigned int Triangulation::n_active_cells (const unsigned int level) const { - return n_active_hexs (level); + switch (dim) + { + case 1: + return n_active_lines(level); + case 2: + return n_active_quads(level); + case 3: + return n_active_hexs(level); + default: + Assert (false, ExcNotImplemented()); + } + return 0; } -#endif template -- 2.39.5