From 4fe0a916078808dfd36e073fea8a0a8bd6d2a7e1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 21 Nov 2010 02:47:43 +0000 Subject: [PATCH] A couple more tests. git-svn-id: https://svn.dealii.org/trunk@22834 0785d39b-7218-0410-832d-ea1e28bc413d --- ...polate_boundary_values_01_vector_valued.cc | 105 +++++++++++++++++ .../cmp/generic | 55 +++++++++ .../cmp/generic | 7 ++ ...polate_boundary_values_02_vector_valued.cc | 107 ++++++++++++++++++ .../cmp/generic | 9 ++ 5 files changed, 283 insertions(+) create mode 100644 tests/codim_one/interpolate_boundary_values_01_vector_valued.cc create mode 100644 tests/codim_one/interpolate_boundary_values_01_vector_valued/cmp/generic create mode 100644 tests/codim_one/interpolate_boundary_values_02/cmp/generic create mode 100644 tests/codim_one/interpolate_boundary_values_02_vector_valued.cc create mode 100644 tests/codim_one/interpolate_boundary_values_02_vector_valued/cmp/generic 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 index 0000000000..0f9a0becb3 --- /dev/null +++ b/tests/codim_one/interpolate_boundary_values_01_vector_valued.cc @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +std::ofstream logfile("interpolate_boundary_values_01_vector_valued/output"); + +template +class X : public Function +{ + public: + X() : Function(dim) {} + + double value (const Point &p, + const unsigned int component) const + { + return p[component]; + } +}; + + +template +void test(std::string filename) { + Triangulation tria; + GridIn 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 fe(FE_Q (2), spacedim); + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + + deallog << dof_handler.n_dofs() << " degrees of freedom" << std::endl; + + std::map bv; + VectorTools::interpolate_boundary_values (dof_handler, + 0, + X(), + bv); + deallog << bv.size() << " boundary degrees of freedom" << std::endl; + + for (std::map::const_iterator i = bv.begin(); + i != bv.end(); ++i) + deallog << i->first << ' ' << i->second << std::endl; + + for (typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); cell != dof_handler.end(); ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->at_boundary(f)) + for (unsigned int v=0; v::vertices_per_face; ++v) + for (unsigned int i=0; iface(f)->vertex_dof_index(v,i)) + != bv.end(), + ExcInternalError()); + Assert (bv[cell->face(f)->vertex_dof_index(v,i)] + == + X() + .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 index 0000000000..0863cebb5d --- /dev/null +++ b/tests/codim_one/interpolate_boundary_values_01_vector_valued/cmp/generic @@ -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 index 0000000000..84e32afe29 --- /dev/null +++ b/tests/codim_one/interpolate_boundary_values_02/cmp/generic @@ -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 index 0000000000..52a2da189a --- /dev/null +++ b/tests/codim_one/interpolate_boundary_values_02_vector_valued.cc @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +std::ofstream logfile("interpolate_boundary_values_02_vector_valued/output"); + +template +class X : public Function +{ + public: + X() : Function(dim) {} + + double value (const Point &p, + const unsigned int component) const + { + return p[component]; + } +}; + +void test() { + const int dim = 1; + const int spacedim = 2; + + Triangulation tria; + GridGenerator::hyper_cube (tria); + deallog << tria.n_active_cells() << " active cells" << std::endl; + + FESystem fe(FE_Q(2), spacedim); + DoFHandler 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 bv; + VectorTools::interpolate_boundary_values (dof_handler, + boundary_id, + X(), + bv); + deallog << bv.size() << " boundary degrees of freedom" << std::endl; + + for (std::map::const_iterator i = bv.begin(); + i != bv.end(); ++i) + deallog << i->first << ' ' << i->second << std::endl; + + for (DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); cell != dof_handler.end(); ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->at_boundary(f) && + (cell->face(f)->boundary_indicator() == boundary_id)) + for (unsigned int v=0; v::vertices_per_face; ++v) + for (unsigned int i=0; iface(f)->vertex_dof_index(v,i)) + != bv.end(), + ExcInternalError()); + Assert (bv[cell->face(f)->vertex_dof_index(v,i)] + == + X() + .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 index 0000000000..e559915678 --- /dev/null +++ b/tests/codim_one/interpolate_boundary_values_02_vector_valued/cmp/generic @@ -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 -- 2.39.5