From 06d8d6f72e7332bac3eb153d5bad5ea6145a065a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 9 Mar 2004 17:32:48 +0000 Subject: [PATCH] New tests. git-svn-id: https://svn.dealii.org/trunk@8703 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/Makefile | 3 +- tests/bits/subdomain_ids_01.cc | 106 ++++++++++++++++++++++++++++++ tests/bits/subdomain_ids_02.cc | 115 +++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 tests/bits/subdomain_ids_01.cc create mode 100644 tests/bits/subdomain_ids_02.cc diff --git a/tests/bits/Makefile b/tests/bits/Makefile index 892f3bc824..449742f13d 100644 --- a/tests/bits/Makefile +++ b/tests/bits/Makefile @@ -51,7 +51,8 @@ tests_x = anna_? \ full_matrix_vector_* \ solver_selector \ deal_solver_* \ - vector_* + vector_* \ + subdomain_ids_* ifeq ($(USE_CONTRIB_PETSC),yes) tests_x += petsc_* diff --git a/tests/bits/subdomain_ids_01.cc b/tests/bits/subdomain_ids_01.cc new file mode 100644 index 0000000000..07c80742c3 --- /dev/null +++ b/tests/bits/subdomain_ids_01.cc @@ -0,0 +1,106 @@ +//---------------------------- subdomain_ids_01.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_01.cc --------------------------- + +// check DoFTools::extract_subdomain_dofs + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +std::ofstream logfile("subdomain_ids_01.output"); + + +DeclException2 (ExcNumberMismatch, + int, int, + << "The numbers " << arg1 << " and " << arg2 + << " should be equal, but are not."); + + +template +void test () +{ + deallog << dim << 'D' << std::endl; + Triangulation 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::active_cell_iterator + cell = tria.begin_active (), + endc = tria.end (); + for (; cell!=endc; ++cell) + { + unsigned int subdomain = 0; + for (unsigned int d=0; dcenter()(d) > 0) + subdomain |= (1<set_subdomain_id (subdomain); + }; + + // distribute some degrees of freedom and + // output some information on them + FESystem fe(FE_Q(2),dim, FE_DGQ(1), 1); + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + deallog << dof_handler.n_dofs() << std::endl; + + std::vector selected_dofs (dof_handler.n_dofs()); + for (unsigned int subdomain=0; subdomain<(1< (); + test<2> (); + test<3> (); + + return 0; +} diff --git a/tests/bits/subdomain_ids_02.cc b/tests/bits/subdomain_ids_02.cc new file mode 100644 index 0000000000..f646b6d0b6 --- /dev/null +++ b/tests/bits/subdomain_ids_02.cc @@ -0,0 +1,115 @@ +//---------------------------- subdomain_ids_02.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_02.cc --------------------------- + +// check DoFTools::get_subdomain_association + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +std::ofstream logfile("subdomain_ids_02.output"); + + +DeclException2 (ExcNumberMismatch, + int, int, + << "The numbers " << arg1 << " and " << arg2 + << " should be equal, but are not."); + + +template +void test () +{ + deallog << dim << 'D' << std::endl; + Triangulation 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::active_cell_iterator + cell = tria.begin_active (), + endc = tria.end (); + for (; cell!=endc; ++cell) + { + unsigned int subdomain = 0; + for (unsigned int d=0; dcenter()(d) > 0) + subdomain |= (1<set_subdomain_id (subdomain); + }; + + // distribute some degrees of freedom and + // output some information on them + FESystem fe(FE_Q(2),dim, FE_DGQ(1), 1); + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + deallog << dof_handler.n_dofs() << std::endl; + + std::vector subdomain_association (dof_handler.n_dofs()); + DoFTools::get_subdomain_association (dof_handler, + subdomain_association); + for (unsigned int subdomain=0; subdomain<(1< (); + test<2> (); + test<3> (); + + return 0; +} -- 2.39.5