mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Adding Material accessors for name.
This commit is contained in:
parent
df379471dd
commit
54df651888
4 changed files with 13 additions and 17 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
12
src/cell.cpp
12
src/cell.cpp
|
|
@ -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
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue