11 bool vaccum_bcs_are_dirichlet )
16 const size_t num_gs_groups = groupset.
groups_.size();
22 vaccum_bcs_are_dirichlet);
25 auto matid_2_mgxs_map =
33 auto solver = std::make_shared<acceleration::DiffusionMIPSolver>(
43 solver->options.residual_tolerance = groupset.
wgdsa_tol_;
46 solver->options.additional_options_string = groupset.
wgdsa_string_;
50 std::vector<double> dummy_rhs(sdm.GetNumLocalDOFs(uk_man), 0.0);
52 solver->AssembleAand_b(dummy_rhs);
70 const std::vector<double>& phi_in)
72 const auto& sdm = *discretization_;
73 const auto& dphi_uk_man = groupset.
wgdsa_solver_->UnknownStructure();
74 const auto& phi_uk_man = flux_moments_uk_man_;
76 const int gsi = groupset.
groups_.front().id_;
77 const size_t gss = groupset.
groups_.size();
79 std::vector<double> output_phi_local(sdm.GetNumLocalDOFs(dphi_uk_man), 0.0);
81 for (
const auto& cell : grid_ptr_->local_cells)
83 const auto& cell_mapping = sdm.GetCellMapping(cell);
84 const size_t num_nodes = cell_mapping.NumNodes();
86 for (
size_t i = 0; i < num_nodes; i++)
88 const int64_t dphi_map = sdm.MapDOFLocal(cell, i, dphi_uk_man, 0, 0);
89 const int64_t phi_map = sdm.MapDOFLocal(cell, i, phi_uk_man, 0, gsi);
91 double* output_mapped = &output_phi_local[dphi_map];
92 const double* phi_in_mapped = &phi_in[phi_map];
94 for (
size_t g = 0; g < gss; g++)
96 output_mapped[g] = phi_in_mapped[g];
101 return output_phi_local;
108 const std::vector<double>& input,
109 std::vector<double>& output)
111 const auto& sdm = *discretization_;
112 const auto& dphi_uk_man = groupset.
wgdsa_solver_->UnknownStructure();
113 const auto& phi_uk_man = flux_moments_uk_man_;
115 const int gsi = groupset.
groups_.front().id_;
116 const size_t gss = groupset.
groups_.size();
118 for (
const auto& cell : grid_ptr_->local_cells)
120 const auto& cell_mapping = sdm.GetCellMapping(cell);
121 const size_t num_nodes = cell_mapping.NumNodes();
123 for (
size_t i = 0; i < num_nodes; i++)
125 const int64_t dphi_map = sdm.MapDOFLocal(cell, i, dphi_uk_man, 0, 0);
126 const int64_t phi_map = sdm.MapDOFLocal(cell, i, phi_uk_man, 0, gsi);
128 const double* input_mapped = &input[dphi_map];
129 double* output_mapped = &output[phi_map];
131 for (
int g = 0; g < gss; g++)
132 output_mapped[g] = input_mapped[g];
141 const std::vector<double>& phi_in,
142 std::vector<double>& delta_phi_local)
144 const auto& sdm = *discretization_;
145 const auto& dphi_uk_man = groupset.
wgdsa_solver_->UnknownStructure();
146 const auto& phi_uk_man = flux_moments_uk_man_;
148 const int gsi = groupset.
groups_.front().id_;
149 const size_t gss = groupset.
groups_.size();
151 delta_phi_local.clear();
152 delta_phi_local.assign(sdm.GetNumLocalDOFs(dphi_uk_man), 0.0);
154 for (
const auto& cell : grid_ptr_->local_cells)
156 const auto& cell_mapping = sdm.GetCellMapping(cell);
157 const size_t num_nodes = cell_mapping.NumNodes();
158 const auto& sigma_s = matid_to_xs_map_[cell.material_id_]->SigmaSGtoG();
160 for (
size_t i = 0; i < num_nodes; i++)
162 const int64_t dphi_map = sdm.MapDOFLocal(cell, i, dphi_uk_man, 0, 0);
163 const int64_t phi_map = sdm.MapDOFLocal(cell, i, phi_uk_man, 0, gsi);
165 double* delta_phi_mapped = &delta_phi_local[dphi_map];
166 const double* phi_in_mapped = &phi_in[phi_map];
168 for (
size_t g = 0; g < gss; g++)
170 delta_phi_mapped[g] = sigma_s[gsi + g] * phi_in_mapped[g];
180 const std::vector<double>& delta_phi_local,
181 std::vector<double>& ref_phi_new)
183 const auto& sdm = *discretization_;
184 const auto& dphi_uk_man = groupset.
wgdsa_solver_->UnknownStructure();
185 const auto& phi_uk_man = flux_moments_uk_man_;
187 const int gsi = groupset.
groups_.front().id_;
188 const size_t gss = groupset.
groups_.size();
190 for (
const auto& cell : grid_ptr_->local_cells)
192 const auto& cell_mapping = sdm.GetCellMapping(cell);
193 const size_t num_nodes = cell_mapping.NumNodes();
195 for (
size_t i = 0; i < num_nodes; i++)
197 const int64_t dphi_map = sdm.MapDOFLocal(cell, i, dphi_uk_man, 0, 0);
198 const int64_t phi_map = sdm.MapDOFLocal(cell, i, phi_uk_man, 0, gsi);
200 const double* delta_phi_mapped = &delta_phi_local[dphi_map];
201 double* phi_new_mapped = &ref_phi_new[phi_map];
203 for (
int g = 0; g < gss; g++)
204 phi_new_mapped[g] += delta_phi_mapped[g];
unsigned int AddUnknown(UnknownType unk_type, unsigned int dimension=0)
std::string TextName() const
std::shared_ptr< lbs::acceleration::DiffusionMIPSolver > wgdsa_solver_
std::string wgdsa_string_
std::vector< LBSGroup > groups_
void DisAssembleWGDSADeltaPhiVector(const LBSGroupset &groupset, const std::vector< double > &delta_phi_local, std::vector< double > &ref_phi_new)
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
std::vector< UnitCellMatrices > unit_cell_matrices_
std::map< uint64_t, std::shared_ptr< SweepBndry > > sweep_boundaries_
std::vector< double > WGSCopyOnlyPhi0(const LBSGroupset &groupset, const std::vector< double > &phi_in)
void InitWGDSA(LBSGroupset &groupset, bool vaccum_bcs_are_dirichlet=true)
void AssembleWGDSADeltaPhiVector(const LBSGroupset &groupset, const std::vector< double > &phi_in, std::vector< double > &delta_phi_local)
static void CleanUpWGDSA(LBSGroupset &groupset)
void GSProjectBackPhi0(const LBSGroupset &groupset, const std::vector< double > &input, std::vector< double > &output)
std::map< int, XSPtr > matid_to_xs_map_
std::map< int, Multigroup_D_and_sigR > PackGroupsetXS(const std::map< int, MGXSPtr > &matid_to_xs_map, int first_grp_index, int last_group_index)
std::map< uint64_t, BoundaryCondition > TranslateBCs(const std::map< uint64_t, SwpBndryPtr > &sweep_boundaries, bool vaccum_bcs_are_dirichlet)