mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Merge pull request #1423 from smharper/valgrind
Address some minor Valgrind errors/warnings
This commit is contained in:
commit
428b8a7690
7 changed files with 22 additions and 17 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/bremsstrahlung.h"
|
||||
#include "openmc/particle.h"
|
||||
|
||||
|
|
@ -132,7 +133,7 @@ public:
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
// Data
|
||||
int32_t id_ {-1}; //!< Unique ID
|
||||
int32_t id_ {C_NONE}; //!< Unique ID
|
||||
std::string name_; //!< Name of material
|
||||
std::vector<int> nuclide_; //!< Indices in nuclides vector
|
||||
std::vector<int> element_; //!< Indices in elements vector
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "pugixml.hpp"
|
||||
|
|
@ -118,7 +119,7 @@ public:
|
|||
protected:
|
||||
int n_bins_;
|
||||
private:
|
||||
int32_t id_ {-1};
|
||||
int32_t id_ {C_NONE};
|
||||
gsl::index index_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Major public data members.
|
||||
|
||||
int id_; //!< User-defined identifier
|
||||
int id_ {C_NONE}; //!< User-defined identifier
|
||||
|
||||
std::string name_; //!< User-defined name
|
||||
|
||||
|
|
|
|||
|
|
@ -857,12 +857,12 @@ void Material::calculate_photon_xs(Particle& p) const
|
|||
|
||||
void Material::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= -1);
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in material map if an ID was already assigned before
|
||||
if (id_ != -1) {
|
||||
if (id_ != C_NONE) {
|
||||
model::material_map.erase(id_);
|
||||
id_ = -1;
|
||||
id_ = C_NONE;
|
||||
}
|
||||
|
||||
// Make sure no other material has same ID
|
||||
|
|
@ -871,7 +871,7 @@ void Material::set_id(int32_t id)
|
|||
}
|
||||
|
||||
// If no ID specified, auto-assign next ID in sequence
|
||||
if (id == -1) {
|
||||
if (id == C_NONE) {
|
||||
id = 0;
|
||||
for (const auto& m : model::materials) {
|
||||
id = std::max(id, m->id_);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <algorithm> // for copy, equal, min, min_element
|
||||
#include <cstddef> // for size_t
|
||||
#include <cmath> // for ceil
|
||||
#include <memory> // for allocator
|
||||
#include <string>
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
|
|
@ -814,9 +815,11 @@ RegularMesh::count_sites(const std::vector<Particle::Bank>& bank,
|
|||
cnt(mesh_bin) += site.wgt;
|
||||
}
|
||||
|
||||
// Create copy of count data
|
||||
// Create copy of count data. Since ownership will be acquired by xtensor,
|
||||
// std::allocator must be used to avoid Valgrind mismatched free() / delete
|
||||
// warnings.
|
||||
int total = cnt.size();
|
||||
double* cnt_reduced = new double[total];
|
||||
double* cnt_reduced = std::allocator<double>{}.allocate(total);
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
// collect values from all processors
|
||||
|
|
|
|||
|
|
@ -148,12 +148,12 @@ Filter* Filter::create(const std::string& type, int32_t id)
|
|||
|
||||
void Filter::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= -1);
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in filter map if an ID was already assigned before
|
||||
if (id_ != -1) {
|
||||
if (id_ != C_NONE) {
|
||||
model::filter_map.erase(id_);
|
||||
id_ = -1;
|
||||
id_ = C_NONE;
|
||||
}
|
||||
|
||||
// Make sure no other filter has same ID
|
||||
|
|
@ -162,7 +162,7 @@ void Filter::set_id(int32_t id)
|
|||
}
|
||||
|
||||
// If no ID specified, auto-assign next ID in sequence
|
||||
if (id == -1) {
|
||||
if (id == C_NONE) {
|
||||
id = 0;
|
||||
for (const auto& f : model::tally_filters) {
|
||||
id = std::max(id, f->id_);
|
||||
|
|
|
|||
|
|
@ -483,12 +483,12 @@ Tally::create(int32_t id)
|
|||
void
|
||||
Tally::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= -1);
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in tally map if an ID was already assigned before
|
||||
if (id_ != -1) {
|
||||
if (id_ != C_NONE) {
|
||||
model::tally_map.erase(id_);
|
||||
id_ = -1;
|
||||
id_ = C_NONE;
|
||||
}
|
||||
|
||||
// Make sure no other tally has the same ID
|
||||
|
|
@ -497,7 +497,7 @@ Tally::set_id(int32_t id)
|
|||
}
|
||||
|
||||
// If no ID specified, auto-assign next ID in sequence
|
||||
if (id == -1) {
|
||||
if (id == C_NONE) {
|
||||
id = 0;
|
||||
for (const auto& t : model::tallies) {
|
||||
id = std::max(id, t->id_);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue