]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 26 Mar 2004 16:54:56 +0000 (16:54 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 26 Mar 2004 16:54:56 +0000 (16:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@8876 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/dof_constraints_03.cc [new file with mode: 0644]
tests/bits/dof_constraints_04.cc [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/bits/dof_constraints_04.output [new file with mode: 0644]

diff --git a/tests/bits/dof_constraints_03.cc b/tests/bits/dof_constraints_03.cc
new file mode 100644 (file)
index 0000000..6904e66
--- /dev/null
@@ -0,0 +1,139 @@
+//----------------------------  dof_constraints_03.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  dof_constraints_03.cc  ---------------------------
+
+
+// simply check what happens when condensing matrices. This test was
+// written when I changed a few things in the algorithm
+
+#include "../tests.h"
+#include <lac/sparsity_pattern.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+#include <grid/tria.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_tools.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_accessor.h>
+#include <dofs/dof_tools.h>
+#include <dofs/dof_constraints.h>
+#include <fe/fe_q.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+  deallog << dim << "D" << std::endl;
+  
+  Triangulation<dim> triangulation;
+  GridGenerator::hyper_cube (triangulation);
+
+                                   // refine once, then refine first cell to
+                                   // create hanging nodes
+  triangulation.refine_global (1);
+  triangulation.begin_active()->set_refine_flag ();
+  triangulation.execute_coarsening_and_refinement ();
+  deallog << "Number of cells: " << triangulation.n_active_cells() << std::endl;
+  
+                                   // set up a DoFHandler and compute hanging
+                                   // node constraints for a Q2 element
+  FE_Q<dim> fe(2);
+  DoFHandler<dim> dof_handler (triangulation);
+  dof_handler.distribute_dofs (fe);
+  deallog << "Number of dofs: " << dof_handler.n_dofs() << std::endl;
+
+  ConstraintMatrix constraints;
+  DoFTools::make_hanging_node_constraints (dof_handler, constraints);
+  constraints.close ();
+  deallog << "Number of constraints: " << constraints.n_constraints() << std::endl;
+
+                                   // then set up a sparsity pattern and a
+                                   // matrix on top of it
+  SparsityPattern sparsity (dof_handler.n_dofs(),
+                            dof_handler.n_dofs(),
+                            dof_handler.max_couplings_between_dofs());
+  DoFTools::make_sparsity_pattern (dof_handler, sparsity);
+  constraints.condense (sparsity);
+  SparseMatrix<double> A(sparsity);
+
+                                   // then fill the matrix by setting up
+                                   // bogus matrix entries
+  std::vector<unsigned int> local_dofs (fe.dofs_per_cell);
+  FullMatrix<double> local_matrix (fe.dofs_per_cell, fe.dofs_per_cell);
+  for (typename DoFHandler<dim>::active_cell_iterator
+         cell = dof_handler.begin_active();
+       cell != dof_handler.end(); ++cell)
+    {
+      cell->get_dof_indices (local_dofs);
+      local_matrix.clear ();
+      for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+        for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+          local_matrix(i,j) = (i+1.)*(j+1.)*(local_dofs[i]+1.)*(local_dofs[j]+1.);
+
+                                       // copy local to global
+      for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+        for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+          A.add (local_dofs[i], local_dofs[j], local_matrix(i,j));
+    }
+
+                                   // now condense away constraints from A
+  constraints.condense (A);
+
+                                   // and output what we have
+  for (SparseMatrix<double>::const_iterator i=A.begin(); i!=A.end(); ++i)
+    deallog << i->row() << ' ' << i->column() << ' ' << i->value()
+            << std::endl;
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("dof_constraints_03.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      test<1> ();
+      test<2> ();
+      test<3> ();
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/bits/dof_constraints_04.cc b/tests/bits/dof_constraints_04.cc
new file mode 100644 (file)
index 0000000..2f610db
--- /dev/null
@@ -0,0 +1,119 @@
+//----------------------------  dof_constraints_04.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  dof_constraints_04.cc  ---------------------------
+
+
+// simply check what happens when condensing vectors. This test was
+// written when I changed a few things in the algorithm
+
+#include "../tests.h"
+#include <lac/sparsity_pattern.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+#include <grid/tria.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_tools.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_accessor.h>
+#include <dofs/dof_tools.h>
+#include <dofs/dof_constraints.h>
+#include <fe/fe_q.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+  deallog << dim << "D" << std::endl;
+  
+  Triangulation<dim> triangulation;
+  GridGenerator::hyper_cube (triangulation);
+
+                                   // refine once, then refine first cell to
+                                   // create hanging nodes
+  triangulation.refine_global (1);
+  triangulation.begin_active()->set_refine_flag ();
+  triangulation.execute_coarsening_and_refinement ();
+  deallog << "Number of cells: " << triangulation.n_active_cells() << std::endl;
+  
+                                   // set up a DoFHandler and compute hanging
+                                   // node constraints for a Q2 element
+  FE_Q<dim> fe(2);
+  DoFHandler<dim> dof_handler (triangulation);
+  dof_handler.distribute_dofs (fe);
+  deallog << "Number of dofs: " << dof_handler.n_dofs() << std::endl;
+
+  ConstraintMatrix constraints;
+  DoFTools::make_hanging_node_constraints (dof_handler, constraints);
+  constraints.close ();
+  deallog << "Number of constraints: " << constraints.n_constraints() << std::endl;
+
+  Vector<double> b(dof_handler.n_dofs());
+  for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
+    b(i) = (1.+1.*i*i)/3;
+
+                                   // now condense away constraints
+  constraints.condense (b);
+
+                                   // and output what we have
+  for (Vector<double>::const_iterator i=b.begin(); i!=b.end(); ++i)
+    deallog << *i << std::endl;
+
+                                   // now also make sure that the elements in
+                                   // constrained rows are zero
+  for (unsigned int i=0; i<b.size(); ++i)
+    if (constraints.is_constrained(i))
+      Assert (b(i) == 0, ExcInternalError());
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("dof_constraints_04.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      test<1> ();
+      test<2> ();
+      test<3> ();
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/dof_constraints_04.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/dof_constraints_04.output
new file mode 100644 (file)
index 0000000..8fa50a7
--- /dev/null
@@ -0,0 +1,298 @@
+
+DEAL::1D
+DEAL::Number of cells: 3
+DEAL::Number of dofs: 7
+DEAL::Number of constraints: 0
+DEAL::0.333333
+DEAL::0.666667
+DEAL::1.66667
+DEAL::3.33333
+DEAL::5.66667
+DEAL::8.66667
+DEAL::12.3333
+DEAL::2D
+DEAL::Number of cells: 7
+DEAL::Number of dofs: 43
+DEAL::Number of constraints: 6
+DEAL::74.4167
+DEAL::0.666667
+DEAL::1.66667
+DEAL::227.292
+DEAL::5.66667
+DEAL::8.66667
+DEAL::12.3333
+DEAL::897.500
+DEAL::21.6667
+DEAL::27.3333
+DEAL::33.6667
+DEAL::40.6667
+DEAL::48.3333
+DEAL::56.6667
+DEAL::65.6667
+DEAL::218.375
+DEAL::85.6667
+DEAL::1248.08
+DEAL::108.333
+DEAL::120.667
+DEAL::133.667
+DEAL::147.333
+DEAL::161.667
+DEAL::176.667
+DEAL::192.333
+DEAL::208.667
+DEAL::225.667
+DEAL::243.333
+DEAL::261.667
+DEAL::280.667
+DEAL::0.00000
+DEAL::320.667
+DEAL::0.00000
+DEAL::363.333
+DEAL::385.667
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::481.667
+DEAL::507.333
+DEAL::0.00000
+DEAL::560.667
+DEAL::588.333
+DEAL::3D
+DEAL::Number of cells: 15
+DEAL::Number of dofs: 235
+DEAL::Number of constraints: 54
+DEAL::2949.37
+DEAL::0.666667
+DEAL::1.66667
+DEAL::6966.45
+DEAL::13904.0
+DEAL::8.66667
+DEAL::12.3333
+DEAL::16415.4
+DEAL::21.6667
+DEAL::27.3333
+DEAL::33.6667
+DEAL::22442.8
+DEAL::48.3333
+DEAL::56.6667
+DEAL::65.6667
+DEAL::58617.0
+DEAL::29780.0
+DEAL::96.6667
+DEAL::108.333
+DEAL::43189.4
+DEAL::133.667
+DEAL::147.333
+DEAL::161.667
+DEAL::176.667
+DEAL::192.333
+DEAL::65400.1
+DEAL::225.667
+DEAL::243.333
+DEAL::261.667
+DEAL::280.667
+DEAL::300.333
+DEAL::320.667
+DEAL::341.667
+DEAL::363.333
+DEAL::385.667
+DEAL::408.667
+DEAL::432.333
+DEAL::456.667
+DEAL::481.667
+DEAL::507.333
+DEAL::533.667
+DEAL::560.667
+DEAL::588.333
+DEAL::616.667
+DEAL::645.667
+DEAL::6094.07
+DEAL::705.667
+DEAL::18108.8
+DEAL::768.333
+DEAL::28710.6
+DEAL::833.667
+DEAL::867.333
+DEAL::65789.7
+DEAL::936.667
+DEAL::972.333
+DEAL::41837.7
+DEAL::1045.67
+DEAL::1083.33
+DEAL::1121.67
+DEAL::76709.7
+DEAL::1200.33
+DEAL::1240.67
+DEAL::1281.67
+DEAL::7312.22
+DEAL::1365.67
+DEAL::1408.67
+DEAL::1452.33
+DEAL::1496.67
+DEAL::40759.4
+DEAL::45043.7
+DEAL::1633.67
+DEAL::1680.67
+DEAL::1728.33
+DEAL::1776.67
+DEAL::1825.67
+DEAL::1875.33
+DEAL::1925.67
+DEAL::1976.67
+DEAL::91061.6
+DEAL::2080.67
+DEAL::2133.67
+DEAL::2187.33
+DEAL::2241.67
+DEAL::2296.67
+DEAL::2352.33
+DEAL::2408.67
+DEAL::2465.67
+DEAL::2523.33
+DEAL::2581.67
+DEAL::2640.67
+DEAL::2700.33
+DEAL::2760.67
+DEAL::2821.67
+DEAL::2883.33
+DEAL::2945.67
+DEAL::3008.67
+DEAL::3072.33
+DEAL::3136.67
+DEAL::3201.67
+DEAL::3267.33
+DEAL::3333.67
+DEAL::3400.67
+DEAL::3468.33
+DEAL::3536.67
+DEAL::3605.67
+DEAL::3675.33
+DEAL::3745.67
+DEAL::3816.67
+DEAL::3888.33
+DEAL::3960.67
+DEAL::4033.67
+DEAL::4107.33
+DEAL::4181.67
+DEAL::4256.67
+DEAL::4332.33
+DEAL::4408.67
+DEAL::4485.67
+DEAL::4563.33
+DEAL::4641.67
+DEAL::4720.67
+DEAL::4800.33
+DEAL::4880.67
+DEAL::4961.67
+DEAL::5043.33
+DEAL::5125.67
+DEAL::5208.67
+DEAL::5292.33
+DEAL::5376.67
+DEAL::5461.67
+DEAL::5547.33
+DEAL::5633.67
+DEAL::5720.67
+DEAL::5808.33
+DEAL::5896.67
+DEAL::5985.67
+DEAL::6075.33
+DEAL::6165.67
+DEAL::6256.67
+DEAL::6348.33
+DEAL::6440.67
+DEAL::6533.67
+DEAL::6627.33
+DEAL::6721.67
+DEAL::6816.67
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::7203.33
+DEAL::0.00000
+DEAL::7400.67
+DEAL::7500.33
+DEAL::0.00000
+DEAL::7701.67
+DEAL::0.00000
+DEAL::0.00000
+DEAL::8008.67
+DEAL::8112.33
+DEAL::8216.67
+DEAL::0.00000
+DEAL::8427.33
+DEAL::8533.67
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::9185.67
+DEAL::0.00000
+DEAL::0.00000
+DEAL::9520.67
+DEAL::0.00000
+DEAL::0.00000
+DEAL::9861.67
+DEAL::9976.67
+DEAL::0.00000
+DEAL::0.00000
+DEAL::10325.7
+DEAL::10443.3
+DEAL::0.00000
+DEAL::0.00000
+DEAL::10800.3
+DEAL::0.00000
+DEAL::11041.7
+DEAL::0.00000
+DEAL::11285.7
+DEAL::11408.7
+DEAL::0.00000
+DEAL::11656.7
+DEAL::11781.7
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::12805.7
+DEAL::12936.7
+DEAL::13068.3
+DEAL::13200.7
+DEAL::0.00000
+DEAL::13467.3
+DEAL::13601.7
+DEAL::13736.7
+DEAL::13872.3
+DEAL::14008.7
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::15123.3
+DEAL::0.00000
+DEAL::15408.7
+DEAL::15552.3
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::17025.7
+DEAL::17176.7
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::0.00000
+DEAL::18096.7
+DEAL::18252.3

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.