source: test/unit_test/library/dirichlet_fas_lr.cpp@ fcf7f6

Last change on this file since fcf7f6 was fcf7f6, checked in by Julian Iseringhausen <isering@…>, 14 years ago

vmg: Added license files and headers (GPLv3).

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1812 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * vmg - a versatile multigrid solver
3 * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
4 *
5 * vmg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vmg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * dirichlet_fas_lr.cpp
21 *
22 * Created on: 25.01.2011
23 * Author: Julian Iseringhausen
24 */
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29
30#include <boost/test/unit_test.hpp>
31#include <boost/test/floating_point_comparison.hpp>
32
33#include "base/factory.hpp"
34#include "base/math.hpp"
35#include "base/vector.hpp"
36#include "comm/comm_serial.hpp"
37#include "level/level_operator_fas.hpp"
38#include "level/level_operator.hpp"
39#include "samples/discretization_poisson_fv.hpp"
40#include "samples/techniques.hpp"
41#include "smoother/gsrb.hpp"
42#ifdef HAVE_LAPACK
43#include "solver/dgesv.hpp"
44#endif
45#include "solver/givens.hpp"
46#include "solver/solver_regular.hpp"
47#include "mg.hpp"
48
49#include "interface_sinus.hpp"
50
51using namespace VMG;
52
53const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
54
55struct LibraryDirichletFASLRFixture
56{
57 LibraryDirichletFASLRFixture()
58 {
59 Factory& factory = MG::GetFactory();
60
61 Comm *comm = new CommSerial(Boundary(Dirichlet, Dirichlet, Dirichlet));
62 comm->Register("COMM");
63
64 Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0, 2, 1.6);
65 MG::SetInterface(interface, comm);
66
67 Discretization* discretization = new DiscretizationPoissonFV(2);
68 discretization->Register("DISCRETIZATION");
69
70 LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
71 lop->Register("LEVEL_OPERATOR");
72
73 Smoother* smoother = new GaussSeidelRB();
74 smoother->Register("SMOOTHER");
75
76#ifdef HAVE_LAPACK
77 Solver* solver = new DGESV<SolverRegular>();
78#else
79 Solver* solver = new Givens<SolverRegular>();
80#endif
81
82 solver->Register("SOLVER");
83
84 Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), 2);
85
86 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
87 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
88 factory.RegisterObjectStorage("PRECISION", 1e-10);
89 factory.RegisterObjectStorage("MAX_ITERATION", 8);
90
91 MG::IsInitialized();
92 }
93
94 ~LibraryDirichletFASLRFixture()
95 {
96 MG::Destroy();
97 }
98};
99
100BOOST_FIXTURE_TEST_CASE(LibraryDirichletFASLRTest, LibraryDirichletFASLRFixture)
101{
102 MG::Solve();
103
104 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
105 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
106
107 BOOST_CHECK_SMALL(res/res_init, 1e-10);
108}
Note: See TracBrowser for help on using the repository browser.