source: test/unit_test/library/dirichlet_fas.cpp@ 6f05224

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

vmg: Implement fourth-order discretization of the Poisson equation.

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

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * dirichlet_fas.cpp
3 *
4 * Created on: 25.01.2011
5 * Author: Julian Iseringhausen
6 */
7
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12#include <boost/test/unit_test.hpp>
13#include <boost/test/floating_point_comparison.hpp>
14
15#include "base/factory.hpp"
16#include "base/math.hpp"
17#include "base/vector.hpp"
18#include "comm/comm_serial.hpp"
19#include "level/level_operator_fas.hpp"
20#include "level/level_operator.hpp"
21#include "samples/discretization_poisson_fd.hpp"
22#include "samples/stencils.hpp"
23#include "samples/techniques.hpp"
24#include "smoother/gsrb.hpp"
25#ifdef HAVE_LAPACK
26#include "solver/dgesv.hpp"
27#endif
28#include "solver/givens.hpp"
29#include "solver/solver_regular.hpp"
30#include "mg.hpp"
31
32#include "interface_sinus.hpp"
33
34using namespace VMG;
35
36const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
37
38struct LibraryDirichletFASFixture
39{
40 LibraryDirichletFASFixture()
41 {
42 Factory& factory = MG::GetFactory();
43
44 Comm *comm = new CommSerial(Boundary(Dirichlet, Dirichlet, Dirichlet));
45 comm->Register("COMM");
46
47 Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
48 MG::SetInterface(interface, comm);
49
50 Discretization* discretization = new DiscretizationPoissonFD(2);
51 discretization->Register("DISCRETIZATION");
52
53 LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
54 lop->Register("LEVEL_OPERATOR");
55
56 Smoother* smoother = new GaussSeidelRB();
57 smoother->Register("SMOOTHER");
58
59#ifdef HAVE_LAPACK
60 Solver* solver = new DGESV<SolverRegular>();
61#else
62 Solver* solver = new Givens<SolverRegular>();
63#endif
64
65 solver->Register("SOLVER");
66
67 Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), 2);
68
69 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
70 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
71 factory.RegisterObjectStorage("PRECISION", 1e-10);
72 factory.RegisterObjectStorage("MAX_ITERATION", 7);
73
74 MG::IsInitialized();
75 }
76
77 ~LibraryDirichletFASFixture()
78 {
79 MG::Destroy();
80 }
81};
82
83BOOST_FIXTURE_TEST_CASE(LibraryDirichletFASTest, LibraryDirichletFASFixture)
84{
85 MG::Solve();
86
87 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
88 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
89
90 BOOST_CHECK_SMALL(res/res_init, 1e-10);
91}
Note: See TracBrowser for help on using the repository browser.