[de061d] | 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_cs.cpp
|
---|
| 21 | *
|
---|
| 22 | * Created on: 25.01.2011
|
---|
| 23 | * Author: Julian Iseringhausen
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #ifdef HAVE_CONFIG_H
|
---|
| 27 | #include <libvmg_config.h>
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | #include <boost/test/unit_test.hpp>
|
---|
| 31 | #include <boost/test/floating_point_comparison.hpp>
|
---|
| 32 |
|
---|
| 33 | #include "base/factory.hpp"
|
---|
| 34 | #include "base/math.hpp"
|
---|
| 35 | #include "base/vector.hpp"
|
---|
| 36 | #include "cycles/cycle_cs_dirichlet.hpp"
|
---|
| 37 | #include "comm/comm_serial.hpp"
|
---|
| 38 | #include "level/level_operator_cs.hpp"
|
---|
| 39 | #include "level/level_operator.hpp"
|
---|
| 40 | #include "level/stencils.hpp"
|
---|
| 41 | #include "discretization/discretization_poisson_fd.hpp"
|
---|
| 42 | #include "smoother/gsrb.hpp"
|
---|
| 43 | #ifdef HAVE_LAPACK
|
---|
| 44 | #include "solver/dgesv.hpp"
|
---|
| 45 | #endif
|
---|
| 46 | #include "solver/givens.hpp"
|
---|
| 47 | #include "solver/solver_regular.hpp"
|
---|
| 48 | #include "mg.hpp"
|
---|
| 49 |
|
---|
| 50 | #include "interface_sinus.hpp"
|
---|
| 51 |
|
---|
| 52 | using namespace VMG;
|
---|
| 53 |
|
---|
| 54 | const vmg_float sine_factor = static_cast<vmg_float>(2.0 * Math::pi);
|
---|
| 55 |
|
---|
| 56 | struct LibraryDirichletCSFixture
|
---|
| 57 | {
|
---|
| 58 | LibraryDirichletCSFixture()
|
---|
| 59 | {
|
---|
| 60 | const Boundary boundary(Dirichlet, Dirichlet, Dirichlet);
|
---|
| 61 |
|
---|
| 62 | new CommSerial(boundary);
|
---|
| 63 | new VMGInterfaces::InterfaceSinus(sine_factor, boundary, 2, 5, 0.0, 1.0);
|
---|
| 64 | new DiscretizationPoissonFD(2);
|
---|
| 65 | new LevelOperatorCS(Stencils::RestrictionFullWeight, Stencils::InterpolationTrilinear);
|
---|
| 66 | new GaussSeidelRB();
|
---|
| 67 | new Givens<SolverRegular>();
|
---|
| 68 | new CycleCSDirichlet(2);
|
---|
| 69 |
|
---|
| 70 | new ObjectStorage<int>("PRESMOOTHSTEPS", 3);
|
---|
| 71 | new ObjectStorage<int>("POSTSMOOTHSTEPS", 3);
|
---|
| 72 | new ObjectStorage<int>("MAX_ITERATION", 7);
|
---|
| 73 | new ObjectStorage<vmg_float>("PRECISION", 1.0e-10);
|
---|
| 74 |
|
---|
| 75 | MG::PostInit();
|
---|
| 76 |
|
---|
| 77 | MG::IsInitialized();
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | ~LibraryDirichletCSFixture()
|
---|
| 81 | {
|
---|
| 82 | MG::Destroy();
|
---|
| 83 | }
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 | BOOST_FIXTURE_TEST_CASE(LibraryDirichletCSTest, LibraryDirichletCSFixture)
|
---|
| 87 | {
|
---|
| 88 | MG::Solve();
|
---|
| 89 |
|
---|
| 90 | double res_init = MG::GetFactory().Get("INITIAL_RESIDUAL")->Cast< ObjectStorage<double> >()->Val();
|
---|
| 91 | double res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
|
---|
| 92 |
|
---|
| 93 | BOOST_CHECK_SMALL(res/res_init, 1e-10);
|
---|
| 94 | }
|
---|