From 338901bfe576dc9e8663ad08c7e37017eacff686 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Fri, 28 Sep 2012 21:56:08 +0000 Subject: [PATCH] simplify more dublicated code in fe_system git-svn-id: https://svn.dealii.org/trunk@26867 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/fe/fe_system.h | 64 ++--------- deal.II/source/fe/fe_system.cc | 150 +++++-------------------- 2 files changed, 38 insertions(+), 176 deletions(-) diff --git a/deal.II/include/deal.II/fe/fe_system.h b/deal.II/include/deal.II/fe/fe_system.h index 939a63ebe4..e36ad3df6c 100644 --- a/deal.II/include/deal.II/fe/fe_system.h +++ b/deal.II/include/deal.II/fe/fe_system.h @@ -914,63 +914,17 @@ class FESystem : public FiniteElement * components of a composed * finite element. */ - static std::vector - compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1); - - /** - * Compute the non-zero vector - * components of a composed - * finite element. - */ - static std::vector - compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2); - - /** - * Compute the non-zero vector - * components of a composed - * finite element. - */ - static std::vector - compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3); - - /** - * Compute the non-zero vector - * components of a composed - * finite element. - */ - static std::vector - compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4); - - /** - * With 5 elements. - */ static std::vector - compute_nonzero_components (const FiniteElement &fe1, + compute_nonzero_components (const FiniteElement *fe1, const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4, - const FiniteElement &fe5, - const unsigned int N5); + const FiniteElement *fe2=NULL, + const unsigned int N2=0, + const FiniteElement *fe3=NULL, + const unsigned int N3=0, + const FiniteElement *fe4=NULL, + const unsigned int N4=0, + const FiniteElement *fe5=NULL, + const unsigned int N5=0); /** * Compute the nonzero components diff --git a/deal.II/source/fe/fe_system.cc b/deal.II/source/fe/fe_system.cc index fd9d131cee..6579fb6cc8 100644 --- a/deal.II/source/fe/fe_system.cc +++ b/deal.II/source/fe/fe_system.cc @@ -161,7 +161,7 @@ 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), - compute_nonzero_components(fe, n_elements)), + compute_nonzero_components(&fe, n_elements)), base_elements((n_elements>0)) { std::vector*> fes; @@ -181,8 +181,8 @@ FESystem::FESystem (const FiniteElement &fe1, FiniteElement (multiply_dof_numbers(&fe1, n1, &fe2, n2), compute_restriction_is_additive_flags (&fe1, n1, &fe2, n2), - compute_nonzero_components(fe1, n1, - fe2, n2)), + compute_nonzero_components(&fe1, n1, + &fe2, n2)), base_elements((n1>0)+(n2>0)) { std::vector*> fes; @@ -209,9 +209,9 @@ FESystem::FESystem (const FiniteElement &fe1, compute_restriction_is_additive_flags (&fe1, n1, &fe2, n2, &fe3, n3), - compute_nonzero_components(fe1, n1, - fe2, n2, - fe3, n3)), + compute_nonzero_components(&fe1, n1, + &fe2, n2, + &fe3, n3)), base_elements((n1>0)+(n2>0)+(n3>0)) { std::vector*> fes; @@ -243,10 +243,10 @@ FESystem::FESystem (const FiniteElement &fe1, &fe2, n2, &fe3, n3, &fe4, n4), - compute_nonzero_components(fe1, n1, - fe2, n2, - fe3, n3, - fe4 ,n4)), + compute_nonzero_components(&fe1, n1, + &fe2, n2, + &fe3, n3, + &fe4 ,n4)), base_elements((n1>0)+(n2>0)+(n3>0)+(n4>0)) { std::vector*> fes; @@ -283,11 +283,11 @@ FESystem::FESystem (const FiniteElement &fe1, &fe3, n3, &fe4, n4, &fe5, n5), - compute_nonzero_components(fe1, n1, - fe2, n2, - fe3, n3, - fe4 ,n4, - fe5, n5)), + compute_nonzero_components(&fe1, n1, + &fe2, n2, + &fe3, n3, + &fe4 ,n4, + &fe5, n5)), base_elements((n1>0)+(n2>0)+(n3>0)+(n4>0)+(n5>0)) { std::vector*> fes; @@ -2886,127 +2886,33 @@ compute_restriction_is_additive_flags (const std::vector std::vector -FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1) -{ - std::vector*> fe_list; - std::vector multiplicities; - - fe_list.push_back (&fe1); - multiplicities.push_back (N1); - - return compute_nonzero_components (fe_list, multiplicities); -} - - - -template -std::vector -FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2) -{ - std::vector*> fe_list; - std::vector multiplicities; - - fe_list.push_back (&fe1); - multiplicities.push_back (N1); - - fe_list.push_back (&fe2); - multiplicities.push_back (N2); - - return compute_nonzero_components (fe_list, multiplicities); -} - - - -template -std::vector -FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3) -{ - std::vector*> fe_list; - std::vector multiplicities; - - fe_list.push_back (&fe1); - multiplicities.push_back (N1); - - fe_list.push_back (&fe2); - multiplicities.push_back (N2); - - fe_list.push_back (&fe3); - multiplicities.push_back (N3); - - return compute_nonzero_components (fe_list, multiplicities); -} - - - -template -std::vector -FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4) -{ - std::vector*> fe_list; - std::vector multiplicities; - - fe_list.push_back (&fe1); - multiplicities.push_back (N1); - - fe_list.push_back (&fe2); - multiplicities.push_back (N2); - - fe_list.push_back (&fe3); - multiplicities.push_back (N3); - - fe_list.push_back (&fe4); - multiplicities.push_back (N4); - - return compute_nonzero_components (fe_list, multiplicities); -} - - - -template -std::vector -FESystem::compute_nonzero_components (const FiniteElement &fe1, +FESystem::compute_nonzero_components (const FiniteElement *fe1, const unsigned int N1, - const FiniteElement &fe2, + const FiniteElement *fe2, const unsigned int N2, - const FiniteElement &fe3, + const FiniteElement *fe3, const unsigned int N3, - const FiniteElement &fe4, + const FiniteElement *fe4, const unsigned int N4, - const FiniteElement &fe5, + const FiniteElement *fe5, const unsigned int N5) { std::vector*> fe_list; std::vector multiplicities; - fe_list.push_back (&fe1); + fe_list.push_back (fe1); multiplicities.push_back (N1); - fe_list.push_back (&fe2); + fe_list.push_back (fe2); multiplicities.push_back (N2); - fe_list.push_back (&fe3); + fe_list.push_back (fe3); multiplicities.push_back (N3); - fe_list.push_back (&fe4); + fe_list.push_back (fe4); multiplicities.push_back (N4); - fe_list.push_back (&fe5); + fe_list.push_back (fe5); multiplicities.push_back (N5); return compute_nonzero_components (fe_list, multiplicities); @@ -3027,11 +2933,13 @@ compute_nonzero_components (const std::vector* // from the given FEs unsigned int n_shape_functions = 0; for (unsigned int i=0; idofs_per_cell * multiplicities[i]; + if (multiplicities[i]>0) //needed because fe might be NULL + n_shape_functions += fes[i]->dofs_per_cell * multiplicities[i]; unsigned int n_components = 0; for (unsigned int i=0; in_components() * multiplicities[i]; + if (multiplicities[i]>0) //needed because fe might be NULL + n_components += fes[i]->n_components() * multiplicities[i]; // generate the array that will // hold the output -- 2.39.5