From 17268a434691ad3c607530a40a07605a100739f0 Mon Sep 17 00:00:00 2001 From: kanschat Date: Tue, 23 Feb 2010 23:05:01 +0000 Subject: [PATCH] MeshWorker::loop() uses WorkStream::run() git-svn-id: https://svn.dealii.org/trunk@20679 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/numerics/mesh_worker_info.h | 45 ++++++++++++++++--- .../numerics/mesh_worker_info.templates.h | 34 ++++++++++++++ .../include/numerics/mesh_worker_loop.h | 22 ++++++--- 3 files changed, 90 insertions(+), 11 deletions(-) diff --git a/deal.II/deal.II/include/numerics/mesh_worker_info.h b/deal.II/deal.II/include/numerics/mesh_worker_info.h index 54c2e54564..f48fe4b9e1 100644 --- a/deal.II/deal.II/include/numerics/mesh_worker_info.h +++ b/deal.II/deal.II/include/numerics/mesh_worker_info.h @@ -359,7 +359,7 @@ namespace MeshWorker * * @author Guido Kanschat, 2010 */ - template < int dim, int spacedim=dim> + template class DoFInfoBox { public: @@ -367,8 +367,15 @@ namespace MeshWorker * Constructor copying the seed * into all other objects. */ - DoFInfoBox(const MeshWorker::DoFInfo& seed); + DoFInfoBox(const DoFInfo& seed); + /** + * Copy constructor, taking + * #cell and using it as a seed + * in the other constructor. + */ + DoFInfoBox(const DoFInfoBox&); + /** * Reset all the availability flags. */ @@ -390,15 +397,15 @@ namespace MeshWorker /** * The data for the cell. */ - MeshWorker::DoFInfo cell; + DoFInfo cell; /** * The data for the faces from inside. */ - MeshWorker::DoFInfo interior[GeometryInfo::faces_per_cell]; + DoFInfo interior[GeometryInfo::faces_per_cell]; /** * The data for the faces from outside. */ - MeshWorker::DoFInfo exterior[GeometryInfo::faces_per_cell]; + DoFInfo exterior[GeometryInfo::faces_per_cell]; /** * A set of flags, indicating @@ -474,11 +481,21 @@ namespace MeshWorker /// vector of FEValues objects std::vector > fevalv; public: + static const unsigned int dimension = FEVALUESBASE::dimension; + static const unsigned int space_dimension = FEVALUESBASE::space_dimension; + /** * Constructor. */ IntegrationInfo(); - + + /** + * Copy constructor, creating a + * clone to be used by + * WorksTream::run(). + */ + IntegrationInfo(const IntegrationInfo& other); + /** * Build all internal * structures, in particular @@ -977,6 +994,22 @@ namespace MeshWorker } + template < int dim, int spacedim> + inline + DoFInfoBox::DoFInfoBox(const DoFInfoBox& other) + : + cell(other.cell) + { + for (unsigned int i=0;i::faces_per_cell;++i) + { + exterior[i] = other.exterior[i]; + interior[i] = other.interior[i]; + interior_face_available[i] = false; + exterior_face_available[i] = false; + } + } + + template < int dim, int spacedim> inline void DoFInfoBox::reset () diff --git a/deal.II/deal.II/include/numerics/mesh_worker_info.templates.h b/deal.II/deal.II/include/numerics/mesh_worker_info.templates.h index 3aa4d16b03..a5b1a956d2 100644 --- a/deal.II/deal.II/include/numerics/mesh_worker_info.templates.h +++ b/deal.II/deal.II/include/numerics/mesh_worker_info.templates.h @@ -75,6 +75,40 @@ namespace MeshWorker global_data(boost::shared_ptr >(new VectorDataBase)) {} + + template + IntegrationInfo::IntegrationInfo(const IntegrationInfo& other) + : + multigrid(other.multigrid), + values(other.values), + gradients(other.gradients), + hessians(other.hessians), + global_data(other.global_data), + n_components(other.n_components) + { + fevalv.resize(other.fevalv.size()); + for (unsigned int i=0;i* pc = dynamic_cast*>(&p); + const FEFaceValues* pf = dynamic_cast*>(&p); + const FESubfaceValues* ps = dynamic_cast*>(&p); + + if (pc != 0) + fevalv[i] = typename boost::shared_ptr ( + reinterpret_cast(new FEValues (pc->get_mapping(), pc->get_fe(), + pc->get_quadrature(), pc->get_update_flags()))); + else if (pf != 0) + fevalv[i] = typename boost::shared_ptr ( + new FEFaceValues (pf->get_mapping(), pf->get_fe(), pf->get_quadrature(), pf->get_update_flags())); + else if (ps != 0) + fevalv[i] = typename boost::shared_ptr ( + new FESubfaceValues (ps->get_mapping(), ps->get_fe(), ps->get_quadrature(), ps->get_update_flags())); + else + Assert(false, ExcInternalError()); + } + } + template template diff --git a/deal.II/deal.II/include/numerics/mesh_worker_loop.h b/deal.II/deal.II/include/numerics/mesh_worker_loop.h index 05023e5e9a..fe628ed255 100644 --- a/deal.II/deal.II/include/numerics/mesh_worker_loop.h +++ b/deal.II/deal.II/include/numerics/mesh_worker_loop.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,11 @@ namespace internal return true; } + template + void assemble(const MeshWorker::DoFInfoBox& dinfo, A& assembler) + { + dinfo.assemble(assembler); + } } @@ -242,11 +248,17 @@ namespace MeshWorker } // Loop over all cells - for (ITERATOR cell = begin; cell != end; ++cell) - { - cell_action(cell, dof_info, info, cell_worker, boundary_worker, face_worker, cells_first); - dof_info.assemble(assembler); - } + WorkStream::run(begin, end, + std_cxx1x::bind(cell_action, _1, _3, _2, + cell_worker, boundary_worker, face_worker, cells_first), + std_cxx1x::bind(internal::assemble, _1, assembler), + info, dof_info); + +// for (ITERATOR cell = begin; cell != end; ++cell) +// { +// cell_action(cell, dof_info, info, cell_worker, boundary_worker, face_worker, cells_first); +// dof_info.assemble(assembler); +// } } /** -- 2.39.5