source: src/comm/comm.cpp@ dfed1c

Last change on this file since dfed1c was dfed1c, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Major vmg update.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1136 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[dfed1c]1/**
2 * @file comm.hpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Wed Jun 16 13:21:06 2010
5 *
6 * @brief Base class for communication.
7 *
8 */
9
10#ifdef HAVE_CONFIG_H
11#include <config.h>
12#endif
13
14#ifdef HAVE_BOOST_FILESYSTEM
15#include <boost/filesystem.hpp>
16namespace fs = boost::filesystem;
17#endif
18
19#include "base/discretization.hpp"
20#include "base/helper.hpp"
21#include "base/stencil.hpp"
22#include "comm/comm.hpp"
23#include "comm/domain_decomposition.hpp"
24#include "grid/grid.hpp"
25#include "mg.hpp"
26
27using namespace VMG;
28
29vmg_float Comm::ComputeResidualNorm(Multigrid& sol, Multigrid& rhs)
30{
31#ifdef DEBUG_MATRIX_CHECKS
32 sol().IsCompatible(rhs());
33 sol().IsConsistent();
34 rhs().IsConsistent();
35#endif
36
37 Grid::iterator grid_iter;
38 Stencil::iterator stencil_iter;
39 vmg_float val;
40 vmg_float norm = 0.0;
41
42 const vmg_float prefactor = MG::GetDiscretization()->OperatorPrefactor(sol());
43 const Stencil& A = MG::GetDiscretization()->GetStencil();
44
45 this->CommToGhosts(sol());
46
47 if (sol().Global().BoundaryType() == LocallyRefined)
48 MG::GetDiscretization()->SetInnerBoundary(sol(), rhs(), sol(sol.Level()-1));
49
50 for (grid_iter=rhs().Iterators().Local().Begin(); grid_iter!=rhs().Iterators().Local().End(); ++grid_iter) {
51
52 val = rhs().GetVal(*grid_iter) - prefactor * A.GetDiag() * sol().GetVal(*grid_iter);
53
54 for (stencil_iter=A.begin(); stencil_iter!=A.end(); ++stencil_iter)
55 val -= prefactor * stencil_iter->Val() * sol().GetVal(*grid_iter + stencil_iter->Disp());
56
57 norm += val*val;
58
59 }
60
61 norm = sqrt( Helper::pow_3(sol().MeshWidth()) * GlobalSum(norm) );
62
63 return norm;
64}
65
66void Comm::InitComm()
67{
68}
69
70Comm::~Comm()
71{
72 delete dd;
73}
74
75const std::string& Comm::OutputPath()
76{
77 if (!output_directory_is_created) {
78 output_path_str = CreateOutputDirectory();
79 output_directory_is_created = true;
80 }
81
82 return output_path_str;
83}
Note: See TracBrowser for help on using the repository browser.