]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 26 Mar 2004 19:58:58 +0000 (19:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 26 Mar 2004 19:58:58 +0000 (19:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@8883 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/dof_constraints_06.cc [new file with mode: 0644]

diff --git a/tests/bits/dof_constraints_06.cc b/tests/bits/dof_constraints_06.cc
new file mode 100644 (file)
index 0000000..345e57e
--- /dev/null
@@ -0,0 +1,113 @@
+//----------------------------  dof_constraints_06.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_06.cc  ---------------------------
+
+
+// simply check what happens when condensing compressed sparsity patterns by
+// printing all nonzero entries
+
+#include "../tests.h"
+#include <lac/compressed_sparsity_pattern.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
+  CompressedSparsityPattern sparsity (dof_handler.n_dofs(),
+                                      dof_handler.n_dofs());
+  DoFTools::make_sparsity_pattern (dof_handler, sparsity);
+  constraints.condense (sparsity);
+
+                                   // output what we have
+  for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
+    for (unsigned int j=0; j<dof_handler.n_dofs(); ++j)
+      if (sparsity.exists(i,j))
+        deallog << i << ' ' << j << std::endl;
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("dof_constraints_06.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;
+    };
+}

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.