From: bangerth Date: Wed, 20 Jan 2010 13:17:03 +0000 (+0000) Subject: Use function<> objects rather than hard-coded names to represent operations. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68bba4624bacef1c860ceef1179d65157e97149d;p=dealii-svn.git Use function<> objects rather than hard-coded names to represent operations. git-svn-id: https://svn.dealii.org/trunk@20397 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/mesh_worker.h b/deal.II/deal.II/include/numerics/mesh_worker.h index 535a2216a9..5a29fa3b73 100644 --- a/deal.II/deal.II/include/numerics/mesh_worker.h +++ b/deal.II/deal.II/include/numerics/mesh_worker.h @@ -14,6 +14,7 @@ #define __deal2__mesh_worker_h #include +#include #include #include #include @@ -62,7 +63,7 @@ template class MGDoFHandler; * * @code * template - * class LocalIntegrator : public Subscriptor + * class LocalIntegrator * { * void cell(typename MeshWorker::IntegrationWorker::CellInfo& info) const; * void bdry(typename MeshWorker::IntegrationWorker::FaceInfo& info) const; @@ -80,9 +81,10 @@ template class MGDoFHandler; * SparseMatrix with no block structure: * * @code - * LocalIntegrator loc; - * MeshWorker::AssemblingIntegrator >, LocalIntegrator > - * integrator(loc); + * MeshWorker::AssemblingIntegrator >> + * integrator(&LocalIntegrator::integrate_cell_term, + * &LocalIntegrator::integrate_boundary_term, + * &LocalIntegrator::integrate_face_term); * @endcode * * Before we can run the integration loop, we have to initialize @@ -238,7 +240,7 @@ namespace MeshWorker * flags stored in this class. */ void initialize_update_flags(); - + /** * Add additional values for update. */ @@ -383,45 +385,71 @@ namespace MeshWorker * @ingroup MeshWorker * @author Guido Kanschat, 2009 */ - template - class AssemblingIntegrator : - public IntegrationWorker, - public ASSEMBLER + template + class AssemblingIntegrator : public IntegrationWorker, + public ASSEMBLER { public: + typedef + typename IntegrationWorker::CellInfo + CellInfo; + + typedef + typename IntegrationWorker::FaceInfo + FaceInfo; + /** * Constructor, initializing * the local data. + * + * The three arguments are + * objects that that will do + * the local computations on + * cells, boundary and interior + * faces. They may be specified + * as pointers to global or + * static functions, pointers + * to objects with an + * operator() that takes the + * required number of + * arguments, or functions with + * bound arguments. */ - AssemblingIntegrator(const INTEGRATOR& local); + AssemblingIntegrator(const std_cxx1x::function &cell_worker, + const std_cxx1x::function &boundary_worker, + const std_cxx1x::function &face_worker); /** * The cell operator called by * integration_loop(). */ - void cell(typename IntegrationWorker::CellInfo& info); + void cell(CellInfo& info); /** * The local boundary operator * called by * integration_loop(). */ - void bdry(typename IntegrationWorker::FaceInfo& info); + void bdry(FaceInfo& info); /** * The interior face operator * called by * integration_loop(). */ - void face(typename IntegrationWorker::FaceInfo& info1, - typename IntegrationWorker::FaceInfo& info2); + void face(FaceInfo& info1, + FaceInfo& info2); private: /** - * Pointer to the object doing - * local integration. + * Pointers to the three + * functions that will do the + * local computations on cells, + * boundary and interior faces. */ - SmartPointer > local; + const std_cxx1x::function cell_worker; + const std_cxx1x::function boundary_worker; + const std_cxx1x::function face_worker; }; //----------------------------------------------------------------------// @@ -434,41 +462,43 @@ namespace MeshWorker //----------------------------------------------------------------------// - template + template inline - AssemblingIntegrator::AssemblingIntegrator(const INTEGRATOR& local) + AssemblingIntegrator:: + AssemblingIntegrator(const std_cxx1x::function &cell_worker, + const std_cxx1x::function &boundary_worker, + const std_cxx1x::function &face_worker) : - local(&local, typeid(*this).name()) + cell_worker (cell_worker), + boundary_worker (boundary_worker), + face_worker (face_worker) {} - template + template inline void - AssemblingIntegrator::cell( - typename IntegrationWorker::CellInfo& info) + AssemblingIntegrator::cell(CellInfo& info) { - local->cell(info); + cell_worker(info); ASSEMBLER::assemble(info); } - template + template inline void - AssemblingIntegrator::bdry( - typename IntegrationWorker::FaceInfo& info) + AssemblingIntegrator::bdry(FaceInfo& info) { - local->bdry(info); + boundary_worker(info); ASSEMBLER::assemble(info); } - template + template inline void - AssemblingIntegrator::face( - typename IntegrationWorker::FaceInfo& info1, - typename IntegrationWorker::FaceInfo& info2) + AssemblingIntegrator::face(FaceInfo& info1, + FaceInfo& info2) { - local->face(info1, info2); + face_worker(info1, info2); ASSEMBLER::assemble(info1, info2); } }