17 #include <deal.II/base/utilities.h> 18 #include <deal.II/base/memory_consumption.h> 19 #include <deal.II/base/logstream.h> 20 #include <deal.II/lac/sparsity_tools.h> 21 #include <deal.II/lac/dynamic_sparsity_pattern.h> 22 #include <deal.II/grid/tria.h> 23 #include <deal.II/grid/tria_accessor.h> 24 #include <deal.II/grid/tria_iterator.h> 25 #include <deal.II/grid/grid_tools.h> 26 #include <deal.II/distributed/tria.h> 27 #include <deal.II/distributed/p4est_wrappers.h> 35 DEAL_II_NAMESPACE_OPEN
38 #ifdef DEAL_II_WITH_P4EST 42 template <
int dim,
int spacedim>
45 std::vector<unsigned int> &vertex_touch_count,
46 std::vector<std::list<
50 vertex_touch_count.resize (triangulation.
n_vertices());
51 vertex_to_cell.resize (triangulation.
n_vertices());
55 cell != triangulation.
end(); ++cell)
56 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
58 ++vertex_touch_count[cell->vertex_index(v)];
59 vertex_to_cell[cell->vertex_index(v)]
60 .push_back (std::make_pair (cell, v));
66 template <
int dim,
int spacedim>
69 std::vector<unsigned int> &edge_touch_count,
70 std::vector<std::list<
81 cell != triangulation.
end(); ++cell)
82 for (
unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++
l)
84 ++edge_touch_count[cell->line(l)->index()];
85 edge_to_cell[cell->line(l)->index()]
86 .push_back (std::make_pair (cell, l));
96 template <
int dim,
int spacedim>
99 const std::vector<unsigned int> &vertex_touch_count,
100 const std::vector<std::list<
103 const std::vector<types::global_dof_index> &coarse_cell_to_p4est_tree_permutation,
104 const bool set_vertex_info,
121 if (set_vertex_info ==
true)
122 for (
unsigned int v=0; v<triangulation.
n_vertices(); ++v)
124 connectivity->vertices[3*v ] = triangulation.
get_vertices()[v][0];
125 connectivity->vertices[3*v+1] = triangulation.
get_vertices()[v][1];
126 connectivity->vertices[3*v+2] = (spacedim == 2 ?
139 endc = triangulation.
end();
140 for (; cell != endc; ++cell)
143 index = coarse_cell_to_p4est_tree_permutation[cell->index()];
145 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
147 if (set_vertex_info ==
true)
154 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
155 if (cell->face(f)->at_boundary() ==
false)
157 = coarse_cell_to_p4est_tree_permutation[cell->neighbor(f)->index()];
160 = coarse_cell_to_p4est_tree_permutation[cell->index()];
164 for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
165 if (cell->face(f)->at_boundary() ==
false)
172 = cell->neighbor_of_neighbor (f);
191 connectivity->tree_to_face[index*6 + f]
192 = cell->neighbor_of_neighbor (f);
194 unsigned int face_idx_list[2] =
195 {f, cell->neighbor_of_neighbor (f)};
197 cell_list[2] = {cell, cell->neighbor(f)};
198 unsigned int smaller_idx = 0;
200 if (f>cell->neighbor_of_neighbor (f))
203 unsigned int larger_idx = (smaller_idx+1) % 2;
212 cell_list[smaller_idx]->vertex_index(
214 face_idx_list[smaller_idx],
216 cell_list[smaller_idx]->face_orientation(face_idx_list[smaller_idx]),
217 cell_list[smaller_idx]->face_flip(face_idx_list[smaller_idx]),
218 cell_list[smaller_idx]->face_rotation(face_idx_list[smaller_idx]))
223 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_face; ++i)
227 cell_list[larger_idx]->vertex_index(
229 face_idx_list[larger_idx],
240 connectivity->tree_to_face[index*6 + f] += 6*v;
253 connectivity->ctt_offset[0] = 0;
254 std::partial_sum (vertex_touch_count.begin(),
255 vertex_touch_count.end(),
256 &connectivity->ctt_offset[1]);
259 num_vtt = std::accumulate (vertex_touch_count.begin(),
260 vertex_touch_count.end(),
267 for (
unsigned int v=0; v<triangulation.
n_vertices(); ++v)
269 Assert (vertex_to_cell[v].size() == vertex_touch_count[v],
272 typename std::list<std::pair
274 unsigned int> >::const_iterator
275 p = vertex_to_cell[v].begin();
276 for (
unsigned int c=0; c<vertex_touch_count[v]; ++c, ++p)
278 connectivity->corner_to_tree[connectivity->ctt_offset[v]+c]
279 = coarse_cell_to_p4est_tree_permutation[p->first->index()];
280 connectivity->corner_to_corner[connectivity->ctt_offset[v]+c]
288 template <
int dim,
int spacedim>
293 Assert (coarse_grid_cell < parallel_forest->connectivity->num_trees,
295 return ((coarse_grid_cell >= parallel_forest->first_local_tree)
297 (coarse_grid_cell <= parallel_forest->last_local_tree));
301 template <
int dim,
int spacedim>
305 if (cell->has_children())
306 for (
unsigned int c=0; c<cell->n_children(); ++c)
307 delete_all_children_and_self<dim,spacedim> (cell->child(c));
309 cell->set_coarsen_flag ();
314 template <
int dim,
int spacedim>
318 if (cell->has_children())
319 for (
unsigned int c=0; c<cell->n_children(); ++c)
320 delete_all_children_and_self<dim,spacedim> (cell->child(c));
324 template <
int dim,
int spacedim>
332 const std::vector<std::vector<bool> > &marked_vertices)
339 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
341 if (marked_vertices[dealii_cell->level()][dealii_cell->vertex_index(v)])
360 if (!used && dealii_cell->active() && dealii_cell->is_artificial()==
false 361 && dealii_cell->level()+1<
static_cast<int>(marked_vertices.size()))
363 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
365 if (marked_vertices[dealii_cell->level()+1][dealii_cell->vertex_index(v)])
374 if (!used && dealii_cell->active() && dealii_cell->is_artificial()==
false 375 && dealii_cell->level()>0)
377 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
379 if (marked_vertices[dealii_cell->level()-1][dealii_cell->vertex_index(v)])
393 Assert((owner!=-2) && (owner!=-1),
ExcMessage(
"p4est should know the owner."));
394 dealii_cell->set_level_subdomain_id(owner);
399 if (dealii_cell->has_children ())
403 for (
unsigned int c=0;
404 c<GeometryInfo<dim>::max_children_per_cell; ++c)
408 P4EST_QUADRANT_INIT(&p4est_child[c]);
411 P8EST_QUADRANT_INIT(&p4est_child[c]);
422 for (
unsigned int c=0;
423 c<GeometryInfo<dim>::max_children_per_cell; ++c)
425 determine_level_subdomain_id_recursively <dim,spacedim> (tree,tree_index,
426 dealii_cell->child(c),
436 template <
int dim,
int spacedim>
445 if (sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
451 delete_all_children<dim,spacedim> (dealii_cell);
452 if (!dealii_cell->has_children())
453 dealii_cell->set_subdomain_id(my_subdomain);
462 if (dealii_cell->has_children () ==
false)
463 dealii_cell->set_refine_flag ();
468 for (
unsigned int c=0;
469 c<GeometryInfo<dim>::max_children_per_cell; ++c)
473 P4EST_QUADRANT_INIT(&p4est_child[c]);
476 P8EST_QUADRANT_INIT(&p4est_child[c]);
487 for (
unsigned int c=0;
488 c<GeometryInfo<dim>::max_children_per_cell; ++c)
498 delete_all_children<dim,spacedim> (dealii_cell->child(c));
499 dealii_cell->child(c)
506 match_tree_recursively<dim,spacedim> (tree,
507 dealii_cell->child(c),
517 template <
int dim,
int spacedim>
519 match_quadrant (const ::Triangulation<dim,spacedim> *tria,
520 unsigned int dealii_index,
525 int l = ghost_quadrant.level;
527 for (i = 0; i <
l; i++)
530 if (cell->has_children () ==
false)
532 cell->clear_coarsen_flag();
533 cell->set_refine_flag ();
538 dealii_index = cell->child_index(child_id);
542 if (cell->has_children())
543 delete_all_children<dim,spacedim> (cell);
546 cell->clear_coarsen_flag();
547 cell->set_subdomain_id(ghost_owner);
553 template <
int dim,
int spacedim>
558 const typename std::list<std::pair<
unsigned int,
typename std_cxx11::function<
560 typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus,
562 > > > &attached_data_pack_callbacks)
564 typedef std::list<std::pair<
unsigned int,
typename std_cxx11::function<
566 typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus,
568 > > > callback_list_t;
570 int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
580 bool p4est_has_children = (idx == -1);
582 if (p4est_has_children && dealii_cell->has_children())
587 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
591 P4EST_QUADRANT_INIT(&p4est_child[c]);
594 P8EST_QUADRANT_INIT(&p4est_child[c]);
603 for (
unsigned int c=0;
604 c<GeometryInfo<dim>::max_children_per_cell; ++c)
606 attach_mesh_data_recursively<dim,spacedim> (tree,
607 dealii_cell->child(c),
609 attached_data_pack_callbacks);
612 else if (!p4est_has_children && !dealii_cell->has_children())
617 sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), idx)
621 for (
typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin();
622 it != attached_data_pack_callbacks.end();
625 void *ptr =
static_cast<char *
>(q->p.user_data) + (*it).first;
626 ((*it).second)(dealii_cell,
631 else if (p4est_has_children)
639 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
643 P4EST_QUADRANT_INIT(&p4est_child[c]);
646 P8EST_QUADRANT_INIT(&p4est_child[c]);
654 int child0_idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
657 Assert(child0_idx != -1,
ExcMessage(
"the first child should exist as an active quadrant!"));
661 sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), child0_idx)
665 for (
typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin();
666 it != attached_data_pack_callbacks.end();
669 void *ptr =
static_cast<char *
>(q->p.user_data) + (*it).first;
671 ((*it).second)(dealii_cell,
677 for (
unsigned int i=1; i<GeometryInfo<dim>::max_children_per_cell; ++i)
679 int child_idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
683 sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), child_idx)
695 sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), idx)
699 for (
typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin();
700 it != attached_data_pack_callbacks.end();
703 void *ptr =
static_cast<char *
>(q->p.user_data) + (*it).first;
704 ((*it).second)(dealii_cell,
711 template <
int dim,
int spacedim>
717 std::vector<unsigned int> &weight)
719 const int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
729 const bool p4est_has_children = (idx == -1);
731 if (p4est_has_children && dealii_cell->has_children())
736 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
740 P4EST_QUADRANT_INIT(&p4est_child[c]);
743 P8EST_QUADRANT_INIT(&p4est_child[c]);
752 for (
unsigned int c=0;
753 c<GeometryInfo<dim>::max_children_per_cell; ++c)
755 get_cell_weights_recursively<dim,spacedim> (tree,
756 dealii_cell->child(c),
762 else if (!p4est_has_children && !dealii_cell->has_children())
765 weight.push_back(1000);
769 else if (p4est_has_children)
772 unsigned int parent_weight(1000);
776 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
779 weight.push_back(parent_weight);
785 weight.push_back(1000);
792 template <
int dim,
int spacedim>
798 const unsigned int offset,
799 const typename std_cxx11::function<
803 int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
814 const bool p4est_has_children = (idx == -1);
815 if (p4est_has_children)
822 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
826 P4EST_QUADRANT_INIT(&p4est_child[c]);
829 P8EST_QUADRANT_INIT(&p4est_child[c]);
838 for (
unsigned int c=0;
839 c<GeometryInfo<dim>::max_children_per_cell; ++c)
841 post_mesh_data_recursively<dim,spacedim> (tree,
842 dealii_cell->child(c),
855 sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), idx)
858 void *ptr =
static_cast<char *
>(q->p.user_data) + offset;
859 typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus
860 status = *
static_cast< 861 typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus *
867 unpack_callback(dealii_cell, status, ptr);
872 unpack_callback(parent_cell, status, ptr);
877 unpack_callback(dealii_cell, status, ptr);
897 template <
int dim,
int spacedim>
898 class RefineAndCoarsenList
902 const std::vector<types::global_dof_index> &p4est_tree_to_coarse_cell_permutation,
929 bool pointers_are_at_end ()
const;
932 std::vector<typename internal::p4est::types<dim>::quadrant> refine_list;
933 typename std::vector<typename internal::p4est::types<dim>::quadrant>::const_iterator current_refine_pointer;
935 std::vector<typename internal::p4est::types<dim>::quadrant> coarsen_list;
936 typename std::vector<typename internal::p4est::types<dim>::quadrant>::const_iterator current_coarsen_pointer;
945 template <
int dim,
int spacedim>
947 RefineAndCoarsenList<dim,spacedim>::
948 pointers_are_at_end ()
const 950 return ((current_refine_pointer == refine_list.end())
952 (current_coarsen_pointer == coarsen_list.end()));
957 template <
int dim,
int spacedim>
958 RefineAndCoarsenList<dim,spacedim>::
960 const std::vector<types::global_dof_index> &p4est_tree_to_coarse_cell_permutation,
964 unsigned int n_refine_flags = 0,
968 cell != triangulation.
end(); ++cell)
971 if (cell->subdomain_id() != my_subdomain)
974 if (cell->refine_flag_set())
976 else if (cell->coarsen_flag_set())
980 refine_list.reserve (n_refine_flags);
981 coarsen_list.reserve (n_coarsen_flags);
991 for (
unsigned int c=0; c<triangulation.
n_cells(0); ++c)
993 unsigned int coarse_cell_index =
994 p4est_tree_to_coarse_cell_permutation[c];
997 cell (&triangulation, 0, coarse_cell_index);
1004 p4est_cell.p.which_tree = c;
1005 build_lists (cell, p4est_cell, my_subdomain);
1009 Assert(refine_list.size() == n_refine_flags,
1011 Assert(coarsen_list.size() == n_coarsen_flags,
1015 for (
unsigned int i=1; i<refine_list.size(); ++i)
1016 Assert (refine_list[i].p.which_tree >=
1017 refine_list[i-1].p.which_tree,
1019 for (
unsigned int i=1; i<coarsen_list.size(); ++i)
1020 Assert (coarsen_list[i].p.which_tree >=
1021 coarsen_list[i-1].p.which_tree,
1024 current_refine_pointer = refine_list.begin();
1025 current_coarsen_pointer = coarsen_list.begin();
1030 template <
int dim,
int spacedim>
1032 RefineAndCoarsenList<dim,spacedim>::
1037 if (!cell->has_children())
1039 if (cell->subdomain_id() == my_subdomain)
1041 if (cell->refine_flag_set())
1042 refine_list.push_back (p4est_cell);
1043 else if (cell->coarsen_flag_set())
1044 coarsen_list.push_back (p4est_cell);
1051 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
1055 P4EST_QUADRANT_INIT(&p4est_child[c]);
1058 P8EST_QUADRANT_INIT(&p4est_child[c]);
1066 for (
unsigned int c=0;
1067 c<GeometryInfo<dim>::max_children_per_cell; ++c)
1069 p4est_child[c].p.which_tree = p4est_cell.p.which_tree;
1070 build_lists (cell->child(c),
1078 template <
int dim,
int spacedim>
1080 RefineAndCoarsenList<dim,spacedim>::
1085 RefineAndCoarsenList<dim,spacedim> *this_object
1086 =
reinterpret_cast<RefineAndCoarsenList<dim,spacedim>*
>(forest->user_pointer);
1090 if (this_object->current_refine_pointer == this_object->refine_list.end())
1093 Assert (coarse_cell_index <=
1094 this_object->current_refine_pointer->p.which_tree,
1099 if (coarse_cell_index <
1100 this_object->current_refine_pointer->p.which_tree)
1104 Assert (coarse_cell_index <=
1105 this_object->current_refine_pointer->p.which_tree,
1111 quadrant_compare (quadrant,
1112 &*this_object->current_refine_pointer) <= 0,
1117 quadrant_is_equal (quadrant, &*this_object->current_refine_pointer))
1119 ++this_object->current_refine_pointer;
1129 template <
int dim,
int spacedim>
1131 RefineAndCoarsenList<dim,spacedim>::
1136 RefineAndCoarsenList<dim,spacedim> *this_object
1137 =
reinterpret_cast<RefineAndCoarsenList<dim,spacedim>*
>(forest->user_pointer);
1141 if (this_object->current_coarsen_pointer ==
1142 this_object->coarsen_list.end())
1145 Assert (coarse_cell_index <=
1146 this_object->current_coarsen_pointer->p.which_tree,
1151 if (coarse_cell_index <
1152 this_object->current_coarsen_pointer->p.which_tree)
1156 Assert (coarse_cell_index <=
1157 this_object->current_coarsen_pointer->p.which_tree,
1163 quadrant_compare (children[0],
1164 &*this_object->current_coarsen_pointer) <= 0,
1170 quadrant_is_equal (children[0],
1171 &*this_object->current_coarsen_pointer))
1174 ++this_object->current_coarsen_pointer;
1178 for (
unsigned int c=1; c<GeometryInfo<dim>::max_children_per_cell; ++c)
1181 quadrant_is_equal (children[c],
1182 &*this_object->current_coarsen_pointer),
1184 ++this_object->current_coarsen_pointer;
1202 template <
int dim,
int spacedim>
1203 class PartitionWeights
1211 PartitionWeights (
const std::vector<unsigned int> &cell_weights);
1227 std::vector<unsigned int> cell_weights_list;
1228 std::vector<unsigned int>::const_iterator current_pointer;
1232 template <
int dim,
int spacedim>
1233 PartitionWeights<dim,spacedim>::
1234 PartitionWeights (
const std::vector<unsigned int> &cell_weights)
1236 cell_weights_list(cell_weights)
1240 current_pointer = cell_weights_list.begin();
1244 template <
int dim,
int spacedim>
1246 PartitionWeights<dim,spacedim>::
1255 PartitionWeights<dim,spacedim> *this_object
1256 =
reinterpret_cast<PartitionWeights<dim,spacedim>*
>(forest->user_pointer);
1258 Assert (this_object->current_pointer >= this_object->cell_weights_list.begin(),
1260 Assert (this_object->current_pointer < this_object->cell_weights_list.end(),
1264 return *this_object->current_pointer++;
1271 namespace distributed
1277 template <
int dim,
int spacedim>
1280 const typename ::Triangulation<dim,spacedim>::MeshSmoothing smooth_grid,
1288 (settings_ & construct_multigrid_hierarchy) ?
1290 (smooth_grid |
Triangulation<dim,spacedim>::limit_level_difference_at_vertices) :
1293 settings(settings_),
1294 triangulation_has_content (false),
1296 parallel_forest (0),
1297 refinement_in_progress (false),
1298 attached_data_size(0),
1299 n_attached_datas(0),
1300 n_attached_deserialize(0)
1307 template <
int dim,
int spacedim>
1312 Assert (triangulation_has_content ==
false,
1322 template <
int dim,
int spacedim>
1334 catch (
const typename ::Triangulation<dim,spacedim>::DistortedCellList &)
1344 triangulation_has_content =
true;
1346 setup_coarse_cell_to_p4est_tree_permutation ();
1352 copy_local_forest_to_triangulation ();
1361 this->update_number_cache ();
1362 this->update_periodic_face_map();
1368 namespace CommunicateLocallyMovedVertices
1377 template <
int dim,
int spacedim>
1381 std::vector<unsigned int> tree_index;
1383 std::vector<typename ::internal::p4est::types<dim>::quadrant> quadrants;
1386 std::vector<unsigned int> vertex_indices;
1389 std::vector<::Point<spacedim> > vertices;
1393 std::vector<unsigned int * > first_vertex_indices;
1394 std::vector<::Point<spacedim>* > first_vertices;
1396 unsigned int bytes_for_buffer ()
const 1398 return (
sizeof(
unsigned int) +
1399 tree_index.size() *
sizeof(
unsigned int) +
1400 quadrants.size() *
sizeof(typename ::internal::p4est
1401 ::types<dim>::quadrant) +
1403 vertex_indices.size() *
sizeof(
unsigned int);
1406 void pack_data (std::vector<char> &buffer)
const 1408 buffer.resize(bytes_for_buffer());
1410 char *ptr = &buffer[0];
1412 const unsigned int num_cells = tree_index.size();
1413 std::memcpy(ptr, &num_cells,
sizeof(
unsigned int));
1414 ptr +=
sizeof(
unsigned int);
1418 num_cells*
sizeof(
unsigned int));
1419 ptr += num_cells*
sizeof(
unsigned int);
1423 num_cells *
sizeof(typename ::internal::p4est::
1424 types<dim>::quadrant));
1425 ptr += num_cells*
sizeof(typename ::internal::p4est::types<dim>::
1430 vertex_indices.size() *
sizeof(
unsigned int));
1431 ptr += vertex_indices.size() *
sizeof(
unsigned int);
1438 Assert (ptr == &buffer[0]+buffer.size(),
1443 void unpack_data (
const std::vector<char> &buffer)
1445 const char *ptr = &buffer[0];
1447 memcpy(&cells, ptr,
sizeof(
unsigned int));
1448 ptr +=
sizeof(
unsigned int);
1450 tree_index.resize(cells);
1451 memcpy(&tree_index[0],ptr,
sizeof(
unsigned int)*cells);
1452 ptr +=
sizeof(
unsigned int)*cells;
1454 quadrants.resize(cells);
1455 memcpy(&quadrants[0],ptr,
1456 sizeof(typename ::internal::p4est::types<dim>::quadrant)*cells);
1457 ptr +=
sizeof(typename ::internal::p4est::types<dim>::quadrant)*cells;
1459 vertex_indices.clear();
1460 first_vertex_indices.resize(cells);
1461 std::vector<unsigned int> n_vertices_on_cell(cells);
1462 std::vector<unsigned int> first_indices (cells);
1463 for (
unsigned int c=0; c<cells; ++c)
1468 const unsigned int *
const vertex_index
1469 =
reinterpret_cast<const unsigned int *const
>(ptr);
1470 first_indices[c] = vertex_indices.size();
1471 vertex_indices.push_back(*vertex_index);
1472 n_vertices_on_cell[c] = *vertex_index;
1473 ptr +=
sizeof(
unsigned int);
1475 vertex_indices.resize(vertex_indices.size() + n_vertices_on_cell[c]);
1476 memcpy(&vertex_indices[vertex_indices.size() - n_vertices_on_cell[c]],
1477 ptr, n_vertices_on_cell[c]*
sizeof(
unsigned int));
1478 ptr += n_vertices_on_cell[c]*
sizeof(
unsigned int);
1480 for (
unsigned int c=0; c<cells; ++c)
1481 first_vertex_indices[c] = &vertex_indices[first_indices[c]];
1484 first_vertices.resize(cells);
1485 for (
unsigned int c=0; c<cells; ++c)
1488 const ::Point<spacedim> *
const vertex
1489 =
reinterpret_cast<const ::Point<spacedim> * const
>(ptr);
1490 first_indices[c] = vertices.size();
1491 vertices.push_back(*vertex);
1493 vertices.resize(vertices.size() + n_vertices_on_cell[c]-1);
1494 memcpy(&vertices[vertices.size() - (n_vertices_on_cell[c]-1)],
1498 for (
unsigned int c=0; c<cells; ++c)
1499 first_vertices[c] = &vertices[first_indices[c]];
1501 Assert (ptr == &buffer[0]+buffer.size(),
1520 template <
int dim,
int spacedim>
1523 const unsigned int tree_index,
1525 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
1526 const std::map<
unsigned int, std::set<::types::subdomain_id> > &vertices_with_ghost_neighbors,
1527 const std::vector<bool> &vertex_locally_moved,
1532 if (dealii_cell->has_children())
1534 typename ::internal::p4est::types<dim>::quadrant
1536 ::internal::p4est::init_quadrant_children<dim>(p4est_cell, p4est_child);
1539 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
1540 fill_vertices_recursively<dim,spacedim>(tria,
1542 dealii_cell->child(c),
1544 vertices_with_ghost_neighbors,
1545 vertex_locally_moved,
1557 if (dealii_cell->is_locally_owned())
1559 std::set<::types::subdomain_id> send_to;
1560 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
1562 const std::map<unsigned int, std::set<::types::subdomain_id> >::const_iterator
1563 neighbor_subdomains_of_vertex
1564 = vertices_with_ghost_neighbors.find (dealii_cell->vertex_index(v));
1566 if (neighbor_subdomains_of_vertex
1567 != vertices_with_ghost_neighbors.end())
1569 Assert(neighbor_subdomains_of_vertex->second.size()!=0,
1571 send_to.insert(neighbor_subdomains_of_vertex->second.begin(),
1572 neighbor_subdomains_of_vertex->second.end());
1576 if (send_to.size() > 0)
1578 std::vector<unsigned int> vertex_indices;
1579 std::vector<::Point<spacedim> > local_vertices;
1580 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
1581 if (vertex_locally_moved[dealii_cell->vertex_index(v)])
1583 vertex_indices.push_back(v);
1584 local_vertices.push_back(dealii_cell->vertex(v));
1587 if (vertex_indices.size()>0)
1588 for (std::set<::types::subdomain_id>::iterator it=send_to.begin();
1589 it!=send_to.end(); ++it)
1591 const ::types::subdomain_id subdomain = *it;
1595 const typename std::map<::types::subdomain_id, CellInfo<dim, spacedim> >::iterator
1597 = needs_to_get_cell.insert (std::make_pair(subdomain,
1598 CellInfo<dim,spacedim>()))
1601 p->second.tree_index.push_back(tree_index);
1602 p->second.quadrants.push_back(p4est_cell);
1604 p->second.vertex_indices.push_back(vertex_indices.size());
1605 p->second.vertex_indices.insert(p->second.vertex_indices.end(),
1606 vertex_indices.begin(),
1607 vertex_indices.end());
1609 p->second.vertices.insert(p->second.vertices.end(),
1610 local_vertices.begin(),
1611 local_vertices.end());
1628 template <
int dim,
int spacedim>
1630 set_vertices_recursively (
1632 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
1634 const typename ::internal::p4est::types<dim>::quadrant &quadrant,
1635 const ::Point<spacedim> *
const vertices,
1636 const unsigned int *
const vertex_indices)
1638 if (::internal::p4est::quadrant_is_equal<dim>(p4est_cell, quadrant))
1644 const unsigned int n_vertices = vertex_indices[0];
1647 for (
unsigned int i=0; i<n_vertices; ++i)
1648 dealii_cell->vertex(vertex_indices[i+1]) = vertices[i];
1653 if (! dealii_cell->has_children())
1656 if (! ::internal::p4est::quadrant_is_ancestor<dim> (p4est_cell, quadrant))
1659 typename ::internal::p4est::types<dim>::quadrant
1661 ::internal::p4est::init_quadrant_children<dim>(p4est_cell, p4est_child);
1663 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
1664 set_vertices_recursively<dim,spacedim> (tria, p4est_child[c],
1665 dealii_cell->child(c),
1674 template <
int dim,
int spacedim>
1678 triangulation_has_content =
false;
1680 if (parallel_ghost != 0)
1686 if (parallel_forest != 0)
1689 parallel_forest = 0;
1692 if (connectivity != 0)
1698 coarse_cell_to_p4est_tree_permutation.resize (0);
1699 p4est_tree_to_coarse_cell_permutation.resize (0);
1703 this->update_number_cache ();
1706 template <
int dim,
int spacedim>
1710 if (this->n_global_levels()<=1)
1719 bool have_coarser_cell =
false;
1721 cell != this->end(this->n_global_levels()-2);
1723 if (cell->is_locally_owned())
1725 have_coarser_cell =
true;
1735 template <
int dim,
int spacedim>
1741 coarse_cell_to_p4est_tree_permutation.resize (this->n_cells(0));
1744 coarse_cell_to_p4est_tree_permutation);
1746 p4est_tree_to_coarse_cell_permutation
1752 template <
int dim,
int spacedim>
1756 Assert (parallel_forest != 0,
1757 ExcMessage (
"Can't produce output when no forest is created yet."));
1763 template <
int dim,
int spacedim>
1768 Assert(n_attached_deserialize==0,
1769 ExcMessage (
"not all SolutionTransfer's got deserialized after the last load()"));
1770 int real_data_size = 0;
1771 if (attached_data_size>0)
1772 real_data_size = attached_data_size+
sizeof(
CellStatus);
1774 Assert(this->n_cells()>0,
ExcMessage(
"Can not save() an empty Triangulation."));
1776 if (this->my_subdomain==0)
1778 std::string fname=std::string(filename)+
".info";
1779 std::ofstream f(fname.c_str());
1780 f <<
"version nproc attached_bytes n_attached_objs n_coarse_cells" << std::endl
1783 << real_data_size <<
" " 1784 << attached_data_pack_callbacks.size() <<
" " 1789 if (attached_data_size>0)
1792 ->attach_mesh_data();
1805 void *userptr = parallel_forest->user_pointer;
1807 parallel_forest->user_pointer = userptr;
1811 template <
int dim,
int spacedim>
1815 const bool autopartition)
1817 Assert(this->n_cells()>0,
ExcMessage(
"load() only works if the Triangulation already contains a coarse mesh!"));
1818 Assert(this->n_levels()==1,
ExcMessage(
"Triangulation may only contain coarse cells when calling load()."));
1821 if (parallel_ghost != 0)
1827 parallel_forest = 0;
1831 unsigned int version, numcpus, attached_size, attached_count, n_coarse_cells;
1833 std::string fname=std::string(filename)+
".info";
1834 std::ifstream f(fname.c_str());
1835 std::string firstline;
1836 getline(f, firstline);
1837 f >> version >> numcpus >> attached_size >> attached_count >> n_coarse_cells;
1840 Assert(version == 2,
ExcMessage(
"Incompatible version found in .info file."));
1841 Assert(this->n_cells(0) == n_coarse_cells,
ExcMessage(
"Number of coarse cells differ!"));
1842 #if DEAL_II_P4EST_VERSION_GTE(0,3,4,3) 1845 ExcMessage(
"parallel::distributed::Triangulation::load() only supports loading " 1846 "saved data with a greater or equal number of processes than were used to " 1847 "save() when using p4est 0.3.4.2."));
1850 attached_data_size = 0;
1851 n_attached_datas = 0;
1852 n_attached_deserialize = attached_count;
1854 #if DEAL_II_P4EST_VERSION_GTE(0,3,4,3) 1856 filename, this->mpi_communicator,
1857 attached_size, attached_size>0,
1862 (void)autopartition;
1864 filename, this->mpi_communicator,
1865 attached_size, attached_size>0,
1879 copy_local_forest_to_triangulation ();
1890 this->update_number_cache ();
1891 this->update_periodic_face_map();
1896 template <
int dim,
int spacedim>
1900 Assert (parallel_forest != 0,
1901 ExcMessage (
"Can't produce a check sum when no forest is created yet."));
1902 return ::internal::p4est::functions<dim>::checksum (parallel_forest);
1905 template <
int dim,
int spacedim>
1912 if (this->n_levels() == 0)
1915 if (settings & construct_multigrid_hierarchy)
1919 cell = this->begin();
1920 cell != this->end();
1923 && cell->level_subdomain_id() != this->locally_owned_subdomain())
1924 this->number_cache.level_ghost_owners.insert(cell->level_subdomain_id());
1930 int ierr = MPI_Barrier(this->mpi_communicator);
1934 std::vector<MPI_Request> requests (this->number_cache.level_ghost_owners.size());
1936 unsigned int req_counter = 0;
1938 for (std::set<types::subdomain_id>::iterator it = this->number_cache.level_ghost_owners.begin();
1939 it != this->number_cache.level_ghost_owners.end();
1940 ++it, ++req_counter)
1943 ==
typeid(
unsigned int),
1945 ierr = MPI_Isend(&dummy, 1, MPI_UNSIGNED,
1946 *it, 9001, this->mpi_communicator,
1947 &requests[req_counter]);
1951 for (std::set<types::subdomain_id>::iterator it = this->number_cache.level_ghost_owners.begin();
1952 it != this->number_cache.level_ghost_owners.end();
1956 ==
typeid(
unsigned int),
1959 ierr = MPI_Recv(&dummy, 1, MPI_UNSIGNED,
1960 *it, 9001, this->mpi_communicator,
1965 if (requests.size() > 0)
1967 ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE);
1971 ierr = MPI_Barrier(this->mpi_communicator);
1982 template <
int dim,
int spacedim>
1983 typename ::internal::p4est::types<dim>::tree *
1987 const unsigned int tree_index
1988 = coarse_cell_to_p4est_tree_permutation[dealii_coarse_cell_index];
1989 typename ::internal::p4est::types<dim>::tree *tree
1990 =
static_cast<typename ::internal::p4est::types<dim>::tree *
> 1991 (sc_array_index (parallel_forest->trees,
2003 const unsigned int dim = 2, spacedim = 2;
2011 std::vector<unsigned int> vertex_touch_count;
2014 std::pair<Triangulation<dim,spacedim>::active_cell_iterator,
2017 get_vertex_to_cell_mappings (*
this,
2020 const ::internal::p4est::types<2>::locidx
2021 num_vtt = std::accumulate (vertex_touch_count.begin(),
2022 vertex_touch_count.end(),
2028 const bool set_vertex_info
2043 set_vertex_and_cell_info (*
this,
2046 coarse_cell_to_p4est_tree_permutation,
2050 Assert (p4est_connectivity_is_valid (connectivity) == 1,
2074 const unsigned int dim = 2, spacedim = 3;
2082 std::vector<unsigned int> vertex_touch_count;
2085 std::pair<Triangulation<dim,spacedim>::active_cell_iterator,
2088 get_vertex_to_cell_mappings (*
this,
2091 const ::internal::p4est::types<2>::locidx
2092 num_vtt = std::accumulate (vertex_touch_count.begin(),
2093 vertex_touch_count.end(),
2099 const bool set_vertex_info
2114 set_vertex_and_cell_info (*
this,
2117 coarse_cell_to_p4est_tree_permutation,
2121 Assert (p4est_connectivity_is_valid (connectivity) == 1,
2143 const int dim = 3, spacedim = 3;
2151 std::vector<unsigned int> vertex_touch_count;
2154 std::pair<Triangulation<3>::active_cell_iterator,
2157 get_vertex_to_cell_mappings (*
this,
2160 const ::internal::p4est::types<2>::locidx
2161 num_vtt = std::accumulate (vertex_touch_count.begin(),
2162 vertex_touch_count.end(),
2165 std::vector<unsigned int> edge_touch_count;
2168 std::pair<Triangulation<3>::active_cell_iterator,
2171 get_edge_to_cell_mappings (*
this,
2174 const ::internal::p4est::types<2>::locidx
2175 num_ett = std::accumulate (edge_touch_count.begin(),
2176 edge_touch_count.end(),
2180 const bool set_vertex_info
2192 this->n_active_lines(),
2197 set_vertex_and_cell_info (*
this,
2200 coarse_cell_to_p4est_tree_permutation,
2229 const unsigned int deal_to_p4est_line_index[12]
2230 = { 4, 5, 0, 1, 6, 7, 2, 3, 8, 9, 10, 11 } ;
2233 cell = this->begin_active();
2234 cell != this->end(); ++cell)
2237 index = coarse_cell_to_p4est_tree_permutation[cell->index()];
2238 for (
unsigned int e=0; e<GeometryInfo<3>::lines_per_cell; ++
e)
2240 deal_to_p4est_line_index[e]]
2241 = cell->line(e)->index();
2246 connectivity->ett_offset[0] = 0;
2247 std::partial_sum (edge_touch_count.begin(),
2248 edge_touch_count.end(),
2249 &connectivity->ett_offset[1]);
2251 Assert (connectivity->ett_offset[this->n_active_lines()] ==
2255 for (
unsigned int v=0; v<this->n_active_lines(); ++v)
2257 Assert (edge_to_cell[v].size() == edge_touch_count[v],
2262 unsigned int> >::const_iterator
2263 p = edge_to_cell[v].begin();
2264 for (
unsigned int c=0; c<edge_touch_count[v]; ++c, ++p)
2266 connectivity->edge_to_tree[connectivity->ett_offset[v]+c]
2267 = coarse_cell_to_p4est_tree_permutation[p->first->index()];
2268 connectivity->edge_to_edge[connectivity->ett_offset[v]+c]
2269 = deal_to_p4est_line_index[p->second];
2273 Assert (p8est_connectivity_is_valid (connectivity) == 1,
2295 template <
int dim,
int spacedim>
2296 bool enforce_mesh_balance_over_periodic_boundaries
2302 std::vector<bool> flags_before[2];
2306 std::vector<unsigned int> topological_vertex_numbering(tria.
n_vertices());
2307 for (
unsigned int i=0; i<topological_vertex_numbering.size(); ++i)
2308 topological_vertex_numbering[i] = i;
2325 typename std::map<std::pair<cell_iterator, unsigned int>,
2326 std::pair<std::pair<cell_iterator,unsigned int>, std::bitset<3> > >::const_iterator it;
2329 const cell_iterator &cell_1 = it->first.first;
2330 const unsigned int face_no_1 = it->first.second;
2331 const cell_iterator &cell_2 = it->second.first.first;
2332 const unsigned int face_no_2 = it->second.first.second;
2333 const std::bitset<3> face_orientation = it->second.second;
2335 if (cell_1->level() == cell_2->level())
2337 for (
unsigned int v=0; v<
GeometryInfo<dim-1>::vertices_per_cell; ++v)
2341 const unsigned int vface0 =
2343 face_orientation[1],
2344 face_orientation[2]);
2345 const unsigned int vi0 = topological_vertex_numbering[cell_1->face(face_no_1)->vertex_index(vface0)];
2346 const unsigned int vi1 = topological_vertex_numbering[cell_2->face(face_no_2)->vertex_index(v)];
2347 const unsigned int min_index = std::min(vi0, vi1);
2348 topological_vertex_numbering[cell_1->face(face_no_1)->vertex_index(vface0)]
2349 = topological_vertex_numbering[cell_2->face(face_no_2)->vertex_index(v)]
2356 for (
unsigned int i=0; i<topological_vertex_numbering.size(); ++i)
2358 const unsigned int j = topological_vertex_numbering[i];
2360 Assert(topological_vertex_numbering[j] == j,
2367 bool continue_iterating =
true;
2368 std::vector<int> vertex_level(tria.
n_vertices());
2369 while (continue_iterating)
2373 std::fill (vertex_level.begin(), vertex_level.end(), 0);
2376 for (; cell!=endc; ++cell)
2378 if (cell->refine_flag_set())
2379 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
2381 vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]]
2382 = std::max (vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]],
2384 else if (!cell->coarsen_flag_set())
2385 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
2387 vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]]
2388 = std::max (vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]],
2399 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
2401 vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]]
2402 = std::max (vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]],
2407 continue_iterating =
false;
2418 for (cell=tria.
last_active(); cell != endc; --cell)
2419 if (cell->refine_flag_set() ==
false)
2421 for (
unsigned int vertex=0;
2422 vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
2423 if (vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]] >=
2427 cell->clear_coarsen_flag();
2432 if (vertex_level[topological_vertex_numbering[cell->vertex_index(vertex)]] >
2435 cell->set_refine_flag();
2436 continue_iterating =
true;
2438 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell;
2440 vertex_level[topological_vertex_numbering[cell->vertex_index(v)]]
2441 = std::max (vertex_level[topological_vertex_numbering[cell->vertex_index(v)]],
2453 cell!=tria.
end(); ++cell)
2459 const unsigned int n_children=cell->n_children();
2460 unsigned int flagged_children=0;
2461 for (
unsigned int child=0; child<n_children; ++child)
2462 if (cell->child(child)->active() &&
2463 cell->child(child)->coarsen_flag_set())
2468 if (flagged_children < n_children)
2469 for (
unsigned int child=0; child<n_children; ++child)
2470 if (cell->child(child)->active())
2471 cell->child(child)->clear_coarsen_flag();
2474 std::vector<bool> flags_after[2];
2477 return ((flags_before[0] != flags_after[0]) ||
2478 (flags_before[1] != flags_after[1]));
2484 template <
int dim,
int spacedim>
2488 std::vector<bool> flags_before[2];
2489 this->save_coarsen_flags (flags_before[0]);
2490 this->save_refine_flags (flags_before[1]);
2492 bool mesh_changed =
false;
2496 this->update_periodic_face_map();
2498 if (this->smooth_grid &
2500 mesh_changed = enforce_mesh_balance_over_periodic_boundaries(*
this);
2502 while (mesh_changed);
2506 std::vector<bool> flags_after[2];
2507 this->save_coarsen_flags (flags_after[0]);
2508 this->save_refine_flags (flags_after[1]);
2509 return ((flags_before[0] != flags_after[0]) ||
2510 (flags_before[1] != flags_after[1]));
2515 template <
int dim,
int spacedim>
2525 save_smooth = this->smooth_grid;
2535 if (settings & construct_multigrid_hierarchy)
2540 bool mesh_changed =
false;
2548 if (settings & mesh_reconstruction_after_repartitioning)
2549 while (this->begin_active()->level() > 0)
2552 cell = this->begin_active();
2553 cell != this->end();
2556 cell->set_coarsen_flag();
2559 this->prepare_coarsening_and_refinement();
2560 const bool saved_refinement_in_progress = refinement_in_progress;
2561 refinement_in_progress =
true;
2565 this->execute_coarsening_and_refinement();
2574 refinement_in_progress = saved_refinement_in_progress;
2579 if (parallel_ghost != 0)
2587 typename ::internal::p4est::types<dim>::
2588 balance_type(P4EST_CONNECT_CORNER)
2590 typename ::internal::p4est::types<dim>::
2591 balance_type(P8EST_CONNECT_CORNER)));
2599 cell = this->begin(0);
2600 cell != this->end(0);
2607 cell = this->begin(0);
2608 cell != this->end(0);
2614 if (tree_exists_locally<dim,spacedim>(parallel_forest,
2615 coarse_cell_to_p4est_tree_permutation[cell->index()])
2618 delete_all_children<dim,spacedim> (cell);
2619 if (!cell->has_children())
2628 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
2629 typename ::internal::p4est::types<dim>::tree *tree =
2630 init_tree(cell->index());
2632 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
2634 match_tree_recursively<dim,spacedim> (*tree, cell,
2637 this->my_subdomain);
2644 typename ::internal::p4est::types<dim>::quadrant *quadr;
2646 typename ::internal::p4est::types<dim>::topidx ghost_tree=0;
2648 for (
unsigned int g_idx=0; g_idx<parallel_ghost->ghosts.elem_count; ++g_idx)
2650 while (g_idx >= (
unsigned int)parallel_ghost->proc_offsets[ghost_owner+1])
2652 while (g_idx >= (
unsigned int)parallel_ghost->tree_offsets[ghost_tree+1])
2655 quadr =
static_cast<typename ::internal::p4est::types<dim>::quadrant *
> 2656 ( sc_array_index(¶llel_ghost->ghosts, g_idx) );
2658 unsigned int coarse_cell_index =
2659 p4est_tree_to_coarse_cell_permutation[ghost_tree];
2661 match_quadrant<dim,spacedim> (
this, coarse_cell_index, *quadr, ghost_owner);
2665 this->prepare_coarsening_and_refinement ();
2668 mesh_changed =
false;
2670 cell = this->begin_active();
2671 cell != this->end();
2673 if (cell->refine_flag_set() || cell->coarsen_flag_set())
2675 mesh_changed =
true;
2681 const bool saved_refinement_in_progress = refinement_in_progress;
2682 refinement_in_progress =
true;
2686 this->execute_coarsening_and_refinement();
2695 refinement_in_progress = saved_refinement_in_progress;
2697 while (mesh_changed);
2701 unsigned int num_ghosts = 0;
2704 cell = this->begin_active();
2705 cell != this->end();
2708 if (cell->subdomain_id() != this->my_subdomain
2722 if (settings & construct_multigrid_hierarchy)
2728 for (
unsigned int lvl=this->n_levels(); lvl>0; )
2732 for (cell = this->begin(lvl); cell!=endc; ++cell)
2734 if ((!cell->has_children() && cell->subdomain_id()==this->locally_owned_subdomain())
2735 || (cell->has_children() && cell->child(0)->level_subdomain_id()==this->locally_owned_subdomain()))
2736 cell->set_level_subdomain_id(this->locally_owned_subdomain());
2747 std::vector<std::vector<bool> > marked_vertices(this->n_levels());
2748 for (
unsigned int lvl=0; lvl < this->n_levels(); ++lvl)
2749 marked_vertices[lvl] = mark_locally_active_vertices_on_level(lvl);
2753 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
2754 const unsigned int tree_index
2755 = coarse_cell_to_p4est_tree_permutation[cell->index()];
2756 typename ::internal::p4est::types<dim>::tree *tree =
2757 init_tree(cell->index());
2759 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
2761 determine_level_subdomain_id_recursively<dim,spacedim> (*tree, tree_index, cell,
2769 for (
unsigned int lvl=this->n_levels(); lvl>0;)
2773 for (cell = this->begin(lvl); cell!=endc; ++cell)
2775 if (cell->has_children())
2776 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
2778 if (cell->child(c)->level_subdomain_id()==this->locally_owned_subdomain())
2783 cell->child(0)->level_subdomain_id();
2785 cell->set_level_subdomain_id(mark);
2802 const unsigned int total_local_cells = this->n_active_cells();
2803 (void)total_local_cells;
2806 Assert (static_cast<unsigned int>(parallel_forest->local_num_quadrants) ==
2810 Assert (static_cast<unsigned int>(parallel_forest->local_num_quadrants) <=
2815 unsigned int n_owned = 0;
2817 cell = this->begin_active();
2818 cell != this->end(); ++cell)
2820 if (cell->subdomain_id() == this->my_subdomain)
2824 Assert(static_cast<unsigned int>(parallel_forest->local_num_quadrants) ==
2829 this->smooth_grid = save_smooth;
2834 template <
int dim,
int spacedim>
2839 if (refinement_in_progress ==
true)
2848 cell = this->begin_active();
2849 cell != this->end(); ++cell)
2850 if (cell->is_locally_owned() && cell->refine_flag_set())
2851 Assert (cell->refine_flag_set() ==
2853 ExcMessage (
"This class does not support anisotropic refinement"));
2865 ExcMessage(
"Fatal Error: maximum refinement level of p4est reached."));
2870 refinement_in_progress =
true;
2871 this->prepare_coarsening_and_refinement ();
2876 cell = this->begin_active();
2877 cell != this->end(); ++cell)
2878 if (cell->is_ghost() || cell->is_artificial())
2880 cell->clear_refine_flag ();
2881 cell->clear_coarsen_flag ();
2887 RefineAndCoarsenList<dim,spacedim>
2888 refine_and_coarsen_list (*
this,
2889 p4est_tree_to_coarse_cell_permutation,
2890 this->my_subdomain);
2896 Assert (parallel_forest->user_pointer ==
this,
2898 parallel_forest->user_pointer = &refine_and_coarsen_list;
2900 if (parallel_ghost != 0)
2906 refine (parallel_forest,
false,
2907 &RefineAndCoarsenList<dim,spacedim>::refine_callback,
2910 coarsen (parallel_forest,
false,
2911 &RefineAndCoarsenList<dim,spacedim>::coarsen_callback,
2915 Assert (refine_and_coarsen_list.pointers_are_at_end(),
2919 parallel_forest->user_pointer =
this;
2927 typename ::internal::p4est::types<dim>::
2928 balance_type(P4EST_CONNECT_FULL)
2930 typename ::internal::p4est::types<dim>::
2931 balance_type(P8EST_CONNECT_FULL)),
2938 if (!(settings & no_automatic_repartitioning))
2944 partition (parallel_forest,
2950 const std::vector<unsigned int> cell_weights = get_cell_weights();
2952 PartitionWeights<dim,spacedim> partition_weights (cell_weights);
2956 Assert (parallel_forest->user_pointer ==
this,
2958 parallel_forest->user_pointer = &partition_weights;
2963 &PartitionWeights<dim,spacedim>::cell_weight);
2966 parallel_forest->user_pointer =
this;
2974 cell = this->begin_active();
2975 cell != this->end(); ++cell)
2977 cell->clear_refine_flag();
2978 cell->clear_coarsen_flag();
2983 copy_local_forest_to_triangulation ();
3008 if (settings & construct_multigrid_hierarchy)
3010 for (
unsigned int lvl=0; lvl<this->n_global_levels(); ++lvl)
3012 std::vector<bool> active_verts = this->mark_locally_active_vertices_on_level(lvl);
3014 const unsigned int maybe_coarser_lvl = (lvl>0) ? (lvl-1) : lvl;
3016 endc = this->end(lvl);
3017 for (; cell != endc; ++cell)
3018 if (cell->level() ==
static_cast<int>(lvl) || cell->active())
3020 const bool is_level_artificial =
3022 bool need_to_know =
false;
3023 for (
unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
3025 if (active_verts[cell->vertex_index(vertex)])
3027 need_to_know =
true;
3031 Assert(!need_to_know || !is_level_artificial,
3032 ExcMessage(
"Internal error: the owner of cell" 3033 + cell->id().to_string()
3034 +
" is unknown even though it is needed for geometric multigrid."));
3040 refinement_in_progress =
false;
3041 this->update_number_cache ();
3042 this->update_periodic_face_map();
3045 template <
int dim,
int spacedim>
3052 cell = this->begin_active();
3053 cell != this->end(); ++cell)
3054 if (cell->is_locally_owned())
3056 !cell->refine_flag_set() && !cell->coarsen_flag_set(),
3057 ExcMessage (
"Error: There shouldn't be any cells flagged for coarsening/refinement when calling repartition()."));
3060 refinement_in_progress =
true;
3078 const std::vector<unsigned int> cell_weights = get_cell_weights();
3080 PartitionWeights<dim,spacedim> partition_weights (cell_weights);
3084 Assert (parallel_forest->user_pointer ==
this,
3086 parallel_forest->user_pointer = &partition_weights;
3091 &PartitionWeights<dim,spacedim>::cell_weight);
3094 parallel_forest->user_pointer =
this;
3099 copy_local_forest_to_triangulation ();
3108 refinement_in_progress =
false;
3111 this->update_number_cache ();
3112 this->update_periodic_face_map();
3117 template <
int dim,
int spacedim>
3122 Assert (vertex_locally_moved.size() == this->n_vertices(),
3124 this->n_vertices()));
3127 const std::vector<bool> locally_owned_vertices
3129 for (
unsigned int i=0; i<locally_owned_vertices.size(); ++i)
3130 Assert ((vertex_locally_moved[i] ==
false)
3132 (locally_owned_vertices[i] ==
true),
3133 ExcMessage (
"The vertex_locally_moved argument must not " 3134 "contain vertices that are not locally owned"));
3138 std::map<unsigned int, std::set<::types::subdomain_id> >
3139 vertices_with_ghost_neighbors;
3145 cell=this->begin_active(); cell!=this->end();
3147 if (cell->is_ghost())
3148 for (
unsigned int vertex_no=0;
3149 vertex_no<GeometryInfo<dim>::vertices_per_cell; ++vertex_no)
3151 const unsigned int process_local_vertex_no = cell->vertex_index(vertex_no);
3152 vertices_with_ghost_neighbors[process_local_vertex_no].insert
3153 (cell->subdomain_id());
3159 std::map<::types::subdomain_id, CommunicateLocallyMovedVertices::CellInfo<dim,spacedim> > cellmap_t;
3160 cellmap_t needs_to_get_cells;
3163 cell = this->begin(0);
3164 cell != this->end(0);
3167 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
3168 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
3170 CommunicateLocallyMovedVertices::fill_vertices_recursively<dim,spacedim>
3172 this->get_coarse_cell_to_p4est_tree_permutation()[cell->index()],
3175 vertices_with_ghost_neighbors,
3176 vertex_locally_moved,
3177 needs_to_get_cells);
3181 std::vector<std::vector<char> > sendbuffers (needs_to_get_cells.size());
3182 std::vector<std::vector<char> >::iterator buffer = sendbuffers.begin();
3183 std::vector<MPI_Request> requests (needs_to_get_cells.size());
3184 std::vector<unsigned int> destinations;
3188 for (
typename cellmap_t::iterator it=needs_to_get_cells.begin();
3189 it!=needs_to_get_cells.end();
3190 ++it, ++buffer, ++idx)
3192 const unsigned int num_cells = it->second.tree_index.size();
3194 destinations.push_back(it->first);
3206 it->second.pack_data (*buffer);
3207 const int ierr = MPI_Isend(&(*buffer)[0], buffer->size(),
3208 MPI_BYTE, it->first,
3209 123, this->get_communicator(), &requests[idx]);
3217 const std::vector<unsigned int> senders
3219 (this->get_communicator(), destinations);
3222 std::vector<char> receive;
3223 CommunicateLocallyMovedVertices::CellInfo<dim,spacedim> cellinfo;
3224 for (
unsigned int i=0; i<senders.size(); ++i)
3228 int ierr = MPI_Probe(MPI_ANY_SOURCE, 123, this->get_communicator(), &status);
3230 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
3232 receive.resize(len);
3234 char *ptr = &receive[0];
3235 ierr = MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG,
3236 this->get_communicator(), &status);
3239 cellinfo.unpack_data(receive);
3240 const unsigned int cells = cellinfo.tree_index.size();
3241 for (
unsigned int c=0; c<cells; ++c)
3243 typename ::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator
3246 this->get_p4est_tree_to_coarse_cell_permutation()[cellinfo.tree_index[c]]);
3248 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
3249 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
3251 CommunicateLocallyMovedVertices::set_vertices_recursively<dim,spacedim> (*
this,
3254 cellinfo.quadrants[c],
3255 cellinfo.first_vertices[c],
3256 cellinfo.first_vertex_indices[c]);
3262 if (requests.size() > 0)
3264 const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE);
3274 template <
int dim,
int spacedim>
3280 void *)> &pack_callback)
3283 Assert(attached_data_pack_callbacks.size()==n_attached_datas,
3284 ExcMessage(
"register_data_attach(), not all data has been unpacked last time?"));
3286 unsigned int offset = attached_data_size+
sizeof(
CellStatus);
3288 attached_data_size+=size;
3289 attached_data_pack_callbacks.push_back(
3290 std::pair<unsigned int, pack_callback_t> (offset, pack_callback)
3297 template <
int dim,
int spacedim>
3303 const void *)> &unpack_callback)
3306 ExcMessage (
"invalid offset in notify_ready_to_unpack()"));
3308 ExcMessage (
"invalid offset in notify_ready_to_unpack()"));
3309 Assert (n_attached_datas > 0,
ExcMessage (
"notify_ready_to_unpack() called too often"));
3313 cell = this->begin (0);
3314 cell != this->end (0);
3318 if (tree_exists_locally<dim, spacedim> (parallel_forest,
3319 coarse_cell_to_p4est_tree_permutation[cell->index() ])
3323 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
3324 typename ::internal::p4est::types<dim>::tree *tree =
3325 init_tree (cell->index());
3327 ::internal::p4est::init_coarse_quadrant<dim> (p4est_coarse_cell);
3331 post_mesh_data_recursively<dim, spacedim> (*tree,
3340 if (n_attached_deserialize > 0)
3342 --n_attached_deserialize;
3343 attached_data_pack_callbacks.pop_front();
3352 if (!n_attached_datas && n_attached_deserialize == 0)
3355 attached_data_size = 0;
3356 attached_data_pack_callbacks.clear();
3359 void *userptr = parallel_forest->user_pointer;
3361 parallel_forest->user_pointer = userptr;
3366 template <
int dim,
int spacedim>
3367 const std::vector<types::global_dof_index> &
3370 return p4est_tree_to_coarse_cell_permutation;
3375 template <
int dim,
int spacedim>
3376 const std::vector<types::global_dof_index> &
3379 return coarse_cell_to_p4est_tree_permutation;
3387 template <
int dim,
int spacedim>
3391 (std::map<
unsigned int, std::set<::types::subdomain_id> >
3392 &vertices_with_ghost_neighbors)
3398 fg.triangulation =
this;
3399 fg.vertices_with_ghost_neighbors = &vertices_with_ghost_neighbors;
3402 this->parallel_ghost,
3403 static_cast<void *
>(&fg));
3405 sc_array_destroy (fg.subids);
3414 template <
int dim,
int spacedim>
3419 std::map<
unsigned int, std::set<::types::subdomain_id> >
3420 &vertices_with_ghost_neighbors)
3422 const std::vector<bool> locally_active_vertices =
3423 mark_locally_active_vertices_on_level(level);
3425 endc = this->end(level);
3426 for ( ; cell != endc; ++cell)
3427 if (cell->level_subdomain_id() != ::numbers::artificial_subdomain_id
3428 && cell->level_subdomain_id() != this->locally_owned_subdomain())
3429 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
3430 if (locally_active_vertices[cell->vertex_index(v)])
3431 vertices_with_ghost_neighbors[cell->vertex_index(v)]
3432 .insert (cell->level_subdomain_id());
3435 typename std::map<std::pair<cell_iterator, unsigned int>,
3436 std::pair<std::pair<cell_iterator,unsigned int>, std::bitset<3> > >::const_iterator it;
3438 for (it = this->get_periodic_face_map().begin(); it!= this->get_periodic_face_map().end(); ++it)
3441 const unsigned int face_no_1 = it->first.second;
3443 const unsigned int face_no_2 = it->second.first.second;
3444 const std::bitset<3> face_orientation = it->second.second;
3446 if (cell_1->level() == level &&
3447 cell_2->level() == level)
3449 for (
unsigned int v=0; v<
GeometryInfo<dim-1>::vertices_per_cell; ++v)
3452 const unsigned int vface0 =
3454 face_orientation[1],
3455 face_orientation[2]);
3456 const unsigned int idx0 = cell_1->face(face_no_1)->vertex_index(vface0);
3457 const unsigned int idx1 = cell_2->face(face_no_2)->vertex_index(v);
3458 if (vertices_with_ghost_neighbors.find(idx0) != vertices_with_ghost_neighbors.end())
3459 vertices_with_ghost_neighbors[idx1].insert(vertices_with_ghost_neighbors[idx0].begin(),
3460 vertices_with_ghost_neighbors[idx0].end());
3461 if (vertices_with_ghost_neighbors.find(idx1) != vertices_with_ghost_neighbors.end())
3462 vertices_with_ghost_neighbors[idx0].insert(vertices_with_ghost_neighbors[idx1].begin(),
3463 vertices_with_ghost_neighbors[idx1].end());
3471 template<
int dim,
int spacedim>
3478 std::vector<bool> marked_vertices(this->n_vertices(),
false);
3480 endc = this->end(level);
3481 for ( ; cell != endc; ++cell)
3482 if (cell->level_subdomain_id() == this->locally_owned_subdomain())
3483 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
3484 marked_vertices[cell->vertex_index(v)] =
true;
3491 typename std::map<std::pair<cell_iterator, unsigned int>,
3492 std::pair<std::pair<cell_iterator,unsigned int>, std::bitset<3> > >::const_iterator it;
3494 for (it = this->get_periodic_face_map().begin(); it!= this->get_periodic_face_map().end(); ++it)
3497 const unsigned int face_no_1 = it->first.second;
3499 const unsigned int face_no_2 = it->second.first.second;
3500 const std::bitset<3> &face_orientation = it->second.second;
3502 if (cell_1->level() == level &&
3503 cell_2->level() == level)
3505 for (
unsigned int v=0; v<
GeometryInfo<dim-1>::vertices_per_cell; ++v)
3508 const unsigned int vface0 =
3510 face_orientation[1],
3511 face_orientation[2]);
3512 if (marked_vertices[cell_1->face(face_no_1)->vertex_index(vface0)] ||
3513 marked_vertices[cell_2->face(face_no_2)->vertex_index(v)])
3514 marked_vertices[cell_1->face(face_no_1)->vertex_index(vface0)]
3515 = marked_vertices[cell_2->face(face_no_2)->vertex_index(v)]
3521 return marked_vertices;
3526 template<
int dim,
int spacedim>
3532 #if DEAL_II_P4EST_VERSION_GTE(0,3,4,1) 3533 Assert (triangulation_has_content ==
true,
3535 Assert (this->n_levels() == 1,
3536 ExcMessage (
"The triangulation is refined!"));
3538 typedef std::vector<GridTools::PeriodicFacePair<cell_iterator> >
3540 typename FaceVector::const_iterator it, periodic_end;
3541 it = periodicity_vector.begin();
3542 periodic_end = periodicity_vector.end();
3544 for (; it<periodic_end; ++it)
3548 const unsigned int face_left = it->face_idx[0];
3549 const unsigned int face_right = it->face_idx[1];
3552 const unsigned int tree_left
3553 = coarse_cell_to_p4est_tree_permutation[std::distance(this->begin(),
3555 const unsigned int tree_right
3556 = coarse_cell_to_p4est_tree_permutation[std::distance(this->begin(),
3566 unsigned int p4est_orientation = 0;
3568 p4est_orientation = it->orientation[1];
3571 const unsigned int face_idx_list[] = {face_left, face_right};
3572 const cell_iterator cell_list[] = {first_cell, second_cell};
3573 unsigned int lower_idx, higher_idx;
3574 if (face_left<=face_right)
3586 unsigned int first_p4est_idx_on_cell = p8est_face_corners[face_idx_list[lower_idx]][0];
3588 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_face; ++i)
3590 const unsigned int first_dealii_idx_on_cell
3592 (face_idx_list[lower_idx], i,
3593 cell_list[lower_idx]->face_orientation(face_idx_list[lower_idx]),
3594 cell_list[lower_idx]->face_flip(face_idx_list[lower_idx]),
3595 cell_list[lower_idx]->face_rotation(face_idx_list[lower_idx]));
3596 if (first_p4est_idx_on_cell == first_dealii_idx_on_cell)
3598 first_dealii_idx_on_face = i;
3604 const unsigned int left_to_right [8][4] = {{0,2,1,3},{0,1,2,3},{3,1,2,0},{3,2,1,0},
3605 {2,3,0,1},{1,3,0,2},{1,0,3,2},{2,0,3,1}
3607 const unsigned int right_to_left [8][4] = {{0,2,1,3},{0,1,2,3},{3,1,2,0},{3,2,1,0},
3608 {2,3,0,1},{2,0,3,1},{1,0,3,2},{1,3,0,2}
3610 const unsigned int second_dealii_idx_on_face
3611 = lower_idx==0?left_to_right[it->orientation.to_ulong()][first_dealii_idx_on_face]:
3612 right_to_left[it->orientation.to_ulong()][first_dealii_idx_on_face];
3613 const unsigned int second_dealii_idx_on_cell
3615 (face_idx_list[higher_idx], second_dealii_idx_on_face,
3616 cell_list[higher_idx]->face_orientation(face_idx_list[higher_idx]),
3617 cell_list[higher_idx]->face_flip(face_idx_list[higher_idx]),
3618 cell_list[higher_idx]->face_rotation(face_idx_list[higher_idx]));
3620 const unsigned int second_p4est_idx_on_face
3621 = p8est_corner_face_corners[second_dealii_idx_on_cell][face_idx_list[higher_idx]];
3622 p4est_orientation = second_p4est_idx_on_face;
3654 copy_local_forest_to_triangulation ();
3672 template <
int dim,
int spacedim>
3687 + memory_consumption_p4est();
3694 template <
int dim,
int spacedim>
3698 return ::internal::p4est::functions<dim>::forest_memory_used(parallel_forest)
3704 template <
int dim,
int spacedim>
3713 catch (
const typename ::Triangulation<dim,spacedim>::DistortedCellList &)
3723 triangulation_has_content =
true;
3725 Assert (other_tria.n_levels() == 1,
3726 ExcMessage (
"Parallel distributed triangulations can only be copied, " 3727 "if they are not refined!"));
3729 if (const ::parallel::distributed::Triangulation<dim,spacedim> *
3730 other_tria_x =
dynamic_cast<const ::parallel::distributed::Triangulation<dim,spacedim> *
>(&other_tria))
3732 Assert (!other_tria_x->refinement_in_progress,
3733 ExcMessage (
"Parallel distributed triangulations can only " 3734 "be copied, if no refinement is in progress!"));
3736 coarse_cell_to_p4est_tree_permutation = other_tria_x->coarse_cell_to_p4est_tree_permutation;
3737 p4est_tree_to_coarse_cell_permutation = other_tria_x->p4est_tree_to_coarse_cell_permutation;
3738 attached_data_size = other_tria_x->attached_data_size;
3739 n_attached_datas = other_tria_x->n_attached_datas;
3741 settings = other_tria_x->settings;
3745 setup_coarse_cell_to_p4est_tree_permutation ();
3752 copy_local_forest_to_triangulation ();
3761 this->update_number_cache ();
3762 this->update_periodic_face_map();
3766 template <
int dim,
int spacedim>
3773 if (attached_data_size==0)
3782 void *userptr = parallel_forest->user_pointer;
3786 parallel_forest->user_pointer = userptr;
3793 cell = this->begin(0);
3794 cell != this->end(0);
3798 if (tree_exists_locally<dim,spacedim>(parallel_forest,
3799 coarse_cell_to_p4est_tree_permutation[cell->index()])
3803 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
3804 typename ::internal::p4est::types<dim>::tree *tree =
3805 init_tree(cell->index());
3807 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
3809 attach_mesh_data_recursively<dim,spacedim>(*tree,
3812 attached_data_pack_callbacks);
3816 template <
int dim,
int spacedim>
3817 std::vector<unsigned int>
3826 std::vector<unsigned int> weights;
3827 weights.reserve(this->n_active_cells());
3835 for (
unsigned int c=0; c<this->n_cells(0); ++c)
3838 if (tree_exists_locally<dim,spacedim>(parallel_forest,c) ==
false)
3841 const unsigned int coarse_cell_index =
3842 p4est_tree_to_coarse_cell_permutation[c];
3845 dealii_coarse_cell (
this, 0, coarse_cell_index);
3847 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
3852 p4est_coarse_cell.p.which_tree = c;
3854 const typename ::internal::p4est::types<dim>::tree *tree =
3855 init_tree(coarse_cell_index);
3857 get_cell_weights_recursively<dim,spacedim>(*tree,
3869 template <
int spacedim>
3880 template <
int spacedim>
3888 template <
int spacedim>
3891 (
const std::vector<bool> &)
3897 template <
int spacedim>
3898 const std::vector<types::global_dof_index> &
3901 static std::vector<types::global_dof_index> a;
3905 template <
int spacedim>
3909 (std::map<
unsigned int, std::set<::types::subdomain_id> >
3915 template <
int spacedim>
3919 (
const unsigned int ,
3920 std::map<
unsigned int, std::set<::types::subdomain_id> >
3926 template <
int spacedim>
3932 return std::vector<bool>();
3938 #else // DEAL_II_WITH_P4EST 3942 namespace distributed
3944 template <
int dim,
int spacedim>
3954 #endif // DEAL_II_WITH_P4EST 3960 #include "tria.inst" 3963 DEAL_II_NAMESPACE_CLOSE
static unsigned int standard_to_real_face_vertex(const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
virtual void copy_triangulation(const Triangulation< dim, spacedim > &other_tria)
unsigned int n_vertices() const
static const unsigned int invalid_unsigned_int
void fill_vertices_with_ghost_neighbors(std::map< unsigned int, std::set<::types::subdomain_id > > &vertices_with_ghost_neighbors)
virtual bool has_hanging_nodes() const
unsigned int n_cells() const
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
virtual void copy_triangulation(const ::Triangulation< dim, spacedim > &old_tria)
static unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
boost::signals2::signal< unsigned int(const cell_iterator &, const CellStatus), CellWeightSum< unsigned int > > cell_weight
unsigned int attached_data_size
active_cell_iterator begin_active(const unsigned int level=0) const
#define AssertThrow(cond, exc)
callback_list_t attached_data_pack_callbacks
cell_iterator begin(const unsigned int level=0) const
const std::vector< types::global_dof_index > & get_p4est_tree_to_coarse_cell_permutation() const
unsigned int n_levels() const
void fill_level_vertices_with_ghost_neighbors(const int level, std::map< unsigned int, std::set<::types::subdomain_id > > &vertices_with_ghost_neighbors)
cell_iterator end() const
virtual void execute_coarsening_and_refinement()
unsigned int n_active_lines() const
virtual bool prepare_coarsening_and_refinement()
static ::ExceptionBase & ExcMessage(std::string arg1)
Triangulation(const MeshSmoothing smooth_grid=none, const bool check_for_distorted_cells=false)
T sum(const T &t, const MPI_Comm &mpi_communicator)
#define Assert(cond, exc)
virtual void update_number_cache()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void load(Archive &ar, const unsigned int version)
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
const std::vector< Point< spacedim > > & get_vertices() const
virtual std::size_t memory_consumption() const
void save_refine_flags(std::ostream &out) const
virtual std::size_t memory_consumption() const
void save(Archive &ar, const unsigned int version) const
std::vector< unsigned int > invert_permutation(const std::vector< unsigned int > &permutation)
unsigned int subdomain_id
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
::Triangulation< dim, spacedim >::active_cell_iterator active_cell_iterator
const types::subdomain_id artificial_subdomain_id
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void communicate_locally_moved_vertices(const std::vector< bool > &vertex_locally_moved)
#define AssertThrowMPI(error_code)
virtual void add_periodicity(const std::vector< GridTools::PeriodicFacePair< cell_iterator > > &)
const std::vector< bool > & get_used_vertices() const
unsigned int n_attached_datas
::Triangulation< dim, spacedim >::cell_iterator cell_iterator
static ::ExceptionBase & ExcNotImplemented()
active_cell_iterator last_active() const
Triangulation(MPI_Comm mpi_communicator, const typename ::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none), const Settings settings=default_setting)
std::vector< unsigned int > compute_point_to_point_communication_pattern(const MPI_Comm &mpi_comm, const std::vector< unsigned int > &destinations)
std::vector< bool > mark_locally_active_vertices_on_level(const int level) const
T max(const T &t, const MPI_Comm &mpi_communicator)
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
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
static ::ExceptionBase & ExcInternalError()