| Rev | Line | |
|---|
| [48b662] | 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 |
|
|---|
| 25 | using namespace VMG;
|
|---|
| 26 |
|
|---|
| 27 | class VMGCommandCheckResidual : public Command
|
|---|
| 28 | {
|
|---|
| 29 | public:
|
|---|
| 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 |
|
|---|
| 50 | CREATE_INITIALIZER(VMGCommandCheckResidual);
|
|---|
| 51 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.