<ol>
- <li> Ported: The build system now supports cmake-3.0.0
+ <li> Ported: The build system now supports CMake 3.0.
<br>
(Matthias Maier, 2014/07/15)
</li>
<h3>Specific improvements</h3>
<ol>
+ <li> New: The function GridTools::get_patch_around_cell() extracts
+ the set of cells that surround a single cell.
+ <br>
+ (Arezou Ghesmati, Wolfgang Bangerth, 2014/07/21)
+ </li>
+
<li> Fixed: Utilities::string_to_int() and
Utilities::string_to_double() did not catch if the
string given started with an integer or double but contained additional
fix_up_distorted_child_cells (const typename Triangulation<dim,spacedim>::DistortedCellList &distorted_cells,
Triangulation<dim,spacedim> &triangulation);
+ /*@}*/
+ /**
+ * @name Extracting and creating patches of cells surrounding a single cell
+ */
+ /*@{*/
+
+
+ /**
+ * This function returns a list of all the neighbor cells of the given cell.
+ * Here, a neighbor is defined as one having at least part of a face in common
+ * with the given cell, but not edge (in 3d) or vertex neighbors (in 2d and
+ * 3d).
+ *
+ * The first element of the returned list is the cell provided as
+ * argument. The remaining ones are neighbors: The function loops over all
+ * faces of that given cell and checks if that face is not on the boundary of
+ * the domain. Then, if the neighbor cell does not have any children (i.e., it
+ * is either at the same refinement level as the current cell, or coarser)
+ * then this neighbor cell is added to the list of cells. Otherwise, if the
+ * neighbor cell is refined and therefore has children, then this function
+ * loops over all subfaces of current face adds the neighbors behind these
+ * sub-faces to the list to be returned.
+ *
+ * The <code>Container</code> template argument can be either a triangulation
+ * or any of the DoF handler classes. Because the C++ language specifies that
+ * the container type can not be inferred from an iterator alone, you will
+ * need to explicitly specify the template argument when calling this
+ * function.
+ *
+ * @note Patches are often used in defining error estimators that require the
+ * solution of a local problem on the patch surrounding each of the cells of
+ * the mesh. This also requires manipulating the degrees of freedom associated
+ * with the cells of a patch. To this end, there are further functions working
+ * on patches in namespace DoFTools.
+ */
+ template <class Container>
+ std::vector<typename Container::active_cell_iterator>
+ get_patch_around_cell(const typename Container::active_cell_iterator &cell);
+
/*@}*/
/**
* @name Lower-dimensional meshes for parts of higher-dimensional meshes
+ template <class Container>
+ std::vector<typename Container::active_cell_iterator>
+ get_patch_around_cell(const typename Container::active_cell_iterator &cell)
+ {
+ std::vector<typename Container::active_cell_iterator> patch;
+ patch.push_back (cell);
+ for (unsigned int face_number=0; face_number<GeometryInfo<Container::dimension>::faces_per_cell; ++face_number)
+ if (cell->face(face_number)->at_boundary()==false)
+ {
+ if (cell->neighbor(face_number)->has_children() == false)
+ patch.push_back (cell->neighbor(face_number));
+ else
+ // the neighbor is refined. in 2d/3d, we can simply ask for the children
+ // of the neighbor because they can not be further refined and,
+ // consequently, the children is active
+ if (Container::dimension > 1)
+ {
+ for (unsigned int subface=0; subface<cell->face(face_number)->n_children(); ++subface)
+ patch.push_back (cell->neighbor_child_on_subface (face_number, subface));
+ }
+ else
+ {
+ // in 1d, we need to work a bit harder: iterate until we find
+ // the child by going from cell to child to child etc
+ typename Container::cell_iterator neighbor
+ = cell->neighbor (face_number);
+ while (neighbor->has_children())
+ neighbor = neighbor->child(1-face_number);
+
+ Assert (neighbor->neighbor(1-face_number) == cell, ExcInternalError());
+ patch.push_back (neighbor);
+ }
+ }
+ return patch;
+ }
+
+
+
+
template <template <int,int> class Container, int dim, int spacedim>
#ifndef _MSC_VER
std::map<typename Container<dim-1,spacedim>::cell_iterator,
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; Container : TRIANGULATION_AND_DOFHANDLER_TEMPLATES)
{
#if deal_II_dimension <= deal_II_space_dimension
-#if deal_II_dimension != 1
namespace GridTools \{
template
+ std::vector<Container<deal_II_dimension,deal_II_space_dimension>::active_cell_iterator>
+ get_patch_around_cell<Container<deal_II_dimension,deal_II_space_dimension> >
+ (const Container<deal_II_dimension,deal_II_space_dimension>::active_cell_iterator &cell);
+
+
+#if deal_II_dimension != 1
+ template
#ifndef _MSC_VER
- std::map< Container<deal_II_dimension-1,deal_II_space_dimension>::cell_iterator,
+ std::map<Container<deal_II_dimension-1,deal_II_space_dimension>::cell_iterator,
Container<deal_II_dimension,deal_II_space_dimension>::face_iterator>
#else
ExtractBoundaryMesh<Container,deal_II_dimension,deal_II_space_dimension>::return_type
extract_boundary_mesh (const Container<deal_II_dimension, deal_II_space_dimension> &mesh,
Container<deal_II_dimension-1,deal_II_space_dimension> &boundary_mesh,
const std::set<types::boundary_id> &boundary_ids);
- \}
#endif
+ \}
#endif
}
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2014 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Test GridTools::get_patch_around_cell()
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
+
+#include <fstream>
+
+
+
+
+template<int dim>
+void test()
+{
+ Triangulation<dim> triangulation (Triangulation<dim>::limit_level_difference_at_vertices);
+
+ GridGenerator::hyper_cube(triangulation);
+ triangulation.refine_global (2);
+
+ const unsigned int n_refinements[] = { 0, 4, 3, 2 };
+ for (unsigned int i=0; i<n_refinements[dim]; ++i)
+ {
+ // refine one-fifth of cells randomly
+ std::vector<bool> flags (triangulation.n_active_cells(), false);
+ for (unsigned int k=0; k<flags.size()/5 + 1; ++k)
+ flags[Testing::rand() % flags.size()] = true;
+ // make sure there's at least one that
+ // will be refined
+ flags[0] = true;
+
+ // refine triangulation
+ unsigned int index=0;
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell != triangulation.end(); ++cell, ++index)
+ if (flags[index])
+ cell->set_refine_flag();
+ Assert (index == triangulation.n_active_cells(), ExcInternalError());
+
+ // flag all other cells for coarsening
+ // (this should ensure that at least
+ // some of them will actually be
+ // coarsened)
+ index=0;
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell != triangulation.end(); ++cell, ++index)
+ if (!flags[index])
+ cell->set_coarsen_flag();
+
+ triangulation.execute_coarsening_and_refinement ();
+ }
+
+ // now extract patches and print every fifth of them
+ unsigned int index = 0;
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell != triangulation.end(); ++cell, ++index)
+ {
+ std::vector<typename Triangulation<dim>::active_cell_iterator> patch_cells
+ = GridTools::get_patch_around_cell<Triangulation<dim> > (cell);
+
+ if (index % 5 == 0)
+ {
+ deallog << "Patch around cell " << cell << ": ";
+ for (unsigned int i=0; i<patch_cells.size(); ++i)
+ deallog << patch_cells[i] << ' ';
+ deallog << std::endl;
+ }
+ }
+}
+
+
+int main()
+{
+ initlog();
+ deallog.threshold_double(1.e-10);
+
+ deallog.push("1d");
+ test<1>();
+ deallog.pop();
+
+ deallog.push("2d");
+ test<2>();
+ deallog.pop();
+
+ deallog.push("3d");
+ test<3>();
+ deallog.pop();
+}
--- /dev/null
+
+DEAL:1d::Patch around cell 2.3: 2.3 3.7
+DEAL:1d::Patch around cell 4.2: 4.2 5.1 4.3
+DEAL:1d::Patch around cell 5.1: 5.1 5.0 4.2
+DEAL:2d::Patch around cell 2.1: 2.1 3.1 3.3 3.40 3.42 3.36 3.37
+DEAL:2d::Patch around cell 3.2: 3.2 3.3 3.0 2.2
+DEAL:2d::Patch around cell 3.7: 3.7 3.6 3.10 3.5 4.16 4.17
+DEAL:2d::Patch around cell 3.12: 3.12 3.13 2.2 4.8 4.9
+DEAL:2d::Patch around cell 3.20: 3.20 3.13 3.21 3.38 3.22
+DEAL:2d::Patch around cell 3.27: 3.27 3.26 4.0 4.2 4.18 4.19 3.29
+DEAL:2d::Patch around cell 3.35: 3.35 3.34 4.30 4.31
+DEAL:2d::Patch around cell 3.40: 3.40 2.1 3.41 3.42
+DEAL:2d::Patch around cell 3.45: 3.45 3.44 3.48 3.15 3.47
+DEAL:2d::Patch around cell 3.50: 3.50 3.47 3.51 3.48
+DEAL:2d::Patch around cell 4.3: 4.3 4.2 5.0 5.2 4.1 4.25
+DEAL:2d::Patch around cell 4.10: 4.10 4.11 4.8 3.44
+DEAL:2d::Patch around cell 4.15: 4.15 4.14 4.18 4.13 3.26
+DEAL:2d::Patch around cell 4.20: 4.20 3.49 4.21 3.26 4.22
+DEAL:2d::Patch around cell 4.25: 4.25 4.24 4.28 4.3 4.27
+DEAL:2d::Patch around cell 4.30: 4.30 4.27 4.31 4.28 3.35
+DEAL:2d::Patch around cell 5.3: 5.3 5.2 5.6 5.1 4.28
+DEAL:3d::Patch around cell 2.11: 2.11 3.153 3.155 3.157 3.159 3.18 3.22 3.19 3.23 3.224 3.228 3.225 3.229 3.176 3.177 3.178 3.179
+DEAL:3d::Patch around cell 2.45: 2.45 3.329 3.331 3.333 3.335 2.47 3.316 3.317 3.318 3.319
+DEAL:3d::Patch around cell 2.60: 2.60 3.353 3.355 3.357 3.359 2.61 2.46 3.400 3.404 3.401 3.405 3.372 3.373 3.374 3.375
+DEAL:3d::Patch around cell 3.2: 3.2 3.3 3.0 3.104 4.8 4.9 4.10 4.11
+DEAL:3d::Patch around cell 3.10: 3.10 3.123 3.11 4.18 4.22 4.19 4.23 3.136 3.102 3.14
+DEAL:3d::Patch around cell 3.16: 3.16 3.145 3.17 3.18 4.32 4.33 4.34 4.35
+DEAL:3d::Patch around cell 3.22: 3.22 3.151 3.23 4.34 4.38 4.35 4.39 2.11 3.18 3.26
+DEAL:3d::Patch around cell 3.27: 3.27 3.26 3.25 3.177 3.23 4.48 4.49 4.50 4.51
+DEAL:3d::Patch around cell 3.37: 3.37 4.73 4.75 4.77 4.79 3.228 3.159 3.39 3.33 3.241
+DEAL:3d::Patch around cell 3.42: 3.42 3.195 4.80 4.82 4.84 4.86 3.40 4.88 4.89 4.90 4.91
+DEAL:3d::Patch around cell 3.49: 3.49 3.48 3.179 3.51 3.229 3.53
+DEAL:3d::Patch around cell 3.55: 3.55 4.97 4.99 4.101 4.103 3.53 3.261 3.51 3.379
+DEAL:3d::Patch around cell 3.61: 3.61 3.60 2.42 3.279 3.63 3.57 3.297
+DEAL:3d::Patch around cell 3.68: 3.68 3.293 3.69 3.70 4.124 4.125 4.126 4.127
+DEAL:3d::Patch around cell 3.73: 3.73 3.72 3.296 3.291 4.128 4.132 4.129 4.133 3.285 3.77
+DEAL:3d::Patch around cell 3.79: 3.79 3.78 3.302 3.77 3.349 4.132 4.133 4.134 4.135
+DEAL:3d::Patch around cell 3.84: 3.84 3.341 3.85 4.114 4.118 4.115 4.119 3.86 3.80 3.352
+DEAL:3d::Patch around cell 3.89: 3.89 3.88 2.51 3.339 3.91 2.22 3.93
+DEAL:3d::Patch around cell 3.95: 3.95 4.137 4.139 4.141 4.143 2.51 3.93 3.91 3.363
+DEAL:3d::Patch around cell 3.100: 3.100 3.5 3.101 3.102 3.96 4.16 4.17 4.18 4.19
+DEAL:3d::Patch around cell 3.105: 3.105 3.104 3.112 3.3 3.107 3.109
+DEAL:3d::Patch around cell 3.110: 3.110 3.111 3.108 2.16 3.106 3.130
+DEAL:3d::Patch around cell 3.115: 3.115 3.114 3.154 3.113 3.185 3.119
+DEAL:3d::Patch around cell 3.120: 3.120 3.121 3.122 4.4 4.5 4.6 4.7 3.124
+DEAL:3d::Patch around cell 3.125: 3.125 3.124 3.12 3.127 3.121 3.265
+DEAL:3d::Patch around cell 3.130: 3.130 3.131 3.128 3.200 3.110 3.134
+DEAL:3d::Patch around cell 3.135: 3.135 3.134 3.142 3.133 3.205 3.131 3.283
+DEAL:3d::Patch around cell 3.140: 3.140 3.133 3.141 3.14 3.142 3.136 3.56
+DEAL:3d::Patch around cell 3.145: 3.145 3.144 3.16 3.147 3.149
+DEAL:3d::Patch around cell 3.150: 3.150 3.103 3.151 3.148 3.156 3.146 3.162
+DEAL:3d::Patch around cell 3.155: 3.155 3.154 2.11 3.153 3.33 3.159
+DEAL:3d::Patch around cell 3.160: 3.160 3.9 3.161 3.162 3.148 3.164
+DEAL:3d::Patch around cell 3.165: 3.165 3.164 3.28 3.167 3.161 3.305
+DEAL:3d::Patch around cell 3.170: 3.170 3.139 3.171 3.168 3.240 3.158 3.174
+DEAL:3d::Patch around cell 3.175: 3.175 3.174 3.182 3.173 3.245 3.171 2.42
+DEAL:3d::Patch around cell 3.180: 3.180 3.173 3.181 3.30 3.182 3.176 3.320
+DEAL:3d::Patch around cell 3.185: 3.185 3.184 4.56 4.58 4.60 4.62 3.115 3.187 3.189
+DEAL:3d::Patch around cell 3.190: 3.190 2.16 3.191 3.188 3.196 3.186 3.210
+DEAL:3d::Patch around cell 3.195: 3.195 3.194 3.42 3.193 3.199
+DEAL:3d::Patch around cell 3.200: 3.200 3.201 3.130 3.202 2.16 3.204
+DEAL:3d::Patch around cell 3.205: 3.205 3.204 3.212 3.135 3.207 3.201 3.337
+DEAL:3d::Patch around cell 3.210: 3.210 3.203 3.211 3.208 3.216 3.190 3.214
+DEAL:3d::Patch around cell 3.215: 3.215 3.214 3.246 3.213 3.221 3.211 3.83
+DEAL:3d::Patch around cell 3.220: 3.220 2.22 3.221 3.214 3.222 3.216 2.51
+DEAL:3d::Patch around cell 3.225: 3.225 3.224 2.11 3.227 3.229
+DEAL:3d::Patch around cell 3.230: 3.230 3.39 3.231 3.228 3.236 3.226 3.50
+DEAL:3d::Patch around cell 3.235: 3.235 3.234 3.233 3.239
+DEAL:3d::Patch around cell 3.240: 3.240 3.209 3.241 3.170 3.242 4.76 4.77 4.78 4.79 3.244
+DEAL:3d::Patch around cell 3.245: 3.245 3.244 3.52 3.175 3.247 3.241 3.369
+DEAL:3d::Patch around cell 3.250: 3.250 3.219 3.251 3.248 4.92 4.93 4.94 4.95 3.254
+DEAL:3d::Patch around cell 3.255: 3.255 3.254 3.262 3.253 3.251 3.387
+DEAL:3d::Patch around cell 3.260: 3.260 3.253 3.261 4.98 4.102 4.99 4.103 3.262 3.256 3.392
+DEAL:3d::Patch around cell 3.265: 3.265 3.264 3.272 3.267 3.125 3.269
+DEAL:3d::Patch around cell 3.270: 3.270 3.271 3.268 3.284 3.266 3.290
+DEAL:3d::Patch around cell 3.275: 3.275 3.274 3.306 3.273 3.57 3.15 3.279
+DEAL:3d::Patch around cell 3.280: 3.280 3.281 3.266 3.282 3.132 3.284
+DEAL:3d::Patch around cell 3.285: 3.285 3.284 3.60 3.271 3.287 3.281 3.73
+DEAL:3d::Patch around cell 3.290: 3.290 3.291 3.288 3.72 3.270 3.294
+DEAL:3d::Patch around cell 3.295: 3.295 3.294 3.70 3.293 3.77 3.291
+DEAL:3d::Patch around cell 3.300: 3.300 3.77 3.301 3.70 3.302 3.296
+DEAL:3d::Patch around cell 3.305: 3.305 3.304 3.312 3.307 3.165 3.309
+DEAL:3d::Patch around cell 3.310: 3.310 3.279 3.311 3.308 2.42 3.306 3.330
+DEAL:3d::Patch around cell 3.315: 3.315 3.314 3.313 3.321 4.52 4.53 4.54 4.55 3.319
+DEAL:3d::Patch around cell 3.320: 3.320 2.42 3.321 3.314 3.322 3.180 3.324
+DEAL:3d::Patch around cell 3.325: 3.325 3.324 3.319 3.327 3.321 2.47
+DEAL:3d::Patch around cell 3.330: 3.330 3.67 3.331 3.328 2.46 3.310 3.334
+DEAL:3d::Patch around cell 3.335: 3.335 3.334 2.45 3.333 2.46 3.331
+DEAL:3d::Patch around cell 3.340: 3.340 3.341 3.286 3.342 3.336 3.344
+DEAL:3d::Patch around cell 3.345: 3.345 3.344 3.352 4.130 4.134 4.131 4.135 3.347 3.341 3.349
+DEAL:3d::Patch around cell 3.350: 3.350 3.351 3.348 3.364 3.346
+DEAL:3d::Patch around cell 3.355: 3.355 3.354 2.60 3.353 2.55 3.87 3.359
+DEAL:3d::Patch around cell 3.360: 3.360 3.361 3.346 3.362 3.92 3.364
+DEAL:3d::Patch around cell 3.365: 3.365 3.364 2.55 3.351 3.367 3.361
+DEAL:3d::Patch around cell 3.370: 3.370 3.83 3.371 3.368 3.384 3.246 3.374
+DEAL:3d::Patch around cell 3.375: 3.375 3.374 3.382 3.373 3.389 3.371 2.60
+DEAL:3d::Patch around cell 3.380: 3.380 3.373 3.381 3.326 3.382 3.376 2.61
+DEAL:3d::Patch around cell 3.385: 3.385 3.384 3.392 3.371 3.387 3.253 3.389
+DEAL:3d::Patch around cell 3.390: 3.390 2.51 3.391 3.388 3.386 3.402
+DEAL:3d::Patch around cell 3.395: 3.395 3.394 3.393 3.263 3.399
+DEAL:3d::Patch around cell 3.400: 3.400 2.55 3.401 2.60 3.402 3.388 3.404
+DEAL:3d::Patch around cell 3.405: 3.405 3.404 2.63 2.60 3.407 3.401
+DEAL:3d::Patch around cell 4.2: 4.2 4.3 4.0 4.8 3.0 4.6
+DEAL:3d::Patch around cell 4.7: 4.7 4.6 3.5 4.5 4.13 4.3 3.120
+DEAL:3d::Patch around cell 4.12: 4.12 4.13 4.6 4.14 4.8 3.122
+DEAL:3d::Patch around cell 4.17: 4.17 4.16 3.9 4.19 3.100 4.21
+DEAL:3d::Patch around cell 4.22: 4.22 3.121 4.23 4.20 3.10 4.18 3.12
+DEAL:3d::Patch around cell 4.27: 4.27 4.26 3.164 4.25 3.15 3.9 4.31
+DEAL:3d::Patch around cell 4.32: 4.32 3.149 4.33 4.34 3.16 4.36
+DEAL:3d::Patch around cell 4.37: 4.37 4.36 3.21 4.39 4.33 3.24
+DEAL:3d::Patch around cell 4.42: 4.42 3.28 4.43 4.40 4.48 3.25 4.46
+DEAL:3d::Patch around cell 4.47: 4.47 4.46 4.45 4.53 4.43 3.313
+DEAL:3d::Patch around cell 4.52: 4.52 3.30 4.53 4.46 4.54 4.48 3.315
+DEAL:3d::Patch around cell 4.57: 4.57 4.56 3.33 3.154 4.59 4.61
+DEAL:3d::Patch around cell 4.62: 4.62 3.185 4.63 4.60 3.34 4.58 4.74
+DEAL:3d::Patch around cell 4.67: 4.67 4.66 3.226 4.65 3.41 4.71
+DEAL:3d::Patch around cell 4.72: 4.72 3.189 4.73 3.158 4.74 4.60 4.76
+DEAL:3d::Patch around cell 4.77: 4.77 4.76 3.37 3.158 4.79 4.73 3.240
+DEAL:3d::Patch around cell 4.82: 4.82 3.42 4.83 4.80 4.86
+DEAL:3d::Patch around cell 4.87: 4.87 4.86 3.234 4.85 4.83 3.47
+DEAL:3d::Patch around cell 4.92: 4.92 3.199 4.93 3.44 4.94 4.88 3.250
+DEAL:3d::Patch around cell 4.97: 4.97 4.96 3.55 3.52 4.99 3.50 4.101
+DEAL:3d::Patch around cell 4.102: 4.102 3.247 4.103 4.100 3.260 4.98 3.378
+DEAL:3d::Patch around cell 4.107: 4.107 4.106 3.59 4.105 3.80 3.142 4.111
+DEAL:3d::Patch around cell 4.112: 4.112 3.287 4.113 3.60 4.114 4.108 4.116
+DEAL:3d::Patch around cell 4.117: 4.117 4.116 3.63 3.60 4.119 4.113 3.298
+DEAL:3d::Patch around cell 4.122: 4.122 3.289 4.123 4.120 3.66 3.276 4.126
+DEAL:3d::Patch around cell 4.127: 4.127 4.126 3.65 4.125 3.66 4.123 3.68
+DEAL:3d::Patch around cell 4.132: 4.132 3.74 4.133 3.73 4.134 4.128 3.79
+DEAL:3d::Patch around cell 4.137: 4.137 4.136 3.95 3.92 4.139 3.90 4.141
+DEAL:3d::Patch around cell 4.142: 4.142 4.143 4.140 4.138 3.362