source: test/unit_test/periodic_cs.cpp@ 48b662

Last change on this file since 48b662 was 48b662, checked in by Olaf Lenz <olenz@…>, 14 years ago

Moved files in scafacos_fcs one level up.

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

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * lib_test.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 "base/factory.hpp"
13#include "comm/comm_serial.hpp"
14#include "level/level_operator_cs.hpp"
15#include "samples/discretization_poisson_fd.hpp"
16#include "samples/stencils.hpp"
17#include "samples/techniques.hpp"
18#include "smoother/gs.hpp"
19#include "smoother/gsrb.hpp"
20#ifdef HAVE_LAPACK
21#include "solver/dsysv.hpp"
22#endif
23#include "solver/givens.hpp"
24#include "solver/solver_periodic.hpp"
25#include "mg.hpp"
26
27#include "interface_sinus.hpp"
28#include "periodic_cs.hpp"
29
30using namespace VMG;
31using VMGTests::PeriodicCSTestSuite;
32
33CPPUNIT_TEST_SUITE_REGISTRATION(PeriodicCSTestSuite);
34
35void PeriodicCSTestSuite::setUp()
36{
37 Factory& factory = MG::GetFactory();
38
39 Comm *comm = new CommSerial(Periodic);
40 comm->Register("COMM");
41
42 Interface* interface = new VMGInterfaces::InterfaceSinus(Periodic, 2, 6, 0.0, 1.0);
43 MG::SetInterface(interface, comm);
44
45 Discretization* discretization = new DiscretizationPoissonFD();
46 discretization->Register("DISCRETIZATION");
47
48 LevelOperator* lop = new LevelOperatorCS(Stencils::RestrictionFullWeight, Stencils::InterpolationTrilinear);
49 lop->Register("LEVEL_OPERATOR");
50
51 Smoother* smoother = new GaussSeidelRB();
52 smoother->Register("SMOOTHER");
53
54#ifdef HAVE_LAPACK
55 Solver* solver = new DSYSV<SolverPeriodic>();
56#else
57 Solver* solver = new Givens<SolverPeriodic>();
58#endif
59 solver->Register("SOLVER");
60
61 Techniques::SetCorrectionSchemePeriodic(interface->MinLevel(), interface->MaxLevel(), 2);
62
63 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
64 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
65 factory.RegisterObjectStorage("PRECISION", 1e-10);
66 factory.RegisterObjectStorage("MAX_ITERATION", 20);
67
68 MG::IsInitialized();
69}
70
71void PeriodicCSTestSuite::tearDown()
72{
73 MG::Destroy();
74}
75
76void PeriodicCSTestSuite::PeriodicCSTest()
77{
78 MG::Solve();
79
80 double res_init = MG::GetFactory().GetObject("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
81 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
82
83 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, fabs(res/res_init), 1e-10);
84}
Note: See TracBrowser for help on using the repository browser.