17 #ifndef dealii__mesh_worker_loop_h 18 #define dealii__mesh_worker_loop_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/std_cxx11/function.h> 22 #include <deal.II/base/work_stream.h> 23 #include <deal.II/base/template_constraints.h> 24 #include <deal.II/grid/tria.h> 25 #include <deal.II/grid/filtered_iterator.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> 31 #define DEAL_II_MESHWORKER_PARALLEL 1 33 DEAL_II_NAMESPACE_OPEN
48 template <
class ACCESSOR>
54 template <
class ACCESSOR>
60 template<
int dim,
class DOFINFO,
class A>
174 template<
class INFOBOX,
class DOFINFO,
int dim,
int spacedim,
class ITERATOR>
179 const std_cxx11::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &cell_worker,
180 const std_cxx11::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &boundary_worker,
181 const std_cxx11::function<
void (DOFINFO &, DOFINFO &,
182 typename INFOBOX::CellInfo &,
183 typename INFOBOX::CellInfo &)> &face_worker,
186 const bool ignore_subdomain = (cell->get_triangulation().locally_owned_subdomain()
190 ? cell->level_subdomain_id()
191 : cell->subdomain_id();
193 const bool own_cell = ignore_subdomain || (csid == cell->get_triangulation().locally_owned_subdomain());
200 dof_info.
cell.reinit(cell);
203 const bool integrate_cell = (cell_worker != 0);
204 const bool integrate_boundary = (boundary_worker != 0);
205 const bool integrate_interior_face = (face_worker != 0);
208 info.cell.reinit(dof_info.
cell);
214 cell_worker(dof_info.
cell, info.cell);
220 info.post_cell(dof_info);
222 if (integrate_interior_face || integrate_boundary)
223 for (
unsigned int face_no=0; face_no < GeometryInfo<ITERATOR::AccessorType::Container::dimension>::faces_per_cell; ++face_no)
225 typename ITERATOR::AccessorType::Container::face_iterator face = cell->face(face_no);
226 if (cell->at_boundary(face_no) && !cell->has_periodic_neighbor(face_no))
229 if (integrate_boundary && own_cell)
232 dof_info.
interior[face_no].reinit(cell, face, face_no);
233 info.boundary.reinit(dof_info.
interior[face_no]);
234 boundary_worker(dof_info.
interior[face_no], info.boundary);
237 else if (integrate_interior_face)
243 if (neighbor->is_level_cell())
244 neighbid = neighbor->level_subdomain_id();
246 else if (neighbor->active())
247 neighbid = neighbor->subdomain_id();
249 const bool own_neighbor = ignore_subdomain ||
250 (neighbid == cell->get_triangulation().locally_owned_subdomain());
253 if (!own_cell && !own_neighbor)
266 const bool periodic_neighbor = cell->has_periodic_neighbor(face_no);
268 if ((!periodic_neighbor && cell->neighbor_is_coarser(face_no))
269 || (periodic_neighbor && cell->periodic_neighbor_is_coarser(face_no)))
280 const std::pair<unsigned int, unsigned int> neighbor_face_no
282 cell->periodic_neighbor_of_coarser_periodic_neighbor(face_no):
283 cell->neighbor_of_coarser_neighbor(face_no);
284 const typename ITERATOR::AccessorType::Container::face_iterator nface
285 = neighbor->face(neighbor_face_no.first);
289 dof_info.
interior[face_no].reinit(cell, face, face_no);
290 info.face.reinit(dof_info.
interior[face_no]);
292 neighbor, nface, neighbor_face_no.first, neighbor_face_no.second);
293 info.subface.reinit(dof_info.
exterior[face_no]);
296 info.face, info.subface);
305 "Assembling from both sides for own_faces is not " 306 "supported with hanging nodes!"));
316 if (own_cell && own_neighbor
318 && (neighbor < cell))
330 if (own_cell && !own_neighbor
332 && (neighbid < csid))
335 const unsigned int neighbor_face_no = periodic_neighbor?
336 cell->periodic_neighbor_face_no(face_no):
337 cell->neighbor_face_no(face_no);
342 dof_info.
interior[face_no].reinit(cell, face, face_no);
343 info.face.reinit(dof_info.
interior[face_no]);
345 neighbor, neighbor->face(neighbor_face_no), neighbor_face_no);
346 info.neighbor.reinit(dof_info.
exterior[face_no]);
349 info.face, info.neighbor);
357 info.post_faces(dof_info);
363 cell_worker(dof_info.
cell, info.cell);
382 template<
int dim,
int spacedim,
class DOFINFO,
class INFOBOX,
class ASSEMBLER,
class ITERATOR>
384 typename identity<ITERATOR>::type end,
387 const std_cxx11::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &cell_worker,
388 const std_cxx11::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &boundary_worker,
389 const std_cxx11::function<
void (DOFINFO &, DOFINFO &,
390 typename INFOBOX::CellInfo &,
391 typename INFOBOX::CellInfo &)> &face_worker,
392 ASSEMBLER &assembler,
397 assembler.initialize_info(dof_info.
cell,
false);
398 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
400 assembler.initialize_info(dof_info.
interior[i],
true);
401 assembler.initialize_info(dof_info.
exterior[i],
true);
405 #ifdef DEAL_II_MESHWORKER_PARALLEL 407 std_cxx11::bind(&cell_action<INFOBOX, DOFINFO, dim, spacedim, ITERATOR>,
408 std_cxx11::_1, std_cxx11::_3, std_cxx11::_2,
409 cell_worker, boundary_worker, face_worker, lctrl),
410 std_cxx11::bind(&internal::assemble<dim,DOFINFO,ASSEMBLER>, std_cxx11::_1, &assembler),
413 for (ITERATOR cell = begin; cell != end; ++cell)
415 cell_action<INFOBOX,DOFINFO,dim,spacedim>(cell, dof_info,
417 boundary_worker, face_worker,
419 dof_info.assemble(assembler);
432 template<
int dim,
int spacedim,
class ITERATOR,
class ASSEMBLER>
434 typename identity<ITERATOR>::type end,
438 ASSEMBLER &assembler,
443 std_cxx11::function<void (DoFInfo<dim> &,
DoFInfo<dim> &,
466 DEAL_II_NAMESPACE_CLOSE
const types::subdomain_id invalid_subdomain_id
bool exterior_face_available[GeometryInfo< dim >::faces_per_cell]
static ::ExceptionBase & ExcMessage(std::string arg1)
void cell_action(ITERATOR cell, DoFInfoBox< dim, DOFINFO > &dof_info, INFOBOX &info, const std_cxx11::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std_cxx11::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std_cxx11::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, const LoopControl &loop_control)
bool interior_face_available[GeometryInfo< dim >::faces_per_cell]
#define Assert(cond, exc)
bool is_active_iterator(const DI &)
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std_cxx11::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std_cxx11::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std_cxx11::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
void assemble(ASSEMBLER &ass) const
unsigned int subdomain_id
const types::subdomain_id artificial_subdomain_id
DOFINFO interior[GeometryInfo< dim >::faces_per_cell]
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)
void integration_loop(ITERATOR begin, typename identity< ITERATOR >::type end, DoFInfo< dim, spacedim > &dof_info, IntegrationInfoBox< dim, spacedim > &box, const LocalIntegrator< dim, spacedim > &integrator, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
DOFINFO exterior[GeometryInfo< dim >::faces_per_cell]
FaceOption faces_to_ghost
static ::ExceptionBase & ExcInternalError()