]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test for issue 154 fixed in r31734
authorTimo Heister <timo.heister@gmail.com>
Thu, 21 Nov 2013 21:31:42 +0000 (21:31 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 21 Nov 2013 21:31:42 +0000 (21:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@31752 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/bits/make_boundary_constraints_03.cc b/tests/bits/make_boundary_constraints_03.cc
new file mode 100644 (file)
index 0000000..9ba4455
--- /dev/null
@@ -0,0 +1,132 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2009 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// bug: https://code.google.com/p/dealii/issues/detail?id=154
+// fixed in r31734
+
+#include "../tests.h"
+#include <deal.II/base/function_lib.h>
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/numerics/vector_tools.h>
+#include <deal.II/numerics/matrix_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/dofs/dof_renumbering.h>
+#include <deal.II/fe/fe_values.h>
+#include <fstream>
+#include <iomanip>
+
+
+template <int dim>
+void test ()
+{
+  Triangulation<dim> triangulation;
+  GridGenerator::hyper_cube (triangulation, -1, 1);
+
+  FESystem<dim> fe(FE_Q<2>(1),1,FE_Q<2>(2),2);
+  
+  deallog << "Number of cells: "
+          << triangulation.n_active_cells() << std::endl;
+
+  DoFHandler<dim> dof_handler (triangulation);
+  dof_handler.distribute_dofs (fe);
+                                  //DoFRenumbering::component_wise(dof_handler);
+  deallog << "Number of dofs: "
+          << dof_handler.n_dofs() << std::endl;
+
+  ConstraintMatrix constraints;
+  FEValuesExtractors::Vector velocities(1);
+  ComponentMask mask = fe.component_mask (velocities);
+
+  deallog << "ComponentMask " << mask[0] << mask[1] << mask[2] << std::endl;
+  DoFTools::make_zero_boundary_constraints(dof_handler, constraints, mask);
+  constraints.close();
+  deallog << "Number of Constraints: " << constraints.n_constraints()<<std::endl;
+
+  Quadrature<2> quadrature_formula(fe.get_unit_support_points()); 
+  FEValues<2> fe_values (fe, quadrature_formula,
+                         update_values | update_gradients | update_JxW_values|update_q_points);
+
+  const unsigned int   dofs_per_cell = fe.dofs_per_cell;
+  std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
+
+  DoFHandler<2>::active_cell_iterator
+  cell = dof_handler.begin_active(),
+  endc = dof_handler.end();
+  for (; cell!=endc; ++cell)
+    {
+      fe_values.reinit (cell);
+
+      std::vector<Point<2> > locations = fe_values.get_quadrature_points();
+      cell->get_dof_indices (local_dof_indices);
+
+      for (unsigned int i=0; i<dofs_per_cell; ++i)
+      {
+        if (constraints.is_constrained(local_dof_indices[i]))
+         deallog << "DoF "<< local_dof_indices[i] 
+                   << ", copy " << fe.system_to_base_index(i).first.second 
+                   << ", base element " << fe.system_to_base_index(i).first.first 
+                   << ", index " << fe.system_to_base_index(i).second 
+                   << ", position " << locations[i] << std::endl;
+      }
+    }
+}
+
+int main ()
+{
+  initlog();
+
+  try
+    {
+      test<2> ();
+    }
+  catch (std::exception &exc)
+    {
+      deallog << std::endl << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Exception on processing: " << std::endl
+              << exc.what() << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      deallog << std::endl << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Unknown exception!" << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/bits/make_boundary_constraints_03.output b/tests/bits/make_boundary_constraints_03.output
new file mode 100644 (file)
index 0000000..5cb4d3e
--- /dev/null
@@ -0,0 +1,21 @@
+
+DEAL::Number of cells: 1
+DEAL::Number of dofs: 22
+DEAL::ComponentMask 011
+DEAL::Number of Constraints: 16
+DEAL::DoF 1, copy 0, base element 1, index 0, position -1.00000 -1.00000
+DEAL::DoF 2, copy 1, base element 1, index 0, position -1.00000 -1.00000
+DEAL::DoF 4, copy 0, base element 1, index 1, position 1.00000 -1.00000
+DEAL::DoF 5, copy 1, base element 1, index 1, position 1.00000 -1.00000
+DEAL::DoF 7, copy 0, base element 1, index 2, position -1.00000 1.00000
+DEAL::DoF 8, copy 1, base element 1, index 2, position -1.00000 1.00000
+DEAL::DoF 10, copy 0, base element 1, index 3, position 1.00000 1.00000
+DEAL::DoF 11, copy 1, base element 1, index 3, position 1.00000 1.00000
+DEAL::DoF 12, copy 0, base element 1, index 4, position -1.00000 0.00000
+DEAL::DoF 13, copy 1, base element 1, index 4, position -1.00000 0.00000
+DEAL::DoF 14, copy 0, base element 1, index 5, position 1.00000 0.00000
+DEAL::DoF 15, copy 1, base element 1, index 5, position 1.00000 0.00000
+DEAL::DoF 16, copy 0, base element 1, index 6, position 0.00000 -1.00000
+DEAL::DoF 17, copy 1, base element 1, index 6, position 0.00000 -1.00000
+DEAL::DoF 18, copy 0, base element 1, index 7, position 0.00000 1.00000
+DEAL::DoF 19, copy 1, base element 1, index 7, position 0.00000 1.00000

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.