From 5d3afc11107cef825a4e652b8d4870d75bb16cbf Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 3 Jul 2019 22:34:06 -0500 Subject: [PATCH] Add accessors for Material.density_ and density_gpcc_ --- include/openmc/material.h | 8 ++++++++ src/material.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/openmc/material.h b/include/openmc/material.h index 107f436c9..2454de071 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -65,6 +65,14 @@ public: //! \param[in] density Density of the nuclide in [atom/b-cm] void add_nuclide(const std::string& nuclide, double density); + //! Get density in [atom/b-cm] + //! \return Density in [atom/b-cm] + double density() const { return density_; } + + //! Get density in [g/cm^3] + //! \return Density in [g/cm^3] + double density_gpcc() const { return density_gpcc_; } + //! Set total density of the material int set_density(double density, std::string units); diff --git a/src/material.cpp b/src/material.cpp index 9e6240560..45d000d4a 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1216,7 +1216,7 @@ openmc_material_get_density(int32_t index, double* density) { if (index >= 0 && index < model::materials.size()) { auto& mat = model::materials[index]; - *density = mat->density_gpcc_; + *density = mat->density_gpcc(); return 0; } else { set_errmsg("Index in materials array is out of bounds.");