17 #include <deal.II/base/memory_consumption.h> 18 #include <deal.II/base/table.h> 19 #include <deal.II/base/geometry_info.h> 20 #include <deal.II/base/std_cxx11/bind.h> 22 #include <deal.II/grid/tria.h> 23 #include <deal.II/grid/tria_levels.h> 24 #include <deal.II/grid/tria_faces.h> 25 #include <deal.II/grid/manifold.h> 26 #include <deal.II/grid/tria_boundary.h> 27 #include <deal.II/grid/tria_accessor.h> 28 #include <deal.II/grid/tria_iterator.h> 29 #include <deal.II/grid/grid_tools.h> 30 #include <deal.II/grid/magic_numbers.h> 31 #include <deal.II/fe/mapping_q1.h> 32 #include <deal.II/lac/vector.h> 33 #include <deal.II/lac/full_matrix.h> 42 #include <deal.II/base/std_cxx11/array.h> 44 DEAL_II_NAMESPACE_OPEN
139 template <
int dim,
int spacedim>
144 unsigned int n_active_children = 0;
145 for (
unsigned int i=0; i<cell->n_children(); ++i)
146 if (cell->child(i)->active())
149 return (n_active_children == 0) || (n_active_children == cell->n_children());
159 template <
int dim,
int spacedim>
165 if (cell->has_children())
167 unsigned int children_to_coarsen=0;
168 const unsigned int n_children=cell->n_children();
170 for (
unsigned int c=0; c<n_children; ++c)
171 if (cell->child(c)->active() &&
172 cell->child(c)->coarsen_flag_set())
173 ++children_to_coarsen;
174 if (children_to_coarsen==n_children)
177 for (
unsigned int c=0; c<n_children; ++c)
178 if (cell->child(c)->active())
179 cell->child(c)->clear_coarsen_flag();
215 template <
int dim,
int spacedim>
218 const unsigned int face_no,
233 if (neighbor->has_children())
238 if (cell_will_be_coarsened(neighbor))
247 expected_face_ref_case=cell->face(face_no)->refinement_case();
259 const unsigned int neighbor_neighbor=cell->neighbor_face_no(face_no);
266 neighbor->face_orientation(neighbor_neighbor),
267 neighbor->face_flip(neighbor_neighbor),
268 neighbor->face_rotation(neighbor_neighbor));
272 const int this_face_index=cell->face_index(face_no);
278 if (neighbor_face->index()==this_face_index)
284 expected_face_ref_case = face_ref_case;
303 for (
unsigned int c=0; c<neighbor_face->n_children(); ++c)
304 if (neighbor_face->child_index(c)==this_face_index)
313 if ((neighbor_face->refinement_case() | face_ref_case)
314 == neighbor_face->refinement_case())
330 expected_face_ref_case = ~neighbor_face->refinement_case();
357 template <
int dim,
int spacedim>
360 const unsigned int face_no)
363 return face_will_be_refined_by_neighbor_internal(cell, face_no, dummy);
370 template <
int dim,
int spacedim>
373 const unsigned int face_no,
376 return face_will_be_refined_by_neighbor_internal(cell, face_no,
377 expected_face_ref_case);
382 template <
int dim,
int spacedim>
386 std::vector<unsigned int> min_adjacent_cell_level (triangulation.
n_vertices(),
388 std::vector<unsigned int> max_adjacent_cell_level (triangulation.
n_vertices(),
393 cell != triangulation.
end(); ++cell)
394 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
396 min_adjacent_cell_level[cell->vertex_index(v)]
397 = std::min<unsigned int>
398 (min_adjacent_cell_level[cell->vertex_index(v)],
400 max_adjacent_cell_level[cell->vertex_index(v)]
401 = std::max<unsigned int> (min_adjacent_cell_level[cell->vertex_index(v)],
405 for (
unsigned int k=0; k<triangulation.
n_vertices(); ++k)
407 if (max_adjacent_cell_level[k] -
408 min_adjacent_cell_level[k] > 1)
421 template <
int dim,
int spacedim>
422 std::vector<unsigned int>
427 std::vector<unsigned int> line_cell_count(triangulation.
n_raw_lines(),0);
429 cell=triangulation.
begin(),
430 endc=triangulation.
end();
431 for (; cell!=endc; ++cell)
432 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++
l)
433 ++line_cell_count[cell->line_index(l)];
434 return line_cell_count;
437 return std::vector<unsigned int>();
449 template <
int dim,
int spacedim>
450 std::vector<unsigned int>
455 std::vector<unsigned int> quad_cell_count (triangulation.
n_raw_quads(),0);
457 cell=triangulation.
begin(),
458 endc=triangulation.
end();
459 for (; cell!=endc; ++cell)
460 for (
unsigned int q=0; q<GeometryInfo<dim>::faces_per_cell; ++q)
461 ++quad_cell_count[cell->quad_index(q)];
462 return quad_cell_count;
465 return std::vector<unsigned int>();
482 reorder_compatibility (
const std::vector<
CellData<1> > &,
491 reorder_compatibility (std::vector<
CellData<2> > &cells,
494 for (
unsigned int cell=0; cell<cells.size(); ++cell)
495 std::swap(cells[cell].vertices[2],cells[cell].vertices[3]);
500 reorder_compatibility (std::vector<
CellData<3> > &cells,
504 for (
unsigned int cell=0; cell<cells.size(); ++cell)
506 for (
unsigned int i=0; i<GeometryInfo<3>::vertices_per_cell; ++i)
507 tmp[i] = cells[cell].vertices[i];
508 for (
unsigned int i=0; i<GeometryInfo<3>::vertices_per_cell; ++i)
513 std::vector<CellData<2> >::iterator boundary_quad
515 std::vector<CellData<2> >::iterator end_quad
517 for (
unsigned int quad_no=0; boundary_quad!=end_quad; ++boundary_quad, ++quad_no)
518 std::swap(boundary_quad->vertices[2], boundary_quad->vertices[3]);
540 template <
int dim,
int spacedim>
542 middle_vertex_index(
const typename Triangulation<dim,spacedim>::line_iterator &line)
544 if (line->has_children())
545 return line->child(0)->vertex_index(1);
550 template <
int dim,
int spacedim>
552 middle_vertex_index(
const typename Triangulation<dim,spacedim>::quad_iterator &quad)
554 switch (static_cast<unsigned char> (quad->refinement_case()))
557 return middle_vertex_index<dim,spacedim>(quad->child(0)->line(1));
560 return middle_vertex_index<dim,spacedim>(quad->child(0)->line(3));
563 return quad->child(0)->vertex_index(3);
572 template <
int dim,
int spacedim>
574 middle_vertex_index(
const typename Triangulation<dim,spacedim>::hex_iterator &hex)
576 switch (static_cast<unsigned char> (hex->refinement_case()))
579 return middle_vertex_index<dim,spacedim>(hex->child(0)->quad(1));
582 return middle_vertex_index<dim,spacedim>(hex->child(0)->quad(3));
585 return middle_vertex_index<dim,spacedim>(hex->child(0)->quad(5));
588 return middle_vertex_index<dim,spacedim>(hex->child(0)->line(11));
591 return middle_vertex_index<dim,spacedim>(hex->child(0)->line(5));
594 return middle_vertex_index<dim,spacedim>(hex->child(0)->line(7));
597 return hex->child(0)->vertex_index(7);
618 template <
class TRIANGULATION>
620 typename TRIANGULATION::DistortedCellList
621 collect_distorted_coarse_cells (
const TRIANGULATION &)
623 return typename TRIANGULATION::DistortedCellList();
643 cell = triangulation.
begin(0); cell != triangulation.
end(0); ++cell)
646 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
647 vertices[i] = cell->vertex(i);
653 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
654 if (determinants[i] <= 1e-9 * std::pow (cell->diameter(),
657 distorted_cells.distorted_cells.push_back (cell);
662 return distorted_cells;
680 for (
unsigned int c=0; c<cell->n_children(); ++c)
683 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
684 vertices[i] = cell->child(c)->vertex(i);
690 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
691 if (determinants[i] <= 1e-9 * std::pow (cell->child(c)->diameter(),
707 template <
int dim,
int spacedim>
722 template <
int spacedim>
729 template <
int dim,
int spacedim>
784 static const unsigned int left_right_offset[2][6][2] =
813 std::vector<typename Triangulation<dim,spacedim>::cell_iterator>
814 adjacent_cells(2*triangulation.
n_raw_faces(), dummy);
817 cell = triangulation.
begin(),
818 endc = triangulation.
end();
819 for (; cell != endc; ++cell)
820 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
826 offset = (cell->direction_flag()
828 left_right_offset[dim-2][f][cell->face_orientation(f)]
830 1-left_right_offset[dim-2][f][cell->face_orientation(f)]);
832 adjacent_cells[2*face->index() + offset] = cell;
842 if (cell->active() && face->has_children())
844 adjacent_cells[2*face->child(0)->index() + offset] = cell;
845 adjacent_cells[2*face->child(1)->index() + offset] = cell;
870 if (face->has_children() &&
875 for (
unsigned int c=0; c<face->n_children(); ++c)
876 adjacent_cells[2*face->child(c)->index() + offset] = cell;
877 if (face->child(0)->has_children())
879 adjacent_cells[2*face->child(0)->child(0)->index() + offset] = cell;
880 adjacent_cells[2*face->child(0)->child(1)->index() + offset] = cell;
882 if (face->child(1)->has_children())
884 adjacent_cells[2*face->child(1)->child(0)->index() + offset] = cell;
885 adjacent_cells[2*face->child(1)->child(1)->index() + offset] = cell;
896 for (cell=triangulation.
begin(); cell != endc; ++cell)
897 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
900 offset = (cell->direction_flag()
902 left_right_offset[dim-2][f][cell->face_orientation(f)]
904 1-left_right_offset[dim-2][f][cell->face_orientation(f)]);
905 cell->set_neighbor(f,
906 adjacent_cells[2*cell->face(f)->index() + 1 - offset]);
911 template <
int dim,
int spacedim>
912 void update_periodic_face_map_recursively
915 unsigned int n_face_1,
unsigned int n_face_2,
916 const std::bitset<3> &orientation,
921 const FaceIterator face_1 = cell_1->face(n_face_1);
922 const FaceIterator face_2 = cell_2->face(n_face_2);
924 const bool face_orientation = orientation[0];
925 const bool face_flip = orientation[1];
926 const bool face_rotation = orientation[2];
928 Assert((dim != 1) || (face_orientation ==
true && face_flip ==
false && face_rotation ==
false),
929 ExcMessage (
"The supplied orientation " "(face_orientation, face_flip, face_rotation) " "is invalid for 1D"));
931 Assert((dim != 2) || (face_orientation ==
true && face_rotation ==
false),
932 ExcMessage (
"The supplied orientation " "(face_orientation, face_flip, face_rotation) " "is invalid for 2D"));
937 Assert(face_1->at_boundary() &&face_2->at_boundary(),
938 ExcMessage (
"Periodic faces must be on the boundary"));
941 typedef std::pair<typename Triangulation<dim,spacedim>::cell_iterator,
unsigned int> CellFace;
942 const CellFace cell_face_1 (cell_1, n_face_1);
943 const CellFace cell_face_2 (cell_2, n_face_2);
944 const std::pair<CellFace, std::bitset<3> > cell_face_orientation_2 (cell_face_2, orientation);
946 const std::pair<CellFace, std::pair<CellFace, std::bitset<3> > > periodic_faces (cell_face_1, cell_face_orientation_2);
950 periodic_face_map.insert(periodic_faces);
956 static const int lookup_table_2d[2][2] =
963 static const int lookup_table_3d[2][2][2][4] =
982 if (cell_1->has_children())
984 if (cell_2->has_children())
993 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_face; ++i)
1000 j = lookup_table_2d[face_flip][i];
1003 j = lookup_table_3d[face_orientation][face_flip][face_rotation][i];
1010 unsigned int child_cell_1
1012 (cell_1->refinement_case(), n_face_1, i, cell_1->face_orientation(n_face_1),
1013 cell_1->face_flip(n_face_1), cell_1->face_rotation(n_face_1), face_1->refinement_case());
1014 unsigned int child_cell_2
1016 (cell_2->refinement_case(), n_face_2, j, cell_2->face_orientation(n_face_2),
1017 cell_2->face_flip(n_face_2), cell_2->face_rotation(n_face_2), face_2->refinement_case());
1024 update_periodic_face_map_recursively<dim, spacedim>
1025 (cell_1->child(child_cell_1), cell_2->child(child_cell_2),
1026 n_face_1, n_face_2, orientation, periodic_face_map);
1031 for (
unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_face; ++i)
1034 unsigned int child_cell_1
1036 cell_1->face_flip(n_face_1), cell_1->face_rotation(n_face_1), face_1->refinement_case());
1039 update_periodic_face_map_recursively<dim, spacedim>
1040 (cell_1->child(child_cell_1), cell_2,
1041 n_face_1, n_face_2, orientation, periodic_face_map);
1062 using ::Triangulation;
1070 <<
"Something went wrong when making cell " << arg1
1071 <<
". Read the docs and the source code " 1072 <<
"for more information.");
1079 <<
"Something went wrong upon construction of cell " 1092 <<
"Cell " << arg1 <<
" has negative measure. This typically " 1093 <<
"indicates some distortion in the cell, or a mistakenly " 1094 <<
"swapped pair of vertices in the input to " 1095 <<
"Triangulation::create_triangulation().");
1105 <<
"Error while creating cell " << arg1
1106 <<
": the vertex index " << arg2 <<
" must be between 0 and " 1114 <<
"While trying to assign a boundary indicator to a line: " 1115 <<
"the line with end vertices " << arg1 <<
" and " 1116 << arg2 <<
" does not exist.");
1123 <<
"While trying to assign a boundary indicator to a quad: " 1124 <<
"the quad with bounding lines " << arg1 <<
", " << arg2
1125 <<
", " << arg3 <<
", " << arg4 <<
" does not exist.");
1133 <<
"The input data for creating a triangulation contained " 1134 <<
"information about a line with indices " 1135 << arg1 <<
" and " << arg2
1136 <<
" that is described to have boundary indicator " 1138 <<
". However, this is an internal line not located on the " 1139 <<
"boundary. You cannot assign a boundary indicator to it." 1142 <<
"If this happened at a place where you call " 1143 <<
"Triangulation::create_triangulation() yourself, you need " 1144 <<
"to check the SubCellData object you pass to this function." 1147 <<
"If this happened in a place where you are reading a mesh " 1148 <<
"from a file, then you need to investigate why such a line " 1149 <<
"ended up in the input file. A typical case is a geometry " 1150 <<
"that consisted of multiple parts and for which the mesh " 1151 <<
"generator program assumes that the interface between " 1152 <<
"two parts is a boundary when that isn't supposed to be " 1153 <<
"the case, or where the mesh generator simply assigns " 1154 <<
"'geometry indicators' to lines at the perimeter of " 1155 <<
"a part that are not supposed to be interpreted as " 1156 <<
"'boundary indicators'.");
1164 <<
"The input data for creating a triangulation contained " 1165 <<
"information about a quad with indices " 1166 << arg1 <<
", " << arg2 <<
", " << arg3 <<
", and " << arg4
1167 <<
" that is described to have boundary indicator " 1169 <<
". However, this is an internal quad not located on the " 1170 <<
"boundary. You cannot assign a boundary indicator to it." 1173 <<
"If this happened at a place where you call " 1174 <<
"Triangulation::create_triangulation() yourself, you need " 1175 <<
"to check the SubCellData object you pass to this function." 1178 <<
"If this happened in a place where you are reading a mesh " 1179 <<
"from a file, then you need to investigate why such a quad " 1180 <<
"ended up in the input file. A typical case is a geometry " 1181 <<
"that consisted of multiple parts and for which the mesh " 1182 <<
"generator program assumes that the interface between " 1183 <<
"two parts is a boundary when that isn't supposed to be " 1184 <<
"the case, or where the mesh generator simply assigns " 1185 <<
"'geometry indicators' to quads at the surface of " 1186 <<
"a part that are not supposed to be interpreted as " 1187 <<
"'boundary indicators'.");
1194 <<
"In SubCellData the line info of the line with vertex indices " 1195 << arg1 <<
" and " << arg2 <<
" appears more than once. " 1196 <<
"This is not allowed.");
1307 template <
int dim,
int spacedim>
1310 const unsigned int level_objects,
1314 typename Triangulation<dim,spacedim>::line_iterator line_iterator;
1317 if (level_objects > 0)
1319 for (
unsigned int level=0; level<level_objects; ++level)
1320 if (triangulation.
begin(level) !=
1321 triangulation.
end(level))
1340 for (
unsigned int level=0; level<number_cache.
n_levels; ++level)
1346 line_iterator line = triangulation.
begin_line (level),
1347 endc = (level == number_cache.
n_levels-1 ?
1348 line_iterator(triangulation.
end_line()) :
1350 for (; line!=endc; ++line)
1353 if (line->has_children() ==
false)
1368 line_iterator line = triangulation.
begin_line (),
1370 for (; line!=endc; ++line)
1373 if (line->has_children() ==
false)
1393 template <
int dim,
int spacedim>
1396 const unsigned int level_objects,
1406 (&compute_number_cache<dim,spacedim>),
1413 typename Triangulation<dim,spacedim>::quad_iterator quad_iterator;
1429 unsigned int n_levels = 0;
1430 if (level_objects > 0)
1432 for (
unsigned int level=0; level<level_objects; ++level)
1433 if (triangulation.
begin(level) !=
1434 triangulation.
end(level))
1440 for (
unsigned int level=0; level<n_levels; ++level)
1446 quad_iterator quad = triangulation.
begin_quad (level),
1447 endc = (level == n_levels-1 ?
1448 quad_iterator(triangulation.
end_quad()) :
1450 for (; quad!=endc; ++quad)
1453 if (quad->has_children() ==
false)
1468 quad_iterator quad = triangulation.
begin_quad (),
1470 for (; quad!=endc; ++quad)
1473 if (quad->has_children() ==
false)
1479 update_lines.
join ();
1497 template <
int dim,
int spacedim>
1500 const unsigned int level_objects,
1510 (&compute_number_cache<dim,spacedim>),
1517 typename Triangulation<dim,spacedim>::hex_iterator hex_iterator;
1534 unsigned int n_levels = 0;
1535 if (level_objects > 0)
1537 for (
unsigned int level=0; level<level_objects; ++level)
1538 if (triangulation.
begin(level) !=
1539 triangulation.
end(level))
1545 for (
unsigned int level=0; level<n_levels; ++level)
1551 hex_iterator hex = triangulation.
begin_hex (level),
1552 endc = (level == n_levels-1 ?
1553 hex_iterator(triangulation.
end_hex()) :
1555 for (; hex!=endc; ++hex)
1558 if (hex->has_children() ==
false)
1573 hex_iterator hex = triangulation.
begin_hex (),
1574 endc = triangulation.
end_hex();
1575 for (; hex!=endc; ++hex)
1578 if (hex->has_children() ==
false)
1584 update_quads_and_lines.
join ();
1595 template <
int spacedim>
1612 const unsigned int dim=1;
1616 triangulation.
vertices_used = std::vector<bool> (v.size(),
true);
1623 if (dim == spacedim)
1625 for (
unsigned int cell_no = 0; cell_no<cells.size(); ++cell_no)
1633 const double cell_measure = GridTools::cell_measure<1>
1634 (triangulation.
vertices, cells[cell_no].vertices);
1645 std::vector<std::vector<int> > lines_at_vertex (v.size());
1649 triangulation.
levels[0]->reserve_space (cells.size(), dim, spacedim);
1650 triangulation.
levels[0]->cells.reserve_space (0,cells.size());
1653 typename Triangulation<dim,spacedim>::raw_line_iterator
1655 for (
unsigned int cell=0; cell<cells.size(); ++cell)
1657 while (next_free_line->used())
1662 cells[cell].vertices[1]));
1663 next_free_line->set_used_flag ();
1664 next_free_line->set_material_id (cells[cell].material_id);
1665 next_free_line->set_manifold_id (cells[cell].manifold_id);
1667 next_free_line->set_subdomain_id (0);
1671 lines_at_vertex[cells[cell].vertices[0]].push_back (cell);
1672 lines_at_vertex[cells[cell].vertices[1]].push_back (cell);
1678 unsigned int boundary_nodes = 0;
1679 for (
unsigned int i=0; i<lines_at_vertex.size(); ++i)
1680 switch (lines_at_vertex[i].size())
1691 ExcMessage (
"You have a vertex in your triangulation " 1692 "at which more than two cells come together. " 1693 "(For one dimensional triangulation, cells are " 1696 "This is not currently supported because the " 1697 "Triangulation class makes the assumption that " 1698 "every cell has zero or one neighbors behind " 1699 "each face (here, behind each vertex), but in your " 1700 "situation there would be more than one." 1702 "Support for this is not currently implemented. " 1703 "If you need to work with triangulations where " 1704 "more than two cells come together at a vertex, " 1705 "duplicate the vertices once per cell (i.e., put " 1706 "multiple vertices at the same physical location, " 1707 "but using different vertex indices for each) " 1708 "and then ensure continuity of the solution by " 1709 "explicitly creating constraints that the degrees " 1710 "of freedom at these vertices have the same " 1711 "value, using the ConstraintMatrix class."));
1723 AssertThrow (((spacedim == 1) && (boundary_nodes == 2))
1726 ExcMessage(
"The Triangulation has too many end points"));
1732 typename Triangulation<dim,spacedim>::active_line_iterator
1735 for (; line!=triangulation.
end(); ++line)
1737 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
1743 if (lines_at_vertex[line->vertex_index(vertex)][0] == line->index())
1744 if (lines_at_vertex[line->vertex_index(vertex)].size() == 2)
1747 neighbor (&triangulation,
1749 lines_at_vertex[line->vertex_index(vertex)][1]);
1750 line->set_neighbor (vertex, neighbor);
1756 line->set_neighbor (vertex, triangulation.
end());
1763 neighbor (&triangulation,
1765 lines_at_vertex[line->vertex_index(vertex)][0]);
1766 line->set_neighbor (vertex, neighbor);
1777 cell != triangulation.
end(); ++cell)
1778 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
1784 if (cell->at_boundary(f))
1786 .vertex_to_boundary_id_map_1d)[cell->face(f)->vertex_index()]
1799 template <
int spacedim>
1810 const unsigned int dim=2;
1814 triangulation.
vertices_used = std::vector<bool> (v.size(),
true);
1821 if (dim == spacedim)
1823 for (
unsigned int cell_no = 0; cell_no<cells.size(); ++cell_no)
1828 const double cell_measure = GridTools::cell_measure<2>
1829 (triangulation.
vertices, cells[cell_no].vertices);
1849 std::map<std::pair<int,int>,
1850 typename Triangulation<dim,spacedim>::line_iterator> needed_lines;
1851 for (
unsigned int cell=0; cell<cells.size(); ++cell)
1853 for (
unsigned int vertex=0; vertex<4; ++vertex)
1858 for (
unsigned int line=0; line<GeometryInfo<dim>::faces_per_cell; ++line)
1863 std::pair<int,int> line_vertices(
1883 AssertThrow (needed_lines.find(std::make_pair(line_vertices.second,
1884 line_vertices.first))
1893 needed_lines[line_vertices] = triangulation.
end_line();
1901 std::vector<unsigned short int> vertex_touch_count (v.size(), 0);
1902 typename std::map<std::pair<int,int>,
1903 typename Triangulation<dim,spacedim>::line_iterator>::iterator i;
1904 for (i=needed_lines.begin(); i!=needed_lines.end(); ++i)
1908 ++vertex_touch_count[i->first.first];
1909 ++vertex_touch_count[i->first.second];
1916 AssertThrow (* (std::min_element(vertex_touch_count.begin(),
1917 vertex_touch_count.end())) >= 2,
1918 ExcMessage(
"During creation of a triangulation, a part of the " 1919 "algorithm encountered a vertex that is part of only " 1920 "a single adjacent line. However, in 2d, every vertex " 1921 "needs to be at least part of two lines."));
1927 triangulation.
levels[0]->reserve_space (cells.size(), dim, spacedim);
1928 triangulation.
faces->lines.reserve_space (0,needed_lines.size());
1929 triangulation.
levels[0]->cells.reserve_space (0,cells.size());
1933 typename Triangulation<dim,spacedim>::raw_line_iterator
1935 typename std::map<std::pair<int,int>,
1936 typename Triangulation<dim,spacedim>::line_iterator>::iterator i;
1937 for (i = needed_lines.begin();
1938 line!=triangulation.
end_line(); ++line, ++i)
1942 line->set_used_flag ();
1943 line->clear_user_flag ();
1952 std::map<int,std::vector<typename Triangulation<dim,spacedim>::cell_iterator> >
1959 for (
unsigned int c=0; c<cells.size(); ++c, ++cell)
1961 typename Triangulation<dim,spacedim>::line_iterator
1963 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
1964 lines[line]=needed_lines[std::make_pair(
1971 lines[3]->index()));
1973 cell->set_used_flag ();
1974 cell->set_material_id (cells[c].material_id);
1975 cell->set_manifold_id (cells[c].manifold_id);
1976 cell->clear_user_data ();
1977 cell->set_subdomain_id (0);
1982 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
1983 adjacent_cells[lines[line]->index()].push_back (cell);
1988 for (
typename Triangulation<dim,spacedim>::line_iterator
1990 line!=triangulation.
end_line(); ++line)
1992 const unsigned int n_adj_cells = adjacent_cells[line->index()].size();
2005 ExcMessage (
"You have a line in your triangulation " 2006 "at which more than two cells come together. " 2008 "This is not currently supported because the " 2009 "Triangulation class makes the assumption that " 2010 "every cell has zero or one neighbors behind " 2011 "each face (here, behind each line), but in your " 2012 "situation there would be more than one." 2014 "Support for this is not currently implemented. " 2015 "If you need to work with triangulations where " 2016 "more than two cells come together at a line, " 2017 "duplicate the vertices once per cell (i.e., put " 2018 "multiple vertices at the same physical location, " 2019 "but using different vertex indices for each) " 2020 "and then ensure continuity of the solution by " 2021 "explicitly creating constraints that the degrees " 2022 "of freedom at these lines have the same " 2023 "value, using the ConstraintMatrix class."));
2032 std::vector<CellData<1> >::const_iterator boundary_line
2034 std::vector<CellData<1> >::const_iterator end_boundary_line
2036 for (; boundary_line!=end_boundary_line; ++boundary_line)
2038 typename Triangulation<dim,spacedim>::line_iterator line;
2039 std::pair<int,int> line_vertices(std::make_pair(boundary_line->vertices[0],
2040 boundary_line->vertices[1]));
2041 if (needed_lines.find(line_vertices) != needed_lines.end())
2043 line = needed_lines[line_vertices];
2047 std::swap (line_vertices.first, line_vertices.second);
2048 if (needed_lines.find(line_vertices) != needed_lines.end())
2049 line = needed_lines[line_vertices];
2053 line_vertices.second));
2060 line_vertices.second));
2084 line->vertex_index(1),
2085 boundary_line->boundary_id));
2089 line->set_manifold_id (boundary_line->manifold_id);
2093 line->set_boundary_id_internal(boundary_line->boundary_id);
2095 line->set_manifold_id (boundary_line->manifold_id);
2101 cell=triangulation.
begin(); cell!=triangulation.
end(); ++cell)
2102 for (
unsigned int side=0; side<4; ++side)
2103 if (adjacent_cells[cell->line(side)->index()][0] == cell)
2107 if (adjacent_cells[cell->line(side)->index()].size() == 2)
2110 cell->set_neighbor (side,
2111 adjacent_cells[cell->line(side)->index()][1]);
2117 cell->set_neighbor (side,
2118 adjacent_cells[cell->line(side)->index()][0]);
2167 template <
int spacedim>
2178 const unsigned int dim=3;
2182 triangulation.
vertices_used = std::vector<bool> (v.size(),
true);
2187 for (
unsigned int cell_no = 0; cell_no<cells.size(); ++cell_no)
2192 const double cell_measure = GridTools::cell_measure<3>
2193 (triangulation.
vertices, cells[cell_no].vertices);
2218 typename std::map<std::pair<int,int>,
2219 typename Triangulation<dim,spacedim>::line_iterator> needed_lines;
2220 for (
unsigned int cell=0; cell<cells.size(); ++cell)
2224 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
2229 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
2237 std::pair<int,int> line_vertices(
2244 if ( (needed_lines.find(std::make_pair(line_vertices.second,
2245 line_vertices.first))
2247 needed_lines.end()))
2253 needed_lines[line_vertices] = triangulation.
end_line();
2265 std::vector<unsigned short int> vertex_touch_count (v.size(), 0);
2266 typename std::map<std::pair<int,int>,
2267 typename Triangulation<dim,spacedim>::line_iterator>::iterator i;
2268 for (i=needed_lines.begin(); i!=needed_lines.end(); ++i)
2272 ++vertex_touch_count[i->first.first];
2273 ++vertex_touch_count[i->first.second];
2280 AssertThrow (* (std::min_element(vertex_touch_count.begin(),
2281 vertex_touch_count.end())) >= 3,
2282 ExcMessage(
"During creation of a triangulation, a part of the " 2283 "algorithm encountered a vertex that is part of only " 2284 "one or two adjacent lines. However, in 3d, every vertex " 2285 "needs to be at least part of three lines."));
2295 triangulation.
levels[0]->reserve_space (cells.size(), dim, spacedim);
2296 triangulation.
faces->lines.reserve_space (0,needed_lines.size());
2300 typename Triangulation<dim,spacedim>::raw_line_iterator
2302 typename std::map<std::pair<int,int>,
2303 typename Triangulation<dim,spacedim>::line_iterator>::iterator i;
2304 for (i = needed_lines.begin(); line!=triangulation.
end_line(); ++line, ++i)
2308 line->set_used_flag ();
2309 line->clear_user_flag ();
2333 std::map<internal::Triangulation::TriaObject<2>,
2334 std::pair<typename Triangulation<dim,spacedim>::quad_iterator,
2335 std_cxx11::array<bool,GeometryInfo<dim>::lines_per_face> >,
2338 for (
unsigned int cell=0; cell<cells.size(); ++cell)
2366 std_cxx11::array<bool,GeometryInfo<dim>::lines_per_face> orientation;
2368 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
2370 line_list[line]=std::pair<int,int> (
2373 inverse_line_list[line]=std::pair<int,int> (
2378 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
2388 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
2390 face_to_cell_lines(face,l)]) == needed_lines.end())
2394 orientation[l]=
true;
2400 orientation[l]=
false;
2405 quad(face_line_list[0],
2449 test_quad_1(quad.
face(2), quad.
face(3),
2451 test_quad_2(quad.
face(0), quad.
face(1),
2453 test_quad_3(quad.
face(3), quad.
face(2),
2455 test_quad_4(quad.
face(1), quad.
face(0),
2457 test_quad_5(quad.
face(2), quad.
face(3),
2459 test_quad_6(quad.
face(1), quad.
face(0),
2461 test_quad_7(quad.
face(3), quad.
face(2),
2463 if (needed_quads.find (test_quad_1) == needed_quads.end() &&
2464 needed_quads.find (test_quad_2) == needed_quads.end() &&
2465 needed_quads.find (test_quad_3) == needed_quads.end() &&
2466 needed_quads.find (test_quad_4) == needed_quads.end() &&
2467 needed_quads.find (test_quad_5) == needed_quads.end() &&
2468 needed_quads.find (test_quad_6) == needed_quads.end() &&
2469 needed_quads.find (test_quad_7) == needed_quads.end())
2470 needed_quads[quad] = std::make_pair(triangulation.
end_quad(),orientation);
2480 triangulation.
faces->quads.reserve_space (0,needed_quads.size());
2483 typename Triangulation<dim,spacedim>::raw_quad_iterator
2485 typename std::map<internal::Triangulation::TriaObject<2>,
2486 std::pair<typename Triangulation<dim,spacedim>::quad_iterator,
2487 std_cxx11::array<bool,GeometryInfo<dim>::lines_per_face> >,
2490 for (q = needed_quads.begin(); quad!=triangulation.
end_quad(); ++quad, ++q)
2492 quad->set (q->first);
2493 quad->set_used_flag ();
2494 quad->clear_user_flag ();
2497 quad->set_line_orientation(0,q->second.second[0]);
2498 quad->set_line_orientation(1,q->second.second[1]);
2499 quad->set_line_orientation(2,q->second.second[2]);
2500 quad->set_line_orientation(3,q->second.second[3]);
2505 q->second.first = quad;
2511 triangulation.
levels[0]->cells.reserve_space (cells.size());
2515 std::map<int,std::vector<typename Triangulation<dim,spacedim>::cell_iterator> >
2522 for (
unsigned int c=0; c<cells.size(); ++c, ++cell)
2537 unsigned int face_line_list[4];
2538 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
2540 line_list[line]=std::make_pair(
2543 inverse_line_list[line]=std::pair<int,int> (
2553 typename Triangulation<dim,spacedim>::quad_iterator
2558 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
2560 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
2562 face_to_cell_lines(face,l)]) == needed_lines.end())
2564 face_to_cell_lines(face,l)]]->index();
2570 quad(face_line_list[0],
2575 if (needed_quads.find (quad) != needed_quads.end())
2586 face_iterator[face] = needed_quads[quad].first;
2587 face_orientation[face] =
true;
2588 face_flip[face]=
false;
2589 face_rotation[face]=
false;
2599 test_quad_1(quad.
face(2), quad.
face(3),
2601 test_quad_2(quad.
face(0), quad.
face(1),
2603 test_quad_3(quad.
face(3), quad.
face(2),
2605 test_quad_4(quad.
face(1), quad.
face(0),
2607 test_quad_5(quad.
face(2), quad.
face(3),
2609 test_quad_6(quad.
face(1), quad.
face(0),
2611 test_quad_7(quad.
face(3), quad.
face(2),
2613 if (needed_quads.find (test_quad_1) != needed_quads.end())
2615 face_iterator[face] = needed_quads[test_quad_1].first;
2616 face_orientation[face] =
false;
2617 face_flip[face]=
false;
2618 face_rotation[face]=
false;
2620 else if (needed_quads.find (test_quad_2) != needed_quads.end())
2622 face_iterator[face] = needed_quads[test_quad_2].first;
2623 face_orientation[face] =
false;
2624 face_flip[face]=
false;
2625 face_rotation[face]=
true;
2627 else if (needed_quads.find (test_quad_3) != needed_quads.end())
2629 face_iterator[face] = needed_quads[test_quad_3].first;
2630 face_orientation[face] =
false;
2631 face_flip[face]=
true;
2632 face_rotation[face]=
false;
2634 else if (needed_quads.find (test_quad_4) != needed_quads.end())
2636 face_iterator[face] = needed_quads[test_quad_4].first;
2637 face_orientation[face] =
false;
2638 face_flip[face]=
true;
2639 face_rotation[face]=
true;
2641 else if (needed_quads.find (test_quad_5) != needed_quads.end())
2643 face_iterator[face] = needed_quads[test_quad_5].first;
2644 face_orientation[face] =
true;
2645 face_flip[face]=
false;
2646 face_rotation[face]=
true;
2648 else if (needed_quads.find (test_quad_6) != needed_quads.end())
2650 face_iterator[face] = needed_quads[test_quad_6].first;
2651 face_orientation[face] =
true;
2652 face_flip[face]=
true;
2653 face_rotation[face]=
false;
2655 else if (needed_quads.find (test_quad_7) != needed_quads.end())
2657 face_iterator[face] = needed_quads[test_quad_7].first;
2658 face_orientation[face] =
true;
2659 face_flip[face]=
true;
2660 face_rotation[face]=
true;
2677 face_iterator[1]->index(),
2678 face_iterator[2]->index(),
2679 face_iterator[3]->index(),
2680 face_iterator[4]->index(),
2681 face_iterator[5]->index()));
2683 cell->set_used_flag ();
2684 cell->set_material_id (cells[c].material_id);
2685 cell->set_manifold_id (cells[c].manifold_id);
2686 cell->clear_user_flag ();
2687 cell->clear_user_data ();
2688 cell->set_subdomain_id (0);
2692 for (
unsigned int quad=0; quad<GeometryInfo<dim>::faces_per_cell; ++quad)
2694 cell->set_face_orientation (quad, face_orientation[quad]);
2695 cell->set_face_flip (quad, face_flip[quad]);
2696 cell->set_face_rotation (quad, face_rotation[quad]);
2703 for (
unsigned int quad=0; quad<GeometryInfo<dim>::faces_per_cell; ++quad)
2704 adjacent_cells[face_iterator[quad]->index()].push_back (cell);
2721 std::multimap<unsigned int, std::pair<unsigned int, unsigned int> >
2723 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
2724 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_face; ++line)
2725 cell_to_face_lines.insert(
2726 std::pair<
unsigned int, std::pair<unsigned int, unsigned int> > (
2728 std::pair<unsigned int, unsigned int> (face,line)));
2729 std::multimap<unsigned int, std::pair<unsigned int, unsigned int> >::const_iterator
2730 map_iter=cell_to_face_lines.begin();
2732 for (; map_iter!=cell_to_face_lines.end(); ++map_iter)
2734 const unsigned int cell_line=map_iter->first;
2735 const unsigned int face1=map_iter->second.first;
2736 const unsigned int line1=map_iter->second.second;
2740 const unsigned int face2=map_iter->second.first;
2741 const unsigned int line2=map_iter->second.second;
2750 face_orientation[face1],
2752 face_rotation[face1])) ==
2755 face_orientation[face2],
2757 face_rotation[face2])),
2768 for (
typename Triangulation<dim,spacedim>::quad_iterator
2771 const unsigned int n_adj_cells = adjacent_cells[quad->index()].size();
2793 for (
typename Triangulation<dim,spacedim>::line_iterator
2818 for (
typename Triangulation<dim,spacedim>::quad_iterator
2820 if (quad->at_boundary())
2822 for (
unsigned int l=0; l<4; ++l)
2824 typename Triangulation<dim,spacedim>::line_iterator line = quad->line(l);
2825 line->set_boundary_id_internal(0);
2834 std::vector<CellData<1> >::const_iterator boundary_line
2836 std::vector<CellData<1> >::const_iterator end_boundary_line
2838 for (; boundary_line!=end_boundary_line; ++boundary_line)
2840 typename Triangulation<dim,spacedim>::line_iterator line;
2841 std::pair <int, int> line_vertices(std::make_pair(boundary_line->vertices[0],
2842 boundary_line->vertices[1]));
2843 if (needed_lines.find(line_vertices) != needed_lines.end())
2846 line = needed_lines[line_vertices];
2852 std::swap (line_vertices.first, line_vertices.second);
2853 if (needed_lines.find(line_vertices) != needed_lines.end())
2854 line = needed_lines[line_vertices];
2858 line_vertices.second));
2865 line->vertex_index(1),
2866 boundary_line->boundary_id));
2873 if (line->boundary_id() != 0)
2874 AssertThrow (line->boundary_id() == boundary_line->boundary_id,
2875 ExcMessage (
"Duplicate boundary lines are only allowed " 2876 "if they carry the same boundary indicator."));
2878 line->set_boundary_id_internal(boundary_line->boundary_id);
2880 line->set_manifold_id(boundary_line->manifold_id);
2885 std::vector<CellData<2> >::const_iterator boundary_quad
2887 std::vector<CellData<2> >::const_iterator end_boundary_quad
2889 for (; boundary_quad!=end_boundary_quad; ++boundary_quad)
2891 typename Triangulation<dim,spacedim>::quad_iterator quad;
2892 typename Triangulation<dim,spacedim>::line_iterator line[4];
2901 for (
unsigned int i=0; i<4; ++i)
2903 std::pair<int, int> line_vertices(
2909 if (needed_lines.find(line_vertices) != needed_lines.end())
2910 line[i] = needed_lines[line_vertices];
2915 std::swap (line_vertices.first, line_vertices.second);
2916 if (needed_lines.find(line_vertices) != needed_lines.end())
2917 line[i] = needed_lines[line_vertices];
2922 line_vertices.second));
2940 quad_compare_1(line[0]->index(), line[1]->index(),
2941 line[2]->index(), line[3]->index());
2943 quad_compare_2(line[2]->index(), line[3]->index(),
2944 line[0]->index(), line[1]->index());
2957 static const unsigned int lex2cclock[4]= {3,1,0,2};
2963 typename Triangulation<dim,spacedim>::line_iterator
2964 line_counterclock[4];
2965 for (
unsigned int i=0; i<4; ++i)
2966 line_counterclock[lex2cclock[i]]=line[i];
2967 unsigned int n_rotations=0;
2968 bool not_found_quad_1;
2969 while ( (not_found_quad_1=(needed_quads.find(quad_compare_1) == needed_quads.end())) &&
2970 ( needed_quads.find(quad_compare_2) == needed_quads.end()) &&
2975 rotate(line_counterclock, line_counterclock+1, line_counterclock+4);
2979 for (
unsigned int i=0; i<4; ++i)
2981 quad_compare_1.
set_face(i, line_counterclock[lex2cclock[i]]->index());
2982 quad_compare_2.
set_face((i+2)%4, line_counterclock[lex2cclock[i]]->index());
2990 line[2]->index(), line[3]->index()));
2992 if (not_found_quad_1)
2993 quad = needed_quads[quad_compare_2].first;
2995 quad = needed_quads[quad_compare_1].first;
3001 quad->vertex_index(1),
3002 quad->vertex_index(2),
3003 quad->vertex_index(3),
3004 boundary_quad->boundary_id));
3011 if (quad->boundary_id() != 0)
3012 AssertThrow (quad->boundary_id() == boundary_quad->boundary_id,
3013 ExcMessage (
"Duplicate boundary quads are only allowed " 3014 "if they carry the same boundary indicator."));
3016 quad->set_boundary_id_internal (boundary_quad->boundary_id);
3017 quad->set_manifold_id (boundary_quad->manifold_id);
3024 cell=triangulation.
begin(); cell!=triangulation.
end(); ++cell)
3025 for (
unsigned int face=0; face<6; ++face)
3026 if (adjacent_cells[cell->quad(face)->index()][0] == cell)
3030 if (adjacent_cells[cell->quad(face)->index()].size() == 2)
3033 cell->set_neighbor (face,
3034 adjacent_cells[cell->quad(face)->index()][1]);
3040 cell->set_neighbor (face,
3041 adjacent_cells[cell->quad(face)->index()][0]);
3060 template <
int spacedim>
3065 std::vector<unsigned int> &,
3066 std::vector<unsigned int> &)
3068 const unsigned int dim = 1;
3080 Assert (!cell->child(0)->has_children() && !cell->child(1)->has_children(),
3086 if (cell->neighbor(0)->has_children())
3089 neighbor = cell->neighbor(0);
3093 neighbor = neighbor->child(1);
3096 Assert (neighbor->neighbor(1) == cell->child(0),
3098 neighbor->set_neighbor (1, cell);
3104 if (neighbor->has_children())
3105 neighbor = neighbor->child(1);
3114 if (cell->neighbor(1)->has_children())
3117 neighbor = cell->neighbor(1);
3121 neighbor = neighbor->child(0);
3124 Assert (neighbor->neighbor(0) == cell->child(1),
3126 neighbor->set_neighbor (0, cell);
3132 if (neighbor->has_children())
3133 neighbor = neighbor->child(0);
3143 triangulation.
vertices_used[cell->child(0)->vertex_index(1)] =
false;
3149 for (
unsigned int child=0; child<cell->n_children(); ++child)
3152 cell->child(child)->clear_user_flag();
3153 cell->child(child)->clear_used_flag();
3158 cell->clear_children ();
3159 cell->clear_user_flag();
3164 template <
int spacedim>
3169 std::vector<unsigned int> &line_cell_count,
3170 std::vector<unsigned int> &)
3172 const unsigned int dim=2;
3179 std::vector<typename Triangulation<dim,spacedim>::line_iterator>
3182 lines_to_delete.reserve(4*2+4);
3187 for (
unsigned int c=0; c<cell->n_children(); ++c)
3190 child=cell->child(c);
3191 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
3192 --line_cell_count[child->line_index(l)];
3206 triangulation.
vertices_used[cell->child(0)->line(1)->vertex_index(1)] =
false;
3208 lines_to_delete.push_back(cell->child(0)->line(1));
3209 lines_to_delete.push_back(cell->child(0)->line(3));
3210 lines_to_delete.push_back(cell->child(3)->line(0));
3211 lines_to_delete.push_back(cell->child(3)->line(2));
3219 lines_to_delete.push_back(cell->child(0)->line(inner_face_no));
3223 for (
unsigned int child=0; child<cell->n_children(); ++child)
3225 cell->child(child)->clear_user_data();
3226 cell->child(child)->clear_user_flag();
3227 cell->child(child)->clear_used_flag();
3232 cell->clear_children ();
3233 cell->clear_refinement_case();
3234 cell->clear_user_flag();
3240 for (
unsigned int line_no=0; line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
3242 typename Triangulation<dim,spacedim>::line_iterator
3243 line=cell->line(line_no);
3245 if (line->has_children())
3250 Assert((line_cell_count[line->child_index(0)] == 0 &&
3251 line_cell_count[line->child_index(1)] == 0) ||
3252 (line_cell_count[line->child_index(0)] > 0 &&
3253 line_cell_count[line->child_index(1)] > 0),
3256 if (line_cell_count[line->child_index(0)]==0)
3258 for (
unsigned int c=0; c<2; ++c)
3259 Assert (!line->child(c)->has_children(),
3266 triangulation.
vertices_used[line->child(0)->vertex_index(1)] =
false;
3268 lines_to_delete.push_back(line->child(0));
3269 lines_to_delete.push_back(line->child(1));
3271 line->clear_children();
3283 typename std::vector<typename Triangulation<dim,spacedim>::line_iterator>::iterator
3284 line=lines_to_delete.
begin(),
3285 endline=lines_to_delete.end();
3286 for (; line!=endline; ++line)
3288 (*line)->clear_user_data();
3289 (*line)->clear_user_flag();
3290 (*line)->clear_used_flag();
3296 template <
int spacedim>
3301 std::vector<unsigned int> &line_cell_count,
3302 std::vector<unsigned int> &quad_cell_count)
3304 const unsigned int dim=3;
3314 std::vector<typename Triangulation<dim,spacedim>::line_iterator>
3316 std::vector<typename Triangulation<dim,spacedim>::quad_iterator>
3319 lines_to_delete.reserve(12*2+6*4+6);
3320 quads_to_delete.reserve(6*4+12);
3324 for (
unsigned int c=0; c<cell->n_children(); ++c)
3327 child=cell->child(c);
3328 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++
l)
3329 --line_cell_count[child->line_index(l)];
3330 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
3331 --quad_cell_count[child->quad_index(f)];
3345 quads_to_delete.push_back(cell->child(0)->face(1));
3348 quads_to_delete.push_back(cell->child(0)->face(3));
3351 quads_to_delete.push_back(cell->child(0)->face(5));
3354 quads_to_delete.push_back(cell->child(0)->face(1));
3355 quads_to_delete.push_back(cell->child(0)->face(3));
3356 quads_to_delete.push_back(cell->child(3)->face(0));
3357 quads_to_delete.push_back(cell->child(3)->face(2));
3359 lines_to_delete.push_back(cell->child(0)->line(11));
3362 quads_to_delete.push_back(cell->child(0)->face(1));
3363 quads_to_delete.push_back(cell->child(0)->face(5));
3364 quads_to_delete.push_back(cell->child(3)->face(0));
3365 quads_to_delete.push_back(cell->child(3)->face(4));
3367 lines_to_delete.push_back(cell->child(0)->line(5));
3370 quads_to_delete.push_back(cell->child(0)->face(3));
3371 quads_to_delete.push_back(cell->child(0)->face(5));
3372 quads_to_delete.push_back(cell->child(3)->face(2));
3373 quads_to_delete.push_back(cell->child(3)->face(4));
3375 lines_to_delete.push_back(cell->child(0)->line(7));
3378 quads_to_delete.push_back(cell->child(0)->face(1));
3379 quads_to_delete.push_back(cell->child(2)->face(1));
3380 quads_to_delete.push_back(cell->child(4)->face(1));
3381 quads_to_delete.push_back(cell->child(6)->face(1));
3383 quads_to_delete.push_back(cell->child(0)->face(3));
3384 quads_to_delete.push_back(cell->child(1)->face(3));
3385 quads_to_delete.push_back(cell->child(4)->face(3));
3386 quads_to_delete.push_back(cell->child(5)->face(3));
3388 quads_to_delete.push_back(cell->child(0)->face(5));
3389 quads_to_delete.push_back(cell->child(1)->face(5));
3390 quads_to_delete.push_back(cell->child(2)->face(5));
3391 quads_to_delete.push_back(cell->child(3)->face(5));
3393 lines_to_delete.push_back(cell->child(0)->line(5));
3394 lines_to_delete.push_back(cell->child(0)->line(7));
3395 lines_to_delete.push_back(cell->child(0)->line(11));
3396 lines_to_delete.push_back(cell->child(7)->line(0));
3397 lines_to_delete.push_back(cell->child(7)->line(2));
3398 lines_to_delete.push_back(cell->child(7)->line(8));
3404 triangulation.
vertices_used[cell->child(0)->vertex_index(7)] =
false;
3415 for (
unsigned int child=0; child<cell->n_children(); ++child)
3417 cell->child(child)->clear_user_data();
3418 cell->child(child)->clear_user_flag();
3420 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
3425 cell->child(child)->set_face_orientation (f,
true);
3426 cell->child(child)->set_face_flip(f,
false);
3427 cell->child(child)->set_face_rotation(f,
false);
3430 cell->child(child)->clear_used_flag();
3435 cell->clear_children ();
3436 cell->clear_refinement_case ();
3437 cell->clear_user_flag();
3447 for (
unsigned int quad_no=0; quad_no<GeometryInfo<dim>::faces_per_cell; ++quad_no)
3449 typename Triangulation<dim,spacedim>::quad_iterator
3450 quad=cell->face(quad_no);
3456 switch (quad->refinement_case())
3468 Assert((quad_cell_count[quad->child_index(0)] == 0 &&
3469 quad_cell_count[quad->child_index(1)] == 0) ||
3470 (quad_cell_count[quad->child_index(0)] > 0 &&
3471 quad_cell_count[quad->child_index(1)] > 0),
3477 unsigned int deleted_grandchildren=0;
3478 unsigned int number_of_child_refinements=0;
3480 for (
unsigned int c=0; c<2; ++c)
3481 if (quad->child(c)->has_children())
3483 ++number_of_child_refinements;
3487 Assert((quad_cell_count[quad->child(c)->child_index(0)] == 0 &&
3488 quad_cell_count[quad->child(c)->child_index(1)] == 0) ||
3489 (quad_cell_count[quad->child(c)->child_index(0)] > 0 &&
3490 quad_cell_count[quad->child(c)->child_index(1)] > 0),
3492 if (quad_cell_count[quad->child(c)->child_index(0)]==0)
3505 quads_to_delete.push_back(quad->child(c)->child(0));
3506 quads_to_delete.push_back(quad->child(c)->child(1));
3508 lines_to_delete.push_back(quad->child(c)->child(0)->line(1));
3510 lines_to_delete.push_back(quad->child(c)->child(0)->line(3));
3511 quad->child(c)->clear_children();
3512 quad->child(c)->clear_refinement_case();
3513 ++deleted_grandchildren;
3521 if (number_of_child_refinements>0 &&
3522 deleted_grandchildren==number_of_child_refinements)
3524 typename Triangulation<dim,spacedim>::line_iterator
3527 middle_line=quad->child(0)->line(1);
3529 middle_line=quad->child(0)->line(3);
3531 lines_to_delete.push_back(middle_line->child(0));
3532 lines_to_delete.push_back(middle_line->child(1));
3533 triangulation.
vertices_used[middle_vertex_index<dim,spacedim>(middle_line)]
3535 middle_line->clear_children();
3540 if (quad_cell_count[quad->child_index(0)]==0)
3546 quads_to_delete.push_back(quad->child(0));
3547 quads_to_delete.push_back(quad->child(1));
3549 lines_to_delete.push_back(quad->child(0)->line(1));
3551 lines_to_delete.push_back(quad->child(0)->line(3));
3571 if (quad->child(0)->has_children())
3604 const typename Triangulation<dim,spacedim>::quad_iterator
3605 switch_1=quad->child(0)->child(1),
3606 switch_2=quad->child(1)->child(0);
3611 const int switch_1_index=switch_1->index();
3612 const int switch_2_index=switch_2->index();
3613 for (
unsigned int l=0;
l<triangulation.
levels.size(); ++
l)
3614 for (
unsigned int h=0; h<triangulation.
levels[
l]->cells.cells.size(); ++h)
3615 for (
unsigned int q=0; q<GeometryInfo<dim>::faces_per_cell; ++q)
3617 const int index=triangulation.
levels[
l]->cells.cells[h].face(q);
3618 if (index==switch_1_index)
3619 triangulation.
levels[
l]->cells.cells[h].set_face(q,switch_2_index);
3620 else if (index==switch_2_index)
3621 triangulation.
levels[
l]->cells.cells[h].set_face(q,switch_1_index);
3626 const int switch_1_lines[4]=
3628 static_cast<signed int>(switch_1->line_index(0)),
3629 static_cast<signed int>(switch_1->line_index(1)),
3630 static_cast<signed int>(switch_1->line_index(2)),
3631 static_cast<signed int>(switch_1->line_index(3))
3633 const bool switch_1_line_orientations[4]=
3635 switch_1->line_orientation(0),
3636 switch_1->line_orientation(1),
3637 switch_1->line_orientation(2),
3638 switch_1->line_orientation(3)
3641 const unsigned int switch_1_user_index=switch_1->user_index();
3642 const bool switch_1_user_flag=switch_1->user_flag_set();
3645 switch_2->line_index(1),
3646 switch_2->line_index(2),
3647 switch_2->line_index(3)));
3648 switch_1->set_line_orientation(0, switch_2->line_orientation(0));
3649 switch_1->set_line_orientation(1, switch_2->line_orientation(1));
3650 switch_1->set_line_orientation(2, switch_2->line_orientation(2));
3651 switch_1->set_line_orientation(3, switch_2->line_orientation(3));
3652 switch_1->set_boundary_id_internal(switch_2->boundary_id());
3653 switch_1->set_manifold_id(switch_2->manifold_id());
3654 switch_1->set_user_index(switch_2->user_index());
3655 if (switch_2->user_flag_set())
3656 switch_1->set_user_flag();
3658 switch_1->clear_user_flag();
3663 switch_1_lines[3]));
3664 switch_2->set_line_orientation(0, switch_1_line_orientations[0]);
3665 switch_2->set_line_orientation(1, switch_1_line_orientations[1]);
3666 switch_2->set_line_orientation(2, switch_1_line_orientations[2]);
3667 switch_2->set_line_orientation(3, switch_1_line_orientations[3]);
3668 switch_2->set_boundary_id_internal(switch_1_boundary_id);
3669 switch_2->set_manifold_id(switch_1->manifold_id());
3670 switch_2->set_user_index(switch_1_user_index);
3671 if (switch_1_user_flag)
3672 switch_2->set_user_flag();
3674 switch_2->clear_user_flag();
3676 const unsigned int child_0=quad->child(0)->child_index(0);
3677 const unsigned int child_2=quad->child(1)->child_index(0);
3678 quad->clear_children();
3679 quad->clear_refinement_case();
3681 quad->set_children(0,child_0);
3682 quad->set_children(2,child_2);
3683 std::swap(quad_cell_count[child_0+1],quad_cell_count[child_2]);
3698 const unsigned int child_0=quad->child(0)->child_index(0);
3699 const unsigned int child_2=quad->child(1)->child_index(0);
3700 quad->clear_children();
3701 quad->clear_refinement_case();
3703 quad->set_children(0,child_0);
3704 quad->set_children(2,child_2);
3708 quad->clear_children();
3709 quad->clear_refinement_case();
3722 Assert((quad_cell_count[quad->child_index(0)] == 0 &&
3723 quad_cell_count[quad->child_index(1)] == 0 &&
3724 quad_cell_count[quad->child_index(2)] == 0 &&
3725 quad_cell_count[quad->child_index(3)] == 0) ||
3726 (quad_cell_count[quad->child_index(0)] > 0 &&
3727 quad_cell_count[quad->child_index(1)] > 0 &&
3728 quad_cell_count[quad->child_index(2)] > 0 &&
3729 quad_cell_count[quad->child_index(3)] > 0),
3732 if (quad_cell_count[quad->child_index(0)]==0)
3738 lines_to_delete.push_back(quad->child(0)->line(1));
3739 lines_to_delete.push_back(quad->child(3)->line(0));
3740 lines_to_delete.push_back(quad->child(0)->line(3));
3741 lines_to_delete.push_back(quad->child(3)->line(2));
3743 for (
unsigned int child=0; child<quad->n_children(); ++child)
3744 quads_to_delete.push_back(quad->child(child));
3746 triangulation.
vertices_used[quad->child(0)->vertex_index(3)] =
false;
3748 quad->clear_children();
3749 quad->clear_refinement_case();
3769 for (
unsigned int line_no=0; line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
3771 typename Triangulation<dim,spacedim>::line_iterator
3772 line=cell->line(line_no);
3778 if (line->has_children())
3783 Assert((line_cell_count[line->child_index(0)] == 0 &&
3784 line_cell_count[line->child_index(1)] == 0) ||
3785 (line_cell_count[line->child_index(0)] > 0 &&
3786 line_cell_count[line->child_index(1)] > 0),
3789 if (line_cell_count[line->child_index(0)]==0)
3791 for (
unsigned int c=0; c<2; ++c)
3792 Assert (!line->child(c)->has_children(),
3799 triangulation.
vertices_used[line->child(0)->vertex_index(1)] =
false;
3801 lines_to_delete.push_back(line->child(0));
3802 lines_to_delete.push_back(line->child(1));
3804 line->clear_children();
3816 typename std::vector<typename Triangulation<dim,spacedim>::line_iterator>::iterator
3817 line=lines_to_delete.
begin(),
3818 endline=lines_to_delete.end();
3819 for (; line!=endline; ++line)
3821 (*line)->clear_user_data();
3822 (*line)->clear_user_flag();
3823 (*line)->clear_used_flag();
3826 typename std::vector<typename Triangulation<dim,spacedim>::quad_iterator>::iterator
3827 quad=quads_to_delete.
begin(),
3828 endquad=quads_to_delete.end();
3829 for (; quad!=endquad; ++quad)
3831 (*quad)->clear_user_data();
3832 (*quad)->clear_children();
3833 (*quad)->clear_refinement_case();
3834 (*quad)->clear_user_flag();
3835 (*quad)->clear_used_flag();
3857 template <
int spacedim>
3861 unsigned int &next_unused_vertex,
3862 typename Triangulation<2,spacedim>::raw_line_iterator &next_unused_line,
3866 const unsigned int dim=2;
3869 cell->clear_refine_flag ();
3965 int new_vertices[9];
3966 for (
unsigned int vertex_no=0; vertex_no<4; ++vertex_no)
3967 new_vertices[vertex_no]=cell->vertex_index(vertex_no);
3968 for (
unsigned int line_no=0; line_no<4; ++line_no)
3969 if (cell->line(line_no)->has_children())
3970 new_vertices[4+line_no]=cell->line(line_no)->child(0)->vertex_index(1);
3980 while (triangulation.
vertices_used[next_unused_vertex] ==
true)
3981 ++next_unused_vertex;
3983 ExcMessage(
"Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
3986 new_vertices[8] = next_unused_vertex;
3998 if (dim == spacedim)
4001 triangulation.
vertices[next_unused_vertex] = cell->center(
true);
4011 if (cell->user_flag_set())
4014 cell->clear_user_flag();
4025 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
4026 if (cell->face(face)->at_boundary())
4047 std::vector<Point<spacedim> > ps(2);
4048 std::vector<double> ws(2, 0.5);
4049 ps[0] = cell->face(boundary_face)
4050 ->child(0)->vertex(1);
4052 ::opposite_face[boundary_face])
4053 ->child(0)->vertex(1);
4054 triangulation.
vertices[next_unused_vertex]
4055 = cell->get_manifold().get_new_point(ps,ws);
4066 cell->clear_user_flag();
4071 Assert(cell->material_id()<= std::numeric_limits<types::material_id>::max(),
4072 ExcIndexRange(cell->material_id(),0,std::numeric_limits<types::material_id>::max()));
4076 triangulation.
vertices[next_unused_vertex] =
4083 typename Triangulation<dim,spacedim>::raw_line_iterator new_lines[12];
4084 unsigned int lmin=8;
4085 unsigned int lmax=12;
4092 for (
unsigned int l=lmin; l<lmax; ++l)
4094 while (next_unused_line->used() ==
true)
4096 new_lines[l] = next_unused_line;
4099 Assert (new_lines[l]->used() ==
false,
4100 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4114 for (
unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
4115 for (
unsigned int c=0; c<2; ++c, ++l)
4116 new_lines[l]=cell->line(face_no)->child(c);
4135 new_lines[0]=cell->line(0);
4136 new_lines[1]=cell->line(1);
4137 new_lines[2]=cell->line(2)->child(0);
4138 new_lines[3]=cell->line(2)->child(1);
4139 new_lines[4]=cell->line(3)->child(0);
4140 new_lines[5]=cell->line(3)->child(1);
4152 new_lines[0]=cell->line(0)->child(0);
4153 new_lines[1]=cell->line(0)->child(1);
4154 new_lines[2]=cell->line(1)->child(0);
4155 new_lines[3]=cell->line(1)->child(1);
4156 new_lines[4]=cell->line(2);
4157 new_lines[5]=cell->line(3);
4162 for (
unsigned int l=lmin; l<lmax; ++l)
4164 new_lines[l]->set_used_flag();
4165 new_lines[l]->clear_user_flag();
4167 new_lines[l]->clear_children();
4170 new_lines[l]->set_manifold_id(cell->manifold_id());
4177 while (next_unused_cell->used() ==
true)
4180 const unsigned int n_children=
4182 for (
unsigned int i=0; i<n_children; ++i)
4184 Assert (next_unused_cell->used() ==
false,
4185 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4186 subcells[i] = next_unused_cell;
4188 if (i%2==1 && i<n_children-1)
4189 while (next_unused_cell->used() ==
true)
4209 new_lines[8]->index(),
4210 new_lines[4]->index(),
4211 new_lines[10]->index()));
4214 new_lines[2]->index(),
4215 new_lines[5]->index(),
4216 new_lines[11]->index()));
4219 new_lines[9]->index(),
4220 new_lines[10]->index(),
4221 new_lines[6]->index()));
4224 new_lines[3]->index(),
4225 new_lines[11]->index(),
4226 new_lines[7]->index()));
4244 new_lines[6]->index(),
4245 new_lines[2]->index(),
4246 new_lines[4]->index()));
4249 new_lines[1]->index(),
4250 new_lines[3]->index(),
4251 new_lines[5]->index()));
4270 new_lines[2]->index(),
4271 new_lines[4]->index(),
4272 new_lines[6]->index()));
4275 new_lines[3]->index(),
4276 new_lines[6]->index(),
4277 new_lines[5]->index()));
4282 for (
unsigned int i=0; i<n_children; ++i)
4284 subcells[i]->set_used_flag();
4285 subcells[i]->clear_refine_flag();
4286 subcells[i]->clear_user_flag();
4287 subcells[i]->clear_user_data();
4288 subcells[i]->clear_children();
4291 subcells[i]->set_material_id (cell->material_id());
4292 subcells[i]->set_manifold_id (cell->manifold_id());
4293 subcells[i]->set_subdomain_id (subdomainid);
4296 subcells[i]->set_parent (cell->index ());
4304 for (
unsigned int i=0; i<n_children/2; ++i)
4305 cell->set_children (2*i, subcells[2*i]->index());
4307 cell->set_refinement_case(ref_case);
4315 for (
unsigned int c=0; c<n_children; ++c)
4316 cell->child(c)->set_direction_flag (cell->direction_flag());
4326 template <
int spacedim>
4332 const unsigned int dim = 1;
4340 endc = triangulation.
end();
4341 for (; cell != endc; ++cell)
4343 if (cell->refine_flag_set())
4356 unsigned int needed_vertices = 0;
4357 for (
int level=triangulation.
levels.size()-2; level>=0; --level)
4361 unsigned int flagged_cells = 0;
4365 for (; acell!=aendc; ++acell)
4366 if (acell->refine_flag_set())
4371 const unsigned int used_cells
4372 = std::count_if (triangulation.
levels[level+1]->cells.used.begin(),
4373 triangulation.
levels[level+1]->cells.used.end(),
4374 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
4379 triangulation.
levels[level+1]
4380 ->reserve_space(used_cells+
4387 triangulation.
levels[level+1]->cells
4392 needed_vertices += flagged_cells;
4397 needed_vertices += std::count_if (triangulation.
vertices_used.begin(),
4399 std_cxx11::bind (std::equal_to<bool>(),
4405 if (needed_vertices > triangulation.
vertices.size())
4407 triangulation.
vertices.resize (needed_vertices,
4409 triangulation.
vertices_used.resize (needed_vertices,
false);
4417 unsigned int next_unused_vertex = 0;
4419 for (
int level=triangulation.
levels.size()-2; level>=0; --level)
4426 next_unused_cell = triangulation.
begin_raw (level+1);
4428 for (; (cell!=endc) && (cell->level()==level); ++cell)
4429 if (cell->refine_flag_set())
4432 cell->clear_refine_flag ();
4436 while (triangulation.
vertices_used[next_unused_vertex] ==
true)
4437 ++next_unused_vertex;
4439 ExcMessage(
"Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
4444 triangulation.
vertices[next_unused_vertex] =
4454 while (next_unused_cell->used() ==
true)
4456 first_child = next_unused_cell;
4457 first_child->set_used_flag ();
4458 first_child->clear_user_data ();
4460 Assert (next_unused_cell->used() ==
false,
4461 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4462 second_child = next_unused_cell;
4463 second_child->set_used_flag ();
4464 second_child->clear_user_data ();
4469 cell->set_children (0, first_child->index());
4470 first_child->clear_children ();
4473 next_unused_vertex));
4474 first_child->set_material_id (cell->material_id());
4475 first_child->set_manifold_id (cell->manifold_id());
4476 first_child->set_subdomain_id (subdomainid);
4477 first_child->set_direction_flag (cell->direction_flag());
4479 first_child->set_parent (cell->index ());
4483 first_child->face(1)->set_manifold_id(cell->manifold_id());
4488 first_child->set_neighbor (1, second_child);
4490 first_child->set_neighbor (0, cell->neighbor(0));
4491 else if (cell->neighbor(0)->active())
4497 Assert (cell->neighbor (0)->level () <= cell->level (),
4499 first_child->set_neighbor (0, cell->neighbor(0));
4505 const unsigned int nbnb = cell->neighbor_of_neighbor (0);
4506 first_child->set_neighbor (0, cell->neighbor(0)->child(nbnb));
4511 left_neighbor = cell->neighbor(0);
4512 while (left_neighbor->has_children())
4514 left_neighbor = left_neighbor->child(nbnb);
4515 left_neighbor->set_neighbor (nbnb, first_child);
4520 second_child->clear_children ();
4523 cell->vertex_index(1)));
4524 second_child->set_neighbor (0, first_child);
4525 second_child->set_material_id (cell->material_id());
4526 second_child->set_manifold_id (cell->manifold_id());
4527 second_child->set_subdomain_id (subdomainid);
4528 second_child->set_direction_flag (cell->direction_flag());
4531 second_child->set_neighbor (1, cell->neighbor(1));
4532 else if (cell->neighbor(1)->active())
4534 Assert (cell->neighbor (1)->level () <= cell->level (),
4536 second_child->set_neighbor (1, cell->neighbor(1));
4541 const unsigned int nbnb = cell->neighbor_of_neighbor (1);
4542 second_child->set_neighbor (1, cell->neighbor(1)->child(nbnb));
4545 right_neighbor = cell->neighbor(1);
4546 while (right_neighbor->has_children())
4548 right_neighbor = right_neighbor->child(nbnb);
4549 right_neighbor->set_neighbor (nbnb, second_child);
4553 triangulation.
signals.post_refinement_on_cell(cell);
4569 template <
int spacedim>
4573 const bool check_for_distorted_cells)
4575 const unsigned int dim = 2;
4584 endc = triangulation.
end();
4585 for (; cell != endc; ++cell)
4587 if (cell->refine_flag_set())
4597 for (
typename Triangulation<dim,spacedim>::line_iterator
4600 line->clear_user_flag();
4601 line->clear_user_data();
4606 unsigned int n_single_lines=0;
4610 unsigned int n_lines_in_pairs = 0;
4616 unsigned int needed_vertices = 0;
4617 for (
int level=triangulation.
levels.size()-2; level>=0; --level)
4621 unsigned int needed_cells = 0;
4626 for (; cell!=endc; ++cell)
4627 if (cell->refine_flag_set())
4638 n_single_lines += 4;
4650 n_single_lines += 1;
4659 for (
unsigned int line_no=0; line_no<GeometryInfo<dim>::faces_per_cell;
4665 typename Triangulation<dim,spacedim>::line_iterator
4666 line = cell->line(line_no);
4667 if (line->has_children() ==
false)
4669 line->set_user_flag ();
4677 if (line->at_boundary())
4680 line->set_user_index(line->boundary_id());
4685 line->set_user_index(cell->material_id());
4694 const unsigned int used_cells
4695 = std::count_if (triangulation.
levels[level+1]->cells.used.begin(),
4696 triangulation.
levels[level+1]->cells.used.end(),
4697 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
4703 triangulation.
levels[level+1]
4704 ->reserve_space (used_cells+needed_cells, 2, spacedim);
4708 triangulation.
levels[level+1]->cells.
4709 reserve_space (needed_cells,0);
4713 for (
typename Triangulation<dim,spacedim>::line_iterator
4715 if (line->user_flag_set())
4718 n_lines_in_pairs += 2;
4719 needed_vertices += 1;
4728 triangulation.
faces->lines.
4729 reserve_space (n_lines_in_pairs, 0);
4733 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
4737 if (needed_vertices > triangulation.
vertices.size())
4740 triangulation.
vertices_used.resize (needed_vertices,
false);
4748 unsigned int next_unused_vertex = 0;
4755 typename Triangulation<dim,spacedim>::active_line_iterator
4758 typename Triangulation<dim,spacedim>::raw_line_iterator
4761 for (; line!=endl; ++line)
4762 if (line->user_flag_set())
4768 while (triangulation.
vertices_used[next_unused_vertex] ==
true)
4769 ++next_unused_vertex;
4771 ExcMessage(
"Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
4774 if (spacedim == dim)
4781 triangulation.
vertices[next_unused_vertex]
4782 = line->center(
true);
4791 triangulation.
vertices[next_unused_vertex]
4792 = triangulation.
get_manifold(line->user_index()).get_new_point_on_line (line);
4794 triangulation.
vertices[next_unused_vertex]
4795 = line->center(
true);
4800 bool pair_found=
false;
4802 for (; next_unused_line!=endl; ++next_unused_line)
4803 if (!next_unused_line->used() &&
4804 !(++next_unused_line)->used())
4817 line->set_children (0, next_unused_line->index());
4820 const typename Triangulation<dim,spacedim>::raw_line_iterator
4821 children[2] = { next_unused_line,
4826 Assert (children[0]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4827 Assert (children[1]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
4831 next_unused_vertex));
4834 line->vertex_index(1)));
4836 children[0]->set_used_flag();
4837 children[1]->set_used_flag();
4838 children[0]->clear_children();
4839 children[1]->clear_children();
4842 children[0]->clear_user_flag();
4843 children[1]->clear_user_flag();
4846 children[0]->set_boundary_id_internal(line->boundary_id());
4847 children[1]->set_boundary_id_internal(line->boundary_id());
4849 children[0]->set_manifold_id (line->manifold_id());
4850 children[1]->set_manifold_id (line->manifold_id());
4854 line->clear_user_flag ();
4863 triangulation.
faces->lines.
4864 reserve_space (0,n_single_lines);
4867 cells_with_distorted_children;
4871 typename Triangulation<dim,spacedim>::raw_line_iterator
4874 for (
int level=0; level<static_cast<int>(triangulation.
levels.size())-1; ++level)
4884 next_unused_cell = triangulation.
begin_raw (level+1);
4886 for (; cell!=endc; ++cell)
4887 if (cell->refine_flag_set())
4895 if (cell->at_boundary())
4896 cell->set_user_flag();
4906 if ((check_for_distorted_cells ==
true)
4908 has_distorted_children (cell,
4913 triangulation.
signals.post_refinement_on_cell(cell);
4917 return cells_with_distorted_children;
4925 template <
int spacedim>
4929 const bool check_for_distorted_cells)
4931 const unsigned int dim = 3;
4946 endc = triangulation.
end();
4947 for (; cell != endc; ++cell)
4949 if (cell->refine_flag_set())
4959 triangulation.
faces->quads.clear_user_data();
4961 for (
typename Triangulation<dim,spacedim>::line_iterator
4963 line->clear_user_flag();
4964 for (
typename Triangulation<dim,spacedim>::quad_iterator
4966 quad->clear_user_flag();
4991 unsigned int needed_vertices = 0;
4992 unsigned int needed_lines_single = 0;
4993 unsigned int needed_quads_single = 0;
4994 unsigned int needed_lines_pair = 0;
4995 unsigned int needed_quads_pair = 0;
4996 for (
int level=triangulation.
levels.size()-2; level>=0; --level)
5000 unsigned int new_cells = 0;
5005 for (; acell!=aendc; ++acell)
5006 if (acell->refine_flag_set())
5016 ++needed_quads_single;
5024 ++needed_lines_single;
5025 needed_quads_single += 4;
5032 needed_lines_single += 6;
5033 needed_quads_single += 12;
5047 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell;
5051 aface = acell->face(face);
5057 acell->face_orientation(face),
5058 acell->face_flip(face),
5059 acell->face_rotation(face));
5066 if (aface->number_of_children()<4)
5069 aface->set_user_flag();
5071 else if (aface->refinement_case()!=face_ref_case)
5085 aface->set_user_index(face_ref_case);
5091 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
5093 !acell->line(line)->has_children())
5094 acell->line(line)->set_user_flag();
5100 const unsigned int used_cells
5101 = std::count_if (triangulation.
levels[level+1]->cells.used.begin(),
5102 triangulation.
levels[level+1]->cells.used.end(),
5103 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
5109 triangulation.
levels[level+1]
5110 ->reserve_space (used_cells+new_cells, 3, spacedim);
5113 triangulation.
levels[level+1]->cells.reserve_space (new_cells);
5117 for (
typename Triangulation<dim,spacedim>::quad_iterator
5120 if (quad->user_flag_set())
5126 needed_quads_pair += 4;
5127 needed_lines_pair += 4;
5128 needed_vertices += 1;
5130 if (quad->user_index())
5134 needed_quads_pair += 2;
5135 needed_lines_single += 1;
5148 if (quad->has_children())
5151 if ((face_refinement_cases[quad->user_index()]==
RefinementCase<dim-1>::cut_x
5152 && (quad->child(0)->line_index(1)+1!=quad->child(2)->line_index(1))) ||
5153 (face_refinement_cases[quad->user_index()]==
RefinementCase<dim-1>::cut_y
5154 && (quad->child(0)->line_index(3)+1!=quad->child(1)->line_index(3))))
5155 needed_lines_pair +=2;
5160 for (
typename Triangulation<dim,spacedim>::line_iterator
5162 if (line->user_flag_set())
5164 needed_lines_pair += 2;
5165 needed_vertices += 1;
5169 triangulation.
faces->lines.
5170 reserve_space (needed_lines_pair,needed_lines_single);
5172 triangulation.
faces->quads.
5173 reserve_space (needed_quads_pair,needed_quads_single);
5178 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
5182 if (needed_vertices > triangulation.
vertices.size())
5185 triangulation.
vertices_used.resize (needed_vertices,
false);
5202 if (!cell->refine_flag_set())
5203 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
5204 if (cell->line(line)->has_children())
5205 for (
unsigned int c=0; c<2; ++c)
5206 Assert (cell->line(line)->child(c)->user_flag_set() ==
false,
5218 unsigned int next_unused_vertex = 0;
5224 typename Triangulation<dim,spacedim>::active_line_iterator
5227 typename Triangulation<dim,spacedim>::raw_line_iterator
5230 for (; line!=endl; ++line)
5231 if (line->user_flag_set())
5237 while (triangulation.
vertices_used[next_unused_vertex] ==
true)
5238 ++next_unused_vertex;
5240 ExcMessage(
"Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
5243 triangulation.
vertices[next_unused_vertex]
5244 = line->center(
true);
5249 next_unused_line=triangulation.
faces->lines.next_free_pair_object(triangulation);
5256 line->set_children (0, next_unused_line->index());
5259 const typename Triangulation<dim,spacedim>::raw_line_iterator
5260 children[2] = { next_unused_line,
5266 Assert (children[0]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5267 Assert (children[1]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5271 next_unused_vertex));
5274 line->vertex_index(1)));
5276 children[0]->set_used_flag();
5277 children[1]->set_used_flag();
5278 children[0]->clear_children();
5279 children[1]->clear_children();
5282 children[0]->clear_user_flag();
5283 children[1]->clear_user_flag();
5285 children[0]->set_boundary_id_internal(line->boundary_id());
5286 children[1]->set_boundary_id_internal(line->boundary_id());
5288 children[0]->set_manifold_id (line->manifold_id());
5289 children[1]->set_manifold_id (line->manifold_id());
5294 line->clear_user_flag ();
5329 typename Triangulation<dim,spacedim>::quad_iterator
5332 typename Triangulation<dim,spacedim>::raw_line_iterator
5334 typename Triangulation<dim,spacedim>::raw_quad_iterator
5337 for (; quad!=endq; ++quad)
5339 if (quad->user_index())
5341 RefinementCase<dim-1> aniso_quad_ref_case=face_refinement_cases[quad->user_index()];
5350 if (aniso_quad_ref_case == quad->refinement_case())
5363 typename Triangulation<dim,spacedim>::raw_line_iterator new_line;
5365 new_line=triangulation.
faces->lines.next_free_single_object(triangulation);
5366 Assert (new_line->used() ==
false,
5367 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5382 unsigned int vertex_indices[2];
5385 vertex_indices[0]=quad->line(2)->child(0)->vertex_index(1);
5386 vertex_indices[1]=quad->line(3)->child(0)->vertex_index(1);
5390 vertex_indices[0]=quad->line(0)->child(0)->vertex_index(1);
5391 vertex_indices[1]=quad->line(1)->child(0)->vertex_index(1);
5396 new_line->set_used_flag();
5397 new_line->clear_user_flag();
5399 new_line->clear_children();
5400 new_line->set_boundary_id_internal(quad->boundary_id());
5401 new_line->set_manifold_id(quad->manifold_id());
5409 const unsigned int index[2][2]=
5417 typename Triangulation<dim,spacedim>::raw_quad_iterator new_quads[2];
5419 next_unused_quad=triangulation.
faces->quads.next_free_pair_object(triangulation);
5420 new_quads[0] = next_unused_quad;
5421 Assert (new_quads[0]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5424 new_quads[1] = next_unused_quad;
5425 Assert (new_quads[1]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5433 quad->line(2)->child(index[0][quad->line_orientation(2)])->index(),
5434 quad->line(3)->child(index[0][quad->line_orientation(3)])->index()));
5437 quad->line_index(1),
5438 quad->line(2)->child(index[1][quad->line_orientation(2)])->index(),
5439 quad->line(3)->child(index[1][quad->line_orientation(3)])->index()));
5444 ::
TriaObject<2>(quad->line(0)->child(index[0][quad->line_orientation(0)])->index(),
5445 quad->line(1)->child(index[0][quad->line_orientation(1)])->index(),
5446 quad->line_index(2),
5447 new_line->index()));
5449 ::
TriaObject<2>(quad->line(0)->child(index[1][quad->line_orientation(0)])->index(),
5450 quad->line(1)->child(index[1][quad->line_orientation(1)])->index(),
5452 quad->line_index(3)));
5455 for (
unsigned int i=0; i<2; ++i)
5457 new_quads[i]->set_used_flag();
5458 new_quads[i]->clear_user_flag();
5460 new_quads[i]->clear_children();
5461 new_quads[i]->set_boundary_id_internal(quad->boundary_id());
5462 new_quads[i]->set_manifold_id (quad->manifold_id());
5466 for (
unsigned int j=0; j<GeometryInfo<dim>::lines_per_face; ++j)
5467 new_quads[i]->set_line_orientation(j,
true);
5473 new_quads[0]->set_line_orientation(0,quad->line_orientation(0));
5474 new_quads[0]->set_line_orientation(2,quad->line_orientation(2));
5475 new_quads[1]->set_line_orientation(1,quad->line_orientation(1));
5476 new_quads[1]->set_line_orientation(3,quad->line_orientation(3));
5479 new_quads[0]->set_line_orientation(3,quad->line_orientation(3));
5480 new_quads[1]->set_line_orientation(2,quad->line_orientation(2));
5484 new_quads[0]->set_line_orientation(1,quad->line_orientation(1));
5485 new_quads[1]->set_line_orientation(0,quad->line_orientation(0));
5511 typename Triangulation<dim,spacedim>::line_iterator old_child[2];
5514 old_child[0]=quad->child(0)->line(1);
5515 old_child[1]=quad->child(2)->line(1);
5521 old_child[0]=quad->child(0)->line(3);
5522 old_child[1]=quad->child(1)->line(3);
5525 if (old_child[0]->index()+1 != old_child[1]->index())
5530 typename Triangulation<dim,spacedim>::raw_line_iterator new_child[2];
5532 new_child[0]=new_child[1]=triangulation.
faces->lines.next_free_pair_object(triangulation);
5535 new_child[0]->set_used_flag();
5536 new_child[1]->set_used_flag();
5538 const int old_index_0=old_child[0]->index(),
5539 old_index_1=old_child[1]->index(),
5540 new_index_0=new_child[0]->index(),
5541 new_index_1=new_child[1]->index();
5545 for (
unsigned int q=0; q<triangulation.
faces->quads.cells.size(); ++q)
5546 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
5548 const int this_index=triangulation.
faces->quads.cells[q].face(l);
5549 if (this_index==old_index_0)
5550 triangulation.
faces->quads.cells[q].set_face(l,new_index_0);
5551 else if (this_index==old_index_1)
5552 triangulation.
faces->quads.cells[q].set_face(l,new_index_1);
5556 for (
unsigned int i=0; i<2; ++i)
5561 old_child[i]->vertex_index(1)));
5562 new_child[i]->set_boundary_id_internal(old_child[i]->boundary_id());
5563 new_child[i]->set_manifold_id(old_child[i]->manifold_id());
5564 new_child[i]->set_user_index(old_child[i]->user_index());
5565 if (old_child[i]->user_flag_set())
5566 new_child[i]->set_user_flag();
5568 new_child[i]->clear_user_flag();
5570 new_child[i]->clear_children();
5572 old_child[i]->clear_user_flag();
5573 old_child[i]->clear_user_index();
5574 old_child[i]->clear_used_flag();
5582 new_line->set_children(0, quad->child(0)->line_index(1));
5583 Assert(new_line->child(1)==quad->child(2)->line(1),
5619 const typename Triangulation<dim,spacedim>::quad_iterator
5620 switch_1=quad->child(1),
5621 switch_2=quad->child(2);
5622 const int switch_1_index=switch_1->index();
5623 const int switch_2_index=switch_2->index();
5624 for (
unsigned int l=0; l<triangulation.
levels.size(); ++l)
5625 for (
unsigned int h=0; h<triangulation.
levels[l]->cells.cells.size(); ++h)
5626 for (
unsigned int q=0; q<GeometryInfo<dim>::faces_per_cell; ++q)
5628 const int face_index=triangulation.
levels[l]->cells.cells[h].face(q);
5629 if (face_index==switch_1_index)
5630 triangulation.
levels[l]->cells.cells[h].set_face(q,switch_2_index);
5631 else if (face_index==switch_2_index)
5632 triangulation.
levels[l]->cells.cells[h].set_face(q,switch_1_index);
5636 const unsigned int switch_1_lines[4]=
5638 switch_1->line_index(0),
5639 switch_1->line_index(1),
5640 switch_1->line_index(2),
5641 switch_1->line_index(3)
5643 const bool switch_1_line_orientations[4]=
5645 switch_1->line_orientation(0),
5646 switch_1->line_orientation(1),
5647 switch_1->line_orientation(2),
5648 switch_1->line_orientation(3)
5651 const unsigned int switch_1_user_index=switch_1->user_index();
5652 const bool switch_1_user_flag=switch_1->user_flag_set();
5653 const RefinementCase<dim-1> switch_1_refinement_case=switch_1->refinement_case();
5654 const int switch_1_first_child_pair=(switch_1_refinement_case ? switch_1->child_index(0) : -1);
5655 const int switch_1_second_child_pair=(switch_1_refinement_case==
RefinementCase<dim-1>::cut_xy ? switch_1->child_index(2) : -1);
5658 switch_2->line_index(1),
5659 switch_2->line_index(2),
5660 switch_2->line_index(3)));
5661 switch_1->set_line_orientation(0, switch_2->line_orientation(0));
5662 switch_1->set_line_orientation(1, switch_2->line_orientation(1));
5663 switch_1->set_line_orientation(2, switch_2->line_orientation(2));
5664 switch_1->set_line_orientation(3, switch_2->line_orientation(3));
5665 switch_1->set_boundary_id_internal(switch_2->boundary_id());
5666 switch_1->set_manifold_id(switch_2->manifold_id());
5667 switch_1->set_user_index(switch_2->user_index());
5668 if (switch_2->user_flag_set())
5669 switch_1->set_user_flag();
5671 switch_1->clear_user_flag();
5672 switch_1->clear_refinement_case();
5673 switch_1->set_refinement_case(switch_2->refinement_case());
5674 switch_1->clear_children();
5675 if (switch_2->refinement_case())
5676 switch_1->set_children(0, switch_2->child_index(0));
5678 switch_1->set_children(2, switch_2->child_index(2));
5683 switch_1_lines[3]));
5684 switch_2->set_line_orientation(0, switch_1_line_orientations[0]);
5685 switch_2->set_line_orientation(1, switch_1_line_orientations[1]);
5686 switch_2->set_line_orientation(2, switch_1_line_orientations[2]);
5687 switch_2->set_line_orientation(3, switch_1_line_orientations[3]);
5688 switch_2->set_boundary_id_internal(switch_1_boundary_id);
5689 switch_2->set_manifold_id(switch_1->manifold_id());
5690 switch_2->set_user_index(switch_1_user_index);
5691 if (switch_1_user_flag)
5692 switch_2->set_user_flag();
5694 switch_2->clear_user_flag();
5695 switch_2->clear_refinement_case();
5696 switch_2->set_refinement_case(switch_1_refinement_case);
5697 switch_2->clear_children();
5698 switch_2->set_children(0, switch_1_first_child_pair);
5699 switch_2->set_children(2, switch_1_second_child_pair);
5702 new_quads[0]->set_children(0, quad->child_index(0));
5704 new_quads[1]->set_children(0, quad->child_index(2));
5709 new_quads[0]->set_children(0, quad->child_index(0));
5711 new_quads[1]->set_children(0, quad->child_index(2));
5712 new_line->set_children(0, quad->child(0)->line_index(3));
5713 Assert(new_line->child(1)==quad->child(1)->line(3),
5716 quad->clear_children();
5720 quad->set_children (0, new_quads[0]->index());
5722 quad->set_refinement_case(aniso_quad_ref_case);
5729 if (quad->user_flag_set())
5739 while (triangulation.
vertices_used[next_unused_vertex] ==
true)
5740 ++next_unused_vertex;
5742 ExcMessage(
"Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
5749 const RefinementCase<dim-1> quad_ref_case=quad->refinement_case();
5758 typename Triangulation<dim,spacedim>::line_iterator middle_line;
5760 middle_line=quad->child(0)->line(1);
5762 middle_line=quad->child(0)->line(3);
5769 if (!middle_line->has_children())
5776 triangulation.
vertices[next_unused_vertex]
5777 = middle_line->center(
true);
5782 next_unused_line=triangulation.
faces->lines.next_free_pair_object(triangulation);
5786 middle_line->set_children (0, next_unused_line->index());
5789 const typename Triangulation<dim,spacedim>::raw_line_iterator
5790 children[2] = { next_unused_line,
5797 Assert (children[0]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5798 Assert (children[1]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5802 next_unused_vertex));
5805 middle_line->vertex_index(1)));
5807 children[0]->set_used_flag();
5808 children[1]->set_used_flag();
5809 children[0]->clear_children();
5810 children[1]->clear_children();
5813 children[0]->clear_user_flag();
5814 children[1]->clear_user_flag();
5816 children[0]->set_boundary_id_internal (middle_line->boundary_id());
5817 children[1]->set_boundary_id_internal (middle_line->boundary_id());
5819 children[0]->set_manifold_id (middle_line->manifold_id());
5820 children[1]->set_manifold_id (middle_line->manifold_id());
5826 quad->clear_user_flag();
5837 if (quad->at_boundary() ||
5839 triangulation.
vertices[next_unused_vertex]
5840 = quad->center(
true);
5864 triangulation.
vertices[next_unused_vertex] =
5865 quad->center(
true,
true);
5871 typename Triangulation<dim,spacedim>::raw_line_iterator new_lines[4];
5873 for (
unsigned int i=0; i<4; ++i)
5882 next_unused_line=triangulation.
faces->lines.next_free_pair_object(triangulation);
5884 new_lines[i] = next_unused_line;
5887 Assert (new_lines[i]->used() ==
false,
5888 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5908 const unsigned int vertex_indices[5]
5909 = { quad->line(0)->child(0)->vertex_index(1),
5910 quad->line(1)->child(0)->vertex_index(1),
5911 quad->line(2)->child(0)->vertex_index(1),
5912 quad->line(3)->child(0)->vertex_index(1),
5925 for (
unsigned int i=0; i<4; ++i)
5927 new_lines[i]->set_used_flag();
5928 new_lines[i]->clear_user_flag();
5930 new_lines[i]->clear_children();
5931 new_lines[i]->set_boundary_id_internal(quad->boundary_id());
5932 new_lines[i]->set_manifold_id(quad->manifold_id());
5951 const unsigned int index[2][2]=
5957 const int line_indices[12]
5958 = { quad->line(0)->child(index[0][quad->line_orientation(0)])->index(),
5959 quad->line(0)->child(index[1][quad->line_orientation(0)])->index(),
5960 quad->line(1)->child(index[0][quad->line_orientation(1)])->index(),
5961 quad->line(1)->child(index[1][quad->line_orientation(1)])->index(),
5962 quad->line(2)->child(index[0][quad->line_orientation(2)])->index(),
5963 quad->line(2)->child(index[1][quad->line_orientation(2)])->index(),
5964 quad->line(3)->child(index[0][quad->line_orientation(3)])->index(),
5965 quad->line(3)->child(index[1][quad->line_orientation(3)])->index(),
5966 new_lines[0]->index(),
5967 new_lines[1]->index(),
5968 new_lines[2]->index(),
5969 new_lines[3]->index()
5975 typename Triangulation<dim,spacedim>::raw_quad_iterator new_quads[4];
5977 next_unused_quad=triangulation.
faces->quads.next_free_pair_object(triangulation);
5979 new_quads[0] = next_unused_quad;
5980 Assert (new_quads[0]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5983 new_quads[1] = next_unused_quad;
5984 Assert (new_quads[1]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5986 next_unused_quad=triangulation.
faces->quads.next_free_pair_object(triangulation);
5987 new_quads[2] = next_unused_quad;
5988 Assert (new_quads[2]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5991 new_quads[3] = next_unused_quad;
5992 Assert (new_quads[3]->used() ==
false,
ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
5995 quad->set_children (0, new_quads[0]->index());
5996 quad->set_children (2, new_quads[2]->index());
6025 for (
unsigned int i=0; i<4; ++i)
6027 new_quads[i]->set_used_flag();
6028 new_quads[i]->clear_user_flag();
6030 new_quads[i]->clear_children();
6031 new_quads[i]->set_boundary_id_internal (quad->boundary_id());
6032 new_quads[i]->set_manifold_id (quad->manifold_id());
6036 for (
unsigned int j=0; j<GeometryInfo<dim>::lines_per_face; ++j)
6037 new_quads[i]->set_line_orientation(j,
true);
6043 new_quads[0]->set_line_orientation(0,quad->line_orientation(0));
6044 new_quads[0]->set_line_orientation(2,quad->line_orientation(2));
6045 new_quads[1]->set_line_orientation(1,quad->line_orientation(1));
6046 new_quads[1]->set_line_orientation(2,quad->line_orientation(2));
6047 new_quads[2]->set_line_orientation(0,quad->line_orientation(0));
6048 new_quads[2]->set_line_orientation(3,quad->line_orientation(3));
6049 new_quads[3]->set_line_orientation(1,quad->line_orientation(1));
6050 new_quads[3]->set_line_orientation(3,quad->line_orientation(3));
6054 quad->clear_user_flag ();
6065 cells_with_distorted_children;
6067 for (
unsigned int level=0; level!=triangulation.
levels.size()-1; ++level)
6072 typename Triangulation<dim,spacedim>::active_hex_iterator
6075 typename Triangulation<dim,spacedim>::raw_hex_iterator
6078 for (; hex!=endh; ++hex)
6079 if (hex->refine_flag_set())
6087 hex->clear_refine_flag ();
6088 hex->set_refinement_case(ref_case);
6099 unsigned int n_new_lines=0;
6100 unsigned int n_new_quads=0;
6101 unsigned int n_new_hexes=0;
6130 std::vector<typename Triangulation<dim,spacedim>::raw_line_iterator>
6131 new_lines(n_new_lines);
6132 for (
unsigned int i=0; i<n_new_lines; ++i)
6134 new_lines[i] = triangulation.
faces->lines.next_free_single_object(triangulation);
6136 Assert (new_lines[i]->used() ==
false,
6137 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6138 new_lines[i]->set_used_flag();
6139 new_lines[i]->clear_user_flag();
6140 new_lines[i]->clear_user_data();
6141 new_lines[i]->clear_children();
6145 new_lines[i]->set_manifold_id(hex->manifold_id());
6150 std::vector<typename Triangulation<dim,spacedim>::raw_quad_iterator>
6151 new_quads(n_new_quads);
6152 for (
unsigned int i=0; i<n_new_quads; ++i)
6154 new_quads[i] = triangulation.
faces->quads.next_free_single_object(triangulation);
6156 Assert (new_quads[i]->used() ==
false,
6157 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6158 new_quads[i]->set_used_flag();
6159 new_quads[i]->clear_user_flag();
6160 new_quads[i]->clear_user_data();
6161 new_quads[i]->clear_children();
6165 new_quads[i]->set_manifold_id (hex->manifold_id());
6168 for (
unsigned int j=0; j<GeometryInfo<dim>::lines_per_face; ++j)
6169 new_quads[i]->set_line_orientation(j,
true);
6176 std::vector<typename Triangulation<dim,spacedim>::raw_hex_iterator>
6177 new_hexes(n_new_hexes);
6178 for (
unsigned int i=0; i<n_new_hexes; ++i)
6181 next_unused_hex=triangulation.
levels[level+1]->cells.next_free_hex(triangulation,level+1);
6185 new_hexes[i]=next_unused_hex;
6187 Assert (new_hexes[i]->used() ==
false,
6188 ExcMessage(
"Internal error: We want to use a cell during refinement that should be unused, but turns out not to be."));
6189 new_hexes[i]->set_used_flag();
6190 new_hexes[i]->clear_user_flag();
6191 new_hexes[i]->clear_user_data();
6192 new_hexes[i]->clear_children();
6195 new_hexes[i]->set_material_id (hex->material_id());
6196 new_hexes[i]->set_manifold_id (hex->manifold_id());
6197 new_hexes[i]->set_subdomain_id (subdomainid);
6200 new_hexes[i]->set_parent (hex->index ());
6212 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
6214 new_hexes[i]->set_face_orientation(f,
true);
6215 new_hexes[i]->set_face_flip(f,
false);
6216 new_hexes[i]->set_face_rotation(f,
false);
6220 for (
unsigned int i=0; i<n_new_hexes/2; ++i)
6221 hex->set_children (2*i, new_hexes[2*i]->index());
6229 = { hex->face_orientation (0),
6230 hex->face_orientation (1),
6231 hex->face_orientation (2),
6232 hex->face_orientation (3),
6233 hex->face_orientation (4),
6234 hex->face_orientation (5)
6239 = { hex->face_flip (0),
6249 = { hex->face_rotation (0),
6250 hex->face_rotation (1),
6251 hex->face_rotation (2),
6252 hex->face_rotation (3),
6253 hex->face_rotation (4),
6254 hex->face_rotation (5)
6265 const unsigned int child_at_origin[2][2][2]=
6294 const typename Triangulation<dim,spacedim>::raw_line_iterator
6296 const unsigned int *line_indices = NULL;
6297 const bool *line_orientation = NULL;
6298 const int *quad_indices = NULL;
6357 const typename Triangulation<dim,spacedim>::raw_line_iterator
6361 hex->face(2)->child(0)
6363 hex->face(3)->child(0)
6365 hex->face(4)->child(0)
6367 hex->face(5)->child(0)
6371 lines = &lines_x[0];
6373 unsigned int line_indices_x[4];
6375 for (
unsigned int i=0; i<4; ++i)
6376 line_indices_x[i] = lines[i]->index();
6377 line_indices = &line_indices_x[0];
6384 bool line_orientation_x[4];
6390 const unsigned int middle_vertices[2]=
6392 hex->line(2)->child(0)->vertex_index(1),
6393 hex->line(7)->child(0)->vertex_index(1)
6396 for (
unsigned int i=0; i<4; ++i)
6397 if (lines[i]->vertex_index(i%2)==middle_vertices[i%2])
6398 line_orientation_x[i]=
true;
6403 Assert(lines[i]->vertex_index((i+1)%2)==middle_vertices[i%2],
6405 line_orientation_x[i]=
false;
6408 line_orientation=&line_orientation_x[0];
6418 new_quads[0]->set_line_orientation(0,line_orientation[0]);
6419 new_quads[0]->set_line_orientation(1,line_orientation[1]);
6420 new_quads[0]->set_line_orientation(2,line_orientation[2]);
6421 new_quads[0]->set_line_orientation(3,line_orientation[3]);
6454 const int quad_indices_x[11]
6457 new_quads[0]->index(),
6459 hex->face(0)->index(),
6461 hex->face(1)->index(),
6463 hex->face(2)->child_index( child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
6464 hex->face(2)->child_index(1-child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
6466 hex->face(3)->child_index( child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
6467 hex->face(3)->child_index(1-child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
6469 hex->face(4)->child_index( child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
6470 hex->face(4)->child_index(1-child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
6472 hex->face(5)->child_index( child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]]),
6473 hex->face(5)->child_index(1-child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]])
6476 quad_indices = &quad_indices_x[0];
6497 const typename Triangulation<dim,spacedim>::raw_line_iterator
6499 const unsigned int *line_indices = NULL;
6500 const bool *line_orientation = NULL;
6501 const int *quad_indices = NULL;
6565 const typename Triangulation<dim,spacedim>::raw_line_iterator
6569 hex->face(0)->child(0)
6571 hex->face(1)->child(0)
6573 hex->face(4)->child(0)
6575 hex->face(5)->child(0)
6581 unsigned int line_indices_y[4];
6583 for (
unsigned int i=0; i<4; ++i)
6584 line_indices_y[i]=lines[i]->index();
6585 line_indices=&line_indices_y[0];
6592 bool line_orientation_y[4];
6598 const unsigned int middle_vertices[2]=
6600 hex->line(0)->child(0)->vertex_index(1),
6601 hex->line(5)->child(0)->vertex_index(1)
6604 for (
unsigned int i=0; i<4; ++i)
6605 if (lines[i]->vertex_index(i%2)==middle_vertices[i%2])
6606 line_orientation_y[i]=
true;
6610 Assert(lines[i]->vertex_index((i+1)%2)==middle_vertices[i%2],
6612 line_orientation_y[i]=
false;
6615 line_orientation=&line_orientation_y[0];
6625 new_quads[0]->set_line_orientation(0,line_orientation[2]);
6626 new_quads[0]->set_line_orientation(1,line_orientation[3]);
6627 new_quads[0]->set_line_orientation(2,line_orientation[0]);
6628 new_quads[0]->set_line_orientation(3,line_orientation[1]);
6661 const int quad_indices_y[11]
6664 new_quads[0]->index(),
6666 hex->face(0)->child_index( child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
6667 hex->face(0)->child_index(1-child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
6669 hex->face(1)->child_index( child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
6670 hex->face(1)->child_index(1-child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
6672 hex->face(2)->index(),
6674 hex->face(3)->index(),
6676 hex->face(4)->child_index( child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
6677 hex->face(4)->child_index(1-child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
6679 hex->face(5)->child_index( child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]]),
6680 hex->face(5)->child_index(1-child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]])
6683 quad_indices=&quad_indices_y[0];
6704 const typename Triangulation<dim,spacedim>::raw_line_iterator
6706 const unsigned int *line_indices = NULL;
6707 const bool *line_orientation = NULL;
6708 const int *quad_indices = NULL;
6774 const typename Triangulation<dim,spacedim>::raw_line_iterator
6778 hex->face(0)->child(0)
6780 hex->face(1)->child(0)
6782 hex->face(2)->child(0)
6784 hex->face(3)->child(0)
6790 unsigned int line_indices_z[4];
6792 for (
unsigned int i=0; i<4; ++i)
6793 line_indices_z[i]=lines[i]->index();
6794 line_indices=&line_indices_z[0];
6801 bool line_orientation_z[4];
6807 const unsigned int middle_vertices[2]=
6809 middle_vertex_index<dim,spacedim>(hex->line(8)),
6810 middle_vertex_index<dim,spacedim>(hex->line(11))
6813 for (
unsigned int i=0; i<4; ++i)
6814 if (lines[i]->vertex_index(i%2)==middle_vertices[i%2])
6815 line_orientation_z[i]=
true;
6819 Assert(lines[i]->vertex_index((i+1)%2)==middle_vertices[i%2],
6821 line_orientation_z[i]=
false;
6824 line_orientation=&line_orientation_z[0];
6834 new_quads[0]->set_line_orientation(0,line_orientation[0]);
6835 new_quads[0]->set_line_orientation(1,line_orientation[1]);
6836 new_quads[0]->set_line_orientation(2,line_orientation[2]);
6837 new_quads[0]->set_line_orientation(3,line_orientation[3]);
6871 const int quad_indices_z[11]
6874 new_quads[0]->index(),
6876 hex->face(0)->child_index( child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
6877 hex->face(0)->child_index(1-child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
6879 hex->face(1)->child_index( child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
6880 hex->face(1)->child_index(1-child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
6882 hex->face(2)->child_index( child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
6883 hex->face(2)->child_index(1-child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
6885 hex->face(3)->child_index( child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
6886 hex->face(3)->child_index(1-child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
6888 hex->face(4)->index(),
6890 hex->face(5)->index()
6892 quad_indices=&quad_indices_z[0];
6913 const typename Triangulation<dim,spacedim>::raw_line_iterator
6915 const unsigned int *line_indices = NULL;
6916 const bool *line_orientation = NULL;
6917 const int *quad_indices = NULL;
6940 TriaObject<1>(middle_vertex_index<dim,spacedim>(hex->face(4)),
6941 middle_vertex_index<dim,spacedim>(hex->face(5))));
7007 const typename Triangulation<dim,spacedim>::raw_line_iterator
7011 hex->face(0)->child(0)
7013 hex->face(1)->child(0)
7015 hex->face(2)->child(0)
7017 hex->face(3)->child(0)
7043 unsigned int line_indices_xy[13];
7045 for (
unsigned int i=0; i<13; ++i)
7046 line_indices_xy[i]=lines[i]->index();
7047 line_indices=&line_indices_xy[0];
7054 bool line_orientation_xy[13];
7058 const unsigned int middle_vertices[4]=
7060 hex->line(0)->child(0)->vertex_index(1),
7061 hex->line(1)->child(0)->vertex_index(1),
7062 hex->line(2)->child(0)->vertex_index(1),
7063 hex->line(3)->child(0)->vertex_index(1),
7069 for (
unsigned int i=0; i<4; ++i)
7070 if (lines[i]->vertex_index(0)==middle_vertices[i])
7071 line_orientation_xy[i]=
true;
7075 Assert(lines[i]->vertex_index(1)==middle_vertices[i],
7077 line_orientation_xy[i]=
false;
7086 for (
unsigned int i=4; i<12; ++i)
7087 if (lines[i]->vertex_index((i+1)%2) ==
7088 middle_vertex_index<dim,spacedim>(hex->face(3+i/4)))
7089 line_orientation_xy[i]=
true;
7094 Assert(lines[i]->vertex_index(i%2) ==
7095 (middle_vertex_index<dim,spacedim>(hex->face(3+i/4))),
7097 line_orientation_xy[i]=
false;
7103 line_orientation_xy[12]=
true;
7104 line_orientation=&line_orientation_xy[0];
7150 new_quads[0]->set_line_orientation(0,line_orientation[2]);
7151 new_quads[0]->set_line_orientation(2,line_orientation[4]);
7152 new_quads[0]->set_line_orientation(3,line_orientation[8]);
7154 new_quads[1]->set_line_orientation(1,line_orientation[3]);
7155 new_quads[1]->set_line_orientation(2,line_orientation[5]);
7156 new_quads[1]->set_line_orientation(3,line_orientation[9]);
7158 new_quads[2]->set_line_orientation(0,line_orientation[6]);
7159 new_quads[2]->set_line_orientation(1,line_orientation[10]);
7160 new_quads[2]->set_line_orientation(2,line_orientation[0]);
7162 new_quads[3]->set_line_orientation(0,line_orientation[7]);
7163 new_quads[3]->set_line_orientation(1,line_orientation[11]);
7164 new_quads[3]->set_line_orientation(3,line_orientation[1]);
7197 const int quad_indices_xy[20]
7200 new_quads[0]->index(),
7201 new_quads[1]->index(),
7202 new_quads[2]->index(),
7203 new_quads[3]->index(),
7205 hex->face(0)->child_index( child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
7206 hex->face(0)->child_index(1-child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
7208 hex->face(1)->child_index( child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
7209 hex->face(1)->child_index(1-child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
7211 hex->face(2)->child_index( child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
7212 hex->face(2)->child_index(1-child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
7214 hex->face(3)->child_index( child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
7215 hex->face(3)->child_index(1-child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
7227 quad_indices=&quad_indices_xy[0];
7262 const typename Triangulation<dim,spacedim>::raw_line_iterator
7264 const unsigned int *line_indices = NULL;
7265 const bool *line_orientation = NULL;
7266 const int *quad_indices = NULL;
7289 TriaObject<1>(middle_vertex_index<dim,spacedim>(hex->face(2)),
7290 middle_vertex_index<dim,spacedim>(hex->face(3))));
7356 const typename Triangulation<dim,spacedim>::raw_line_iterator
7360 hex->face(0)->child(0)
7362 hex->face(1)->child(0)
7364 hex->face(4)->child(0)
7366 hex->face(5)->child(0)
7392 unsigned int line_indices_xz[13];
7394 for (
unsigned int i=0; i<13; ++i)
7395 line_indices_xz[i]=lines[i]->index();
7396 line_indices=&line_indices_xz[0];
7403 bool line_orientation_xz[13];
7407 const unsigned int middle_vertices[4]=
7409 hex->line(8)->child(0)->vertex_index(1),
7410 hex->line(9)->child(0)->vertex_index(1),
7411 hex->line(2)->child(0)->vertex_index(1),
7412 hex->line(6)->child(0)->vertex_index(1),
7417 for (
unsigned int i=0; i<4; ++i)
7418 if (lines[i]->vertex_index(0)==middle_vertices[i])
7419 line_orientation_xz[i]=
true;
7423 Assert(lines[i]->vertex_index(1)==middle_vertices[i],
7425 line_orientation_xz[i]=
false;
7434 for (
unsigned int i=4; i<12; ++i)
7435 if (lines[i]->vertex_index((i+1)%2) ==
7436 middle_vertex_index<dim,spacedim>(hex->face(1+i/4)))
7437 line_orientation_xz[i]=
true;
7442 Assert(lines[i]->vertex_index(i%2) ==
7443 (middle_vertex_index<dim,spacedim>(hex->face(1+i/4))),
7445 line_orientation_xz[i]=
false;
7451 line_orientation_xz[12]=
true;
7452 line_orientation=&line_orientation_xz[0];
7499 new_quads[0]->set_line_orientation(0,line_orientation[0]);
7500 new_quads[0]->set_line_orientation(2,line_orientation[6]);
7501 new_quads[0]->set_line_orientation(3,line_orientation[10]);
7503 new_quads[1]->set_line_orientation(1,line_orientation[1]);
7504 new_quads[1]->set_line_orientation(2,line_orientation[7]);
7505 new_quads[1]->set_line_orientation(3,line_orientation[11]);
7507 new_quads[2]->set_line_orientation(0,line_orientation[4]);
7508 new_quads[2]->set_line_orientation(1,line_orientation[8]);
7509 new_quads[2]->set_line_orientation(2,line_orientation[2]);
7511 new_quads[3]->set_line_orientation(0,line_orientation[5]);
7512 new_quads[3]->set_line_orientation(1,line_orientation[9]);
7513 new_quads[3]->set_line_orientation(3,line_orientation[3]);
7547 const int quad_indices_xz[20]
7550 new_quads[0]->index(),
7551 new_quads[1]->index(),
7552 new_quads[2]->index(),
7553 new_quads[3]->index(),
7555 hex->face(0)->child_index( child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
7556 hex->face(0)->child_index(1-child_at_origin[hex->face(0)->refinement_case()-1][f_fl[0]][f_ro[0]]),
7558 hex->face(1)->child_index( child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
7559 hex->face(1)->child_index(1-child_at_origin[hex->face(1)->refinement_case()-1][f_fl[1]][f_ro[1]]),
7571 hex->face(4)->child_index( child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
7572 hex->face(4)->child_index(1-child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
7574 hex->face(5)->child_index( child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]]),
7575 hex->face(5)->child_index(1-child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]])
7577 quad_indices=&quad_indices_xz[0];
7621 const typename Triangulation<dim,spacedim>::raw_line_iterator
7623 const unsigned int *line_indices = NULL;
7624 const bool *line_orientation = NULL;
7625 const int *quad_indices = NULL;
7649 TriaObject<1>(middle_vertex_index<dim,spacedim>(hex->face(0)),
7650 middle_vertex_index<dim,spacedim>(hex->face(1))));
7717 const typename Triangulation<dim,spacedim>::raw_line_iterator
7721 hex->face(2)->child(0)
7723 hex->face(3)->child(0)
7725 hex->face(4)->child(0)
7727 hex->face(5)->child(0)
7753 unsigned int line_indices_yz[13];
7755 for (
unsigned int i=0; i<13; ++i)
7756 line_indices_yz[i]=lines[i]->index();
7757 line_indices=&line_indices_yz[0];
7764 bool line_orientation_yz[13];
7768 const unsigned int middle_vertices[4]=
7770 hex->line(8)->child(0)->vertex_index(1),
7771 hex->line(10)->child(0)->vertex_index(1),
7772 hex->line(0)->child(0)->vertex_index(1),
7773 hex->line(4)->child(0)->vertex_index(1),
7778 for (
unsigned int i=0; i<4; ++i)
7779 if (lines[i]->vertex_index(0)==middle_vertices[i])
7780 line_orientation_yz[i]=
true;
7784 Assert(lines[i]->vertex_index(1)==middle_vertices[i],
7786 line_orientation_yz[i]=
false;
7795 for (
unsigned int i=4; i<12; ++i)
7796 if (lines[i]->vertex_index((i+1)%2) ==
7797 middle_vertex_index<dim,spacedim>(hex->face(i/4-1)))
7798 line_orientation_yz[i]=
true;
7803 Assert(lines[i]->vertex_index(i%2) ==
7804 (middle_vertex_index<dim,spacedim>(hex->face(i/4-1))),
7806 line_orientation_yz[i]=
false;
7812 line_orientation_yz[12]=
true;
7813 line_orientation=&line_orientation_yz[0];
7854 new_quads[0]->set_line_orientation(0,line_orientation[6]);
7855 new_quads[0]->set_line_orientation(1,line_orientation[10]);
7856 new_quads[0]->set_line_orientation(2,line_orientation[0]);
7858 new_quads[1]->set_line_orientation(0,line_orientation[7]);
7859 new_quads[1]->set_line_orientation(1,line_orientation[11]);
7860 new_quads[1]->set_line_orientation(3,line_orientation[1]);
7862 new_quads[2]->set_line_orientation(0,line_orientation[2]);
7863 new_quads[2]->set_line_orientation(2,line_orientation[4]);
7864 new_quads[2]->set_line_orientation(3,line_orientation[8]);
7866 new_quads[3]->set_line_orientation(1,line_orientation[3]);
7867 new_quads[3]->set_line_orientation(2,line_orientation[5]);
7868 new_quads[3]->set_line_orientation(3,line_orientation[9]);
7902 const int quad_indices_yz[20]
7905 new_quads[0]->index(),
7906 new_quads[1]->index(),
7907 new_quads[2]->index(),
7908 new_quads[3]->index(),
7920 hex->face(2)->child_index( child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
7921 hex->face(2)->child_index(1-child_at_origin[hex->face(2)->refinement_case()-1][f_fl[2]][f_ro[2]]),
7923 hex->face(3)->child_index( child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
7924 hex->face(3)->child_index(1-child_at_origin[hex->face(3)->refinement_case()-1][f_fl[3]][f_ro[3]]),
7926 hex->face(4)->child_index( child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
7927 hex->face(4)->child_index(1-child_at_origin[hex->face(4)->refinement_case()-1][f_fl[4]][f_ro[4]]),
7929 hex->face(5)->child_index( child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]]),
7930 hex->face(5)->child_index(1-child_at_origin[hex->face(5)->refinement_case()-1][f_fl[5]][f_ro[5]])
7932 quad_indices=&quad_indices_yz[0];
7967 const typename Triangulation<dim,spacedim>::raw_line_iterator
7969 const unsigned int *vertex_indices = NULL;
7970 const unsigned int *line_indices = NULL;
7971 const bool *line_orientation = NULL;
7972 const int *quad_indices = NULL;
7997 while (triangulation.
vertices_used[next_unused_vertex] ==
true)
7998 ++next_unused_vertex;
8000 ExcMessage(
"Internal error: During refinement, the triangulation wants to access an element of the 'vertices' array but it turns out that the array is not large enough."));
8009 triangulation.
vertices[next_unused_vertex] =
8010 hex->center(
true,
true);
8031 const unsigned int vertex_indices_xyz[7]
8032 = { middle_vertex_index<dim,spacedim>(hex->face(0)),
8033 middle_vertex_index<dim,spacedim>(hex->face(1)),
8034 middle_vertex_index<dim,spacedim>(hex->face(2)),
8035 middle_vertex_index<dim,spacedim>(hex->face(3)),
8036 middle_vertex_index<dim,spacedim>(hex->face(4)),
8037 middle_vertex_index<dim,spacedim>(hex->face(5)),
8040 vertex_indices=&vertex_indices_xyz[0];
8120 const typename Triangulation<dim,spacedim>::raw_line_iterator
8186 lines=&lines_xyz[0];
8188 unsigned int line_indices_xyz[30];
8189 for (
unsigned int i=0; i<30; ++i)
8190 line_indices_xyz[i]=lines[i]->index();
8191 line_indices=&line_indices_xyz[0];
8198 bool line_orientation_xyz[30];
8206 for (
unsigned int i=0; i<24; ++i)
8207 if (lines[i]->vertex_index((i+1)%2)==vertex_indices[i/4])
8208 line_orientation_xyz[i]=
true;
8213 Assert(lines[i]->vertex_index(i%2)==vertex_indices[i/4],
8215 line_orientation_xyz[i]=
false;
8220 for (
unsigned int i=24; i<30; ++i)
8221 line_orientation_xyz[i]=
true;
8222 line_orientation=&line_orientation_xyz[0];
8318 new_quads[0]->set_line_orientation(0,line_orientation[10]);
8319 new_quads[0]->set_line_orientation(2,line_orientation[16]);
8321 new_quads[1]->set_line_orientation(1,line_orientation[14]);
8322 new_quads[1]->set_line_orientation(2,line_orientation[17]);
8324 new_quads[2]->set_line_orientation(0,line_orientation[11]);
8325 new_quads[2]->set_line_orientation(3,line_orientation[20]);
8327 new_quads[3]->set_line_orientation(1,line_orientation[15]);
8328 new_quads[3]->set_line_orientation(3,line_orientation[21]);
8330 new_quads[4]->set_line_orientation(0,line_orientation[18]);
8331 new_quads[4]->set_line_orientation(2,line_orientation[0]);
8333 new_quads[5]->set_line_orientation(1,line_orientation[22]);
8334 new_quads[5]->set_line_orientation(2,line_orientation[1]);
8336 new_quads[6]->set_line_orientation(0,line_orientation[19]);
8337 new_quads[6]->set_line_orientation(3,line_orientation[4]);
8339 new_quads[7]->set_line_orientation(1,line_orientation[23]);
8340 new_quads[7]->set_line_orientation(3,line_orientation[5]);
8342 new_quads[8]->set_line_orientation(0,line_orientation[2]);
8343 new_quads[8]->set_line_orientation(2,line_orientation[8]);
8345 new_quads[9]->set_line_orientation(1,line_orientation[6]);
8346 new_quads[9]->set_line_orientation(2,line_orientation[9]);
8348 new_quads[10]->set_line_orientation(0,line_orientation[3]);
8349 new_quads[10]->set_line_orientation(3,line_orientation[12]);
8351 new_quads[11]->set_line_orientation(1,line_orientation[7]);
8352 new_quads[11]->set_line_orientation(3,line_orientation[13]);
8393 const int quad_indices_xyz[36]
8396 new_quads[0]->index(),
8397 new_quads[1]->index(),
8398 new_quads[2]->index(),
8399 new_quads[3]->index(),
8400 new_quads[4]->index(),
8401 new_quads[5]->index(),
8402 new_quads[6]->index(),
8403 new_quads[7]->index(),
8404 new_quads[8]->index(),
8405 new_quads[9]->index(),
8406 new_quads[10]->index(),
8407 new_quads[11]->index(),
8439 quad_indices=&quad_indices_xyz[0];
8532 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
8533 for (
unsigned int s=0;
8538 const unsigned int current_child
8550 new_hexes[current_child]->set_face_orientation (f, f_or[f]);
8551 new_hexes[current_child]->set_face_flip (f, f_fl[f]);
8552 new_hexes[current_child]->set_face_rotation (f, f_ro[f]);
8557 if ((check_for_distorted_cells ==
true)
8559 has_distorted_children (hex,
8568 triangulation.
signals.post_refinement_on_cell(hex);
8577 triangulation.
faces->quads.clear_user_data();
8580 return cells_with_distorted_children;
8596 template <
int spacedim>
8602 template <
int dim,
int spacedim>
8609 if (spacedim>dim)
return;
8612 cell=triangulation.
begin(); cell!=triangulation.
end(); ++cell)
8613 if (cell->at_boundary() &&
8614 cell->refine_flag_set() &&
8621 for (
unsigned int face_no=0;
8622 face_no<GeometryInfo<dim>::faces_per_cell;
8624 if (cell->face(face_no)->at_boundary())
8634 face = cell->face(face_no);
8638 = face->center(
true);
8643 transform_real_to_unit_cell(cell,
8654 const double dist = std::fabs(new_unit[face_no/2] - face_no%2);
8659 const double allowed=0.25;
8662 cell->flag_for_face_refinement(face_no);
8681 template <
int dim,
int spacedim>
8687 ExcMessage (
"Wrong function called -- there should " 8688 "be a specialization."));
8692 template <
int spacedim>
8697 const unsigned int dim = 3;
8709 bool mesh_changed =
false;
8713 mesh_changed =
false;
8724 cell=triangulation.
begin(); cell!=triangulation.
end(); ++cell)
8725 if (cell->refine_flag_set())
8727 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
8732 cell->line(line)->set_user_flag();
8734 else if (cell->has_children() && !cell->child(0)->coarsen_flag_set())
8736 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
8741 cell->line(line)->set_user_flag();
8743 else if (cell->has_children() && cell->child(0)->coarsen_flag_set())
8744 cell->set_user_flag();
8752 cell=triangulation.
last_active(); cell!=triangulation.
end(); --cell)
8753 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
8755 if (cell->line(line)->has_children())
8764 bool offending_line_found =
false;
8766 for (
unsigned int c=0; c<2; ++c)
8768 Assert (cell->line(line)->child(c)->has_children() ==
false,
8771 if (cell->line(line)->child(c)->user_flag_set () &&
8777 cell->clear_coarsen_flag ();
8784 cell->flag_for_line_refinement(line);
8786 cell->set_refine_flag();
8788 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
8792 cell->line(l)->set_user_flag();
8795 offending_line_found =
true;
8801 for (
unsigned int l=0;
8802 l<GeometryInfo<dim>::lines_per_cell; ++l)
8803 if (!cell->line(l)->has_children() &&
8807 cell->line(l)->set_user_flag();
8813 if (offending_line_found)
8815 mesh_changed =
true;
8833 cell=triangulation.
last(); cell!=triangulation.
end(); --cell)
8835 if (cell->user_flag_set())
8836 for (
unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
8837 if (cell->line(line)->has_children() &&
8838 (cell->line(line)->child(0)->user_flag_set() ||
8839 cell->line(line)->child(1)->user_flag_set()))
8841 for (
unsigned int c=0; c<cell->n_children(); ++c)
8842 cell->child(c)->clear_coarsen_flag ();
8843 cell->clear_user_flag();
8844 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++
l)
8849 cell->line(l)->set_user_flag();
8850 mesh_changed =
true;
8855 while (mesh_changed ==
true);
8866 template <
int dim,
int spacedim>
8877 for (
unsigned int n=0; n<GeometryInfo<dim>::faces_per_cell; ++n)
8886 const unsigned int n_subfaces
8889 if (n_subfaces == 0 || cell->at_boundary(n))
8891 for (
unsigned int c=0; c<n_subfaces; ++c)
8895 child_cell_on_face(ref_case,
8899 child_neighbor = child->neighbor(n);
8900 if (!child->neighbor_is_coarser(n))
8913 if ((child_neighbor->has_children() &&
8914 !child_neighbor->user_flag_set())||
8923 child_neighbor->refine_flag_set())
8934 template <
int dim,
int spacedim>
8940 template <
int dim,
int spacedim>
8946 template <
int dim,
int spacedim>
8949 const bool check_for_distorted_cells)
8951 smooth_grid(smooth_grid),
8952 anisotropic_refinement(false),
8953 check_for_distorted_cells(check_for_distorted_cells)
8958 .reset (
new std::map<unsigned int, types::boundary_id>());
8960 .reset (
new std::map<unsigned int, types::manifold_id>());
8971 template <
int dim,
int spacedim>
8980 anisotropic_refinement(false),
8981 check_for_distorted_cells(other.check_for_distorted_cells)
8984 "because copying Triangulation objects is not " 8985 "allowed. Use Triangulation::copy_from() instead."));
8990 #ifdef DEAL_II_WITH_CXX11 8992 template <
int dim,
int spacedim>
8997 smooth_grid(tria.smooth_grid),
8998 periodic_face_pairs_level_0(
std::move(tria.periodic_face_pairs_level_0)),
8999 periodic_face_map(
std::move(tria.periodic_face_map)),
9000 levels(
std::move(tria.levels)),
9001 faces(
std::move(tria.faces)),
9002 vertices(
std::move(tria.vertices)),
9003 vertices_used(
std::move(tria.vertices_used)),
9004 manifold(
std::move(tria.manifold)),
9005 anisotropic_refinement(tria.anisotropic_refinement),
9006 check_for_distorted_cells(tria.check_for_distorted_cells),
9007 number_cache(tria.number_cache),
9008 vertex_to_boundary_id_map_1d(
std::move(tria.vertex_to_boundary_id_map_1d)),
9009 vertex_to_manifold_id_map_1d(
std::move(tria.vertex_to_manifold_id_map_1d))
9011 for (
unsigned int i=0; i<tria.levels.size(); ++i)
9012 tria.levels[i] =
nullptr;
9018 template <
int dim,
int spacedim>
9024 smooth_grid = tria.smooth_grid;
9025 periodic_face_pairs_level_0 = std::move(tria.periodic_face_pairs_level_0);
9026 periodic_face_map = std::move(tria.periodic_face_map);
9027 levels = std::move(tria.levels);
9028 faces = std::move(tria.faces);
9029 vertices = std::move(tria.vertices);
9030 vertices_used = std::move(tria.vertices_used);
9031 manifold = std::move(tria.manifold);
9032 anisotropic_refinement = tria.anisotropic_refinement;
9033 number_cache = tria.number_cache;
9034 vertex_to_boundary_id_map_1d = std::move(tria.vertex_to_boundary_id_map_1d);
9035 vertex_to_manifold_id_map_1d = std::move(tria.vertex_to_manifold_id_map_1d);
9037 for (
unsigned int i=0; i<tria.levels.size(); ++i)
9038 tria.levels[i] =
nullptr;
9049 template <
int dim,
int spacedim>
9052 for (
unsigned int i=0; i<levels.size(); ++i)
9066 (vertex_to_boundary_id_map_1d == 0),
9073 (vertex_to_manifold_id_map_1d == 0),
9079 template <
int dim,
int spacedim>
9086 clear_despite_subscriptions();
9087 periodic_face_pairs_level_0.clear();
9088 periodic_face_map.clear();
9093 template <
int dim,
int spacedim>
9098 ExcTriangulationNotEmpty (vertices.size(), levels.size()));
9099 smooth_grid=mesh_smoothing;
9104 template <
int dim,
int spacedim>
9113 template <
int dim,
int spacedim>
9118 set_manifold(m_number, boundary_object);
9121 template <
int dim,
int spacedim>
9129 manifold[m_number] = &manifold_object;
9133 template <
int dim,
int spacedim>
9137 set_manifold(m_number);
9141 template <
int dim,
int spacedim>
9149 manifold.erase(m_number);
9152 template <
int dim,
int spacedim>
9157 ExcMessage(
"Error: set_all_manifold_ids() can not be called on an empty Triangulation."));
9160 cell=this->begin_active(), endc=this->end();
9162 for (; cell != endc; ++cell)
9163 cell->set_all_manifold_ids(m_number);
9167 template <
int dim,
int spacedim>
9172 ExcMessage(
"Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
9175 cell=this->begin_active(), endc=this->end();
9177 for (; cell != endc; ++cell)
9178 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
9179 if (cell->face(f)->at_boundary())
9180 cell->face(f)->set_all_manifold_ids(m_number);
9184 template <
int dim,
int spacedim>
9190 ExcMessage(
"Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
9192 bool boundary_found =
false;
9194 cell=this->begin_active(), endc=this->end();
9196 for (; cell != endc; ++cell)
9199 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
9200 if (cell->face(f)->at_boundary() && cell->face(f)->boundary_id()==b_id)
9202 boundary_found =
true;
9203 cell->face(f)->set_manifold_id(m_number);
9208 for (
unsigned int e=0; e<GeometryInfo<dim>::lines_per_cell; ++e)
9209 if (cell->line(e)->at_boundary() && cell->line(e)->boundary_id()==b_id)
9211 boundary_found =
true;
9212 cell->line(e)->set_manifold_id(m_number);
9216 (void)boundary_found;
9217 Assert(boundary_found, ExcBoundaryIdNotFound(b_id));
9221 template <
int dim,
int spacedim>
9228 ExcMessage(
"You tried to get a Boundary, but I only have a Manifold."));
9234 template <
int dim,
int spacedim>
9241 = manifold.find(m_number);
9243 if (it != manifold.end())
9246 return *(it->second);
9252 return straight_boundary;
9259 template <
int dim,
int spacedim>
9260 std::vector<types::boundary_id>
9267 std::vector<types::boundary_id> boundary_ids;
9268 for (std::map<unsigned int, types::boundary_id>::const_iterator
9269 p = vertex_to_boundary_id_map_1d->begin();
9270 p != vertex_to_boundary_id_map_1d->end();
9272 boundary_ids.push_back (p->second);
9274 return boundary_ids;
9278 std::set<types::boundary_id> b_ids;
9280 for (; cell!=end(); ++cell)
9281 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
9282 if (cell->at_boundary(face))
9283 b_ids.insert(cell->face(face)->boundary_id());
9284 std::vector<types::boundary_id> boundary_ids(b_ids.begin(), b_ids.end());
9285 return boundary_ids;
9291 template <
int dim,
int spacedim>
9292 std::vector<types::manifold_id>
9295 std::set<types::manifold_id> m_ids;
9297 for (; cell!=end(); ++cell)
9299 m_ids.insert(cell->manifold_id());
9301 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
9302 if (cell->at_boundary(face))
9303 m_ids.insert(cell->face(face)->manifold_id());
9305 std::vector<types::manifold_id> manifold_indicators(m_ids.begin(), m_ids.end());
9306 return manifold_indicators;
9312 template <
int dim,
int spacedim>
9317 Assert ((vertices.size() == 0) &&
9318 (levels.size () == 0) &&
9320 ExcTriangulationNotEmpty(vertices.size(), levels.size()));
9322 (other_tria.
vertices.size() != 0) &&
9323 (dim == 1 || other_tria.
faces != NULL),
9324 ExcMessage(
"When calling Triangulation::copy_triangulation(), " 9325 "the target triangulation must be empty but the source " 9326 "triangulation (the argument to this function) must contain " 9327 "something. Here, it seems like the source does not " 9328 "contain anything at all."));
9342 bdry_iterator = other_tria.
manifold.begin();
9343 for (; bdry_iterator != other_tria.
manifold.end() ; ++bdry_iterator)
9344 manifold[bdry_iterator->first] = bdry_iterator->second;
9347 levels.reserve (other_tria.
levels.size());
9348 for (
unsigned int level=0; level<other_tria.
levels.size(); ++level)
9349 levels.push_back (
new 9351 TriaLevel<dim>(*other_tria.
levels[level]));
9357 vertex_to_boundary_id_map_1d
9358 .reset(
new std::map<unsigned int, types::boundary_id>
9361 vertex_to_manifold_id_map_1d
9362 .reset(
new std::map<unsigned int, types::manifold_id>
9367 other_tria.
signals.copy (*
this);
9378 template <
int dim,
int spacedim>
9385 std::vector<CellData<dim> > reordered_cells (cells);
9389 reorder_compatibility (reordered_cells, reordered_subcelldata);
9393 create_triangulation(v, reordered_cells, reordered_subcelldata);
9398 template <
int dim,
int spacedim>
9405 Assert ((vertices.size() == 0) &&
9406 (levels.size () == 0) &&
9408 ExcTriangulationNotEmpty(vertices.size(), levels.size()));
9422 clear_despite_subscriptions();
9430 reset_active_cell_indices ();
9435 if (check_for_distorted_cells ==
true)
9437 DistortedCellList distorted_cells = collect_distorted_coarse_cells (*
this);
9441 AssertThrow (distorted_cells.distorted_cells.size() == 0,
9482 bool values [][2] = {{
false,
true},
9485 for (
unsigned int i=0; i< GeometryInfo< dim >::faces_per_cell; ++i)
9486 for (
unsigned int j=0; j< GeometryInfo< dim >::faces_per_cell; ++j)
9487 correct(i,j) = ( values[i][j]);
9492 bool values [][4]= {{
false,true ,true ,
false},
9493 {true ,
false,
false,
true },
9494 {true ,
false,
false,
true },
9495 {
false,true ,true ,
false}
9497 for (
unsigned int i=0; i< GeometryInfo< dim >::faces_per_cell; ++i)
9498 for (
unsigned int j=0; j< GeometryInfo< dim >::faces_per_cell; ++j)
9499 correct(i,j) = ( values[i][j]);
9507 std::list<active_cell_iterator> this_round, next_round;
9510 this_round.push_back (begin_active());
9511 begin_active()->set_direction_flag (
true);
9512 begin_active()->set_user_flag ();
9514 while (this_round.size() > 0)
9516 for (
typename std::list<active_cell_iterator>::iterator cell = this_round.begin();
9517 cell != this_round.end(); ++cell)
9519 for (
unsigned int i = 0; i < GeometryInfo< dim >::faces_per_cell; ++i)
9521 if ( !((*cell)->face(i)->at_boundary()) )
9523 neighbor = (*cell)->neighbor(i);
9525 unsigned int cf = (*cell)->face_index(i);
9527 while (neighbor->face_index(j) != cf)
9532 if ( (correct(i,j) && !(*cell)->direction_flag())
9534 (!correct(i,j) && (*cell)->direction_flag()) )
9536 if (neighbor->user_flag_set() ==
false)
9538 neighbor->set_direction_flag (
false);
9539 neighbor->set_user_flag ();
9540 next_round.push_back (neighbor);
9543 Assert (neighbor->direction_flag() ==
false,
9544 ExcNonOrientableTriangulation());
9555 if (next_round.size() == 0)
9557 cell != end(); ++cell)
9558 if (cell->user_flag_set() ==
false)
9560 next_round.push_back (cell);
9561 cell->set_direction_flag (
true);
9562 cell->set_user_flag ();
9566 this_round = next_round;
9578 template <
int dim,
int spacedim>
9585 cell != end(); ++cell)
9586 cell->set_direction_flag (!cell->direction_flag());
9591 template <
int dim,
int spacedim>
9594 Assert(n_cells()>0,
ExcMessage(
"Error: An empty Triangulation can not be refined."));
9598 for (; cell != endc; ++cell)
9600 cell->clear_coarsen_flag();
9601 cell->set_refine_flag ();
9607 template <
int dim,
int spacedim>
9610 for (
unsigned int i=0; i<times; ++i)
9612 set_all_refine_flags();
9613 execute_coarsening_and_refinement ();
9623 template <
int dim,
int spacedim>
9626 v.resize (dim*n_active_cells(),
false);
9627 std::vector<bool>::iterator i = v.begin();
9630 for (; cell!=endc; ++cell)
9631 for (
unsigned int j=0; j<dim; ++j,++i)
9632 if (cell->refine_flag_set() & (1<<j) )
9640 template <
int dim,
int spacedim>
9643 std::vector<bool> v;
9644 save_refine_flags (v);
9645 write_bool_vector (mn_tria_refine_flags_begin, v, mn_tria_refine_flags_end,
9651 template <
int dim,
int spacedim>
9654 std::vector<bool> v;
9655 read_bool_vector (mn_tria_refine_flags_begin, v, mn_tria_refine_flags_end,
9657 load_refine_flags (v);
9662 template <
int dim,
int spacedim>
9665 AssertThrow (v.size() == dim*n_active_cells(), ExcGridReadError());
9669 std::vector<bool>::const_iterator i = v.begin();
9670 for (; cell!=endc; ++cell)
9672 unsigned int ref_case=0;
9674 for (
unsigned int j=0; j<dim; ++j, ++i)
9678 ExcGridReadError());
9682 cell->clear_refine_flag();
9690 template <
int dim,
int spacedim>
9693 v.resize (n_active_cells(),
false);
9694 std::vector<bool>::iterator i = v.begin();
9697 for (; cell!=endc; ++cell, ++i)
9698 *i = cell->coarsen_flag_set();
9705 template <
int dim,
int spacedim>
9708 std::vector<bool> v;
9709 save_coarsen_flags (v);
9710 write_bool_vector (mn_tria_coarsen_flags_begin, v, mn_tria_coarsen_flags_end,
9716 template <
int dim,
int spacedim>
9719 std::vector<bool> v;
9720 read_bool_vector (mn_tria_coarsen_flags_begin, v, mn_tria_coarsen_flags_end,
9722 load_coarsen_flags (v);
9727 template <
int dim,
int spacedim>
9730 Assert (v.size() == n_active_cells(), ExcGridReadError());
9734 std::vector<bool>::const_iterator i = v.begin();
9735 for (; cell!=endc; ++cell, ++i)
9737 cell->set_coarsen_flag();
9739 cell->clear_coarsen_flag();
9745 template <
int dim,
int spacedim>
9748 return anisotropic_refinement;
9762 for (
unsigned int level=0; level<levels.size(); ++level)
9763 levels[level]->cells.clear_user_data();
9776 faces->
lines.clear_user_data();
9782 faces->
lines.clear_user_data();
9788 template <
int dim,
int spacedim>
9792 ::clear_user_data (levels);
9793 ::clear_user_data (faces.get());
9803 for (
unsigned int level=0; level<levels.size(); ++level)
9804 levels[level]->cells.clear_user_flags();
9811 faces->lines.clear_user_flags();
9816 template <
int dim,
int spacedim>
9819 ::clear_user_flags_line (levels, faces.get());
9835 for (
unsigned int level=0; level<levels.size(); ++level)
9836 levels[level]->cells.clear_user_flags();
9843 faces->quads.clear_user_flags();
9848 template <
int dim,
int spacedim>
9851 ::clear_user_flags_quad (levels, faces.get());
9874 for (
unsigned int level=0; level<levels.size(); ++level)
9875 levels[level]->cells.clear_user_flags();
9880 template <
int dim,
int spacedim>
9883 ::clear_user_flags_hex (levels, faces.get());
9888 template <
int dim,
int spacedim>
9891 clear_user_flags_line ();
9892 clear_user_flags_quad ();
9893 clear_user_flags_hex ();
9898 template <
int dim,
int spacedim>
9901 save_user_flags_line (out);
9904 save_user_flags_quad (out);
9907 save_user_flags_hex (out);
9915 template <
int dim,
int spacedim>
9922 std::vector<bool> tmp;
9924 save_user_flags_line (tmp);
9925 v.insert (v.end(), tmp.begin(), tmp.end());
9929 save_user_flags_quad (tmp);
9930 v.insert (v.end(), tmp.begin(), tmp.end());
9935 save_user_flags_hex (tmp);
9936 v.insert (v.end(), tmp.begin(), tmp.end());
9945 template <
int dim,
int spacedim>
9948 load_user_flags_line (in);
9951 load_user_flags_quad (in);
9954 load_user_flags_hex (in);
9962 template <
int dim,
int spacedim>
9966 std::vector<bool> tmp;
9970 tmp.insert (tmp.end(),
9971 v.begin(), v.begin()+n_lines());
9973 load_user_flags_line (tmp);
9978 tmp.insert (tmp.end(),
9979 v.begin()+n_lines(), v.begin()+n_lines()+n_quads());
9980 load_user_flags_quad (tmp);
9986 tmp.insert (tmp.end(),
9987 v.begin()+n_lines()+n_quads(), v.begin()+n_lines()+n_quads()+n_hexs());
9988 load_user_flags_hex (tmp);
9997 template <
int dim,
int spacedim>
10000 v.resize (n_lines(),
false);
10001 std::vector<bool>::iterator i = v.begin();
10002 line_iterator line = begin_line(),
10004 for (; line!=endl; ++line, ++i)
10005 *i = line->user_flag_set();
10012 template <
int dim,
int spacedim>
10015 std::vector<bool> v;
10016 save_user_flags_line (v);
10017 write_bool_vector (mn_tria_line_user_flags_begin, v, mn_tria_line_user_flags_end,
10023 template <
int dim,
int spacedim>
10026 std::vector<bool> v;
10027 read_bool_vector (mn_tria_line_user_flags_begin, v, mn_tria_line_user_flags_end,
10029 load_user_flags_line (v);
10034 template <
int dim,
int spacedim>
10037 Assert (v.size() == n_lines(), ExcGridReadError());
10039 line_iterator line = begin_line(),
10041 std::vector<bool>::const_iterator i = v.begin();
10042 for (; line!=endl; ++line, ++i)
10044 line->set_user_flag();
10046 line->clear_user_flag();
10054 template <
typename Iterator>
10055 bool get_user_flag (
const Iterator &i)
10057 return i->user_flag_set();
10062 template <
int structdim,
int dim,
int spacedim>
10071 template <
typename Iterator>
10072 void set_user_flag (
const Iterator &i)
10074 i->set_user_flag();
10079 template <
int structdim,
int dim,
int spacedim>
10087 template <
typename Iterator>
10088 void clear_user_flag (
const Iterator &i)
10090 i->clear_user_flag();
10095 template <
int structdim,
int dim,
int spacedim>
10103 template <
int dim,
int spacedim>
10106 v.resize (n_quads(),
false);
10110 std::vector<bool>::iterator i = v.begin();
10111 quad_iterator quad = begin_quad(),
10113 for (; quad!=endq; ++quad, ++i)
10114 *i = get_user_flag (quad);
10122 template <
int dim,
int spacedim>
10125 std::vector<bool> v;
10126 save_user_flags_quad (v);
10127 write_bool_vector (mn_tria_quad_user_flags_begin, v, mn_tria_quad_user_flags_end,
10133 template <
int dim,
int spacedim>
10136 std::vector<bool> v;
10137 read_bool_vector (mn_tria_quad_user_flags_begin, v, mn_tria_quad_user_flags_end,
10139 load_user_flags_quad (v);
10144 template <
int dim,
int spacedim>
10147 Assert (v.size() == n_quads(), ExcGridReadError());
10151 quad_iterator quad = begin_quad(),
10153 std::vector<bool>::const_iterator i = v.begin();
10154 for (; quad!=endq; ++quad, ++i)
10156 set_user_flag(quad);
10158 clear_user_flag(quad);
10166 template <
int dim,
int spacedim>
10169 v.resize (n_hexs(),
false);
10173 std::vector<bool>::iterator i = v.begin();
10174 hex_iterator hex = begin_hex(),
10176 for (; hex!=endh; ++hex, ++i)
10177 *i = get_user_flag (hex);
10185 template <
int dim,
int spacedim>
10188 std::vector<bool> v;
10189 save_user_flags_hex (v);
10190 write_bool_vector (mn_tria_hex_user_flags_begin, v, mn_tria_hex_user_flags_end,
10196 template <
int dim,
int spacedim>
10199 std::vector<bool> v;
10200 read_bool_vector (mn_tria_hex_user_flags_begin, v, mn_tria_hex_user_flags_end,
10202 load_user_flags_hex (v);
10207 template <
int dim,
int spacedim>
10210 Assert (v.size() == n_hexs(), ExcGridReadError());
10214 hex_iterator hex = begin_hex(),
10216 std::vector<bool>::const_iterator i = v.begin();
10217 for (; hex!=endh; ++hex, ++i)
10219 set_user_flag(hex);
10221 clear_user_flag(hex);
10229 template <
int dim,
int spacedim>
10236 std::vector<unsigned int> tmp;
10238 save_user_indices_line (tmp);
10239 v.insert (v.end(), tmp.begin(), tmp.end());
10243 save_user_indices_quad (tmp);
10244 v.insert (v.end(), tmp.begin(), tmp.end());
10249 save_user_indices_hex (tmp);
10250 v.insert (v.end(), tmp.begin(), tmp.end());
10259 template <
int dim,
int spacedim>
10263 std::vector<unsigned int> tmp;
10267 tmp.insert (tmp.end(),
10268 v.begin(), v.begin()+n_lines());
10270 load_user_indices_line (tmp);
10275 tmp.insert (tmp.end(),
10276 v.begin()+n_lines(), v.begin()+n_lines()+n_quads());
10277 load_user_indices_quad (tmp);
10283 tmp.insert (tmp.end(),
10284 v.begin()+n_lines()+n_quads(), v.begin()+n_lines()+n_quads()+n_hexs());
10285 load_user_indices_hex (tmp);
10296 template <
typename Iterator>
10297 unsigned int get_user_index (
const Iterator &i)
10299 return i->user_index();
10304 template <
int structdim,
int dim,
int spacedim>
10313 template <
typename Iterator>
10314 void set_user_index (
const Iterator &i,
10315 const unsigned int x)
10317 i->set_user_index(x);
10322 template <
int structdim,
int dim,
int spacedim>
10324 const unsigned int)
10331 template <
int dim,
int spacedim>
10334 v.resize (n_lines(), 0);
10335 std::vector<unsigned int>::iterator i = v.begin();
10336 line_iterator line = begin_line(),
10338 for (; line!=endl; ++line, ++i)
10339 *i = line->user_index();
10344 template <
int dim,
int spacedim>
10347 Assert (v.size() == n_lines(), ExcGridReadError());
10349 line_iterator line = begin_line(),
10351 std::vector<unsigned int>::const_iterator i = v.begin();
10352 for (; line!=endl; ++line, ++i)
10353 line->set_user_index(*i);
10357 template <
int dim,
int spacedim>
10360 v.resize (n_quads(), 0);
10364 std::vector<unsigned int>::iterator i = v.begin();
10365 quad_iterator quad = begin_quad(),
10367 for (; quad!=endq; ++quad, ++i)
10368 *i = get_user_index(quad);
10374 template <
int dim,
int spacedim>
10377 Assert (v.size() == n_quads(), ExcGridReadError());
10381 quad_iterator quad = begin_quad(),
10383 std::vector<unsigned int>::const_iterator i = v.begin();
10384 for (; quad!=endq; ++quad, ++i)
10385 set_user_index(quad, *i);
10390 template <
int dim,
int spacedim>
10393 v.resize (n_hexs(), 0);
10397 std::vector<unsigned int>::iterator i = v.begin();
10398 hex_iterator hex = begin_hex(),
10400 for (; hex!=endh; ++hex, ++i)
10401 *i = get_user_index(hex);
10407 template <
int dim,
int spacedim>
10410 Assert (v.size() == n_hexs(), ExcGridReadError());
10414 hex_iterator hex = begin_hex(),
10416 std::vector<unsigned int>::const_iterator i = v.begin();
10417 for (; hex!=endh; ++hex, ++i)
10418 set_user_index(hex, *i);
10429 template <
typename Iterator>
10430 void *get_user_pointer (
const Iterator &i)
10432 return i->user_pointer();
10437 template <
int structdim,
int dim,
int spacedim>
10446 template <
typename Iterator>
10447 void set_user_pointer (
const Iterator &i,
10450 i->set_user_pointer(x);
10455 template <
int structdim,
int dim,
int spacedim>
10464 template <
int dim,
int spacedim>
10471 std::vector<void *> tmp;
10473 save_user_pointers_line (tmp);
10474 v.insert (v.end(), tmp.begin(), tmp.end());
10478 save_user_pointers_quad (tmp);
10479 v.insert (v.end(), tmp.begin(), tmp.end());
10484 save_user_pointers_hex (tmp);
10485 v.insert (v.end(), tmp.begin(), tmp.end());
10494 template <
int dim,
int spacedim>
10498 std::vector<void *> tmp;
10502 tmp.insert (tmp.end(),
10503 v.begin(), v.begin()+n_lines());
10505 load_user_pointers_line (tmp);
10510 tmp.insert (tmp.end(),
10511 v.begin()+n_lines(), v.begin()+n_lines()+n_quads());
10512 load_user_pointers_quad (tmp);
10518 tmp.insert (tmp.end(),
10519 v.begin()+n_lines()+n_quads(), v.begin()+n_lines()+n_quads()+n_hexs());
10520 load_user_pointers_hex (tmp);
10529 template <
int dim,
int spacedim>
10532 v.resize (n_lines(), 0);
10533 std::vector<void *>::iterator i = v.begin();
10534 line_iterator line = begin_line(),
10536 for (; line!=endl; ++line, ++i)
10537 *i = line->user_pointer();
10542 template <
int dim,
int spacedim>
10545 Assert (v.size() == n_lines(), ExcGridReadError());
10547 line_iterator line = begin_line(),
10549 std::vector<void *>::const_iterator i = v.begin();
10550 for (; line!=endl; ++line, ++i)
10551 line->set_user_pointer(*i);
10556 template <
int dim,
int spacedim>
10559 v.resize (n_quads(), 0);
10563 std::vector<void *>::iterator i = v.begin();
10564 quad_iterator quad = begin_quad(),
10566 for (; quad!=endq; ++quad, ++i)
10567 *i = get_user_pointer(quad);
10573 template <
int dim,
int spacedim>
10576 Assert (v.size() == n_quads(), ExcGridReadError());
10580 quad_iterator quad = begin_quad(),
10582 std::vector<void *>::const_iterator i = v.begin();
10583 for (; quad!=endq; ++quad, ++i)
10584 set_user_pointer(quad, *i);
10589 template <
int dim,
int spacedim>
10592 v.resize (n_hexs(), 0);
10596 std::vector<void *>::iterator i = v.begin();
10597 hex_iterator hex = begin_hex(),
10599 for (; hex!=endh; ++hex, ++i)
10600 *i = get_user_pointer(hex);
10606 template <
int dim,
int spacedim>
10609 Assert (v.size() == n_hexs(), ExcGridReadError());
10613 hex_iterator hex = begin_hex(),
10615 std::vector<void *>::const_iterator i = v.begin();
10616 for (; hex!=endh; ++hex, ++i)
10617 set_user_pointer(hex, *i);
10626 template <
int dim,
int spacedim>
10633 return begin_raw_line (level);
10635 return begin_raw_quad (level);
10637 return begin_raw_hex (level);
10646 template <
int dim,
int spacedim>
10653 return begin_line (level);
10655 return begin_quad (level);
10657 return begin_hex (level);
10666 template <
int dim,
int spacedim>
10673 return begin_active_line (level);
10675 return begin_active_quad (level);
10677 return begin_active_hex (level);
10686 template <
int dim,
int spacedim>
10690 const unsigned int level = levels.size()-1;
10692 Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
10693 if (levels[level]->cells.cells.size() ==0)
10700 levels[level]->cells.cells.size()-1);
10703 if (ri->used()==
true)
10706 if (ri->used()==
true)
10713 template <
int dim,
int spacedim>
10723 if (cell->active()==
true)
10726 if (cell->active()==
true)
10734 template <
int dim,
int spacedim>
10745 template <
int dim,
int spacedim>
10749 Assert (level<n_global_levels(), ExcInvalidLevel(level));
10750 if (level < levels.size()-1)
10751 return begin_raw (level+1);
10757 template <
int dim,
int spacedim>
10761 if (level < levels.size()-1)
10762 return begin (level+1);
10763 Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
10768 template <
int dim,
int spacedim>
10772 Assert (level<n_global_levels() || level < levels.size(), ExcInvalidLevel(level));
10773 return (level >= levels.size()-1 ?
10775 begin_active (level+1));
10780 template <
int dim,
int spacedim>
10790 template <
int dim,
int spacedim>
10796 (begin_active(), end());
10801 template <
int dim,
int spacedim>
10807 (begin(level), end(level));
10812 template <
int dim,
int spacedim>
10818 (begin_active(level), end_active(level));
10825 template <
int dim,
int spacedim>
10835 return begin_line ();
10837 return begin_quad ();
10846 template <
int dim,
int spacedim>
10856 return begin_active_line ();
10858 return begin_active_quad ();
10867 template <
int dim,
int spacedim>
10877 return end_line ();
10879 return end_quad ();
10890 template <
int dim,
int spacedim>
10891 typename Triangulation<dim,spacedim>::vertex_iterator
10899 return raw_vertex_iterator();
10909 while (i->used() ==
false)
10918 template <
int dim,
int spacedim>
10919 typename Triangulation<dim,spacedim>::active_vertex_iterator
10922 return begin_vertex();
10927 template <
int dim,
int spacedim>
10928 typename Triangulation<dim,spacedim>::vertex_iterator
10934 return raw_vertex_iterator();
10949 template <
int dim,
int spacedim>
10950 typename Triangulation<dim, spacedim>::raw_line_iterator
10956 Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
10958 if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
10974 template <
int dim,
int spacedim>
10975 typename Triangulation<dim, spacedim>::line_iterator
10979 raw_line_iterator ri = begin_raw_line (level);
10982 while (ri->used() ==
false)
10990 template <
int dim,
int spacedim>
10991 typename Triangulation<dim, spacedim>::active_line_iterator
10995 line_iterator i = begin_line (level);
10998 while (i->has_children())
11006 template <
int dim,
int spacedim>
11007 typename Triangulation<dim, spacedim>::line_iterator
11020 template <
int dim,
int spacedim>
11021 typename Triangulation<dim,spacedim>::raw_quad_iterator
11028 return raw_hex_iterator();
11031 Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
11033 if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
11053 return raw_hex_iterator();
11059 template <
int dim,
int spacedim>
11060 typename Triangulation<dim,spacedim>::quad_iterator
11064 raw_quad_iterator ri = begin_raw_quad (level);
11067 while (ri->used() ==
false)
11075 template <
int dim,
int spacedim>
11076 typename Triangulation<dim,spacedim>::active_quad_iterator
11080 quad_iterator i = begin_quad (level);
11083 while (i->has_children())
11091 template <
int dim,
int spacedim>
11092 typename Triangulation<dim,spacedim>::quad_iterator
11104 template <
int dim,
int spacedim>
11105 typename Triangulation<dim,spacedim>::raw_hex_iterator
11113 return raw_hex_iterator();
11116 Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
11118 if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
11128 return raw_hex_iterator();
11134 template <
int dim,
int spacedim>
11135 typename Triangulation<dim,spacedim>::hex_iterator
11139 raw_hex_iterator ri = begin_raw_hex (level);
11142 while (ri->used() ==
false)
11150 template <
int dim,
int spacedim>
11151 typename Triangulation<dim, spacedim>::active_hex_iterator
11155 hex_iterator i = begin_hex (level);
11158 while (i->has_children())
11166 template <
int dim,
int spacedim>
11167 typename Triangulation<dim, spacedim>::hex_iterator
11236 template <
int dim,
int spacedim>
11239 return internal::Triangulation::n_cells (number_cache);
11243 template <
int dim,
int spacedim>
11246 return internal::Triangulation::n_active_cells (number_cache);
11249 template <
int dim,
int spacedim>
11252 return n_active_cells();
11257 template <
int dim,
int spacedim>
11275 template <
int dim,
int spacedim>
11281 return n_raw_lines();
11283 return n_raw_quads();
11291 template <
int dim,
int spacedim>
11299 return n_active_lines();
11301 return n_active_quads();
11309 template <
int dim,
int spacedim>
11315 return n_raw_lines(level);
11317 return n_raw_quads(level);
11319 return n_raw_hexs(level);
11328 template <
int dim,
int spacedim>
11334 return n_lines(level);
11336 return n_quads(level);
11338 return n_hexs(level);
11347 template <
int dim,
int spacedim>
11353 return n_active_lines(level);
11355 return n_active_quads(level);
11357 return n_active_hexs(level);
11365 template <
int dim,
int spacedim>
11368 for (
unsigned int lvl = 0; lvl<n_global_levels()-1; lvl++)
11369 if (n_active_cells(lvl) != 0)
11376 template <
int dim,
int spacedim>
11379 return number_cache.n_lines;
11388 return levels[level]->cells.cells.size();
11405 return levels[level]->cells.cells.size();
11421 return levels[level]->cells.cells.size();
11433 template <
int dim,
int spacedim>
11441 template <
int dim,
int spacedim>
11444 return faces->
lines.cells.size();
11448 template <
int dim,
int spacedim>
11451 Assert (level < number_cache.n_lines_level.size(),
11452 ExcIndexRange (level, 0, number_cache.n_lines_level.size()));
11454 return number_cache.n_lines_level[level];
11458 template <
int dim,
int spacedim>
11461 return number_cache.n_active_lines;
11465 template <
int dim,
int spacedim>
11468 Assert (level < number_cache.n_lines_level.size(),
11469 ExcIndexRange (level, 0, number_cache.n_lines_level.size()));
11472 return number_cache.n_active_lines_level[level];
11605 template <
int dim,
int spacedim>
11608 return number_cache.n_quads;
11612 template <
int dim,
int spacedim>
11616 Assert (level < number_cache.n_quads_level.size(),
11617 ExcIndexRange (level, 0, number_cache.n_quads_level.size()));
11618 return number_cache.n_quads_level[level];
11627 return levels[level]->cells.cells.size();
11636 return levels[level]->cells.cells.size();
11651 template <
int dim,
int spacedim>
11668 template <
int dim,
int spacedim>
11671 return number_cache.n_active_quads;
11675 template <
int dim,
int spacedim>
11678 Assert (level < number_cache.n_quads_level.size(),
11679 ExcIndexRange (level, 0, number_cache.n_quads_level.size()));
11682 return number_cache.n_active_quads_level[level];
11686 template <
int dim,
int spacedim>
11694 template <
int dim,
int spacedim>
11702 template <
int dim,
int spacedim>
11709 template <
int dim,
int spacedim>
11717 template <
int dim,
int spacedim>
11727 return number_cache.n_hexes;
11735 Assert (level < number_cache.n_hexes_level.size(),
11736 ExcIndexRange (level, 0, number_cache.n_hexes_level.size()));
11738 return number_cache.n_hexes_level[level];
11747 return levels[level]->cells.cells.size();
11754 return number_cache.n_active_hexes;
11762 Assert (level < number_cache.n_hexes_level.size(),
11763 ExcIndexRange (level, 0, number_cache.n_hexes_level.size()));
11765 return number_cache.n_active_hexes_level[level];
11770 template <
int dim,
int spacedim>
11774 return std::count_if (vertices_used.begin(), vertices_used.end(),
11775 std_cxx11::bind (std::equal_to<bool>(), std_cxx11::_1,
true));
11780 template <
int dim,
int spacedim>
11781 const std::vector<bool> &
11784 return vertices_used;
11812 template <
int dim,
int spacedim>
11819 unsigned int max_vertex_index = 0;
11820 for (; cell!=endc; ++cell)
11821 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
11822 if (cell->vertex_index(vertex) > max_vertex_index)
11823 max_vertex_index = cell->vertex_index(vertex);
11829 std::vector<unsigned short int> usage_count (max_vertex_index+1, 0);
11833 for (cell=begin(); cell!=endc; ++cell)
11834 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
11835 ++usage_count[cell->vertex_index(vertex)];
11838 static_cast<unsigned int>(*std::max_element (usage_count.begin(),
11839 usage_count.end())));
11844 template <
int dim,
int spacedim>
11853 template <
int dim,
int spacedim>
11862 template <
int dim,
int spacedim>
11871 template <
int dim,
int spacedim>
11875 periodicity_vector)
11877 periodic_face_pairs_level_0.insert(periodic_face_pairs_level_0.end(),
11878 periodicity_vector.begin(),
11879 periodicity_vector.end());
11882 update_periodic_face_map();
11887 template <
int dim,
int spacedim>
11888 const typename std::map<std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
unsigned int>,
11889 std::pair<std::pair<typename Triangulation<dim, spacedim>::cell_iterator,
unsigned int>, std::bitset<3> > > &
11892 return periodic_face_map;
11897 template <
int dim,
int spacedim>
11901 prepare_coarsening_and_refinement ();
11906 if (smooth_grid & limit_level_difference_at_vertices)
11907 Assert (satisfies_level1_at_vertex_rule (*
this) ==
true,
11911 signals.pre_refinement();
11913 execute_coarsening();
11915 const DistortedCellList
11916 cells_with_distorted_children = execute_refinement();
11921 if (smooth_grid & limit_level_difference_at_vertices)
11922 Assert (satisfies_level1_at_vertex_rule (*
this) ==
true,
11927 update_neighbors(*
this);
11928 reset_active_cell_indices ();
11931 signals.post_refinement();
11933 AssertThrow (cells_with_distorted_children.distorted_cells.size() == 0,
11934 cells_with_distorted_children);
11936 update_periodic_face_map();
11941 template <
int dim,
int spacedim>
11945 unsigned int active_cell_index = 0;
11947 if ((cell->used() ==
false) || cell->has_children())
11951 cell->set_active_cell_index (active_cell_index);
11952 ++active_cell_index;
11959 template <
int dim,
int spacedim>
11964 periodic_face_map.clear();
11966 typename std::vector<GridTools::PeriodicFacePair<cell_iterator> >::const_iterator it;
11967 for (it=periodic_face_pairs_level_0.begin(); it!=periodic_face_pairs_level_0.end(); ++it)
11969 update_periodic_face_map_recursively<dim, spacedim>
11970 (it->cell[0], it->cell[1], it->face_idx[0], it->face_idx[1],
11971 it->orientation, periodic_face_map);
11974 std::bitset<3> inverted_orientation;
11976 bool orientation, flip, rotation;
11977 orientation = it->orientation[0];
11978 rotation = it->orientation[2];
11979 flip = orientation ? rotation ^ it->orientation[1] : it->orientation[1];
11980 inverted_orientation[0] = orientation;
11981 inverted_orientation[1] = flip;
11982 inverted_orientation[2] = rotation;
11984 update_periodic_face_map_recursively<dim, spacedim>
11985 (it->cell[1], it->cell[0], it->face_idx[1], it->face_idx[0],
11986 inverted_orientation, periodic_face_map);
11990 typename std::map<std::pair<cell_iterator, unsigned int>,
11991 std::pair<std::pair<cell_iterator, unsigned int>, std::bitset<3> > >::const_iterator it_test;
11992 for (it_test=periodic_face_map.begin(); it_test!=periodic_face_map.end(); ++it_test)
11996 if (cell_1->level() == cell_2->level())
12000 Assert (periodic_face_map[it_test->second.first].first == it_test->first,
12008 template<
int dim,
int spacedim>
12015 for (
unsigned int i=0; i<levels.size(); ++i)
12022 vertices_used.clear ();
12030 template <
int dim,
int spacedim>
12034 const DistortedCellList
12035 cells_with_distorted_children
12047 for (
unsigned int level=0; level<levels.size(); ++level)
12048 levels[level]->cells.monitor_memory (dim);
12056 while (cell != endc)
12060 return cells_with_distorted_children;
12065 template <
int dim,
int spacedim>
12072 std::vector<unsigned int> line_cell_count = count_cells_bounded_by_line (*
this);
12073 std::vector<unsigned int> quad_cell_count = count_cells_bounded_by_quad (*
this);
12085 clear_user_flags ();
12089 for (; cell!=endc; ++cell)
12090 if (!cell->active())
12091 if (cell->child(0)->coarsen_flag_set())
12093 cell->set_user_flag();
12094 for (
unsigned int child=0; child<cell->n_children(); ++child)
12096 Assert (cell->child(child)->coarsen_flag_set(),
12098 cell->child(child)->clear_coarsen_flag();
12113 if (levels.size() >= 2)
12114 for (cell = last(); cell!=endc; --cell)
12115 if (cell->level()<=
static_cast<int>(levels.size()-2) && cell->user_flag_set())
12118 signals.pre_coarsening_on_cell(cell);
12130 for (cell=begin(); cell!=endc; ++cell)
12137 template <
int dim,
int spacedim>
12153 std::vector<bool> previous_coarsen_flags (n_active_cells());
12154 save_coarsen_flags (previous_coarsen_flags);
12156 std::vector<int> vertex_level (vertices.size(), 0);
12158 bool continue_iterating =
true;
12162 if (smooth_grid & limit_level_difference_at_vertices)
12164 Assert(!anisotropic_refinement,
12165 ExcMessage(
"In case of anisotropic refinement the " 12166 "limit_level_difference_at_vertices flag for " 12167 "mesh smoothing must not be set!"));
12171 std::fill (vertex_level.begin(), vertex_level.end(), 0);
12174 for (; cell!=endc; ++cell)
12176 if (cell->refine_flag_set())
12177 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
12179 vertex_level[cell->vertex_index(vertex)]
12180 = std::max (vertex_level[cell->vertex_index(vertex)],
12182 else if (!cell->coarsen_flag_set())
12183 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
12185 vertex_level[cell->vertex_index(vertex)]
12186 = std::max (vertex_level[cell->vertex_index(vertex)],
12197 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
12199 vertex_level[cell->vertex_index(vertex)]
12200 = std::max (vertex_level[cell->vertex_index(vertex)],
12215 for (cell=last_active(); cell != endc; --cell)
12216 if (cell->refine_flag_set() ==
false)
12218 for (
unsigned int vertex=0;
12219 vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
12220 if (vertex_level[cell->vertex_index(vertex)] >=
12224 cell->clear_coarsen_flag();
12229 if (vertex_level[cell->vertex_index(vertex)] >
12232 cell->set_refine_flag();
12234 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell;
12236 vertex_level[cell->vertex_index(v)]
12237 = std::max (vertex_level[cell->vertex_index(v)],
12260 clear_user_flags ();
12264 end_ac = end_active(0);
12265 for (; acell!=end_ac; ++acell)
12266 acell->clear_coarsen_flag();
12270 for (; cell!=endc; ++cell)
12273 if (cell->active())
12276 const unsigned int n_children=cell->n_children();
12277 unsigned int flagged_children=0;
12278 for (
unsigned int child=0; child<n_children; ++child)
12279 if (cell->child(child)->active() &&
12280 cell->child(child)->coarsen_flag_set())
12282 ++flagged_children;
12284 cell->child(child)->clear_coarsen_flag();
12289 if (flagged_children == n_children)
12290 cell->set_user_flag();
12296 for (cell=begin(); cell!=endc; ++cell)
12317 for (cell=last(); cell!=endc; --cell)
12318 if (cell->user_flag_set())
12321 if (internal::Triangulation::Implementation::template coarsening_allowed<dim,spacedim>(cell))
12322 for (
unsigned int c=0; c<cell->n_children(); ++c)
12324 Assert (cell->child(c)->refine_flag_set()==
false,
12327 cell->child(c)->set_coarsen_flag();
12332 clear_user_flags ();
12337 std::vector<bool> current_coarsen_flags (n_active_cells());
12338 save_coarsen_flags (current_coarsen_flags);
12340 continue_iterating = (current_coarsen_flags != previous_coarsen_flags);
12341 previous_coarsen_flags = current_coarsen_flags;
12343 while (continue_iterating ==
true);
12353 std::vector<bool> flags_before;
12354 save_coarsen_flags (flags_before);
12357 fix_coarsen_flags ();
12359 std::vector<bool> flags_after;
12360 save_coarsen_flags (flags_after);
12362 return (flags_before != flags_after);
12371 std::vector<bool> flags_before;
12372 save_coarsen_flags (flags_before);
12375 fix_coarsen_flags ();
12377 std::vector<bool> flags_after;
12378 save_coarsen_flags (flags_after);
12380 return (flags_before != flags_after);
12389 std::vector<bool> flags_before;
12390 save_coarsen_flags (flags_before);
12393 fix_coarsen_flags ();
12395 std::vector<bool> flags_after;
12396 save_coarsen_flags (flags_after);
12398 return (flags_before != flags_after);
12411 template <
int dim,
int spacedim>
12413 possibly_do_not_produce_unrefined_islands(
12418 unsigned int n_neighbors=0;
12421 unsigned int count=0;
12422 for (
unsigned int n=0; n<GeometryInfo<dim>::faces_per_cell; ++n)
12428 if (face_will_be_refined_by_neighbor(cell,n))
12435 if (count==n_neighbors ||
12436 (count>=n_neighbors-1 &&
12439 for (
unsigned int c=0; c<cell->n_children(); ++c)
12440 cell->child(c)->clear_coarsen_flag();
12442 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
12443 if (!cell->at_boundary(face)
12445 ( !cell->neighbor(face)->active() )
12446 && (cell_will_be_coarsened(cell->neighbor(face))) )
12447 possibly_do_not_produce_unrefined_islands<dim,spacedim>( cell->neighbor(face) );
12462 template <
int dim,
int spacedim>
12464 possibly_refine_unrefined_island
12466 const bool allow_anisotropic_smoothing)
12481 if (allow_anisotropic_smoothing ==
false)
12484 unsigned int refined_neighbors = 0,
12485 unrefined_neighbors = 0;
12486 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
12487 if (!cell->at_boundary(face))
12489 if (face_will_be_refined_by_neighbor(cell,face))
12490 ++refined_neighbors;
12492 ++unrefined_neighbors;
12495 if (unrefined_neighbors < refined_neighbors)
12497 cell->clear_coarsen_flag();
12498 cell->set_refine_flag ();
12503 if (unrefined_neighbors > 0)
12504 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
12505 if (!cell->at_boundary(face)
12507 (face_will_be_refined_by_neighbor(cell,face) ==
false)
12509 (cell->neighbor(face)->has_children() ==
false)
12511 (cell->neighbor(face)->refine_flag_set() ==
false))
12512 possibly_refine_unrefined_island<dim,spacedim>
12513 (cell->neighbor(face),
12514 allow_anisotropic_smoothing);
12526 for (
unsigned int face_pair=0;
12527 face_pair<GeometryInfo<dim>::faces_per_cell/2; ++face_pair)
12535 for (
unsigned int face_index=0; face_index<2; ++face_index)
12537 unsigned int face=2*face_pair+face_index;
12544 face_will_be_refined_by_neighbor<dim,spacedim>(cell,face,expected_face_ref_case);
12558 directional_cell_refinement_case
12559 = (directional_cell_refinement_case &
12561 expected_face_ref_case,
12563 cell->face_orientation(face),
12564 cell->face_flip(face),
12565 cell->face_rotation(face)));
12571 Assert(directional_cell_refinement_case <
12574 smoothing_cell_refinement_case = smoothing_cell_refinement_case |
12575 directional_cell_refinement_case;
12580 if (smoothing_cell_refinement_case)
12582 cell->clear_coarsen_flag();
12583 cell->set_refine_flag(cell->refine_flag_set() |
12584 smoothing_cell_refinement_case);
12591 template <
int dim,
int spacedim>
12596 std::vector<bool> flags_before[2];
12597 save_coarsen_flags (flags_before[0]);
12598 save_refine_flags (flags_before[1]);
12616 std::vector<bool> flags_before_loop[2] = {flags_before[0],
12695 if (((smooth_grid & coarsest_level_1) ||
12696 (smooth_grid & patch_level_1)) && n_levels()>=2)
12699 cell=begin_active(1),
12700 endc=end_active(1);
12702 for (; cell!=endc; ++cell)
12703 cell->clear_coarsen_flag();
12706 bool mesh_changed_in_this_loop =
false;
12715 if (smooth_grid & do_not_produce_unrefined_islands &&
12716 !(smooth_grid & patch_level_1))
12721 for (cell=begin(); cell!=endc; ++cell)
12725 if (!cell->active() && cell_will_be_coarsened(cell))
12726 possibly_do_not_produce_unrefined_islands<dim,spacedim>(cell);
12750 if (smooth_grid & (eliminate_refined_inner_islands |
12751 eliminate_refined_boundary_islands) &&
12752 !(smooth_grid & patch_level_1))
12757 for (cell=begin(); cell!=endc; ++cell)
12758 if (!cell->active() ||
12760 cell->refine_flag_set() &&
12761 cell->is_locally_owned()))
12768 bool all_children_active =
true;
12769 if (!cell->active())
12770 for (
unsigned int c=0; c<cell->n_children(); ++c)
12771 if (!cell->child(c)->active() ||
12772 cell->child(c)->is_ghost() ||
12773 cell->child(c)->is_artificial())
12775 all_children_active =
false;
12779 if (all_children_active)
12786 unsigned int unrefined_neighbors = 0,
12787 total_neighbors = 0;
12789 for (
unsigned int n=0; n<GeometryInfo<dim>::faces_per_cell; ++n)
12796 if (!face_will_be_refined_by_neighbor(cell,n))
12797 ++unrefined_neighbors;
12813 if ((unrefined_neighbors == total_neighbors)
12816 (smooth_grid & eliminate_refined_inner_islands)) ||
12818 (smooth_grid & eliminate_refined_boundary_islands)) )
12820 (total_neighbors != 0))
12822 if (!cell->active())
12823 for (
unsigned int c=0; c<cell->n_children(); ++c)
12825 cell->child(c)->clear_refine_flag ();
12826 cell->child(c)->set_coarsen_flag ();
12829 cell->clear_refine_flag();
12844 if (smooth_grid & limit_level_difference_at_vertices)
12846 Assert(!anisotropic_refinement,
12847 ExcMessage(
"In case of anisotropic refinement the " 12848 "limit_level_difference_at_vertices flag for " 12849 "mesh smoothing must not be set!"));
12853 std::vector<int> vertex_level (vertices.size(), 0);
12856 for (; cell!=endc; ++cell)
12858 if (cell->refine_flag_set())
12859 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
12861 vertex_level[cell->vertex_index(vertex)]
12862 = std::max (vertex_level[cell->vertex_index(vertex)],
12864 else if (!cell->coarsen_flag_set())
12865 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
12867 vertex_level[cell->vertex_index(vertex)]
12868 = std::max (vertex_level[cell->vertex_index(vertex)],
12877 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
12879 vertex_level[cell->vertex_index(vertex)]
12880 = std::max (vertex_level[cell->vertex_index(vertex)],
12895 for (cell=last_active(); cell != endc; --cell)
12896 if (cell->refine_flag_set() ==
false)
12898 for (
unsigned int vertex=0;
12899 vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
12900 if (vertex_level[cell->vertex_index(vertex)] >=
12904 cell->clear_coarsen_flag();
12909 if (vertex_level[cell->vertex_index(vertex)] >
12912 cell->set_refine_flag();
12914 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell;
12916 vertex_level[cell->vertex_index(v)]
12917 = std::max (vertex_level[cell->vertex_index(v)],
12939 if (smooth_grid & eliminate_unrefined_islands)
12944 for (; cell != endc; --cell)
12948 possibly_refine_unrefined_island<dim,spacedim>
12950 (smooth_grid & allow_anisotropic_smoothing) != 0);
12978 if (smooth_grid & patch_level_1)
12990 if (!cell->active())
12995 Assert (cell_is_patch_level_1(cell),
12997 if (cell->child(0)->has_children() ==
true)
13003 for (
unsigned int i=0; i<cell->n_children(); ++i)
13004 combined_ref_case = combined_ref_case |
13005 cell->child(i)->refine_flag_set();
13007 for (
unsigned int i=0; i<cell->n_children(); ++i)
13011 child->clear_coarsen_flag();
13012 child->set_refine_flag(combined_ref_case);
13033 cell->child(0)->active())
13040 const unsigned int n_children=cell->n_children();
13041 bool has_active_grandchildren =
false;
13043 for (
unsigned int i=0; i<n_children; ++i)
13044 if (cell->child(i)->child(0)->active())
13046 has_active_grandchildren =
true;
13050 if (has_active_grandchildren ==
false)
13056 unsigned int n_grandchildren=0;
13059 unsigned int n_coarsen_flags=0;
13064 for (
unsigned int c=0; c<n_children; ++c)
13071 const unsigned int nn_children=child->n_children();
13072 n_grandchildren += nn_children;
13077 if (child->child(0)->active())
13078 for (
unsigned int cc=0; cc<nn_children; ++cc)
13079 if (child->child(cc)->coarsen_flag_set())
13094 if ((n_coarsen_flags != n_grandchildren)
13096 (n_coarsen_flags > 0))
13097 for (
unsigned int c=0; c<n_children; ++c)
13100 if (child->child(0)->active())
13101 for (
unsigned int cc=0; cc<child->n_children(); ++cc)
13102 child->child(cc)->clear_coarsen_flag();
13129 bool changed =
true;
13136 for (; cell != endc; --cell)
13137 if (cell->refine_flag_set())
13140 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
13160 if (cell->neighbor(i)->active())
13162 if (cell->neighbor_is_coarser(i))
13164 if (cell->neighbor(i)->coarsen_flag_set())
13165 cell->neighbor(i)->clear_coarsen_flag();
13181 if (smooth_grid & allow_anisotropic_smoothing)
13182 changed=cell->neighbor(i)->flag_for_face_refinement(cell->neighbor_of_coarser_neighbor(i).first,
13186 if (!cell->neighbor(i)->refine_flag_set())
13188 cell->neighbor(i)->set_refine_flag();
13311 std::pair<unsigned int, unsigned int> nb_indices
13312 =cell->neighbor_of_coarser_neighbor(i);
13313 unsigned int refined_along_x=0,
13315 to_be_refined_along_x=0,
13316 to_be_refined_along_y=0;
13318 const int this_face_index=cell->face_index(i);
13321 if ((this_face_index
13322 == cell->neighbor(i)->face(nb_indices.first)->child_index(0)) ||
13324 == cell->neighbor(i)->face(nb_indices.first)->child_index(1)))
13332 RefinementCase<dim-1> frc=cell->neighbor(i)->face(nb_indices.first)->refinement_case();
13350 cell->face_orientation(i),
13351 cell->face_flip(i),
13352 cell->face_rotation(i));
13354 ++to_be_refined_along_x;
13356 ++to_be_refined_along_y;
13359 if ((smooth_grid & allow_anisotropic_smoothing) ||
13360 cell->neighbor(i)->refine_flag_set())
13362 if (refined_along_x + to_be_refined_along_x > 1)
13363 changed |= cell->neighbor(i)->flag_for_face_refinement(nb_indices.first,
13365 if (refined_along_y + to_be_refined_along_y > 1)
13366 changed |= cell->neighbor(i)->flag_for_face_refinement(nb_indices.first,
13373 cell->neighbor(i)->set_refine_flag();
13381 nb->face_orientation(nb_indices.first),
13382 nb->face_flip(nb_indices.first),
13383 nb->face_rotation(nb_indices.first));
13385 !(refined_along_x || to_be_refined_along_x))
13388 !(refined_along_y || to_be_refined_along_y))
13394 cell->neighbor(i)->clear_coarsen_flag();
13395 const unsigned int nb_nb=cell->neighbor_of_neighbor(i);
13400 neighbor->face_orientation(nb_nb),
13401 neighbor->face_flip(nb_nb),
13402 neighbor->face_rotation(nb_nb));
13406 cell->face_orientation(i),
13407 cell->face_flip(i),
13408 cell->face_rotation(i));
13416 changed=cell->flag_for_face_refinement(i, face_ref_case);
13417 neighbor->flag_for_face_refinement(nb_nb, needed_face_ref_case);
13423 RefinementCase<dim-1> face_ref_case = cell->face(i)->refinement_case(),
13426 cell->face_orientation(i),
13427 cell->face_flip(i),
13428 cell->face_rotation(i));
13434 changed=cell->flag_for_face_refinement(i, face_ref_case);
13453 fix_coarsen_flags ();
13456 std::vector<bool> flags_after_loop[2];
13457 save_coarsen_flags (flags_after_loop[0]);
13458 save_refine_flags (flags_after_loop[1]);
13462 mesh_changed_in_this_loop
13463 = ((flags_before_loop[0] != flags_after_loop[0]) ||
13464 (flags_before_loop[1] != flags_after_loop[1]));
13468 flags_before_loop[0].swap(flags_after_loop[0]);
13469 flags_before_loop[1].swap(flags_after_loop[1]);
13471 while (mesh_changed_in_this_loop);
13477 return ((flags_before[0] != flags_before_loop[0]) ||
13478 (flags_before[1] != flags_before_loop[1]));
13484 template <
int dim,
int spacedim>
13486 const std::vector<bool> &v,
13487 const unsigned int magic_number2,
13490 const unsigned int N = v.size();
13491 unsigned char *flags =
new unsigned char[N/8+1];
13492 for (
unsigned int i=0; i<N/8+1; ++i) flags[i]=0;
13494 for (
unsigned int position=0; position<N; ++position)
13495 flags[position/8] |= (v[position] ? (1<<(position%8)) : 0);
13504 out << magic_number1 <<
' ' << N << std::endl;
13505 for (
unsigned int i=0; i<N/8+1; ++i)
13506 out << static_cast<unsigned int>(flags[i]) <<
' ';
13508 out << std::endl << magic_number2 << std::endl;
13516 template <
int dim,
int spacedim>
13518 std::vector<bool> &v,
13519 const unsigned int magic_number2,
13524 unsigned int magic_number;
13525 in >> magic_number;
13526 AssertThrow (magic_number==magic_number1, ExcGridReadError());
13532 unsigned char *flags =
new unsigned char[N/8+1];
13533 unsigned short int tmp;
13534 for (
unsigned int i=0; i<N/8+1; ++i)
13540 for (
unsigned int position=0; position!=N; ++position)
13541 v[position] = (flags[position/8] & (1<<(position%8)));
13543 in >> magic_number;
13544 AssertThrow (magic_number==magic_number2, ExcGridReadError());
13553 template <
int dim,
int spacedim>
13557 std::size_t mem = 0;
13559 for (
unsigned int i=0; i<levels.size(); ++i)
13563 mem +=
sizeof(manifold);
13564 mem +=
sizeof(smooth_grid);
13566 mem +=
sizeof (faces);
13576 template<
int dim,
int spacedim>
13587 #include "tria.inst" 13589 DEAL_II_NAMESPACE_CLOSE
std::vector< CellData< 1 > > boundary_lines
std::vector<::internal::Triangulation::TriaLevel< dim > * > levels
static void compute_number_cache(const Triangulation< dim, spacedim > &triangulation, const unsigned int level_objects, internal::Triangulation::NumberCache< 1 > &number_cache)
boost::signals2::signal< void()> any_change
unsigned int n_active_cells() const
void set_boundary(const types::manifold_id number, const Boundary< dim, spacedim > &boundary_object)
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
unsigned int n_vertices() const
unsigned int n_used_vertices() const
const types::manifold_id flat_manifold_id
static const unsigned int invalid_unsigned_int
void load_user_flags_line(std::istream &in)
#define DeclException2(Exception2, type1, type2, outsequence)
hex_iterator begin_hex(const unsigned int level=0) const
static ::ExceptionBase & ExcInteriorLineCantBeBoundary(int arg1, int arg2, types::boundary_id arg3)
const types::subdomain_id invalid_subdomain_id
active_face_iterator begin_active_face() const
::internal::Triangulation::NumberCache< dim > number_cache
void save_user_flags_quad(std::ostream &out) const
virtual bool has_hanging_nodes() const
unsigned int n_raw_cells(const unsigned int level) const
cell_iterator last() const
void save_user_pointers_hex(std::vector< void *> &v) const
vertex_iterator begin_vertex() const
static RefinementCase< 1 > line_refinement_case(const RefinementCase< dim > &cell_refinement_case, const unsigned int line_no)
static ::ExceptionBase & ExcMultiplySetLineInfoOfLine(int arg1, int arg2)
unsigned int n_cells() const
std_cxx11::unique_ptr<::internal::Triangulation::TriaFaces< dim > > faces
static void create_triangulation(const std::vector< Point< spacedim > > &v, const std::vector< CellData< 2 > > &cells, const SubCellData &subcelldata, Triangulation< 2, spacedim > &triangulation)
int face(const unsigned int i) const
unsigned int n_raw_hexs() const
static ::ExceptionBase & ExcIO()
Subscriptor & operator=(const Subscriptor &)
static void delete_children(Triangulation< 1, spacedim > &triangulation, typename Triangulation< 1, spacedim >::cell_iterator &cell, std::vector< unsigned int > &, std::vector< unsigned int > &)
std::list< typename Triangulation< dim, spacedim >::cell_iterator > distorted_cells
std::vector< Point< spacedim > > vertices
boost::signals2::signal< void()> clear
static unsigned int line_to_cell_vertices(const unsigned int line, const unsigned int vertex)
static void compute_number_cache(const Triangulation< dim, spacedim > &triangulation, const unsigned int level_objects, internal::Triangulation::NumberCache< 3 > &number_cache)
IteratorRange< active_cell_iterator > active_cell_iterators() const
void set_all_refine_flags()
void load_user_flags(std::istream &in)
static void compute_number_cache(const Triangulation< dim, spacedim > &triangulation, const unsigned int level_objects, internal::Triangulation::NumberCache< 2 > &number_cache)
bool anisotropic_refinement
std::vector< unsigned int > n_active_lines_level
std::vector< unsigned int > n_hexes_level
static void read_bool_vector(const unsigned int magic_number1, std::vector< bool > &v, const unsigned int magic_number2, std::istream &in)
line_iterator begin_line(const unsigned int level=0) const
virtual ~DistortedCellList() DEAL_II_NOEXCEPT
line_iterator end_line() const
boost::signals2::signal< void()> mesh_movement
void clear_user_flags_quad()
unsigned int n_faces() const
std::vector< unsigned int > n_quads_level
static ::ExceptionBase & ExcLineInexistant(int arg1, int arg2)
void flip_all_direction_flags()
static RefinementCase< dim-1 > face_refinement_case(const RefinementCase< dim > &cell_refinement_case, const unsigned int face_no, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static Triangulation< 3, spacedim >::DistortedCellList execute_refinement(Triangulation< 3, spacedim > &triangulation, const bool check_for_distorted_cells)
active_cell_iterator begin_active(const unsigned int level=0) const
#define AssertThrow(cond, exc)
static Triangulation< 1, spacedim >::DistortedCellList execute_refinement(Triangulation< 1, spacedim > &triangulation, const bool)
static void create_children(Triangulation< 2, spacedim > &triangulation, unsigned int &next_unused_vertex, typename Triangulation< 2, spacedim >::raw_line_iterator &next_unused_line, typename Triangulation< 2, spacedim >::raw_cell_iterator &next_unused_cell, typename Triangulation< 2, spacedim >::cell_iterator &cell)
static void write_bool_vector(const unsigned int magic_number1, const std::vector< bool > &v, const unsigned int magic_number2, std::ostream &out)
unsigned int n_active_hexs() const
void save_user_pointers_quad(std::vector< void *> &v) const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcFacesHaveNoLevel()
std::vector< unsigned int > n_active_quads_level
void execute_coarsening()
const Boundary< dim, spacedim > & get_boundary(const types::manifold_id number) const
cell_iterator begin(const unsigned int level=0) const
void load_user_flags_quad(std::istream &in)
unsigned int n_levels() const
void set_manifold(const types::manifold_id number, const Manifold< dim, spacedim > &manifold_object)
raw_hex_iterator begin_raw_hex(const unsigned int level=0) const
std_cxx11::unique_ptr< std::map< unsigned int, types::boundary_id > > vertex_to_boundary_id_map_1d
void load_user_pointers_line(const std::vector< void *> &v)
unsigned int n_active_faces() const
raw_quad_iterator begin_raw_quad(const unsigned int level=0) const
cell_iterator end() const
static void create_triangulation(const std::vector< Point< spacedim > > &v, const std::vector< CellData< 3 > > &cells, const SubCellData &subcelldata, Triangulation< 3, spacedim > &triangulation)
void load_coarsen_flags(std::istream &out)
void load_user_flags_hex(std::istream &in)
active_quad_iterator begin_active_quad(const unsigned int level=0) const
virtual void execute_coarsening_and_refinement()
unsigned int n_active_lines() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
virtual bool prepare_coarsening_and_refinement()
static ::ExceptionBase & ExcMessage(std::string arg1)
bool check_consistency(const unsigned int dim) const
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
void reset_active_cell_indices()
static unsigned int n_children(const RefinementCase< dim > &refinement_case)
DistortedCellList execute_refinement()
const bool check_for_distorted_cells
void save_user_flags_line(std::ostream &out) const
void save_user_pointers_line(std::vector< void *> &v) const
static bool coarsening_allowed(const typename Triangulation< dim, spacedim >::cell_iterator &cell)
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcGridHasInvalidCell(int arg1)
Triangulation & operator=(Triangulation< dim, spacedim > &&tria)
void clear_user_flags_hex()
void load_user_indices_line(const std::vector< unsigned int > &v)
unsigned int global_dof_index
static unsigned int face_to_cell_lines(const unsigned int face, const unsigned int line, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
vertex_iterator end_vertex() const
unsigned int n_raw_quads() const
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim-1 > &face_refinement_case=RefinementCase< dim-1 >::isotropic_refinement)
#define Assert(cond, exc)
active_hex_iterator begin_active_hex(const unsigned int level=0) const
void save_user_indices_line(std::vector< unsigned int > &v) const
std::map< types::manifold_id, SmartPointer< const Manifold< dim, spacedim >, Triangulation< dim, spacedim > > > manifold
void set_all_manifold_ids(const types::manifold_id number)
static ::ExceptionBase & ExcCellHasNegativeMeasure(int arg1)
boost::signals2::signal< void()> create
unsigned int max_adjacent_cells() const
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2, int arg3)
bool get_anisotropic_refinement_flag() const
unsigned int n_quads() const
void clear_user_data(const unsigned int i)
std::vector< bool > vertices_used
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std_cxx11::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std_cxx11::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std_cxx11::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
virtual void create_triangulation(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
void save_coarsen_flags(std::ostream &out) const
void save_user_indices(std::vector< unsigned int > &v) const
TriaObjects< TriaObject< 1 > > lines
void load_user_indices(const std::vector< unsigned int > &v)
void save_refine_flags(std::ostream &out) const
unsigned int n_lines() const
void clear_despite_subscriptions()
raw_cell_iterator begin_raw(const unsigned int level=0) const
unsigned int n_raw_lines() const
virtual std::size_t memory_consumption() const
#define DeclException5(Exception5, type1, type2, type3, type4, type5, outsequence)
virtual void set_mesh_smoothing(const MeshSmoothing mesh_smoothing)
void load_user_pointers_hex(const std::vector< void *> &v)
void save_user_flags_hex(std::ostream &out) const
face_iterator begin_face() const
unsigned int subdomain_id
boost::signals2::signal< void()> post_refinement
virtual types::global_dof_index n_global_active_cells() const
unsigned int n_hexs() const
void set_face(const unsigned int i, const int index)
unsigned int n_active_quads() const
static ::ExceptionBase & ExcInteriorQuadCantBeBoundary(int arg1, int arg2, int arg3, int arg4, types::boundary_id arg5)
TriaObjects< TriaObject< 1 > > lines
active_line_iterator begin_active_line(const unsigned int level=0) const
raw_cell_iterator end_raw(const unsigned int level) const
unsigned int n_raw_faces() const
void load_user_indices_hex(const std::vector< unsigned int > &v)
active_vertex_iterator begin_active_vertex() const
static void alternating_form_at_vertices(const Point< spacedim >(&vertices)[vertices_per_cell], Tensor< spacedim-dim, spacedim >(&forms)[vertices_per_cell])
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::vector< types::boundary_id > get_boundary_ids() const
const types::manifold_id invalid_manifold_id
std::vector< unsigned int > n_active_hexes_level
void load_user_pointers_quad(const std::vector< void *> &v)
active_cell_iterator end_active(const unsigned int level) const
void update_periodic_face_map()
static void prevent_distorted_boundary_cells(const Triangulation< 1, spacedim > &)
void save_user_indices_quad(std::vector< unsigned int > &v) const
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
unsigned int n_active_quads
const std::vector< bool > & get_used_vertices() const
hex_iterator end_hex() const
std::vector< CellData< 2 > > boundary_quads
MeshSmoothing smooth_grid
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
IteratorRange< active_cell_iterator > active_cell_iterators_on_level(const unsigned int level) const
void load_user_pointers(const std::vector< void *> &v)
static ::ExceptionBase & ExcQuadInexistant(int arg1, int arg2, int arg3, int arg4)
void refine_global(const unsigned int times=1)
void save_user_pointers(std::vector< void *> &v) const
void save_user_flags(std::ostream &out) const
static ::ExceptionBase & ExcNotImplemented()
Iterator points to a valid object.
quad_iterator end_quad() const
std_cxx11::unique_ptr< std::map< unsigned int, types::manifold_id > > vertex_to_manifold_id_map_1d
IteratorRange< cell_iterator > cell_iterators() const
unsigned char boundary_id
#define DeclException3(Exception3, type1, type2, type3, outsequence)
face_iterator end_face() const
void set_all_manifold_ids_on_boundary(const types::manifold_id number)
active_cell_iterator last_active() const
const types::boundary_id internal_face_boundary_id
static ::ExceptionBase & ExcInternalErrorOnCell(int arg1)
void clear_user_flags_line()
IteratorState::IteratorStates state() const
static Triangulation< 2, spacedim >::DistortedCellList execute_refinement(Triangulation< 2, spacedim > &triangulation, const bool check_for_distorted_cells)
quad_iterator begin_quad(const unsigned int level=0) const
static void prepare_refinement_dim_dependent(const Triangulation< dim, spacedim > &)
std::vector< types::manifold_id > get_manifold_ids() const
bool vertex_used(const unsigned int index) const
unsigned int n_active_hexes
const Manifold< dim, spacedim > & get_manifold(const types::manifold_id number) const
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
static RefinementCase< dim > min_cell_refinement_case_for_face_refinement(const RefinementCase< dim-1 > &face_refinement_case, const unsigned int face_no, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
void load_user_indices_quad(const std::vector< unsigned int > &v)
virtual types::subdomain_id locally_owned_subdomain() const
unsigned int n_active_lines
raw_line_iterator begin_raw_line(const unsigned int level=0) const
virtual const MeshSmoothing & get_mesh_smoothing() const
Task< RT > new_task(const std_cxx11::function< RT()> &function)
const std::map< std::pair< cell_iterator, unsigned int >, std::pair< std::pair< cell_iterator, unsigned int >, std::bitset< 3 > > > & get_periodic_face_map() const
void load_refine_flags(std::istream &in)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
std::vector< unsigned int > n_lines_level
static ::ExceptionBase & ExcInternalError()
Triangulation< dim, spacedim > & get_triangulation()
static void create_triangulation(const std::vector< Point< spacedim > > &v, const std::vector< CellData< 1 > > &cells, const SubCellData &, Triangulation< 1, spacedim > &triangulation)
void save_user_indices_hex(std::vector< unsigned int > &v) const