]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
A couple more tests.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 21 Nov 2010 02:47:43 +0000 (02:47 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 21 Nov 2010 02:47:43 +0000 (02:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@22834 0785d39b-7218-0410-832d-ea1e28bc413d

tests/codim_one/interpolate_boundary_values_01_vector_valued.cc [new file with mode: 0644]
tests/codim_one/interpolate_boundary_values_01_vector_valued/cmp/generic [new file with mode: 0644]
tests/codim_one/interpolate_boundary_values_02/cmp/generic [new file with mode: 0644]
tests/codim_one/interpolate_boundary_values_02_vector_valued.cc [new file with mode: 0644]
tests/codim_one/interpolate_boundary_values_02_vector_valued/cmp/generic [new file with mode: 0644]

diff --git a/tests/codim_one/interpolate_boundary_values_01_vector_valued.cc b/tests/codim_one/interpolate_boundary_values_01_vector_valued.cc
new file mode 100644 (file)
index 0000000..0f9a0be
--- /dev/null
@@ -0,0 +1,105 @@
+
+//----------------------------  template.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2005, 2008, 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.
+//
+//----------------------------  template.cc  ---------------------------
+
+
+// test VectorTools::interpolate_boundary_values for codim=1. like
+// _01_vector_valued, but for vector-valued functions
+
+#include "../tests.h"
+#include <fstream>
+#include <base/logstream.h>
+#include <base/function_lib.h>
+#include <grid/tria.h>
+#include <grid/grid_in.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <numerics/vectors.h>
+
+#include <string>
+
+std::ofstream logfile("interpolate_boundary_values_01_vector_valued/output");
+
+template <int dim>
+class X : public Function<dim>
+{
+  public:
+    X() : Function<dim>(dim) {}
+
+    double value (const Point<dim> &p,
+                 const unsigned int component) const
+      {
+       return p[component];
+      }
+};
+
+
+template <int dim, int spacedim>
+void test(std::string filename) {
+    Triangulation<dim, spacedim> tria;
+    GridIn<dim, spacedim> gi;
+    gi.attach_triangulation (tria);
+    std::ifstream in (filename.c_str());
+    gi.read_ucd (in);
+
+    deallog << tria.n_active_cells() << " active cells" << std::endl;
+
+    FESystem<dim,spacedim> fe(FE_Q<dim,spacedim> (2), spacedim);
+    DoFHandler<dim,spacedim> dof_handler (tria);
+    dof_handler.distribute_dofs (fe);
+
+    deallog << dof_handler.n_dofs() << " degrees of freedom" << std::endl;
+
+    std::map<unsigned int, double> bv;
+    VectorTools::interpolate_boundary_values (dof_handler,
+                                             0,
+                                             X<spacedim>(),
+                                             bv);
+    deallog << bv.size() << " boundary degrees of freedom" << std::endl;
+
+    for (std::map<unsigned int, double>::const_iterator i = bv.begin();
+        i != bv.end(); ++i)
+      deallog << i->first << ' ' << i->second << std::endl;
+
+    for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+          cell = dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
+      for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+       if (cell->at_boundary(f))
+         for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
+           for (unsigned int i=0; i<fe.dofs_per_vertex; ++i)
+             {
+               Assert (bv.find(cell->face(f)->vertex_dof_index(v,i))
+                       != bv.end(),
+                       ExcInternalError());
+               Assert (bv[cell->face(f)->vertex_dof_index(v,i)]
+                       ==
+                       X<spacedim>()
+                       .value(cell->face(f)->vertex(v),i),
+                       ExcInternalError());
+             }
+}
+
+
+
+int main ()
+{
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<2,3>("grids/square.inp");
+  test<2,3>("grids/sphere_1.inp");
+
+  return 0;
+}
+
diff --git a/tests/codim_one/interpolate_boundary_values_01_vector_valued/cmp/generic b/tests/codim_one/interpolate_boundary_values_01_vector_valued/cmp/generic
new file mode 100644 (file)
index 0000000..0863ceb
--- /dev/null
@@ -0,0 +1,55 @@
+
+DEAL::4 active cells
+DEAL::75 degrees of freedom
+DEAL::48 boundary degrees of freedom
+DEAL::3 0
+DEAL::4 1.00000
+DEAL::5 0
+DEAL::6 1.00000
+DEAL::7 0
+DEAL::8 0
+DEAL::9 0
+DEAL::10 0
+DEAL::11 0
+DEAL::15 0
+DEAL::16 0.500000
+DEAL::17 0
+DEAL::21 0.500000
+DEAL::22 0
+DEAL::23 0
+DEAL::27 2.00000
+DEAL::28 1.00000
+DEAL::29 0
+DEAL::30 2.00000
+DEAL::31 0
+DEAL::32 0
+DEAL::33 2.00000
+DEAL::34 0.500000
+DEAL::35 0
+DEAL::39 1.50000
+DEAL::40 0
+DEAL::41 0
+DEAL::45 2.00000
+DEAL::46 2.00000
+DEAL::47 0
+DEAL::48 1.00000
+DEAL::49 2.00000
+DEAL::50 0
+DEAL::51 2.00000
+DEAL::52 1.50000
+DEAL::53 0
+DEAL::57 1.50000
+DEAL::58 2.00000
+DEAL::59 0
+DEAL::63 0
+DEAL::64 2.00000
+DEAL::65 0
+DEAL::66 0
+DEAL::67 1.50000
+DEAL::68 0
+DEAL::69 0.500000
+DEAL::70 2.00000
+DEAL::71 0
+DEAL::106 active cells
+DEAL::1278 degrees of freedom
+DEAL::0 boundary degrees of freedom
diff --git a/tests/codim_one/interpolate_boundary_values_02/cmp/generic b/tests/codim_one/interpolate_boundary_values_02/cmp/generic
new file mode 100644 (file)
index 0000000..84e32af
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::1 active cells
+DEAL::3 degrees of freedom
+DEAL::1 boundary degrees of freedom
+DEAL::0 0
+DEAL::1 boundary degrees of freedom
+DEAL::1 1.00000
diff --git a/tests/codim_one/interpolate_boundary_values_02_vector_valued.cc b/tests/codim_one/interpolate_boundary_values_02_vector_valued.cc
new file mode 100644 (file)
index 0000000..52a2da1
--- /dev/null
@@ -0,0 +1,107 @@
+
+//----------------------------  template.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2005, 2008, 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.
+//
+//----------------------------  template.cc  ---------------------------
+
+
+// test VectorTools::interpolate_boundary_values for codim=1. like _02
+// but for vector-valued elements
+
+#include "../tests.h"
+#include <fstream>
+#include <base/logstream.h>
+#include <base/function_lib.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <numerics/vectors.h>
+
+#include <string>
+
+std::ofstream logfile("interpolate_boundary_values_02_vector_valued/output");
+
+template <int dim>
+class X : public Function<dim>
+{
+  public:
+    X() : Function<dim>(dim) {}
+
+    double value (const Point<dim> &p,
+                 const unsigned int component) const
+      {
+       return p[component];
+      }
+};
+
+void test() {
+  const int dim = 1;
+  const int spacedim = 2;
+
+    Triangulation<dim, spacedim> tria;
+    GridGenerator::hyper_cube (tria);
+    deallog << tria.n_active_cells() << " active cells" << std::endl;
+
+    FESystem<dim,spacedim> fe(FE_Q<dim,spacedim>(2), spacedim);
+    DoFHandler<dim,spacedim> dof_handler (tria);
+    dof_handler.distribute_dofs (fe);
+
+    deallog << dof_handler.n_dofs() << " degrees of freedom" << std::endl;
+
+                                    // test left and right boundary
+                                    // separatel
+    for (unsigned int boundary_id=0; boundary_id<2; ++boundary_id)
+      {
+       std::map<unsigned int, double> bv;
+       VectorTools::interpolate_boundary_values (dof_handler,
+                                                 boundary_id,
+                                                 X<spacedim>(),
+                                                 bv);
+       deallog << bv.size() << " boundary degrees of freedom" << std::endl;
+
+       for (std::map<unsigned int, double>::const_iterator i = bv.begin();
+            i != bv.end(); ++i)
+         deallog << i->first << ' ' << i->second << std::endl;
+
+       for (DoFHandler<dim,spacedim>::active_cell_iterator
+              cell = dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
+         for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+           if (cell->at_boundary(f) &&
+               (cell->face(f)->boundary_indicator() == boundary_id))
+             for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
+               for (unsigned int i=0; i<fe.dofs_per_vertex; ++i)
+                 {
+                   Assert (bv.find(cell->face(f)->vertex_dof_index(v,i))
+                           != bv.end(),
+                           ExcInternalError());
+                   Assert (bv[cell->face(f)->vertex_dof_index(v,i)]
+                           ==
+                           X<spacedim>()
+                           .value(cell->face(f)->vertex(v),i),
+                           ExcInternalError());
+                 }
+      }
+}
+
+
+
+int main ()
+{
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test();
+
+  return 0;
+}
+
diff --git a/tests/codim_one/interpolate_boundary_values_02_vector_valued/cmp/generic b/tests/codim_one/interpolate_boundary_values_02_vector_valued/cmp/generic
new file mode 100644 (file)
index 0000000..e559915
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL::1 active cells
+DEAL::6 degrees of freedom
+DEAL::2 boundary degrees of freedom
+DEAL::0 0
+DEAL::1 0
+DEAL::2 boundary degrees of freedom
+DEAL::2 1.00000
+DEAL::3 0

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.