]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Mar 2004 20:19:44 +0000 (20:19 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Mar 2004 20:19:44 +0000 (20:19 +0000)
git-svn-id: https://svn.dealii.org/trunk@8866 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/bits/subdomain_ids_05.cc b/tests/bits/subdomain_ids_05.cc
new file mode 100644 (file)
index 0000000..41753b5
--- /dev/null
@@ -0,0 +1,102 @@
+//----------------------------  subdomain_ids_05.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2001, 2002, 2003, 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.
+//
+//----------------------------  subdomain_ids_05.cc  ---------------------------
+
+// check DoFTools::count_dofs_with_subdomain_association
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_iterator.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_accessor.h>
+#include <dofs/dof_tools.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <dofs/dof_tools.h>
+
+#include <fstream>
+#include <algorithm>
+#include <cmath>
+
+
+std::ofstream logfile("subdomain_ids_05.output");
+
+
+template <int dim>
+void test ()
+{
+  deallog << dim << 'D' << std::endl;
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria, -1, 1);
+  tria.refine_global (2);
+
+                                  // we now have a number of cells,
+                                  // flag them with some subdomain
+                                  // ids based on their position, in
+                                  // particular we take the quadrant
+                                  // (octant)
+  typename Triangulation<dim>::active_cell_iterator
+    cell = tria.begin_active (),
+    endc = tria.end ();
+  for (; cell!=endc; ++cell)
+    {
+      unsigned int subdomain = 0;
+      for (unsigned int d=0; d<dim; ++d)
+       if (cell->center()(d) > 0)
+         subdomain |= (1<<d);
+      Assert (subdomain < (1<<dim), ExcInternalError());
+
+      cell->set_subdomain_id (subdomain);
+    };
+
+                                  // distribute some degrees of freedom and
+                                  // output some information on them
+  FESystem<dim> fe(FE_Q<dim>(2),dim, FE_DGQ<dim>(1), 1);
+  DoFHandler<dim> dof_handler (tria);
+  dof_handler.distribute_dofs (fe);
+  deallog << dof_handler.n_dofs() << std::endl;
+  
+  std::vector<unsigned int> subdomain_association (dof_handler.n_dofs());
+  DoFTools::get_subdomain_association (dof_handler,
+                                       subdomain_association);
+  for (unsigned int subdomain=0; subdomain<(1<<dim); ++subdomain)
+                                     // check that the number of dofs
+                                     // associated is also what the respective
+                                     // function returns
+    Assert (static_cast<unsigned int>
+            (std::count (subdomain_association.begin(),
+                         subdomain_association.end(), subdomain))
+            ==
+            DoFTools::count_dofs_with_subdomain_association (dof_handler,
+                                                             subdomain),
+            ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main ()
+{
+  logfile.precision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<1> ();
+  test<2> ();
+  test<3> ();
+  
+  return 0;
+}
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/subdomain_ids_05.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/subdomain_ids_05.output
new file mode 100644 (file)
index 0000000..5ba8baa
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::1D
+DEAL::17
+DEAL::OK
+DEAL::2D
+DEAL::226
+DEAL::OK
+DEAL::3D
+DEAL::2699
+DEAL::OK

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.