17 #ifndef dealii_mesh_worker_mesh_loop_h 18 #define dealii_mesh_worker_mesh_loop_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/work_stream.h> 22 #include <deal.II/base/template_constraints.h> 23 #include <deal.II/grid/tria.h> 24 #include <deal.II/grid/filtered_iterator.h> 25 #include <deal.II/meshworker/loop.h> 26 #include <deal.II/meshworker/local_integrator.h> 27 #include <deal.II/meshworker/dof_info.h> 28 #include <deal.II/meshworker/integration_info.h> 29 #include <deal.II/meshworker/assemble_flags.h> 33 DEAL_II_NAMESPACE_OPEN
114 template <
class CellIteratorType,
115 class ScratchData,
class CopyData>
117 const typename identity<CellIteratorType>::type &end,
119 const typename identity<std::function<
void (
const CellIteratorType &, ScratchData &, CopyData &)>>::type &cell_worker,
120 const typename identity<std::function<
void (
const CopyData &)>>::type &copier,
122 const ScratchData &sample_scratch_data,
123 const CopyData &sample_copy_data,
127 const typename identity<std::function<
void (
const CellIteratorType &,
const unsigned int &, ScratchData &, CopyData &)>>::type &boundary_worker=
128 std::function<
void (
const CellIteratorType &,
const unsigned int &, ScratchData &, CopyData &)>(),
130 const typename identity<std::function<
void (
const CellIteratorType &,
const unsigned int &,
const unsigned int &,
131 const CellIteratorType &,
const unsigned int &,
const unsigned int &,
132 ScratchData &, CopyData &)>>::type &face_worker=
133 std::function<
void (
const CellIteratorType &,
const unsigned int &,
const unsigned int &,
134 const CellIteratorType &,
const unsigned int &,
const unsigned int &,
135 ScratchData &, CopyData &)>(),
138 const unsigned int chunk_size = 8)
141 ExcMessage(
"If you specify a cell_worker, you need to set assemble_own_cells or assemble_ghost_cells."));
145 ExcMessage(
"You can only specify assemble_own_interior_faces_once OR assemble_own_interior_faces_both."));
149 ExcMessage(
"You can only specify assemble_ghost_faces_once OR assemble_ghost_faces_both."));
153 ExcMessage(
"The option cells_after_faces only makes sense if you assemble on cells."));
156 ExcMessage(
"If you specify a face_worker, assemble_face_* needs to be set."));
159 ExcMessage(
"If you specify a boundary_worker, assemble_boundary_faces needs to be set."));
161 auto cell_action = [&] (
const CellIteratorType &cell, ScratchData &scratch, CopyData ©)
164 copy = sample_copy_data;
166 const bool ignore_subdomain = (cell->get_triangulation().locally_owned_subdomain()
170 ? cell->level_subdomain_id()
171 : cell->subdomain_id());
173 const bool own_cell = ignore_subdomain || (current_subdomain_id == cell->get_triangulation().locally_owned_subdomain());
181 cell_worker(cell, scratch, copy);
184 for (
unsigned int face_no=0; face_no < GeometryInfo<CellIteratorType::AccessorType::Container::dimension>::faces_per_cell; ++face_no)
186 typename CellIteratorType::AccessorType::Container::face_iterator face = cell->face(face_no);
187 if (cell->at_boundary(face_no) && !cell->has_periodic_neighbor(face_no))
191 boundary_worker(cell, face_no, scratch, copy);
199 if (neighbor->is_level_cell())
200 neighbor_subdomain_id = neighbor->level_subdomain_id();
202 else if (neighbor->active())
203 neighbor_subdomain_id = neighbor->subdomain_id();
205 const bool own_neighbor = ignore_subdomain ||
206 (neighbor_subdomain_id == cell->get_triangulation().locally_owned_subdomain());
209 if (!own_cell && !own_neighbor)
222 const bool periodic_neighbor = cell->has_periodic_neighbor(face_no);
224 if ((!periodic_neighbor && cell->neighbor_is_coarser(face_no))
225 || (periodic_neighbor && cell->periodic_neighbor_is_coarser(face_no)))
235 const std::pair<unsigned int, unsigned int> neighbor_face_no
237 cell->periodic_neighbor_of_coarser_periodic_neighbor(face_no):
238 cell->neighbor_of_coarser_neighbor(face_no);
241 neighbor, neighbor_face_no.first, neighbor_face_no.second,
250 face_worker(neighbor, neighbor_face_no.first, neighbor_face_no.second,
268 if (own_cell && own_neighbor
270 && (neighbor < cell))
281 if (own_cell && !own_neighbor
283 && (neighbor_subdomain_id < current_subdomain_id))
286 const unsigned int neighbor_face_no = periodic_neighbor?
287 cell->periodic_neighbor_face_no(face_no):
288 cell->neighbor_face_no(face_no);
301 cell_worker(cell, scratch, copy);
307 sample_scratch_data, sample_copy_data,
308 queue_length, chunk_size);
312 DEAL_II_NAMESPACE_CLOSE
static const unsigned int invalid_unsigned_int
void mesh_loop(const CellIteratorType &begin, const typename identity< CellIteratorType >::type &end, const typename identity< std::function< void(const CellIteratorType &, ScratchData &, CopyData &)>>::type &cell_worker, const typename identity< std::function< void(const CopyData &)>>::type &copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const AssembleFlags flags=assemble_own_cells, const typename identity< std::function< void(const CellIteratorType &, const unsigned int &, ScratchData &, CopyData &)>>::type &boundary_worker=std::function< void(const CellIteratorType &, const unsigned int &, ScratchData &, CopyData &)>(), const typename identity< std::function< void(const CellIteratorType &, const unsigned int &, const unsigned int &, const CellIteratorType &, const unsigned int &, const unsigned int &, ScratchData &, CopyData &)>>::type &face_worker=std::function< void(const CellIteratorType &, const unsigned int &, const unsigned int &, const CellIteratorType &, const unsigned int &, const unsigned int &, ScratchData &, CopyData &)>(), const unsigned int queue_length=2 *MultithreadInfo::n_threads(), const unsigned int chunk_size=8)
const types::subdomain_id invalid_subdomain_id
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
bool is_active_iterator(const DI &)
unsigned int subdomain_id
const types::subdomain_id artificial_subdomain_id
void run(const std::vector< std::vector< Iterator > > &colored_iterators, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length=2 *MultithreadInfo::n_threads(), const unsigned int chunk_size=8)
static unsigned int n_threads()
void cell_action(ITERATOR cell, DoFInfoBox< dim, DOFINFO > &dof_info, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, const LoopControl &loop_control)
static ::ExceptionBase & ExcInternalError()