]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Approaching systems of equations
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 9 Feb 1999 10:37:59 +0000 (10:37 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 9 Feb 1999 10:37:59 +0000 (10:37 +0000)
More ANSI conformance (math.h)

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

12 files changed:
deal.II/deal.II/include/fe/fe.h
deal.II/deal.II/include/fe/fe_lib.criss_cross.h
deal.II/deal.II/include/fe/fe_lib.lagrange.h
deal.II/deal.II/include/fe/fe_linear_mapping.h
deal.II/deal.II/include/fe/fe_system.h
deal.II/deal.II/include/fe/fe_values.h
deal.II/deal.II/include/grid/tria_boundary.h
deal.II/deal.II/source/fe/fe.cc
deal.II/deal.II/source/fe/fe_system.cc
deal.II/deal.II/source/fe/fe_values.cc
deal.II/deal.II/source/grid/tria_accessor.cc
deal.II/deal.II/source/numerics/error_estimator.cc

index 9833e96bfd979d92c65cb151ddb1dfabba8d5c1a..9864d3dd4a8a105d8dd3de0497c02dc49c50ee84 100644 (file)
@@ -64,6 +64,11 @@ struct FiniteElementData<1> {
                                      */
     const unsigned int n_transform_functions;
     
+                                  /**
+                                   * Number of components.
+                                   */
+  const unsigned int n_components;
+
                                     /**
                                      * Default constructor. Constructs an element
                                      * which is not so useful. Checking
@@ -78,7 +83,8 @@ struct FiniteElementData<1> {
                                      */
     FiniteElementData (const unsigned int dofs_per_vertex,
                       const unsigned int dofs_per_line,
-                      const unsigned int n_transform_functions);
+                      const unsigned int n_transform_functions,
+                      const unsigned int n_components = 1);
 
                                     /**
                                      * Another frequently used useful
@@ -152,6 +158,11 @@ struct FiniteElementData<2> {
                                      */
     const unsigned int n_transform_functions;
 
+                                  /**
+                                   * Number of components.
+                                   */
+  const unsigned int n_components;
+
                                     /**
                                      * Default constructor. Constructs an element
                                      * which is not so useful. Checking
@@ -167,7 +178,8 @@ struct FiniteElementData<2> {
     FiniteElementData (const unsigned int dofs_per_vertex,
                       const unsigned int dofs_per_line,
                       const unsigned int dofs_per_quad,
-                      const unsigned int n_transform_functions);
+                      const unsigned int n_transform_functions,
+                      const unsigned int n_components = 1);
 
                                     /**
                                      * Another frequently used useful
@@ -1121,6 +1133,17 @@ class FiniteElement : public FiniteElementBase<dim> {
     virtual void get_local_mass_matrix (const DoFHandler<dim>::cell_iterator &cell,
                                        const Boundary<dim> &boundary, 
                                        dFMatrix            &local_mass_matrix) const =0;
+
+                                  /**
+                                   * Compute system index from components.
+                                   */
+  virtual unsigned component_to_system_index (unsigned component,
+                                             unsigned component_index) const;
+  
+                                  /**
+                                   * Compute component and index from system index.
+                                   */
+  virtual pair<unsigned,unsigned> system_to_component_index (unsigned index) const; 
     
                                     /**
                                      * Exception
index bda4a68a04f07d1d9bf8cf1163b07f60af1a4c83..c703a736c90722c4f6cb928f62b5ac191fc5fb7e 100644 (file)
@@ -8,7 +8,7 @@
 
 #include <fe/fe.h>
 #include <base/quadrature.h>
-
+#include <math.h>
 
 /**
  * This class implements a rather unusual macro element, the so-called
index 8eff4866573616f353aa352749d023b05f5c34c8..c44d72be0579c2d2664eaa20c561a5da7a1da7e7 100644 (file)
@@ -9,7 +9,6 @@
 #include <fe/fe_linear_mapping.h>
 
 
-
 /**
  * Define a (bi-, tri-, etc)linear finite element in #dim# space dimensions,
  * along with (bi-, tri-)linear (therefore isoparametric) transforms from the
index 68250cd016ac0a5b81401fa245ee65cb45f780a0..4a489b7aba91a52c7d3efd374ead600e522dc5dd 100644 (file)
@@ -6,6 +6,7 @@
 /*----------------------------   fe_linear_mapping.h     ---------------------------*/
 
 
+#include <math.h>
 #include <fe/fe.h>
 
 
index 3f83f4df399564f3dd4dc4184d522196e7222996..01651fdfb44ce5550bb392e919be0af897bce5df 100644 (file)
@@ -21,9 +21,8 @@
  * shape functions. These #N# shape functions for each degree of freedom
  * of the basic finite element are numbered consecutively, i.e. for
  * the common case of a velocity #(u,v,w)#, the sequence of basis functions
- * would be #u1, v1, w1, u2, v2, w2, ..., uN, vN, wN#. The other possibility
- * would have been #u1, ..., uN, v1, ..., vN, w1, ...wN#, but we chose the
- * first way.
+ * will be #u1, v1, w1, u2, v2, w2, ..., uN, vN, wN# compared to
+ *  #u1, ..., uN, v1, ..., vN, w1, ...wN#.
  *
  * Using this scheme, the overall numbering of degrees of freedom is as
  * follows: for each subobject (vertex, line, quad, or hex), the degrees
@@ -42,7 +41,7 @@
  * \end{itemize}
  *
  * In the most cases, the composed element behaves as if it were a usual element
- * with more degrees of freedom. Howeverm the underlying structure is visible in
+ * with more degrees of freedom. However the underlying structure is visible in
  * the restriction, prolongation and interface constraint matrices, which do not
  * couple the degrees of freedom of the subobject. E.g. the continuity requirement
  * is imposed for the shape functions of the subobjects separately; no requirement
  * @author Wolfgang Bangerth, 1999
  */
 template <int dim>
-class FESystem : public FiniteElement<dim> {
+class FESystem : public FiniteElement<dim>
+{
+                                  /**
+                                   * Copy constructor prohibited.
+                                   */
+  FESystem(const FESystem<dim>&);
+  
+
   public:
 
                                     /**
@@ -298,23 +304,55 @@ class FESystem : public FiniteElement<dim> {
                                     const unsigned int           subface_no,
                                     const vector<Point<dim-1> > &unit_points,
                                     vector<Point<dim> >         &normal_vectors) const;    
-    
-  private:
-                                    /**
-                                     * Pointer to an object of the underlying
-                                     * finite element class. This object is
-                                     * created by the constructor.
-                                     */
-    const FiniteElement<dim> *const base_element;
 
                                     /**
                                      * Number of subelements of this object.
-                                     * Since these objects may have
+                                     * 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!
                                      */
     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;
+  
+  private:
+
+                                    /**
+                                     * Pointer to an object of the underlying
+                                     * finite element class. This object is
+                                     * created by the constructor.
+                                     */
+    const FiniteElement<dim> *const base_element;
+
     
                                     /**
                                      * Helper function used in the constructor:
@@ -351,12 +389,26 @@ class FESystem : public FiniteElement<dim> {
 
 /* ------------------------- template functions ------------------------- */
 
+template <int dim>
+inline const FiniteElement<dim>&
+FESystem<dim>::get_base_element() const
+{
+  return *base_element;
+}
+
+template <int dim>
+inline unsigned
+FESystem<dim>::index(unsigned component, unsigned base) const
+{
+  return n_sub_elements * base + component;
+}
+
 template <int dim>
 template <typename FE>
 FESystem<dim>::FESystem (const FE &fe, const unsigned int n_elements) :
                FiniteElement (multiply_dof_numbers(fe, n_elements)),
-               base_element (new FE()),
-               n_sub_elements (n_elements)
+               n_sub_elements (n_elements),
+               base_element (new FE())
 {
   base_element->subscribe ();
   initialize_matrices ();
index 35c15b2f76a3a1a234d41aa5f74da4428516006b..06c5d119b69f791fc0c0b6187fabb74d145351c8 100644 (file)
@@ -286,13 +286,31 @@ class FEValuesBase {
                                      * of the derived class was called,
                                      * at the quadrature points.
                                      *
+                                     * To get values of
+                                     * multi-component elements,
+                                     * there is another
+                                     * #get_function_values#
+                                     * returning a vector of vectors of
+                                     * results.
+                                     *
                                      * The function assumes that the
                                      * #values# object already has the
-                                     * right size.
+                                     * right size. 
                                      */
     void get_function_values (const dVector      &fe_function,
                              vector<double>     &values) const;
 
+                                  /**
+                                   * Access to vector valued finite element functions.
+                                   *
+                                   * This function does the same as
+                                   * the other #get_function_values#,
+                                   * but applied to multi-component
+                                   * elements.
+                                   */
+    void get_function_values (const dVector      &fe_function,
+                             vector<vector<double> >     &values) const;
+
                                     /**
                                      * Return the gradient of the #i#th shape
                                      * function at the #j# quadrature point.
@@ -471,6 +489,10 @@ class FEValuesBase {
                                     /**
                                      * Exception
                                      */
+  DeclException0 (ExcWrongNoOfComponents);
+                                  /**
+                                   * Exception.
+                                   */
     DeclException2 (ExcWrongVectorSize,
                    int, int,
                    << "Vector has wrong size " << arg1
index c110ee46a77739f298b1caa7a001fa3c5cd8f6e0..834991ce8c2eea3019b8080eb9ce14e8ecc0cb65 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <base/point.h>
 #include <grid/geometry_info.h>
+#include <math.h>
 
 
 
index 283e08b23db4444bd24782954f09bdd64353d3f9..7a619ebde610e0e803b2ac706505d7a66f32287e 100644 (file)
@@ -21,7 +21,9 @@ FiniteElementData<1>::FiniteElementData () :
                dofs_per_line(0),
                dofs_per_face(0),
                total_dofs(0),
-               n_transform_functions(0) {
+               n_transform_functions(0),
+               n_components(0)
+{
   Assert (false, ExcInternalError());
 };
 
@@ -29,12 +31,14 @@ FiniteElementData<1>::FiniteElementData () :
 
 FiniteElementData<1>::FiniteElementData (const unsigned int dofs_per_vertex,
                                         const unsigned int dofs_per_line,
-                                        const unsigned int n_transform_functions) :
+                                        const unsigned int n_transform_functions,
+                                        const unsigned int n_components) :
                dofs_per_vertex(dofs_per_vertex),
                dofs_per_line(dofs_per_line),
                dofs_per_face(dofs_per_vertex),
                total_dofs (2*dofs_per_vertex+dofs_per_line),
-               n_transform_functions(n_transform_functions)
+               n_transform_functions(n_transform_functions),
+               n_components(n_components)
 {};
 
 
@@ -44,7 +48,8 @@ FiniteElementData<1>::FiniteElementData (const FiniteElementData<1> &fe_data) :
                dofs_per_line(fe_data.dofs_per_line),
                dofs_per_face(fe_data.dofs_per_face),
                total_dofs (fe_data.total_dofs),
-               n_transform_functions(fe_data.n_transform_functions)
+               n_transform_functions(fe_data.n_transform_functions),
+               n_components(fe_data.n_components)
 {};
 
 
@@ -52,7 +57,8 @@ FiniteElementData<1>::FiniteElementData (const FiniteElementData<1> &fe_data) :
 bool FiniteElementData<1>::operator== (const FiniteElementData<1> &f) const {
   return ((dofs_per_vertex == f.dofs_per_vertex) &&
          (dofs_per_line == f.dofs_per_line) &&
-         (total_dofs == f.total_dofs));
+         (total_dofs == f.total_dofs) &&
+         (n_components == f.n_components));
 };
 
 #endif
@@ -68,7 +74,9 @@ FiniteElementData<2>::FiniteElementData () :
                dofs_per_quad(0),
                dofs_per_face(0),
                total_dofs(0),
-               n_transform_functions(0) {
+               n_transform_functions(0),
+               n_components(0)
+{
   Assert (false, ExcInternalError());
 };
 
@@ -77,7 +85,8 @@ FiniteElementData<2>::FiniteElementData () :
 FiniteElementData<2>::FiniteElementData (const unsigned int dofs_per_vertex,
                                         const unsigned int dofs_per_line,
                                         const unsigned int dofs_per_quad,
-                                        const unsigned int n_transform_functions) :
+                                        const unsigned int n_transform_functions,
+                                        const unsigned int n_components) :
                dofs_per_vertex(dofs_per_vertex),
                dofs_per_line(dofs_per_line),
                dofs_per_quad(dofs_per_quad),
@@ -86,7 +95,8 @@ FiniteElementData<2>::FiniteElementData (const unsigned int dofs_per_vertex,
                total_dofs (4*dofs_per_vertex+
                            4*dofs_per_line+
                            dofs_per_quad),
-               n_transform_functions (n_transform_functions)
+               n_transform_functions (n_transform_functions),
+               n_components(n_components)
 {};
 
 
@@ -97,7 +107,8 @@ FiniteElementData<2>::FiniteElementData (const FiniteElementData<2> &fe_data) :
                dofs_per_quad(fe_data.dofs_per_quad),
                dofs_per_face(fe_data.dofs_per_face),
                total_dofs (fe_data.total_dofs),
-               n_transform_functions (fe_data.n_transform_functions)
+               n_transform_functions (fe_data.n_transform_functions),
+               n_components(fe_data.n_components)
 {};
 
 
@@ -106,7 +117,8 @@ bool FiniteElementData<2>::operator== (const FiniteElementData<2> &f) const {
   return ((dofs_per_vertex == f.dofs_per_vertex) &&
          (dofs_per_line == f.dofs_per_line) &&
          (dofs_per_quad == f.dofs_per_quad) &&
-         (total_dofs == f.total_dofs));
+         (total_dofs == f.total_dofs) &&
+         (n_components == f.n_components));
 };
 
 #endif
index f8ba397cb99990c544cb4b54824050e45a4081fc..1a43388b428d47c88b9b4716ab16f2164de74463 100644 (file)
@@ -9,7 +9,8 @@
 
 
 template <int dim>
-FESystem<dim>::~FESystem () {
+FESystem<dim>::~FESystem ()
+{
   base_element->unsubscribe ();
   delete base_element;
 };
@@ -17,11 +18,12 @@ FESystem<dim>::~FESystem () {
 
 
 template <int dim>
-void FESystem<dim>::initialize_matrices () {
+void FESystem<dim>::initialize_matrices ()
+{
                                   // distribute the matrices of the base
                                   // finite element to the matrices of
                                   // this object
-  for (unsigned int i=0; i<base_element->total_dofs; ++i)
+/*  for (unsigned int i=0; i<base_element->total_dofs; ++i)
     for (unsigned int j=0; j<base_element->total_dofs; ++j)
       for (unsigned int n=0; n<n_sub_elements; ++n)
                                         // only fill diagonals of the blocks
@@ -40,7 +42,7 @@ void FESystem<dim>::initialize_matrices () {
                                 j*n_sub_elements + n)
            = base_element->constraints()(i,j);
        };
-};
+*/};
 
 
 
@@ -53,7 +55,8 @@ FESystem<1>::multiply_dof_numbers (const FiniteElementData<1> &fe_data,
                                   const unsigned int          N) {
   return FiniteElementData<1> (fe_data.dofs_per_vertex * N,
                               fe_data.dofs_per_line * N,
-                              fe_data.n_transform_functions);
+                              fe_data.n_transform_functions,
+                              fe_data.n_components * N);
 };
 
 #endif
@@ -68,7 +71,8 @@ FESystem<2>::multiply_dof_numbers (const FiniteElementData<2> &fe_data,
   return FiniteElementData<2> (fe_data.dofs_per_vertex * N,
                               fe_data.dofs_per_line * N,
                               fe_data.dofs_per_quad * N,
-                              fe_data.n_transform_functions);
+                              fe_data.n_transform_functions,
+                              fe_data.n_components * N);
 };
 
 #endif
index 37e60ea2cc9dafc4096510201a8d537fa347f15e..9921778febb1ebc5b7aabbdc6ef3a1b30a3357d2 100644 (file)
@@ -62,7 +62,10 @@ double FEValuesBase<dim>::shape_value (const unsigned int i,
 
 template <int dim>
 void FEValuesBase<dim>::get_function_values (const dVector  &fe_function,
-                                            vector<double> &values) const {
+                                            vector<double> &values) const
+{
+  Assert (fe.n_components == 1,
+         ExcWrongNoOfComponents());
   Assert (selected_dataset<shape_values.size(),
          ExcInvalidIndex (selected_dataset, shape_values.size()));
   Assert (values.size() == n_quadrature_points,
index 876ff92be3aac819502e79c017c4b8df9cf81bfb..dd43ba13c3333bfecca67c6c5e635f43de5d55bf 100644 (file)
@@ -8,6 +8,7 @@
 #include <grid/tria_accessor.h>
 #include <grid/tria_iterator.templates.h>
 #include <grid/geometry_info.h>
+#include <math.h>
 
 /* Note: explicit instantiations at the end of the different sections!       */
 
index b25f34be0e526f2333c9fad835480c2b434d675f..784da34e8e970f394b08fb5be4383966294b8214 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <numeric>
 #include <algorithm>
+#include <math.h>
 
 
 

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.