source: test/unit_test/library/periodic_fas.cpp@ 06e153

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

Fixed newly introduced error due to unexpected behaviour of git-svn. Sorry.

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

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * periodic_cs.cpp
3 *
4 * Created on: Oct 20, 2010
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 "comm/comm_serial.hpp"
18#include "level/level_operator_fas.hpp"
19#include "samples/discretization_poisson_fd.hpp"
20#include "samples/techniques.hpp"
21#include "smoother/gs.hpp"
22#include "smoother/gsrb.hpp"
23#ifdef HAVE_LAPACK
24#include "solver/dsysv.hpp"
25#endif
26#include "solver/givens.hpp"
27#include "solver/solver_singular.hpp"
28#include "mg.hpp"
29
30#include "interface_sinus.hpp"
31
32using namespace VMG;
33
34const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
35
36struct LibraryPeriodicFASFixture
37{
38 LibraryPeriodicFASFixture()
39 {
40 Factory& factory = MG::GetFactory();
41
42 Comm *comm = new CommSerial(Boundary(Periodic, Periodic, Periodic));
43 comm->Register("COMM");
44
45 Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
46 MG::SetInterface(interface, comm);
47
48 Discretization* discretization = new DiscretizationPoissonFD(2);
49 discretization->Register("DISCRETIZATION");
50
51 LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
52 lop->Register("LEVEL_OPERATOR");
53
54 Smoother* smoother = new GaussSeidelRB();
55 smoother->Register("SMOOTHER");
56
57#ifdef HAVE_LAPACK
58 Solver* solver = new DSYSV<SolverSingular>();
59#else
60 Solver* solver = new Givens<SolverSingular>();
61#endif
62 solver->Register("SOLVER");
63
64 Techniques::SetFullApproximationSchemePeriodic(interface->MinLevel(), interface->MaxLevel(), 2);
65
66 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
67 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
68 factory.RegisterObjectStorage("PRECISION", 1e-10);
69 factory.RegisterObjectStorage("MAX_ITERATION", 7);
70
71 MG::IsInitialized();
72 }
73
74 ~LibraryPeriodicFASFixture()
75 {
76 MG::Destroy();
77 }
78};
79
80BOOST_FIXTURE_TEST_CASE(LibraryPeriodicFASTest, LibraryPeriodicFASFixture)
81{
82 MG::Solve();
83
84 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
85 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
86
87 BOOST_CHECK_SMALL(res/res_init, 1e-10);
88}
Note: See TracBrowser for help on using the repository browser.