| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @file tempgrid.cpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 12:55:05 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief VMG::TempGrid
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | #ifdef HAVE_CONFIG_H
|
|---|
| 12 | #include <config.h>
|
|---|
| 13 | #endif
|
|---|
| 14 |
|
|---|
| 15 | #include "base/discretization.hpp"
|
|---|
| 16 | #include "base/stencil.hpp"
|
|---|
| 17 | #include "comm/comm.hpp"
|
|---|
| 18 | #include "grid/tempgrid.hpp"
|
|---|
| 19 | #include "mg.hpp"
|
|---|
| 20 |
|
|---|
| 21 | using namespace VMG;
|
|---|
| 22 |
|
|---|
| 23 | void TempGrid::SetProperties(const Grid& rhs)
|
|---|
| 24 | {
|
|---|
| 25 | local = rhs.Local();
|
|---|
| 26 | global = rhs.Global();
|
|---|
| 27 | extent = rhs.Extent();
|
|---|
| 28 |
|
|---|
| 29 | delete [] grid;
|
|---|
| 30 |
|
|---|
| 31 | grid = new vmg_float[local.SizeTotal().Product()];
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | void TempGrid::SetProperties(const GlobalIndices& global_, const LocalIndices& local_, const SpatialExtent& extent_)
|
|---|
| 35 | {
|
|---|
| 36 | local = local_;
|
|---|
| 37 | global = global_;
|
|---|
| 38 | extent = extent_;
|
|---|
| 39 |
|
|---|
| 40 | delete [] grid;
|
|---|
| 41 |
|
|---|
| 42 | grid = new vmg_float[local.SizeTotal().Product()];
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | void TempGrid::ImportFromResidual(const Grid& sol, const Grid& rhs)
|
|---|
| 46 | {
|
|---|
| 47 | #ifdef DEBUG
|
|---|
| 48 | this->IsCompatible(sol);
|
|---|
| 49 | this->IsCompatible(rhs);
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | vmg_float residual;
|
|---|
| 53 | Index i;
|
|---|
| 54 |
|
|---|
| 55 | const vmg_float prefactor = MG::GetDiscretization()->OperatorPrefactor(sol);
|
|---|
| 56 | const Stencil& A = MG::GetDiscretization()->GetStencil();
|
|---|
| 57 |
|
|---|
| 58 | this->Clear();
|
|---|
| 59 |
|
|---|
| 60 | for (i.X()=Local().Begin().X(); i.X()<Local().End().X(); ++i.X())
|
|---|
| 61 | for (i.Y()=Local().Begin().Y(); i.Y()<Local().End().Y(); ++i.Y())
|
|---|
| 62 | for (i.Z()=Local().Begin().Z(); i.Z()<Local().End().Z(); ++i.Z()) {
|
|---|
| 63 |
|
|---|
| 64 | residual = rhs.GetVal(i) - prefactor * A.GetDiag() * sol.GetVal(i);
|
|---|
| 65 |
|
|---|
| 66 | for (Stencil::iterator iter=A.begin(); iter!=A.end(); iter++)
|
|---|
| 67 | residual -= prefactor * iter->val * sol.GetVal(i+iter);
|
|---|
| 68 |
|
|---|
| 69 | (*this)(i) = residual;
|
|---|
| 70 |
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | MG::GetComm()->CommToGhosts(*this);
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | TempGrid::~TempGrid()
|
|---|
| 77 | {
|
|---|
| 78 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.