19 std::stringstream materials_list;
23 bool first_material_read =
true;
25 for (
const int& mat_id : material_ids)
27 auto current_material =
29 mat_id, __FUNCTION__);
30 materials_list <<
"Material id " << mat_id;
33 if (mat_id < 0) {
throw std::logic_error(
34 "MG-diff-InitMaterials: Cells encountered with no assigned material.");}
35 if (
static_cast<size_t>(mat_id) >= num_physics_mats) {
36 throw std::logic_error(
"MG-diff-InitMaterials: Cells encountered with "
37 "material id that matches no material in physics material library.");}
41 bool found_transport_xs =
false;
42 for (
const auto& property : current_material->properties_)
44 if (property->Type() == MatProperty::TRANSPORT_XSECTIONS)
47 std::static_pointer_cast<chi_physics::MultiGroupXS>(property);
49 found_transport_xs =
true;
50 if (first_material_read)
54 if (property->Type() == MatProperty::ISOTROPIC_MG_SOURCE)
57 std::static_pointer_cast<chi_physics::IsotropicMultiGrpSource>(property);
59 if (mg_source->source_value_g_.size() <
num_groups_)
62 <<
"MG-Diff-InitMaterials: Isotropic Multigroup source specified in "
63 <<
"material \"" << current_material->name_ <<
"\" has fewer "
64 <<
"energy groups than called for in the simulation. "
65 <<
"Source will be ignored.";
75 if (!found_transport_xs)
78 <<
"MG-Diff-InitMaterials: Found no transport cross-section property for "
79 <<
"material \"" << current_material->name_ <<
"\".";
86 <<
"MG-Diff-InitMaterials: Found material \""
87 << current_material->name_ <<
"\" has "
89 <<
"the simulation has " <<
num_groups_ <<
" groups. The material "
90 <<
"must have the same number of groups.";
98 <<
"MG-Diff-InitMaterials: Found material \""
99 << current_material->name_ <<
"\" has a scattering order of "
101 <<
" the simulation has a scattering order of One (MG-Diff)"
102 <<
" The higher moments will therefore not be used.";
106 <<
" number of moments "
109 first_material_read =
false;
113 <<
"Materials Initialized:\n" << materials_list.str() <<
"\n";
128 const auto &S = mat_id_xs.second->TransferMatrix(0);
131 for (
int g = G-1; g >=0 ; --g)
133 for (
const auto &[row_g, gp, sigma_sm]: S.Row(g))
135 if ((std::fabs(sigma_sm) > 1e-10) && (gp > row_g))
136 lfg = std::min(lfg,
static_cast<unsigned int>(row_g));
static std::vector< chi_physics::MaterialPtr > material_stack
static void Exit(int error_code)
static std::shared_ptr< T > & GetStackItemPtr(std::vector< std::shared_ptr< T > > &stack, const size_t handle, const std::string &calling_function_name="Unknown")
static chi::MPI_Info & mpi
LogStream Log(LOG_LVL level=LOG_0)
LogStream LogAllWarning()
BasicOptions basic_options_
void Initialize_Materials(std::set< int > &material_ids)
std::map< int, std::shared_ptr< chi_physics::MultiGroupXS > > matid_to_xs_map
void Compute_TwoGrid_Params()
std::map< int, std::shared_ptr< chi_physics::IsotropicMultiGrpSource > > matid_to_src_map