]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Only test for distorted cells if so instructed by the user.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 20 Feb 2010 00:08:34 +0000 (00:08 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sat, 20 Feb 2010 00:08:34 +0000 (00:08 +0000)
git-svn-id: https://svn.dealii.org/trunk@20655 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/source/grid/tria.cc
deal.II/doc/doxygen/headers/glossary.h
deal.II/doc/news/changes.h

index 2d371d03c66cb85c3c5208d64251ec7b75017131..12f3b4070e073f7b69ad97d7da20a1828d5edbb7 100644 (file)
@@ -1119,8 +1119,8 @@ namespace internal
  *   Therefore if your new boundary vertex is too near the center of
  *   the old quadrilateral or hexahedron, the distance to the midpoint
  *   vertex will become too small, thus generating distorted
- *   cells. Remedy: take care of such situations when defining the
- *   coarse grid.
+ *   cells. This issue is discussed extensively in
+ *   @ref GlossDistorted "distorted cells".
  *
  *
  *   <h3>Technical details</h3>
@@ -1388,7 +1388,13 @@ class Triangulation : public Subscriptor
                                      * execute_coarsening_and_refinement()
                                      * functions, and they can be
                                      * caught in user code if this
-                                     * condition is to be ignored.
+                                     * condition is to be
+                                     * ignored. Note, however, that
+                                     * such exceptions are only
+                                     * produced if the necessity for
+                                     * this check was indicated when
+                                     * calling the constructor of the
+                                     * Triangulation class.
                                      *
                                      * A cell is called
                                      * <i>deformed</i> if the
@@ -1443,8 +1449,30 @@ class Triangulation : public Subscriptor
                                      *  Create an empty
                                      *  triangulation. Do not create
                                      *  any cells.
+                                     *
+                                     * @param smooth_grid Determines
+                                     * the level of smoothness of the
+                                     * mesh size function that should
+                                     * be enforced upon mesh
+                                     * refinement.
+                                     *
+                                     * @param
+                                     * check_for_distorted_cells
+                                     * Determines whether the
+                                     * triangulation should check
+                                     * whether any of the cells that
+                                     * are created by
+                                     * create_triangulation() or
+                                     * execute_coarsening_and_refinement()
+                                     * are distorted (see @ref
+                                     * GlossDistorted "distorted
+                                     * cells"). If set, these two
+                                     * functions may throw an
+                                     * exception if they encounter
+                                     * distorted cells.
                                      */
-    Triangulation (const MeshSmoothing smooth_grid = none);
+    Triangulation (const MeshSmoothing smooth_grid = none,
+                  const bool check_for_distorted_cells = false);
 
                                     /**
                                      *  Copy constructor.
@@ -1672,19 +1700,24 @@ class Triangulation : public Subscriptor
                                      * and the GridIn and
                                      * GridReordering class.
                                      *
-                                     * At the very end of its
-                                     * operation, this function walks
+                                     * If the
+                                     * <code>check_for_distorted_cells</code>
+                                     * flag was specified upon
+                                     * creation of this object, at
+                                     * the very end of its operation,
+                                     * the current function walks
                                      * over all cells and verifies
                                      * that none of the cells is
-                                     * deformed (see
-                                     * the entry on @ref GlossDistorted in
-                                     * the glossary), where we call a cell
-                                     * deformed if the determinant of
-                                     * the Jacobian of the mapping
-                                     * from reference cell to real
-                                     * cell is negative at least at
-                                     * one of the vertices (this
-                                     * computation is done using the
+                                     * deformed (see the entry on
+                                     * @ref GlossDistorted "distorted
+                                     * cells" in the glossary), where
+                                     * we call a cell deformed if the
+                                     * determinant of the Jacobian of
+                                     * the mapping from reference
+                                     * cell to real cell is negative
+                                     * at least at one of the
+                                     * vertices (this computation is
+                                     * done using the
                                      * GeometryInfo::jacobian_determinants_at_vertices
                                      * function). If there are
                                      * deformed cells, this function
@@ -1829,6 +1862,12 @@ class Triangulation : public Subscriptor
                                      * does not create such an
                                      * exception if no cells have
                                      * created distorted children.
+                                     * Note that for the check for
+                                     * distorted cells to happen, the
+                                     * <code>check_for_distorted_cells</code>
+                                     * flag has to be specified upon
+                                     * creation of a triangulation
+                                     * object.
                                      *
                                       * See the general docs for more
                                       * information.
@@ -3202,7 +3241,11 @@ class Triangulation : public Subscriptor
                                      *  of cells that have produced
                                      *  children that satisfy the
                                      *  criteria of
-                                     *  @ref GlossDistorted "distorted cells".
+                                     *  @ref GlossDistorted "distorted cells"
+                                     * if the
+                                     * <code>check_for_distorted_cells</code>
+                                     * flag was specified upon
+                                     * creation of this object, at
                                      */
     DistortedCellList execute_refinement ();
 
@@ -3289,6 +3332,14 @@ class Triangulation : public Subscriptor
                                      */
     MeshSmoothing                    smooth_grid;
 
+                                    /**
+                                     * A flag that determines whether
+                                     * we are to check for distorted
+                                     * cells upon creation and
+                                     * refinement of a mesh.
+                                     */
+    const bool check_for_distorted_cells;
+
                                     /**
                                      * Cache to hold the numbers of lines,
                                      * quads, hexes, etc. These numbers
index d2dc8a9ffb7adbfafd12579d67230f97a4b7fef1..335b99e467d7a132df5274f589b9114db8bc0740 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -4063,7 +4063,8 @@ namespace internal
        template <int spacedim>
        static
        typename Triangulation<1,spacedim>::DistortedCellList
-       execute_refinement (Triangulation<1,spacedim> &triangulation)
+       execute_refinement (Triangulation<1,spacedim> &triangulation,
+                           const bool check_for_distorted_cells)
          {
            const unsigned int dim = 1;
 
@@ -4333,7 +4334,8 @@ namespace internal
        template <int spacedim>
        static
        typename Triangulation<2,spacedim>::DistortedCellList
-       execute_refinement (Triangulation<2,spacedim> &triangulation)
+       execute_refinement (Triangulation<2,spacedim> &triangulation,
+                           const bool check_for_distorted_cells)
          {
            const unsigned int dim = 2;
 
@@ -4717,7 +4719,9 @@ namespace internal
                                       next_unused_cell,
                                       cell);
 
-                     if (has_distorted_children (cell,
+                     if ((check_for_distorted_cells == true)
+                         &&
+                         has_distorted_children (cell,
                                                  internal::int2type<dim>(),
                                                  internal::int2type<spacedim>()))
                        cells_with_distorted_children.distorted_cells.push_back (cell);
@@ -4735,7 +4739,8 @@ namespace internal
        template <int spacedim>
        static
        typename Triangulation<3,spacedim>::DistortedCellList
-       execute_refinement (Triangulation<3,spacedim> &triangulation)
+       execute_refinement (Triangulation<3,spacedim> &triangulation,
+                           const bool check_for_distorted_cells)
          {
            const unsigned int dim = 3;
 
@@ -8680,7 +8685,9 @@ namespace internal
                                                       // and if so
                                                       // add them to
                                                       // our list
-                     if (has_distorted_children (hex,
+                     if ((check_for_distorted_cells == true)
+                         &&
+                         has_distorted_children (hex,
                                                  internal::int2type<dim>(),
                                                  internal::int2type<spacedim>()))
                        cells_with_distorted_children.distorted_cells.push_back (hex);
@@ -9148,11 +9155,14 @@ Triangulation<dim, spacedim>::dimension;
 
 
 template <int dim, int spacedim>
-Triangulation<dim, spacedim>::Triangulation (const MeshSmoothing smooth_grid)
+Triangulation<dim, spacedim>::
+Triangulation (const MeshSmoothing smooth_grid,
+              const bool check_for_distorted_cells)
                :
                faces(NULL),
                anisotropic_refinement(false),
-               smooth_grid(smooth_grid)
+               smooth_grid(smooth_grid),
+               check_for_distorted_cells(check_for_distorted_cells)
 {
                                   // set default boundary for all
                                   // possible components
@@ -9162,12 +9172,14 @@ Triangulation<dim, spacedim>::Triangulation (const MeshSmoothing smooth_grid)
 
 
 template <int dim, int spacedim>
-Triangulation<dim, spacedim>::Triangulation (const Triangulation<dim, spacedim> &)
+Triangulation<dim, spacedim>::
+Triangulation (const Triangulation<dim, spacedim> &)
                                   // do not set any subscriptors;
                                   // anyway, calling this constructor
                                   // is an error!
                :
-               Subscriptor()
+               Subscriptor(),
+               check_for_distorted_cells(check_for_distorted_cells)
 {
   Assert (false, ExcInternalError());
 }
@@ -9365,14 +9377,17 @@ create_triangulation (const std::vector<Point<spacedim> >    &v,
                                   // first collect all distorted
                                   // cells and then throw an
                                   // exception if there are any
-  DistortedCellList distorted_cells = collect_distorted_coarse_cells (*this);
-                                  // throw the array (and fill the
-                                  // various location fields) if
-                                  // there are distorted
-                                  // cells. otherwise, just fall off
-                                  // the end of the function
-  AssertThrow (distorted_cells.distorted_cells.size() == 0,
-              distorted_cells);
+  if (check_for_distorted_cells == true)
+    {
+      DistortedCellList distorted_cells = collect_distorted_coarse_cells (*this);
+                                      // throw the array (and fill the
+                                      // various location fields) if
+                                      // there are distorted
+                                      // cells. otherwise, just fall off
+                                      // the end of the function
+      AssertThrow (distorted_cells.distorted_cells.size() == 0,
+                  distorted_cells);
+    }
 }
 
 
@@ -12114,7 +12129,9 @@ Triangulation<dim,spacedim>::execute_refinement ()
 {
   const DistortedCellList
     cells_with_distorted_children
-    = internal::Triangulation::Implementation::execute_refinement (*this);
+    =
+    internal::Triangulation::Implementation::
+    execute_refinement (*this,check_for_distorted_cells);
 
 
 
index f438f05ba636bcb2747b442c56ec34ca19b08d2f..7d579b54fb6b2c2bb5c53574f564c8157eedcf93 100644 (file)
  * as the result of mesh refinement if the boundary description in use
  * is sufficiently irregular.
  *
- * The function Triangulation::create_triangulation, which is called
+ * If the appropriate flag is given upon creation of a triangulation,
+ * the function Triangulation::create_triangulation, which is called
  * by the various functions in GridGenerator and GridIn (but can also
- * be called from user code, see step-14 will signal
+ * be called from user code, see step-14, will signal
  * the creation of coarse meshes with distorted cells by throwing an
  * exception of type Triangulation::DistortedCellList. There are
  * legitimate cases for creating meshes with distorted cells (in
  * fix up exactly these cells if possible by moving around the node at
  * the center of the cell.
  *
+ * Note that the Triangulation class does not test for the presence of
+ * distorted cells by default, since the determination whether a cell
+ * is distorted or not is not a cheap operation. If you want a
+ * Triangulation object to test for distortion of cells, you need to
+ * specify this upon creation of the object by passing the appropriate
+ * flag.
+ *
  *
  * <dt class="glossary">@anchor GlossFaceOrientation <b>Face orientation</b></dt>
  * <dd>In a triangulation, the normal vector to a face
index b8154b523939c9451ea09c53beff2123c28dcabc..97824207521b89dcd7d4cd0fb1123c2c70c2dbea 100644 (file)
@@ -60,31 +60,6 @@ inconvenience this causes.
   <br>
   (GK 2009/08/04)
   </p>
-
-  <li>
-  <p>
-  Changed: Previously, the Triangulation::create_triangulation
-  function silently accepted input meshes with inverted cells
-  (i.e. cells with a zero or negative determinant of the Jacobian of
-  the mapping from the reference cell to the real cell). This has been
-  changed now: The function checks whether cells are distorted or
-  inverted, and may throw an exception containing a list of cells
-  for which this is the case. If you know that this is harmless, for
-  example if you have cells with collapsed vertices in your mesh but
-  you do not intend to integrate on them, then you can catch and
-  ignore this message. In all other cases, the output of your
-  computations are likely to be wrong anyway.
-  <br>
-  The same is true for the Triangulation::execute_coarsening_and_refinement
-  function: if it creates cells that are distorted, it throws a list of cells
-  whose children are distorted.
-  <br>
-  The whole issue is described in some detail in the entry on
-  @ref GlossDistorted "distorted cells" in the glossary.
-  <br>
-  (WB 2009/06/29)
-  </p>
-  </li>
 </ol>
 
 
@@ -604,7 +579,7 @@ inconvenience this causes.
   <p>
   New: The class MGTransferSelect is prepared for use on adaptively refined meshes.
   <br>
-  (Bärbel Janssen 2010/02/05)
+  (B&auml;rbel Janssen 2010/02/05)
   </p>
   </li>
 
@@ -613,7 +588,7 @@ inconvenience this causes.
   New: The function Cuthill_McKee in namespace DoFRenumbering is now also compiled for
   MGDoFHandler as well as the make_sparsity_pattern functions in DoFTools.
   <br>
-  (Bärbel Janssen 2010/01/08)
+  (B&auml;rbel Janssen 2010/01/08)
   </p>
   </li>
 
@@ -737,6 +712,34 @@ inconvenience this causes.
   </p>
   </li>
 
+  <li>
+  <p>
+  New: Previously, the Triangulation::create_triangulation
+  function silently accepted input meshes with inverted cells
+  (i.e. cells with a zero or negative determinant of the Jacobian of
+  the mapping from the reference cell to the real cell). This can been
+  changed now: By passing the appropriate flag to the constructor of
+  the Triangulation class, the Triangulation::create_triangulation
+  function checks whether cells are distorted or
+  inverted, and may throw an exception containing a list of cells
+  for which this is the case. If you know that this is harmless, for
+  example if you have cells with collapsed vertices in your mesh but
+  you do not intend to integrate on them, then you can catch and
+  ignore this message. In all other cases, the output of your
+  computations are likely to be wrong anyway.
+  <br>
+  The same is true for the Triangulation::execute_coarsening_and_refinement
+  function: if it creates cells that are distorted, it throws a list of cells
+  whose children are distorted.
+  <br>
+  The whole issue is described in some detail in the entry on
+  @ref GlossDistorted "distorted cells" in the glossary.
+  <br>
+  (WB 2009/06/29)
+  </p>
+  </li>
+
+
   <li>
   <p>
   New: The new hp::DoFHandler::set_active_fe_indices function allows

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.