Chi-Tech
diffusion_solver.h
Go to the documentation of this file.
1#ifndef CHI_DIFFUSION_SOLVER_H
2#define CHI_DIFFUSION_SOLVER_H
3
4#include "mesh/Cell/cell.h"
5
8
14
16
17#include "utils/chi_timer.h"
18
19#include <petscksp.h>
20
21#define DIFFUSION_MATERIALS_REGULAR 10
22#define DIFFUSION_MATERIALS_FROM_TRANSPORTXS_TTR 11
23#define DIFFUSION_MATERIALS_FROM_TRANSPORTXS_TTF 12
24#define DIFFUSION_MATERIALS_FROM_TRANSPORTXS_TTF_JPART 13
25#define DIFFUSION_MATERIALS_FROM_TRANSPORTXS_TTF_JFULL 14
26
27//######################################################### Class def
28/**Solver for the general diffusion problem.
29
30 <img src="DiffusionMatProp.png" style="width:500px">
31 * */
33{
34private:
37
38 double time_assembly_ = 0.0;
39 double time_solve_ = 0.0;
40 bool verbose_info_ = true;
41
42public:
43 typedef unsigned int uint;
44 typedef std::pair<BoundaryType,std::vector<double>> BoundaryInfo;
45 typedef std::map<std::string, BoundaryInfo> BoundaryPreferences;
46
47public:
49 std::map<uint64_t,chi_diffusion::Boundary*> boundaries_;
51
52 std::shared_ptr<chi_math::SpatialDiscretization> discretization_;
53
55
57
59
60 Vec x_ = nullptr; // approx solution
61 Vec b_ = nullptr; // RHS
62 Mat A_ = nullptr; // linear system matrix
63 KSP ksp_ = nullptr; // linear solver context
64 PC pc_ = nullptr; // preconditioner context
65
66 PetscReal norm_ = 0.0; /* norm of solution error */
67 PetscErrorCode ierr_ = 0; // General error code
68
69 size_t local_dof_count_ = 0;
71
72 std::vector<double> pwld_phi_local_;
73
74 int gi_ = 0;
75 int G_ = 1;
76 std::string options_string_;
77
78 std::map<uint64_t, UnitIntegralContainer> unit_integrals_;
79
80public:
81 //00
82 Solver (const Solver&) = delete;
83 Solver& operator= (const Solver&) = delete;
84
85 explicit Solver(const std::string& in_solver_name);
86 virtual ~Solver();
87
88 //01 General
90 int cell_dofs,
91 std::vector<double>& diffCoeff,
92 std::vector<double>& sourceQ,
93 std::vector<double>& sigmaa,
94 int group=0,
95 int moment=0);
96 //01a
98
99 //01b
100 void Initialize() override {Initialize(true);}
101 int Initialize(bool verbose);
102
103 //02a
104 void Execute() override { ExecuteS(); }
105 int ExecuteS(bool suppress_assembly = false, bool suppress_solve = false);
106
107 void CFEM_Assemble_A_and_b(chi_mesh::Cell& cell, int group=0);
108
109 //02c_c
110 void PWLD_Assemble_A_and_b(const chi_mesh::Cell& cell, int component = 0);
111 void PWLD_Assemble_b(const chi_mesh::Cell& cell, int component = 0);
112
113 //02e_c
114// void PWLD_Assemble_A_and_b_GAGG(const chi_mesh::Cell& cell);
115// void PWLD_Assemble_b_GAGG(const chi_mesh::Cell& cell);
116
117 //03b
118 double HPerpendicular(
119 const chi_mesh::Cell& cell,
120 const UnitIntegralContainer& fe_intgrl_values,
121 unsigned int f);
122
123 static uint64_t
125 uint64_t node_global_id);
126
127 static unsigned int
128 MapCellFace(const chi_mesh::Cell& cur_cell,
129 const chi_mesh::Cell& adj_cell,
130 unsigned int f);
131
133};
134
135#endif
std::map< uint64_t, UnitIntegralContainer > unit_integrals_
void CFEM_Assemble_A_and_b(chi_mesh::Cell &cell, int group=0)
Definition: assemble_pwlc.cc:7
void UpdateFieldFunctions()
Definition: general.cc:185
std::vector< double > pwld_phi_local_
static uint64_t MapCellLocalNodeIDFromGlobalID(const chi_mesh::Cell &cell, uint64_t node_global_id)
Solver(const Solver &)=delete
std::pair< BoundaryType, std::vector< double > > BoundaryInfo
void GetMaterialProperties(const chi_mesh::Cell &cell, int cell_dofs, std::vector< double > &diffCoeff, std::vector< double > &sourceQ, std::vector< double > &sigmaa, int group=0, int moment=0)
Definition: general.cc:16
void PWLD_Assemble_b(const chi_mesh::Cell &cell, int component=0)
static unsigned int MapCellFace(const chi_mesh::Cell &cur_cell, const chi_mesh::Cell &adj_cell, unsigned int f)
BoundaryPreferences boundary_preferences_
void Execute() override
int ExecuteS(bool suppress_assembly=false, bool suppress_solve=false)
Definition: main_exec.cc:12
void Initialize() override
std::map< uint64_t, chi_diffusion::Boundary * > boundaries_
chi_mesh::MeshContinuumPtr grid_ptr_
void InitializeCommonItems()
Definition: initcommon.cc:11
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
std::map< std::string, BoundaryInfo > BoundaryPreferences
chi_math::UnknownManager unknown_manager_
double HPerpendicular(const chi_mesh::Cell &cell, const UnitIntegralContainer &fe_intgrl_values, unsigned int f)
void PWLD_Assemble_A_and_b(const chi_mesh::Cell &cell, int component=0)
Solver & operator=(const Solver &)=delete
#define DIFFUSION_MATERIALS_REGULAR
std::shared_ptr< MeshContinuum > MeshContinuumPtr
Definition: chi_mesh.h:44
struct _p_Mat * Mat
struct _p_Vec * Vec