From ebc20705abbc594cd722568c1ce9b4aed0367d16 Mon Sep 17 00:00:00 2001 From: janssen Date: Mon, 8 Mar 2010 21:25:11 +0000 Subject: [PATCH] cc file for adaptive test git-svn-id: https://svn.dealii.org/trunk@20752 0785d39b-7218-0410-832d-ea1e28bc413d --- .../multigrid/transfer_system_adaptive_01.cc | 197 ++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 tests/multigrid/transfer_system_adaptive_01.cc diff --git a/tests/multigrid/transfer_system_adaptive_01.cc b/tests/multigrid/transfer_system_adaptive_01.cc new file mode 100644 index 0000000000..e0feb8cd83 --- /dev/null +++ b/tests/multigrid/transfer_system_adaptive_01.cc @@ -0,0 +1,197 @@ +//---------------------------------------------------------------------------- +// transfer.cc,v 1.13 2005/12/30 16:07:03 guido Exp +// Version: +// +// Copyright (C) 2000 - 2007, 2009, 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. +// +//---------------------------------------------------------------------------- + +// test TransferPrebuilt with system elements on adaptively refined meshes + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +template +void +reinit_vector (const dealii::MGDoFHandler &mg_dof, + MGLevelObject > &v) +{ + for (unsigned int level=v.get_minlevel(); + level<=v.get_maxlevel();++level) + { + unsigned int n = mg_dof.n_dofs (level); + v[level].reinit(n); + } + +} + + +template +void +make_matrix (const Transfer &transfer, + const unsigned int high_level, + FullMatrix &matrix) +{ + Vector src (matrix.n()); + Vector dst (matrix.m()); + for (unsigned int i=0; i &m) +{ + for (unsigned int i=0; i +void refine_mesh (Triangulation &triangulation) +{ + bool cell_refined = false; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + { + const Point p = cell->center(); + bool positive = p(0) > 0; + //if (dim>1 && p(1) <= 0) + // positive = false; + //if (dim>2 && p(2) <= 0) + // positive = false; + if (positive) + { + cell->set_refine_flag(); + cell_refined = true; + } + } + //Wenn nichts verfeinert wurde bisher, global verfeinern! + if(!cell_refined) + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + cell->set_refine_flag(); + triangulation.execute_coarsening_and_refinement (); +} + + + +template +void check (const FiniteElement& fe) +{ + deallog << fe.get_name() << std::endl; + + Triangulation tr; + + std::vector subdivisions (dim, 1); + subdivisions[0] = 2; + + const Point bottom_left = (dim == 2 ? + Point(-1,-1) : Point(-1,-1,-1)); + const Point top_right = (dim == 2 ? + Point(1,1) : Point(1,1,1)); + GridGenerator::subdivided_hyper_rectangle (tr, + subdivisions, bottom_left, top_right, true); + refine_mesh(tr); +// tr.refine_global(1); + std::ostringstream out_filename; + out_filename<< "gitter.eps"; + std::ofstream grid_output(out_filename.str().c_str()); + GridOut grid_out; + grid_out.write_eps (tr, grid_output); + + + MGDoFHandler mg_dof_handler(tr); + mg_dof_handler.distribute_dofs(fe); + + deallog << "Global dofs: " << mg_dof_handler.n_dofs() << std::endl; + for(unsigned int l=0; l > boundary_indices(tr.n_levels()); + typename FunctionMap::type dirichlet_boundary; + ZeroFunction dirichlet_bc(fe.n_components()); + dirichlet_boundary[0] = &dirichlet_bc; + + MGTools::make_boundary_list (mg_dof_handler, dirichlet_boundary, + boundary_indices); + + MGTransferPrebuilt > transfer; + transfer.build_matrices(mg_dof_handler);//, boundary_indices); + + FullMatrix prolong_0_1 (mg_dof_handler.n_dofs(1), + mg_dof_handler.n_dofs(0)); +// FullMatrix prolong_1_2 (mg_dof_handler.n_dofs(2), +// mg_dof_handler.n_dofs(1)); + + deallog << "Level 0->1" << std::endl; + make_matrix (transfer, 1, prolong_0_1); + print_matrix (prolong_0_1); + + deallog << std::endl; + + //deallog << "Level 1->2" << std::endl; + //make_matrix (transfer, 2, prolong_1_2); + //print_matrix (prolong_1_2); +} + + +int main() +{ + std::ofstream logfile("transfer_system_adaptive_01/output"); + deallog << std::setprecision(4); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + +//TODO: do in 1d + check (FESystem<2>(FE_Q<2>(1),2)); +} -- 2.39.5