From: bangerth Date: Sat, 10 Mar 2007 03:08:43 +0000 (+0000) Subject: New DoFTools::make_sparsity_pattern and GridTools::get_active_child_cells X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a76ff4269931ea9094c3be8b360deca45fe5cb8;p=dealii-svn.git New DoFTools::make_sparsity_pattern and GridTools::get_active_child_cells git-svn-id: https://svn.dealii.org/trunk@14572 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/deal.II/sparsity_pattern_02.cc b/tests/deal.II/sparsity_pattern_02.cc new file mode 100644 index 0000000000..f3f3178847 --- /dev/null +++ b/tests/deal.II/sparsity_pattern_02.cc @@ -0,0 +1,110 @@ +//---------------------------- sparsity_pattern_02.cc --------------------------- +// $Id: sparsity_pattern_02.cc 11749 2005-11-09 19:11:20Z wolf $ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2007 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. +// +//---------------------------- sparsity_pattern_02.cc --------------------------- + + +// use the version of DoFTools::make_sparsity_pattern that takes two +// DoFHandler arguments for two DoFHandlers that are actually from different +// meshes (though with the same base) + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +void +check () +{ + // create two different triangulations + Triangulation triangulation_1; + if (dim==2) + GridGenerator::hyper_ball(triangulation_1, Point(), 1); + else + GridGenerator::hyper_cube(triangulation_1, -1,1); + triangulation_1.refine_global (1); + triangulation_1.begin_active()->set_refine_flag (); + triangulation_1.execute_coarsening_and_refinement (); + triangulation_1.begin_active(2)->set_refine_flag (); + triangulation_1.execute_coarsening_and_refinement (); + if (dim==1) + triangulation_1.refine_global(2); + + + Triangulation triangulation_2; + if (dim==2) + GridGenerator::hyper_ball(triangulation_2, Point(), 1); + else + GridGenerator::hyper_cube(triangulation_2, -1,1); + triangulation_2.refine_global (1); + (++triangulation_2.begin_active())->set_refine_flag (); + triangulation_2.execute_coarsening_and_refinement (); + (++triangulation_2.begin_active(2))->set_refine_flag (); + triangulation_2.execute_coarsening_and_refinement (); + if (dim==1) + triangulation_2.refine_global(2); + + + + // create a system element composed + // of one Q1 and one Q2 element + FESystem element(FE_Q(1), 1, + FE_Q(2), 1); + DoFHandler dof_1(triangulation_1); + DoFHandler dof_2(triangulation_2); + dof_1.distribute_dofs(element); + dof_2.distribute_dofs(element); + + SparsityPattern sparsity (dof_1.n_dofs(), dof_2.n_dofs(), + std::max(dof_1.n_dofs(), dof_2.n_dofs())); + DoFTools::make_sparsity_pattern (dof_1, dof_2, sparsity); + sparsity.compress (); + + sparsity.print (deallog.get_file_stream()); +} + + + +int main () +{ + std::ofstream logfile ("sparsity_pattern_02/output"); + logfile.precision (2); + logfile.setf(std::ios::fixed); + deallog.attach(logfile); + deallog.depth_console (0); + + deallog.push ("1d"); + check<1> (); + deallog.pop (); + deallog.push ("2d"); + check<2> (); + deallog.pop (); + deallog.push ("3d"); + check<3> (); + deallog.pop (); +} diff --git a/tests/deal.II/sparsity_pattern_03.cc b/tests/deal.II/sparsity_pattern_03.cc new file mode 100644 index 0000000000..a30c13c4ac --- /dev/null +++ b/tests/deal.II/sparsity_pattern_03.cc @@ -0,0 +1,113 @@ +//---------------------------- sparsity_pattern_03.cc --------------------------- +// $Id: sparsity_pattern_03.cc 11749 2005-11-09 19:11:20Z wolf $ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2007 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. +// +//---------------------------- sparsity_pattern_03.cc --------------------------- + + +// use the version of DoFTools::make_sparsity_pattern that takes two +// DoFHandler arguments for two DoFHandlers that are actually from different +// meshes (though with the same base) +// +// like sparsity_pattern_03, but use different finite elements + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +void +check () +{ + // create two different triangulations + Triangulation triangulation_1; + if (dim==2) + GridGenerator::hyper_ball(triangulation_1, Point(), 1); + else + GridGenerator::hyper_cube(triangulation_1, -1,1); + triangulation_1.refine_global (1); + triangulation_1.begin_active()->set_refine_flag (); + triangulation_1.execute_coarsening_and_refinement (); + triangulation_1.begin_active(2)->set_refine_flag (); + triangulation_1.execute_coarsening_and_refinement (); + if (dim==1) + triangulation_1.refine_global(2); + + + Triangulation triangulation_2; + if (dim==2) + GridGenerator::hyper_ball(triangulation_2, Point(), 1); + else + GridGenerator::hyper_cube(triangulation_2, -1,1); + triangulation_2.refine_global (1); + (++triangulation_2.begin_active())->set_refine_flag (); + triangulation_2.execute_coarsening_and_refinement (); + (++triangulation_2.begin_active(2))->set_refine_flag (); + triangulation_2.execute_coarsening_and_refinement (); + if (dim==1) + triangulation_2.refine_global(2); + + + + FESystem element_1(FE_Q(1), 2, + FE_Q(2), 1); + FESystem element_2(FE_Q(3), 1, + FE_DGQ(0), 2); + DoFHandler dof_1(triangulation_1); + DoFHandler dof_2(triangulation_2); + dof_1.distribute_dofs(element_1); + dof_2.distribute_dofs(element_2); + + SparsityPattern sparsity (dof_1.n_dofs(), dof_2.n_dofs(), + std::max(dof_1.n_dofs(), dof_2.n_dofs())); + DoFTools::make_sparsity_pattern (dof_1, dof_2, sparsity); + sparsity.compress (); + + sparsity.print (deallog.get_file_stream()); +} + + + +int main () +{ + std::ofstream logfile ("sparsity_pattern_03/output"); + logfile.precision (2); + logfile.setf(std::ios::fixed); + deallog.attach(logfile); + deallog.depth_console (0); + + deallog.push ("1d"); + check<1> (); + deallog.pop (); + deallog.push ("2d"); + check<2> (); + deallog.pop (); + deallog.push ("3d"); + check<3> (); + deallog.pop (); +} diff --git a/tests/deal.II/sparsity_pattern_04.cc b/tests/deal.II/sparsity_pattern_04.cc new file mode 100644 index 0000000000..009d156d7e --- /dev/null +++ b/tests/deal.II/sparsity_pattern_04.cc @@ -0,0 +1,115 @@ +//---------------------------- sparsity_pattern_04.cc --------------------------- +// $Id: sparsity_pattern_04.cc 11749 2005-11-09 19:11:20Z wolf $ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2007 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. +// +//---------------------------- sparsity_pattern_04.cc --------------------------- + + +// use the version of DoFTools::make_sparsity_pattern that takes two +// DoFHandler arguments for two DoFHandlers that are actually from different +// meshes (though with the same base) +// +// like sparsity_pattern_03, but use different finite elements and use a mesh +// with a different number of cells + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +void +check () +{ + // create two different triangulations + Triangulation triangulation_1; + if (dim==2) + GridGenerator::hyper_ball(triangulation_1, Point(), 1); + else + GridGenerator::hyper_cube(triangulation_1, -1,1); + triangulation_1.refine_global (1); + triangulation_1.begin_active()->set_refine_flag (); + triangulation_1.execute_coarsening_and_refinement (); + triangulation_1.begin_active(2)->set_refine_flag (); + triangulation_1.execute_coarsening_and_refinement (); + if (dim==1) + triangulation_1.refine_global(2); + + + Triangulation triangulation_2; + if (dim==2) + GridGenerator::hyper_ball(triangulation_2, Point(), 1); + else + GridGenerator::hyper_cube(triangulation_2, -1,1); + triangulation_2.refine_global (1); + (++triangulation_2.begin_active())->set_refine_flag (); + triangulation_2.execute_coarsening_and_refinement (); + (++triangulation_2.begin_active(2))->set_refine_flag (); + triangulation_2.execute_coarsening_and_refinement (); + if (dim==1) + triangulation_2.refine_global(2); + triangulation_2.refine_global(1); + + + + FESystem element_1(FE_Q(1), 2, + FE_Q(2), 1); + FESystem element_2(FE_Q(3), 1, + FE_DGQ(0), 2); + DoFHandler dof_1(triangulation_1); + DoFHandler dof_2(triangulation_2); + dof_1.distribute_dofs(element_1); + dof_2.distribute_dofs(element_2); + + SparsityPattern sparsity (dof_1.n_dofs(), dof_2.n_dofs(), + std::max(dof_1.n_dofs(), dof_2.n_dofs())); + DoFTools::make_sparsity_pattern (dof_1, dof_2, sparsity); + sparsity.compress (); + + sparsity.print (deallog.get_file_stream()); +} + + + +int main () +{ + std::ofstream logfile ("sparsity_pattern_04/output"); + logfile.precision (2); + logfile.setf(std::ios::fixed); + deallog.attach(logfile); + deallog.depth_console (0); + + deallog.push ("1d"); + check<1> (); + deallog.pop (); + deallog.push ("2d"); + check<2> (); + deallog.pop (); + deallog.push ("3d"); + check<3> (); + deallog.pop (); +}