| Line | |
|---|
| 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 "comm/comm.hpp"
|
|---|
| 19 | #include "grid/multigrid.hpp"
|
|---|
| 20 | #include "smoother/gs.hpp"
|
|---|
| 21 | #include "mg.hpp"
|
|---|
| 22 |
|
|---|
| 23 | using namespace VMG;
|
|---|
| 24 |
|
|---|
| 25 | void GaussSeidel::Compute(Grid& sol, Grid& rhs)
|
|---|
| 26 | {
|
|---|
| 27 | #ifdef DEBUG_MATRIX_CHECKS
|
|---|
| 28 | sol.IsConsistent();
|
|---|
| 29 | rhs.IsConsistent();
|
|---|
| 30 | sol.IsCompatible(rhs);
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | Grid::iterator grid_iter;
|
|---|
| 34 | Stencil::iterator stencil_iter;
|
|---|
| 35 | vmg_float temp;
|
|---|
| 36 |
|
|---|
| 37 | const Stencil& A = MG::GetDiscretization()->GetStencil();
|
|---|
| 38 | const vmg_float prefactor_inv = 1.0 / MG::GetDiscretization()->OperatorPrefactor(sol);
|
|---|
| 39 | const vmg_float diag_inv = 1.0 / A.GetDiag();
|
|---|
| 40 |
|
|---|
| 41 | MG::GetComm()->CommToGhosts(sol);
|
|---|
| 42 |
|
|---|
| 43 | for (grid_iter = rhs.Iterators().Local().Begin(); grid_iter != rhs.Iterators().Local().End(); ++grid_iter) {
|
|---|
| 44 |
|
|---|
| 45 | temp = prefactor_inv * rhs.GetVal(*grid_iter);
|
|---|
| 46 |
|
|---|
| 47 | for (stencil_iter=A.begin(); stencil_iter!=A.end(); ++stencil_iter)
|
|---|
| 48 | temp -= stencil_iter->Val() * sol.GetVal(*grid_iter + stencil_iter->Disp());
|
|---|
| 49 |
|
|---|
| 50 | sol(*grid_iter) = temp * diag_inv;
|
|---|
| 51 |
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.