From 50dcae177225b4ddd86eef7515caf3758da244a2 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 5 Sep 2018 12:27:18 -0500 Subject: [PATCH] Add Doxygen comments, remove unused variables --- include/openmc/capi.h | 1 - include/openmc/mesh.h | 62 ++++++++++++++++++++++++++++++++++++---- src/cmfd_input.F90 | 2 -- src/input_xml.F90 | 10 ------- src/multipole_header.F90 | 4 +-- src/nuclide_header.F90 | 1 - src/physics.F90 | 1 - src/physics_mg.F90 | 1 - src/settings.cpp | 13 ++++----- src/state_point.F90 | 2 +- 10 files changed, 64 insertions(+), 33 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index c155e7bd1..c48b212bd 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -140,7 +140,6 @@ extern "C" { extern int32_t n_filters; extern int32_t n_lattices; extern int32_t n_materials; - extern int32_t n_meshes; extern int n_nuclides; extern int32_t n_plots; extern int32_t n_realizations; diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index c81756491..dca028287 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -28,26 +28,76 @@ public: RegularMesh(pugi::xml_node node); // Methods + + //! Determine which bins were crossed by a particle + //! + //! \param[in] p Particle to check + //! \param[out] bins Bins that were crossed + //! \param[out] lengths Fraction of tracklength in each bin void bins_crossed(const Particle* p, std::vector& bins, std::vector& lengths); + + //! Determine which surface bins were crossed by a particle + //! + //! \param[in] p Particle to check + //! \param[out] bins Surface bins that were crossed void surface_bins_crossed(const Particle* p, std::vector& bins); + + //! Get bin at a given position in space + //! + //! \param[in] r Position to get bin for + //! \return Mesh bin int get_bin(Position r); + + //! Get bin given mesh indices + //! + //! \param[in] Array of mesh indices + //! \return Mesh bin int get_bin_from_indices(const int* ijk); + + //! Get mesh indices given a position + //! + //! \param[in] r Position to get indices for + //! \param[out] ijk Array of mesh indices + //! \param[out] in_mesh Whether position is in mesh void get_indices(Position r, int* ijk, bool* in_mesh); + + //! Get mesh indices corresponding to a mesh bin + //! + //! \param[in] bin Mesh bin + //! \param[out] ijk Mesh indices void get_indices_from_bin(int bin, int* ijk); + + //! Check if a line connected by two points intersects the mesh + //! + //! \param[in] r0 Starting position + //! \param[in] r1 Ending position + //! \return Whether line connecting r0 and r1 intersects mesh bool intersects(Position r0, Position r1); + + //! Write mesh data to an HDF5 group + //! + //! \param[in] group HDF5 group void to_hdf5(hid_t group); + //! Count number of bank sites in each mesh bin / energy bin + //! + //! \param[in] n Number of bank sites + //! \param[in] bank Array of bank sites + //! \param[in] n_energy Number of energies + //! \param[in] energies Array of energies + //! \param[out] Whether any bank sites are outside the mesh + //! \return Array indicating number of sites in each mesh/energy bin xt::xarray count_sites(int64_t n, const Bank* bank, int n_energy, const double* energies, bool* outside); int id_ {-1}; //!< User-specified ID - int n_dimension_; - double volume_frac_; - xt::xarray shape_; - xt::xarray lower_left_; - xt::xarray upper_right_; - xt::xarray width_; + int n_dimension_; //!< Number of dimensions + double volume_frac_; //!< Volume fraction of each mesh element + xt::xarray shape_; //!< Number of mesh elements in each dimension + xt::xarray lower_left_; //!< Lower-left coordinates of mesh + xt::xarray upper_right_; //!< Upper-right coordinates of mesh + xt::xarray width_; //!< Width of each mesh element private: bool intersects_1d(Position r0, Position r1); diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90 index 3208ad9d0..d1e0f6a9a 100644 --- a/src/cmfd_input.F90 +++ b/src/cmfd_input.F90 @@ -263,8 +263,6 @@ contains integer :: i_filt ! index in filters array integer :: filt_id integer :: tally_id - integer :: iarray3(3) ! temp integer array - real(8) :: rarray3(3) ! temp double array real(C_DOUBLE), allocatable :: energies(:) type(XMLNode) :: node_mesh diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 4766650bf..e756a6aa5 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -203,22 +203,14 @@ contains subroutine read_settings_xml_f(root_ptr) bind(C) type(C_PTR), value :: root_ptr - character(MAX_LINE_LEN) :: temp_str integer :: i integer :: n - integer :: temp_int - integer :: temp_int_array3(3) - integer(C_INT32_T) :: i_start, i_end - integer(C_INT) :: err integer, allocatable :: temp_int_array(:) integer :: n_tracks type(XMLNode) :: root - type(XMLNode) :: node_entropy - type(XMLNode) :: node_ufs type(XMLNode) :: node_sp type(XMLNode) :: node_res_scat type(XMLNode) :: node_vol - type(XMLNode), allocatable :: node_mesh_list(:) type(XMLNode), allocatable :: node_vol_list(:) ! Get proper XMLNode type given pointer @@ -1164,13 +1156,11 @@ contains character(MAX_WORD_LEN), allocatable :: sarray(:) type(DictCharInt) :: trigger_scores type(TallyFilterContainer), pointer :: f - type(RegularMesh), pointer :: m type(XMLDocument) :: doc type(XMLNode) :: root type(XMLNode) :: node_tal type(XMLNode) :: node_filt type(XMLNode) :: node_trigger - type(XMLNode), allocatable :: node_mesh_list(:) type(XMLNode), allocatable :: node_tal_list(:) type(XMLNode), allocatable :: node_filt_list(:) type(XMLNode), allocatable :: node_trigger_list(:) diff --git a/src/multipole_header.F90 b/src/multipole_header.F90 index 05eb62e1a..64610e471 100644 --- a/src/multipole_header.F90 +++ b/src/multipole_header.F90 @@ -1,7 +1,6 @@ module multipole_header use constants - use dict_header, only: DictIntInt use error, only: fatal_error use hdf5_interface @@ -74,12 +73,11 @@ contains character(len=*), intent(in) :: filename character(len=10) :: version - integer :: i, n_poles, n_residues, n_windows + integer :: n_poles, n_residues, n_windows integer(HSIZE_T) :: dims_1d(1), dims_2d(2), dims_3d(3) integer(HID_T) :: file_id integer(HID_T) :: group_id integer(HID_T) :: dset - type(DictIntInt) :: l_val_dict ! Open file for reading and move into the /isotope group file_id = file_open(filename, 'r', parallel=.true.) diff --git a/src/nuclide_header.F90 b/src/nuclide_header.F90 index 481419fdc..47a2d700a 100644 --- a/src/nuclide_header.F90 +++ b/src/nuclide_header.F90 @@ -600,7 +600,6 @@ contains integer :: i, j, k, l integer :: t - integer :: m integer :: n integer :: n_grid integer :: i_fission diff --git a/src/physics.F90 b/src/physics.F90 index f1a0d7c57..29a806495 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -1181,7 +1181,6 @@ contains integer :: nu_d(MAX_DELAYED_GROUPS) ! number of delayed neutrons born integer :: i ! loop index integer :: nu ! actual number of neutrons produced - integer :: mesh_bin ! mesh bin for source site real(8) :: nu_t ! total nu real(8) :: weight ! weight adjustment for ufs method type(Nuclide), pointer :: nuc diff --git a/src/physics_mg.F90 b/src/physics_mg.F90 index bcafc4314..1d60b371e 100644 --- a/src/physics_mg.F90 +++ b/src/physics_mg.F90 @@ -167,7 +167,6 @@ contains integer :: dg ! delayed group integer :: gout ! group out integer :: nu ! actual number of neutrons produced - integer :: mesh_bin ! mesh bin for source site real(8) :: nu_t ! total nu real(8) :: mu ! fission neutron angular cosine real(8) :: phi ! fission neutron azimuthal angle diff --git a/src/settings.cpp b/src/settings.cpp index 7da8b3166..007c515b0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -3,7 +3,6 @@ #include // for ceil, pow #include // for numeric_limits #include -#include // for out_of_range #include #include @@ -490,13 +489,13 @@ void read_settings_xml() // Shannon Entropy mesh if (check_for_node(root, "entropy_mesh")) { int temp = std::stoi(get_node_value(root, "entropy_mesh")); - try { - index_entropy_mesh = mesh_map.at(temp); - } catch (const std::out_of_range& e) { + if (mesh_map.find(temp) == mesh_map.end()) { std::stringstream msg; msg << "Mesh " << temp << " specified for Shannon entropy does not exist."; fatal_error(msg); } + index_entropy_mesh = mesh_map.at(temp); + } else if (check_for_node(root, "entropy")) { warning("Specifying a Shannon entropy mesh via the element " "is deprecated. Please create a mesh using and then reference " @@ -535,14 +534,14 @@ void read_settings_xml() // Uniform fission source weighting mesh if (check_for_node(root, "ufs_mesh")) { auto temp = std::stoi(get_node_value(root, "ufs_mesh")); - try { - index_ufs_mesh = mesh_map.at(temp); - } catch (const std::out_of_range& e) { + if (mesh_map.find(temp) == mesh_map.end()) { std::stringstream msg; msg << "Mesh " << temp << " specified for uniform fission site method " "does not exist."; fatal_error(msg); } + index_ufs_mesh = mesh_map.at(temp); + } else if (check_for_node(root, "uniform_fs")) { warning("Specifying a UFS mesh via the element " "is deprecated. Please create a mesh using and then reference " diff --git a/src/state_point.F90 b/src/state_point.F90 index d20456d7b..526066c52 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -67,7 +67,7 @@ contains integer :: i_xs integer, allocatable :: id_array(:) integer(HID_T) :: file_id - integer(HID_T) :: cmfd_group, tallies_group, tally_group, meshes_group, & + integer(HID_T) :: cmfd_group, tallies_group, tally_group, & filters_group, filter_group, derivs_group, & deriv_group, runtime_group integer(C_INT) :: ignored_err