| Rev | Line | |
|---|
| [48b662] | 1 | /**
|
|---|
| 2 | * @file gs.cpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 13:07:44 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief Gauss-Seidel method
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #ifdef HAVE_CONFIG_H
|
|---|
| 11 | #include <config.h>
|
|---|
| 12 | #endif
|
|---|
| 13 |
|
|---|
| 14 | #include <cassert>
|
|---|
| 15 |
|
|---|
| 16 | #include "base/discretization.hpp"
|
|---|
| 17 | #include "base/stencil.hpp"
|
|---|
| 18 | #include "grid/multigrid.hpp"
|
|---|
| 19 | #include "smoother/gs.hpp"
|
|---|
| 20 | #include "mg.hpp"
|
|---|
| 21 |
|
|---|
| 22 | using namespace VMG;
|
|---|
| 23 |
|
|---|
| 24 | void GaussSeidel::Compute(Grid& sol, Grid& rhs)
|
|---|
| 25 | {
|
|---|
| [dfed1c] | 26 | #ifdef DEBUG_MATRIX_CHECKS
|
|---|
| [48b662] | 27 | sol.IsConsistent();
|
|---|
| 28 | rhs.IsConsistent();
|
|---|
| 29 | sol.IsCompatible(rhs);
|
|---|
| 30 | #endif
|
|---|
| 31 |
|
|---|
| [dfed1c] | 32 | Grid::iterator grid_iter;
|
|---|
| 33 | Stencil::iterator stencil_iter;
|
|---|
| [48b662] | 34 | vmg_float temp;
|
|---|
| 35 |
|
|---|
| 36 | const Stencil& A = MG::GetDiscretization()->GetStencil();
|
|---|
| 37 | const vmg_float prefactor_inv = 1.0 / MG::GetDiscretization()->OperatorPrefactor(sol);
|
|---|
| 38 | const vmg_float diag_inv = 1.0 / A.GetDiag();
|
|---|
| 39 |
|
|---|
| [dfed1c] | 40 | for (grid_iter = rhs.Iterators().Local().Begin(); grid_iter != rhs.Iterators().Local().End(); ++grid_iter) {
|
|---|
| [48b662] | 41 |
|
|---|
| [dfed1c] | 42 | temp = prefactor_inv * rhs.GetCorrectedVal(*grid_iter);
|
|---|
| [48b662] | 43 |
|
|---|
| [dfed1c] | 44 | for (stencil_iter=A.begin(); stencil_iter!=A.end(); ++stencil_iter)
|
|---|
| 45 | temp -= stencil_iter->Val() * sol.GetVal(*grid_iter + stencil_iter->Disp());
|
|---|
| [48b662] | 46 |
|
|---|
| [dfed1c] | 47 | sol(*grid_iter) = temp * diag_inv;
|
|---|
| [48b662] | 48 |
|
|---|
| [dfed1c] | 49 | }
|
|---|
| [48b662] | 50 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.