From a34ae8e3c46b4e609d5e5ac41bf6dabbe27769f2 Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 23 Apr 2003 22:42:18 +0000 Subject: [PATCH] Build the renumbering arrays in the member initializer list. This way, they are available all the time, and furthermore can be made "const", which they really are. git-svn-id: https://svn.dealii.org/trunk@7462 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/fe/fe_q.h | 25 ++++++------ deal.II/deal.II/source/fe/fe_q.cc | 64 ++++++++++++++++++------------- 2 files changed, 50 insertions(+), 39 deletions(-) diff --git a/deal.II/deal.II/include/fe/fe_q.h b/deal.II/deal.II/include/fe/fe_q.h index b92d8a373a..cb4ec781fd 100644 --- a/deal.II/deal.II/include/fe/fe_q.h +++ b/deal.II/deal.II/include/fe/fe_q.h @@ -626,10 +626,9 @@ class FE_Q : public FiniteElement * proper design. */ static - void + std::vector lexicographic_to_hierarchic_numbering (const FiniteElementData &fe_data, - const unsigned int degree, - std::vector &numbering); + const unsigned int degree); /** * This is an analogon to the @@ -637,9 +636,8 @@ class FE_Q : public FiniteElement * on faces. */ static - void - face_lexicographic_to_hierarchic_numbering (const unsigned int degree, - std::vector &numbering); + std::vector + face_lexicographic_to_hierarchic_numbering (const unsigned int degree); /** * Initialize the @@ -737,7 +735,7 @@ class FE_Q : public FiniteElement * Mapping from lexicographic to * shape function numbering. */ - std::vector renumber; + const std::vector renumber; /** * Inverse renumber @@ -745,13 +743,13 @@ class FE_Q : public FiniteElement * shape function numbering to * lexicographic numbering. */ - std::vector renumber_inverse; + const std::vector renumber_inverse; /** * Mapping from lexicographic to * shape function numbering on first face. */ - std::vector face_renumber; + const std::vector face_renumber; /** * Pointer to the tensor @@ -828,9 +826,12 @@ class FE_Q : public FiniteElement /* -------------- declaration of explicit specializations ------------- */ -template <> void FE_Q<1>::initialize_unit_face_support_points (); -template <> void FE_Q<1>::face_lexicographic_to_hierarchic_numbering (const unsigned int, - std::vector&); +template <> +void FE_Q<1>::initialize_unit_face_support_points (); + +template <> +std::vector +FE_Q<1>::face_lexicographic_to_hierarchic_numbering (const unsigned int); // declaration of explicit specializations of member variables, if the // compiler allows us to do that (the standard says we must) diff --git a/deal.II/deal.II/source/fe/fe_q.cc b/deal.II/deal.II/source/fe/fe_q.cc index 7dad2433ba..b39b401616 100644 --- a/deal.II/deal.II/source/fe/fe_q.cc +++ b/deal.II/deal.II/source/fe/fe_q.cc @@ -23,6 +23,20 @@ #include +namespace +{ + std::vector + invert_numbering (const std::vector &in) + { + std::vector out (in.size()); + for (unsigned int i=0; i FE_Q::FE_Q (const unsigned int degree) : @@ -32,22 +46,11 @@ FE_Q::FE_Q (const unsigned int degree) std::vector >(FiniteElementData(get_dpo_vector(degree),1).dofs_per_cell, std::vector(1,true))), degree(degree), - renumber(this->dofs_per_cell, 0), - renumber_inverse(this->dofs_per_cell, 0), - face_renumber(this->dofs_per_face, 0), + renumber(lexicographic_to_hierarchic_numbering (*this, degree)), + renumber_inverse(invert_numbering (renumber)), + face_renumber(face_lexicographic_to_hierarchic_numbering (degree)), polynomial_space(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)) { - // do some internal book-keeping on - // cells and faces. if in 1d, the - // face function is empty - lexicographic_to_hierarchic_numbering (*this, degree, renumber); - face_lexicographic_to_hierarchic_numbering (degree, face_renumber); - - // build inverse of renumbering - // vector - for (unsigned int i=0; idofs_per_cell; ++i) - renumber_inverse[renumber[i]]=i; - // copy constraint matrices if they // are defined. otherwise leave them // at invalid size @@ -801,11 +804,12 @@ FE_Q::get_dpo_vector(const unsigned int deg) template -void +std::vector FE_Q::lexicographic_to_hierarchic_numbering (const FiniteElementData &fe_data, - const unsigned int degree, - std::vector &renumber) + const unsigned int degree) { + std::vector renumber (fe_data.dofs_per_cell); + const unsigned int n = degree+1; @@ -876,7 +880,8 @@ FE_Q::lexicographic_to_hierarchic_numbering (const FiniteElementData & default: Assert(false, ExcNotImplemented()); } - + + Assert (index::lexicographic_to_hierarchic_numbering (const FiniteElementData & for (unsigned int jx = 1; jx::lexicographic_to_hierarchic_numbering (const FiniteElementData & { unsigned int tensorindex = tensorstart + jx * incx + jy * incy; + Assert (tensorindex::lexicographic_to_hierarchic_numbering (const FiniteElementData & for (unsigned int jx = 1; jx -void -FE_Q::face_lexicographic_to_hierarchic_numbering (const unsigned int degree, - std::vector &numbering) +std::vector +FE_Q::face_lexicographic_to_hierarchic_numbering (const unsigned int degree) { - FiniteElementData fe_data(FE_Q::get_dpo_vector(degree),1); - FE_Q::lexicographic_to_hierarchic_numbering (fe_data, degree, numbering); + const FiniteElementData fe_data(FE_Q::get_dpo_vector(degree),1); + return FE_Q::lexicographic_to_hierarchic_numbering (fe_data, degree); } #if (deal_II_dimension == 1) template <> -void -FE_Q<1>::face_lexicographic_to_hierarchic_numbering (const unsigned int, - std::vector&) -{} +std::vector +FE_Q<1>::face_lexicographic_to_hierarchic_numbering (const unsigned int) +{ + return std::vector(); +} #endif -- 2.39.5