]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add get_dof_indices function to DoFAccessor of faces in 1d.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 12 Nov 2010 19:45:37 +0000 (19:45 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 12 Nov 2010 19:45:37 +0000 (19:45 +0000)
git-svn-id: https://svn.dealii.org/trunk@22709 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/dofs/dof_accessor.templates.h
tests/deal.II/vertex_as_face_06.cc [new file with mode: 0644]
tests/deal.II/vertex_as_face_06/cmp/generic [new file with mode: 0644]
tests/deal.II/vertex_as_face_07.cc [new file with mode: 0644]
tests/deal.II/vertex_as_face_07/cmp/generic [new file with mode: 0644]

index 0b5244eb1050dbbf2a2e2b99c6a34926c8e2a667..e02da33b7d8cee0390fdd1b546313f8fd9d2bb59 100644 (file)
@@ -1912,6 +1912,24 @@ DoFAccessor<0,DH<1,spacedim> >::get_dof_handler () const
 
 
 
+template <template <int, int> class DH, int spacedim>
+inline
+void
+DoFAccessor<0,DH<1,spacedim> >::
+get_dof_indices (std::vector<unsigned int> &dof_indices,
+                const unsigned int fe_index) const
+{
+  for (unsigned int i=0; i<dof_indices.size(); ++i)
+    dof_indices[i]
+      = internal::DoFAccessor::Implementation::
+      get_vertex_dof_index (*dof_handler,
+                           this->global_vertex_index,
+                           fe_index,
+                           i);
+}
+
+
+
 /*------------------------- Functions: DoFCellAccessor -----------------------*/
 
 
diff --git a/tests/deal.II/vertex_as_face_06.cc b/tests/deal.II/vertex_as_face_06.cc
new file mode 100644 (file)
index 0000000..49fa5e4
--- /dev/null
@@ -0,0 +1,82 @@
+//----------------------------  vertex_as_face_06.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010 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.
+//
+//----------------------------  vertex_as_face_06.cc  ---------------------------
+
+// verify that we can do things like cell->face() in 1d as well. here:
+// test cell->face(0)->get_dof_indices()
+
+
+#include "../tests.h"
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_accessor.h>
+#include <grid/grid_generator.h>
+
+#include <fe/fe_system.h>
+#include <fe/fe_q.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_accessor.h>
+
+#include <fstream>
+
+
+template <int spacedim>
+void test ()
+{
+  Triangulation<1,spacedim> tria;
+  GridGenerator::hyper_cube (tria);
+
+  FESystem<1,spacedim> fe(FE_Q<1,spacedim>(2),1,
+                         FE_Q<1,spacedim>(1),1);
+  DoFHandler<1,spacedim> dof_handler (tria);
+  dof_handler.distribute_dofs (fe);
+
+  std::vector<unsigned int> dof_indices(fe.dofs_per_face);
+
+  deallog << "Coarse mesh:" << std::endl;
+  dof_handler.begin_active()->face(0)->get_dof_indices (dof_indices);
+  for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+    deallog << "Left vertex=" << dof_indices[i] << std::endl;
+  dof_handler.begin_active()->face(1)->get_dof_indices (dof_indices);
+  for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+    deallog << "Right vertex=" << dof_indices[i] << std::endl;
+
+  tria.refine_global (2);
+  dof_handler.distribute_dofs (fe);
+
+  for (typename DoFHandler<1,spacedim>::active_cell_iterator
+        cell = dof_handler.begin_active();
+       cell != dof_handler.end(); ++cell)
+    {
+      deallog << "Cell: " << cell << std::endl;
+      cell->face(0)->get_dof_indices (dof_indices);
+      for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+       deallog << "Left vertex=" << dof_indices[i] << std::endl;
+      cell->face(1)->get_dof_indices (dof_indices);
+      for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+       deallog << "Right vertex=" << dof_indices[i] << std::endl;
+    }
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("vertex_as_face_06/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<1> ();
+  test<2> ();
+
+  return 0;
+}
diff --git a/tests/deal.II/vertex_as_face_06/cmp/generic b/tests/deal.II/vertex_as_face_06/cmp/generic
new file mode 100644 (file)
index 0000000..865c23a
--- /dev/null
@@ -0,0 +1,51 @@
+
+DEAL::Coarse mesh:
+DEAL::Left vertex=0
+DEAL::Left vertex=1
+DEAL::Right vertex=2
+DEAL::Right vertex=3
+DEAL::Cell: 2.0
+DEAL::Left vertex=0
+DEAL::Left vertex=1
+DEAL::Right vertex=2
+DEAL::Right vertex=3
+DEAL::Cell: 2.1
+DEAL::Left vertex=2
+DEAL::Left vertex=3
+DEAL::Right vertex=5
+DEAL::Right vertex=6
+DEAL::Cell: 2.2
+DEAL::Left vertex=5
+DEAL::Left vertex=6
+DEAL::Right vertex=8
+DEAL::Right vertex=9
+DEAL::Cell: 2.3
+DEAL::Left vertex=8
+DEAL::Left vertex=9
+DEAL::Right vertex=11
+DEAL::Right vertex=12
+DEAL::Coarse mesh:
+DEAL::Left vertex=0
+DEAL::Left vertex=1
+DEAL::Right vertex=2
+DEAL::Right vertex=3
+DEAL::Cell: 2.0
+DEAL::Left vertex=0
+DEAL::Left vertex=1
+DEAL::Right vertex=2
+DEAL::Right vertex=3
+DEAL::Cell: 2.1
+DEAL::Left vertex=2
+DEAL::Left vertex=3
+DEAL::Right vertex=5
+DEAL::Right vertex=6
+DEAL::Cell: 2.2
+DEAL::Left vertex=5
+DEAL::Left vertex=6
+DEAL::Right vertex=8
+DEAL::Right vertex=9
+DEAL::Cell: 2.3
+DEAL::Left vertex=8
+DEAL::Left vertex=9
+DEAL::Right vertex=11
+DEAL::Right vertex=12
diff --git a/tests/deal.II/vertex_as_face_07.cc b/tests/deal.II/vertex_as_face_07.cc
new file mode 100644 (file)
index 0000000..3a2f661
--- /dev/null
@@ -0,0 +1,123 @@
+//----------------------------  vertex_as_face_07.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010 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.
+//
+//----------------------------  vertex_as_face_07.cc  ---------------------------
+
+// verify that we can do things like cell->face() in 1d as well. here:
+// test cell->face(0)->get_dof_indices()
+// compared to _06, we now test for an hp DoFHandler
+
+#include "../tests.h"
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_accessor.h>
+#include <grid/grid_generator.h>
+
+#include <fe/fe_system.h>
+#include <fe/fe_q.h>
+#include <hp/dof_handler.h>
+#include <hp/fe_collection.h>
+#include <dofs/dof_accessor.h>
+
+#include <fstream>
+
+
+template <int spacedim>
+void print_dofs (const typename hp::DoFHandler<1,spacedim>::face_iterator &i,
+                const unsigned int fe_index,
+                const unsigned int n)
+{
+  std::vector<unsigned int> dof_indices (n);
+  i->get_dof_indices (dof_indices, fe_index);
+  for (unsigned int i=0; i<n; ++i)
+    deallog << dof_indices[i] << ' ';
+  deallog << std::endl;
+}
+
+
+
+template <int spacedim>
+void print_dofs (const typename hp::DoFHandler<1,spacedim>::cell_iterator &i,
+                const unsigned int n)
+{
+  std::vector<unsigned int> dof_indices (n);
+  i->get_dof_indices (dof_indices);
+  for (unsigned int i=0; i<n; ++i)
+    deallog << dof_indices[i] << ' ';
+  deallog << std::endl;
+}
+
+
+
+template <int spacedim>
+void test ()
+{
+  Triangulation<1,spacedim> tria;
+  GridGenerator::hyper_cube (tria);
+
+  FESystem<1,spacedim> fe1(FE_Q<1,spacedim>(2),1,
+                          FE_Q<1,spacedim>(1),1);
+  FESystem<1,spacedim> fe2(FE_Q<1,spacedim>(3),1,
+                          FE_Q<1,spacedim>(2),1);
+  hp::FECollection<1,spacedim> fe_collection;
+  fe_collection.push_back (fe1);
+  fe_collection.push_back (fe2);
+
+  hp::DoFHandler<1,spacedim> dof_handler (tria);
+  dof_handler.begin_active()->set_active_fe_index (0);
+  dof_handler.distribute_dofs (fe_collection);
+
+  deallog << "Coarse mesh:" << std::endl;
+  print_dofs<spacedim> (dof_handler.begin_active()->face(0), 0, fe1.dofs_per_face);
+  print_dofs<spacedim> (dof_handler.begin_active()->face(1), 0, fe1.dofs_per_face);
+
+  tria.refine_global (2);
+  {
+    unsigned int index = 0;
+    for (typename hp::DoFHandler<1,spacedim>::active_cell_iterator
+          cell = dof_handler.begin_active();
+        cell != dof_handler.end(); ++cell, index = (index + 1) % fe_collection.size())
+      cell->set_active_fe_index (index);
+  }
+  dof_handler.distribute_dofs (fe_collection);
+
+  for (typename hp::DoFHandler<1,spacedim>::active_cell_iterator
+        cell = dof_handler.begin_active();
+       cell != dof_handler.end(); ++cell)
+    {
+      deallog << "Cell: " << cell
+             << ", active_fe_index=" << cell->active_fe_index()
+             << std::endl;
+
+      print_dofs<spacedim> (cell,
+                           cell->get_fe().dofs_per_cell);
+      print_dofs<spacedim> (cell->face(0),
+                           cell->active_fe_index(),
+                           cell->get_fe().dofs_per_face);
+      print_dofs<spacedim> (cell->face(1),
+                           cell->active_fe_index(),
+                           cell->get_fe().dofs_per_face);
+    }
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("vertex_as_face_07/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<1> ();
+  test<2> ();
+
+  return 0;
+}
diff --git a/tests/deal.II/vertex_as_face_07/cmp/generic b/tests/deal.II/vertex_as_face_07/cmp/generic
new file mode 100644 (file)
index 0000000..48da620
--- /dev/null
@@ -0,0 +1,39 @@
+
+DEAL::Coarse mesh:
+DEAL::0 1 
+DEAL::2 3 
+DEAL::Cell: 2.0, active_fe_index=0
+DEAL::0 1 2 3 4 
+DEAL::0 1 
+DEAL::2 3 
+DEAL::Cell: 2.1, active_fe_index=1
+DEAL::2 3 8 9 5 6 7 
+DEAL::2 3 
+DEAL::8 9 
+DEAL::Cell: 2.2, active_fe_index=0
+DEAL::8 9 10 11 12 
+DEAL::8 9 
+DEAL::10 11 
+DEAL::Cell: 2.3, active_fe_index=1
+DEAL::10 11 13 14 15 16 17 
+DEAL::10 11 
+DEAL::13 14 
+DEAL::Coarse mesh:
+DEAL::0 1 
+DEAL::2 3 
+DEAL::Cell: 2.0, active_fe_index=0
+DEAL::0 1 2 3 4 
+DEAL::0 1 
+DEAL::2 3 
+DEAL::Cell: 2.1, active_fe_index=1
+DEAL::2 3 8 9 5 6 7 
+DEAL::2 3 
+DEAL::8 9 
+DEAL::Cell: 2.2, active_fe_index=0
+DEAL::8 9 10 11 12 
+DEAL::8 9 
+DEAL::10 11 
+DEAL::Cell: 2.3, active_fe_index=1
+DEAL::10 11 13 14 15 16 17 
+DEAL::10 11 
+DEAL::13 14 

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.