Chi-Tech
mg_diffusion_solver.h
Go to the documentation of this file.
1#ifndef MG_DIFFUSION_SOLVER_H
2#define MG_DIFFUSION_SOLVER_H
3
6
8#include "utils/chi_timer.h"
9
10#include "console/chi_console.h"
11
14
15#include <map>
16
17// forward declaration
18namespace chi_mesh
19{
20class MeshContinuum;
21typedef std::shared_ptr<MeshContinuum> MeshContinuumPtr;
22}
23namespace chi_math
24{
25class SpatialDiscretization;
26typedef std::shared_ptr<SpatialDiscretization> SDMPtr ;
27}
28
29namespace mg_diffusion {
30
32{
33 PetscBool verbose = PETSC_FALSE;
34};
35
37{
38 double collapsed_D = 0.0;
39 double collapsed_sig_a = 0.0;
40 std::vector<double> spectrum;
41};
42
43//struct Multigroup_D_and_sigR
44//{
45// std::vector<double> Dg;
46// std::vector<double> sigR;
47//};
48
49/** Multi-group diffusion solver
50 *
51*/
53{
54public:
56
58
61 bool do_two_grid_ = false;
62
63 size_t num_local_dofs_ = 0;
64 size_t num_globl_dofs_ = 0;
65
66 std::vector<Mat> A_; // linear system matrix for each group
67 std::vector<Vec> bext_; // external source vector for each group
68 std::vector<Vec> x_; // solution vector for each group
69 std::vector<Vec> x_old_; // vector of old fluxes
70
71 Vec thermal_dphi_ = nullptr; // error vector for thermal fluxes
72 Vec b_ = nullptr; // actual rhs vector for the linear system A[g] x[g] = b
73
76
77 std::vector< std::vector<double> > VF_;
78
79// typedef std::pair<BoundaryType,std::vector<double>> BoundaryInfo;
80 typedef std::pair<BoundaryType,std::array<std::vector<double>, 3>>
82
83 typedef std::map<uint, BoundaryInfo> BoundaryPreferences;
85 std::vector<Boundary> boundaries_;
86
87 explicit Solver(const std::string& in_solver_name);
88 ~Solver() override;
89
90 void Initialize() override;
91
92 void Initialize_Materials(std::set<int> &material_ids);
93 void Set_BCs(const std::vector<uint64_t>& globl_unique_bndry_ids);
94 void Assemble_A_bext();
97
98 void Execute() override;
99
100 void Assemble_RHS(unsigned int g, int64_t iverbose);
101 void Assemble_RHS_TwoGrid(int64_t iverbose);
102 void SolveOneGroupProblem(unsigned int g, int64_t iverbose);
103 void Update_Flux_With_TwoGrid(int64_t iverbose);
104
105 //04
107
108protected:
109 std::map<int,std::shared_ptr<chi_physics::MultiGroupXS>>
111
112 std::map<int,std::shared_ptr<chi_physics::IsotropicMultiGrpSource>>
114
115 std::map<int, TwoGridCollapsedInfo> map_mat_id_2_tginfo;
116// std::map<int, Multigroup_D_and_sigR> map_mat_id_2_tgXS;
117
118};
119
120} // namespace mg_diffusion
121
122
123#endif //MG_DIFFUSION_SOLVER_H
124
std::vector< std::vector< double > > VF_
std::map< int, TwoGridCollapsedInfo > map_mat_id_2_tginfo
BoundaryPreferences boundary_preferences_
void Assemble_RHS_TwoGrid(int64_t iverbose)
KSPAppContext my_app_context_
void Execute() override
std::vector< Vec > x_
std::vector< Vec > x_old_
void Initialize_Materials(std::set< int > &material_ids)
Solver(const std::string &in_solver_name)
std::map< int, std::shared_ptr< chi_physics::MultiGroupXS > > matid_to_xs_map
chi_mesh::MeshContinuumPtr grid_ptr_
std::vector< Boundary > boundaries_
std::pair< BoundaryType, std::array< std::vector< double >, 3 > > BoundaryInfo
std::vector< Mat > A_
std::map< int, std::shared_ptr< chi_physics::IsotropicMultiGrpSource > > matid_to_src_map
chi_math::SDMPtr sdm_ptr_
std::vector< Vec > bext_
void Set_BCs(const std::vector< uint64_t > &globl_unique_bndry_ids)
void Assemble_RHS(unsigned int g, int64_t iverbose)
void Initialize() override
std::map< uint, BoundaryInfo > BoundaryPreferences
chi_math::PETScUtils::PETScSolverSetup petsc_solver_
void SolveOneGroupProblem(unsigned int g, int64_t iverbose)
std::shared_ptr< SpatialDiscretization > SDMPtr
std::shared_ptr< MeshContinuum > MeshContinuumPtr
Definition: chi_mesh.h:44
struct _p_Vec * Vec
#define uint