| 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 |
|
|---|
| 17 | #include "base/command.hpp"
|
|---|
| 18 | #include "base/factory.hpp"
|
|---|
| 19 | #include "base/object.hpp"
|
|---|
| 20 | #include "comm/comm.hpp"
|
|---|
| 21 | #include "grid/multigrid.hpp"
|
|---|
| 22 | #include "mg.hpp"
|
|---|
| 23 |
|
|---|
| 24 | using namespace VMG;
|
|---|
| 25 |
|
|---|
| 26 | class VMGCommandCheckRelativeResidual : public Command
|
|---|
| 27 | {
|
|---|
| 28 | public:
|
|---|
| 29 | Request Run(Command::argument_vector arguments)
|
|---|
| 30 | {
|
|---|
| 31 | MPE_EVENT_BEGIN()
|
|---|
| 32 |
|
|---|
| 33 | VMG::Factory& factory = MG::GetFactory();
|
|---|
| 34 |
|
|---|
| 35 | const vmg_float& res = factory.GetObjectStorageVal<vmg_float>(arguments[0]);
|
|---|
| 36 | const vmg_float& init_res = factory.GetObjectStorageVal<vmg_float>(arguments[1]);
|
|---|
| 37 | const vmg_float& precision = factory.GetObjectStorageVal<vmg_float>("PRECISION");
|
|---|
| 38 | const vmg_float rel_res = std::fabs(res / init_res);
|
|---|
| 39 |
|
|---|
| 40 | #ifdef DEBUG_OUTPUT
|
|---|
| 41 | MG::GetComm()->PrintStringOnce("Relative residual: %e", rel_res);
|
|---|
| 42 | #endif /* DEBUG_OUTPUT */
|
|---|
| 43 |
|
|---|
| 44 | MPE_EVENT_END()
|
|---|
| 45 |
|
|---|
| 46 | if (rel_res < precision)
|
|---|
| 47 | return StopCycleLater;
|
|---|
| 48 | else
|
|---|
| 49 | return Continue;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | static const char* Name() {return "CheckRelativeResidual";}
|
|---|
| 53 | static int Arguments() {return 2;}
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 | CREATE_INITIALIZER(VMGCommandCheckRelativeResidual)
|
|---|
| 57 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.