From 68576c67c242061f3b76dcc2a82ade0f3ad2b02b Mon Sep 17 00:00:00 2001 From: kanschat Date: Mon, 15 Aug 2011 12:19:02 +0000 Subject: [PATCH] replace two unnecessarily virtual functions by inline provide standard implementation for base_element() such that only FESystem reimplements it git-svn-id: https://svn.dealii.org/trunk@24072 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/fe/fe.h | 53 +++-- deal.II/include/deal.II/fe/fe_abf.h | 31 +-- deal.II/include/deal.II/fe/fe_base.h | 45 ++-- .../include/deal.II/fe/fe_dgp_nonparametric.h | 30 +-- deal.II/include/deal.II/fe/fe_nothing.h | 34 --- deal.II/include/deal.II/fe/fe_poly.h | 35 +-- .../include/deal.II/fe/fe_poly.templates.h | 30 --- deal.II/include/deal.II/fe/fe_poly_face.h | 32 +-- .../deal.II/fe/fe_poly_face.templates.h | 30 --- deal.II/include/deal.II/fe/fe_poly_tensor.h | 29 --- deal.II/include/deal.II/fe/fe_system.h | 21 +- deal.II/source/fe/fe.cc | 5 +- deal.II/source/fe/fe_abf.cc | 32 --- deal.II/source/fe/fe_data.cc | 10 +- deal.II/source/fe/fe_dgp_nonparametric.cc | 29 --- deal.II/source/fe/fe_nothing.cc | 29 --- deal.II/source/fe/fe_poly_tensor.cc | 30 +-- deal.II/source/fe/fe_system.cc | 220 +++++++++--------- 18 files changed, 183 insertions(+), 542 deletions(-) diff --git a/deal.II/include/deal.II/fe/fe.h b/deal.II/include/deal.II/fe/fe.h index 813609cb2d..8312954bc2 100644 --- a/deal.II/include/deal.II/fe/fe.h +++ b/deal.II/include/deal.II/fe/fe.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -1421,32 +1421,31 @@ class FiniteElement : public Subscriptor, * element is equal to the * multiplicity. */ - virtual unsigned int n_base_elements () const = 0; + unsigned int n_base_elements () const; /** * Access to base element * objects. If the element is - * scalar, then + * atomic, then * base_element(0) is * @p this. */ virtual const FiniteElement & - base_element (const unsigned int index) const = 0; + base_element (const unsigned int index) const; /** * This index denotes how often * the base element @p index is * used in a composed element. If - * the element is scalar, then + * the element is atomic, then * the result is always equal to * one. See the documentation for * the n_base_elements() * function for more details. */ - virtual unsigned int - element_multiplicity (const unsigned int index) const = 0; + element_multiplicity (const unsigned int index) const; /** * Return for shape function @@ -2344,10 +2343,11 @@ class FiniteElement : public Subscriptor, /** * For each base element, store - * the first block in a block + * the number of blocks generated + * by the base and the first block in a block * vector it will generate. */ - std::vector first_block_of_base_table; + BlockIndices base_to_block_indices; /** * The base element establishing @@ -2648,6 +2648,26 @@ FiniteElement::system_to_component_index (const unsigned int index +template +inline +unsigned int +FiniteElement::n_base_elements () const +{ + return base_to_block_indices.size(); +} + + + +template +inline +unsigned int +FiniteElement::element_multiplicity (const unsigned int index) const +{ + return base_to_block_indices.block_size(index); +} + + + template inline unsigned int @@ -2723,10 +2743,7 @@ inline unsigned int FiniteElement::first_block_of_base (const unsigned int index) const { - Assert(index < first_block_of_base_table.size(), - ExcIndexRange(index, 0, first_block_of_base_table.size())); - - return first_block_of_base_table[index]; + return base_to_block_indices.block_start(index); } @@ -2749,15 +2766,7 @@ inline std::pair FiniteElement::block_to_base_index (const unsigned int index) const { - Assert(index < this->n_blocks(), - ExcIndexRange(index, 0, this->n_blocks())); - - for (int i=first_block_of_base_table.size()-1; i>=0; --i) - if (first_block_of_base_table[i] <= index) - return std::pair(static_cast (i), - index - first_block_of_base_table[i]); - return std::make_pair(numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int); + return base_to_block_indices.global_to_local(index); } diff --git a/deal.II/include/deal.II/fe/fe_abf.h b/deal.II/include/deal.II/fe/fe_abf.h index 90a58ee933..46a4e73af0 100644 --- a/deal.II/include/deal.II/fe/fe_abf.h +++ b/deal.II/include/deal.II/fe/fe_abf.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -113,35 +113,6 @@ class FE_ABF : public FE_PolyTensor, dim> * values. */ virtual std::string get_name () const; - - - /** - * Number of base elements in a - * mixed discretization. Here, - * this is of course equal to - * one. - */ - virtual unsigned int n_base_elements () const; - - /** - * Access to base element - * objects. Since this element is - * atomic, base_element(0) is - * @p this, and all other - * indices throw an error. - */ - virtual const FiniteElement & - base_element (const unsigned int index) const; - - /** - * Multiplicity of base element - * @p index. Since this is an - * atomic element, - * element_multiplicity(0) - * returns one, and all other - * indices will throw an error. - */ - virtual unsigned int element_multiplicity (const unsigned int index) const; /** * Check whether a shape function diff --git a/deal.II/include/deal.II/fe/fe_base.h b/deal.II/include/deal.II/fe/fe_base.h index aa0b4e4566..4d63b986eb 100644 --- a/deal.II/include/deal.II/fe/fe_base.h +++ b/deal.II/include/deal.II/fe/fe_base.h @@ -392,19 +392,7 @@ class FiniteElementData * base element. */ const unsigned int components; - /** - * The number of vector blocks a - * BlockVector for this element - * should contain. For primitive - * elements, this is equal to - * #components, but for vector - * valued base elements it may - * differ. Actually, in systems - * this is the sum of the base - * element multiplicities. - */ - const unsigned int blocks; - + /** * Maximal polynomial degree of a * shape function in a single @@ -417,6 +405,17 @@ class FiniteElementData */ const Conformity conforming_space; + /** + * Storage for an object + * describing the sizes of each + * block of a compound + * element. For an element which + * is not an FESystem, this + * contains only a single block + * with length #dofs_per_cell. + */ + BlockIndices block_indices_data; + /** * Default * constructor. Constructs an @@ -449,8 +448,7 @@ class FiniteElementData * @param conformity The finite * element space has continuity * of this Sobolev space. - * @param n_blocks Number of - * vector blocks. + * @param n_blocks obsolete and ignored. */ FiniteElementData (const std::vector &dofs_per_object, const unsigned int n_components, @@ -529,6 +527,11 @@ class FiniteElementData */ unsigned int n_blocks () const; + /** + * Detailed infromation on block sizes. + */ + const BlockIndices& block_indices() const; + /** * Return whether the entire * finite element is primitive, @@ -830,12 +833,22 @@ FiniteElementData::set_primitivity (const bool value) } +template +inline +const BlockIndices& +FiniteElementData::block_indices () const +{ + return block_indices_data; +} + + + template inline unsigned int FiniteElementData::n_blocks () const { - return blocks; + return block_indices_data.size(); } diff --git a/deal.II/include/deal.II/fe/fe_dgp_nonparametric.h b/deal.II/include/deal.II/fe/fe_dgp_nonparametric.h index 3fc60d425b..5047392faf 100644 --- a/deal.II/include/deal.II/fe/fe_dgp_nonparametric.h +++ b/deal.II/include/deal.II/fe/fe_dgp_nonparametric.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2010 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -180,34 +180,6 @@ class FE_DGPNonparametric : public FiniteElement * constructor. */ unsigned int get_degree () const; - - /** - * Number of base elements in a - * mixed discretization. Since - * this is a scalar element, - * return one. - */ - virtual unsigned int n_base_elements () const; - - /** - * Access to base element - * objects. Since this element is - * scalar, base_element(0) is - * @p this, and all other - * indices throw an error. - */ - virtual const FiniteElement & - base_element (const unsigned int index) const; - - /** - * Multiplicity of base element - * @p index. Since this is a - * scalar element, - * element_multiplicity(0) - * returns one, and all other - * indices will throw an error. - */ - virtual unsigned int element_multiplicity (const unsigned int index) const; /** * Return the matrix diff --git a/deal.II/include/deal.II/fe/fe_nothing.h b/deal.II/include/deal.II/fe/fe_nothing.h index f34d8ec7c7..39ebbd2aa8 100644 --- a/deal.II/include/deal.II/fe/fe_nothing.h +++ b/deal.II/include/deal.II/fe/fe_nothing.h @@ -105,41 +105,7 @@ class FE_Nothing : public FiniteElement virtual std::string get_name() const; - - /** - * Number of base elements in a - * mixed discretization. In this case - * we only have one. - */ - virtual - unsigned int - n_base_elements () const; - /** - * Access to base element - * objects. Since the element is - * scalar, then - * base_element(0) is - * @p this. - */ - virtual - const FiniteElement & - base_element (const unsigned int index) const; - - /** - * This index denotes how often - * the base element @p index is - * used in a composed element. If - * the element is scalar, then - * the result is always equal to - * one. See the documentation for - * the n_base_elements() - * function for more details. - */ - virtual - unsigned int - element_multiplicity (const unsigned int index) const; - /** * Determine the values a finite * element should compute on diff --git a/deal.II/include/deal.II/fe/fe_poly.h b/deal.II/include/deal.II/fe/fe_poly.h index 5baf05488b..b5a44dce4a 100644 --- a/deal.II/include/deal.II/fe/fe_poly.h +++ b/deal.II/include/deal.II/fe/fe_poly.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -177,38 +177,7 @@ class FE_Poly : public FiniteElement */ virtual Tensor<2,dim> shape_grad_grad_component (const unsigned int i, const Point &p, - const unsigned int component) const; - - /** - * Number of base elements in a - * mixed discretization. Since - * this is a scalar element, - * return one. - */ - virtual unsigned int n_base_elements () const; - - /** - * Access to base element - * objects. Since this element is - * scalar, - * base_element(0) is - * this, and all other - * indices throw an error. - */ - virtual const FiniteElement & - base_element (const unsigned int index) const; - - /** - * Multiplicity of base element - * index. Since this is - * a scalar element, - * element_multiplicity(0) - * returns one, and all other - * indices will throw an error. - */ - virtual unsigned int element_multiplicity (const unsigned int index) const; - - + const unsigned int component) const; protected: virtual diff --git a/deal.II/include/deal.II/fe/fe_poly.templates.h b/deal.II/include/deal.II/fe/fe_poly.templates.h index 60c62025c8..f24c672e14 100644 --- a/deal.II/include/deal.II/fe/fe_poly.templates.h +++ b/deal.II/include/deal.II/fe/fe_poly.templates.h @@ -622,34 +622,4 @@ FE_Poly::fill_fe_subface_values (const Mapping this->compute_2nd (mapping, cell, offset, mapping_data, fe_data, data); } - - -template -unsigned int -FE_Poly::n_base_elements () const -{ - return 1; -} - - - -template -const FiniteElement & -FE_Poly::base_element (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return *this; -} - - - -template -unsigned int -FE_Poly::element_multiplicity (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return 1; -} - - DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/include/deal.II/fe/fe_poly_face.h b/deal.II/include/deal.II/fe/fe_poly_face.h index 1a3f3ad72d..81ae307bbf 100644 --- a/deal.II/include/deal.II/fe/fe_poly_face.h +++ b/deal.II/include/deal.II/fe/fe_poly_face.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2009, 2010 by the deal.II authors +// Copyright (C) 2009, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -169,36 +169,6 @@ class FE_PolyFace : public FiniteElement // virtual Tensor<2,dim> shape_grad_grad_component (const unsigned int i, // const Point &p, // const unsigned int component) const; - - /** - * Number of base elements in a - * mixed discretization. Since - * this is a scalar element, - * return one. - */ - virtual unsigned int n_base_elements () const; - - /** - * Access to base element - * objects. Since this element is - * scalar, - * base_element(0) is - * this, and all other - * indices throw an error. - */ - virtual const FiniteElement & - base_element (const unsigned int index) const; - - /** - * Multiplicity of base element - * index. Since this is - * a scalar element, - * element_multiplicity(0) - * returns one, and all other - * indices will throw an error. - */ - virtual unsigned int element_multiplicity (const unsigned int index) const; - protected: diff --git a/deal.II/include/deal.II/fe/fe_poly_face.templates.h b/deal.II/include/deal.II/fe/fe_poly_face.templates.h index edc9cdcab0..8ffc3b9897 100644 --- a/deal.II/include/deal.II/fe/fe_poly_face.templates.h +++ b/deal.II/include/deal.II/fe/fe_poly_face.templates.h @@ -254,34 +254,4 @@ FE_PolyFace::fill_fe_subface_values ( Assert (!(flags & update_hessians), ExcNotImplemented()); } - - -template -unsigned int -FE_PolyFace::n_base_elements () const -{ - return 1; -} - - - -template -const FiniteElement & -FE_PolyFace::base_element (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return *this; -} - - - -template -unsigned int -FE_PolyFace::element_multiplicity (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return 1; -} - - DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/include/deal.II/fe/fe_poly_tensor.h b/deal.II/include/deal.II/fe/fe_poly_tensor.h index c422702528..e4cb56b408 100644 --- a/deal.II/include/deal.II/fe/fe_poly_tensor.h +++ b/deal.II/include/deal.II/fe/fe_poly_tensor.h @@ -162,36 +162,7 @@ class FE_PolyTensor : public FiniteElement virtual Tensor<2,dim> shape_grad_grad_component (const unsigned int i, const Point &p, const unsigned int component) const; - - /** - * Number of base elements in a - * mixed discretization. Since - * this is not a composed element, - * return one. - */ - virtual unsigned int n_base_elements () const; - /** - * Access to base element - * objects. Since this element is - * not composed of several elements, - * base_element(0) is - * this, and all other - * indices throw an error. - */ - virtual const FiniteElement & - base_element (const unsigned int index) const; - - /** - * Multiplicity of base element - * index. Since this is - * not a composed element, - * element_multiplicity(0) - * returns one, and all other - * indices will throw an error. - */ - virtual unsigned int element_multiplicity (const unsigned int index) const; - /** * Given flags, * determines the values which diff --git a/deal.II/include/deal.II/fe/fe_system.h b/deal.II/include/deal.II/fe/fe_system.h index 839d11996f..38c7109688 100644 --- a/deal.II/include/deal.II/fe/fe_system.h +++ b/deal.II/include/deal.II/fe/fe_system.h @@ -424,26 +424,7 @@ class FESystem : public FiniteElement virtual void get_interpolation_matrix (const FiniteElement &source, FullMatrix &matrix) const; - - /** - * Number of different base - * elements of this object. - * - * Since these objects can have - * multiplicity and subobjects - * themselves, this may be - * smaller than the total number - * of finite elements composed - * into this structure. - */ - virtual unsigned int n_base_elements () const; - - /** - * How often is a composing - * element used. - */ - virtual unsigned int element_multiplicity (const unsigned int index) const; - + /** * Access to a composing * element. The index needs to be diff --git a/deal.II/source/fe/fe.cc b/deal.II/source/fe/fe.cc index 7b632cb9cc..a61a2cb5de 100644 --- a/deal.II/source/fe/fe.cc +++ b/deal.II/source/fe/fe.cc @@ -204,7 +204,7 @@ FiniteElement::FiniteElement ( // Fill with default value; may be // changed by constructor of // derived class. - first_block_of_base_table.resize(1,0); + base_to_block_indices.reinit(1,1); // initialize the restriction and // prolongation matrices. the default @@ -1150,6 +1150,9 @@ const FiniteElement& FiniteElement::base_element(const unsigned index) const { Assert (index==0, ExcIndexRange(index,0,1)); + // This function should not be + // called for a system element + Assert (base_to_block_indices.size() == 1, ExcInternalError()); return *this; } diff --git a/deal.II/source/fe/fe_abf.cc b/deal.II/source/fe/fe_abf.cc index ffc5a3ee8c..9b9a7a29c8 100644 --- a/deal.II/source/fe/fe_abf.cc +++ b/deal.II/source/fe/fe_abf.cc @@ -511,38 +511,6 @@ FE_ABF::update_each (const UpdateFlags flags) const // Data field initialization //--------------------------------------------------------------------------- - - - -template -unsigned int -FE_ABF::n_base_elements () const -{ - return 1; -} - - - -template -const FiniteElement & -FE_ABF::base_element (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return *this; -} - - - -template -unsigned int -FE_ABF::element_multiplicity (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return 1; -} - - - template bool FE_ABF::has_support_on_face (const unsigned int shape_index, diff --git a/deal.II/source/fe/fe_data.cc b/deal.II/source/fe/fe_data.cc index 0e7c26927d..edf723fa41 100644 --- a/deal.II/source/fe/fe_data.cc +++ b/deal.II/source/fe/fe_data.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -32,7 +32,6 @@ FiniteElementData::FiniteElementData () dofs_per_face(0), dofs_per_cell (0), components(0), - blocks(0), degree(0), conforming_space(unknown), cached_primitivity(false) @@ -46,7 +45,7 @@ FiniteElementData (const std::vector &dofs_per_object, const unsigned int n_components, const unsigned int degree, const Conformity conformity, - const unsigned int n_blocks) + const unsigned int) : dofs_per_vertex(dofs_per_object[0]), dofs_per_line(dofs_per_object[1]), @@ -77,10 +76,9 @@ FiniteElementData (const std::vector &dofs_per_object, GeometryInfo::quads_per_cell * dofs_per_quad + GeometryInfo::hexes_per_cell * dofs_per_hex), components(n_components), - blocks(n_blocks == numbers::invalid_unsigned_int - ? n_components : n_blocks), degree(degree), - conforming_space(conformity) + conforming_space(conformity), + block_indices_data(1, dofs_per_cell) { Assert(dofs_per_object.size()==dim+1, ExcDimensionMismatch(dofs_per_object.size()-1,dim)); } diff --git a/deal.II/source/fe/fe_dgp_nonparametric.cc b/deal.II/source/fe/fe_dgp_nonparametric.cc index 392d83c5e2..1df24ade4d 100644 --- a/deal.II/source/fe/fe_dgp_nonparametric.cc +++ b/deal.II/source/fe/fe_dgp_nonparametric.cc @@ -413,35 +413,6 @@ FE_DGPNonparametric::fill_fe_subface_values ( -template -unsigned int -FE_DGPNonparametric::n_base_elements () const -{ - return 1; -} - - - -template -const FiniteElement & -FE_DGPNonparametric::base_element (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return *this; -} - - - -template -unsigned int -FE_DGPNonparametric::element_multiplicity (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return 1; -} - - - template void FE_DGPNonparametric:: diff --git a/deal.II/source/fe/fe_nothing.cc b/deal.II/source/fe/fe_nothing.cc index 0c109f8d88..8b5d72c909 100644 --- a/deal.II/source/fe/fe_nothing.cc +++ b/deal.II/source/fe/fe_nothing.cc @@ -59,35 +59,6 @@ FE_Nothing::get_name () const -template -unsigned int -FE_Nothing::n_base_elements () const -{ - return 1; -} - - - -template -const FiniteElement & -FE_Nothing::base_element (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return *this; -} - - - -template -unsigned int -FE_Nothing::element_multiplicity (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return 1; -} - - - template UpdateFlags FE_Nothing::update_once (const UpdateFlags /*flags*/) const diff --git a/deal.II/source/fe/fe_poly_tensor.cc b/deal.II/source/fe/fe_poly_tensor.cc index 6fb07c5602..f3de047eb8 100644 --- a/deal.II/source/fe/fe_poly_tensor.cc +++ b/deal.II/source/fe/fe_poly_tensor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -969,34 +969,6 @@ FE_PolyTensor::fill_fe_subface_values ( -template -unsigned int -FE_PolyTensor::n_base_elements () const -{ - return 1; -} - - - -template -const FiniteElement & -FE_PolyTensor::base_element (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return *this; -} - - - -template -unsigned int -FE_PolyTensor::element_multiplicity (const unsigned int index) const -{ - Assert (index==0, ExcIndexRange(index, 0, 1)); - return 1; -} - - template UpdateFlags FE_PolyTensor::update_once (const UpdateFlags flags) const diff --git a/deal.II/source/fe/fe_system.cc b/deal.II/source/fe/fe_system.cc index 1f063c86a5..9f3caf63ac 100644 --- a/deal.II/source/fe/fe_system.cc +++ b/deal.II/source/fe/fe_system.cc @@ -154,6 +154,8 @@ FESystem::FESystem (const FiniteElement &fe, compute_nonzero_components(fe, n_elements)), base_elements(1) { + this->base_to_block_indices.reinit(0, 0); + this->base_to_block_indices.push_back(n_elements); base_elements[0] = ElementPair(fe.clone(), n_elements); base_elements[0].first->subscribe (typeid(*this).name()); initialize (); @@ -173,11 +175,13 @@ FESystem::FESystem (const FiniteElement &fe1, fe2, n2)), base_elements(2) { + this->base_to_block_indices.reinit(0, 0); + this->base_to_block_indices.push_back(n1); + this->base_to_block_indices.push_back(n2); base_elements[0] = ElementPair(fe1.clone(), n1); base_elements[0].first->subscribe (typeid(*this).name()); base_elements[1] = ElementPair(fe2.clone(), n2); base_elements[1].first->subscribe (typeid(*this).name()); - this->first_block_of_base_table.push_back(n1); initialize (); } @@ -201,14 +205,16 @@ FESystem::FESystem (const FiniteElement &fe1, fe3, n3)), base_elements(3) { + this->base_to_block_indices.reinit(0, 0); + this->base_to_block_indices.push_back(n1); + this->base_to_block_indices.push_back(n2); + this->base_to_block_indices.push_back(n3); base_elements[0] = ElementPair(fe1.clone(), n1); base_elements[0].first->subscribe (typeid(*this).name()); base_elements[1] = ElementPair(fe2.clone(), n2); base_elements[1].first->subscribe (typeid(*this).name()); base_elements[2] = ElementPair(fe3.clone(), n3); base_elements[2].first->subscribe (typeid(*this).name()); - this->first_block_of_base_table.push_back(n1); - this->first_block_of_base_table.push_back(n1+n2); initialize (); } @@ -236,6 +242,11 @@ FESystem::FESystem (const FiniteElement &fe1, fe4 ,n4)), base_elements(4) { + this->base_to_block_indices.reinit(0, 0); + this->base_to_block_indices.push_back(n1); + this->base_to_block_indices.push_back(n2); + this->base_to_block_indices.push_back(n3); + this->base_to_block_indices.push_back(n4); base_elements[0] = ElementPair(fe1.clone(), n1); base_elements[0].first->subscribe (typeid(*this).name()); base_elements[1] = ElementPair(fe2.clone(), n2); @@ -244,9 +255,6 @@ FESystem::FESystem (const FiniteElement &fe1, base_elements[2].first->subscribe (typeid(*this).name()); base_elements[3] = ElementPair(fe4.clone(), n4); base_elements[3].first->subscribe (typeid(*this).name()); - this->first_block_of_base_table.push_back(n1); - this->first_block_of_base_table.push_back(n1+n2); - this->first_block_of_base_table.push_back(n1+n2+n3); initialize (); } @@ -278,6 +286,13 @@ FESystem::FESystem (const FiniteElement &fe1, fe5, n5)), base_elements(5) { + this->base_to_block_indices.reinit(0, 0); + this->base_to_block_indices.push_back(n1); + this->base_to_block_indices.push_back(n2); + this->base_to_block_indices.push_back(n3); + this->base_to_block_indices.push_back(n4); + this->base_to_block_indices.push_back(n5); + base_elements[0] = ElementPair(fe1.clone(), n1); base_elements[0].first->subscribe (typeid(*this).name()); base_elements[1] = ElementPair(fe2.clone(), n2); @@ -288,10 +303,6 @@ FESystem::FESystem (const FiniteElement &fe1, base_elements[3].first->subscribe (typeid(*this).name()); base_elements[4] = ElementPair(fe5.clone(), n5); base_elements[4].first->subscribe (typeid(*this).name()); - this->first_block_of_base_table.push_back(n1); - this->first_block_of_base_table.push_back(n1+n2); - this->first_block_of_base_table.push_back(n1+n2+n3); - this->first_block_of_base_table.push_back(n1+n2+n3+n4); initialize (); } @@ -325,12 +336,12 @@ FESystem::get_name () const std::ostringstream namebuf; namebuf << "FESystem<" << dim << ">["; - for (unsigned int i=0; in_base_elements(); ++i) { namebuf << base_element(i).get_name(); - if (element_multiplicity(i) != 1) - namebuf << '^' << element_multiplicity(i); - if (i != n_base_elements()-1) + if (this->element_multiplicity(i) != 1) + namebuf << '^' << this->element_multiplicity(i); + if (i != this->n_base_elements()-1) namebuf << '-'; } namebuf << ']'; @@ -344,43 +355,43 @@ template FiniteElement* FESystem::clone() const { - switch (n_base_elements()) + switch (this->n_base_elements()) { case 1: return new FESystem(base_element(0), - element_multiplicity(0)); + this->element_multiplicity(0)); case 2: return new FESystem(base_element(0), - element_multiplicity(0), + this->element_multiplicity(0), base_element(1), - element_multiplicity(1)); + this->element_multiplicity(1)); case 3: return new FESystem(base_element(0), - element_multiplicity(0), + this->element_multiplicity(0), base_element(1), - element_multiplicity(1), + this->element_multiplicity(1), base_element(2), - element_multiplicity(2)); + this->element_multiplicity(2)); case 4: return new FESystem(base_element(0), - element_multiplicity(0), + this->element_multiplicity(0), base_element(1), - element_multiplicity(1), + this->element_multiplicity(1), base_element(2), - element_multiplicity(2), + this->element_multiplicity(2), base_element(3), - element_multiplicity(3)); + this->element_multiplicity(3)); case 5: return new FESystem(base_element(0), - element_multiplicity(0), + this->element_multiplicity(0), base_element(1), - element_multiplicity(1), + this->element_multiplicity(1), base_element(2), - element_multiplicity(2), + this->element_multiplicity(2), base_element(3), - element_multiplicity(3), + this->element_multiplicity(3), base_element(4), - element_multiplicity(4)); + this->element_multiplicity(4)); default: Assert(false, ExcNotImplemented()); } @@ -547,9 +558,9 @@ FESystem::shape_grad_grad_component (const unsigned int i, template void -FESystem:: -get_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const +FESystem::get_interpolation_matrix ( + const FiniteElement &x_source_fe, + FullMatrix &interpolation_matrix) const { Assert (interpolation_matrix.m() == this->dofs_per_cell, ExcDimensionMismatch (interpolation_matrix.m(), @@ -579,14 +590,14 @@ get_interpolation_matrix (const FiniteElement &x_source_fe, // condition 2: same number of // basis elements - AssertThrow (n_base_elements() == source_fe.n_base_elements(), + AssertThrow (this->n_base_elements() == source_fe.n_base_elements(), typename FEL:: ExcInterpolationNotImplemented()); // condition 3: same number of // basis elements - for (unsigned int i=0; in_base_elements(); ++i) + AssertThrow (this->element_multiplicity(i) == source_fe.element_multiplicity(i), typename FEL:: ExcInterpolationNotImplemented()); @@ -604,8 +615,8 @@ get_interpolation_matrix (const FiniteElement &x_source_fe, // continuing and assembling the // one big matrix from the small // ones of the base elements - std::vector > base_matrices (n_base_elements()); - for (unsigned int i=0; i > base_matrices (this->n_base_elements()); + for (unsigned int i=0; in_base_elements(); ++i) { base_matrices[i].reinit (base_element(i).dofs_per_cell, source_fe.base_element(i).dofs_per_cell); @@ -644,7 +655,7 @@ FESystem::update_once (const UpdateFlags flags) const UpdateFlags out = update_default; // generate maximal set of flags // that are necessary - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) out |= base_element(base_no).update_once(flags); return out; } @@ -658,7 +669,7 @@ FESystem::update_each (const UpdateFlags flags) const UpdateFlags out = update_default; // generate maximal set of flags // that are necessary - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) out |= base_element(base_no).update_each(flags); // second derivatives are handled @@ -685,7 +696,7 @@ FESystem::get_data (const UpdateFlags flags_, const Quadrature &quadrature) const { UpdateFlags flags = flags_; - InternalData* data = new InternalData(n_base_elements()); + InternalData* data = new InternalData(this->n_base_elements()); data->update_once = update_once (flags); data->update_each = update_each (flags); @@ -708,7 +719,7 @@ FESystem::get_data (const UpdateFlags flags_, // get data objects from each of // the base elements and store them - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { typename Mapping::InternalDataBase *base_fe_data_base = base_element(base_no).get_data(sub_flags, mapping, quadrature); @@ -772,7 +783,7 @@ FESystem::get_face_data ( const Quadrature &quadrature) const { UpdateFlags flags = flags_; - InternalData* data = new InternalData(n_base_elements()); + InternalData* data = new InternalData(this->n_base_elements()); data->update_once = update_once (flags); data->update_each = update_each (flags); @@ -786,7 +797,7 @@ FESystem::get_face_data ( data->initialize_2nd (this, mapping, QProjector::project_to_all_faces(quadrature)); } - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { typename Mapping::InternalDataBase *base_fe_data_base = base_element(base_no).get_face_data(sub_flags, mapping, quadrature); @@ -824,7 +835,7 @@ FESystem::get_subface_data ( const Quadrature &quadrature) const { UpdateFlags flags = flags_; - InternalData* data = new InternalData(n_base_elements()); + InternalData* data = new InternalData(this->n_base_elements()); data->update_once = update_once (flags); data->update_each = update_each (flags); @@ -838,7 +849,7 @@ FESystem::get_subface_data ( data->initialize_2nd (this, mapping, QProjector::project_to_all_subfaces(quadrature)); } - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { typename Mapping::InternalDataBase *base_fe_data_base = base_element(base_no).get_subface_data(sub_flags, mapping, quadrature); @@ -884,14 +895,14 @@ FESystem::fill_fe_values ( template void -FESystem:: -fill_fe_face_values (const Mapping &mapping, - const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const Quadrature &quadrature, - typename Mapping::InternalDataBase &mapping_data, - typename Mapping::InternalDataBase &fe_data, - FEValuesData &data) const +FESystem::fill_fe_face_values ( + const Mapping &mapping, + const typename Triangulation::cell_iterator &cell, + const unsigned int face_no, + const Quadrature &quadrature, + typename Mapping::InternalDataBase &mapping_data, + typename Mapping::InternalDataBase &fe_data, + FEValuesData &data) const { compute_fill (mapping, cell, face_no, invalid_face_number, quadrature, CellSimilarity::none, mapping_data, fe_data, data); @@ -968,7 +979,7 @@ FESystem::compute_fill ( // (and: how should it know // of their existence, // after all). - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { // Pointer needed to get // the update flags of the @@ -1041,7 +1052,7 @@ FESystem::compute_fill ( // let base elements update the // necessary data - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { const FiniteElement & base_fe = base_element(base_no); @@ -1233,14 +1244,19 @@ FESystem::build_cell_tables() this->face_system_to_component_table.resize(this->dofs_per_face); unsigned total_index = 0; - for (unsigned int base=0; base < n_base_elements(); ++base) - for (unsigned int m = 0; m < element_multiplicity(base); ++m) - for (unsigned int k=0; kcomponent_to_base_table[total_index++] - = std::make_pair(std::make_pair(base,k), m); + this->block_indices_data.reinit(0,0); + + for (unsigned int base=0; base < this->n_base_elements(); ++base) + for (unsigned int m = 0; m < this->element_multiplicity(base); ++m) + { + this->block_indices_data.push_back(base_element(base).dofs_per_cell); + for (unsigned int k=0; kcomponent_to_base_table[total_index++] + = std::make_pair(std::make_pair(base,k), m); + } Assert (total_index == this->component_to_base_table.size(), ExcInternalError()); - + // Initialize index tables. // Multi-component base elements // have to be thought of. For @@ -1261,8 +1277,8 @@ FESystem::build_cell_tables() ++vertex_number) { unsigned comp_start = 0; - for(unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); ++m, comp_start+=base_element(base).n_components()) for (unsigned int local_index = 0; local_index < base_element(base).dofs_per_vertex; @@ -1298,8 +1314,8 @@ FESystem::build_cell_tables() ++line_number) { unsigned comp_start = 0; - for (unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); ++m, comp_start+=base_element(base).n_components()) for (unsigned int local_index = 0; local_index < base_element(base).dofs_per_line; @@ -1336,8 +1352,8 @@ FESystem::build_cell_tables() ++quad_number) { unsigned int comp_start = 0; - for (unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); ++m, comp_start += base_element(base).n_components()) for (unsigned int local_index = 0; local_index < base_element(base).dofs_per_quad; @@ -1374,8 +1390,8 @@ FESystem::build_cell_tables() ++hex_number) { unsigned int comp_start = 0; - for(unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); ++m, comp_start+=base_element(base).n_components()) for (unsigned int local_index = 0; local_index < base_element(base).dofs_per_hex; @@ -1431,8 +1447,8 @@ FESystem::build_face_tables() ++vertex_number) { unsigned int comp_start = 0; - for(unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); ++m, comp_start += base_element(base).n_components()) for (unsigned int local_index = 0; local_index < base_element(base).dofs_per_vertex; @@ -1497,8 +1513,8 @@ FESystem::build_face_tables() ++line_number) { unsigned comp_start = 0; - for(unsigned base = 0; base < n_base_elements(); ++base) - for (unsigned m=0; mn_base_elements(); ++base) + for (unsigned m=0; melement_multiplicity(base); ++m, comp_start += base_element(base).n_components()) for (unsigned local_index = 0; local_index < base_element(base).dofs_per_line; @@ -1543,8 +1559,8 @@ FESystem::build_face_tables() ++quad_number) { unsigned comp_start = 0; - for(unsigned base=0; basen_base_elements(); ++base) + for (unsigned m=0; melement_multiplicity(base); ++m, comp_start += base_element(base).n_components()) for (unsigned local_index = 0; local_index < base_element(base).dofs_per_quad; @@ -1601,7 +1617,7 @@ void FESystem::build_interface_constraints () // composed element empty as well; // however, the rest of the element // is usable - for (unsigned int base=0; basen_base_elements(); ++base) if (base_element(base).constraints_are_implemented() == false) return; @@ -1872,7 +1888,7 @@ void FESystem::initialize () bool do_restriction = true; bool do_prolongation = true; - for (unsigned int i=0; in_base_elements(); ++i) { if (base_element(i).restriction[ref_case-1][0].n() == 0) do_restriction = false; @@ -2004,7 +2020,7 @@ initialize_unit_support_points () // an empty array to // demonstrate that // fact - for (unsigned int base_el=0; base_eln_base_elements(); ++base_el) if (!base_element(base_el).has_support_points()) { this->unit_support_points.resize(0); @@ -2021,7 +2037,7 @@ initialize_unit_support_points () const unsigned int base = this->system_to_base_table[i].first.first, base_index = this->system_to_base_table[i].second; - Assert (basen_base_elements(), ExcInternalError()); Assert (base_indexunit_support_points[i] = base_element(base).unit_support_points[base_index]; @@ -2055,7 +2071,7 @@ initialize_unit_face_support_points () // or not. this is, for example, the case // for the stable Stokes element Q(p)^dim // \times DGP(p-1). - for (unsigned int base_el=0; base_eln_base_elements(); ++base_el) if (!base_element(base_el).has_support_points() && (base_element(base_el).dofs_per_face > 0)) @@ -2102,11 +2118,11 @@ FESystem::initialize_quad_dof_index_permutation () // element, copy the shift information of // the base elements unsigned int index = 0; - for (unsigned int b=0; bn_base_elements();++b) { const Table<2,int> &temp = this->base_element(b).adjust_quad_dof_index_for_face_orientation_table; - for (unsigned int c=0; celement_multiplicity(b); ++c) { for (unsigned int i=0; i::initialize_quad_dof_index_permutation () Assert (this->adjust_line_dof_index_for_line_orientation_table.size()== this->dofs_per_line, ExcInternalError()); index = 0; - for (unsigned int b=0; bn_base_elements();++b) { const std::vector &temp2 = this->base_element(b).adjust_line_dof_index_for_line_orientation_table; - for (unsigned int c=0; celement_multiplicity(b); ++c) { std::copy(temp2.begin(), temp2.end(), this->adjust_line_dof_index_for_line_orientation_table.begin() @@ -2146,7 +2162,7 @@ bool FESystem:: hp_constraints_are_implemented () const { - for (unsigned int b=0; bn_base_elements(); ++b) if (base_element(b).hp_constraints_are_implemented() == false) return false; @@ -2247,7 +2263,7 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, // or if have to move on to the // next base element ++multiplicity; - if (multiplicity == element_multiplicity(base_index)) + if (multiplicity == this->element_multiplicity(base_index)) { multiplicity = 0; ++base_index; @@ -2264,7 +2280,7 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, // of the present element. if so, // we should have reached the end // of the other one as well - if (base_index == n_base_elements()) + if (base_index == this->n_base_elements()) { Assert (base_index_other == fe_other_system->n_base_elements(), ExcInternalError()); @@ -2376,7 +2392,7 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe // or if have to move on to the // next base element ++multiplicity; - if (multiplicity == element_multiplicity(base_index)) + if (multiplicity == this->element_multiplicity(base_index)) { multiplicity = 0; ++base_index; @@ -2393,7 +2409,7 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe // of the present element. if so, // we should have reached the end // of the other one as well - if (base_index == n_base_elements()) + if (base_index == this->n_base_elements()) { Assert (base_index_other == fe_other_system->n_base_elements(), ExcInternalError()); @@ -2500,7 +2516,7 @@ FESystem::hp_object_dof_identities (const FiniteElementelement_multiplicity(base_index)) { multiplicity = 0; ++base_index; @@ -2517,7 +2533,7 @@ FESystem::hp_object_dof_identities (const FiniteElementn_base_elements()) { Assert (base_index_other == fe_other_system->n_base_elements(), ExcInternalError()); @@ -3371,26 +3387,6 @@ FESystem::base_element (const unsigned int index) const -template -unsigned int -FESystem::n_base_elements () const -{ - return base_elements.size(); -} - - - -template -unsigned int -FESystem::element_multiplicity (const unsigned int index) const -{ - Assert (index < base_elements.size(), - ExcIndexRange(index, 0, base_elements.size())); - return base_elements[index].second; -} - - - template bool FESystem::has_support_on_face (const unsigned int shape_index, -- 2.39.5