From c68052da6bad51e05f6ef9d0445da7dd9f552151 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 5 Jul 2019 21:41:35 -0500 Subject: [PATCH] Reorder declarations in Tally, Filter, and Material classes --- include/openmc/material.h | 36 ++++++++++++++++++++++----------- include/openmc/tallies/filter.h | 34 ++++++++++++++++++++----------- include/openmc/tallies/tally.h | 7 +++---- src/tallies/tally.cpp | 5 ----- 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/include/openmc/material.h b/include/openmc/material.h index 03d76f6cc1..02c5380f35 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -36,6 +36,7 @@ extern std::unordered_map material_map; class Material { public: + //---------------------------------------------------------------------------- // Types struct ThermalTable { int index_table; //!< Index of table in data::thermal_scatt @@ -43,12 +44,15 @@ public: double fraction; //!< How often to use table }; - // Constructors and destructors + //---------------------------------------------------------------------------- + // Constructors, destructors, factory functions Material() {}; explicit Material(pugi::xml_node material_node); ~Material(); + //---------------------------------------------------------------------------- // Methods + void calculate_xs(Particle& p) const; //! Assign thermal scattering tables to specific nuclides within the material @@ -61,12 +65,25 @@ public: //! Finalize the material, assigning tables, normalize density, etc. void finalize(); + //! Write material data to HDF5 + void to_hdf5(hid_t group) const; + //! Add nuclide to the material // //! \param[in] nuclide Name of the nuclide //! \param[in] density Density of the nuclide in [atom/b-cm] void add_nuclide(const std::string& nuclide, double density); + //! Set atom densities for the material + // + //! \param[in] name Name of each nuclide + //! \param[in] density Density of each nuclide in [atom/b-cm] + void set_densities(const std::vector& name, + const std::vector& density); + + //---------------------------------------------------------------------------- + // Accessors + //! Get density in [atom/b-cm] //! \return Density in [atom/b-cm] double density() const { return density_; } @@ -89,13 +106,6 @@ public: //! \return Densities in [atom/b-cm] gsl::span densities() const { return {atom_density_.data(), atom_density_.size()}; } - //! Set atom densities for the material - // - //! \param[in] name Name of each nuclide - //! \param[in] density Density of each nuclide in [atom/b-cm] - void set_densities(const std::vector& name, - const std::vector& density); - //! Get ID of material //! \return ID of material int32_t id() const { return id_; } @@ -113,9 +123,7 @@ public: //! \return Volume in [cm^3] double volume() const; - //! Write material data to HDF5 - void to_hdf5(hid_t group) const; - + //---------------------------------------------------------------------------- // Data int32_t id_; //!< Unique ID std::string name_; //!< Name of material @@ -146,6 +154,9 @@ public: std::unique_ptr ttb_; private: + //---------------------------------------------------------------------------- + // Private methods + //! Calculate the collision stopping power void collision_stopping_power(double* s_col, bool positron); @@ -158,7 +169,8 @@ private: void calculate_neutron_xs(Particle& p) const; void calculate_photon_xs(Particle& p) const; - // Data members + //---------------------------------------------------------------------------- + // Private data members gsl::index index_; }; diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index 905107790a..7203a81615 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -45,8 +45,11 @@ namespace openmc { class Filter { public: - // Default constructor + //---------------------------------------------------------------------------- + // Constructors, destructors, factory functions + Filter(); + virtual ~Filter(); //! Create a new tally filter // @@ -62,13 +65,14 @@ public: //! \return Pointer to the new filter object static Filter* create(pugi::xml_node node); - virtual ~Filter(); - - virtual std::string type() const = 0; - //! Uses an XML input to fill the filter's data fields. virtual void from_xml(pugi::xml_node node) = 0; + //---------------------------------------------------------------------------- + // Methods + + virtual std::string type() const = 0; + //! Matches a tally event to a set of filter bins and weights. //! //! \param[out] match will contain the matching bins and corresponding @@ -76,13 +80,6 @@ public: virtual void get_all_bins(const Particle* p, int estimator, FilterMatch& match) const = 0; - //! Assign a unique ID to the filter - //! \param[in] Unique ID to assign. A value of -1 indicates that an ID should - //! be automatically assigned - void set_id(int32_t id); - - gsl::index index() const { return index_; } - //! Writes data describing this filter to an HDF5 statepoint group. virtual void to_statepoint(hid_t filter_group) const @@ -97,6 +94,19 @@ public: //! "Incoming Energy [0.625E-6, 20.0)". virtual std::string text_label(int bin) const = 0; + //---------------------------------------------------------------------------- + // Accessors + + //! Assign a unique ID to the filter + //! \param[in] Unique ID to assign. A value of -1 indicates that an ID should + //! be automatically assigned + void set_id(int32_t id); + + gsl::index index() const { return index_; } + + //---------------------------------------------------------------------------- + // Data members + int32_t id_ {-1}; int n_bins_; diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index 8fe2773055..2a166738d8 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -23,13 +23,15 @@ namespace openmc { class Tally { public: + //---------------------------------------------------------------------------- // Constructors, destructors, factory functions explicit Tally(int32_t id); explicit Tally(pugi::xml_node node); ~Tally(); static Tally* create(int32_t id = -1); - void init_from_xml(pugi::xml_node node); + //---------------------------------------------------------------------------- + // Accessors void set_id(int32_t id); @@ -43,9 +45,6 @@ public: void set_nuclides(const std::vector& nuclides); - //---------------------------------------------------------------------------- - // Methods for getting and setting filter/stride data. - const std::vector& filters() const {return filters_;} int32_t filters(int i) const {return filters_[i];} diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 1eda7da50c..496c18ee4f 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -479,11 +479,6 @@ Tally::create(int32_t id) return model::tallies.back().get(); } -void -Tally::init_from_xml(pugi::xml_node node) -{ -} - void Tally::set_id(int32_t id) {