16 #include <deal.II/distributed/p4est_wrappers.h> 17 #include <deal.II/distributed/tria.h> 18 #include <deal.II/fe/fe_tools.h> 19 #include <deal.II/grid/tria.h> 20 #include <deal.II/dofs/dof_handler.h> 21 #include <deal.II/dofs/dof_tools.h> 22 #include <deal.II/lac/block_vector.h> 23 #include <deal.II/lac/constraint_matrix.h> 24 #include <deal.II/lac/la_vector.h> 25 #include <deal.II/lac/la_parallel_vector.h> 26 #include <deal.II/lac/la_parallel_block_vector.h> 27 #include <deal.II/lac/petsc_parallel_vector.h> 28 #include <deal.II/lac/petsc_block_vector.h> 29 #include <deal.II/lac/petsc_parallel_block_vector.h> 30 #include <deal.II/lac/trilinos_vector.h> 31 #include <deal.II/lac/trilinos_block_vector.h> 35 DEAL_II_NAMESPACE_OPEN
42 #ifndef DEAL_II_WITH_P4EST 44 template <
int dim,
int spacedim,
class OutVector>
45 class ExtrapolateImplementation
49 ExtrapolateImplementation ()
54 template <
class InVector>
55 void extrapolate_parallel (
const InVector &,
65 template <
int dim,
int spacedim,
class OutVector>
66 class ExtrapolateImplementation
70 ExtrapolateImplementation ();
72 template <
class InVector>
73 void extrapolate_parallel (
const InVector &u2_relevant,
79 typedef typename OutVector::value_type value_type;
85 const typename ::internal::p4est::types<dim>::forest forest;
86 const typename ::internal::p4est::types<dim>::tree tree;
87 const typename ::internal::p4est::types<dim>::locidx tree_index;
89 const typename ::internal::p4est::types<dim>::quadrant p4est_cell;
91 WorkPackage(
const typename ::internal::p4est::types<dim>::forest &forest_,
92 const typename ::internal::p4est::types<dim>::tree &tree_,
93 const typename ::internal::p4est::types<dim>::locidx &tree_index_,
95 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell_)
99 tree_index(tree_index_),
100 dealii_cell(dealii_cell_),
101 p4est_cell(p4est_cell_)
113 CellData (
const unsigned int dofs_per_cell);
117 unsigned int tree_index;
119 typename ::internal::p4est::types<dim>::quadrant quadrant;
123 bool operator < (
const CellData &rhs)
const 131 unsigned int bytes_for_buffer ()
const 133 return (
sizeof(
unsigned int) +
134 dof_values.
size() *
sizeof(value_type) +
135 sizeof(
unsigned int) +
136 sizeof(typename ::internal::p4est::types<dim>::quadrant));
139 void pack_data (std::vector<char> &buffer)
const 141 buffer.resize(bytes_for_buffer());
143 char *ptr = &buffer[0];
145 unsigned int n_dofs = dof_values.
size ();
146 std::memcpy(ptr, &n_dofs,
sizeof(
unsigned int));
147 ptr +=
sizeof(
unsigned int);
149 std::memcpy(ptr,dof_values.
begin(),n_dofs*
sizeof(value_type));
150 ptr += n_dofs*
sizeof(value_type);
152 std::memcpy(ptr,&tree_index,
sizeof(
unsigned int));
153 ptr +=
sizeof(
unsigned int);
155 std::memcpy(ptr,&quadrant,
sizeof(typename ::internal::p4est::types<dim>::quadrant));
156 ptr +=
sizeof(typename ::internal::p4est::types<dim>::quadrant);
158 Assert (ptr == &buffer[0]+buffer.size(),
162 void unpack_data (
const std::vector<char> &buffer)
164 const char *ptr = &buffer[0];
166 memcpy(&n_dofs, ptr,
sizeof(
unsigned int));
167 ptr +=
sizeof(
unsigned int);
169 dof_values.
reinit(n_dofs);
170 std::memcpy(dof_values.
begin(),ptr,n_dofs *
sizeof(value_type));
171 ptr += n_dofs *
sizeof(value_type);
173 std::memcpy(&tree_index,ptr,
sizeof(
unsigned int));
174 ptr +=
sizeof(
unsigned int);
176 std::memcpy(&quadrant,ptr,
sizeof(typename ::internal::p4est::types<dim>::quadrant));
177 ptr +=
sizeof(typename ::internal::p4est::types<dim>::quadrant);
179 Assert (ptr == &buffer[0]+buffer.size(),
232 template <
class InVector>
240 template <
class InVector>
241 void interpolate_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
242 const typename ::internal::p4est::types<dim>::tree &tree,
243 const typename ::internal::p4est::types<dim>::locidx &tree_index,
245 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
254 template <
class InVector>
255 void get_interpolated_dof_values (
const typename ::internal::p4est::types<dim>::forest &forest,
256 const typename ::internal::p4est::types<dim>::tree &tree,
257 const typename ::internal::p4est::types<dim>::locidx &tree_index,
259 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
262 std::vector<CellData> &new_needs);
267 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
276 std::vector<CellData> &new_needs);
281 void traverse_tree_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
282 const typename ::internal::p4est::types<dim>::tree &tree,
283 const typename ::internal::p4est::types<dim>::locidx &tree_index,
285 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
286 std::vector<CellData> &new_needs);
292 void traverse_patch_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
293 const typename ::internal::p4est::types<dim>::tree &tree,
294 const typename ::internal::p4est::types<dim>::locidx &tree_index,
296 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
297 std::vector<CellData> &new_needs);
308 template <
class InVector>
311 std::vector<CellData> &cells_to_compute,
312 std::vector<CellData> &computed_cells,
313 std::vector<CellData> &new_needs);
317 template <
class InVector>
318 void compute_cells_in_tree_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
319 const typename ::internal::p4est::types<dim>::tree &tree,
320 const typename ::internal::p4est::types<dim>::locidx &tree_index,
322 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
324 std::vector<CellData> &cells_to_compute,
325 std::vector<CellData> &computed_cells,
326 std::vector<CellData> &new_needs);
331 void send_cells (
const std::vector<CellData> &cells_to_send,
332 std::vector<CellData> &received_cells)
const;
337 static void add_new_need (
const typename ::internal::p4est::types<dim>::forest &forest,
338 const typename ::internal::p4est::types<dim>::locidx &tree_index,
340 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
341 std::vector<CellData> &new_needs);
346 static int cell_data_search (
const CellData &cell_data,
347 const std::vector<CellData> &cells_list);
353 static void cell_data_insert (
const CellData &cell_data,
354 std::vector<CellData> &cells_list);
356 MPI_Comm communicator;
360 std::vector<CellData> available_cells;
364 std::map<types::global_dof_index, int> dofs_on_refined_neighbors;
370 template <
class OutVector>
371 class ExtrapolateImplementation<1,1,OutVector>
375 ExtrapolateImplementation ()
380 template <
class InVector>
381 void extrapolate_parallel (
const InVector &,
387 template <
class OutVector>
388 class ExtrapolateImplementation<1,2,OutVector>
392 ExtrapolateImplementation ()
397 template <
class InVector>
398 void extrapolate_parallel (
const InVector &,
404 template <
class OutVector>
405 class ExtrapolateImplementation<1,3,OutVector>
409 ExtrapolateImplementation ()
414 template <
class InVector>
415 void extrapolate_parallel (
const InVector &,
423 template <
int dim,
int spacedim,
class OutVector>
424 ExtrapolateImplementation<dim,spacedim,OutVector>::
425 ExtrapolateImplementation ()
431 template <
int dim,
int spacedim,
class OutVector>
432 ExtrapolateImplementation<dim,spacedim,OutVector>::
433 CellData::CellData ()
440 template <
int dim,
int spacedim,
class OutVector>
441 ExtrapolateImplementation<dim,spacedim,OutVector>::
442 CellData::CellData (
const unsigned int dofs_per_cell)
446 dof_values.
reinit (dofs_per_cell);
451 template <
int dim,
int spacedim,
class OutVector>
452 template <
class InVector>
454 ExtrapolateImplementation<dim,spacedim,OutVector>::
455 interpolate_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
456 const typename ::internal::p4est::types<dim>::tree &tree,
457 const typename ::internal::p4est::types<dim>::locidx &tree_index,
459 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
464 int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
470 quadrant_overlaps_tree (
const_cast<typename ::internal::p4est::types<dim>::tree *
>(&tree),
475 bool p4est_has_children = (idx == -1);
477 bool locally_owned_children =
false;
478 if (p4est_has_children)
483 for (
unsigned int child_n=0; child_n<dealii_cell->n_children(); ++child_n)
484 if (dealii_cell->child(child_n)->active())
485 if (dealii_cell->child(child_n)->is_locally_owned())
487 locally_owned_children=
true;
492 if (locally_owned_children)
499 std::vector<CellData> new_needs;
500 get_interpolated_dof_values (forest,
512 Assert (new_needs.size () == 0,
515 set_dof_values_by_interpolation (dealii_cell,
527 template <
int dim,
int spacedim,
class OutVector>
528 template <
class InVector>
530 ExtrapolateImplementation<dim,spacedim,OutVector>::
531 get_interpolated_dof_values (
const typename ::internal::p4est::types<dim>::forest &forest,
532 const typename ::internal::p4est::types<dim>::tree &tree,
533 const typename ::internal::p4est::types<dim>::locidx &tree_index,
535 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
538 std::vector<CellData> &new_needs)
540 if (!dealii_cell->has_children ())
542 if (dealii_cell->is_locally_owned ())
546 dealii_cell->get_dof_values (u, interpolated_values);
550 add_new_need (forest,
562 Assert (interpolated_values.
size() == dofs_per_cell,
564 Assert (u.size() == dealii_cell->get_dof_handler().
n_dofs(),
570 interpolated_values = 0;
571 std::vector<bool> restriction_is_additive (dofs_per_cell);
572 for (
unsigned int i=0; i<dofs_per_cell; ++i)
575 typename ::internal::p4est::types<dim>::quadrant
578 ::internal::p4est::init_quadrant_children<dim> (p4est_cell,
581 bool found_child =
true;
582 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
585 quadrant_overlaps_tree (
const_cast<typename ::internal::p4est::types<dim>::tree *
>(&tree),
596 cell_data.quadrant = p4est_child[c];
597 int pos = cell_data_search (cell_data, available_cells);
605 add_new_need (forest,
607 dealii_cell->child(c),
613 Assert (available_cells[pos].dof_values.
size() == dofs_per_cell,
616 tmp1 = available_cells[pos].dof_values;
625 get_interpolated_dof_values (forest,
628 dealii_cell->child(c),
641 for (
unsigned int i=0; i<dofs_per_cell; ++i)
642 if (tmp2(i) != value_type())
644 if (restriction_is_additive[i])
645 interpolated_values(i) += tmp2(i);
647 interpolated_values(i) = tmp2(i);
652 if (found_child ==
false)
653 interpolated_values = 0;
659 template <
int dim,
int spacedim,
class OutVector>
661 ExtrapolateImplementation<dim,spacedim,OutVector>::
663 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
670 if (!dealii_cell->has_children ())
672 if (dealii_cell->is_locally_owned ())
674 std::vector<types::global_dof_index> indices(dofs_per_cell);
675 dealii_cell->get_dof_indices(indices);
676 for (
unsigned int j=0; j<dofs_per_cell; ++j)
679 const bool on_refined_neighbor
680 = (dofs_on_refined_neighbors.find(indices[j])!=dofs_on_refined_neighbors.end());
681 if (!(on_refined_neighbor && dofs_on_refined_neighbors[indices[j]]>dealii_cell->level()))
682 u(indices[j]) = local_values(j);
690 Assert (u.size() == dealii_cell->get_dof_handler().
n_dofs(),
695 typename ::internal::p4est::types<dim>::quadrant
698 ::internal::p4est::init_quadrant_children<dim> (p4est_cell,
701 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
705 .vmult (tmp, local_values);
707 set_dof_values_by_interpolation (dealii_cell->child(c),
717 template <
int dim,
int spacedim,
class OutVector>
719 ExtrapolateImplementation<dim,spacedim,OutVector>::
721 std::vector<CellData> &new_needs)
732 for (; cell!=endc; ++cell)
739 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
741 typename ::internal::p4est::types<dim>::tree *tree = tr->
init_tree(cell->index());
743 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
751 int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree->quadrants),
769 template <
int dim,
int spacedim,
class OutVector>
771 ExtrapolateImplementation<dim,spacedim,OutVector>::
772 traverse_tree_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
773 const typename ::internal::p4est::types<dim>::tree &tree,
774 const typename ::internal::p4est::types<dim>::locidx &tree_index,
776 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
777 std::vector<CellData> &new_needs)
780 int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
786 quadrant_overlaps_tree (
const_cast<typename ::internal::p4est::types<dim>::tree *
>(&tree),
791 bool p4est_has_children = (idx == -1);
797 bool locally_owned_children =
false;
798 if (p4est_has_children)
802 for (
unsigned int child_n=0; child_n<dealii_cell->n_children(); ++child_n)
803 if (dealii_cell->child(child_n)->active())
804 if (dealii_cell->child(child_n)->is_locally_owned())
806 locally_owned_children=
true;
814 if (locally_owned_children)
816 traverse_patch_recursively (forest,
825 if (p4est_has_children)
827 typename ::internal::p4est::types<dim>::quadrant
830 ::internal::p4est::init_quadrant_children<dim> (p4est_cell,
833 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
835 traverse_tree_recursively (forest,
838 dealii_cell->child(c),
847 template <
int dim,
int spacedim,
class OutVector>
849 ExtrapolateImplementation<dim,spacedim,OutVector>::
850 traverse_patch_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
851 const typename ::internal::p4est::types<dim>::tree &tree,
852 const typename ::internal::p4est::types<dim>::locidx &tree_index,
854 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
855 std::vector<CellData> &new_needs)
857 if (dealii_cell->has_children ())
861 typename ::internal::p4est::types<dim>::quadrant
864 ::internal::p4est::init_quadrant_children<dim> (p4est_cell,
867 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
873 quadrant_overlaps_tree (
const_cast<typename ::internal::p4est::types<dim>::tree *
>(&tree),
880 add_new_need (forest,
882 dealii_cell->child(c),
891 traverse_patch_recursively (forest,
894 dealii_cell->child(c),
904 template <
int dim,
int spacedim,
class OutVector>
905 template <
class InVector>
907 ExtrapolateImplementation<dim,spacedim,OutVector>::
910 std::vector<CellData> &cells_to_compute,
911 std::vector<CellData> &computed_cells,
912 std::vector<CellData> &new_needs)
922 std::set<unsigned int> trees;
923 for (
typename std::vector<CellData>::const_iterator it=cells_to_compute.begin(); it!=cells_to_compute.end(); ++it)
924 trees.insert (it->tree_index);
929 for (; cell!=endc; ++cell)
935 if ((trees.find (tree_index) == trees.end ())
942 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
943 typename ::internal::p4est::types<dim>::tree *tree = tr->
init_tree(cell->index());
945 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
961 template <
int dim,
int spacedim,
class OutVector>
962 template <
class InVector>
964 ExtrapolateImplementation<dim,spacedim,OutVector>::
965 compute_cells_in_tree_recursively (
const typename ::internal::p4est::types<dim>::forest &forest,
966 const typename ::internal::p4est::types<dim>::tree &tree,
967 const typename ::internal::p4est::types<dim>::locidx &tree_index,
969 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
971 std::vector<CellData> &cells_to_compute,
972 std::vector<CellData> &computed_cells,
973 std::vector<CellData> &new_needs)
975 if (cells_to_compute.size () == 0)
979 int idx = sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
985 quadrant_overlaps_tree (
const_cast<typename ::internal::p4est::types<dim>::tree *
>(&tree),
990 bool p4est_has_children = (idx == -1);
994 cell_data.quadrant = p4est_cell;
995 int pos = cell_data_search (cell_data, cells_to_compute);
998 std::vector<CellData> tmp;
1000 get_interpolated_dof_values (forest,
1006 cells_to_compute[pos].dof_values,
1013 if (tmp.size () == 0)
1015 cell_data_insert (cells_to_compute[pos], computed_cells);
1016 cells_to_compute.erase (cells_to_compute.begin () + pos);
1020 for (
unsigned int i=0; i<tmp.size (); ++i)
1021 cell_data_insert (tmp[i], new_needs);
1026 if (p4est_has_children)
1028 typename ::internal::p4est::types<dim>::quadrant
1031 ::internal::p4est::init_quadrant_children<dim> (p4est_cell,
1034 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
1036 compute_cells_in_tree_recursively (forest,
1039 dealii_cell->child(c),
1051 template <
int dim,
int spacedim,
class OutVector>
1053 ExtrapolateImplementation<dim,spacedim,OutVector>::
1054 send_cells (
const std::vector<CellData> &cells_to_send,
1055 std::vector<CellData> &received_cells)
const 1057 std::vector<std::vector<char> > sendbuffers (cells_to_send.size());
1058 std::vector<std::vector<char> >::iterator buffer = sendbuffers.begin();
1059 std::vector<MPI_Request> requests (cells_to_send.size());
1060 std::vector<unsigned int> destinations;
1064 for (
typename std::vector<CellData>::const_iterator it=cells_to_send.begin();
1065 it!=cells_to_send.end();
1068 destinations.push_back (it->receiver);
1070 it->pack_data (*buffer);
1071 const int ierr = MPI_Isend (&(*buffer)[0], buffer->size(),
1082 std::vector<unsigned int> senders
1086 std::vector<char> receive;
1088 for (
unsigned int index=0; index<senders.size (); ++index)
1092 int ierr = MPI_Probe(MPI_ANY_SOURCE, round, communicator, &status);
1094 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
1096 receive.resize (len);
1098 char *buf = &receive[0];
1099 ierr = MPI_Recv (buf, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, communicator, &status);
1102 cell_data.unpack_data (receive);
1107 cell_data.receiver = status.MPI_SOURCE;
1109 received_cells.push_back (cell_data);
1112 if (requests.size () > 0)
1114 const int ierr = MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE);
1119 std::sort (received_cells.begin (), received_cells.end ());
1124 template <
int dim,
int spacedim,
class OutVector>
1126 ExtrapolateImplementation<dim,spacedim,OutVector>::
1127 add_new_need (
const typename ::internal::p4est::types<dim>::forest &forest,
1128 const typename ::internal::p4est::types<dim>::locidx &tree_index,
1130 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell,
1131 std::vector<CellData> &new_needs)
1136 CellData cell_data (dofs_per_cell);
1137 cell_data.quadrant = p4est_cell;
1138 cell_data.tree_index = tree_index;
1140 comm_find_owner (
const_cast<typename ::internal::p4est::types<dim>::forest *
> (&forest),
1143 dealii_cell->level_subdomain_id ());
1145 cell_data_insert (cell_data, new_needs);
1150 template <
int dim,
int spacedim,
class OutVector>
1152 ExtrapolateImplementation<dim,spacedim,OutVector>::
1153 cell_data_search (
const CellData &cell_data,
1154 const std::vector<CellData> &cells_list)
1156 typename std::vector<CellData>::const_iterator bound
1157 = std::lower_bound (cells_list.begin(), cells_list.end(), cell_data);
1159 if ((bound != cells_list.end ())
1161 !(cell_data < *bound))
1162 return (
int)(bound - cells_list.begin ());
1169 template <
int dim,
int spacedim,
class OutVector>
1171 ExtrapolateImplementation<dim,spacedim,OutVector>::
1172 cell_data_insert (
const CellData &cell_data,
1173 std::vector<CellData> &cells_list)
1175 typename std::vector<CellData>::iterator bound
1176 = std::lower_bound (cells_list.begin(), cells_list.end(), cell_data);
1178 if ((bound == cells_list.end ())
1180 (cell_data < *bound))
1181 cells_list.insert (bound, 1, cell_data);
1186 template <
int dim,
int spacedim,
class OutVector>
1187 template <
class InVector>
1189 ExtrapolateImplementation<dim,spacedim,OutVector>::
1193 std::vector<CellData> cells_we_need,
1205 compute_needs (dof2, cells_we_need);
1209 send_cells (cells_we_need, received_needs);
1222 unsigned int ready = 0;
1225 for (
unsigned int i=0; i<received_needs.size(); ++i)
1226 cell_data_insert (received_needs[i], cells_to_compute);
1228 compute_cells (dof2, u, cells_to_compute, computed_cells, new_needs);
1233 for (
typename std::vector<CellData>::const_iterator comp=computed_cells.begin ();
1234 comp != computed_cells.end ();
1238 cell_data_insert (*comp, available_cells);
1242 typename std::vector<CellData>::iterator recv=received_needs.begin();
1243 while (recv != received_needs.end())
1245 if (::internal::p4est::quadrant_is_equal<dim>(recv->quadrant, comp->quadrant))
1247 recv->dof_values = comp->dof_values;
1248 cells_to_send.push_back (*recv);
1249 received_needs.erase (recv);
1250 recv = received_needs.begin();
1261 send_cells (cells_to_send, received_cells);
1264 for (
typename std::vector<CellData>::const_iterator recv=received_cells.begin ();
1265 recv != received_cells.end ();
1268 cell_data_insert (*recv, available_cells);
1276 send_cells (new_needs, received_needs);
1283 template <
int dim,
int spacedim,
class OutVector>
1284 template <
class InVector>
1286 ExtrapolateImplementation<dim,spacedim,OutVector>::
1287 extrapolate_parallel (
const InVector &u2_relevant,
1296 ExcMessage (
"Extrapolate in parallel only works for parallel distributed triangulations!"));
1300 compute_all_non_local_data (dof2, u2_relevant);
1305 if (dofs_per_face > 0)
1308 std::vector<types::global_dof_index> indices (dofs_per_cell);
1312 for (; cell!=endc; ++cell)
1313 if (cell->is_ghost())
1315 cell->get_dof_indices(indices);
1316 for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
1317 if (!cell->at_boundary(face))
1320 if (neighbor->level() != cell->level())
1321 for (
unsigned int i=0; i<dofs_per_face; ++i)
1324 const bool index_stored
1325 = (dofs_on_refined_neighbors.find(index)!=dofs_on_refined_neighbors.end());
1326 const unsigned int level = index_stored ?
1327 std::max(cell->level(), dofs_on_refined_neighbors[index]) :
1329 dofs_on_refined_neighbors[index] = level;
1341 std::queue<WorkPackage> queue;
1346 for (; cell!=endc; ++cell)
1353 typename ::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
1355 typename ::internal::p4est::types<dim>::tree *tree = tr->
init_tree(cell->index());
1357 ::internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
1359 const WorkPackage data (*tr->
parallel_forest, *tree,tree_index,cell,p4est_coarse_cell);
1365 while (!queue.empty())
1367 const WorkPackage &data = queue.front();
1369 const typename ::internal::p4est::types<dim>::forest &forest = data.forest;
1370 const typename ::internal::p4est::types<dim>::tree &tree = data.tree;
1371 const typename ::internal::p4est::types<dim>::locidx &tree_index= data.tree_index;
1373 const typename ::internal::p4est::types<dim>::quadrant &p4est_cell = data.p4est_cell;
1375 interpolate_recursively (forest, tree, tree_index, dealii_cell, p4est_cell, u2_relevant, u2);
1378 if (dealii_cell->has_children())
1381 typename ::internal::p4est::types<dim>::quadrant
1384 ::internal::p4est::init_quadrant_children<dim> (p4est_cell,
1387 for (
unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
1388 queue.push(WorkPackage(forest, tree, tree_index, dealii_cell->child(c), p4est_child[c]));
1396 #endif //DEAL_II_WITH_P4EST 1400 template <
class VectorType,
class DH>
1401 void reinit_distributed(
const DH &dh,
1404 vector.reinit(dh.n_dofs());
1407 #ifdef DEAL_II_WITH_PETSC 1408 template <
int dim,
int spacedim>
1419 #endif //DEAL_II_WITH_PETSC 1421 #ifdef DEAL_II_WITH_TRILINOS 1422 template <
int dim,
int spacedim>
1433 #endif //DEAL_II_WITH_TRILINOS 1435 template <
int dim,
int spacedim,
typename Number>
1449 template <
class VectorType,
class DH>
1450 void reinit_ghosted(
const DH &,
1456 #ifdef DEAL_II_WITH_PETSC 1457 template <
int dim,
int spacedim>
1467 vector.
reinit (locally_owned_dofs, locally_relevant_dofs,
1470 #endif //DEAL_II_WITH_PETSC 1472 #ifdef DEAL_II_WITH_TRILINOS 1473 template <
int dim,
int spacedim>
1483 vector.
reinit (locally_owned_dofs, locally_relevant_dofs,
1486 #endif //DEAL_II_WITH_TRILINOS 1488 template <
int dim,
int spacedim,
typename Number>
1498 vector.
reinit (locally_owned_dofs, locally_relevant_dofs,
1504 template <
int dim,
class InVector,
class OutVector,
int spacedim>
1505 void extrapolate_serial(
const InVector &u3,
1509 const unsigned int dofs_per_cell = dof2.
get_fe().dofs_per_cell;
1513 for (
unsigned int level=0; level<dof2.
get_triangulation().n_levels()-1; ++level)
1516 endc=dof2.
end(level);
1518 for (; cell!=endc; ++cell)
1519 if (!cell->active())
1524 bool active_children=
false;
1525 for (
unsigned int child_n=0; child_n<cell->n_children(); ++child_n)
1526 if (cell->child(child_n)->active())
1528 active_children=
true;
1539 if (active_children)
1541 cell->get_interpolated_dof_values(u3, dof_values);
1542 cell->set_dof_values_by_interpolation(dof_values, u2);
1550 template <
int dim,
class InVector,
class OutVector,
int spacedim>
1563 template <
int dim,
class InVector,
class OutVector,
int spacedim>
1581 for (; cell!=endc; ++cell)
1587 internal::reinit_distributed(dof2, u3);
1592 OutVector u3_relevant;
1593 internal::reinit_ghosted(dof2, u3_relevant);
1596 internal::ExtrapolateImplementation<dim,spacedim,OutVector> implementation;
1597 implementation.extrapolate_parallel (u3_relevant, dof2, u2);
1603 internal::extrapolate_serial (u3, dof2, u2);
1612 #include "fe_tools_extrapolate.inst" 1617 DEAL_II_NAMESPACE_CLOSE
void reinit(const size_type size, const bool omit_zeroing_entries=false)
bool restriction_is_additive(const unsigned int index) const
static ::ExceptionBase & ExcGridNotRefinedAtLeastOnce()
cell_iterator begin(const unsigned int level=0) const
const Triangulation< dim, spacedim > & get_tria() const 1
cell_iterator end() const
ActiveSelector::active_cell_iterator active_cell_iterator
#define AssertThrow(cond, exc)
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
const FiniteElement< dim, spacedim > & get_fe() const
typename ::internal::p4est::types< dim >::forest * parallel_forest
void reinit(const VectorBase &v, const bool omit_zeroing_entries=false, const bool allow_different_maps=false)
active_cell_iterator begin_active(const unsigned int level=0) const
static ::ExceptionBase & ExcMessage(std::string arg1)
ActiveSelector::cell_iterator cell_iterator
T sum(const T &t, const MPI_Comm &mpi_communicator)
unsigned int global_dof_index
#define Assert(cond, exc)
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual MPI_Comm get_communicator() const
types::global_dof_index n_dofs() const
typename ::internal::p4est::types< dim >::tree * init_tree(const int dealii_coarse_cell_index) const
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false) const
const unsigned int dofs_per_cell
void distribute(VectorType &vec) const
#define AssertThrowMPI(error_code)
void reinit(const MPI_Comm &communicator, const size_type N, const size_type local_size, const bool omit_zeroing_entries=false)
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
const unsigned int dofs_per_face
static ::ExceptionBase & ExcNotImplemented()
const Triangulation< dim, spacedim > & get_triangulation() const
std::vector< unsigned int > compute_point_to_point_communication_pattern(const MPI_Comm &mpi_comm, const std::vector< unsigned int > &destinations)
const IndexSet & locally_owned_dofs() const
static ::ExceptionBase & ExcTriangulationMismatch()
std::vector< types::global_dof_index > coarse_cell_to_p4est_tree_permutation
static ::ExceptionBase & ExcInternalError()