18 #ifndef __deal2__mesh_worker_loop_h
19 #define __deal2__mesh_worker_loop_h
21 #include <deal.II/base/config.h>
22 #include <deal.II/base/std_cxx1x/function.h>
23 #include <deal.II/base/work_stream.h>
24 #include <deal.II/base/template_constraints.h>
25 #include <deal.II/grid/tria.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
49 template <
class ACCESSOR>
55 template <
class ACCESSOR>
61 template<
int dim,
class DOFINFO,
class A>
108 template<
class INFOBOX,
class DOFINFO,
int dim,
int spacedim,
class ITERATOR>
113 const std_cxx1x::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &cell_worker,
114 const std_cxx1x::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &boundary_worker,
115 const std_cxx1x::function<
void (DOFINFO &, DOFINFO &,
116 typename INFOBOX::CellInfo &,
117 typename INFOBOX::CellInfo &)> &face_worker,
118 const bool cells_first,
119 const bool unique_faces_only)
121 const bool integrate_cell = (cell_worker != 0);
122 const bool integrate_boundary = (boundary_worker != 0);
123 const bool integrate_interior_face = (face_worker != 0);
127 dof_info.
cell.reinit(cell);
129 info.cell.reinit(dof_info.
cell);
133 if (integrate_cell && cells_first)
134 cell_worker(dof_info.
cell, info.cell);
140 info.post_cell(dof_info);
142 if (integrate_interior_face || integrate_boundary)
143 for (
unsigned int face_no=0; face_no < GeometryInfo<ITERATOR::AccessorType::Container::dimension>::faces_per_cell; ++face_no)
145 typename ITERATOR::AccessorType::Container::face_iterator face = cell->face(face_no);
146 if (cell->at_boundary(face_no))
148 if (integrate_boundary)
151 dof_info.
interior[face_no].reinit(cell, face, face_no);
152 info.boundary.reinit(dof_info.
interior[face_no]);
153 boundary_worker(dof_info.
interior[face_no], info.boundary);
156 else if (integrate_interior_face)
171 if (cell->neighbor_is_coarser(face_no))
176 const std::pair<unsigned int, unsigned int> neighbor_face_no
177 = cell->neighbor_of_coarser_neighbor(face_no);
178 const typename ITERATOR::AccessorType::Container::face_iterator nface
179 = neighbor->face(neighbor_face_no.first);
183 dof_info.
interior[face_no].reinit(cell, face, face_no);
184 info.face.reinit(dof_info.
interior[face_no]);
186 neighbor, nface, neighbor_face_no.first, neighbor_face_no.second);
187 info.subface.reinit(dof_info.
exterior[face_no]);
190 info.face, info.subface);
199 if (unique_faces_only && (neighbor < cell))
continue;
210 const unsigned int neighbor_face_no = cell->neighbor_face_no(face_no);
215 dof_info.
interior[face_no].reinit(cell, face, face_no);
216 info.face.reinit(dof_info.
interior[face_no]);
218 neighbor, neighbor->face(neighbor_face_no), neighbor_face_no);
219 info.neighbor.reinit(dof_info.
exterior[face_no]);
222 info.face, info.neighbor);
230 info.post_faces(dof_info);
234 if (integrate_cell && !cells_first)
235 cell_worker(dof_info.
cell, info.cell);
254 template<
int dim,
int spacedim,
class DOFINFO,
class INFOBOX,
class ASSEMBLER,
class ITERATOR>
256 typename identity<ITERATOR>::type end,
259 const std_cxx1x::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &cell_worker,
260 const std_cxx1x::function<
void (DOFINFO &,
typename INFOBOX::CellInfo &)> &boundary_worker,
261 const std_cxx1x::function<
void (DOFINFO &, DOFINFO &,
262 typename INFOBOX::CellInfo &,
263 typename INFOBOX::CellInfo &)> &face_worker,
264 ASSEMBLER &assembler,
265 bool cells_first =
true,
266 bool unique_faces_only =
true)
270 assembler.initialize_info(dof_info.
cell,
false);
271 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
273 assembler.initialize_info(dof_info.
interior[i],
true);
274 assembler.initialize_info(dof_info.
exterior[i],
true);
278 #ifdef DEAL_II_MESHWORKER_PARALLEL
280 std_cxx1x::bind(&cell_action<INFOBOX, DOFINFO, dim, spacedim, ITERATOR>,
281 std_cxx1x::_1, std_cxx1x::_3, std_cxx1x::_2,
282 cell_worker, boundary_worker, face_worker, cells_first, unique_faces_only),
283 std_cxx1x::bind(&internal::assemble<dim,DOFINFO,ASSEMBLER>, std_cxx1x::_1, &assembler),
286 for (ITERATOR cell = begin; cell != end; ++cell)
288 cell_action<INFOBOX,DOFINFO,dim,spacedim>(cell, dof_info,
290 boundary_worker, face_worker,
293 dof_info.assemble(assembler);
307 template<
int dim,
int spacedim,
class ITERATOR,
class ASSEMBLER>
309 typename identity<ITERATOR>::type end,
310 DoFInfo<dim, spacedim> &dof_info,
311 IntegrationInfoBox<dim, spacedim> &box,
312 const std_cxx1x::function<
void (DoFInfo<dim>&, IntegrationInfo<dim, spacedim>&)> &cell_worker,
313 const std_cxx1x::function<
void (DoFInfo<dim>&, IntegrationInfo<dim, spacedim>&)> &boundary_worker,
314 const std_cxx1x::function<
void (DoFInfo<dim> &, DoFInfo<dim> &,
315 IntegrationInfo<dim, spacedim> &,
316 IntegrationInfo<dim, spacedim> &)> &face_worker,
317 ASSEMBLER &assembler,
321 template<
int dim,
int spacedim, class ITERATOR, class ASSEMBLER>
323 typename
identity<ITERATOR>::type end,
324 DoFInfo<dim, spacedim> &dof_info,
331 ASSEMBLER &assembler,
353 template<
int dim,
int spacedim,
class ITERATOR,
class ASSEMBLER>
355 typename identity<ITERATOR>::type end,
359 ASSEMBLER &assembler,
360 bool cells_first =
true)
364 std_cxx1x::function<void (DoFInfo<dim> &,
DoFInfo<dim> &,
366 IntegrationInfo<dim, spacedim> &)> face_worker;
389 DEAL_II_NAMESPACE_CLOSE
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std_cxx1x::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std_cxx1x::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std_cxx1x::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, bool cells_first=true, bool unique_faces_only=true)
bool exterior_face_available[GeometryInfo< dim >::faces_per_cell]
void integration_loop(ITERATOR begin, typename identity< ITERATOR >::type end, DoFInfo< dim, spacedim > &dof_info, IntegrationInfoBox< dim, spacedim > &box, const std_cxx1x::function< void(DoFInfo< dim > &, IntegrationInfo< dim, spacedim > &)> &cell_worker, const std_cxx1x::function< void(DoFInfo< dim > &, IntegrationInfo< dim, spacedim > &)> &boundary_worker, const std_cxx1x::function< void(DoFInfo< dim > &, DoFInfo< dim > &, IntegrationInfo< dim, spacedim > &, IntegrationInfo< dim, spacedim > &)> &face_worker, ASSEMBLER &assembler, bool cells_first=true) DEAL_II_DEPRECATED
void cell_action(ITERATOR cell, DoFInfoBox< dim, DOFINFO > &dof_info, INFOBOX &info, const std_cxx1x::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std_cxx1x::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std_cxx1x::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, const bool cells_first, const bool unique_faces_only)
bool interior_face_available[GeometryInfo< dim >::faces_per_cell]
#define Assert(cond, exc)
void assemble(ASSEMBLER &ass) const
bool is_active_iterator(const DI &)
BlockCompressedSparsityPattern CompressedBlockSparsityPattern DEAL_II_DEPRECATED
void run(const Iterator &begin, const typename identity< Iterator >::type &end, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length=2 *multithread_info.n_threads(), const unsigned int chunk_size=8)
DOFINFO interior[GeometryInfo< dim >::faces_per_cell]
DOFINFO exterior[GeometryInfo< dim >::faces_per_cell]
::ExceptionBase & ExcInternalError()