get_longest_direction(typename Triangulation<dim, spacedim>::active_cell_iterator cell);
/**
- * Remove hanging nodes from a grid. @p isotropic (default) allows to reproduce
- * the proportion of each cell in child cells.
- * Since this procedure could require a large number of iterations,
- * a max number of iteration is provided.
+ * Remove hanging nodes from a grid. If the @p isotropic parameter is set
+ * to @p false (default) this function detects cells with hanging nodes and
+ * refines the neighbours in the direction that removes hanging nodes.
+ * If the @p isotropic parameter is set
+ * to @p true, the neighbours refinement is made in each directions.
+ * In order to remove all hanging nodes this procedure has to be repeated:
+ * this could require a large number of iterations.
+ * To avoid this a max number (@p max_iterations) of iteration is provided.
*
* Consider the following grid:
* @image html remove_hanging_nodes-hanging.png
* @param[in] isotropic if true refine cells in each directions, otherwise
* (default value) refine the cell in the direction that removes hanging node.
*
- * @param[in] max_iterations at each step only closest cells to hanging
- * nodes are refined. In order to remove completely hangind nodes one may have
- * infinite loops. @p max_iterations is the maximum number of iteration allowed.
- * If @p max_iterations == 0 this function continues refining until
+ * @param[in] max_iterations at each step only closest cells to hanging nodes
+ * are refined. The code may require a lot of iterations to to remove all
+ * hangind nodes. @p max_iterations is the maximum number of iteration
+ * allowed. If @p max_iterations == 0 this function continues refining until
* there are no hanging nodes.
+ *
+ * @note In the case of parallel codes, this function should be combined
+ * with GridGenerator::flatten_triangulation.
*/
template<int dim, int spacedim>
void
* the dimensions of each cell.
*
* @param[in] max_iterations maximum number of iterations allowed.
+ *
+ * @note In the case of parallel codes, this function should be combined
+ * with GridGenerator::flatten_triangulation and remove_hanging_nodes.
*/
template<int dim, int spacedim>
void
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2013 - 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+#include "../tests.h"
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/base/point.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/base/logstream.h>
+#include <cmath>
+#include <cstdlib>
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+
+std::ofstream logfile ("output");
+
+void check_remove_anisotropy ()
+{
+ Point<3> (corners) [3];
+
+ corners[0] = Point<3> (1, 0, 0);
+ corners[1] = Point<3> (0, 4, 0);
+ corners[2] = Point<3> (0, 0, 2);
+
+ const unsigned int n_subdivisions = 1;
+
+ Triangulation<3> triangulation;
+ GridGenerator::subdivided_parallelepiped (triangulation, n_subdivisions, corners);
+ dealii::GridTools::remove_anisotropy<3>(triangulation,
+ /*max ratio =*/ 1.2);
+
+ GridOut grid_out;
+ grid_out.write_vtk (triangulation, logfile);
+
+ triangulation.clear ();
+}
+
+int main ()
+{
+ check_remove_anisotropy();
+}
--- /dev/null
+# vtk DataFile Version 3.0
+#This file was generated
+ASCII
+DATASET UNSTRUCTURED_GRID
+
+POINTS 64 double
+0 0 0
+1 0 0
+0 1 0
+1 1 0
+0 0 1
+1 0 1
+0 1 1
+1 1 1
+0 0 1
+1 0 1
+0 1 1
+1 1 1
+0 0 2
+1 0 2
+0 1 2
+1 1 2
+0 1 0
+1 1 0
+0 2 0
+1 2 0
+0 1 1
+1 1 1
+0 2 1
+1 2 1
+0 1 1
+1 1 1
+0 2 1
+1 2 1
+0 1 2
+1 1 2
+0 2 2
+1 2 2
+0 2 0
+1 2 0
+0 3 0
+1 3 0
+0 2 1
+1 2 1
+0 3 1
+1 3 1
+0 2 1
+1 2 1
+0 3 1
+1 3 1
+0 2 2
+1 2 2
+0 3 2
+1 3 2
+0 3 0
+1 3 0
+0 4 0
+1 4 0
+0 3 1
+1 3 1
+0 4 1
+1 4 1
+0 3 1
+1 3 1
+0 4 1
+1 4 1
+0 3 2
+1 3 2
+0 4 2
+1 4 2
+
+CELLS 8 72
+8 0 1 3 2 4 5 7 6
+8 8 9 11 10 12 13 15 14
+8 16 17 19 18 20 21 23 22
+8 24 25 27 26 28 29 31 30
+8 32 33 35 34 36 37 39 38
+8 40 41 43 42 44 45 47 46
+8 48 49 51 50 52 53 55 54
+8 56 57 59 58 60 61 63 62
+
+CELL_TYPES 8
+ 12 12 12 12 12 12 12 12
+POINT_DATA 64
+SCALARS level double 1
+LOOKUP_TABLE default
+3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
+SCALARS manifold double 1
+LOOKUP_TABLE default
+-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
+SCALARS material double 1
+LOOKUP_TABLE default
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+SCALARS subdomain double 1
+LOOKUP_TABLE default
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+SCALARS level_subdomain double 1
+LOOKUP_TABLE default
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2013 - 2015 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include "../tests.h"
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/base/point.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/base/logstream.h>
+#include <cmath>
+#include <cstdlib>
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+
+std::ofstream logfile ("output");
+
+void check_remove_hanging_nodes ()
+{
+ Point<2> corners[2];
+
+ corners[0] = Point<2> (1, 0);
+ corners[1] = Point<2> (0, 4);
+ const unsigned int n_subdivisions = 1;
+
+
+ Triangulation<2> tria;
+ GridGenerator::subdivided_parallelepiped (tria, n_subdivisions, corners);
+
+ tria.refine_global();
+
+ tria.begin_active()->set_refine_flag();
+ tria.execute_coarsening_and_refinement();
+
+ tria.refine_global();
+
+ dealii::GridTools::remove_hanging_nodes(tria, /*isotropic=*/false);
+
+ GridOut grid_out;
+ grid_out.write_vtk (tria, logfile);
+
+ tria.clear ();
+}
+
+int main ()
+{
+ check_remove_hanging_nodes();
+}
--- /dev/null
+# vtk DataFile Version 3.0
+#This file was generated
+ASCII
+DATASET UNSTRUCTURED_GRID
+
+POINTS 144 double
+0.5 2 0
+0.75 2 0
+0.5 3 0
+0.75 3 0
+0.75 2 0
+1 2 0
+0.75 3 0
+1 3 0
+0.5 3 0
+0.75 3 0
+0.5 4 0
+0.75 4 0
+0.75 3 0
+1 3 0
+0.75 4 0
+1 4 0
+0 0 0
+0.125 0 0
+0 0.5 0
+0.125 0.5 0
+0.125 0 0
+0.25 0 0
+0.125 0.5 0
+0.25 0.5 0
+0 0.5 0
+0.125 0.5 0
+0 1 0
+0.125 1 0
+0.125 0.5 0
+0.25 0.5 0
+0.125 1 0
+0.25 1 0
+0.25 0 0
+0.375 0 0
+0.25 0.5 0
+0.375 0.5 0
+0.375 0 0
+0.5 0 0
+0.375 0.5 0
+0.5 0.5 0
+0.25 0.5 0
+0.375 0.5 0
+0.25 1 0
+0.375 1 0
+0.375 0.5 0
+0.5 0.5 0
+0.375 1 0
+0.5 1 0
+0 1 0
+0.125 1 0
+0 1.5 0
+0.125 1.5 0
+0.125 1 0
+0.25 1 0
+0.125 1.5 0
+0.25 1.5 0
+0 1.5 0
+0.125 1.5 0
+0 2 0
+0.125 2 0
+0.125 1.5 0
+0.25 1.5 0
+0.125 2 0
+0.25 2 0
+0.25 1 0
+0.375 1 0
+0.25 1.5 0
+0.375 1.5 0
+0.375 1 0
+0.5 1 0
+0.375 1.5 0
+0.5 1.5 0
+0.25 1.5 0
+0.375 1.5 0
+0.25 2 0
+0.375 2 0
+0.375 1.5 0
+0.5 1.5 0
+0.375 2 0
+0.5 2 0
+0.5 0 0
+0.75 0 0
+0.5 0.5 0
+0.75 0.5 0
+0.5 0.5 0
+0.75 0.5 0
+0.5 1 0
+0.75 1 0
+0.5 1 0
+0.75 1 0
+0.5 1.5 0
+0.75 1.5 0
+0.5 1.5 0
+0.75 1.5 0
+0.5 2 0
+0.75 2 0
+0 2 0
+0.125 2 0
+0 3 0
+0.125 3 0
+0.125 2 0
+0.25 2 0
+0.125 3 0
+0.25 3 0
+0.25 2 0
+0.375 2 0
+0.25 3 0
+0.375 3 0
+0.375 2 0
+0.5 2 0
+0.375 3 0
+0.5 3 0
+0.75 0 0
+1 0 0
+0.75 0.5 0
+1 0.5 0
+0.75 0.5 0
+1 0.5 0
+0.75 1 0
+1 1 0
+0.75 1 0
+1 1 0
+0.75 1.5 0
+1 1.5 0
+0.75 1.5 0
+1 1.5 0
+0.75 2 0
+1 2 0
+0 3 0
+0.125 3 0
+0 4 0
+0.125 4 0
+0.125 3 0
+0.25 3 0
+0.125 4 0
+0.25 4 0
+0.25 3 0
+0.375 3 0
+0.25 4 0
+0.375 4 0
+0.375 3 0
+0.5 3 0
+0.375 4 0
+0.5 4 0
+
+CELLS 36 180
+4 0 1 3 2
+4 4 5 7 6
+4 8 9 11 10
+4 12 13 15 14
+4 16 17 19 18
+4 20 21 23 22
+4 24 25 27 26
+4 28 29 31 30
+4 32 33 35 34
+4 36 37 39 38
+4 40 41 43 42
+4 44 45 47 46
+4 48 49 51 50
+4 52 53 55 54
+4 56 57 59 58
+4 60 61 63 62
+4 64 65 67 66
+4 68 69 71 70
+4 72 73 75 74
+4 76 77 79 78
+4 80 81 83 82
+4 84 85 87 86
+4 88 89 91 90
+4 92 93 95 94
+4 96 97 99 98
+4 100 101 103 102
+4 104 105 107 106
+4 108 109 111 110
+4 112 113 115 114
+4 116 117 119 118
+4 120 121 123 122
+4 124 125 127 126
+4 128 129 131 130
+4 132 133 135 134
+4 136 137 139 138
+4 140 141 143 142
+
+CELL_TYPES 36
+ 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
+POINT_DATA 144
+SCALARS level double 1
+LOOKUP_TABLE default
+2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3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