source: test/unit_test/library/periodic_fas_mpi.cpp@ b2154a3

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

Merge recent changes of the vmg library into ScaFaCos.

Includes a fix for the communication problems on Jugene.

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

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[dfed1c]1/*
2 * periodic_fas_mpi.cpp
3 *
4 * Created on: Oct 20, 2010
5 * Author: Julian Iseringhausen
6 */
7
8#ifdef HAVE_CONFIG_H
9#include <config.h>
10#endif
11
[ac6d04]12#include <boost/test/unit_test.hpp>
13#include <boost/test/floating_point_comparison.hpp>
14
[dfed1c]15#ifdef HAVE_MPI
16
17#include <mpi.h>
[ac6d04]18#ifdef HAVE_MARMOT
19#include <enhancempicalls.h>
20#include <sourceinfompicalls.h>
21#endif
[dfed1c]22
23#include "base/factory.hpp"
[ac6d04]24#include "base/math.hpp"
[dfed1c]25#include "comm/comm_mpi.hpp"
26#include "comm/domain_decomposition_mpi.hpp"
27#include "level/level_operator_fas.hpp"
28#include "samples/discretization_poisson_fd.hpp"
29#include "samples/stencils.hpp"
30#include "samples/techniques.hpp"
31#include "smoother/gs.hpp"
32#include "smoother/gsrb.hpp"
33#ifdef HAVE_LAPACK
34#include "solver/dsysv.hpp"
35#endif
36#include "solver/givens.hpp"
37#include "solver/solver_singular.hpp"
38#include "mg.hpp"
39
40#include "interface_sinus.hpp"
41
42using namespace VMG;
43
[ac6d04]44const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
[dfed1c]45
[ac6d04]46struct LibraryPeriodicFASMPIFixture
[dfed1c]47{
[ac6d04]48 LibraryPeriodicFASMPIFixture()
49 {
[dfed1c]50 Factory& factory = MG::GetFactory();
51
52 Comm* comm = new CommMPI(Boundary(Periodic, Periodic, Periodic), new DomainDecompositionMPI());
53 comm->Register("COMM");
54
[ac6d04]55 Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
[dfed1c]56 MG::SetInterface(interface, comm);
57
58 Discretization* discretization = new DiscretizationPoissonFD();
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 DSYSV<SolverSingular>();
69#else
70 Solver* solver = new Givens<SolverSingular>();
71#endif
72 solver->Register("SOLVER");
73
74 Techniques::SetFullApproximationSchemePeriodic(interface->MinLevel(), interface->MaxLevel(), 2);
75
76 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
77 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
78 factory.RegisterObjectStorage("PRECISION", 1e-10);
[ac6d04]79 factory.RegisterObjectStorage("MAX_ITERATION", 7);
[dfed1c]80
81 MG::IsInitialized();
82
[ac6d04]83 MG::PostInit();
84 }
85
86 ~LibraryPeriodicFASMPIFixture()
87 {
[dfed1c]88 MG::Destroy();
[ac6d04]89 }
90};
[dfed1c]91
[ac6d04]92BOOST_FIXTURE_TEST_CASE(LibraryPeriodicFASMPITest, LibraryPeriodicFASMPIFixture)
[dfed1c]93{
94 MG::Solve();
95
96 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
97 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
98
[ac6d04]99 BOOST_CHECK_SMALL(res/res_init, 1e-10);
[dfed1c]100}
101
102#endif /* HAVE_MPI */
Note: See TracBrowser for help on using the repository browser.