From 091a670ed54cb46817b98cec78d2708b49db3685 Mon Sep 17 00:00:00 2001
From: kanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Date: Tue, 4 May 2010 14:48:50 +0000
Subject: [PATCH] add callback functions to cell_action

git-svn-id: https://svn.dealii.org/trunk@21062 0785d39b-7218-0410-832d-ea1e28bc413d
---
 .../include/numerics/mesh_worker_info.h       | 86 ++++++++++++++++++-
 .../include/numerics/mesh_worker_loop.h       | 30 ++++---
 2 files changed, 104 insertions(+), 12 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 d141bbb210..a44c6eae6c 100644
--- a/deal.II/deal.II/include/numerics/mesh_worker_info.h
+++ b/deal.II/deal.II/include/numerics/mesh_worker_info.h
@@ -732,6 +732,74 @@ namespace MeshWorker
 
 /// The type of the info objects for faces.
       typedef IntegrationInfo<dim, spacedim> FaceInfo;
+
+				       /**
+					* A callback function which is
+					* called in the loop over all
+					* cells, after the action on a
+					* cell has been performed and
+					* before the faces are dealt
+					* with.
+					*
+					* In order for this function
+					* to have this effect,
+					* at least either of the
+					* arguments
+					* <tt>boundary_worker</tt> or
+					* <tt>face_worker</tt>
+					* arguments of loop() should
+					* be nonzero. Additionally,
+					* <tt>cells_first</tt> should
+					* be true. If
+					* <tt>cells_first</tt> is
+					* false, this function is
+					* called before any action on
+					* a cell is taken.
+					*
+					* And empty function in this
+					* class, but can be replaced
+					* in other classes given to
+					* loop() instead.
+					*
+					* See loop() and cell_action()
+					* for more details of how this
+					* function can be used.
+					*/
+      template <class DOFINFO>
+      void post_cell(const DoFInfoBox<dim, DOFINFO>&);
+      
+				       /**
+					* A callback function which is
+					* called in the loop over all
+					* cells, after the action on
+					* the faces of a cell has been
+					* performed and before the
+					* cell itself is dealt with
+					* (assumes
+					* <tt>cells_first</tt> is false).
+					*
+					* In order for this function
+					* to have a reasonable effect,
+					* at least either of the
+					* arguments
+					* <tt>boundary_worker</tt> or
+					* <tt>face_worker</tt>
+					* arguments of loop() should
+					* be nonzero. Additionally,
+					* <tt>cells_first</tt> should
+					* be false.
+					*
+					* And empty function in this
+					* class, but can be replaced
+					* in other classes given to
+					* loop() instead.
+					*
+					* See loop() and cell_action()
+					* for more details of how this
+					* function can be used.
+					*/
+      template <class DOFINFO>
+      void post_faces(const DoFInfoBox<dim, DOFINFO>&);
       
       template <class WORKER>
       void initialize(const WORKER&,
@@ -752,7 +820,7 @@ namespace MeshWorker
 		      const Mapping<dim, spacedim>& mapping,
 		      const NamedData<MGLevelObject<VECTOR>*>& data,
 		      const BlockInfo* block_info = 0);
-
+      
       boost::shared_ptr<MeshWorker::VectorDataBase<dim, spacedim> > cell_data;
       boost::shared_ptr<MeshWorker::VectorDataBase<dim, spacedim> > boundary_data;
       boost::shared_ptr<MeshWorker::VectorDataBase<dim, spacedim> > face_data;
@@ -1318,6 +1386,22 @@ namespace MeshWorker
     subface.initialize_data(p);
     neighbor.initialize_data(p);
   }
+
+
+  template <int dim, int sdim>
+  template <class DOFINFO>
+  void
+  IntegrationInfoBox<dim,sdim>::post_cell(const DoFInfoBox<dim, DOFINFO>&)
+  {}
+  
+
+  template <int dim, int sdim>
+  template <class DOFINFO>
+  void
+  IntegrationInfoBox<dim,sdim>::post_faces(const DoFInfoBox<dim, DOFINFO>&)
+  {}
+  
+
 }
 
 DEAL_II_NAMESPACE_CLOSE
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 e3c5364ead..7b47a4e8b8 100644
--- a/deal.II/deal.II/include/numerics/mesh_worker_loop.h
+++ b/deal.II/deal.II/include/numerics/mesh_worker_loop.h
@@ -112,6 +112,12 @@ namespace MeshWorker
 	info.cell.reinit(dof_info.cell);
 	cell_worker(dof_info.cell, info.cell);
       }
+
+				     // Call the callback function in
+				     // the info box to do
+				     // computations between cell and
+				     // face action.
+    info.post_cell(dof_info);
     
     if (integrate_interior_face || integrate_boundary)
       for (unsigned int face_no=0; face_no < GeometryInfo<ITERATOR::AccessorType::Container::dimension>::faces_per_cell; ++face_no)
@@ -198,6 +204,12 @@ namespace MeshWorker
 		}
 	    }
 	} // faces
+				     // Call the callback function in
+				     // the info box to do
+				     // computations between face and
+				     // cell action.
+    info.post_faces(dof_info);
+    
 				     // Execute this, if faces
 				     // have to be handled first
     if (integrate_cell && !cells_first)
@@ -210,19 +222,15 @@ namespace MeshWorker
   
   
 /**
- * The main work function of this namespace. Its action consists of two
- * loops.
- *
- * First, a loop over all cells in the iterator range is performed, in
- * each step updating the CellInfo object, then calling
- * cell_worker() with this object.
- *
- * In the second loop, we walk through all the faces of cells in the
- * iterator range. The functions boundary_worker() and
- * face_worker() are called for each boundary and interior face,
- * respectively. Unilaterally refined interior faces are handled
+ * The main work function of this namespace. It is a loop over all
+ * cells in an iterator range, in which cell_action() is called for
+ * each cell. Unilaterally refined interior faces are handled
  * automatically by the loop.
  *
+ * Most of the work in this loop is done in cell_action(), whic halso
+ * reeived most of the parameters of this function. See the
+ * documentation there for mor details.
+ *
  * If you don't want integration on cells, interior or boundary faces
  * to happen, simply pass the Null pointer to one of the function
  * arguments.
-- 
2.39.5