17 #ifndef dealii_mesh_worker_loop_h
18 #define dealii_mesh_worker_loop_h
20 #include <deal.II/base/config.h>
22 #include <deal.II/base/template_constraints.h>
23 #include <deal.II/base/work_stream.h>
25 #include <deal.II/grid/filtered_iterator.h>
26 #include <deal.II/grid/tria.h>
28 #include <deal.II/meshworker/dof_info.h>
29 #include <deal.II/meshworker/integration_info.h>
30 #include <deal.II/meshworker/local_integrator.h>
34 DEAL_II_NAMESPACE_OPEN
51 template <
class ACCESSOR>
58 template <
class ACCESSOR>
66 template <
int dim,
class DOFINFO,
class A>
188 template <
class INFOBOX,
class DOFINFO,
int dim,
int spacedim,
class ITERATOR>
194 const std::function<
void(DOFINFO &,
typename INFOBOX::CellInfo &)>
196 const std::function<
void(DOFINFO &,
typename INFOBOX::CellInfo &)>
198 const std::function<
void(DOFINFO &,
200 typename INFOBOX::CellInfo &,
201 typename INFOBOX::CellInfo &)> &face_worker,
204 const bool ignore_subdomain =
205 (cell->get_triangulation().locally_owned_subdomain() ==
209 cell->level_subdomain_id() :
210 cell->subdomain_id();
212 const bool own_cell =
214 (csid == cell->get_triangulation().locally_owned_subdomain());
221 dof_info.
cell.reinit(cell);
224 const bool integrate_cell = (cell_worker !=
nullptr);
225 const bool integrate_boundary = (boundary_worker !=
nullptr);
226 const bool integrate_interior_face = (face_worker !=
nullptr);
229 info.cell.reinit(dof_info.
cell);
236 cell_worker(dof_info.
cell, info.cell);
242 info.post_cell(dof_info);
244 if (integrate_interior_face || integrate_boundary)
245 for (
unsigned int face_no = 0;
248 ITERATOR::AccessorType::Container::dimension>::faces_per_cell;
251 typename ITERATOR::AccessorType::Container::face_iterator face =
253 if (cell->at_boundary(face_no) &&
254 !cell->has_periodic_neighbor(face_no))
257 if (integrate_boundary && own_cell)
260 dof_info.
interior[face_no].reinit(cell, face, face_no);
261 info.boundary.reinit(dof_info.
interior[face_no]);
262 boundary_worker(dof_info.
interior[face_no], info.boundary);
265 else if (integrate_interior_face)
269 cell->neighbor_or_periodic_neighbor(face_no);
272 if (neighbor->is_level_cell())
273 neighbid = neighbor->level_subdomain_id();
275 else if (neighbor->active())
276 neighbid = neighbor->subdomain_id();
278 const bool own_neighbor =
281 cell->get_triangulation().locally_owned_subdomain());
284 if (!own_cell && !own_neighbor)
288 if (own_cell && own_neighbor &&
293 if (own_cell != own_neighbor &&
300 const bool periodic_neighbor =
301 cell->has_periodic_neighbor(face_no);
303 if ((!periodic_neighbor && cell->neighbor_is_coarser(face_no)) ||
304 (periodic_neighbor &&
305 cell->periodic_neighbor_is_coarser(face_no)))
316 const std::pair<unsigned int, unsigned int> neighbor_face_no =
318 cell->periodic_neighbor_of_coarser_periodic_neighbor(
320 cell->neighbor_of_coarser_neighbor(face_no);
321 const typename ITERATOR::AccessorType::Container::
322 face_iterator nface =
323 neighbor->face(neighbor_face_no.first);
327 dof_info.
interior[face_no].reinit(cell, face, face_no);
328 info.face.reinit(dof_info.
interior[face_no]);
329 dof_info.
exterior[face_no].reinit(neighbor,
331 neighbor_face_no.first,
332 neighbor_face_no.second);
333 info.subface.reinit(dof_info.
exterior[face_no]);
335 face_worker(dof_info.
interior[face_no],
345 neighbor->has_children())
350 "Assembling from both sides for own_faces is not "
351 "supported with hanging nodes!"));
356 Assert(cell->level() == neighbor->level(),
362 if (own_cell && own_neighbor &&
376 if (own_cell && !own_neighbor &&
381 const unsigned int neighbor_face_no =
383 cell->periodic_neighbor_face_no(face_no) :
384 cell->neighbor_face_no(face_no);
385 Assert(periodic_neighbor ||
386 neighbor->face(neighbor_face_no) == face,
391 dof_info.
interior[face_no].reinit(cell, face, face_no);
392 info.face.reinit(dof_info.
interior[face_no]);
393 dof_info.
exterior[face_no].reinit(neighbor,
397 info.neighbor.reinit(dof_info.
exterior[face_no]);
399 face_worker(dof_info.
interior[face_no],
410 info.post_faces(dof_info);
417 cell_worker(dof_info.
cell, info.cell);
444 typename identity<ITERATOR>::type end,
447 const std::function<
void(DOFINFO &,
typename INFOBOX::CellInfo &)>
449 const std::function<
void(DOFINFO &,
typename INFOBOX::CellInfo &)>
451 const std::function<
void(DOFINFO &,
453 typename INFOBOX::CellInfo &,
454 typename INFOBOX::CellInfo &)> &face_worker,
455 ASSEMBLER & assembler,
460 assembler.initialize_info(dof_info.
cell,
false);
461 for (
unsigned int i = 0; i < GeometryInfo<dim>::faces_per_cell; ++i)
463 assembler.initialize_info(dof_info.
interior[i],
true);
464 assembler.initialize_info(dof_info.
exterior[i],
true);
471 std::bind(&cell_action<INFOBOX, DOFINFO, dim, spacedim, ITERATOR>,
472 std::placeholders::_1,
473 std::placeholders::_3,
474 std::placeholders::_2,
479 std::bind(&internal::assemble<dim, DOFINFO, ASSEMBLER>,
480 std::placeholders::_1,
494 template <
int dim,
int spacedim,
class ITERATOR,
class ASSEMBLER>
497 typename identity<ITERATOR>::type end,
501 ASSEMBLER & assembler,
518 std::placeholders::_1,
519 std::placeholders::_2);
523 std::placeholders::_1,
524 std::placeholders::_2);
528 std::placeholders::_1,
529 std::placeholders::_2,
530 std::placeholders::_3,
531 std::placeholders::_4);
533 loop<dim, spacedim>(begin,
546 DEAL_II_NAMESPACE_CLOSE