]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Unify the constructors of FiniteElementBase to be a template
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 16 Feb 1999 17:31:08 +0000 (17:31 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 16 Feb 1999 17:31:08 +0000 (17:31 +0000)
again. This was not possible before, since the FiniteElementBase
classes were divided.

git-svn-id: https://svn.dealii.org/trunk@821 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/fe/fe.cc

index 90eaa5e2f20e63581ccd6f83b561948b91959be8..366661276d8003448c0130461dc9d758507053a8 100644 (file)
@@ -124,87 +124,44 @@ bool FiniteElementData<dim>::operator== (const FiniteElementData<dim> &f) const
 
 /*------------------------------- FiniteElementBase ----------------------*/
 
-#if deal_II_dimension == 1
 
-template <>
-FiniteElementBase<1>::FiniteElementBase (const FiniteElementData<1> &fe_data) :
-               FiniteElementData<1> (fe_data),
-               system_to_component_table(total_dofs),
-               component_to_system_table(n_components, vector<unsigned>(total_dofs))
-{
-  const unsigned int dim=1;
-  for (unsigned int i=0; i<GeometryInfo<dim>::children_per_cell; ++i) 
-    {
-      restriction[i].reinit (total_dofs, total_dofs);
-      prolongation[i].reinit (total_dofs, total_dofs);
-    };
-  interface_constraints.reinit (1,1);
-  interface_constraints(0,0)=1.;
 
-                                  // this is the default way, if there is only
-                                  // one component; if there are several, then
-                                  // the constructor of the derived class needs
-                                  // to fill these arrays
-  for (unsigned int j=0 ; j<total_dofs ; ++j)
-    {
-      system_to_component_table[j] = pair<unsigned,unsigned>(0,j);
-      component_to_system_table[0][j] = j;
-    }
-};
-
-#endif
-
-
-#if deal_II_dimension == 2
-
-template <>
-FiniteElementBase<2>::FiniteElementBase (const FiniteElementData<2> &fe_data) :
-               FiniteElementData<2> (fe_data),
+template <int dim>
+FiniteElementBase<dim>::FiniteElementBase (const FiniteElementData<dim> &fe_data) :
+               FiniteElementData<dim> (fe_data),
                system_to_component_table(total_dofs),
                component_to_system_table(n_components, vector<unsigned>(total_dofs))
 {
-  const unsigned int dim=2;
   for (unsigned int i=0; i<GeometryInfo<dim>::children_per_cell; ++i) 
     {
       restriction[i].reinit (total_dofs, total_dofs);
       prolongation[i].reinit (total_dofs, total_dofs);
     };
-  interface_constraints.reinit (dofs_per_vertex+2*dofs_per_line,
-                               dofs_per_face);
 
-                                  // this is the default way, if there is only
-                                  // one component; if there are several, then
-                                  // the constructor of the derived class needs
-                                  // to fill these arrays
-  for (unsigned int j=0 ; j<total_dofs ; ++j)
+  switch (dim)
     {
-      system_to_component_table[j] = pair<unsigned,unsigned>(0,j);
-      component_to_system_table[0][j] = j;
-    }
-};
-
-#endif
-
-
-
-#if deal_II_dimension == 3
-
-template <>
-FiniteElementBase<3>::FiniteElementBase (const FiniteElementData<3> &fe_data) :
-               FiniteElementData<3> (fe_data),
-               system_to_component_table(total_dofs),
-               component_to_system_table(n_components, vector<unsigned>(total_dofs))
-{
-  const unsigned int dim=3;
-  for (unsigned int i=0; i<GeometryInfo<dim>::children_per_cell; ++i) 
-    {
-      restriction[i].reinit (total_dofs, total_dofs);
-      prolongation[i].reinit (total_dofs, total_dofs);
+      case 1:
+           interface_constraints.reinit (1,1);
+           interface_constraints(0,0)=1.;
+           break;
+           
+      case 2:
+           interface_constraints.reinit (dofs_per_vertex+2*dofs_per_line,
+                                         dofs_per_face);
+           break;
+
+      case 3:
+           interface_constraints.reinit (5*dofs_per_vertex +
+                                         12*dofs_per_line  +
+                                         4*dofs_per_quad,
+                                         dofs_per_face);
+           break;
+
+      default:
+           Assert (false, ExcNotImplemented());
     };
-  interface_constraints.reinit (5*dofs_per_vertex+12*dofs_per_line+4*dofs_per_quad,
-                               dofs_per_face);
-
-                                  // this is the default way, if there is only
+           
+                                  // this is the default way, if there is only
                                   // one component; if there are several, then
                                   // the constructor of the derived class needs
                                   // to fill these arrays
@@ -215,8 +172,6 @@ FiniteElementBase<3>::FiniteElementBase (const FiniteElementData<3> &fe_data) :
     }
 };
 
-#endif
-
 
 
 template <int dim>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.