From: kanschat Date: Fri, 9 Mar 2012 23:20:38 +0000 (+0000) Subject: new test X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb60d3434eca666e105f1a300d6df9cffe9175db;p=dealii-svn.git new test git-svn-id: https://svn.dealii.org/trunk@25231 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/integrators/mesh_worker_01.cc b/tests/integrators/mesh_worker_01.cc index bd25b2be37..653379dc9c 100644 --- a/tests/integrators/mesh_worker_01.cc +++ b/tests/integrators/mesh_worker_01.cc @@ -1,8 +1,7 @@ //---------------------------------------------------------------------- // $Id$ -// Version: $Name$ // -// Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer diff --git a/tests/integrators/mesh_worker_02.cc b/tests/integrators/mesh_worker_02.cc index d87b1c20c8..2e859cc759 100644 --- a/tests/integrators/mesh_worker_02.cc +++ b/tests/integrators/mesh_worker_02.cc @@ -1,8 +1,7 @@ //---------------------------------------------------------------------- // $Id$ -// Version: $Name$ // -// Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer diff --git a/tests/integrators/mesh_worker_03.cc b/tests/integrators/mesh_worker_03.cc new file mode 100644 index 0000000000..109298a47a --- /dev/null +++ b/tests/integrators/mesh_worker_03.cc @@ -0,0 +1,317 @@ +//---------------------------------------------------------------------- +// $Id: mesh_worker_02.cc 23710 2011-05-17 04:50:10Z bangerth $ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010, 2012 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. +// +//---------------------------------------------------------------------- + +// Test consistency of assemblers MatrixSimple with and without local blocks + +#include "../tests.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace dealii; + +// Local integrators fill every matrix entry with 10*block_row + block_col +template +class MatrixIntegrator : public Subscriptor +{ + public: + static void cell(MeshWorker::DoFInfo& dinfo, + MeshWorker::IntegrationInfo& info); + static void face(MeshWorker::DoFInfo& dinfo1, + MeshWorker::DoFInfo& dinfo2, + MeshWorker::IntegrationInfo& info1, + MeshWorker::IntegrationInfo& info2); + static void block_cell(MeshWorker::DoFInfo& dinfo, + MeshWorker::IntegrationInfo& info); + static void block_face(MeshWorker::DoFInfo& dinfo1, + MeshWorker::DoFInfo& dinfo2, + MeshWorker::IntegrationInfo& info1, + MeshWorker::IntegrationInfo& info2); +}; + + +template +void MatrixIntegrator::cell(MeshWorker::DoFInfo& dinfo, + MeshWorker::IntegrationInfo& info) +{ + const FiniteElement& fe = info.fe_values().get_fe(); + FullMatrix& local_matrix = dinfo.matrix(0).matrix; + + for (unsigned int i=0; i +void MatrixIntegrator::face(MeshWorker::DoFInfo& dinfo1, + MeshWorker::DoFInfo& dinfo2, + MeshWorker::IntegrationInfo& info1, + MeshWorker::IntegrationInfo& info2) +{ + const FiniteElement& fe1 = info1.fe_values().get_fe(); + const FiniteElement& fe2 = info2.fe_values().get_fe(); + FullMatrix& matrix_v1u2 = dinfo1.matrix(0, true).matrix; + FullMatrix& matrix_v2u1 = dinfo2.matrix(0, true).matrix; + + for (unsigned int i=0; i +void MatrixIntegrator::block_cell( + MeshWorker::DoFInfo& dinfo, + MeshWorker::IntegrationInfo&) +{ + for (unsigned int m=0;m >& loc = dinfo.matrix(m); + + for (unsigned int i=0; i +void MatrixIntegrator::block_face( + MeshWorker::DoFInfo& dinfo1, + MeshWorker::DoFInfo& dinfo2, + MeshWorker::IntegrationInfo&, + MeshWorker::IntegrationInfo&) +{ + for (unsigned int m=0;m >& loc = dinfo1.matrix(m, true); + + for (unsigned int i=0; i >& loc = dinfo2.matrix(m, true); + + for (unsigned int i=0; i +void +assemble(const DoFHandler& dof_handler, SparseMatrix& matrix) +{ + const FiniteElement& fe = dof_handler.get_fe(); + MappingQ1 mapping; + + MeshWorker::IntegrationInfoBox info_box; + const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1; + info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points, n_gauss_points); + info_box.initialize_update_flags(); + UpdateFlags update_flags = update_values | update_gradients; + info_box.add_update_flags(update_flags, true, true, true, true); + info_box.initialize(fe, mapping); + + MeshWorker::DoFInfo dof_info(dof_handler); + + MeshWorker::Assembler::MatrixSimple > assembler; + assembler.initialize(matrix); + + MeshWorker::integration_loop + (dof_handler.begin_active(), + dof_handler.end(), + dof_info, + info_box, + &MatrixIntegrator::cell, + 0,//&MatrixIntegrator::bdry, + &MatrixIntegrator::face, + assembler); +} + + +template +void +assemble(const MGDoFHandler& dof_handler, + MGLevelObject > matrix, + MGLevelObject > dg_up, + MGLevelObject > dg_down) +{ + const FiniteElement& fe = dof_handler.get_fe(); + MappingQ1 mapping; + + MeshWorker::IntegrationInfoBox info_box; + const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1; + info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points, n_gauss_points); + info_box.initialize_update_flags(); + UpdateFlags update_flags = update_values | update_gradients; + info_box.add_update_flags(update_flags, true, true, true, true); + info_box.initialize(fe, mapping); + + MeshWorker::DoFInfo dof_info(dof_handler); + + MeshWorker::Assembler::MGMatrixSimple > assembler; + assembler.initialize(matrix); + + MeshWorker::loop, MeshWorker::IntegrationInfoBox > + (dof_handler.begin(), + dof_handler.end(), + dof_info, + info_box, + &MatrixIntegrator::cell, + &MatrixIntegrator::bdry, + &MatrixIntegrator::face, + assembler); +} + + +template +void +test_simple(MGDoFHandler& mgdofs) +{ + SparsityPattern pattern; + SparseMatrix matrix; + Vector v; + + const DoFHandler& dofs = mgdofs; + const FiniteElement& fe = dofs.get_fe(); + pattern.reinit (dofs.n_dofs(), dofs.n_dofs(), + (GeometryInfo::faces_per_cell + *GeometryInfo::max_children_per_face+1)*fe.dofs_per_cell); + DoFTools::make_flux_sparsity_pattern (dofs, pattern); + pattern.compress(); + matrix.reinit (pattern); + + assemble(dofs, matrix); + deallog << std::setprecision(3); + matrix.print(deallog); + + MGLevelObject mg_sparsity; + MGLevelObject mg_sparsity_dg_interface; + MGLevelObject > mg_matrix; + MGLevelObject > mg_matrix_dg_up; + MGLevelObject > mg_matrix_dg_down; + + const unsigned int n_levels = mgdofs.get_tria().n_levels(); + + mg_sparsity.resize(0, n_levels-1); + mg_sparsity_dg_interface.resize(0, n_levels-1); + mg_matrix.resize(0, n_levels-1); + mg_matrix_dg_up.resize(0, n_levels-1); + mg_matrix_dg_down.resize(0, n_levels-1); + + for (unsigned int level=mg_sparsity.get_minlevel(); + level<=mg_sparsity.get_maxlevel();++level) + { + CompressedSparsityPattern c_sparsity(mgdofs.n_dofs(level)); + CompressedSparsityPattern ci_sparsity; + if (level>0) + ci_sparsity.reinit(mgdofs.n_dofs(level-1), mgdofs.n_dofs(level)); + + MGTools::make_flux_sparsity_pattern(mgdofs, c_sparsity, level); + if (level>0) + MGTools::make_flux_sparsity_pattern_edge(mgdofs, ci_sparsity, level); + + mg_sparsity[level].copy_from(c_sparsity); + mg_matrix[level].reinit(mg_sparsity[level]); + if (level>0) + { + mg_sparsity_dg_interface[level].copy_from(ci_sparsity); + mg_matrix_dg_up[level].reinit(mg_sparsity_dg_interface[level]); + mg_matrix_dg_down[level].reinit(mg_sparsity_dg_interface[level]); + } + } + +} + + +template +void +test(const FiniteElement& fe) +{ + Triangulation tr; + GridGenerator::hyper_L(tr); + tr.begin()->set_refine_flag(); + tr.execute_coarsening_and_refinement(); +// tr.begin(2)->set_refine_flag(); +// tr.execute_coarsening_and_refinement(); +// tr.refine_global(1); + deallog << "Triangulation levels"; + for (unsigned int l=0;l::cell_iterator cell = tr.begin(); + cell != tr.end(); ++cell, ++cn) + cell->set_user_index(cn); + + MGDoFHandler dofs(tr); + dofs.distribute_dofs(fe); + deallog << "DoFHandler " << dofs.n_dofs() << " levels"; + for (unsigned int l=0;l > > fe2; + fe2.push_back(std_cxx1x::shared_ptr >(new FE_DGP<2>(1))); +// fe2.push_back(std_cxx1x::shared_ptr >(new FE_Q<2>(1))); + + for (unsigned int i=0;i