]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Approaching component tables
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 12 Feb 1999 21:33:03 +0000 (21:33 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 12 Feb 1999 21:33:03 +0000 (21:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@795 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/fe/fe.h
deal.II/deal.II/include/fe/fe_system.h
deal.II/deal.II/source/fe/fe.cc
deal.II/deal.II/source/fe/fe_system.cc

index e4ae48e19810416d7c34853e1054d0bc2c61b993..0579249e6454440642f39b20ddbd59a154a2228d 100644 (file)
@@ -67,7 +67,7 @@ struct FiniteElementData<1> {
                                   /**
                                    * Number of components.
                                    */
-  const unsigned int n_components;
+    const unsigned int n_components;
 
                                     /**
                                      * Default constructor. Constructs an element
@@ -226,7 +226,7 @@ struct FiniteElementData<2> {
  * @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-struct FiniteElementBase :
+class FiniteElementBase :
   public Subscriptor,
   public FiniteElementData<dim>
 
@@ -293,6 +293,10 @@ struct FiniteElementBase :
   
                                     /**
                                      * Compute component and index from system index.
+                                     *
+                                     * Return value contains first
+                                     * component and second index in
+                                     * component.
                                      */
     pair<unsigned,unsigned> system_to_component_index (unsigned index) const; 
     
@@ -471,6 +475,11 @@ struct FiniteElementBase :
                                      * space dimension.
                                      */
     dFMatrix interface_constraints;
+
+                                    /**
+                                     * Map between linear dofs and component dofs.
+                                     */
+    vector< pair<unsigned, unsigned> > system_to_component_table;
 };
 
 
@@ -1164,8 +1173,22 @@ class FiniteElement : public FiniteElementBase<dim> {
     DeclException0 (ExcJacobiDeterminantHasWrongSign);
 };
 
+template <int dim>
+inline unsigned
+FiniteElementBase<dim>::component_to_system_index (unsigned component,
+                                                  unsigned component_index) const
+{
+  Assert(false, ExcNotImplemented());
+  return component_index;
+}
 
-
+template <int dim>  
+inline pair<unsigned,unsigned>
+FiniteElementBase<dim>::system_to_component_index (unsigned index) const
+{
+  Assert(index < system_to_component_table.size(), ExcInvalidIndex(index));
+  return system_to_component_table[index];
+}
 
 /*----------------------------   fe.h     ---------------------------*/
 /* end of #ifndef __fe_H */
index 01651fdfb44ce5550bb392e919be0af897bce5df..df5fa8cbced6c7cc105aadff9dc3a798133d0dbd 100644 (file)
@@ -1,12 +1,13 @@
 /*----------------------------   fe_lib.system.h     ---------------------------*/
 /*      $Id$                 */
-#ifndef __fe_system_H
-#define __fe_system_H
+#ifndef __deal_fe_system_H
+#define __deal_fe_system_H
 /*----------------------------   fe_lib.system.h     ---------------------------*/
 
 
 #include <fe/fe.h>
-
+#include <vector>
+#include <pair.h>
 
 /**
  * This class provides an interface to group several equal elements together
 template <int dim>
 class FESystem : public FiniteElement<dim>
 {
-                                  /**
-                                   * Copy constructor prohibited.
-                                   */
-  FESystem(const FESystem<dim>&);
-  
+                                    /**
+                                     * Copy constructor prohibited.
+                                     */
+    FESystem(const FESystem<dim>&);
 
   public:
 
@@ -303,55 +303,63 @@ class FESystem : public FiniteElement<dim>
                                     const unsigned int           face_no,
                                     const unsigned int           subface_no,
                                     const vector<Point<dim-1> > &unit_points,
-                                    vector<Point<dim> >         &normal_vectors) const;    
+                                    vector<Point<dim> >         &normal_vectors) const;
 
-                                    /**
-                                     * Number of subelements of this object.
+                                    /** 
+                                     *Number of different composing
+                                     * elements of this object.
+                                     *
                                      * Since these objects can have
-                                     * subobjects themselves, this may be
-                                     * smaller than the total number of finite
-                                     * elements composed into this structure.
-                                     * This is definitely not what you'd
-                                     * usally intend, so don't do it!
+                                     * multiplicity and subobjects
+                                     * themselves, this may be
+                                     * smaller than the total number
+                                     * of finite elements composed
+                                     * into this structure.
                                      */
-    const unsigned int n_sub_elements;
-
-                                  /**
-                                   * Access to the single valued element.
-                                   *
-                                   * If you assemble your system
-                                   * matrix, you usually will not
-                                   * want to have an FEValues object
-                                   * with a lot of equal entries. Ok,
-                                   * so initialize your FEValues with
-                                   * the #base_element# yuo get by
-                                   * this function.
-                                   *
-                                   */
-  const FiniteElement<dim>& get_base_element() const;
-
-                                  /**
-                                   * Calculate the actual position.
-                                   *
-                                   * For a given #component#
-                                   * (e.g. u,v,w in the example
-                                   * above) of the #base# function of
-                                   * the #base_element#, return the
-                                   * actual index in the local
-                                   * degrees of freedom vector of the
-                                   * system.
-                                   *
-                                   */
-  unsigned index(unsigned component, unsigned base) const;
-  
+    unsigned n_component_elements() const;
+
+                                    /**
+                                     * How often is a composing element used.
+                                     *
+                                     */
+    unsigned element_multiplicity(unsigned index) const;
+
+                                    /**
+                                     * Access to a composing element.
+                                     *
+                                     * If you assemble your system
+                                     * matrix, you usually will not
+                                     * want to have an FEValues object
+                                     * with a lot of equal entries. Ok,
+                                     * so initialize your FEValues with
+                                     * the #base_element# you get by
+                                     * this function. In a mixed
+                                     * discretization, you can choose
+                                     * the different base element types
+                                     * by index.
+                                     *
+                                     */
+    const FiniteElement<dim>& base_element(unsigned index) const;
+
   private:
 
                                     /**
-                                     * Pointer to an object of the underlying
-                                     * finite element class. This object is
-                                     * created by the constructor.
+                                     * Pairs of multiplicity and element type.
+                                     */
+    typedef pair<const FiniteElement<dim> *, unsigned > ElementPair;
+    
+                                    /**
+                                     * Pointer to underlying finite
+                                     * element classes.
+                                     *
+                                     * This object contains a pointer
+                                     * to each contributing element
+                                     * of a mixed discretization and
+                                     * its multiplicity. It is
+                                     * created by the constructor and
+                                     * constant afterwards.
                                      */
-    const FiniteElement<dim> *const base_element;
+    vector< ElementPair > base_elements;
 
     
                                     /**
@@ -365,12 +373,14 @@ class FESystem : public FiniteElement<dim>
                                      * transformation from unit to real
                                      * cell.
                                      */
-    static FiniteElementData<dim> multiply_dof_numbers (const FiniteElementData<dim> &fe_data,
-                                                       const unsigned int            N);
+    static FiniteElementData<dim>
+    multiply_dof_numbers (const FiniteElementData<dim> &fe_data,
+                         const unsigned int            N);
     
                                     /**
                                      * This function is simply singled out of
-                                     * the constructor; it sets up the
+                                     * the constructor. It sets up the
+                                     * index table for the system as well as
                                      * #restriction# and #prolongation#
                                      * matrices. Since the operation of this
                                      * function can be done without explicit
@@ -380,7 +390,7 @@ class FESystem : public FiniteElement<dim>
                                      * the general template definition in
                                      * the #.h# file.
                                      */
-    void initialize_matrices ();
+    void initialize();
 };
 
 
@@ -389,35 +399,45 @@ class FESystem : public FiniteElement<dim>
 
 /* ------------------------- template functions ------------------------- */
 
-template <int dim>
-inline const FiniteElement<dim>&
-FESystem<dim>::get_base_element() const
+template<int dim>
+inline unsigned
+FESystem<dim>::n_component_elements() const
 {
-  return *base_element;
+  return base_elements.size();
 }
 
-template <int dim>
+
+template<int dim>
 inline unsigned
-FESystem<dim>::index(unsigned component, unsigned base) const
+FESystem<dim>::element_multiplicity(unsigned index) const
 {
-  return n_sub_elements * base + component;
+  return base_elements[index].second;
 }
 
+
 template <int dim>
-template <typename FE>
+inline const FiniteElement<dim>&
+FESystem<dim>::base_element(unsigned index) const
+{
+  return *base_elements[index].first;
+}
+
+
+template <int dim>
+template <class FE>
 FESystem<dim>::FESystem (const FE &fe, const unsigned int n_elements) :
                FiniteElement (multiply_dof_numbers(fe, n_elements)),
-               n_sub_elements (n_elements),
-               base_element (new FE())
+               base_elements(1)
 {
-  base_element->subscribe ();
-  initialize_matrices ();
+  base_elements[0] = ElementPair(&fe, n_elements);
+  base_elements[0].first -> subscribe ();
+  initialize ();
 };
 
 
 
 
-/*----------------------------   fe_lib.system.h     ---------------------------*/
+/*----------------------------  fe_lib.system.h  ---------------------------*/
 /* end of #ifndef __fe_system_H */
 #endif
-/*----------------------------   fe_lib.system.h     ---------------------------*/
+/*----------------------------  fe_lib.system.h  ---------------------------*/
index 2f2597f18b8095358e9f35b79e47a1c3274a998f..c0c7901767f009283814385ff720a3b4e3017d7c 100644 (file)
@@ -127,7 +127,6 @@ bool FiniteElementData<2>::operator== (const FiniteElementData<2> &f) const {
 
 /*------------------------------- FiniteElementBase ----------------------*/
 
-
 #if deal_II_dimension == 1
 
 template <>
@@ -142,6 +141,9 @@ FiniteElementBase<1>::FiniteElementBase (const FiniteElementData<1> &fe_data) :
     };
   interface_constraints.reinit (1,1);
   interface_constraints(0,0)=1.;
+
+  for (unsigned int j=0 ; j<total_dofs ; ++j)
+    system_to_component_table[j] = pair<unsigned,unsigned>(0,j);
 };
 
 #endif
@@ -161,6 +163,8 @@ FiniteElementBase<2>::FiniteElementBase (const FiniteElementData<2> &fe_data) :
     };
   interface_constraints.reinit (dofs_per_vertex+2*dofs_per_line,
                                2*dofs_per_vertex+dofs_per_line);
+  for (unsigned int j=0 ; j<total_dofs ; ++j)
+    system_to_component_table[j] = pair<unsigned,unsigned>(0,j);
 };
 
 #endif
@@ -216,28 +220,6 @@ template <int dim>
 FiniteElement<dim>::FiniteElement (const FiniteElementData<dim> &fe_data) :
                FiniteElementBase<dim> (fe_data) {};
 
-
-
-template <int dim>
-unsigned
-FiniteElementBase<dim>::component_to_system_index (unsigned component,
-                                                  unsigned component_index) const
-{
-  Assert(false, ExcInvalidIndex(component));
-  return component_index;
-}
-
-
-template <int dim>  
-pair<unsigned,unsigned>
-FiniteElementBase<dim>::system_to_component_index (unsigned index) const
-{
-  Assert(false, ExcInvalidIndex(index));
-  return pair<unsigned,unsigned>(0,0);
-}
-
-
-
 #if deal_II_dimension == 1
 
 // declare this function to be explicitely specialized before first use
index 1a43388b428d47c88b9b4716ab16f2164de74463..db56eae77afc990a0940f506c840e8c8a58e2540 100644 (file)
 template <int dim>
 FESystem<dim>::~FESystem ()
 {
-  base_element->unsubscribe ();
-  delete base_element;
+  for (unsigned i=0;i<base_elements.size();++i)
+    {
+      base_elements[i].first -> unsubscribe ();
+      delete base_elements[i].first;
+    }
 };
 
 
 
 template <int dim>
-void FESystem<dim>::initialize_matrices ()
+void FESystem<dim>::initialize ()
 {
+                                  // Initialize index table
+                                  // Multi-component base elements have to be thought of.
+                                  // 1. Vertices
+  unsigned total_index = 0;
+  for(unsigned comp = 0; comp < n_component_elements() ; ++comp)
+    {
+      for (unsigned local_index = 0 ;
+          local_index < base_element(comp).dofs_per_vertex ;
+          ++local_index)
+       {
+         system_to_component_table[total_index++] = pair<unsigned,unsigned>
+                                                  (comp, 0);
+       }
+    }
+                                  // 2. Lines
+  for(unsigned comp = 0; comp < n_component_elements() ; ++comp)
+    {
+      for (unsigned local_index = 0 ;
+          local_index < base_element(comp).dofs_per_vertex ;
+          ++local_index)
+       {
+         system_to_component_table[total_index++] = pair<unsigned,unsigned>
+                                                  (comp, 0);
+       }
+    }
+                                  // 3. Quads
+  for(unsigned comp = 0; comp < n_component_elements() ; ++comp)
+    {
+      for (unsigned local_index = 0 ;
+          local_index < base_element(comp).dofs_per_vertex ;
+          ++local_index)
+       {
+         system_to_component_table[total_index++] = pair<unsigned,unsigned>
+                                                  (comp, 0);
+       }
+    }
+  
+
                                   // distribute the matrices of the base
                                   // finite element to the matrices of
                                   // this object
@@ -67,7 +108,8 @@ FESystem<1>::multiply_dof_numbers (const FiniteElementData<1> &fe_data,
 template <>
 FiniteElementData<2>
 FESystem<2>::multiply_dof_numbers (const FiniteElementData<2> &fe_data,
-                                  const unsigned int          N) {
+                                  const unsigned int          N)
+{
   return FiniteElementData<2> (fe_data.dofs_per_vertex * N,
                               fe_data.dofs_per_line * N,
                               fe_data.dofs_per_quad * N,
@@ -79,12 +121,14 @@ FESystem<2>::multiply_dof_numbers (const FiniteElementData<2> &fe_data,
 
 
 
+/*
 template <int dim>
 double FESystem<dim>::shape_value (const unsigned int i,
-                                  const Point<dim>  &p) const {
+                                  const Point<dim>  &p) const
+{
   Assert((i<total_dofs), ExcInvalidIndex(i));
 
-  return base_element->shape_value (i / n_sub_elements, p);
+//  return base_element->shape_value (i / n_sub_elements, p);
 };
 
 
@@ -95,7 +139,7 @@ FESystem<dim>::shape_grad (const unsigned int  i,
                           const Point<dim>   &p) const {
   Assert((i<total_dofs), ExcInvalidIndex(i));
 
-  return base_element->shape_grad (i / n_sub_elements, p);
+//  return base_element->shape_grad (i / n_sub_elements, p);
 };
 
 
@@ -106,7 +150,7 @@ FESystem<dim>::shape_grad_grad (const unsigned int  i,
                                const Point<dim>   &p) const {
   Assert((i<total_dofs), ExcInvalidIndex(i));
 
-  return base_element->shape_grad_grad (i / n_sub_elements, p);
+//  return base_element->shape_grad_grad (i / n_sub_elements, p);
 };
 
 
@@ -245,7 +289,7 @@ void FESystem<dim>::get_normal_vectors (const DoFHandler<dim>::cell_iterator &ce
   base_element->get_normal_vectors (cell, face_no, subface_no, unit_points, normal_vectors);
 };
 
-
+*/
 
 
 

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.