source: test/unit_test/library/dirichlet_fas_lr_mpi.cpp@ fcf7f6

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

vmg: Added license files and headers (GPLv3).

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

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * vmg - a versatile multigrid solver
3 * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
4 *
5 * vmg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vmg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * dirichlet_fas_lr_mpi.cpp
21 *
22 * Created on: 25.01.2011
23 * Author: Julian Iseringhausen
24 */
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29
30#include <boost/test/unit_test.hpp>
31#include <boost/test/floating_point_comparison.hpp>
32
33#ifdef HAVE_MPI
34
35#include <mpi.h>
36#ifdef HAVE_MARMOT
37#include <enhancempicalls.h>
38#include <sourceinfompicalls.h>
39#endif
40
41#include "base/factory.hpp"
42#include "base/math.hpp"
43#include "base/vector.hpp"
44#include "comm/comm_mpi.hpp"
45#include "comm/domain_decomposition_mpi.hpp"
46#include "level/level_operator_fas.hpp"
47#include "level/level_operator.hpp"
48#include "samples/discretization_poisson_fv.hpp"
49#include "samples/techniques.hpp"
50#include "smoother/gsrb.hpp"
51#ifdef HAVE_LAPACK
52#include "solver/dgesv.hpp"
53#endif
54#include "solver/givens.hpp"
55#include "solver/solver_regular.hpp"
56#include "mg.hpp"
57
58#include "interface_sinus.hpp"
59
60using namespace VMG;
61
62const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
63
64struct LibraryDirichletFASLRMPIFixture
65{
66 LibraryDirichletFASLRMPIFixture()
67 {
68 Factory& factory = MG::GetFactory();
69
70 Comm *comm = new CommMPI(Boundary(Dirichlet, Dirichlet, Dirichlet), new DomainDecompositionMPI());
71 comm->Register("COMM");
72
73 Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0, 2, 1.6);
74 MG::SetInterface(interface, comm);
75
76 Discretization* discretization = new DiscretizationPoissonFV(2);
77 discretization->Register("DISCRETIZATION");
78
79 LevelOperator* lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
80 lop->Register("LEVEL_OPERATOR");
81
82 Smoother* smoother = new GaussSeidelRB();
83 smoother->Register("SMOOTHER");
84
85#ifdef HAVE_LAPACK
86 Solver* solver = new DGESV<SolverRegular>();
87#else
88 Solver* solver = new Givens<SolverRegular>();
89#endif
90
91 solver->Register("SOLVER");
92
93 Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), 2);
94
95 factory.RegisterObjectStorage("PRESMOOTHSTEPS", 3);
96 factory.RegisterObjectStorage("POSTSMOOTHSTEPS", 3);
97 factory.RegisterObjectStorage("PRECISION", 1e-10);
98 factory.RegisterObjectStorage("MAX_ITERATION", 8);
99
100 MG::IsInitialized();
101
102 MG::PostInit();
103 }
104
105 ~LibraryDirichletFASLRMPIFixture()
106 {
107 MG::Destroy();
108 }
109};
110
111BOOST_FIXTURE_TEST_CASE(LibraryDirichletFASLRMPITest, LibraryDirichletFASLRMPIFixture)
112{
113 MG::Solve();
114
115 double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
116 double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
117
118 BOOST_CHECK_SMALL(res/res_init, 1e-10);
119}
120
121#endif /* HAVE_MPI */
Note: See TracBrowser for help on using the repository browser.