]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
size of MGDoFHandler
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 May 2007 21:03:46 +0000 (21:03 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 May 2007 21:03:46 +0000 (21:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@14735 0785d39b-7218-0410-832d-ea1e28bc413d

tests/benchmarks/dof_handler_size.cc
tests/benchmarks/patches/library/2007-05-30 [new file with mode: 0644]

index e454b94de7ca1fbf20577711fd54c26504fc455b..50bccecd3adb49f20004178dae0ed20c192dcd3b 100644 (file)
 #include <grid/grid_generator.h>
 #include <dofs/dof_handler.h>
 #include <dofs/dof_accessor.h>
+#include <multigrid/mg_dof_handler.h>
+#include <multigrid/mg_dof_accessor.h>
 #include <fe/fe_q.h>
 #include <fe/fe_dgq.h>
 #include <fe/fe_system.h>
 
 using namespace dealii;
 
-template <int dim>
-void check ()
+
+// Fill dof handlers for different elements and see how large they get.
+template <class DOF>
+void check_dofs(DOF& dof)
 {
-  deallog << "Dimension " << dim << std::endl;
-  Triangulation<dim> tr;
-  GridGenerator::hyper_cube(tr);
-  tr.refine_global(18/dim);
-  
-  deallog << "Cells " << std::setw(12)  << tr.n_cells()
-         << " active " << std::setw(12)  << tr.n_active_cells()
-         << " memory " << std::setw(12)  << tr.memory_consumption()
-         << " quotient " << (1./tr.n_cells()*tr.memory_consumption())
-         << std::endl;
-  
-  FE_Q<dim> q1(1);
-  FE_Q<dim> q3(3);
-  FESystem<dim> sys1(q3, 1);
-  FESystem<dim> sys2(q3, 10);
-  DoFHandler<dim> dof(tr);
-  
+  FE_Q<DOF::dimension> q1(1);
+  FE_Q<DOF::dimension> q3(3);
+  FESystem<DOF::dimension> sys1(q3, 1);
+  FESystem<DOF::dimension> sys2(q3, 10);
+
   dof.distribute_dofs(q1);
   deallog << "Dofs Q1   " << std::setw(12) << dof.n_dofs()
          << " memory " << std::setw(12) << dof.memory_consumption()
@@ -60,18 +52,64 @@ void check ()
   deallog << "Dofs Sys1 " << std::setw(12) << dof.n_dofs()
          << " memory " << std::setw(12) << dof.memory_consumption()
          << " quotient " << (1./dof.n_dofs()*dof.memory_consumption())
-         << std::endl;  
+         << std::endl;
   
   dof.distribute_dofs(sys2);
   deallog << "Dofs Sys2 " << std::setw(12) << dof.n_dofs()
          << " memory " << std::setw(12) << dof.memory_consumption()
          << " quotient " << (1./dof.n_dofs()*dof.memory_consumption())
-         << std::endl;  
+         << std::endl;
+  
+  dof.clear();
+}
+
+
+template <int dim>
+void check (bool local)
+{
+  deallog << "Dimension " << dim << std::endl;
+  Triangulation<dim> tr(Triangulation<dim>::maximum_smoothing);
+  GridGenerator::hyper_cube(tr);
+
+  if (local)
+    for (unsigned int i=0;i<99/dim;++i)
+      {
+       tr.last_active()->set_refine_flag();
+       tr.execute_coarsening_and_refinement();
+      }
+  else
+    tr.refine_global(18/dim);
+  
+  deallog << "Levels " << tr.n_levels() << "Cells "<< tr.n_cells()
+         << std::endl
+         << " active " << std::setw(12)  << tr.n_active_cells()
+         << " memory " << std::setw(12)  << tr.memory_consumption()
+         << " quotient " << (1./tr.n_cells()*tr.memory_consumption())
+         << std::endl;
+  
+  FE_Q<dim> q1(1);
+  FE_Q<dim> q3(3);
+  FESystem<dim> sys1(q3, 1);
+  FESystem<dim> sys2(q3, 10);
+  deallog.push("DoF");
+  DoFHandler<dim> dof(tr);
+  check_dofs(dof);
+  deallog.pop();
+  deallog.push("MGDoF");
+  MGDoFHandler<dim> mgdof(tr);
+  check_dofs(mgdof);
+  deallog.pop();
 }
 
 int main()
 {
-  check<2>();
-  check<3>();
+  deallog.push("local");
+  check<2>(true);
+  check<3>(true);
+  deallog.pop();
+  deallog.push("global");  
+  check<2>(false);
+  check<3>(false);
+  deallog.pop();
 }
 
diff --git a/tests/benchmarks/patches/library/2007-05-30 b/tests/benchmarks/patches/library/2007-05-30
new file mode 100644 (file)
index 0000000..cd619e8
--- /dev/null
@@ -0,0 +1,91 @@
+Index: deal.II/source/multigrid/mg_dof_handler.cc
+===================================================================
+--- deal.II/source/multigrid/mg_dof_handler.cc (revision 14714)
++++ deal.II/source/multigrid/mg_dof_handler.cc (working copy)
+@@ -2,7 +2,7 @@
+ //    $Id$
+ //    Version: $Name$
+ //
+-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
++//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+ //
+ //    This file is subject to QPL and may not be  distributed
+ //    without copyright and license information. Please refer
+@@ -11,7 +11,7 @@
+ //
+ //---------------------------------------------------------------------------
+-
++#include <base/memory_consumption.h>
+ #include <dofs/dof_levels.h>
+ #include <dofs/dof_faces.h>
+ #include <dofs/dof_constraints.h>
+@@ -33,6 +33,7 @@
+ /* ------------------------ MGVertexDoFs ----------------------------------- */
++//TODO: This seems horrible memory fragmentation!
+ template <int dim>
+ MGDoFHandler<dim>::MGVertexDoFs::MGVertexDoFs ()
+@@ -124,6 +125,25 @@
+ }
++template <int dim>
++unsigned int
++MGDoFHandler<dim>::memory_consumption() const
++{
++  unsigned int mem = DoFHandler<dim>::memory_consumption();
++  for (unsigned int l=0;l<mg_levels.size();++l)
++    mem += mg_levels[l]->memory_consumption();
++  
++  mem += MemoryConsumption::memory_consumption(*mg_faces);
++  
++  for (unsigned int l=0;l<mg_vertex_dofs.size();++l)
++    mem += sizeof(MGVertexDoFs)
++         + (1+mg_vertex_dofs[l].get_finest_level()-mg_vertex_dofs[l].get_coarsest_level())
++         * sizeof(unsigned int);
++  mem += MemoryConsumption::memory_consumption(mg_used_dofs);
++  return mem;
++}
++
++
+ #if deal_II_dimension == 1
+ template <>
+Index: deal.II/include/multigrid/mg_dof_handler.h
+===================================================================
+--- deal.II/include/multigrid/mg_dof_handler.h (revision 14714)
++++ deal.II/include/multigrid/mg_dof_handler.h (working copy)
+@@ -2,7 +2,7 @@
+ //    $Id$
+ //    Version: $Name$
+ //
+-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
++//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+ //
+ //    This file is subject to QPL and may not be  distributed
+ //    without copyright and license information. Please refer
+@@ -711,6 +711,21 @@
+                                     */
+     unsigned int n_dofs () const;
+     
++                                   /**
++                                    * Determine an estimate for the
++                                    * memory consumption (in bytes)
++                                    * of this object.
++                                    *
++                                    * This function is made virtual,
++                                    * since a dof handler object
++                                    * might be accessed through a
++                                    * pointers to thisr base class,
++                                    * although the actual object
++                                    * might be a derived class.
++                                    */
++    virtual unsigned int memory_consumption () const;
++
++
+                                    /**
+                                     * Exception.
+                                     */

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.