From cd9cf5e34302d65cc8af942eb441dc417d1b6a21 Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 7 Mar 2001 17:26:07 +0000 Subject: [PATCH] Move several functions from the .h to the .cc file as they are no longer templated on other types. Minor clean-ups. Fix a bug where the wrong array was resized. Fix a bug where clone would not have worked because of missing 'break's in a switch statement. git-svn-id: https://svn.dealii.org/trunk@4155 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/fe/fe_system.h | 143 +++---------------- deal.II/deal.II/source/fe/fe_system.cc | 190 +++++++++++++++++++++---- 2 files changed, 183 insertions(+), 150 deletions(-) diff --git a/deal.II/deal.II/include/fe/fe_system.h b/deal.II/deal.II/include/fe/fe_system.h index 295ebc4962..54bae219a1 100644 --- a/deal.II/deal.II/include/fe/fe_system.h +++ b/deal.II/deal.II/include/fe/fe_system.h @@ -14,7 +14,7 @@ #define __deal2__fe_system_h -/*---------------------------- fe_lib.system.h ---------------------------*/ +/*---------------------------- fe_system.h ---------------------------*/ #include @@ -194,12 +194,13 @@ class FESystem : public FiniteElement * the @p{cell->get_dof_indices} * function, but: * - * If the shape functions of one - * of the base elements are not - * Lagrangian interpolants at - * some points, the size of the - * array will be zero after - * calling this function. + * If one of the base elements + * has no support points, then it + * makes no sense to define + * support points for the + * composed element, so return an + * empty array to demonstrate + * that fact. */ virtual void get_unit_support_points (typename std::vector > &) const; @@ -572,151 +573,41 @@ class FESystem : public FiniteElement }; -/* ------------------------- template functions ------------------------- */ +/* ------------------------- inline functions ------------------------- */ template inline unsigned int FESystem::n_base_elements() const { return base_elements.size(); -} - - -template -FESystem::FESystem (const FiniteElement &fe, const unsigned int n_elements) : - FiniteElement (multiply_dof_numbers(fe, n_elements), - compute_restriction_is_additive_flags (fe, n_elements)), - base_elements(1) -{ - base_elements[0] = ElementPair(fe.clone(), n_elements); - base_elements[0].first -> subscribe (); - initialize (); }; -template -FESystem::FESystem (const FiniteElement &fe1, const unsigned int n1, - const FiniteElement &fe2, const unsigned int n2) - : - FiniteElement (multiply_dof_numbers(fe1, n1, fe2, n2), - compute_restriction_is_additive_flags (fe1, n1, - fe2, n2)), - base_elements(2) -{ - base_elements[0] = ElementPair(fe1.clone(), n1); - base_elements[0].first -> subscribe (); - base_elements[1] = ElementPair(fe2.clone(), n2); - base_elements[1].first -> subscribe (); - initialize (); -}; - - -template -FESystem::FESystem (const FiniteElement &fe1, const unsigned int n1, - const FiniteElement &fe2, const unsigned int n2, - const FiniteElement &fe3, const unsigned int n3) - : - FiniteElement (multiply_dof_numbers(fe1, n1, - fe2, n2, - fe3, n3), - compute_restriction_is_additive_flags (fe1, n1, - fe2, n2, - fe3, n3)), - base_elements(3) -{ - base_elements[0] = ElementPair(fe1.clone(), n1); - base_elements[0].first -> subscribe (); - base_elements[1] = ElementPair(fe2.clone(), n2); - base_elements[1].first -> subscribe (); - base_elements[2] = ElementPair(fe3.clone(), n3); - base_elements[2].first -> subscribe (); - initialize (); -}; - template inline unsigned int -FESystem::element_multiplicity(unsigned int index) const +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 -inline const FiniteElement& -FESystem::base_element(unsigned int index) const +inline const FiniteElement & +FESystem::base_element (const unsigned int index) const { Assert (index < base_elements.size(), ExcIndexRange(index, 0, base_elements.size())); return *base_elements[index].first; -} - - -template -inline FiniteElementBase::InternalDataBase & -FESystem:: -InternalData::get_fe_data(unsigned int base_no) const -{ - Assert(base_no -inline void -FESystem:: -InternalData::set_fe_data(unsigned int base_no, - FiniteElementBase::InternalDataBase *ptr) -{ - Assert(base_no -inline FEValuesData & -FESystem:: -InternalData::get_fe_values_data(unsigned int base_no) const -{ - Assert(base_no -inline void -FESystem:: -InternalData::set_fe_values_data(unsigned int base_no, - FEValuesData *ptr) -{ - Assert(base_no -inline void -FESystem:: -InternalData::delete_fe_values_data(unsigned int base_no) -{ - Assert(base_no +inline FiniteElementBase::InternalDataBase & +FESystem:: +InternalData::get_fe_data (const unsigned int base_no) const +{ + Assert(base_no +inline void +FESystem:: +InternalData::set_fe_data (const unsigned int base_no, + FiniteElementBase::InternalDataBase *ptr) +{ + Assert(base_no +inline FEValuesData & +FESystem:: +InternalData::get_fe_values_data (const unsigned int base_no) const +{ + Assert(base_no +inline void +FESystem:: +InternalData::set_fe_values_data (const unsigned int base_no, + FEValuesData *ptr) +{ + Assert(base_no +inline void +FESystem:: +InternalData::delete_fe_values_data (const unsigned int base_no) +{ + Assert(base_no +FESystem::FESystem (const FiniteElement &fe, const unsigned int n_elements) : + FiniteElement (multiply_dof_numbers(fe, n_elements), + compute_restriction_is_additive_flags (fe, n_elements)), + base_elements(1) +{ + base_elements[0] = ElementPair(fe.clone(), n_elements); + base_elements[0].first->subscribe (); + initialize (); +}; + + + +template +FESystem::FESystem (const FiniteElement &fe1, const unsigned int n1, + const FiniteElement &fe2, const unsigned int n2) : + FiniteElement (multiply_dof_numbers(fe1, n1, fe2, n2), + compute_restriction_is_additive_flags (fe1, n1, + fe2, n2)), + base_elements(2) +{ + base_elements[0] = ElementPair(fe1.clone(), n1); + base_elements[0].first->subscribe (); + base_elements[1] = ElementPair(fe2.clone(), n2); + base_elements[1].first->subscribe (); + initialize (); +}; + + + +template +FESystem::FESystem (const FiniteElement &fe1, const unsigned int n1, + const FiniteElement &fe2, const unsigned int n2, + const FiniteElement &fe3, const unsigned int n3) : + FiniteElement (multiply_dof_numbers(fe1, n1, + fe2, n2, + fe3, n3), + compute_restriction_is_additive_flags (fe1, n1, + fe2, n2, + fe3, n3)), + base_elements(3) +{ + base_elements[0] = ElementPair(fe1.clone(), n1); + base_elements[0].first->subscribe (); + base_elements[1] = ElementPair(fe2.clone(), n2); + base_elements[1].first->subscribe (); + base_elements[2] = ElementPair(fe3.clone(), n3); + base_elements[2].first->subscribe (); + initialize (); +}; + + template FESystem::~FESystem () { - for (unsigned i=0;i unsubscribe (); + base_elements[i].first->unsubscribe(); delete base_elements[i].first; + base_elements[i].first = 0; } }; + template FiniteElement* FESystem::clone() const { - FiniteElement *fe=0; switch (n_base_elements()) { case 1: - fe=new FESystem(base_element(0), - element_multiplicity(0)); + return new FESystem(base_element(0), + element_multiplicity(0)); case 2: - fe=new FESystem(base_element(0), - element_multiplicity(0), - base_element(1), - element_multiplicity(1)); + return new FESystem(base_element(0), + element_multiplicity(0), + base_element(1), + element_multiplicity(1)); case 3: - fe=new FESystem(base_element(0), - element_multiplicity(0), - base_element(1), - element_multiplicity(1), - base_element(2), - element_multiplicity(2)); + return new FESystem(base_element(0), + element_multiplicity(0), + base_element(1), + element_multiplicity(1), + base_element(2), + element_multiplicity(2)); default: Assert(false, ExcNotImplemented()); } - return fe; + return 0; } + template -void FESystem::get_unit_support_points ( - typename std::vector > &unit_support_points) const +void +FESystem:: +get_unit_support_points (typename std::vector > &unit_support_points) const { + // generate unit support points + // from unit support points of sub + // elements unit_support_points.resize(dofs_per_cell); typename std::vector > base_unit_support_points (base_element(0).dofs_per_cell); unsigned int comp = 0; - for (unsigned int base_el=0 ; base_el