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