]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement a TriaAccessor::is_translation_of function and use it in FEValues.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 20 May 2009 20:50:07 +0000 (20:50 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 20 May 2009 20:50:07 +0000 (20:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@18871 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria_accessor.h
deal.II/deal.II/include/grid/tria_accessor.templates.h
deal.II/deal.II/source/fe/fe_values.cc
deal.II/doc/news/changes.h

index 50cee74d264830e1349a476e104794f33e04c38c..f79ee92b7cc9a19b36be7b5a4af87c9afab67f41 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -1045,7 +1045,7 @@ class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim>
                                      * Return the RefinementCase
                                      * of this cell.
                                      */
-    RefinementCase<structdim> refinement_case() const;
+    RefinementCase<structdim> refinement_case () const;
 
                                     /**
                                      *  Index of the @p ith child.
@@ -1367,6 +1367,36 @@ class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim>
                                      * used.
                                      */
     double measure () const;
+
+                                    /**
+                                     * Return true if the current object is a
+                                     * translation of the given argument.
+                                     *
+                                     * @note For the purpose of a
+                                     * triangulation, cells, faces, etc are
+                                     * only characterized by their
+                                     * vertices. The current function
+                                     * therefore only compares the locations
+                                     * of vertices. For many practical
+                                     * applications, however, it is not only
+                                     * the vertices that determine whether
+                                     * one cell is a translation of another,
+                                     * but also how the cell is mapped from
+                                     * the reference cell to its location in
+                                     * real space. For example, if we are
+                                     * using higher order mappings, then not
+                                     * only do the vertices have to be
+                                     * translations of each other, but also
+                                     * the points along edges. In these
+                                     * questions, therefore, it would be
+                                     * appropriate to ask the mapping, not
+                                     * the current function, whether two
+                                     * objects are translations of each
+                                     * other.
+                                     */
+    bool
+    is_translation_of (const TriaIterator<TriaAccessor<structdim,dim,spacedim> > &o) const;
+    
                                     /**
                                      * @}
                                      */
index 690c2060622b17678a15bddafe4faa85e542c01a..0fd98bff7c98dc9e576ff13040c87af5f53d1cd8 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -1896,6 +1896,43 @@ TriaAccessor<structdim, dim, spacedim>::center () const
 }
 
 
+template <int structdim, int dim, int spacedim>
+bool
+TriaAccessor<structdim, dim, spacedim>::
+is_translation_of (const TriaIterator<TriaAccessor<structdim,dim,spacedim> > &o) const
+{
+                                  // 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 down to
+                                  // rounding errors (we have to be careful
+                                  // here because the calculation of the
+                                  // displacement between one cell and the
+                                  // next can already result in the loss of
+                                  // one or two digits), so we choose 1e-12
+                                  // times the distance between the zeroth
+                                  // vertices here.
+  bool is_translation = true;
+  const Point<spacedim> dist = o->vertex(0) - this->vertex(0);
+  const double tol_square = 1e-24 * dist.norm_square();
+  for (unsigned int i=1; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
+    {
+      const Point<spacedim> dist_new = (o->vertex(i) - this->vertex(i)) - dist;
+      if (dist_new.norm_square() > tol_square)
+       {
+         is_translation = false;
+         break;
+       }
+    }
+  return is_translation;
+}
+
+
+
 /*------------------------ Functions: CellAccessor<dim,spacedim> -----------------------*/
 
 
index 36cf4cefd537be29ff3d5242d325ed61cc008d37..db9a1eecd99561025d5320c591c857a366888ad6 100644 (file)
@@ -3249,65 +3249,22 @@ FEValuesBase<dim,spacedim>::check_cell_similarity
                                   // case that there has not been any cell
                                   // before
   if (&*this->present_cell == 0)
-    {
-      cell_similarity = CellSimilarity::none;
-      return;
-    }
-
-                                  // in MappingQ, data can have been
-                                  // modified during the last call. Then,
-                                  // we can't use that data on the new
-                                  // cell.
-  if (cell_similarity == CellSimilarity::invalid_next_cell)
-    {
+    cell_similarity = CellSimilarity::none;
+  else
+                                    // in MappingQ, data can have been
+                                    // modified during the last call. Then,
+                                    // we can't use that data on the new
+                                    // cell.
+    if (cell_similarity == CellSimilarity::invalid_next_cell)
       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 down to
-                                  // rounding errors (we have to be
-                                  // careful here because the
-                                  // calculation of the displacement
-                                  // between one cell and the next can
-                                  // already result in the loss of one
-                                  // or two digits), so we choose 1e-12
-                                  // times the distance between the
-                                  // zeroth vertices here.
-    bool is_translation = true;
-    const Point<spacedim> dist = cell->vertex(0) - present_cell->vertex(0);
-    const double tolerance = 1e-24 * dist.norm_square();
-    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() > tolerance)
-         {
-           is_translation = false;
-           break;
-         }
-      }
-
-    cell_similarity = (is_translation == true 
-                      ? 
-                      CellSimilarity::translation 
-                      : 
-                      CellSimilarity::none);
-    return;
-  }
-
+    else
+      cell_similarity = (cell->is_translation_of
+                        (static_cast<const typename Triangulation<dim,spacedim>::cell_iterator>(*this->present_cell))
+                        ? 
+                        CellSimilarity::translation 
+                        : 
+                        CellSimilarity::none);
+  
                                   // TODO: here, one could implement other
                                   // checks for similarity, e.g. for
                                   // children of a parallelogram.
index c955c9702b8b73f53f914390d5214df10fe4a3c9..7558e3ae7865a01c635e835929ee367550be0e0e 100644 (file)
@@ -125,6 +125,15 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+  <li>
+  <p>
+  New: The new function TriaAccessor::is_translation_of computes
+  whether a cell, face, or edge is a translation of another.
+  <br>
+  (Martin Kronbichler, WB 2009/05/19)
+  </p>
+  </li>
+
   <li>
   <p>
   New: The DoFTools::make_sparsity_pattern functions have acquired a
@@ -139,7 +148,7 @@ inconvenience this causes.
   (WB 2009/04/29)
   </p>
   </li>
-
+  
    <li>
    <p>
    Fixed: The DoFRenumbering::component_wise function for MGDoFHandler objects

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.