source: src/commands/com_check_residual.cpp@ 48b662

Last change on this file since 48b662 was 48b662, checked in by Olaf Lenz <olenz@…>, 14 years ago

Moved files in scafacos_fcs one level up.

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

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @file com_check_residual.cpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Mon Apr 18 12:31:37 2011
5 *
6 * @brief Checks if the residual is small enough to stop
7 * execution.
8 *
9 */
10
11#ifdef HAVE_CONFIG_H
12#include <config.h>
13#endif
14
15#include <cmath>
16#include <cstdio>
17
18#include "base/command.hpp"
19#include "base/factory.hpp"
20#include "base/object.hpp"
21#include "comm/comm.hpp"
22#include "grid/multigrid.hpp"
23#include "mg.hpp"
24
25using namespace VMG;
26
27class VMGCommandCheckResidual : public Command
28{
29public:
30 Request Run(Command::argument_vector arguments)
31 {
32 const vmg_float res = MG::GetComm()->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
33 const vmg_float& precision = MG::GetFactory().GetObject("PRECISION")->Cast< ObjectStorage<vmg_float> >()->Val();
34
35#ifdef DEBUG
36 if (MG::GetComm()->Rank() == 0)
37 printf("Multigrid: Residual: %e\n", res);
38#endif
39
40 if (fabs(res) < precision)
41 return StopCycleLater;
42 else
43 return Continue;
44 }
45
46 static const char* Name() {return "CheckResidual";}
47 static int Arguments() {return 0;}
48};
49
50CREATE_INITIALIZER(VMGCommandCheckResidual);
51
Note: See TracBrowser for help on using the repository browser.