Chi-Tech
lbts_02a_step.cc
Go to the documentation of this file.
2
3#include "LinearBoltzmannSolvers/B_DO_Solver/IterativeMethods/sweep_wgs_context.h"
5
6#include "chi_runtime.h"
7#include "chi_log.h"
8
9//###################################################################
10/**Transient solver timestep routine.*/
12{
14 chi::log.Log() << TextName() << " Stepping with dt " << dt_;
15
16 phi_old_local_ = phi_prev_local_;
17
18 for (auto& groupset : groupsets_)
19 {
20 //======================================== Converge the scattering source
21 // with a fixed fission source
22 // and temporal source
23 q_moments_local_.assign(q_moments_local_.size(), 0.0);
24 auto sweep_chunk = SetTransientSweepChunk(groupset);
25
26 auto sweep_wgs_context_ptr =
27 std::make_shared<SweepWGSContext<Mat, Vec, KSP>>(
28 *this, groupset,
29 active_set_source_function_,
32 APPLY_AGS_FISSION_SOURCES, //rhs_scope
33 options_.verbose_inner_iterations,
34 sweep_chunk);
35
36 WGSLinearSolver<Mat,Vec,KSP> solver(sweep_wgs_context_ptr);
37 solver.Setup();
38 solver.Solve();
39
41 }
42
43 //======================================== Compute t^{n+1} value
44 {
45 const auto& BackwardEuler = chi_math::SteppingMethod::IMPLICIT_EULER;
46 const auto& CrankNicolson = chi_math::SteppingMethod::CRANK_NICOLSON;
47
48 double theta;
49 if (method == BackwardEuler) theta = 1.0;
50 else if (method == CrankNicolson) theta = 0.5;
51 else theta = 0.7;
52 const double inv_theta = 1.0/theta;
53
54 auto& phi = phi_new_local_;
55 const auto& phi_prev = phi_prev_local_;
56 for (size_t i = 0; i < phi.size(); ++i)
57 phi[i] = inv_theta*(phi[i] + (theta-1.0) * phi_prev[i]);
58
59 if (options_.use_precursors)
61 }
62
63 const double FR_new = ComputeFissionProduction(phi_new_local_);
64
65 //============================================= Print end of timestep
67 {
68 char buff[200];
69 snprintf(buff, 200, " dt=%.1e time=%10.4g FR=%12.6g", dt_, time_ + dt_, FR_new);
70 chi::log.Log() << TextName() << buff;
71 }
72
73 UpdateFieldFunctions();
74}
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
void Barrier() const
Definition: mpi_info.cc:38
std::vector< double > phi_prev_local_
std::shared_ptr< SweepChunk > SetTransientSweepChunk(LBSGroupset &groupset)
chi_math::SteppingMethod method
struct lbs::DiscOrdTransientSolver::Options transient_options_
@ APPLY_AGS_FISSION_SOURCES
Definition: lbs_structs.h:94
@ APPLY_WGS_FISSION_SOURCES
Definition: lbs_structs.h:93
@ APPLY_FIXED_SOURCES
Definition: lbs_structs.h:90
@ APPLY_WGS_SCATTER_SOURCES
Definition: lbs_structs.h:91
@ APPLY_AGS_SCATTER_SOURCES
Definition: lbs_structs.h:92