source: src/commands/com_check_relative_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.4 KB
Line 
1/**
2 * @file com_check_relative_residual.cpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Mon Apr 18 12:30:18 2011
5 *
6 * @brief Checks if the relative residual is small enough
7 * to stop 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 VMGCommandCheckRelativeResidual : public Command
28{
29public:
30 Request Run(Command::argument_vector arguments)
31 {
32 VMG::Comm* comm = MG::GetComm();
33 VMG::Factory& factory = MG::GetFactory();
34
35 const vmg_float res = comm->ComputeResidualNorm(*MG::GetSol(), *MG::GetRhs());
36 const vmg_float& init_res = factory.GetObject(arguments[0])->Cast< ObjectStorage<vmg_float> >()->Val();
37 const vmg_float& precision = factory.GetObject("PRECISION")->Cast< ObjectStorage<vmg_float> >()->Val();
38 const vmg_float rel_res = fabs(res / init_res);
39
40 if (comm->Rank() == 0)
41 printf("Multigrid: Relative residual: %e\n", rel_res);
42
43 if (rel_res < precision)
44 return StopCycleLater;
45 else
46 return Continue;
47 }
48
49 static const char* Name() {return "CheckRelativeResidual";}
50 static int Arguments() {return 1;}
51};
52
53CREATE_INITIALIZER(VMGCommandCheckRelativeResidual);
54
Note: See TracBrowser for help on using the repository browser.