Chi-Tech
diffusion.h
Go to the documentation of this file.
1#ifndef CHITECH_LBS_ACCEL_DIFFUSION_H
2#define CHITECH_LBS_ACCEL_DIFFUSION_H
3
4#include "acceleration.h"
6#include "petscksp.h"
7
8// ############################################### Forward declarations
9namespace chi_mesh
10{
11class MeshContinuum;
12class Cell;
13struct Vector3;
14} // namespace chi_mesh
15
16namespace chi_math
17{
18class SpatialDiscretization;
19}
20
21namespace lbs
22{
23struct UnitCellMatrices;
24}
25
26namespace lbs::acceleration
27{
28
29struct Multigroup_D_and_sigR;
30
31/**Generic diffusion solver for acceleration.*/
33{
34protected:
35 typedef std::map<int, Multigroup_D_and_sigR> MatID2XSMap;
36
37 const std::string text_name_;
41
42 const std::map<uint64_t, BoundaryCondition> bcs_;
43
45
46 const std::vector<UnitCellMatrices>& unit_cell_matrices_;
47
48 const int64_t num_local_dofs_;
49 const int64_t num_global_dofs_;
50
51 Mat A_ = nullptr;
52 Vec rhs_ = nullptr;
53 KSP ksp_ = nullptr;
54
55 const bool requires_ghosts_;
56
57public:
58 struct Options
59 {
60 double residual_tolerance = 1.0e-4; ///< Residual tol. relative to rhs
61 int max_iters = 100; ///< Maximum iterations
62 bool verbose = false; ///< Verbosity flag
64 false; ///< For debugging only (very expensive)
65 std::string source_lua_function; ///< for mms
66 std::string ref_solution_lua_function; ///< for mms
68 double penalty_factor = 4.0;
70
71public:
72 DiffusionSolver(std::string text_name,
74 const chi_math::UnknownManager& uk_man,
75 std::map<uint64_t, BoundaryCondition> bcs,
76 MatID2XSMap map_mat_id_2_xs,
77 const std::vector<UnitCellMatrices>& unit_cell_matrices,
78 bool verbose,
79 bool requires_ghosts);
80
81 std::string TextName() const;
82 const Vec& RHS() const;
83 const std::map<uint64_t, BoundaryCondition>& BCS() const {return bcs_;}
84
87
88 std::pair<size_t, size_t> GetNumPhiIterativeUnknowns();
89
90 virtual ~DiffusionSolver();
91
92 void Initialize();
93
94 virtual void AssembleAand_b(const std::vector<double>& q_vector) = 0;
95 virtual void Assemble_b(const std::vector<double>& q_vector) = 0;
96 virtual void Assemble_b(Vec petsc_q_vector) = 0;
97 void AddToRHS(const std::vector<double>& values);
98
99 void Solve(std::vector<double>& solution, bool use_initial_guess=false);
100 void Solve(Vec petsc_solution, bool use_initial_guess=false);
101};
102
103} // namespace lbs::acceleration
104
105#endif // CHITECH_LBS_ACCEL_DIFFUSION_H
struct lbs::acceleration::DiffusionSolver::Options options
const std::map< uint64_t, BoundaryCondition > & BCS() const
Definition: diffusion.h:83
std::string TextName() const
Definition: diffusion.cc:51
const chi_math::SpatialDiscretization & sdm_
Definition: diffusion.h:39
const chi_math::UnknownManager & UnknownStructure() const
Definition: diffusion.cc:59
virtual void Assemble_b(Vec petsc_q_vector)=0
void Solve(std::vector< double > &solution, bool use_initial_guess=false)
DiffusionSolver(std::string text_name, const chi_math::SpatialDiscretization &sdm, const chi_math::UnknownManager &uk_man, std::map< uint64_t, BoundaryCondition > bcs, MatID2XSMap map_mat_id_2_xs, const std::vector< UnitCellMatrices > &unit_cell_matrices, bool verbose, bool requires_ghosts)
Definition: diffusion.cc:14
void AddToRHS(const std::vector< double > &values)
Definition: diffusion.cc:80
virtual void Assemble_b(const std::vector< double > &q_vector)=0
const chi_math::UnknownManager uk_man_
Definition: diffusion.h:40
virtual void AssembleAand_b(const std::vector< double > &q_vector)=0
const chi_math::SpatialDiscretization & SpatialDiscretization() const
Definition: diffusion.cc:67
const chi_mesh::MeshContinuum & grid_
Definition: diffusion.h:38
const std::map< uint64_t, BoundaryCondition > bcs_
Definition: diffusion.h:42
std::map< int, Multigroup_D_and_sigR > MatID2XSMap
Definition: diffusion.h:35
const MatID2XSMap mat_id_2_xs_map_
Definition: diffusion.h:44
std::pair< size_t, size_t > GetNumPhiIterativeUnknowns()
Definition: diffusion.cc:73
const std::string text_name_
Definition: diffusion.h:37
const std::vector< UnitCellMatrices > & unit_cell_matrices_
Definition: diffusion.h:46
VectorN< 3 > Vector3
struct _p_Mat * Mat
struct _p_Vec * Vec
std::string ref_solution_lua_function
for mms
Definition: diffusion.h:66
double residual_tolerance
Residual tol. relative to rhs.
Definition: diffusion.h:60
bool perform_symmetry_check
For debugging only (very expensive)
Definition: diffusion.h:63