18 const std::string fname =
"lbs::SteadyStateSolver::InitMaterials";
23 std::set<int> unique_material_ids;
24 int invalid_mat_cell_count = 0;
27 unique_material_ids.insert(cell.material_id_);
28 if (cell.material_id_ < 0)
29 ++invalid_mat_cell_count;
31 const auto& ghost_cell_ids =
grid_ptr_->cells.GetGhostGlobalIDs();
32 for (uint64_t cell_id : ghost_cell_ids)
34 const auto& cell =
grid_ptr_->cells[cell_id];
35 unique_material_ids.insert(cell.material_id_);
36 if (cell.material_id_ < 0)
37 ++invalid_mat_cell_count;
40 if (invalid_mat_cell_count>0)
43 <<
"Number of invalid material cells: " << invalid_mat_cell_count;
47 std::stringstream materials_list;
54 for (
const int& mat_id : unique_material_ids)
56 materials_list <<
"Material id " << mat_id;
60 throw std::logic_error(fname +
": Cells encountered with no assigned "
62 if (
static_cast<size_t>(mat_id) >= num_physics_mats)
63 throw std::logic_error(fname +
": Cells encountered with material id that"
64 " matches no material in physics material "
67 auto current_material =
73 bool found_transport_xs =
false;
74 for (
const auto& property : current_material->properties_)
76 if (property->Type() == MatProperty::TRANSPORT_XSECTIONS)
79 std::static_pointer_cast<chi_physics::MultiGroupXS>(property);
81 found_transport_xs =
true;
83 if (property->Type() == MatProperty::ISOTROPIC_MG_SOURCE)
86 std::static_pointer_cast<chi_physics::IsotropicMultiGrpSource>(property);
88 if (mg_source->source_value_g_.size() <
groups_.size())
91 << fname +
": Isotropic Multigroup source specified in "
92 <<
"material \"" << current_material->name_ <<
"\" has fewer "
93 <<
"energy groups than called for in the simulation. "
94 <<
"Source will be ignored.";
104 if (!found_transport_xs)
107 << fname +
": Found no transport cross-section property for "
108 <<
"material \"" << current_material->name_ <<
"\".";
115 << fname +
": Found material \"" << current_material->name_ <<
"\" has "
117 <<
" the simulation has " <<
groups_.size() <<
" groups."
118 <<
" The material must have a greater or equal amount of groups.";
126 << fname +
": Found material \"" << current_material->name_
127 <<
"\" has a scattering order of "
129 <<
" and the simulation has a scattering order of "
131 <<
". The higher moments will therefore not be used.";
135 <<
" number of moments "
146 const auto& xs = mat_id_xs.second;
161 const auto& xs = mat_id_xs.second;
163 throw std::logic_error(
164 "Incompatible cross section data encountered."
165 "When delayed neutron data is present for one "
166 "fissionable material, it must be present for "
167 "all fissionable materials.");
174 for (
const auto& cell :
grid_ptr_->local_cells)
179 transport_view.ReassingXS(*xs_ptr);
183 <<
"Materials Initialized:\n" << materials_list.str() <<
"\n";
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 LogAllWarning()
chi_mesh::MeshContinuumPtr grid_ptr_
std::vector< lbs::CellLBSView > cell_transport_views_
std::vector< LBSGroup > groups_
std::map< int, IsotropicSrcPtr > matid_to_src_map_
std::map< int, XSPtr > matid_to_xs_map_
size_t max_precursors_per_material_
unsigned int scattering_order