From: guido Date: Wed, 26 Sep 2001 14:12:35 +0000 (+0000) Subject: multigrid moved X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5da8fb312604900bcdab805b8291ebd65325e1be;p=dealii-svn.git multigrid moved git-svn-id: https://svn.dealii.org/trunk@5102 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/deal.II/Makefile b/tests/deal.II/Makefile index ab4185745f..f421960a69 100644 --- a/tests/deal.II/Makefile +++ b/tests/deal.II/Makefile @@ -46,12 +46,11 @@ boundaries.exe : boundaries.go $(lib-1d) $(lib-2d) $ sparsity_pattern.exe : sparsity_pattern.go $(lib-1d) $(lib-2d) $(lib-3d) $(libraries) grid_tools.exe : grid_tools.go $(lib-1d) $(lib-2d) $(lib-3d) $(libraries) -tests = grid_test grid_transform dof_test data_out derivatives gradients constraints mg \ - mglocal block_matrices second_derivatives derivative_approximation \ +tests = grid_test grid_transform dof_test data_out derivatives gradients \ + constraints block_matrices second_derivatives derivative_approximation \ matrices error_estimator intergrid_constraints intergrid_map \ wave-test-3 dof_renumbering support_point_map filtered_matrix \ boundaries sparsity_pattern grid_tools - ############################################################ diff --git a/tests/deal.II/mg.cc b/tests/deal.II/mg.cc deleted file mode 100644 index 453a58ca1e..0000000000 --- a/tests/deal.II/mg.cc +++ /dev/null @@ -1,205 +0,0 @@ -//---------------------------- mg.cc --------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 1998, 1999, 2000, 2001 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. -// -//---------------------------- mg.cc --------------------------- - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -MappingQ1<2> mapping; - -#include "helmholtz.h" - -#include - - -template -class RHSFunction : public Function -{ - public: - virtual double value (const Point&, - const unsigned int) const; -}; - - -class MGSmootherLAC : public MGSmootherBase -{ - private: - SmartPointer > >matrices; - public: - MGSmootherLAC(MGLevelObject >&); - - virtual void smooth (const unsigned int level, - Vector &u, - const Vector &rhs) const; - -}; - -int main() -{ - try - { - std::ofstream logfile("mg.output"); - deallog.attach(logfile); - deallog.depth_console(0); - - Helmholtz equation; - RHSFunction<2> rhs; - QGauss5<2> quadrature; - - FE_Q<2> fe1(1); - FE_Q<2> fe2(2); - FE_Q<2> fe3(3); - FE_Q<2> fe4(4); - for (unsigned int degree=1;degree<=3;degree++) - { - Triangulation<2> tr; - MGDoFHandler<2> mgdof(tr); - DoFHandler<2>& dof(mgdof); - - GridGenerator::hyper_cube(tr,-1.,1.); - - FiniteElement<2>* fe; - switch(degree) - { - case 1: fe = &fe1; deallog.push("Q1"); break; - case 2: fe = &fe2; deallog.push("Q2"); break; - case 3: fe = &fe3; deallog.push("Q3"); break; - case 4: fe = &fe4; deallog.push("Q4"); break; - } - - for (unsigned int step=0;step < 3; ++step) - { - tr.refine_global(1); - dof.distribute_dofs(*fe); - - ConstraintMatrix hanging_nodes; - DoFTools::make_hanging_node_constraints(dof, hanging_nodes); - hanging_nodes.close(); - - const unsigned int size = dof.n_dofs(); - deallog << "DoFs " << size << std::endl; - deallog << "Levels: " << tr.n_levels() << std::endl; - - SparsityPattern structure(size, dof.max_couplings_between_dofs()); - DoFTools::make_sparsity_pattern(dof, structure); - structure.compress(); - - SparseMatrix A(structure); - Vector f(size); - - equation.build_all(A,f,dof, quadrature, rhs); - - Vector u; - u.reinit(f); - PrimitiveVectorMemory<> mem; - SolverControl control(1000, 1.e-10,false , true); - SolverCG<> solver(control, mem); - - u = 0.; - MGLevelObject mgstruct(0, tr.n_levels()-1); - MGLevelObject > mgA(0,tr.n_levels()-1); - for (unsigned int i=0;i cgmem; - SolverCG<> cgsolver(cgcontrol, cgmem); - PreconditionIdentity cgprec; - MGCoarseGridLACIteration, SparseMatrix, PreconditionIdentity> - coarse(cgsolver, mgA[0], cgprec); - - MGSmootherLAC smoother(mgA); - MGTransferPrebuilt transfer; - transfer.build_matrices(mgdof); - - -Multigrid<2> multigrid(mgdof, hanging_nodes, mgstruct, mgA, transfer); - PreconditionMG > - mgprecondition(multigrid, smoother, smoother, coarse); - - solver.solve(A, u, f, mgprecondition); - } - deallog.pop(); - } - - } - catch (const SolverControl::NoConvergence& e) - { - deallog << "Step " << e.last_step - << " Residual " << e.last_residual << std::endl; - } -} - -template -double -RHSFunction::value (const Point&, - const unsigned int) const -{ - return 1.; -} - -MGSmootherLAC::MGSmootherLAC(MGLevelObject >& matrix) - : - matrices(&matrix) -{} - -void -MGSmootherLAC::smooth (const unsigned int level, - Vector &u, - const Vector &rhs) const -{ - SolverControl control(2,1.e-300,false,false); - PrimitiveVectorMemory<> mem; - SolverRichardson<> rich(control, mem); - PreconditionSSOR<> prec; - prec.initialize((*matrices)[level], 1.); - - try - { - rich.solve((*matrices)[level], u, rhs, prec); - } - catch (const SolverControl::NoConvergence&) - { - } -} diff --git a/tests/deal.II/mg.checked b/tests/deal.II/mg.checked deleted file mode 100644 index 60791912fc..0000000000 --- a/tests/deal.II/mg.checked +++ /dev/null @@ -1,37 +0,0 @@ - -DEAL:Q1::DoFs 9 -DEAL:Q1::Levels: 2 -DEAL:Q1:cg::Starting -DEAL:Q1:cg::Convergence step 3 -DEAL:Q1::DoFs 25 -DEAL:Q1::Levels: 3 -DEAL:Q1:cg::Starting -DEAL:Q1:cg::Convergence step 4 -DEAL:Q1::DoFs 81 -DEAL:Q1::Levels: 4 -DEAL:Q1:cg::Starting -DEAL:Q1:cg::Convergence step 5 -DEAL:Q2::DoFs 25 -DEAL:Q2::Levels: 2 -DEAL:Q2:cg::Starting -DEAL:Q2:cg::Convergence step 5 -DEAL:Q2::DoFs 81 -DEAL:Q2::Levels: 3 -DEAL:Q2:cg::Starting -DEAL:Q2:cg::Convergence step 6 -DEAL:Q2::DoFs 289 -DEAL:Q2::Levels: 4 -DEAL:Q2:cg::Starting -DEAL:Q2:cg::Convergence step 6 -DEAL:Q3::DoFs 49 -DEAL:Q3::Levels: 2 -DEAL:Q3:cg::Starting -DEAL:Q3:cg::Convergence step 6 -DEAL:Q3::DoFs 169 -DEAL:Q3::Levels: 3 -DEAL:Q3:cg::Starting -DEAL:Q3:cg::Convergence step 6 -DEAL:Q3::DoFs 625 -DEAL:Q3::Levels: 4 -DEAL:Q3:cg::Starting -DEAL:Q3:cg::Convergence step 6 diff --git a/tests/deal.II/mglocal.cc b/tests/deal.II/mglocal.cc deleted file mode 100644 index 91b2da484b..0000000000 --- a/tests/deal.II/mglocal.cc +++ /dev/null @@ -1,212 +0,0 @@ -//---------------------------- mglocal.cc --------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 1998, 1999, 2000, 2001 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. -// -//---------------------------- mglocal.cc --------------------------- - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -MGSmoother* smoother_object; - -// Does anybody know why cmath does not do this? - -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 -#endif - - -int step_counter = 0; - -#include "helmholtz.h" - -template -class RHSFunction - : - public Function -{ - public: - virtual double value (const Point&, - const unsigned int ) const; -}; - -extern void write_gnuplot (const MGDoFHandler<2>& dofs, - const Vector& v, - unsigned int level, - std::ostream &out); - -int main() -{ - std::ofstream logfile("mglocal.output"); - // logfile.setf(std::ios::fixed); - // logfile.precision (3); - deallog.attach(logfile); -// deallog.log_execution_time(true); - deallog.depth_console(0); - - deallog << "Test" << std::endl; - - Helmholtz equation; - RHSFunction<2> rhs; - QGauss5<2> quadrature; - - for (unsigned int degree=1;degree<=1;degree++) - { - Triangulation<2> tr; - GridGenerator::hyper_cube(tr,-M_PI_2,M_PI_2); - - tr.refine_global(1); - Triangulation<2>::active_cell_iterator cell = tr.begin_active(); - cell->set_refine_flag(); - tr.execute_coarsening_and_refinement(); - - tr.refine_global(1); - - FE_Q<2> fe(degree); - - MGDoFHandler<2> mgdof(tr); - DoFHandler<2>& dof(mgdof); - - dof.distribute_dofs(fe); - const unsigned int size = dof.n_dofs(); - deallog << "DoFs " << size << std::endl; - deallog << "Levels: " << tr.n_levels() << std::endl; - for (unsigned int step=1;step < 3; ++step) - { - deallog << "smoothing-steps" << step << std::endl; - SparsityPattern structure(size, dof.max_couplings_between_dofs()); - DoFTools::make_sparsity_pattern(dof, structure); - - ConstraintMatrix hanging_nodes; - DoFTools::make_hanging_node_constraints (dof, hanging_nodes); - hanging_nodes.close(); - hanging_nodes.condense(structure); - - structure.compress(); - - SparseMatrix A(structure); - Vector f(size); - - equation.build_all(A,f,dof, quadrature, rhs); - - hanging_nodes.condense(A); - hanging_nodes.condense(f); - - if (false) - { - std::ofstream out_file("MGf"); - DataOut<2> out; - out.attach_dof_handler(dof); - out.add_data_vector(f, "v"); - out.build_patches(5); - out.write_gnuplot(out_file); - } - - Vector u; - u.reinit(f); - PrimitiveVectorMemory<> mem; - - SolverControl control(2000, 1.e-12, false); - SolverCG<> solver(control, mem); - - MGLevelObject mgstruct(0, tr.n_levels()-1); - MGLevelObject > mgA(0,tr.n_levels()-1); - for (unsigned int i=0;i cgmem; - SolverCG<> cgsolver(cgcontrol, cgmem); - PreconditionIdentity cgprec; - MGCoarseGridLACIteration, SparseMatrix, PreconditionIdentity> - coarse(cgsolver, mgA[tr.n_levels()-2], cgprec); - - MGSmootherRelaxation - smoother(mgdof, mgA, &SparseMatrix::template precondition_SSOR, - step, 1.); - smoother_object = &smoother; - - MGTransferPrebuilt transfer; - transfer.build_matrices(mgdof); - - -Multigrid<2> multigrid(mgdof, hanging_nodes, mgstruct, mgA, transfer, tr.n_levels()-2); - PreconditionMG > - mgprecondition(multigrid, smoother, smoother, coarse); - - u = 0.; - - solver.solve(A, u, f, mgprecondition); - hanging_nodes.distribute(u); - - if (false) - { - DataOut<2> out; - char* name = new char[100]; - - sprintf(name, "MG-Q%d-%d", degree, step); - - std::ofstream ofile(name); - out.attach_dof_handler(dof); - out.add_data_vector(u,"u"); - out.add_data_vector(f,"f"); - out.build_patches(5); - out.write_gnuplot(ofile); - delete[] name; - } - } - deallog.pop(); - } -} - -template -double -RHSFunction::value (const Point&p, - const unsigned int) const -{ - return 1.; - - return p(0)*p(0)+p(1)*p(1); - - return (2.1)*(sin(p(0))* sin(p(1))); -} diff --git a/tests/deal.II/mglocal.checked b/tests/deal.II/mglocal.checked deleted file mode 100644 index 79c0f825d5..0000000000 --- a/tests/deal.II/mglocal.checked +++ /dev/null @@ -1,10 +0,0 @@ - -DEAL::Test -DEAL::DoFs 41 -DEAL::Levels: 4 -DEAL::smoothing-steps1 -DEAL:cg::Starting -DEAL:cg::Convergence step 8 -DEAL::smoothing-steps2 -DEAL:cg::Starting -DEAL:cg::Convergence step 7