mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Clone material. Refs #2442
This commit is contained in:
parent
3068d0cbbb
commit
e41ae3604e
2 changed files with 34 additions and 0 deletions
|
|
@ -90,6 +90,9 @@ public:
|
|||
void set_densities(
|
||||
const vector<std::string>& name, const vector<double>& density);
|
||||
|
||||
//! Clone the material by deep-copying all members
|
||||
void clone();
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
|
|
|
|||
|
|
@ -353,6 +353,37 @@ Material::~Material()
|
|||
model::material_map.erase(id_);
|
||||
}
|
||||
|
||||
void Material::clone()
|
||||
{
|
||||
std::unique_ptr<Material> mat = std::make_unique<Material>();
|
||||
mat->index_ = model::materials.size();
|
||||
mat->set_id(C_NONE);
|
||||
|
||||
// set all other parameters to whatever the calling Material has
|
||||
mat->name_ = name_;
|
||||
mat->nuclide_ = nuclide_;
|
||||
mat->element_ = element_;
|
||||
mat->ncrystal_mat_ = ncrystal_mat_;
|
||||
mat->atom_density_ = atom_density_;
|
||||
mat->density_ = density_;
|
||||
mat->density_gpcc_ = density_gpcc_;
|
||||
mat->volume_ = volume_;
|
||||
mat->fissionable_ = fissionable_;
|
||||
mat->depletable_ = depletable_;
|
||||
mat->p0_ = p0_;
|
||||
mat->mat_nuclide_index_ = mat_nuclide_index_;
|
||||
mat->thermal_tables_ = thermal_tables_;
|
||||
mat->temperature_ = temperature_;
|
||||
|
||||
if (ttb_)
|
||||
{
|
||||
std::unique_ptr<Bremsstrahlung> ptr2{new Bremsstrahlung{*ttb_}};
|
||||
mat->ttb_ = std::move(ptr2);
|
||||
}
|
||||
|
||||
model::materials.push_back(std::move(mat));
|
||||
}
|
||||
|
||||
void Material::finalize()
|
||||
{
|
||||
// Set fissionable if any nuclide is fissionable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue