From: bangerth Date: Thu, 20 Sep 2012 13:37:12 +0000 (+0000) Subject: Add a FECollection::n_blocks function. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a09ac67d9e051e48ec6bcbc9bfd94dae51f7fd72;p=dealii-svn.git Add a FECollection::n_blocks function. git-svn-id: https://svn.dealii.org/trunk@26564 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 91de6a8289..6811424846 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -53,6 +53,11 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. New: There is now a function hp::FECollection::n_blocks() in analogy to +the existing function hp::FECollection::n_components(). +
    +(Wolfgang Bangerth, 2012/09/20) +
  2. Changed: step-8 now outputs data in VTK format, rather than GMV. GMV has long been dead.
    diff --git a/deal.II/include/deal.II/hp/fe_collection.h b/deal.II/include/deal.II/hp/fe_collection.h index cfe2769964..ff0f550f77 100644 --- a/deal.II/include/deal.II/hp/fe_collection.h +++ b/deal.II/include/deal.II/hp/fe_collection.h @@ -124,6 +124,27 @@ namespace hp */ unsigned int n_components () const; + /** + * Return the number of vector + * blocks of the finite elements in + * this collection. While this class ensures that all + * elements stored in it have the same number of vector + * components, there is no such guarantees for the number + * of blocks each element is made up of (an element may + * have fewer blocks than vector components; see + * @ref GlossBlock "the glossary" for more information). + * For example, you may have an FECollection object that stores + * one copy of an FESystem with dim FE_Q objects + * and one copy of an FE_RaviartThomas element. Both have + * dim vector components but while the former has + * dim blocks the latter has only one. + * Consequently, this function will throw an assertion + * if the number of blocks is not the same for all elements. + * If they are the same, this function returns the result + * of FiniteElement::n_blocks(). + */ + unsigned int n_blocks () const; + /** * Return the maximal number of degrees * of freedom per vertex over all diff --git a/deal.II/source/hp/fe_collection.cc b/deal.II/source/hp/fe_collection.cc index 033eb46013..cb6ed6399b 100644 --- a/deal.II/source/hp/fe_collection.cc +++ b/deal.II/source/hp/fe_collection.cc @@ -72,6 +72,23 @@ namespace hp + template + unsigned int + FECollection::n_blocks () const + { + Assert (finite_elements.size () > 0, ExcNoFiniteElements()); + + const unsigned int nb = finite_elements[0]->n_blocks (); + for (unsigned int i=1; in_blocks() == nb, + ExcMessage ("Not all finite elements in this collection have " + "the same number of components.")); + + return nb; + } + + + template std::size_t FECollection::memory_consumption () const