source: test/unit_test/smoother_test.cpp@ d24c2f

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

Major vmg update.

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

  • Property mode set to 100644
File size: 1.9 KB
Line 
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 Boundary boundary(Dirichlet, Dirichlet, Dirichlet);
30
31 Comm* comm = new CommSerial(boundary);
32 comm->Register("COMM");
33
34 Discretization* discretization = new DiscretizationPoissonFD();
35 discretization->Register("DISCRETIZATION");
36
37 Interface* interface = new VMGInterfaces::InterfaceSinus(boundary, 4, 4, 0.0, 1.0);
38 MG::SetInterface(interface, comm);
39
40 interface->ImportRightHandSide(*MG::GetRhs());
41
42 gs = new GaussSeidel();
43 gsrb = new GaussSeidelRB();
44}
45
46void SmootherTestSuite::tearDown()
47{
48 MG::Destroy();
49
50 delete gs;
51 delete gsrb;
52}
53
54void SmootherTestSuite::GaussSeidelLEXTest()
55{
56 double norm;
57 Multigrid& sol = *MG::GetSol();
58 Multigrid& rhs = *MG::GetRhs();
59 Comm& comm = *MG::GetComm();
60
61 sol.ClearAll();
62
63 for (int i=0; i<20; ++i) {
64
65 gs->Run(sol, rhs, 50);
66 norm = comm.ComputeResidualNorm(sol, rhs);
67
68 if (norm < 1e-10)
69 break;
70 }
71
72 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Gauss-Seidel LEX smoother does not converge.", 0.0, norm, 1e-10);
73}
74
75
76void SmootherTestSuite::GaussSeidelRBTest()
77{
78 double norm;
79
80 MG::GetSol()->ClearAll();
81
82 for (int i=0; i<20; ++i) {
83
84 gsrb->Run(*MG::GetSol(), *MG::GetRhs(), 50);
85 norm = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
86
87 if (norm < 1e-10)
88 break;
89 }
90
91 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Gauss Seidel RB smoother does not converge.", 0.0, norm, 1e-10);
92}
Note: See TracBrowser for help on using the repository browser.