| 1 | /**
|
|---|
| 2 | * @file discretization_poisson_fd_collatz.cpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 13:03:47 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief Discretization of the poisson equation
|
|---|
| 7 | * using the Collatz Mehrstellen Ansatz.
|
|---|
| 8 | * Discretization error: O(h^4)
|
|---|
| 9 | *
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include "grid/grid.hpp"
|
|---|
| 17 | #include "samples/discretization_poisson_fd.hpp"
|
|---|
| 18 | #include "mg.hpp"
|
|---|
| 19 |
|
|---|
| 20 | using namespace VMG;
|
|---|
| 21 |
|
|---|
| 22 | DiscretizationPoissonFD::DiscretizationPoissonFD(const int& order) :
|
|---|
| 23 | Discretization(order)
|
|---|
| 24 | {
|
|---|
| 25 | switch (order)
|
|---|
| 26 | {
|
|---|
| 27 | case 2:
|
|---|
| 28 | stencil.SetDiag(6.0);
|
|---|
| 29 | stencil.push_back(-1, 0, 0, -1.0);
|
|---|
| 30 | stencil.push_back( 1, 0, 0, -1.0);
|
|---|
| 31 | stencil.push_back( 0, -1, 0, -1.0);
|
|---|
| 32 | stencil.push_back( 0, 1, 0, -1.0);
|
|---|
| 33 | stencil.push_back( 0, 0, -1, -1.0);
|
|---|
| 34 | stencil.push_back( 0, 0, 1, -1.0);
|
|---|
| 35 | break;
|
|---|
| 36 | case 4:
|
|---|
| 37 | stencil.SetDiag(24.0/6.0);
|
|---|
| 38 | stencil.push_back(-1, 0, 0, -2.0/6.0);
|
|---|
| 39 | stencil.push_back( 1, 0, 0, -2.0/6.0);
|
|---|
| 40 | stencil.push_back( 0, -1, 0, -2.0/6.0);
|
|---|
| 41 | stencil.push_back( 0, 1, 0, -2.0/6.0);
|
|---|
| 42 | stencil.push_back( 0, 0, -1, -2.0/6.0);
|
|---|
| 43 | stencil.push_back( 0, 0, 1, -2.0/6.0);
|
|---|
| 44 | stencil.push_back(-1, -1, 0, -1.0/6.0);
|
|---|
| 45 | stencil.push_back(-1, 1, 0, -1.0/6.0);
|
|---|
| 46 | stencil.push_back( 1, -1, 0, -1.0/6.0);
|
|---|
| 47 | stencil.push_back( 1, 1, 0, -1.0/6.0);
|
|---|
| 48 | stencil.push_back(-1, 0, -1, -1.0/6.0);
|
|---|
| 49 | stencil.push_back(-1, 0, 1, -1.0/6.0);
|
|---|
| 50 | stencil.push_back( 1, 0, -1, -1.0/6.0);
|
|---|
| 51 | stencil.push_back( 1, 0, 1, -1.0/6.0);
|
|---|
| 52 | stencil.push_back( 0, -1, -1, -1.0/6.0);
|
|---|
| 53 | stencil.push_back( 0, -1, 1, -1.0/6.0);
|
|---|
| 54 | stencil.push_back( 0, 1, -1, -1.0/6.0);
|
|---|
| 55 | stencil.push_back( 0, 1, 1, -1.0/6.0);
|
|---|
| 56 | break;
|
|---|
| 57 | default:
|
|---|
| 58 | assert(0 != "vmg choose discretization order 2 or 4");
|
|---|
| 59 | break;
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | void DiscretizationPoissonFD::ModifyRightHandSide()
|
|---|
| 64 | {
|
|---|
| 65 | if (order == 4) {
|
|---|
| 66 |
|
|---|
| 67 | Grid& rhs = MG::GetRhsMaxLevel();
|
|---|
| 68 |
|
|---|
| 69 | Stencil stencil(6.0/12.0);
|
|---|
| 70 | stencil.push_back(-1, 0, 0, 1.0/12.0);
|
|---|
| 71 | stencil.push_back( 1, 0, 0, 1.0/12.0);
|
|---|
| 72 | stencil.push_back( 0, -1, 0, 1.0/12.0);
|
|---|
| 73 | stencil.push_back( 0, 1, 0, 1.0/12.0);
|
|---|
| 74 | stencil.push_back( 0, 0, -1, 1.0/12.0);
|
|---|
| 75 | stencil.push_back( 0, 0, 1, 1.0/12.0);
|
|---|
| 76 |
|
|---|
| 77 | stencil.Apply(rhs);
|
|---|
| 78 |
|
|---|
| 79 | }
|
|---|
| 80 | }
|
|---|