Adding Material accessors for name.

This commit is contained in:
Patrick Shriwise 2019-07-18 12:25:53 -05:00
parent df379471dd
commit 54df651888
4 changed files with 13 additions and 17 deletions

View file

@ -136,11 +136,11 @@ public:
//! Get the name of a cell
//! \return Cell name
std::string name() const;
std::string name() const { return name_; };
//! Set the temperature of a cell instance
//! \param[in] name Cell name
void set_name(const std::string& name);
void set_name(const std::string& name) { name_ = name; };
//----------------------------------------------------------------------------
// Data members

View file

@ -92,6 +92,13 @@ public:
//! \return Density in [g/cm^3]
double density_gpcc() const { return density_gpcc_; }
//! Get name
//! \return Material name
std::string name() const { return name_; }
//! Set name
void set_name(const std::string& name) { name_ = name; }
//! Set total density of the material
//
//! \param[in] density Density value

View file

@ -252,18 +252,6 @@ Cell::set_temperature(double T, int32_t instance)
}
}
std::string
Cell::name() const
{
return name_;
}
void
Cell::set_name(const std::string& name)
{
name_ = name;
}
//==============================================================================
// CSGCell implementation
//==============================================================================

View file

@ -1382,13 +1382,14 @@ openmc_material_set_id(int32_t index, int32_t id)
}
extern "C" int
openmc_material_get_name(int32_t index, const char*& name) {
openmc_material_get_name(int32_t index, char*& name) {
if (index < 0 || index >= model::materials.size()) {
strcpy(openmc_err_msg, "Index in materials array is out of bounds.");
return OPENMC_E_OUT_OF_BOUNDS;
}
name = model::materials[index]->name_.c_str();
auto name_str = model::materials[index]->name();
strcpy(name, name_str.c_str());
return 0;
}
@ -1401,7 +1402,7 @@ openmc_material_set_name(int32_t index, const char* name) {
}
std::string name_str(name);
model::materials[index]->name_ = name_str;
model::materials[index]->set_name(name);
return 0;
}