From e98805949ae080a7ec4de48bf5f1192786a1edf6 Mon Sep 17 00:00:00 2001 From: kanschat Date: Fri, 17 Sep 2010 16:21:31 +0000 Subject: [PATCH] move primitivity to FiniteElementData git-svn-id: https://svn.dealii.org/trunk@22017 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/fe/fe.h | 43 +------------------- deal.II/deal.II/include/fe/fe_base.h | 60 ++++++++++++++++++++++++++++ deal.II/deal.II/source/fe/fe.cc | 16 ++++---- deal.II/deal.II/source/fe/fe_data.cc | 5 ++- 4 files changed, 72 insertions(+), 52 deletions(-) diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h index 0e448f8d11..0c89f0ab56 100644 --- a/deal.II/deal.II/include/fe/fe.h +++ b/deal.II/deal.II/include/fe/fe.h @@ -1397,24 +1397,7 @@ class FiniteElement : public Subscriptor, bool is_primitive (const unsigned int i) const; - /** - * Return whether the entire - * finite element is primitive, - * in the sense that all its - * shape functions are - * primitive. If the finite - * element is scalar, then this - * is always the case. - * - * Since this is an extremely - * common operation, the result - * is cached in the - * #cached_primitivity - * variable which is computed in - * the constructor. - */ - bool - is_primitive () const; + FiniteElementData::is_primitive; /** * Number of base elements in a @@ -2000,18 +1983,6 @@ class FiniteElement : public Subscriptor, void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false); - - /** - * Store whether all shape - * functions are primitive. Since - * finding this out is a very - * common operation, we cache the - * result, i.e. compute the value - * in the constructor for simpler - * access. - */ - const bool cached_primitivity; - /** * Vector of projection * matrices. See @@ -2862,22 +2833,12 @@ FiniteElement::is_primitive (const unsigned int i) const // // for good measure, short circuit the test // if the entire FE is primitive - return ((cached_primitivity == true) - || + return (is_primitive() || (n_nonzero_components_table[i] == 1)); } -template -inline -bool -FiniteElement::is_primitive () const -{ - return cached_primitivity; -} - - DEAL_II_NAMESPACE_CLOSE #endif diff --git a/deal.II/deal.II/include/fe/fe_base.h b/deal.II/deal.II/include/fe/fe_base.h index dae7c287e5..916467b88c 100644 --- a/deal.II/deal.II/include/fe/fe_base.h +++ b/deal.II/deal.II/include/fe/fe_base.h @@ -517,6 +517,24 @@ class FiniteElementData */ unsigned int n_blocks () const; + /** + * Return whether the entire + * finite element is primitive, + * in the sense that all its + * shape functions are + * primitive. If the finite + * element is scalar, then this + * is always the case. + * + * Since this is an extremely + * common operation, the result + * is cached in the + * #cached_primitivity + * variable which is computed in + * the constructor. + */ + bool is_primitive () const; + /** * Maximal polynomial degree of a * shape function in a single @@ -598,6 +616,30 @@ class FiniteElementData * Comparison operator. */ bool operator == (const FiniteElementData &) const; + + protected: + + /** + * Set the primitivity of the + * element. This is usually done + * by the constructor of a + * derived class. + * See @ref GlossPrimitive "primitive" + * for details. + */ + void set_primitivity(const bool value); + + private: + /** + * Store whether all shape + * functions are primitive. Since + * finding this out is a very + * common operation, we cache the + * result, i.e. compute the value + * in the constructor for simpler + * access. + */ + bool cached_primitivity; }; @@ -750,6 +792,24 @@ FiniteElementData::n_components () const +template +inline +bool +FiniteElementData::is_primitive () const +{ + return cached_primitivity; +} + + +template +inline +void +FiniteElementData::set_primitivity (const bool value) +{ + cached_primitivity = value; +} + + template inline unsigned int diff --git a/deal.II/deal.II/source/fe/fe.cc b/deal.II/deal.II/source/fe/fe.cc index 3a44e0290a..32784952bc 100644 --- a/deal.II/deal.II/source/fe/fe.cc +++ b/deal.II/deal.II/source/fe/fe.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -113,7 +113,6 @@ FiniteElement::FiniteElement ( const std::vector > &nonzero_c) : FiniteElementData (fe_data), - cached_primitivity(false), adjust_quad_dof_index_for_face_orientation_table (dim == 3 ? this->dofs_per_quad : 0 , dim==3 ? 8 : 0), @@ -156,12 +155,11 @@ FiniteElement::FiniteElement ( // nonzero_components vector. const_cast&> (n_nonzero_components_table) = compute_n_nonzero_components(nonzero_components); - const_cast - (cached_primitivity) = std::find_if (n_nonzero_components_table.begin(), - n_nonzero_components_table.end(), - std::bind2nd(std::not_equal_to(), - 1U)) - == n_nonzero_components_table.end(); + this->set_primitivity(std::find_if (n_nonzero_components_table.begin(), + n_nonzero_components_table.end(), + std::bind2nd(std::not_equal_to(), + 1U)) + == n_nonzero_components_table.end()); Assert (restriction_is_additive_flags.size() == this->dofs_per_cell, @@ -189,7 +187,7 @@ FiniteElement::FiniteElement ( // only one (vector-)component; if // the element is not primitive, // leave these tables empty. - if (cached_primitivity) + if (this->is_primitive()) { system_to_component_table.resize(this->dofs_per_cell); face_system_to_component_table.resize(this->dofs_per_face); diff --git a/deal.II/deal.II/source/fe/fe_data.cc b/deal.II/deal.II/source/fe/fe_data.cc index 7b7588d9e9..fe483d2139 100644 --- a/deal.II/deal.II/source/fe/fe_data.cc +++ b/deal.II/deal.II/source/fe/fe_data.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -34,7 +34,8 @@ FiniteElementData::FiniteElementData () components(0), blocks(0), degree(0), - conforming_space(unknown) + conforming_space(unknown), + cached_primitivity(false) {} -- 2.39.5