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