source: test/unit_test/dirichlet_fas.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: 2.3 KB
RevLine 
[48b662]1/*
2 * dirichlet_fas.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_fas.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"
[dfed1c]25#include "solver/solver_regular.hpp"
[48b662]26#include "mg.hpp"
27
28#include "interface_sinus.hpp"
29#include "dirichlet_fas.hpp"
30
31using namespace VMG;
32using VMGTests::DirichletFASTestSuite;
33
34CPPUNIT_TEST_SUITE_REGISTRATION(DirichletFASTestSuite);
35
36void DirichletFASTestSuite::setUp()
37{
38 Factory& factory = MG::GetFactory();
39
[dfed1c]40 Comm *comm = new CommSerial(Boundary(Dirichlet, Dirichlet, Dirichlet));
[48b662]41 comm->Register("COMM");
42
[dfed1c]43 Interface* interface = new VMGInterfaces::InterfaceSinus(comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
[48b662]44 MG::SetInterface(interface, comm);
45
46 Discretization* discretization = new DiscretizationPoissonFD();
47 discretization->Register("DISCRETIZATION");
48
49 LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
50 lop->Register("LEVEL_OPERATOR");
51
52 Smoother* smoother = new GaussSeidelRB();
53 smoother->Register("SMOOTHER");
54
55#ifdef HAVE_LAPACK
[dfed1c]56 Solver* solver = new DGESV<SolverRegular>();
[48b662]57#else
[dfed1c]58 Solver* solver = new Givens<SolverRegular>();
[48b662]59#endif
60
61 solver->Register("SOLVER");
62
63 Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), 2);
64
65 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
66 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
67 factory.RegisterObjectStorage("PRECISION", 1e-10);
68 factory.RegisterObjectStorage("MAX_ITERATION", 20);
69
70 MG::IsInitialized();
71}
72
73void DirichletFASTestSuite::tearDown()
74{
75 MG::Destroy();
76}
77
78void DirichletFASTestSuite::DirichletFASTest()
79{
80 MG::Solve();
81
[dfed1c]82 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
[48b662]83 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
84
85 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, fabs(res/res_init), 1e-10);
86}
Note: See TracBrowser for help on using the repository browser.