| [dfed1c] | 1 | /*
|
|---|
| 2 | * periodic_cs_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 |
|
|---|
| 12 | #ifdef HAVE_MPI
|
|---|
| 13 |
|
|---|
| 14 | #include <mpi.h>
|
|---|
| 15 |
|
|---|
| 16 | #include "base/factory.hpp"
|
|---|
| 17 | #include "comm/comm_mpi.hpp"
|
|---|
| 18 | #include "comm/domain_decomposition_mpi.hpp"
|
|---|
| 19 | #include "level/level_operator_cs.hpp"
|
|---|
| 20 | #include "samples/discretization_poisson_fd.hpp"
|
|---|
| 21 | #include "samples/stencils.hpp"
|
|---|
| 22 | #include "samples/techniques.hpp"
|
|---|
| 23 | #include "smoother/gs.hpp"
|
|---|
| 24 | #include "smoother/gsrb.hpp"
|
|---|
| 25 | #ifdef HAVE_LAPACK
|
|---|
| 26 | #include "solver/dsysv.hpp"
|
|---|
| 27 | #endif
|
|---|
| 28 | #include "solver/givens.hpp"
|
|---|
| 29 | #include "solver/solver_singular.hpp"
|
|---|
| 30 | #include "mg.hpp"
|
|---|
| 31 |
|
|---|
| 32 | #include "interface_sinus.hpp"
|
|---|
| 33 | #include "periodic_cs_mpi.hpp"
|
|---|
| 34 |
|
|---|
| 35 | using namespace VMG;
|
|---|
| 36 | using VMGTests::PeriodicCSMPITestSuite;
|
|---|
| 37 |
|
|---|
| 38 | CPPUNIT_TEST_SUITE_REGISTRATION(PeriodicCSMPITestSuite);
|
|---|
| 39 |
|
|---|
| 40 | void PeriodicCSMPITestSuite::setUp()
|
|---|
| 41 | {
|
|---|
| 42 | Factory& factory = MG::GetFactory();
|
|---|
| 43 |
|
|---|
| 44 | Comm *comm = new CommMPI(Boundary(Periodic, Periodic, Periodic), new DomainDecompositionMPI());
|
|---|
| 45 | comm->Register("COMM");
|
|---|
| 46 |
|
|---|
| 47 | Interface* interface = new VMGInterfaces::InterfaceSinus(comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
|
|---|
| 48 | MG::SetInterface(interface, comm);
|
|---|
| 49 |
|
|---|
| 50 | Discretization* discretization = new DiscretizationPoissonFD();
|
|---|
| 51 | discretization->Register("DISCRETIZATION");
|
|---|
| 52 |
|
|---|
| 53 | LevelOperator* lop = new LevelOperatorCS(Stencils::RestrictionFullWeight, Stencils::InterpolationTrilinear);
|
|---|
| 54 | lop->Register("LEVEL_OPERATOR");
|
|---|
| 55 |
|
|---|
| 56 | Smoother* smoother = new GaussSeidelRB();
|
|---|
| 57 | smoother->Register("SMOOTHER");
|
|---|
| 58 |
|
|---|
| 59 | #ifdef HAVE_LAPACK
|
|---|
| 60 | Solver* solver = new DSYSV<SolverSingular>();
|
|---|
| 61 | #else
|
|---|
| 62 | Solver* solver = new Givens<SolverSingular>();
|
|---|
| 63 | #endif
|
|---|
| 64 | solver->Register("SOLVER");
|
|---|
| 65 |
|
|---|
| 66 | Techniques::SetCorrectionSchemePeriodic(interface->MinLevel(), interface->MaxLevel(), 2);
|
|---|
| 67 |
|
|---|
| 68 | factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
|
|---|
| 69 | factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
|
|---|
| 70 | factory.RegisterObjectStorage("PRECISION", 1e-10);
|
|---|
| 71 | factory.RegisterObjectStorage("MAX_ITERATION", 20);
|
|---|
| 72 |
|
|---|
| 73 | MG::IsInitialized();
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | void PeriodicCSMPITestSuite::tearDown()
|
|---|
| 77 | {
|
|---|
| 78 | MG::Destroy();
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | void PeriodicCSMPITestSuite::PeriodicCSMPITest()
|
|---|
| 82 | {
|
|---|
| 83 | MG::Solve();
|
|---|
| 84 |
|
|---|
| 85 | double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
|
|---|
| 86 | double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
|
|---|
| 87 |
|
|---|
| 88 | CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, fabs(res/res_init), 1e-10);
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | #endif /* HAVE_MPI */
|
|---|