source: test/unit_test/library/dirichlet_fas_lr_mpi.cpp@ 06e153

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

Fixed newly introduced error due to unexpected behaviour of git-svn. Sorry.

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

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * dirichlet_fas_lr_mpi.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 <boost/test/unit_test.hpp>
13#include <boost/test/floating_point_comparison.hpp>
14
15#ifdef HAVE_MPI
16
17#include <mpi.h>
18#ifdef HAVE_MARMOT
19#include <enhancempicalls.h>
20#include <sourceinfompicalls.h>
21#endif
22
23#include "base/factory.hpp"
24#include "base/math.hpp"
25#include "base/vector.hpp"
26#include "comm/comm_mpi.hpp"
27#include "comm/domain_decomposition_mpi.hpp"
28#include "level/level_operator_fas.hpp"
29#include "level/level_operator.hpp"
30#include "samples/discretization_poisson_fv.hpp"
31#include "samples/techniques.hpp"
32#include "smoother/gsrb.hpp"
33#ifdef HAVE_LAPACK
34#include "solver/dgesv.hpp"
35#endif
36#include "solver/givens.hpp"
37#include "solver/solver_regular.hpp"
38#include "mg.hpp"
39
40#include "interface_sinus.hpp"
41
42using namespace VMG;
43
44const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
45
46struct LibraryDirichletFASLRMPIFixture
47{
48 LibraryDirichletFASLRMPIFixture()
49 {
50 Factory& factory = MG::GetFactory();
51
52 Comm *comm = new CommMPI(Boundary(Dirichlet, Dirichlet, Dirichlet), new DomainDecompositionMPI());
53 comm->Register("COMM");
54
55 Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0, 2, 1.6);
56 MG::SetInterface(interface, comm);
57
58 Discretization* discretization = new DiscretizationPoissonFV(2);
59 discretization->Register("DISCRETIZATION");
60
61 LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
62 lop->Register("LEVEL_OPERATOR");
63
64 Smoother* smoother = new GaussSeidelRB();
65 smoother->Register("SMOOTHER");
66
67#ifdef HAVE_LAPACK
68 Solver* solver = new DGESV<SolverRegular>();
69#else
70 Solver* solver = new Givens<SolverRegular>();
71#endif
72
73 solver->Register("SOLVER");
74
75 Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), 2);
76
77 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
78 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
79 factory.RegisterObjectStorage("PRECISION", 1e-10);
80 factory.RegisterObjectStorage("MAX_ITERATION", 8);
81
82 MG::IsInitialized();
83
84 MG::PostInit();
85 }
86
87 ~LibraryDirichletFASLRMPIFixture()
88 {
89 MG::Destroy();
90 }
91};
92
93BOOST_FIXTURE_TEST_CASE(LibraryDirichletFASLRMPITest, LibraryDirichletFASLRMPIFixture)
94{
95 MG::Solve();
96
97 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
98 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
99
100 BOOST_CHECK_SMALL(res/res_init, 1e-10);
101}
102
103#endif /* HAVE_MPI */
Note: See TracBrowser for help on using the repository browser.