]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Improved some details in CellSimilarity concept.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 9 Mar 2009 11:15:09 +0000 (11:15 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 9 Mar 2009 11:15:09 +0000 (11:15 +0000)
git-svn-id: https://svn.dealii.org/trunk@18467 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/fe/fe_update_flags.h
deal.II/deal.II/include/fe/fe_values.h
deal.II/deal.II/include/fe/mapping.h
deal.II/deal.II/source/fe/fe_system.cc
deal.II/deal.II/source/fe/fe_values.cc
deal.II/deal.II/source/fe/mapping_cartesian.cc
deal.II/deal.II/source/fe/mapping_q.cc
deal.II/deal.II/source/fe/mapping_q1.cc
deal.II/deal.II/source/fe/mapping_q1_eulerian.cc
deal.II/deal.II/source/fe/mapping_q_eulerian.cc
deal.II/lac/source/trilinos_sparse_matrix.cc

index 9eb404b7a7e29695c67dda2d759ab9aa402fceee..a7e8bc797ab8cac1dd00b7a6a7d0980a8dad392d 100644 (file)
@@ -340,8 +340,29 @@ operator &= (UpdateFlags &f1, UpdateFlags f2)
 
 
 
+/**
+ * This enum definition is used for storing similarities of the current cell
+ * to the previously visited cell. This information is used for reusing data
+ * when calling the method FEValues::reinit() (like derivatives, which do
+ * not change if one cell is just a translation of the previous). Currently,
+ * this variable does only recognize a translation. However, this concept
+ * makes it easy to add additional staties to be detected in
+ * FEValues/FEFaceValues for making use of these similarities as well.
+ */
+namespace CellSimilarity
+{
+  enum Similarity 
+    {
+      none, 
+      translation
+    };
+}
+
+
 /*@}*/
 
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
index 4d77e951775ce5b7500851abf3663317cc214279..73ee333fcf24c6ee7892860437a383d2c8b342a3 100644 (file)
@@ -2244,7 +2244,6 @@ class FEValuesBase : protected FEValuesData<dim,spacedim>,
 
     const std::vector<Point<spacedim> > & get_cell_normal_vectors () const;
 
-
                                     /**
                                      * Return the outward normal vector to
                                      * the cell at the <tt>i</tt>th quadrature
@@ -2253,6 +2252,17 @@ class FEValuesBase : protected FEValuesData<dim,spacedim>,
                                      */
     const Point<spacedim> & cell_normal_vector (const unsigned int i) const;
 
+                                    /**
+                                     * Return the relation of the current
+                                     * cell to the previous cell. This
+                                     * allows re-use of some cell data
+                                     * (like local matrices for equations
+                                     * with constant coefficients) if the
+                                     * result is
+                                     * <tt>CellSimilarity::translation</tt>.
+                                     */
+    const enum CellSimilarity::Similarity get_cell_similarity () const;
+
                                     /**
                                      * Determine an estimate for the
                                      * memory consumption (in bytes)
@@ -2603,6 +2613,28 @@ class FEValuesBase : protected FEValuesData<dim,spacedim>,
                                      */
     UpdateFlags compute_update_flags (const UpdateFlags update_flags) const;
 
+                                    /**
+                                     * An enum variable that can store
+                                     * different states of the current cell
+                                     * in comparison to the previously
+                                     * visited cell. If wanted, additional
+                                     * states can be checked here and used
+                                     * in one of the methods used during
+                                     * reinit.
+                                     */
+    enum CellSimilarity::Similarity cell_similarity;
+
+                                    /**
+                                     * A function that checks whether the
+                                     * new cell is similar to the one
+                                     * previously used. Then, a significant
+                                     * amount of the data can be reused,
+                                     * e.g. the derivatives of the basis
+                                     * functions in real space, shape_grad.
+                                     */
+    void
+    check_cell_similarity (const typename Triangulation<dim,spacedim>::cell_iterator &cell);
+
   private:
                                      /**
                                       * Copy constructor. Since
@@ -2679,16 +2711,16 @@ class FEValues : public FEValuesBase<dim,spacedim>
                                      */
     FEValues (const Mapping<dim,spacedim>       &mapping,
              const FiniteElement<dim,spacedim> &fe,
-             const Quadrature<dim>    &quadrature,
-             const UpdateFlags         update_flags);
+             const Quadrature<dim>             &quadrature,
+             const UpdateFlags                  update_flags);
 
                                      /**
                                      * Constructor. Uses MappingQ1
                                      * implicitly.
                                      */
     FEValues (const FiniteElement<dim,spacedim> &fe,
-             const Quadrature<dim>    &quadrature,
-             const UpdateFlags         update_flags);
+             const Quadrature<dim>             &quadrature,
+             const UpdateFlags                  update_flags);
     
                                     /**
                                      * Reinitialize the gradients,
@@ -2815,28 +2847,6 @@ class FEValues : public FEValuesBase<dim,spacedim>
                                      */
     void initialize (const UpdateFlags update_flags);
 
-                                    /**
-                                     * An enum variable that can store
-                                     * different states of the current cell
-                                     * in comparison to the previously
-                                     * visited cell. If wanted, additional
-                                     * states can be checked here and used
-                                     * in one of the methods used during
-                                     * reinit.
-                                     */
-    enum CellSimilarity::Similarity cell_similarity;
-
-                                    /**
-                                     * A function that checks whether the
-                                     * new cell is similar to the one
-                                     * previously used. Then, a significant
-                                     * amount of the data can be reused,
-                                     * e.g. the derivatives of the basis
-                                     * functions in real space, shape_grad.
-                                     */
-    void
-    check_cell_similarity (const typename Triangulation<dim,spacedim>::cell_iterator &cell);
-
                                      /**
                                       * The reinit() functions do
                                       * only that part of the work
@@ -2895,12 +2905,12 @@ class FEFaceValuesBase : public FEValuesBase<dim,spacedim>
                                      * of faces times the number of subfaces
                                      * per face.
                                      */
-    FEFaceValuesBase (const unsigned int n_q_points,
-                     const unsigned int dofs_per_cell,
-                     const UpdateFlags         update_flags,
+    FEFaceValuesBase (const unsigned int                 n_q_points,
+                     const unsigned int                 dofs_per_cell,
+                     const UpdateFlags                  update_flags,
                      const Mapping<dim,spacedim>       &mapping,
                      const FiniteElement<dim,spacedim> &fe,
-                     const Quadrature<dim-1>& quadrature);
+                     const Quadrature<dim-1>&           quadrature);
 
                                     /**
                                      * Return the outward normal vector to
@@ -3026,16 +3036,16 @@ class FEFaceValues : public FEFaceValuesBase<dim,spacedim>
                                      */
     FEFaceValues (const Mapping<dim,spacedim>       &mapping,
                  const FiniteElement<dim,spacedim> &fe,
-                 const Quadrature<dim-1>  &quadrature,
-                 const UpdateFlags         update_flags);
+                 const Quadrature<dim-1>           &quadrature,
+                 const UpdateFlags                  update_flags);
 
                                      /**
                                      * Constructor. Uses MappingQ1
                                      * implicitly.
                                      */
     FEFaceValues (const FiniteElement<dim,spacedim> &fe,
-                 const Quadrature<dim-1>  &quadrature,
-                 const UpdateFlags         update_flags);
+                 const Quadrature<dim-1>           &quadrature,
+                 const UpdateFlags                  update_flags);
 
                                     /**
                                      * Reinitialize the gradients, Jacobi
@@ -3044,7 +3054,7 @@ class FEFaceValues : public FEFaceValuesBase<dim,spacedim>
                                      * and the given finite element.
                                      */
     void reinit (const typename DoFHandler<dim,spacedim>::cell_iterator &cell,
-                const unsigned int                            face_no);
+                const unsigned int                                      face_no);
 
                                     /**
                                      * Reinitialize the gradients,
@@ -3060,7 +3070,7 @@ class FEFaceValues : public FEFaceValuesBase<dim,spacedim>
                                      * object.
                                      */
     void reinit (const typename hp::DoFHandler<dim,spacedim>::cell_iterator &cell,
-                const unsigned int                              face_no);
+                const unsigned int                                          face_no);
 
                                     /**
                                      * Reinitialize the gradients,
@@ -3076,7 +3086,7 @@ class FEFaceValues : public FEFaceValuesBase<dim,spacedim>
                                      * object.
                                      */
     void reinit (const typename MGDoFHandler<dim,spacedim>::cell_iterator &cell,
-                const unsigned int                              face_no);
+                const unsigned int                                        face_no);
 
                                     /**
                                      * Reinitialize the gradients,
@@ -3105,7 +3115,7 @@ class FEFaceValues : public FEFaceValuesBase<dim,spacedim>
                                      * handler type objects.
                                      */
     void reinit (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
-                const unsigned int                    face_no);
+                const unsigned int                                         face_no);
     
                                      /**
                                       * Return a reference to this
index cfbaebbc29ac4e4c61649916044960b45c449de9..290a9b0757bc4fa12b8aa0565f08713e3bf9b534 100644 (file)
@@ -32,24 +32,6 @@ template <int dim, int spacedim> class FEValues;
 template <int dim, int spacedim> class FEFaceValues;
 template <int dim, int spacedim> class FESubfaceValues;
 
-                                    /**
-                                     * An enum variable that can store
-                                     * different states of the current cell
-                                     * in comparison to the previously
-                                     * visited cell. If wanted, additional
-                                     * states can be checked here and used
-                                     * in one of the methods used during
-                                     * reinit.
-                                     */
-namespace CellSimilarity
-{
-  enum Similarity 
-    {
-      no_similarity, 
-      translation
-    };
-}
-
                                      /**
                                       * The transformation type used
                                       * for the Mapping::transform() functions.
index 9989fb6ea830a2df759fd0d8c1dfb97331b60c30..53917b353d2dba4e8d49ff80ea4f05ca11218a6b 100644 (file)
@@ -690,7 +690,7 @@ fill_fe_face_values (const Mapping<dim,spacedim>                   &mapping,
                      FEValuesData<dim,spacedim>                    &data) const
 {
   compute_fill (mapping, cell, face_no, invalid_face_number, quadrature,
-                CellSimilarity::no_similarity, mapping_data, fe_data, data);
+                CellSimilarity::none, mapping_data, fe_data, data);
 }
 
 
@@ -709,7 +709,7 @@ fill_fe_subface_values (const Mapping<dim,spacedim>                      &mappin
                         FEValuesData<dim,spacedim>                       &data) const
 {
   compute_fill (mapping, cell, face_no, sub_no, quadrature,
-                CellSimilarity::no_similarity, mapping_data, fe_data, data);
+                CellSimilarity::none, mapping_data, fe_data, data);
 }
 
 
index 0cb2bd6f11bc6e312e01d2f355b08709d6317c58..c66288f97f4174b5ae38e2f8aced9c5573ebc2a4 100644 (file)
@@ -3239,6 +3239,70 @@ FEValuesBase<dim,spacedim>::compute_update_flags (const UpdateFlags update_flags
 }
 
 
+
+template <int dim, int spacedim>
+inline
+void
+FEValuesBase<dim,spacedim>::check_cell_similarity 
+  (const typename Triangulation<dim,spacedim>::cell_iterator &cell)
+{
+                                  // case that there has not been any cell
+                                  // before
+  if (&*this->present_cell == 0)
+    {
+      cell_similarity = CellSimilarity::none;
+      return;
+    }
+
+  const typename Triangulation<dim,spacedim>::cell_iterator & present_cell = 
+    *this->present_cell;
+
+                                  // test for translation
+  {
+                                  // otherwise, go through the vertices and
+                                  // check... The cell is a translation of
+                                  // the previous one in case the distance
+                                  // between the individual vertices in the
+                                  // two cell is the same for all the
+                                  // vertices. So do the check by first
+                                  // getting the distance on the first
+                                  // vertex, and then checking whether all
+                                  // others have the same.
+    bool is_translation = true;
+    const Point<spacedim> dist = cell->vertex(0) - present_cell->vertex(0);
+    for (unsigned int i=1; i<GeometryInfo<dim>::vertices_per_cell; ++i)
+      {
+       Point<spacedim> dist_new = cell->vertex(i) - present_cell->vertex(i) - dist;
+       if (dist_new.norm_square() > 1e-28)
+         {
+           is_translation = false;
+           break;
+         }
+      }
+
+    cell_similarity = (is_translation == true 
+                      ? 
+                      CellSimilarity::translation 
+                      : 
+                      CellSimilarity::none);
+    return;
+  }
+
+                                  // TODO: here, one could implement other
+                                  // checks for similarity, e.g. for
+                                  // children of a parallelogram.
+}
+
+
+
+template <int dim, int spacedim>
+const enum CellSimilarity::Similarity 
+FEValuesBase<dim,spacedim>::get_cell_similarity () const
+{
+  return cell_similarity;
+}
+
+
 /*------------------------------- FEValues -------------------------------*/
 
 
@@ -3469,53 +3533,6 @@ void FEValues<dim,spacedim>::reinit (const typename Triangulation<dim,spacedim>:
 
 
 
-template <int dim, int spacedim>
-inline
-void
-FEValues<dim,spacedim>::check_cell_similarity (const typename Triangulation<dim,spacedim>::cell_iterator &cell)
-{
-                                  // case that there has not been any cell
-                                  // before
-  if (&*this->present_cell == 0)
-    {
-      cell_similarity = CellSimilarity::no_similarity;
-      return;
-    }
-
-  const typename Triangulation<dim,spacedim>::cell_iterator & present_cell = 
-    *this->present_cell;
-
-                                  // test for translation
-  {
-                                  // otherwise, go through the vertices and
-                                  // check...
-    bool is_translation = true;
-    const Point<spacedim> dist = cell->vertex(0) - present_cell->vertex(0);
-    for (unsigned int i=1; i<GeometryInfo<dim>::vertices_per_cell; ++i)
-      {
-       Point<spacedim> dist_new = cell->vertex(i) - present_cell->vertex(i) - dist;
-       if (dist_new.norm_square() > 1e-28)
-         {
-           is_translation = false;
-           break;
-         }
-      }
-
-    cell_similarity = (is_translation == true 
-                      ? 
-                      CellSimilarity::translation 
-                      : 
-                      CellSimilarity::no_similarity);
-    return;
-  }
-
-                                  // TODO: here, one could implement other
-                                  // checks for similarity, e.g. for
-                                  // children of a parallelogram.
-}
-
-
-
 template <int dim, int spacedim>
 void FEValues<dim,spacedim>::do_reinit ()
 {
index ec021ded6c2d5fb7fac6a32b5e1d3137b1f4b074..db2c77f370876d48f5e5d172fbe986dbba13ad68 100644 (file)
@@ -431,7 +431,7 @@ MappingCartesian<dim, spacedim>::fill_fe_face_values (
   InternalData &data = static_cast<InternalData&> (mapping_data);
 
   compute_fill (cell, face_no, invalid_face_number, 
-               CellSimilarity::no_similarity,
+               CellSimilarity::none,
                data,
                quadrature_points,
                normal_vectors);
@@ -484,7 +484,7 @@ MappingCartesian<dim, spacedim>::fill_fe_subface_values (
   Assert (dynamic_cast<InternalData*> (&mapping_data) != 0, ExcInternalError());
   InternalData &data = static_cast<InternalData&> (mapping_data);
 
-  compute_fill (cell, face_no, sub_no, CellSimilarity::no_similarity,
+  compute_fill (cell, face_no, sub_no, CellSimilarity::none,
                data,
                quadrature_points,
                normal_vectors);
index fc6c6336b55ce60378aa13d8f19cd4a5d070ea81..106bd505322e4bec2de9d36ce752faee5435970a 100644 (file)
@@ -351,7 +351,7 @@ MappingQ<dim,spacedim>::fill_fe_values (
   else
     {
       p_data=&data;
-      cell_similarity = CellSimilarity::no_similarity;
+      cell_similarity = CellSimilarity::none;
     }
   
   MappingQ1<dim,spacedim>::fill_fe_values(cell, q, cell_similarity, *p_data,
index d7b3aa9f0000c98a758049153bfa54a133867931..c5985e9b5d9b1f8fc64ecc86ad4f125e010ec9cf 100644 (file)
@@ -962,7 +962,7 @@ MappingQ1<dim,spacedim>::compute_fill_face (
   std::vector<Tensor<1,dim> > &boundary_forms,
   std::vector<Point<spacedim> >    &normal_vectors) const
 {
-  compute_fill (cell, n_q_points, data_set, CellSimilarity::no_similarity,
+  compute_fill (cell, n_q_points, data_set, CellSimilarity::none,
                data, quadrature_points);
 
   const UpdateFlags update_flags(data.current_update_flags());
index 287a809e10695a4acb5a5030e9ba6249b15d4864..3e1bd7f83279ef149406ee929a9ab2995524f858 100644 (file)
@@ -132,7 +132,7 @@ MappingQ1Eulerian<dim,EulerVectorType,spacedim>::fill_fe_values (
                                   // disable any previously detected
                                   // similarity and hand on to the
                                   // respective function of the base class.
-  cell_similarity = CellSimilarity::no_similarity;
+  cell_similarity = CellSimilarity::none;
   MappingQ1<dim,spacedim>::fill_fe_values (cell, q, cell_similarity, mapping_data,
                                           quadrature_points, JxW_values, jacobians,
                                           jacobian_grads, inverse_jacobians,
index cfa9ce19301d7e8f64f12766b2c59b62e2cdb476..cff88e4ba01bb04d4fe6e1695bcb6aa3c8a26d96 100644 (file)
@@ -199,7 +199,7 @@ MappingQEulerian<dim,EulerVectorType,spacedim>::fill_fe_values (
                                   // disable any previously detected
                                   // similarity and hand on to the respective
                                   // function of the base class.
-  cell_similarity = CellSimilarity::no_similarity;
+  cell_similarity = CellSimilarity::none;
   MappingQ<dim,spacedim>::fill_fe_values (cell, q, cell_similarity, mapping_data,
                                          quadrature_points, JxW_values, jacobians,
                                          jacobian_grads, inverse_jacobians,
index 9ef30e4069de00a230454e59eb47f7d95a4021c7..496c11b1755e8db622cffe87e7ebc116cdc2b767 100755 (executable)
@@ -406,7 +406,9 @@ namespace TrilinosWrappers
          for (int col=0; col < row_length; ++col)
            row_indices[col] = sparsity_pattern.column_number (row, col);
 
-         graph->InsertGlobalIndices (row, row_length, &row_indices[0]);
+         graph->InsertGlobalIndices (static_cast<int>(row), 
+                                     row_length, &row_indices[0]);
+
        }
 
                                  // Now, fill the graph (sort indices, make

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.