From d302c7a4d4b74d473ef7fb0757b8d0d37c6fe4b1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 23 Jan 2016 12:24:25 -0600 Subject: [PATCH] Initialize the last non-const field of FiniteElementData from constructor arguments. --- include/deal.II/fe/fe_base.h | 12 ++++++++++-- include/deal.II/lac/block_indices.h | 8 ++++---- source/fe/fe_data.cc | 13 +++++++++---- source/fe/fe_system.cc | 21 +++++++++++++++------ 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/include/deal.II/fe/fe_base.h b/include/deal.II/fe/fe_base.h index 1a290d7780..83cacd0061 100644 --- a/include/deal.II/fe/fe_base.h +++ b/include/deal.II/fe/fe_base.h @@ -308,7 +308,7 @@ public: * element. For an element which is not an FESystem, this contains only a * single block with length #dofs_per_cell. */ - BlockIndices block_indices_data; + const BlockIndices block_indices_data; /** * Constructor, computing all necessary values from the distribution of dofs @@ -340,11 +340,19 @@ public: * $H_\text{div}$ conforming; finally, completely discontinuous * elements (implemented by the FE_DGQ class) are only $L_2$ * conforming. + * + * @param[in] block_indices An argument that describes how the base elements + * of a finite element are grouped. The default value constructs a single + * block that consists of all @p dofs_per_cell degrees of freedom. This + * is appropriate for all "atomic" elements (including non-primitive ones) + * and these can therefore omit this argument. On the other hand, composed + * elements such as FESystem will want to pass a different value here. */ FiniteElementData (const std::vector &dofs_per_object, const unsigned int n_components, const unsigned int degree, - const Conformity conformity = unknown); + const Conformity conformity = unknown, + const BlockIndices &block_indices = BlockIndices()); /** * Number of dofs per vertex. diff --git a/include/deal.II/lac/block_indices.h b/include/deal.II/lac/block_indices.h index 7f4f715604..d6227fd242 100644 --- a/include/deal.II/lac/block_indices.h +++ b/include/deal.II/lac/block_indices.h @@ -74,7 +74,8 @@ public: /** * Specialized constructor for a structure with blocks of equal size. */ - explicit BlockIndices(const unsigned int n_blocks, const size_type block_size = 0); + explicit BlockIndices(const unsigned int n_blocks, + const size_type block_size = 0); /** * Reinitialize the number of blocks and assign each block the same number @@ -259,9 +260,8 @@ BlockIndices::BlockIndices () inline -BlockIndices::BlockIndices ( - const unsigned int n_blocks, - const size_type block_size) +BlockIndices::BlockIndices (const unsigned int n_blocks, + const size_type block_size) : n_blocks(n_blocks), start_indices(n_blocks+1) diff --git a/source/fe/fe_data.cc b/source/fe/fe_data.cc index ddcc3173f7..10e2229baa 100644 --- a/source/fe/fe_data.cc +++ b/source/fe/fe_data.cc @@ -21,9 +21,10 @@ DEAL_II_NAMESPACE_OPEN template FiniteElementData:: FiniteElementData (const std::vector &dofs_per_object, - const unsigned int n_components, - const unsigned int degree, - const Conformity conformity) + const unsigned int n_components, + const unsigned int degree, + const Conformity conformity, + const BlockIndices &block_indices) : dofs_per_vertex(dofs_per_object[0]), dofs_per_line(dofs_per_object[1]), @@ -56,7 +57,11 @@ FiniteElementData (const std::vector &dofs_per_object, components(n_components), degree(degree), conforming_space(conformity), - block_indices_data(1, dofs_per_cell) + block_indices_data(block_indices.size() == 0 + ? + BlockIndices(1, dofs_per_cell) + : + block_indices) { Assert(dofs_per_object.size()==dim+1, ExcDimensionMismatch(dofs_per_object.size()-1,dim)); } diff --git a/source/fe/fe_system.cc b/source/fe/fe_system.cc index aefbfa6849..c9e5c34c04 100644 --- a/source/fe/fe_system.cc +++ b/source/fe/fe_system.cc @@ -123,7 +123,7 @@ namespace multiply_dof_numbers (const std::vector*> &fes, const std::vector &multiplicities) { - Assert (fes.size() == multiplicities.size(), ExcDimensionMismatch (fes.size(), multiplicities.size())); + AssertDimension(fes.size(), multiplicities.size()); unsigned int multiplied_dofs_per_vertex = 0; unsigned int multiplied_dofs_per_line = 0; @@ -175,10 +175,17 @@ namespace if (dim>1) dpo.push_back(multiplied_dofs_per_quad); if (dim>2) dpo.push_back(multiplied_dofs_per_hex); + BlockIndices block_indices (0,0); + + for (unsigned int base=0; base < fes.size(); ++base) + for (unsigned int m = 0; m < multiplicities[base]; ++m) + block_indices.push_back(fes[base]->dofs_per_cell); + return FiniteElementData (dpo, multiplied_n_components, degree, - total_conformity); + total_conformity, + block_indices); } /** @@ -225,7 +232,7 @@ namespace compute_restriction_is_additive_flags (const std::vector*> &fes, const std::vector &multiplicities) { - Assert (fes.size() == multiplicities.size(), ExcInternalError()); + AssertDimension(fes.size(), multiplicities.size()); // first count the number of dofs and components that will emerge from the // given FEs @@ -391,7 +398,7 @@ namespace compute_nonzero_components (const std::vector*> &fes, const std::vector &multiplicities) { - Assert (fes.size() == multiplicities.size(), ExcInternalError()); + AssertDimension(fes.size(), multiplicities.size()); // first count the number of dofs and components that will emerge from the // given FEs @@ -666,6 +673,7 @@ FESystem::FESystem (const FiniteElement &fe1, } + template FESystem::FESystem (const FiniteElement &fe1, const unsigned int n1, @@ -702,6 +710,8 @@ FESystem::FESystem (const FiniteElement &fe1, initialize(fes, multiplicities); } + + template FESystem::FESystem (const FiniteElement &fe1, const unsigned int n1, @@ -761,6 +771,7 @@ FESystem::FESystem ( } + template FESystem::~FESystem () {} @@ -1756,12 +1767,10 @@ FESystem::build_cell_tables() this->face_system_to_component_table.resize(this->dofs_per_face); unsigned int total_index = 0; - 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); -- 2.39.5