Chi-Tech
snes_k_monitor.cc
Go to the documentation of this file.
2
3#include "chi_runtime.h"
4#include "chi_log.h"
5#include "utils/chi_timer.h"
6
7#include <petscsnes.h>
8#include <iomanip>
9
10namespace lbs
11{
12
13PetscErrorCode KEigenSNESMonitor(SNES, PetscInt iter,
14 PetscReal rnorm, void*ctx)
15{
16 auto& residual_context = *(KResidualFunctionContext*)ctx;
17
18 double k_eff = residual_context.k_eff;
19 double reactivity = (k_eff - 1.0) / k_eff;
20
21 std::stringstream iter_info;
22 iter_info
24 << residual_context.solver_name
25 << "_NonLinearK_Outer"
26 << " Iteration " << std::setw(5) << iter
27 << " Residual " << std::setw(11) << rnorm
28 << " k_eff " << std::fixed << std::setw(10) << std::setprecision(7)
29 << k_eff
30 << std::setprecision(2)
31 << " reactivity " << std::setw(10) << reactivity * 1e5;
32
33 Chi::log.Log() << iter_info.str();
34
35 return 0;
36}
37
38PetscErrorCode KEigenKSPMonitor(KSP ksp, PetscInt iter, PetscReal rnorm,
39 void*ctx)
40{
41 auto& residual_context = *(KResidualFunctionContext*)ctx;
42
43 std::stringstream iter_info;
44 iter_info
45 << " " << Chi::program_timer.GetTimeString() << " "
46 << residual_context.solver_name
47 << "_NonLinearK_Inner"
48 << " Iteration " << std::setw(5) << iter
49 << " Residual " << std::setw(11) << rnorm;
50
51 Chi::log.Log() << iter_info.str();
52
53 return 0;
54}
55
56}//namespace lbs
static chi::Timer program_timer
Definition: chi_runtime.h:79
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
std::string GetTimeString() const
Definition: chi_timer.cc:38
PetscErrorCode KEigenSNESMonitor(SNES, PetscInt iter, PetscReal rnorm, void *ctx)
PetscErrorCode KEigenKSPMonitor(KSP ksp, PetscInt iter, PetscReal rnorm, void *ctx)