source: test/unit_test/smoother_test.cpp@ 2fad0e0

Last change on this file since 2fad0e0 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: 1.8 KB
RevLine 
[48b662]1/*
2 * smoother_test.cpp
3 *
4 * Created on: 20.09.2010
5 * Author: Julian Iseringhausen
6 */
7
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
12#include "comm/comm_serial.hpp"
13#include "interface/interface.hpp"
14#include "samples/discretization_poisson_fd.hpp"
15#include "smoother/gs.hpp"
16#include "smoother/gsrb.hpp"
17#include "mg.hpp"
18
19#include "interface_sinus.hpp"
20#include "smoother_test.hpp"
21
22using namespace VMG;
23using VMGTests::SmootherTestSuite;
24
25CPPUNIT_TEST_SUITE_REGISTRATION(SmootherTestSuite);
26
27void SmootherTestSuite::setUp()
28{
29 Comm* comm = new CommSerial(Dirichlet);
30 comm->Register("COMM");
31
32 Discretization* discretization = new DiscretizationPoissonFD();
33 discretization->Register("DISCRETIZATION");
34
35 Interface* interface = new VMGInterfaces::InterfaceSinus(Dirichlet, 4, 4, 0.0, 1.0);
36 MG::SetInterface(interface, comm);
37
38 interface->ImportRightHandSide(*MG::GetRhs());
39
40 gs = new GaussSeidel();
41 gsrb = new GaussSeidelRB();
42}
43
44void SmootherTestSuite::tearDown()
45{
46 delete gs;
47 delete gsrb;
48}
49
50void SmootherTestSuite::GaussSeidelLEXTest()
51{
52 double norm;
53
54 MG::GetSol()->ClearAll();
55
56 for (int i=0; i<20; ++i) {
57
58 gs->Run(*MG::GetSol(), *MG::GetRhs(), 50);
59 norm = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
60
61 if (norm < 1e-10)
62 break;
63 }
64
65 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Gauss-Seidel LEX smoother does not converge.", 0.0, norm, 1e-10);
66}
67
68
69void SmootherTestSuite::GaussSeidelRBTest()
70{
71 double norm;
72
73 MG::GetSol()->ClearAll();
74
75 for (int i=0; i<20; ++i) {
76
77 gsrb->Run(*MG::GetSol(), *MG::GetRhs(), 50);
78 norm = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
79
80 if (norm < 1e-10)
81 break;
82 }
83
84 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Gauss Seidel RB smoother does not converge.", 0.0, norm, 1e-10);
85}
Note: See TracBrowser for help on using the repository browser.