Move CellInstance to cell.h

This commit is contained in:
Paul Romano 2019-12-12 07:30:41 -06:00
parent 671e8b49b9
commit a14e3d98aa
2 changed files with 33 additions and 30 deletions

View file

@ -2,12 +2,14 @@
#define OPENMC_CELL_H
#include <cstdint>
#include <functional> // for hash
#include <limits>
#include <memory> // for unique_ptr
#include <string>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "hdf5.h"
#include "pugixml.hpp"
#include "dagmc.h"
@ -286,10 +288,40 @@ private:
std::vector<std::vector<int32_t>> partitions_;
};
//==============================================================================
//! Define an instance of a particular cell
//==============================================================================
struct CellInstance {
//! Check for equality
bool operator==(const CellInstance& other) const
{ return index_cell == other.index_cell && instance == other.instance; }
gsl::index index_cell;
gsl::index instance;
};
} // namespace openmc
namespace std {
template<>
struct hash<openmc::CellInstance> {
// Taken from https://stackoverflow.com/a/17017281
std::size_t operator()(const openmc::CellInstance& k) const
{
std::size_t res = 17;
res = 31 * res + std::hash<gsl::index>()(k.index_cell);
res = 31 * res + std::hash<gsl::index>()(k.instance);
return res;
}
};
} // namespace std
//==============================================================================
// Non-member functions
//==============================================================================
namespace openmc {
void read_cells(pugi::xml_node node);
#ifdef DAGMC

View file

@ -2,43 +2,14 @@
#define OPENMC_TALLIES_FILTER_CELL_INSTANCE_H
#include <cstdint>
#include <functional> // for hash
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "openmc/cell.h"
#include "openmc/tallies/filter.h"
//==============================================================================
//! Define an instance of a particular cell
//==============================================================================
namespace openmc {
struct CellInstance {
//! Check for equality
bool operator==(const CellInstance& other) const
{ return index_cell == other.index_cell && instance == other.instance; }
gsl::index index_cell;
gsl::index instance;
};
} // namespace openmc
namespace std {
template<>
struct hash<openmc::CellInstance> {
// Taken from https://stackoverflow.com/a/17017281
std::size_t operator()(const openmc::CellInstance& k) const
{
std::size_t res = 17;
res = 31 * res + std::hash<gsl::index>()(k.index_cell);
res = 31 * res + std::hash<gsl::index>()(k.instance);
return res;
}
};
} // namespace std
namespace openmc {