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

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

diff --git a/tests/bits/dof_constraints_05.cc b/tests/bits/dof_constraints_05.cc
new file mode 100644 (file)
index 0000000..2903012
--- /dev/null
@@ -0,0 +1,123 @@
+//----------------------------  dof_constraints_05.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_05.cc  ---------------------------
+
+
+// simply check what happens when calling DoFConstraints::set_zero
+// 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.set_zero (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, and that all
+                                   // the other elements are unchanged
+  for (unsigned int i=0; i<b.size(); ++i)
+    if (constraints.is_constrained(i))
+      Assert (b(i) == 0, ExcInternalError())
+    else
+      Assert (std::fabs(b(i) - (1.+1.*i*i)/3) < 1e-14*std::fabs(b(i)),
+              ExcInternalError());
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("dof_constraints_05.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_05.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/dof_constraints_05.output
new file mode 100644 (file)
index 0000000..cc3fba5
--- /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::0.333333
+DEAL::0.666667
+DEAL::1.66667
+DEAL::3.33333
+DEAL::5.66667
+DEAL::8.66667
+DEAL::12.3333
+DEAL::16.6667
+DEAL::21.6667
+DEAL::27.3333
+DEAL::33.6667
+DEAL::40.6667
+DEAL::48.3333
+DEAL::56.6667
+DEAL::65.6667
+DEAL::75.3333
+DEAL::85.6667
+DEAL::96.6667
+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::0.333333
+DEAL::0.666667
+DEAL::1.66667
+DEAL::3.33333
+DEAL::5.66667
+DEAL::8.66667
+DEAL::12.3333
+DEAL::16.6667
+DEAL::21.6667
+DEAL::27.3333
+DEAL::33.6667
+DEAL::40.6667
+DEAL::48.3333
+DEAL::56.6667
+DEAL::65.6667
+DEAL::75.3333
+DEAL::85.6667
+DEAL::96.6667
+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::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::675.333
+DEAL::705.667
+DEAL::736.667
+DEAL::768.333
+DEAL::800.667
+DEAL::833.667
+DEAL::867.333
+DEAL::901.667
+DEAL::936.667
+DEAL::972.333
+DEAL::1008.67
+DEAL::1045.67
+DEAL::1083.33
+DEAL::1121.67
+DEAL::1160.67
+DEAL::1200.33
+DEAL::1240.67
+DEAL::1281.67
+DEAL::1323.33
+DEAL::1365.67
+DEAL::1408.67
+DEAL::1452.33
+DEAL::1496.67
+DEAL::1541.67
+DEAL::1587.33
+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::2028.33
+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.