| 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/stencils.hpp"
|
|---|
| 32 | #include "samples/techniques.hpp"
|
|---|
| 33 | #include "smoother/gsrb.hpp"
|
|---|
| 34 | #ifdef HAVE_LAPACK
|
|---|
| 35 | #include "solver/dgesv.hpp"
|
|---|
| 36 | #endif
|
|---|
| 37 | #include "solver/givens.hpp"
|
|---|
| 38 | #include "solver/solver_regular.hpp"
|
|---|
| 39 | #include "mg.hpp"
|
|---|
| 40 |
|
|---|
| 41 | #include "interface_sinus.hpp"
|
|---|
| 42 |
|
|---|
| 43 | using namespace VMG;
|
|---|
| 44 |
|
|---|
| 45 | const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
|
|---|
| 46 |
|
|---|
| 47 | struct LibraryDirichletFASLRMPIFixture
|
|---|
| 48 | {
|
|---|
| 49 | LibraryDirichletFASLRMPIFixture()
|
|---|
| 50 | {
|
|---|
| 51 | Factory& factory = MG::GetFactory();
|
|---|
| 52 |
|
|---|
| 53 | Comm *comm = new CommMPI(Boundary(Dirichlet, Dirichlet, Dirichlet), new DomainDecompositionMPI());
|
|---|
| 54 | comm->Register("COMM");
|
|---|
| 55 |
|
|---|
| 56 | Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0, 2, 1.6);
|
|---|
| 57 | MG::SetInterface(interface, comm);
|
|---|
| 58 |
|
|---|
| 59 | Discretization* discretization = new DiscretizationPoissonFV(2);
|
|---|
| 60 | discretization->Register("DISCRETIZATION");
|
|---|
| 61 |
|
|---|
| 62 | LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
|
|---|
| 63 | lop->Register("LEVEL_OPERATOR");
|
|---|
| 64 |
|
|---|
| 65 | Smoother* smoother = new GaussSeidelRB();
|
|---|
| 66 | smoother->Register("SMOOTHER");
|
|---|
| 67 |
|
|---|
| 68 | #ifdef HAVE_LAPACK
|
|---|
| 69 | Solver* solver = new DGESV<SolverRegular>();
|
|---|
| 70 | #else
|
|---|
| 71 | Solver* solver = new Givens<SolverRegular>();
|
|---|
| 72 | #endif
|
|---|
| 73 |
|
|---|
| 74 | solver->Register("SOLVER");
|
|---|
| 75 |
|
|---|
| 76 | Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), 2);
|
|---|
| 77 |
|
|---|
| 78 | factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
|
|---|
| 79 | factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
|
|---|
| 80 | factory.RegisterObjectStorage("PRECISION", 1e-10);
|
|---|
| 81 | factory.RegisterObjectStorage("MAX_ITERATION", 8);
|
|---|
| 82 |
|
|---|
| 83 | MG::IsInitialized();
|
|---|
| 84 |
|
|---|
| 85 | MG::PostInit();
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | ~LibraryDirichletFASLRMPIFixture()
|
|---|
| 89 | {
|
|---|
| 90 | MG::Destroy();
|
|---|
| 91 | }
|
|---|
| 92 | };
|
|---|
| 93 |
|
|---|
| 94 | BOOST_FIXTURE_TEST_CASE(LibraryDirichletFASLRMPITest, LibraryDirichletFASLRMPIFixture)
|
|---|
| 95 | {
|
|---|
| 96 | MG::Solve();
|
|---|
| 97 |
|
|---|
| 98 | double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
|
|---|
| 99 | double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
|
|---|
| 100 |
|
|---|
| 101 | BOOST_CHECK_SMALL(res/res_init, 1e-10);
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | #endif /* HAVE_MPI */
|
|---|