source: test/unit_test/library/dirichlet_cs_mpi.cpp@ b7b317

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