mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
Merge branch 'develop' into rng-stream-changes
This commit is contained in:
commit
43804fc09d
158 changed files with 3155 additions and 2934 deletions
|
|
@ -295,6 +295,7 @@ list(APPEND libopenmc_SOURCES
|
|||
src/nuclide.cpp
|
||||
src/output.cpp
|
||||
src/particle.cpp
|
||||
src/particle_data.cpp
|
||||
src/particle_restart.cpp
|
||||
src/photon.cpp
|
||||
src/physics.cpp
|
||||
|
|
|
|||
|
|
@ -295,11 +295,11 @@ below.
|
|||
|
||||
class CustomSource : public openmc::Source
|
||||
{
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
openmc::SourceSite sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
openmc::SourceSite particle;
|
||||
// weight
|
||||
particle.particle = openmc::Particle::Type::neutron;
|
||||
particle.particle = openmc::ParticleType::neutron;
|
||||
particle.wgt = 1.0;
|
||||
// position
|
||||
double angle = 2.0 * M_PI * openmc::prn(seed);
|
||||
|
|
@ -370,11 +370,11 @@ the source class when it is created:
|
|||
CustomSource(double energy) : energy_{energy} { }
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
openmc::SourceSite sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
openmc::SourceSite particle;
|
||||
// weight
|
||||
particle.particle = openmc::Particle::Type::neutron;
|
||||
particle.particle = openmc::ParticleType::neutron;
|
||||
particle.wgt = 1.0;
|
||||
// position
|
||||
particle.r.x = 0.0;
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
class RingSource : public openmc::Source
|
||||
{
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
openmc::SourceSite sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
openmc::SourceSite particle;
|
||||
// wgt
|
||||
particle.particle = openmc::Particle::Type::neutron;
|
||||
particle.particle = openmc::ParticleType::neutron;
|
||||
particle.wgt = 1.0;
|
||||
// position
|
||||
double angle = 2.0 * M_PI * openmc::prn(seed);
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ class RingSource : public openmc::Source {
|
|||
}
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
openmc::SourceSite sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
openmc::SourceSite particle;
|
||||
// wgt
|
||||
particle.particle = openmc::Particle::Type::neutron;
|
||||
particle.particle = openmc::ParticleType::neutron;
|
||||
particle.wgt = 1.0;
|
||||
// position
|
||||
double angle = 2.0 * M_PI * openmc::prn(seed);
|
||||
|
|
|
|||
18
include/openmc/array.h
Normal file
18
include/openmc/array.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef OPENMC_ARRAY_H
|
||||
#define OPENMC_ARRAY_H
|
||||
|
||||
/*
|
||||
* See notes in include/openmc/vector.h
|
||||
*
|
||||
* In an implementation of OpenMC that uses an accelerator, we may remove the
|
||||
* use of array below and replace it with a custom
|
||||
* implementation behaving as expected on the device.
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace openmc {
|
||||
using std::array;
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_ARRAY_H
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
#define OPENMC_BANK_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/shared_array.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/shared_array.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -16,13 +16,13 @@ namespace openmc {
|
|||
|
||||
namespace simulation {
|
||||
|
||||
extern std::vector<Particle::Bank> source_bank;
|
||||
extern vector<SourceSite> source_bank;
|
||||
|
||||
extern SharedArray<Particle::Bank> surf_source_bank;
|
||||
extern SharedArray<SourceSite> surf_source_bank;
|
||||
|
||||
extern SharedArray<Particle::Bank> fission_bank;
|
||||
extern SharedArray<SourceSite> fission_bank;
|
||||
|
||||
extern std::vector<int64_t> progeny_per_particle;
|
||||
extern vector<int64_t> progeny_per_particle;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
#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"
|
||||
|
|
@ -15,9 +13,11 @@
|
|||
#include "dagmc.h"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/neighbor_list.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/surface.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ class UniversePartitioner;
|
|||
|
||||
namespace model {
|
||||
extern std::unordered_map<int32_t, int32_t> cell_map;
|
||||
extern std::vector<std::unique_ptr<Cell>> cells;
|
||||
extern vector<unique_ptr<Cell>> cells;
|
||||
|
||||
extern std::unordered_map<int32_t, int32_t> universe_map;
|
||||
extern std::vector<std::unique_ptr<Universe>> universes;
|
||||
extern vector<unique_ptr<Universe>> universes;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -64,7 +64,7 @@ class Universe
|
|||
{
|
||||
public:
|
||||
int32_t id_; //!< Unique ID
|
||||
std::vector<int32_t> cells_; //!< Cells within this universe
|
||||
vector<int32_t> cells_; //!< Cells within this universe
|
||||
|
||||
//! \brief Write universe information to an HDF5 group.
|
||||
//! \param group_id An HDF5 group id.
|
||||
|
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
BoundingBox bounding_box() const;
|
||||
|
||||
std::unique_ptr<UniversePartitioner> partitioner_;
|
||||
unique_ptr<UniversePartitioner> partitioner_;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -151,13 +151,12 @@ public:
|
|||
|
||||
//! Get all cell instances contained by this cell
|
||||
//! \return Map with cell indexes as keys and instances as values
|
||||
std::unordered_map<int32_t, std::vector<int32_t>>
|
||||
get_contained_cells() const;
|
||||
std::unordered_map<int32_t, vector<int32_t>> get_contained_cells() const;
|
||||
|
||||
protected:
|
||||
void
|
||||
get_contained_cells_inner(std::unordered_map<int32_t, std::vector<int32_t>>& contained_cells,
|
||||
std::vector<ParentCell>& parent_cells) const;
|
||||
void get_contained_cells_inner(
|
||||
std::unordered_map<int32_t, vector<int32_t>>& contained_cells,
|
||||
vector<ParentCell>& parent_cells) const;
|
||||
|
||||
public:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -176,18 +175,18 @@ public:
|
|||
//! \brief Material(s) within this cell.
|
||||
//!
|
||||
//! May be multiple materials for distribcell.
|
||||
std::vector<int32_t> material_;
|
||||
vector<int32_t> material_;
|
||||
|
||||
//! \brief Temperature(s) within this cell.
|
||||
//!
|
||||
//! The stored values are actually sqrt(k_Boltzmann * T) for each temperature
|
||||
//! T. The units are sqrt(eV).
|
||||
std::vector<double> sqrtkT_;
|
||||
vector<double> sqrtkT_;
|
||||
|
||||
//! Definition of spatial region as Boolean expression of half-spaces
|
||||
std::vector<std::int32_t> region_;
|
||||
vector<std::int32_t> region_;
|
||||
//! Reverse Polish notation for region expression
|
||||
std::vector<std::int32_t> rpn_;
|
||||
vector<std::int32_t> rpn_;
|
||||
bool simple_; //!< Does the region contain only intersections?
|
||||
|
||||
//! \brief Neighboring cells in the same universe.
|
||||
|
|
@ -201,9 +200,9 @@ public:
|
|||
//! give the rotation matrix in row-major order. When the user specifies
|
||||
//! rotation angles about the x-, y- and z- axes in degrees, these values are
|
||||
//! also present at the end of the vector, making it of length 12.
|
||||
std::vector<double> rotation_;
|
||||
vector<double> rotation_;
|
||||
|
||||
std::vector<int32_t> offset_; //!< Distribcell offset table
|
||||
vector<int32_t> offset_; //!< Distribcell offset table
|
||||
};
|
||||
|
||||
struct CellInstanceItem {
|
||||
|
|
@ -234,27 +233,25 @@ protected:
|
|||
bool contains_simple(Position r, Direction u, int32_t on_surface) const;
|
||||
bool contains_complex(Position r, Direction u, int32_t on_surface) const;
|
||||
BoundingBox bounding_box_simple() const;
|
||||
static BoundingBox bounding_box_complex(std::vector<int32_t> rpn);
|
||||
static BoundingBox bounding_box_complex(vector<int32_t> rpn);
|
||||
|
||||
//! Applies DeMorgan's laws to a section of the RPN
|
||||
//! \param start Starting point for token modification
|
||||
//! \param stop Stopping point for token modification
|
||||
static void apply_demorgan(std::vector<int32_t>::iterator start,
|
||||
std::vector<int32_t>::iterator stop);
|
||||
static void apply_demorgan(
|
||||
vector<int32_t>::iterator start, vector<int32_t>::iterator stop);
|
||||
|
||||
//! Removes complement operators from the RPN
|
||||
//! \param rpn The rpn to remove complement operators from.
|
||||
static void remove_complement_ops(std::vector<int32_t>& rpn);
|
||||
static void remove_complement_ops(vector<int32_t>& rpn);
|
||||
|
||||
//! Returns the beginning position of a parenthesis block (immediately before
|
||||
//! two surface tokens) in the RPN given a starting position at the end of
|
||||
//! that block (immediately after two surface tokens)
|
||||
//! \param start Starting position of the search
|
||||
//! \param rpn The rpn being searched
|
||||
static std::vector<int32_t>::iterator
|
||||
find_left_parenthesis(std::vector<int32_t>::iterator start,
|
||||
const std::vector<int32_t>& rpn);
|
||||
|
||||
static vector<int32_t>::iterator find_left_parenthesis(
|
||||
vector<int32_t>::iterator start, const vector<int32_t>& rpn);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -293,11 +290,11 @@ public:
|
|||
explicit UniversePartitioner(const Universe& univ);
|
||||
|
||||
//! Return the list of cells that could contain the given coordinates.
|
||||
const std::vector<int32_t>& get_cells(Position r, Direction u) const;
|
||||
const vector<int32_t>& get_cells(Position r, Direction u) const;
|
||||
|
||||
private:
|
||||
//! A sorted vector of indices to surfaces that partition the universe
|
||||
std::vector<int32_t> surfs_;
|
||||
vector<int32_t> surfs_;
|
||||
|
||||
//! Vectors listing the indices of the cells that lie within each partition
|
||||
//
|
||||
|
|
@ -306,7 +303,7 @@ private:
|
|||
//! `partitions_.back()` gives the cells that lie on the positive side of
|
||||
//! `surfs_.back()`. Otherwise, `partitions_[i]` gives cells sandwiched
|
||||
//! between `surfs_[i-1]` and `surfs_[i]`.
|
||||
std::vector<std::vector<int32_t>> partitions_;
|
||||
vector<vector<int32_t>> partitions_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@
|
|||
#ifndef OPENMC_CONSTANTS_H
|
||||
#define OPENMC_CONSTANTS_H
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/vector.h"
|
||||
#include "openmc/version.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
using double_2dvec = std::vector<std::vector<double>>;
|
||||
using double_3dvec = std::vector<std::vector<std::vector<double>>>;
|
||||
using double_4dvec = std::vector<std::vector<std::vector<std::vector<double>>>>;
|
||||
using double_2dvec = vector<vector<double>>;
|
||||
using double_3dvec = vector<vector<vector<double>>>;
|
||||
using double_4dvec = vector<vector<vector<vector<double>>>>;
|
||||
|
||||
// ============================================================================
|
||||
// VERSIONING NUMBERS
|
||||
|
|
@ -24,13 +24,13 @@ using double_4dvec = std::vector<std::vector<std::vector<std::vector<double>>>>;
|
|||
constexpr int HDF5_VERSION[] {3, 0};
|
||||
|
||||
// Version numbers for binary files
|
||||
constexpr std::array<int, 2> VERSION_STATEPOINT {17, 0};
|
||||
constexpr std::array<int, 2> VERSION_PARTICLE_RESTART {2, 0};
|
||||
constexpr std::array<int, 2> VERSION_TRACK {2, 0};
|
||||
constexpr std::array<int, 2> VERSION_SUMMARY {6, 0};
|
||||
constexpr std::array<int, 2> VERSION_VOLUME {1, 0};
|
||||
constexpr std::array<int, 2> VERSION_VOXEL {2, 0};
|
||||
constexpr std::array<int, 2> VERSION_MGXS_LIBRARY {1, 0};
|
||||
constexpr array<int, 2> VERSION_STATEPOINT {17, 0};
|
||||
constexpr array<int, 2> VERSION_PARTICLE_RESTART {2, 0};
|
||||
constexpr array<int, 2> VERSION_TRACK {2, 0};
|
||||
constexpr array<int, 2> VERSION_SUMMARY {6, 0};
|
||||
constexpr array<int, 2> VERSION_VOLUME {1, 0};
|
||||
constexpr array<int, 2> VERSION_VOXEL {2, 0};
|
||||
constexpr array<int, 2> VERSION_MGXS_LIBRARY {1, 0};
|
||||
|
||||
// ============================================================================
|
||||
// ADJUSTABLE PARAMETERS
|
||||
|
|
@ -90,13 +90,10 @@ constexpr double N_AVOGADRO {0.602214076}; // Avogadro's number in 10^24/m
|
|||
constexpr double K_BOLTZMANN {8.617333262e-5}; // Boltzmann constant in eV/K
|
||||
|
||||
// Electron subshell labels
|
||||
constexpr std::array<const char*, 39> SUBSHELLS = {
|
||||
"K", "L1", "L2", "L3", "M1", "M2", "M3", "M4", "M5",
|
||||
"N1", "N2", "N3", "N4", "N5", "N6", "N7", "O1", "O2",
|
||||
"O3", "O4", "O5", "O6", "O7", "O8", "O9", "P1", "P2",
|
||||
"P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11",
|
||||
"Q1", "Q2", "Q3"
|
||||
};
|
||||
constexpr array<const char*, 39> SUBSHELLS = {"K", "L1", "L2", "L3", "M1", "M2",
|
||||
"M3", "M4", "M5", "N1", "N2", "N3", "N4", "N5", "N6", "N7", "O1", "O2", "O3",
|
||||
"O4", "O5", "O6", "O7", "O8", "O9", "P1", "P2", "P3", "P4", "P5", "P6", "P7",
|
||||
"P8", "P9", "P10", "P11", "Q1", "Q2", "Q3"};
|
||||
|
||||
// Void material and nuclide
|
||||
// TODO: refactor and remove
|
||||
|
|
@ -241,7 +238,7 @@ enum ReactionType {
|
|||
HEATING_LOCAL = 901
|
||||
};
|
||||
|
||||
constexpr std::array<int, 6> DEPLETION_RX {N_GAMMA, N_P, N_A, N_2N, N_3N, N_4N};
|
||||
constexpr array<int, 6> DEPLETION_RX {N_GAMMA, N_P, N_A, N_2N, N_3N, N_4N};
|
||||
|
||||
enum class URRTableParam {
|
||||
CUM_PROB,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public:
|
|||
|
||||
// Data members
|
||||
Type type_; //!< Type of data library
|
||||
std::vector<std::string> materials_; //!< Materials contained in library
|
||||
vector<std::string> materials_; //!< Materials contained in library
|
||||
std::string path_; //!< File path to library
|
||||
};
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ namespace data {
|
|||
extern std::map<LibraryKey, std::size_t> library_map;
|
||||
|
||||
//!< Data libraries
|
||||
extern std::vector<Library> libraries;
|
||||
extern vector<Library> libraries;
|
||||
|
||||
} // namespace data
|
||||
|
||||
|
|
@ -64,8 +65,8 @@ void read_cross_sections_xml();
|
|||
//
|
||||
//! \param[in] nuc_temps Temperatures for each nuclide in [K]
|
||||
//! \param[in] thermal_temps Temperatures for each thermal scattering table in [K]
|
||||
void read_ce_cross_sections(const std::vector<std::vector<double>>& nuc_temps,
|
||||
const std::vector<std::vector<double>>& thermal_temps);
|
||||
void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
||||
const vector<vector<double>>& thermal_temps);
|
||||
|
||||
//! Read cross_sections.xml and populate data libraries
|
||||
void read_ce_cross_sections_xml();
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
#define OPENMC_DISTRIBUTION_H
|
||||
|
||||
#include <cstddef> // for size_t
|
||||
#include <memory> // for unique_ptr
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/vector.h" // for vector
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -39,11 +39,12 @@ public:
|
|||
double sample(uint64_t* seed) const;
|
||||
|
||||
// Properties
|
||||
const std::vector<double>& x() const { return x_; }
|
||||
const std::vector<double>& p() const { return p_; }
|
||||
const vector<double>& x() const { return x_; }
|
||||
const vector<double>& p() const { return p_; }
|
||||
|
||||
private:
|
||||
std::vector<double> x_; //!< Possible outcomes
|
||||
std::vector<double> p_; //!< Probability of each outcome
|
||||
vector<double> x_; //!< Possible outcomes
|
||||
vector<double> p_; //!< Probability of each outcome
|
||||
|
||||
//! Normalize distribution so that probabilities sum to unity
|
||||
void normalize();
|
||||
|
|
@ -174,14 +175,14 @@ public:
|
|||
double sample(uint64_t* seed) const;
|
||||
|
||||
// x property
|
||||
std::vector<double>& x() { return x_; }
|
||||
const std::vector<double>& x() const { return x_; }
|
||||
const std::vector<double>& p() const { return p_; }
|
||||
vector<double>& x() { return x_; }
|
||||
const vector<double>& x() const { return x_; }
|
||||
const vector<double>& p() const { return p_; }
|
||||
Interpolation interp() const { return interp_; }
|
||||
private:
|
||||
std::vector<double> x_; //!< tabulated independent variable
|
||||
std::vector<double> p_; //!< tabulated probability density
|
||||
std::vector<double> c_; //!< cumulative distribution at tabulated values
|
||||
vector<double> x_; //!< tabulated independent variable
|
||||
vector<double> p_; //!< tabulated probability density
|
||||
vector<double> c_; //!< cumulative distribution at tabulated values
|
||||
Interpolation interp_; //!< interpolation rule
|
||||
|
||||
//! Initialize tabulated probability density function
|
||||
|
|
@ -206,13 +207,13 @@ public:
|
|||
//! \return Sampled value
|
||||
double sample(uint64_t* seed) const;
|
||||
|
||||
const std::vector<double>& x() const { return x_; }
|
||||
const vector<double>& x() const { return x_; }
|
||||
|
||||
private:
|
||||
std::vector<double> x_; //! Possible outcomes
|
||||
vector<double> x_; //! Possible outcomes
|
||||
};
|
||||
|
||||
|
||||
using UPtrDist = std::unique_ptr<Distribution>;
|
||||
using UPtrDist = unique_ptr<Distribution>;
|
||||
|
||||
//! Return univariate probability distribution specified in XML file
|
||||
//! \param[in] node XML node representing distribution
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@
|
|||
#ifndef OPENMC_DISTRIBUTION_ANGLE_H
|
||||
#define OPENMC_DISTRIBUTION_ANGLE_H
|
||||
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/distribution.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -32,8 +31,8 @@ public:
|
|||
bool empty() const { return energy_.empty(); }
|
||||
|
||||
private:
|
||||
std::vector<double> energy_;
|
||||
std::vector<std::unique_ptr<Tabular>> distribution_;
|
||||
vector<double> energy_;
|
||||
vector<unique_ptr<Tabular>> distribution_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@
|
|||
#ifndef OPENMC_DISTRIBUTION_ENERGY_H
|
||||
#define OPENMC_DISTRIBUTION_ENERGY_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -90,10 +89,10 @@ private:
|
|||
};
|
||||
|
||||
int n_region_; //!< Number of inteprolation regions
|
||||
std::vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
std::vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
std::vector<double> energy_; //!< Incident energy in [eV]
|
||||
std::vector<CTTable> distribution_; //!< Distributions for each incident energy
|
||||
vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
vector<double> energy_; //!< Incident energy in [eV]
|
||||
vector<CTTable> distribution_; //!< Distributions for each incident energy
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DISTRIBUTION_MULTI_H
|
||||
#define DISTRIBUTION_MULTI_H
|
||||
|
||||
#include <memory>
|
||||
#include "openmc/memory.h"
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ public:
|
|||
Direction sample(uint64_t* seed) const;
|
||||
};
|
||||
|
||||
using UPtrAngle = std::unique_ptr<UnitSphereDistribution>;
|
||||
using UPtrAngle = unique_ptr<UnitSphereDistribution>;
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ private:
|
|||
Position r_; //!< Single position at which sites are generated
|
||||
};
|
||||
|
||||
using UPtrSpace = std::unique_ptr<SpatialDistribution>;
|
||||
using UPtrSpace = unique_ptr<SpatialDistribution>;
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
#ifndef OPENMC_EIGENVALUE_H
|
||||
#define OPENMC_EIGENVALUE_H
|
||||
|
||||
#include <array>
|
||||
#include <cstdint> // for int64_t
|
||||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <hdf5.h>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ namespace openmc {
|
|||
namespace simulation {
|
||||
|
||||
extern double keff_generation; //!< Single-generation k on each processor
|
||||
extern std::array<double, 2> k_sum; //!< Used to reduce sum and sum_sq
|
||||
extern std::vector<double> entropy; //!< Shannon entropy at each generation
|
||||
extern array<double, 2> k_sum; //!< Used to reduce sum and sum_sq
|
||||
extern vector<double> entropy; //!< Shannon entropy at each generation
|
||||
extern xt::xtensor<double, 1> source_frac; //!< Source fraction for UFS
|
||||
|
||||
} // namespace simulation
|
||||
|
|
|
|||
|
|
@ -4,12 +4,11 @@
|
|||
#ifndef OPENMC_ENDF_H
|
||||
#define OPENMC_ENDF_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -59,7 +58,7 @@ public:
|
|||
//! \return Polynomial evaluated at x
|
||||
double operator()(double x) const override;
|
||||
private:
|
||||
std::vector<double> coef_; //!< Polynomial coefficients
|
||||
vector<double> coef_; //!< Polynomial coefficients
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -80,15 +79,16 @@ public:
|
|||
double operator()(double x) const override;
|
||||
|
||||
// Accessors
|
||||
const std::vector<double>& x() const { return x_; }
|
||||
const std::vector<double>& y() const { return y_; }
|
||||
const vector<double>& x() const { return x_; }
|
||||
const vector<double>& y() const { return y_; }
|
||||
|
||||
private:
|
||||
std::size_t n_regions_ {0}; //!< number of interpolation regions
|
||||
std::vector<int> nbt_; //!< values separating interpolation regions
|
||||
std::vector<Interpolation> int_; //!< interpolation schemes
|
||||
vector<int> nbt_; //!< values separating interpolation regions
|
||||
vector<Interpolation> int_; //!< interpolation schemes
|
||||
std::size_t n_pairs_; //!< number of (x,y) pairs
|
||||
std::vector<double> x_; //!< values of abscissa
|
||||
std::vector<double> y_; //!< values of ordinate
|
||||
vector<double> x_; //!< values of abscissa
|
||||
vector<double> y_; //!< values of ordinate
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -101,11 +101,12 @@ public:
|
|||
|
||||
double operator()(double E) const override;
|
||||
|
||||
const std::vector<double>& bragg_edges() const { return bragg_edges_; }
|
||||
const std::vector<double>& factors() const { return factors_; }
|
||||
const vector<double>& bragg_edges() const { return bragg_edges_; }
|
||||
const vector<double>& factors() const { return factors_; }
|
||||
|
||||
private:
|
||||
std::vector<double> bragg_edges_; //!< Bragg edges in [eV]
|
||||
std::vector<double> factors_; //!< Partial sums of structure factors [eV-b]
|
||||
vector<double> bragg_edges_; //!< Bragg edges in [eV]
|
||||
vector<double> factors_; //!< Partial sums of structure factors [eV-b]
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -126,7 +127,7 @@ private:
|
|||
//! \param[in] group HDF5 group containing dataset
|
||||
//! \param[in] name Name of dataset
|
||||
//! \return Unique pointer to 1D function
|
||||
std::unique_ptr<Function1D> read_function(hid_t group, const char* name);
|
||||
unique_ptr<Function1D> read_function(hid_t group, const char* name);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,15 @@ namespace openmc {
|
|||
// consistent locality improvements.
|
||||
struct EventQueueItem{
|
||||
int64_t idx; //!< particle index in event-based particle buffer
|
||||
Particle::Type type; //!< particle type
|
||||
ParticleType type; //!< particle type
|
||||
int64_t material; //!< material that particle is in
|
||||
double E; //!< particle energy
|
||||
|
||||
// Constructors
|
||||
EventQueueItem() = default;
|
||||
EventQueueItem(const Particle& p, int64_t buffer_idx) :
|
||||
idx(buffer_idx), type(p.type_), material(p.material_), E(p.E_) {}
|
||||
EventQueueItem(const Particle& p, int64_t buffer_idx)
|
||||
: idx(buffer_idx), type(p.type()), material(p.material()), E(p.E())
|
||||
{}
|
||||
|
||||
// Compare by particle type, then by material type (4.5% fuel/7.0% fuel/cladding/etc),
|
||||
// then by energy.
|
||||
|
|
@ -64,7 +65,7 @@ extern SharedArray<EventQueueItem> surface_crossing_queue;
|
|||
extern SharedArray<EventQueueItem> collision_queue;
|
||||
|
||||
// Particle buffer
|
||||
extern std::vector<Particle> particles;
|
||||
extern vector<Particle> particles;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
#ifndef OPENMC_GEOMETRY_H
|
||||
#define OPENMC_GEOMETRY_H
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/particle.h"
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
class BoundaryInfo;
|
||||
class Particle;
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
|
@ -20,7 +22,7 @@ namespace model {
|
|||
extern int root_universe; //!< Index of root universe
|
||||
extern "C" int n_coord_levels; //!< Number of CSG coordinate levels
|
||||
|
||||
extern std::vector<int64_t> overlap_check_count;
|
||||
extern vector<int64_t> overlap_check_count;
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
namespace model {
|
||||
|
|
@ -41,8 +42,8 @@ void assign_temperatures();
|
|||
//! table
|
||||
//==============================================================================
|
||||
|
||||
void get_temperatures(std::vector<std::vector<double>>& nuc_temps,
|
||||
std::vector<std::vector<double>>& thermal_temps);
|
||||
void get_temperatures(
|
||||
vector<vector<double>>& nuc_temps, vector<vector<double>>& thermal_temps);
|
||||
|
||||
//==============================================================================
|
||||
//! \brief Perform final setup for geometry
|
||||
|
|
|
|||
|
|
@ -2,22 +2,22 @@
|
|||
#define OPENMC_HDF5_INTERFACE_H
|
||||
|
||||
#include <algorithm> // for min
|
||||
#include <array>
|
||||
#include <complex>
|
||||
#include <cstddef>
|
||||
#include <cstring> // for strlen
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "hdf5_hl.h"
|
||||
#include "xtensor/xadapt.hpp"
|
||||
#include "xtensor/xarray.hpp"
|
||||
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -55,11 +55,11 @@ hid_t file_open(const std::string& filename, char mode, bool parallel=false);
|
|||
void write_string(hid_t group_id, const char* name, const std::string& buffer,
|
||||
bool indep);
|
||||
|
||||
std::vector<hsize_t> attribute_shape(hid_t obj_id, const char* name);
|
||||
std::vector<std::string> dataset_names(hid_t group_id);
|
||||
vector<hsize_t> attribute_shape(hid_t obj_id, const char* name);
|
||||
vector<std::string> dataset_names(hid_t group_id);
|
||||
void ensure_exists(hid_t obj_id, const char* name, bool attribute=false);
|
||||
std::vector<std::string> group_names(hid_t group_id);
|
||||
std::vector<hsize_t> object_shape(hid_t obj_id);
|
||||
vector<std::string> group_names(hid_t group_id);
|
||||
vector<hsize_t> object_shape(hid_t obj_id);
|
||||
std::string object_name(hid_t obj_id);
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -141,15 +141,15 @@ void read_attribute(hid_t obj_id, const char* name, T& buffer)
|
|||
}
|
||||
|
||||
// array version
|
||||
template<typename T, std::size_t N> inline void
|
||||
read_attribute(hid_t obj_id, const char* name, std::array<T, N>& buffer)
|
||||
template<typename T, std::size_t N>
|
||||
inline void read_attribute(hid_t obj_id, const char* name, array<T, N>& buffer)
|
||||
{
|
||||
read_attr(obj_id, name, H5TypeMap<T>::type_id, buffer.data());
|
||||
}
|
||||
|
||||
// vector version
|
||||
template<typename T>
|
||||
void read_attribute(hid_t obj_id, const char* name, std::vector<T>& vec)
|
||||
void read_attribute(hid_t obj_id, const char* name, vector<T>& vec)
|
||||
{
|
||||
// Get shape of attribute array
|
||||
auto shape = attribute_shape(obj_id, name);
|
||||
|
|
@ -175,7 +175,7 @@ void read_attribute(hid_t obj_id, const char* name, xt::xarray<T>& arr)
|
|||
std::size_t size = 1;
|
||||
for (const auto x : shape)
|
||||
size *= x;
|
||||
std::vector<T> buffer(size);
|
||||
vector<T> buffer(size);
|
||||
|
||||
// Read data from attribute
|
||||
read_attr(obj_id, name, H5TypeMap<T>::type_id, buffer.data());
|
||||
|
|
@ -198,9 +198,9 @@ read_attribute(hid_t obj_id, const char* name, std::string& str)
|
|||
delete[] buffer;
|
||||
}
|
||||
|
||||
// overload for std::vector<std::string>
|
||||
inline void
|
||||
read_attribute(hid_t obj_id, const char* name, std::vector<std::string>& vec)
|
||||
// overload for vector<std::string>
|
||||
inline void read_attribute(
|
||||
hid_t obj_id, const char* name, vector<std::string>& vec)
|
||||
{
|
||||
auto dims = attribute_shape(obj_id, name);
|
||||
auto m = dims[0];
|
||||
|
|
@ -254,20 +254,20 @@ read_dataset(hid_t obj_id, const char* name, std::string& str, bool indep=false)
|
|||
}
|
||||
|
||||
// array version
|
||||
template<typename T, std::size_t N> inline void
|
||||
read_dataset(hid_t dset, const char* name, std::array<T, N>& buffer,
|
||||
bool indep=false)
|
||||
template<typename T, std::size_t N>
|
||||
inline void read_dataset(
|
||||
hid_t dset, const char* name, array<T, N>& buffer, bool indep = false)
|
||||
{
|
||||
read_dataset_lowlevel(dset, name, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
buffer.data());
|
||||
}
|
||||
|
||||
// vector version
|
||||
template <typename T>
|
||||
void read_dataset(hid_t dset, std::vector<T>& vec, bool indep=false)
|
||||
template<typename T>
|
||||
void read_dataset(hid_t dset, vector<T>& vec, bool indep = false)
|
||||
{
|
||||
// Get shape of dataset
|
||||
std::vector<hsize_t> shape = object_shape(dset);
|
||||
vector<hsize_t> shape = object_shape(dset);
|
||||
|
||||
// Resize vector to appropriate size
|
||||
vec.resize(shape[0]);
|
||||
|
|
@ -277,9 +277,9 @@ void read_dataset(hid_t dset, std::vector<T>& vec, bool indep=false)
|
|||
vec.data());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void read_dataset(hid_t obj_id, const char* name, std::vector<T>& vec,
|
||||
bool indep=false)
|
||||
template<typename T>
|
||||
void read_dataset(
|
||||
hid_t obj_id, const char* name, vector<T>& vec, bool indep = false)
|
||||
{
|
||||
hid_t dset = open_dataset(obj_id, name);
|
||||
read_dataset(dset, vec, indep);
|
||||
|
|
@ -290,7 +290,7 @@ template <typename T>
|
|||
void read_dataset(hid_t dset, xt::xarray<T>& arr, bool indep=false)
|
||||
{
|
||||
// Get shape of dataset
|
||||
std::vector<hsize_t> shape = object_shape(dset);
|
||||
vector<hsize_t> shape = object_shape(dset);
|
||||
|
||||
// Allocate space in the array to read data into
|
||||
std::size_t size = 1;
|
||||
|
|
@ -326,11 +326,11 @@ void read_dataset(hid_t obj_id, const char* name, xt::xtensor<T, N>& arr,
|
|||
hid_t dset = open_dataset(obj_id, name);
|
||||
|
||||
// Get shape of dataset
|
||||
std::vector<hsize_t> hsize_t_shape = object_shape(dset);
|
||||
vector<hsize_t> hsize_t_shape = object_shape(dset);
|
||||
close_dataset(dset);
|
||||
|
||||
// cast from hsize_t to size_t
|
||||
std::vector<size_t> shape(hsize_t_shape.size());
|
||||
vector<size_t> shape(hsize_t_shape.size());
|
||||
for (int i = 0; i < shape.size(); i++) {
|
||||
shape[i] = static_cast<size_t>(hsize_t_shape[i]);
|
||||
}
|
||||
|
|
@ -349,7 +349,7 @@ void read_dataset(hid_t obj_id, const char* name, xt::xtensor<T, N>& arr,
|
|||
inline void
|
||||
read_dataset(hid_t obj_id, const char* name, Position& r, bool indep=false)
|
||||
{
|
||||
std::array<double, 3> x;
|
||||
array<double, 3> x;
|
||||
read_dataset(obj_id, name, x, indep);
|
||||
r.x = x[0];
|
||||
r.y = x[1];
|
||||
|
|
@ -366,7 +366,7 @@ inline void read_dataset_as_shape(hid_t obj_id, const char* name,
|
|||
std::size_t size = 1;
|
||||
for (const auto x : arr.shape())
|
||||
size *= x;
|
||||
std::vector<T> buffer(size);
|
||||
vector<T> buffer(size);
|
||||
|
||||
// Read data from attribute
|
||||
read_dataset_lowlevel(dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep,
|
||||
|
|
@ -412,15 +412,17 @@ write_attribute(hid_t obj_id, const char* name, const std::string& buffer)
|
|||
write_attr_string(obj_id, name, buffer.c_str());
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N> inline void
|
||||
write_attribute(hid_t obj_id, const char* name, const std::array<T, N>& buffer)
|
||||
template<typename T, std::size_t N>
|
||||
inline void write_attribute(
|
||||
hid_t obj_id, const char* name, const array<T, N>& buffer)
|
||||
{
|
||||
hsize_t dims[] {N};
|
||||
write_attr(obj_id, 1, dims, name, H5TypeMap<T>::type_id, buffer.data());
|
||||
}
|
||||
|
||||
template<typename T> inline void
|
||||
write_attribute(hid_t obj_id, const char* name, const std::vector<T>& buffer)
|
||||
template<typename T>
|
||||
inline void write_attribute(
|
||||
hid_t obj_id, const char* name, const vector<T>& buffer)
|
||||
{
|
||||
hsize_t dims[] {buffer.size()};
|
||||
write_attr(obj_id, 1, dims, name, H5TypeMap<T>::type_id, buffer.data());
|
||||
|
|
@ -429,7 +431,7 @@ write_attribute(hid_t obj_id, const char* name, const std::vector<T>& buffer)
|
|||
inline void
|
||||
write_attribute(hid_t obj_id, const char* name, Position r)
|
||||
{
|
||||
std::array<double, 3> buffer {r.x, r.y, r.z};
|
||||
array<double, 3> buffer {r.x, r.y, r.z};
|
||||
write_attribute(obj_id, name, buffer);
|
||||
}
|
||||
|
||||
|
|
@ -454,17 +456,17 @@ write_dataset(hid_t obj_id, const char* name, const char* buffer)
|
|||
write_string(obj_id, name, buffer, false);
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N> inline void
|
||||
write_dataset(hid_t obj_id, const char* name, const std::array<T, N>& buffer)
|
||||
template<typename T, std::size_t N>
|
||||
inline void write_dataset(
|
||||
hid_t obj_id, const char* name, const array<T, N>& buffer)
|
||||
{
|
||||
hsize_t dims[] {N};
|
||||
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id,
|
||||
H5S_ALL, false, buffer.data());
|
||||
}
|
||||
|
||||
inline void
|
||||
write_dataset(hid_t obj_id, const char* name,
|
||||
const std::vector<std::string>& buffer)
|
||||
inline void write_dataset(
|
||||
hid_t obj_id, const char* name, const vector<std::string>& buffer)
|
||||
{
|
||||
auto n {buffer.size()};
|
||||
hsize_t dims[] {n};
|
||||
|
|
@ -489,8 +491,9 @@ write_dataset(hid_t obj_id, const char* name,
|
|||
delete[] temp;
|
||||
}
|
||||
|
||||
template<typename T> inline void
|
||||
write_dataset(hid_t obj_id, const char* name, const std::vector<T>& buffer)
|
||||
template<typename T>
|
||||
inline void write_dataset(
|
||||
hid_t obj_id, const char* name, const vector<T>& buffer)
|
||||
{
|
||||
hsize_t dims[] {buffer.size()};
|
||||
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id,
|
||||
|
|
@ -503,7 +506,7 @@ write_dataset(hid_t obj_id, const char* name, const xt::xcontainer<D>& arr)
|
|||
{
|
||||
using T = typename D::value_type;
|
||||
auto s = arr.shape();
|
||||
std::vector<hsize_t> dims {s.cbegin(), s.cend()};
|
||||
vector<hsize_t> dims {s.cbegin(), s.cend()};
|
||||
write_dataset_lowlevel(obj_id, dims.size(), dims.data(), name,
|
||||
H5TypeMap<T>::type_id, H5S_ALL, false, arr.data());
|
||||
}
|
||||
|
|
@ -511,7 +514,7 @@ write_dataset(hid_t obj_id, const char* name, const xt::xcontainer<D>& arr)
|
|||
inline void
|
||||
write_dataset(hid_t obj_id, const char* name, Position r)
|
||||
{
|
||||
std::array<double, 3> buffer {r.x, r.y, r.z};
|
||||
array<double, 3> buffer {r.x, r.y, r.z};
|
||||
write_dataset(obj_id, name, buffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
#ifndef OPENMC_LATTICE_H
|
||||
#define OPENMC_LATTICE_H
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory> // for unique_ptr
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/position.h"
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -27,7 +26,6 @@ enum class LatticeType {
|
|||
rect, hex
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
|
@ -36,7 +34,7 @@ class Lattice;
|
|||
|
||||
namespace model {
|
||||
extern std::unordered_map<int32_t, int32_t> lattice_map;
|
||||
extern std::vector<std::unique_ptr<Lattice>> lattices;
|
||||
extern vector<unique_ptr<Lattice>> lattices;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -53,15 +51,15 @@ public:
|
|||
int32_t id_; //!< Universe ID number
|
||||
std::string name_; //!< User-defined name
|
||||
LatticeType type_;
|
||||
std::vector<int32_t> universes_; //!< Universes filling each lattice tile
|
||||
vector<int32_t> universes_; //!< Universes filling each lattice tile
|
||||
int32_t outer_ {NO_OUTER_UNIVERSE}; //!< Universe tiled outside the lattice
|
||||
std::vector<int32_t> offsets_; //!< Distribcell offset table
|
||||
vector<int32_t> offsets_; //!< Distribcell offset table
|
||||
|
||||
explicit Lattice(pugi::xml_node lat_node);
|
||||
|
||||
virtual ~Lattice() {}
|
||||
|
||||
virtual int32_t& operator[](std::array<int, 3> i_xyz) = 0;
|
||||
virtual int32_t const& operator[](array<int, 3> const& i_xyz) = 0;
|
||||
|
||||
virtual LatticeIter begin();
|
||||
LatticeIter end();
|
||||
|
|
@ -84,14 +82,7 @@ public:
|
|||
//! \param i_xyz[3] The indices for a lattice tile.
|
||||
//! \return true if the given indices fit within the lattice bounds. False
|
||||
//! otherwise.
|
||||
virtual bool are_valid_indices(const int i_xyz[3]) const = 0;
|
||||
|
||||
bool
|
||||
are_valid_indices(std::array<int, 3> i_xyz) const
|
||||
{
|
||||
int i_xyz_[3] {i_xyz[0], i_xyz[1], i_xyz[2]};
|
||||
return are_valid_indices(i_xyz_);
|
||||
}
|
||||
virtual bool are_valid_indices(array<int, 3> const& i_xyz) const = 0;
|
||||
|
||||
//! \brief Find the next lattice surface crossing
|
||||
//! \param r A 3D Cartesian coordinate.
|
||||
|
|
@ -99,21 +90,22 @@ public:
|
|||
//! \param i_xyz The indices for a lattice tile.
|
||||
//! \return The distance to the next crossing and an array indicating how the
|
||||
//! lattice indices would change after crossing that boundary.
|
||||
virtual std::pair<double, std::array<int, 3>>
|
||||
distance(Position r, Direction u, const std::array<int, 3>& i_xyz) const
|
||||
= 0;
|
||||
virtual std::pair<double, array<int, 3>> distance(
|
||||
Position r, Direction u, const array<int, 3>& i_xyz) const = 0;
|
||||
|
||||
//! \brief Find the lattice tile indices for a given point.
|
||||
//! \param r A 3D Cartesian coordinate.
|
||||
//! \return An array containing the indices of a lattice tile.
|
||||
virtual std::array<int, 3> get_indices(Position r, Direction u) const = 0;
|
||||
//! \param u Direction of a particle
|
||||
//! \param result resulting indices to save to
|
||||
virtual void get_indices(
|
||||
Position r, Direction u, array<int, 3>& result) const = 0;
|
||||
|
||||
//! \brief Get coordinates local to a lattice tile.
|
||||
//! \param r A 3D Cartesian coordinate.
|
||||
//! \param i_xyz The indices for a lattice tile.
|
||||
//! \return Local 3D Cartesian coordinates.
|
||||
virtual Position
|
||||
get_local_position(Position r, const std::array<int, 3> i_xyz) const = 0;
|
||||
virtual Position get_local_position(
|
||||
Position r, const array<int, 3>& i_xyz) const = 0;
|
||||
|
||||
//! \brief Check flattened lattice index.
|
||||
//! \param indx The index for a lattice tile.
|
||||
|
|
@ -127,7 +119,7 @@ public:
|
|||
//! \param i_xyz[3] The indices for a lattice tile.
|
||||
//! \return Distribcell offset i.e. the largest instance number for the target
|
||||
//! cell found in the geometry tree under this lattice tile.
|
||||
virtual int32_t& offset(int map, const int i_xyz[3]) = 0;
|
||||
virtual int32_t& offset(int map, array<int, 3> const& i_xyz) = 0;
|
||||
|
||||
//! \brief Get the distribcell offset for a lattice tile.
|
||||
//! \param The map index for the target cell.
|
||||
|
|
@ -213,19 +205,18 @@ class RectLattice : public Lattice
|
|||
public:
|
||||
explicit RectLattice(pugi::xml_node lat_node);
|
||||
|
||||
int32_t& operator[](std::array<int, 3> i_xyz);
|
||||
int32_t const& operator[](array<int, 3> const& i_xyz);
|
||||
|
||||
bool are_valid_indices(const int i_xyz[3]) const;
|
||||
bool are_valid_indices(array<int, 3> const& i_xyz) const;
|
||||
|
||||
std::pair<double, std::array<int, 3>>
|
||||
distance(Position r, Direction u, const std::array<int, 3>& i_xyz) const;
|
||||
std::pair<double, array<int, 3>> distance(
|
||||
Position r, Direction u, const array<int, 3>& i_xyz) const;
|
||||
|
||||
std::array<int, 3> get_indices(Position r, Direction u) const;
|
||||
void get_indices(Position r, Direction u, array<int, 3>& result) const;
|
||||
|
||||
Position
|
||||
get_local_position(Position r, const std::array<int, 3> i_xyz) const;
|
||||
Position get_local_position(Position r, const array<int, 3>& i_xyz) const;
|
||||
|
||||
int32_t& offset(int map, const int i_xyz[3]);
|
||||
int32_t& offset(int map, array<int, 3> const& i_xyz);
|
||||
|
||||
int32_t offset(int map, int indx) const;
|
||||
|
||||
|
|
@ -234,14 +225,9 @@ public:
|
|||
void to_hdf5_inner(hid_t group_id) const;
|
||||
|
||||
private:
|
||||
std::array<int, 3> n_cells_; //!< Number of cells along each axis
|
||||
array<int, 3> n_cells_; //!< Number of cells along each axis
|
||||
Position lower_left_; //!< Global lower-left corner of the lattice
|
||||
Position pitch_; //!< Lattice tile width along each axis
|
||||
|
||||
// Convenience aliases
|
||||
int &nx {n_cells_[0]};
|
||||
int &ny {n_cells_[1]};
|
||||
int &nz {n_cells_[2]};
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -251,25 +237,24 @@ class HexLattice : public Lattice
|
|||
public:
|
||||
explicit HexLattice(pugi::xml_node lat_node);
|
||||
|
||||
int32_t& operator[](std::array<int, 3> i_xyz);
|
||||
int32_t const& operator[](array<int, 3> const& i_xyz);
|
||||
|
||||
LatticeIter begin();
|
||||
|
||||
ReverseLatticeIter rbegin();
|
||||
|
||||
bool are_valid_indices(const int i_xyz[3]) const;
|
||||
bool are_valid_indices(array<int, 3> const& i_xyz) const;
|
||||
|
||||
std::pair<double, std::array<int, 3>>
|
||||
distance(Position r, Direction u, const std::array<int, 3>& i_xyz) const;
|
||||
std::pair<double, array<int, 3>> distance(
|
||||
Position r, Direction u, const array<int, 3>& i_xyz) const;
|
||||
|
||||
std::array<int, 3> get_indices(Position r, Direction u) const;
|
||||
void get_indices(Position r, Direction u, array<int, 3>& result) const;
|
||||
|
||||
Position
|
||||
get_local_position(Position r, const std::array<int, 3> i_xyz) const;
|
||||
Position get_local_position(Position r, const array<int, 3>& i_xyz) const;
|
||||
|
||||
bool is_valid_index(int indx) const;
|
||||
|
||||
int32_t& offset(int map, const int i_xyz[3]);
|
||||
int32_t& offset(int map, array<int, 3> const& i_xyz);
|
||||
|
||||
int32_t offset(int map, int indx) const;
|
||||
|
||||
|
|
@ -284,16 +269,16 @@ private:
|
|||
};
|
||||
|
||||
//! Fill universes_ vector for 'y' orientation
|
||||
void fill_lattice_y(const std::vector<std::string>& univ_words);
|
||||
void fill_lattice_y(const vector<std::string>& univ_words);
|
||||
|
||||
//! Fill universes_ vector for 'x' orientation
|
||||
void fill_lattice_x(const std::vector<std::string>& univ_words);
|
||||
void fill_lattice_x(const vector<std::string>& univ_words);
|
||||
|
||||
int n_rings_; //!< Number of radial tile positions
|
||||
int n_axial_; //!< Number of axial tile positions
|
||||
Orientation orientation_; //!< Orientation of lattice
|
||||
Position center_; //!< Global center of lattice
|
||||
std::array<double, 2> pitch_; //!< Lattice tile width and height
|
||||
array<double, 2> pitch_; //!< Lattice tile width and height
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
#ifndef OPENMC_MATERIAL_H
|
||||
#define OPENMC_MATERIAL_H
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include <hdf5.h>
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/bremsstrahlung.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ class Material;
|
|||
namespace model {
|
||||
|
||||
extern std::unordered_map<int32_t, int32_t> material_map;
|
||||
extern std::vector<std::unique_ptr<Material>> materials;
|
||||
extern vector<unique_ptr<Material>> materials;
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -79,8 +79,8 @@ public:
|
|||
//
|
||||
//! \param[in] name Name of each nuclide
|
||||
//! \param[in] density Density of each nuclide in [atom/b-cm]
|
||||
void set_densities(const std::vector<std::string>& name,
|
||||
const std::vector<double>& density);
|
||||
void set_densities(
|
||||
const vector<std::string>& name, const vector<double>& density);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
|
@ -139,26 +139,27 @@ public:
|
|||
// Data
|
||||
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
|
||||
vector<int> nuclide_; //!< Indices in nuclides vector
|
||||
vector<int> element_; //!< Indices in elements vector
|
||||
xt::xtensor<double, 1> atom_density_; //!< Nuclide atom density in [atom/b-cm]
|
||||
double density_; //!< Total atom density in [atom/b-cm]
|
||||
double density_gpcc_; //!< Total atom density in [g/cm^3]
|
||||
double volume_ {-1.0}; //!< Volume in [cm^3]
|
||||
bool fissionable_ {false}; //!< Does this material contain fissionable nuclides
|
||||
bool depletable_ {false}; //!< Is the material depletable?
|
||||
std::vector<bool> p0_; //!< Indicate which nuclides are to be treated with iso-in-lab scattering
|
||||
vector<bool> p0_; //!< Indicate which nuclides are to be treated with
|
||||
//!< iso-in-lab scattering
|
||||
|
||||
// To improve performance of tallying, we store an array (direct address
|
||||
// table) that indicates for each nuclide in data::nuclides the index of the
|
||||
// corresponding nuclide in the nuclide_ vector. If it is not present in the
|
||||
// material, the entry is set to -1.
|
||||
std::vector<int> mat_nuclide_index_;
|
||||
vector<int> mat_nuclide_index_;
|
||||
|
||||
// Thermal scattering tables
|
||||
std::vector<ThermalTable> thermal_tables_;
|
||||
vector<ThermalTable> thermal_tables_;
|
||||
|
||||
std::unique_ptr<Bremsstrahlung> ttb_;
|
||||
unique_ptr<Bremsstrahlung> ttb_;
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -191,13 +192,13 @@ private:
|
|||
//==============================================================================
|
||||
|
||||
//! Calculate Sternheimer adjustment factor
|
||||
double sternheimer_adjustment(const std::vector<double>& f, const
|
||||
std::vector<double>& e_b_sq, double e_p_sq, double n_conduction, double
|
||||
log_I, double tol, int max_iter);
|
||||
double sternheimer_adjustment(const vector<double>& f,
|
||||
const vector<double>& e_b_sq, double e_p_sq, double n_conduction,
|
||||
double log_I, double tol, int max_iter);
|
||||
|
||||
//! Calculate density effect correction
|
||||
double density_effect(const std::vector<double>& f, const std::vector<double>&
|
||||
e_b_sq, double e_p_sq, double n_conduction, double rho, double E, double tol,
|
||||
double density_effect(const vector<double>& f, const vector<double>& e_b_sq,
|
||||
double e_p_sq, double n_conduction, double rho, double E, double tol,
|
||||
int max_iter);
|
||||
|
||||
//! Read material data from materials.xml
|
||||
|
|
|
|||
19
include/openmc/memory.h
Normal file
19
include/openmc/memory.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef OPENMC_MEMORY_H
|
||||
#define OPENMC_MEMORY_H
|
||||
|
||||
/*
|
||||
* See notes in include/openmc/vector.h
|
||||
*
|
||||
* In an implementation of OpenMC that uses an accelerator, we may remove the
|
||||
* use of unique_ptr, etc. below and replace it with a custom
|
||||
* implementation behaving as expected on the device.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace openmc {
|
||||
using std::make_unique;
|
||||
using std::unique_ptr;
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_MEMORY_H
|
||||
|
|
@ -4,16 +4,16 @@
|
|||
#ifndef OPENMC_MESH_H
|
||||
#define OPENMC_MESH_H
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#ifdef DAGMC
|
||||
#include "moab/Core.hpp"
|
||||
|
|
@ -47,14 +47,14 @@ class Mesh;
|
|||
namespace model {
|
||||
|
||||
extern std::unordered_map<int32_t, int32_t> mesh_map;
|
||||
extern std::vector<std::unique_ptr<Mesh>> meshes;
|
||||
extern vector<unique_ptr<Mesh>> meshes;
|
||||
|
||||
} // namespace model
|
||||
|
||||
#ifdef LIBMESH
|
||||
namespace settings {
|
||||
// used when creating new libMesh::Mesh instances
|
||||
extern std::unique_ptr<libMesh::LibMeshInit> libmesh_init;
|
||||
extern unique_ptr<libMesh::LibMeshInit> libmesh_init;
|
||||
extern const libMesh::Parallel::Communicator* libmesh_comm;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -79,8 +79,8 @@ public:
|
|||
virtual void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const = 0;
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const = 0;
|
||||
|
||||
//! Determine which surface bins were crossed by a particle
|
||||
//
|
||||
|
|
@ -92,7 +92,7 @@ public:
|
|||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const = 0;
|
||||
vector<int>& bins) const = 0;
|
||||
|
||||
//! Get bin at a given position in space
|
||||
//
|
||||
|
|
@ -122,8 +122,8 @@ public:
|
|||
//! of the plot's axes. For example an xy-slice plot will get back a vector
|
||||
//! of x-coordinates and another of y-coordinates. These vectors may be
|
||||
//! empty for low-dimensional meshes.
|
||||
virtual std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const = 0;
|
||||
virtual std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const = 0;
|
||||
|
||||
//! Return a string representation of the mesh bin
|
||||
//
|
||||
|
|
@ -150,16 +150,16 @@ public:
|
|||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const override;
|
||||
|
||||
//! Count number of bank sites in each mesh bin / energy bin
|
||||
//
|
||||
//! \param[in] Pointer to bank sites
|
||||
//! \param[in] Number of bank sites
|
||||
//! \param[out] Whether any bank sites are outside the mesh
|
||||
xt::xtensor<double, 1> count_sites(const Particle::Bank* bank,
|
||||
int64_t length, bool* outside) const;
|
||||
xt::xtensor<double, 1> count_sites(
|
||||
const SourceSite* bank, int64_t length, bool* outside) const;
|
||||
|
||||
//! Get bin given mesh indices
|
||||
//
|
||||
|
|
@ -236,7 +236,7 @@ public:
|
|||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const override;
|
||||
vector<int>& bins) const override;
|
||||
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
|
|
@ -244,8 +244,8 @@ public:
|
|||
|
||||
double negative_grid_boundary(int* ijk, int i) const override;
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const override;
|
||||
std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
void to_hdf5(hid_t group) const override;
|
||||
|
||||
|
|
@ -256,9 +256,8 @@ public:
|
|||
//! \param[in] bank Array of bank sites
|
||||
//! \param[out] Whether any bank sites are outside the mesh
|
||||
//! \return Array indicating number of sites in each mesh/energy bin
|
||||
xt::xtensor<double, 1> count_sites(const Particle::Bank* bank,
|
||||
int64_t length,
|
||||
bool* outside) const;
|
||||
xt::xtensor<double, 1> count_sites(
|
||||
const SourceSite* bank, int64_t length, bool* outside) const;
|
||||
|
||||
// Data members
|
||||
double volume_frac_; //!< Volume fraction of each mesh element
|
||||
|
|
@ -278,7 +277,7 @@ public:
|
|||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const override;
|
||||
vector<int>& bins) const override;
|
||||
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
|
|
@ -286,12 +285,12 @@ public:
|
|||
|
||||
double negative_grid_boundary(int* ijk, int i) const override;
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const override;
|
||||
std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
void to_hdf5(hid_t group) const override;
|
||||
|
||||
std::vector<std::vector<double>> grid_;
|
||||
vector<vector<double>> grid_;
|
||||
|
||||
int set_grid();
|
||||
};
|
||||
|
|
@ -316,8 +315,7 @@ public:
|
|||
//! Set the value of a bin for a variable on the internal
|
||||
// mesh instance
|
||||
virtual void set_score_data(const std::string& var_name,
|
||||
const std::vector<double>& values,
|
||||
const std::vector<double>& std_dev) = 0;
|
||||
const vector<double>& values, const vector<double>& std_dev) = 0;
|
||||
|
||||
//! Write the unstructured mesh to file
|
||||
//
|
||||
|
|
@ -343,7 +341,7 @@ public:
|
|||
|
||||
void surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
std::vector<int>& bins) const;
|
||||
vector<int>& bins) const;
|
||||
|
||||
void to_hdf5(hid_t group) const override;
|
||||
|
||||
|
|
@ -369,14 +367,11 @@ public:
|
|||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const override;
|
||||
|
||||
void
|
||||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const override;
|
||||
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
|
||||
int get_bin(Position r) const;
|
||||
|
||||
|
|
@ -384,8 +379,8 @@ public:
|
|||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const override;
|
||||
std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
std::string library() const override;
|
||||
|
||||
|
|
@ -396,9 +391,8 @@ public:
|
|||
void remove_scores() override;
|
||||
|
||||
//! Set data for a score
|
||||
void set_score_data(const std::string& score,
|
||||
const std::vector<double>& values,
|
||||
const std::vector<double>& std_dev) override;
|
||||
void set_score_data(const std::string& score, const vector<double>& values,
|
||||
const vector<double>& std_dev) override;
|
||||
|
||||
//! Write the mesh with any current tally data
|
||||
void write(const std::string& base_filename) const;
|
||||
|
|
@ -417,11 +411,8 @@ private:
|
|||
//! \param[in] dir Normalized particle direction
|
||||
//! \param[in] track_len length of particle track
|
||||
//! \param[out] Mesh intersections
|
||||
void
|
||||
intersect_track(const moab::CartVect& start,
|
||||
const moab::CartVect& dir,
|
||||
double track_len,
|
||||
std::vector<double>& hits) const;
|
||||
void intersect_track(const moab::CartVect& start, const moab::CartVect& dir,
|
||||
double track_len, vector<double>& hits) const;
|
||||
|
||||
//! Calculate the volume for a given tetrahedron handle.
|
||||
//
|
||||
|
|
@ -505,10 +496,10 @@ private:
|
|||
moab::Range ehs_; //!< Range of tetrahedra EntityHandle's in the mesh
|
||||
moab::EntityHandle tetset_; //!< EntitySet containing all tetrahedra
|
||||
moab::EntityHandle kdtree_root_; //!< Root of the MOAB KDTree
|
||||
std::unique_ptr<moab::Interface> mbi_; //!< MOAB instance
|
||||
std::unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
|
||||
std::vector<moab::Matrix3> baryc_data_; //!< Barycentric data for tetrahedra
|
||||
std::vector<std::string> tag_names_; //!< Names of score tags added to the mesh
|
||||
unique_ptr<moab::Interface> mbi_; //!< MOAB instance
|
||||
unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
|
||||
vector<moab::Matrix3> baryc_data_; //!< Barycentric data for tetrahedra
|
||||
vector<std::string> tag_names_; //!< Names of score tags added to the mesh
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -525,14 +516,11 @@ public:
|
|||
void bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const override;
|
||||
|
||||
void
|
||||
surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const override;
|
||||
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
|
||||
vector<int>& bins) const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
|
|
@ -540,16 +528,15 @@ public:
|
|||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const override;
|
||||
std::pair<vector<double>, vector<double>> plot(
|
||||
Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
void add_score(const std::string& var_name) override;
|
||||
|
||||
void remove_scores() override;
|
||||
|
||||
void set_score_data(const std::string& var_name,
|
||||
const std::vector<double>& values,
|
||||
const std::vector<double>& std_dev) override;
|
||||
void set_score_data(const std::string& var_name, const vector<double>& values,
|
||||
const vector<double>& std_dev) override;
|
||||
|
||||
void write(const std::string& base_filename) const override;
|
||||
|
||||
|
|
@ -570,9 +557,11 @@ private:
|
|||
int get_bin_from_element(const libMesh::Elem* elem) const;
|
||||
|
||||
// Data members
|
||||
std::unique_ptr<libMesh::Mesh> m_; //!< pointer to the libMesh mesh instance
|
||||
std::vector<std::unique_ptr<libMesh::PointLocatorBase>> pl_; //!< per-thread point locators
|
||||
std::unique_ptr<libMesh::EquationSystems> equation_systems_; //!< pointer to the equation systems of the mesh
|
||||
unique_ptr<libMesh::Mesh> m_; //!< pointer to the libMesh mesh instance
|
||||
vector<unique_ptr<libMesh::PointLocatorBase>>
|
||||
pl_; //!< per-thread point locators
|
||||
unique_ptr<libMesh::EquationSystems>
|
||||
equation_systems_; //!< pointer to the equation systems of the mesh
|
||||
std::string eq_system_name_; //!< name of the equation system holding OpenMC results
|
||||
std::unordered_map<std::string, unsigned int> variable_map_; //!< mapping of variable names (tally scores) to libMesh variable numbers
|
||||
libMesh::BoundingBox bbox_; //!< bounding box of the mesh
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace mpi {
|
|||
extern bool master;
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
extern MPI_Datatype bank;
|
||||
extern MPI_Datatype source_site;
|
||||
extern MPI_Comm intracomm;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,15 @@
|
|||
#define OPENMC_MGXS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
#include "openmc/xsdata.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -42,13 +41,13 @@ class Mgxs {
|
|||
AngleDistributionType scatter_format; // flag for if this is legendre, histogram, or tabular
|
||||
int num_groups; // number of energy groups
|
||||
int num_delayed_groups; // number of delayed neutron groups
|
||||
std::vector<XsData> xs; // Cross section data
|
||||
vector<XsData> xs; // Cross section data
|
||||
// MGXS Incoming Flux Angular grid information
|
||||
bool is_isotropic; // used to skip search for angle indices if isotropic
|
||||
int n_pol;
|
||||
int n_azi;
|
||||
std::vector<double> polar;
|
||||
std::vector<double> azimuthal;
|
||||
vector<double> polar;
|
||||
vector<double> azimuthal;
|
||||
|
||||
//! \brief Initializes the Mgxs object metadata
|
||||
//!
|
||||
|
|
@ -62,10 +61,10 @@ class Mgxs {
|
|||
//! the incoming particle.
|
||||
//! @param in_polar Polar angle grid.
|
||||
//! @param in_azimuthal Azimuthal angle grid.
|
||||
void
|
||||
init(const std::string& in_name, double in_awr, const std::vector<double>& in_kTs,
|
||||
bool in_fissionable, AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const std::vector<double>& in_polar, const std::vector<double>& in_azimuthal);
|
||||
void init(const std::string& in_name, double in_awr,
|
||||
const vector<double>& in_kTs, bool in_fissionable,
|
||||
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const vector<double>& in_polar, const vector<double>& in_azimuthal);
|
||||
|
||||
//! \brief Initializes the Mgxs object metadata from the HDF5 file
|
||||
//!
|
||||
|
|
@ -74,9 +73,8 @@ class Mgxs {
|
|||
//! @param temps_to_read Resultant list of temperatures in the library
|
||||
//! to read which correspond to the requested temperatures.
|
||||
//! @param order_dim Resultant dimensionality of the scattering order.
|
||||
void
|
||||
metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
|
||||
std::vector<int>& temps_to_read, int& order_dim);
|
||||
void metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
|
||||
vector<int>& temps_to_read, int& order_dim);
|
||||
|
||||
//! \brief Performs the actual act of combining the microscopic data for a
|
||||
//! single temperature.
|
||||
|
|
@ -86,9 +84,8 @@ class Mgxs {
|
|||
//! @param micro_ts The temperature index of the microscopic objects that
|
||||
//! corresponds to the temperature of interest.
|
||||
//! @param this_t The temperature index of the macroscopic object.
|
||||
void
|
||||
combine(const std::vector<Mgxs*>& micros, const std::vector<double>& scalars,
|
||||
const std::vector<int>& micro_ts, int this_t);
|
||||
void combine(const vector<Mgxs*>& micros, const vector<double>& scalars,
|
||||
const vector<int>& micro_ts, int this_t);
|
||||
|
||||
//! \brief Checks to see if this and that are able to be combined
|
||||
//!
|
||||
|
|
@ -103,7 +100,7 @@ class Mgxs {
|
|||
std::string name; // name of dataset, e.g., UO2
|
||||
double awr; // atomic weight ratio
|
||||
bool fissionable; // Is this fissionable
|
||||
std::vector<CacheData> cache; // index and data cache
|
||||
vector<CacheData> cache; // index and data cache
|
||||
|
||||
Mgxs() = default;
|
||||
|
||||
|
|
@ -113,8 +110,8 @@ class Mgxs {
|
|||
//! @param temperature Temperatures to read.
|
||||
//! @param num_group number of energy groups
|
||||
//! @param num_delay number of delayed groups
|
||||
Mgxs(hid_t xs_id, const std::vector<double>& temperature,
|
||||
int num_group, int num_delay);
|
||||
Mgxs(hid_t xs_id, const vector<double>& temperature, int num_group,
|
||||
int num_delay);
|
||||
|
||||
//! \brief Constructor that initializes and populates all data to build a
|
||||
//! macroscopic cross section from microscopic cross sections.
|
||||
|
|
@ -125,9 +122,9 @@ class Mgxs {
|
|||
//! @param atom_densities Atom densities of those microscopic quantities.
|
||||
//! @param num_group number of energy groups
|
||||
//! @param num_delay number of delayed groups
|
||||
Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
|
||||
const std::vector<Mgxs*>& micros, const std::vector<double>& atom_densities,
|
||||
int num_group, int num_delay);
|
||||
Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
||||
const vector<Mgxs*>& micros, const vector<double>& atom_densities,
|
||||
int num_group, int num_delay);
|
||||
|
||||
//! \brief Provides a cross section value given certain parameters
|
||||
//!
|
||||
|
|
@ -187,7 +184,7 @@ class Mgxs {
|
|||
set_angle_index(Direction u);
|
||||
|
||||
//! \brief Provide const access to list of XsData held by this
|
||||
const std::vector<XsData>& get_xsdata() const { return xs; }
|
||||
const vector<XsData>& get_xsdata() const { return xs; }
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@
|
|||
#ifndef OPENMC_MGXS_INTERFACE_H
|
||||
#define OPENMC_MGXS_INTERFACE_H
|
||||
|
||||
#include "hdf5_interface.h"
|
||||
#include "mgxs.h"
|
||||
|
||||
#include <vector>
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/mgxs.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -23,20 +22,20 @@ public:
|
|||
// Construct from path to cross sections file, as well as a list
|
||||
// of XS to read and the corresponding temperatures for each XS
|
||||
MgxsInterface(const std::string& path_cross_sections,
|
||||
const std::vector<std::string> xs_to_read,
|
||||
const std::vector<std::vector<double>> xs_temps);
|
||||
const vector<std::string> xs_to_read,
|
||||
const vector<vector<double>> xs_temps);
|
||||
|
||||
// Does things to construct after the nuclides and temperatures to
|
||||
// read have been specified.
|
||||
void init();
|
||||
|
||||
// Set which nuclides and temperatures are to be read
|
||||
void set_nuclides_and_temperatures(std::vector<std::string> xs_to_read,
|
||||
std::vector<std::vector<double>> xs_temps);
|
||||
void set_nuclides_and_temperatures(
|
||||
vector<std::string> xs_to_read, vector<vector<double>> xs_temps);
|
||||
|
||||
// Add an Mgxs object to be managed
|
||||
void add_mgxs(hid_t file_id, const std::string& name,
|
||||
const std::vector<double>& temperature);
|
||||
void add_mgxs(
|
||||
hid_t file_id, const std::string& name, const vector<double>& temperature);
|
||||
|
||||
// Reads just the header of the cross sections file, to find
|
||||
// min & max energies as well as the available XS
|
||||
|
|
@ -46,20 +45,20 @@ public:
|
|||
void create_macro_xs();
|
||||
|
||||
// Get the kT values which are used in the OpenMC model
|
||||
std::vector<std::vector<double>> get_mat_kTs();
|
||||
vector<vector<double>> get_mat_kTs();
|
||||
|
||||
int num_energy_groups_;
|
||||
int num_delayed_groups_;
|
||||
std::vector<std::string> xs_names_; // available names in HDF5 file
|
||||
std::vector<std::string> xs_to_read_; // XS which appear in materials
|
||||
std::vector<std::vector<double>> xs_temps_to_read_; // temperatures used
|
||||
vector<std::string> xs_names_; // available names in HDF5 file
|
||||
vector<std::string> xs_to_read_; // XS which appear in materials
|
||||
vector<vector<double>> xs_temps_to_read_; // temperatures used
|
||||
std::string cross_sections_path_; // path to MGXS h5 file
|
||||
std::vector<Mgxs> nuclides_;
|
||||
std::vector<Mgxs> macro_xs_;
|
||||
std::vector<double> energy_bins_;
|
||||
std::vector<double> energy_bin_avg_;
|
||||
std::vector<double> rev_energy_bins_;
|
||||
std::vector<std::vector<double>> nuc_temps_; // all available temperatures
|
||||
vector<Mgxs> nuclides_;
|
||||
vector<Mgxs> macro_xs_;
|
||||
vector<double> energy_bins_;
|
||||
vector<double> energy_bin_avg_;
|
||||
vector<double> rev_energy_bins_;
|
||||
vector<vector<double>> nuc_temps_; // all available temperatures
|
||||
};
|
||||
|
||||
namespace data {
|
||||
|
|
|
|||
|
|
@ -4,21 +4,21 @@
|
|||
#ifndef OPENMC_NUCLIDE_H
|
||||
#define OPENMC_NUCLIDE_H
|
||||
|
||||
#include <array>
|
||||
#include <memory> // for unique_ptr
|
||||
#include <unordered_map>
|
||||
#include <utility> // for pair
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include <hdf5.h>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/reaction.h"
|
||||
#include "openmc/reaction_product.h"
|
||||
#include "openmc/urr.h"
|
||||
#include "openmc/vector.h"
|
||||
#include "openmc/wmp.h"
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -32,12 +32,12 @@ public:
|
|||
// Types, aliases
|
||||
using EmissionMode = ReactionProduct::EmissionMode;
|
||||
struct EnergyGrid {
|
||||
std::vector<int> grid_index;
|
||||
std::vector<double> energy;
|
||||
vector<int> grid_index;
|
||||
vector<double> energy;
|
||||
};
|
||||
|
||||
// Constructors/destructors
|
||||
Nuclide(hid_t group, const std::vector<double>& temperature);
|
||||
Nuclide(hid_t group, const vector<double>& temperature);
|
||||
~Nuclide();
|
||||
|
||||
//! Initialize logarithmic grid for energy searches
|
||||
|
|
@ -78,40 +78,41 @@ public:
|
|||
gsl::index index_; //!< Index in the nuclides array
|
||||
|
||||
// Temperature dependent cross section data
|
||||
std::vector<double> kTs_; //!< temperatures in eV (k*T)
|
||||
std::vector<EnergyGrid> grid_; //!< Energy grid at each temperature
|
||||
std::vector<xt::xtensor<double, 2>> xs_; //!< Cross sections at each temperature
|
||||
vector<double> kTs_; //!< temperatures in eV (k*T)
|
||||
vector<EnergyGrid> grid_; //!< Energy grid at each temperature
|
||||
vector<xt::xtensor<double, 2>> xs_; //!< Cross sections at each temperature
|
||||
|
||||
// Multipole data
|
||||
std::unique_ptr<WindowedMultipole> multipole_;
|
||||
unique_ptr<WindowedMultipole> multipole_;
|
||||
|
||||
// Fission data
|
||||
bool fissionable_ {false}; //!< Whether nuclide is fissionable
|
||||
bool has_partial_fission_ {false}; //!< has partial fission reactions?
|
||||
std::vector<Reaction*> fission_rx_; //!< Fission reactions
|
||||
vector<Reaction*> fission_rx_; //!< Fission reactions
|
||||
int n_precursor_ {0}; //!< Number of delayed neutron precursors
|
||||
std::unique_ptr<Function1D> total_nu_; //!< Total neutron yield
|
||||
std::unique_ptr<Function1D> fission_q_prompt_; //!< Prompt fission energy release
|
||||
std::unique_ptr<Function1D> fission_q_recov_; //!< Recoverable fission energy release
|
||||
std::unique_ptr<Function1D> prompt_photons_; //!< Prompt photon energy release
|
||||
std::unique_ptr<Function1D> delayed_photons_; //!< Delayed photon energy release
|
||||
std::unique_ptr<Function1D> fragments_; //!< Fission fragment energy release
|
||||
std::unique_ptr<Function1D> betas_; //!< Delayed beta energy release
|
||||
unique_ptr<Function1D> total_nu_; //!< Total neutron yield
|
||||
unique_ptr<Function1D> fission_q_prompt_; //!< Prompt fission energy release
|
||||
unique_ptr<Function1D>
|
||||
fission_q_recov_; //!< Recoverable fission energy release
|
||||
unique_ptr<Function1D> prompt_photons_; //!< Prompt photon energy release
|
||||
unique_ptr<Function1D> delayed_photons_; //!< Delayed photon energy release
|
||||
unique_ptr<Function1D> fragments_; //!< Fission fragment energy release
|
||||
unique_ptr<Function1D> betas_; //!< Delayed beta energy release
|
||||
|
||||
// Resonance scattering information
|
||||
bool resonant_ {false};
|
||||
std::vector<double> energy_0K_;
|
||||
std::vector<double> elastic_0K_;
|
||||
std::vector<double> xs_cdf_;
|
||||
vector<double> energy_0K_;
|
||||
vector<double> elastic_0K_;
|
||||
vector<double> xs_cdf_;
|
||||
|
||||
// Unresolved resonance range information
|
||||
bool urr_present_ {false};
|
||||
int urr_inelastic_ {C_NONE};
|
||||
std::vector<UrrData> urr_data_;
|
||||
vector<UrrData> urr_data_;
|
||||
|
||||
std::vector<std::unique_ptr<Reaction>> reactions_; //!< Reactions
|
||||
std::array<size_t, 902> reaction_index_; //!< Index of each reaction
|
||||
std::vector<int> index_inelastic_scatter_;
|
||||
vector<unique_ptr<Reaction>> reactions_; //!< Reactions
|
||||
array<size_t, 902> reaction_index_; //!< Index of each reaction
|
||||
vector<int> index_inelastic_scatter_;
|
||||
|
||||
private:
|
||||
void create_derived(const Function1D* prompt_photons, const Function1D* delayed_photons);
|
||||
|
|
@ -146,8 +147,8 @@ namespace data {
|
|||
|
||||
// Minimum/maximum transport energy for each particle type. Order corresponds to
|
||||
// that of the ParticleType enum
|
||||
extern std::array<double, 2> energy_min;
|
||||
extern std::array<double, 2> energy_max;
|
||||
extern array<double, 2> energy_min;
|
||||
extern array<double, 2> energy_max;
|
||||
|
||||
//! Minimum temperature in [K] that nuclide data is available at
|
||||
extern double temperature_min;
|
||||
|
|
@ -156,7 +157,7 @@ extern double temperature_min;
|
|||
extern double temperature_max;
|
||||
|
||||
extern std::unordered_map<std::string, int> nuclide_map;
|
||||
extern std::vector<std::unique_ptr<Nuclide>> nuclides;
|
||||
extern vector<unique_ptr<Nuclide>> nuclides;
|
||||
|
||||
} // namespace data
|
||||
|
||||
|
|
|
|||
|
|
@ -4,213 +4,37 @@
|
|||
//! \file particle.h
|
||||
//! \brief Particle type
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory> // for unique_ptr
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle_data.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/tallies/filter_match.h"
|
||||
|
||||
#ifdef DAGMC
|
||||
#include "DagMC.hpp"
|
||||
#endif
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Constants
|
||||
//==============================================================================
|
||||
|
||||
// Since cross section libraries come with different numbers of delayed groups
|
||||
// (e.g. ENDF/B-VII.1 has 6 and JEFF 3.1.1 has 8 delayed groups) and we don't
|
||||
// yet know what cross section library is being used when the tallies.xml file
|
||||
// is read in, we want to have an upper bound on the size of the array we
|
||||
// use to store the bins for delayed group tallies.
|
||||
constexpr int MAX_DELAYED_GROUPS {8};
|
||||
|
||||
constexpr double CACHE_INVALID {-1.0};
|
||||
|
||||
//==============================================================================
|
||||
// Class declarations
|
||||
//==============================================================================
|
||||
|
||||
// Forward declare the Surface class for use in function arguments.
|
||||
// Forward declare the Surface class for use in Particle::cross_vacuum_bc, etc.
|
||||
class Surface;
|
||||
|
||||
class LocalCoord {
|
||||
/*
|
||||
* The Particle class encompasses data and methods for transporting particles
|
||||
* through their lifecycle. Its base class defines particle data layout in
|
||||
* memory. A more detailed description of the rationale behind this approach
|
||||
* can be found in particle_data.h.
|
||||
*/
|
||||
|
||||
class Particle : public ParticleData {
|
||||
public:
|
||||
void rotate(const std::vector<double>& rotation);
|
||||
|
||||
//! clear data from a single coordinate level
|
||||
void reset();
|
||||
|
||||
Position r; //!< particle position
|
||||
Direction u; //!< particle direction
|
||||
int cell {-1};
|
||||
int universe {-1};
|
||||
int lattice {-1};
|
||||
int lattice_x {-1};
|
||||
int lattice_y {-1};
|
||||
int lattice_z {-1};
|
||||
bool rotated {false}; //!< Is the level rotated?
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Cached microscopic cross sections for a particular nuclide at the current
|
||||
//! energy
|
||||
//==============================================================================
|
||||
|
||||
struct NuclideMicroXS {
|
||||
// Microscopic cross sections in barns
|
||||
double total; //!< total cross section
|
||||
double absorption; //!< absorption (disappearance)
|
||||
double fission; //!< fission
|
||||
double nu_fission; //!< neutron production from fission
|
||||
|
||||
double elastic; //!< If sab_frac is not 1 or 0, then this value is
|
||||
//!< averaged over bound and non-bound nuclei
|
||||
double thermal; //!< Bound thermal elastic & inelastic scattering
|
||||
double thermal_elastic; //!< Bound thermal elastic scattering
|
||||
double photon_prod; //!< microscopic photon production xs
|
||||
|
||||
// Cross sections for depletion reactions (note that these are not stored in
|
||||
// macroscopic cache)
|
||||
double reaction[DEPLETION_RX.size()];
|
||||
|
||||
// Indicies and factors needed to compute cross sections from the data tables
|
||||
int index_grid; //!< Index on nuclide energy grid
|
||||
int index_temp; //!< Temperature index for nuclide
|
||||
double interp_factor; //!< Interpolation factor on nuc. energy grid
|
||||
int index_sab {-1}; //!< Index in sab_tables
|
||||
int index_temp_sab; //!< Temperature index for sab_tables
|
||||
double sab_frac; //!< Fraction of atoms affected by S(a,b)
|
||||
bool use_ptable; //!< In URR range with probability tables?
|
||||
|
||||
// Energy and temperature last used to evaluate these cross sections. If
|
||||
// these values have changed, then the cross sections must be re-evaluated.
|
||||
double last_E {0.0}; //!< Last evaluated energy
|
||||
double last_sqrtkT {0.0}; //!< Last temperature in sqrt(Boltzmann constant
|
||||
//!< * temperature (eV))
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Cached microscopic photon cross sections for a particular element at the
|
||||
//! current energy
|
||||
//==============================================================================
|
||||
|
||||
struct ElementMicroXS {
|
||||
int index_grid; //!< index on element energy grid
|
||||
double last_E {0.0}; //!< last evaluated energy in [eV]
|
||||
double interp_factor; //!< interpolation factor on energy grid
|
||||
double total; //!< microscopic total photon xs
|
||||
double coherent; //!< microscopic coherent xs
|
||||
double incoherent; //!< microscopic incoherent xs
|
||||
double photoelectric; //!< microscopic photoelectric xs
|
||||
double pair_production; //!< microscopic pair production xs
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// MACROXS contains cached macroscopic cross sections for the material a
|
||||
// particle is traveling through
|
||||
//==============================================================================
|
||||
|
||||
struct MacroXS {
|
||||
double total; //!< macroscopic total xs
|
||||
double absorption; //!< macroscopic absorption xs
|
||||
double fission; //!< macroscopic fission xs
|
||||
double nu_fission; //!< macroscopic production xs
|
||||
double photon_prod; //!< macroscopic photon production xs
|
||||
|
||||
// Photon cross sections
|
||||
double coherent; //!< macroscopic coherent xs
|
||||
double incoherent; //!< macroscopic incoherent xs
|
||||
double photoelectric; //!< macroscopic photoelectric xs
|
||||
double pair_production; //!< macroscopic pair production xs
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Information about nearest boundary crossing
|
||||
//==============================================================================
|
||||
|
||||
struct BoundaryInfo {
|
||||
double distance {INFINITY}; //!< distance to nearest boundary
|
||||
int surface_index {0}; //!< if boundary is surface, index in surfaces vector
|
||||
int coord_level; //!< coordinate level after crossing boundary
|
||||
std::array<int, 3> lattice_translation {}; //!< which way lattice indices will change
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
//! State of a particle being transported through geometry
|
||||
//============================================================================
|
||||
|
||||
class Particle {
|
||||
public:
|
||||
//==========================================================================
|
||||
// Aliases and type definitions
|
||||
|
||||
//! Particle types
|
||||
enum class Type {
|
||||
neutron, photon, electron, positron
|
||||
};
|
||||
|
||||
//! Saved ("banked") state of a particle
|
||||
//! NOTE: This structure's MPI type is built in initialize_mpi() of
|
||||
//! initialize.cpp. Any changes made to the struct here must also be
|
||||
//! made when building the Bank MPI type in initialize_mpi().
|
||||
//! NOTE: This structure is also used on the python side, and is defined
|
||||
//! in lib/core.py. Changes made to the type here must also be made to the
|
||||
//! python defintion.
|
||||
struct Bank {
|
||||
Position r;
|
||||
Direction u;
|
||||
double E;
|
||||
double wgt;
|
||||
int delayed_group;
|
||||
int surf_id;
|
||||
Type particle;
|
||||
int64_t parent_id;
|
||||
int64_t progeny_id;
|
||||
};
|
||||
|
||||
//! Saved ("banked") state of a particle, for nu-fission tallying
|
||||
struct NuBank {
|
||||
double E; //!< particle energy
|
||||
double wgt; //!< particle weight
|
||||
int delayed_group; //!< particle delayed group
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
// Constructors
|
||||
|
||||
Particle();
|
||||
|
||||
//==========================================================================
|
||||
// Methods and accessors
|
||||
|
||||
// Accessors for position in global coordinates
|
||||
Position& r() { return coord_[0].r; }
|
||||
const Position& r() const { return coord_[0].r; }
|
||||
|
||||
// Accessors for position in local coordinates
|
||||
Position& r_local() { return coord_[n_coord_ - 1].r; }
|
||||
const Position& r_local() const { return coord_[n_coord_ - 1].r; }
|
||||
|
||||
// Accessors for direction in global coordinates
|
||||
Direction& u() { return coord_[0].u; }
|
||||
const Direction& u() const { return coord_[0].u; }
|
||||
|
||||
// Accessors for direction in local coordinates
|
||||
Direction& u_local() { return coord_[n_coord_ - 1].u; }
|
||||
const Direction& u_local() const { return coord_[n_coord_ - 1].u; }
|
||||
|
||||
//! resets all coordinate levels for the particle
|
||||
void clear();
|
||||
Particle() = default;
|
||||
|
||||
//! create a secondary particle
|
||||
//
|
||||
|
|
@ -220,7 +44,7 @@ public:
|
|||
//! \param u Direction of the secondary particle
|
||||
//! \param E Energy of the secondary particle in [eV]
|
||||
//! \param type Particle type
|
||||
void create_secondary(double wgt, Direction u, double E, Type type);
|
||||
void create_secondary(double wgt, Direction u, double E, ParticleType type);
|
||||
|
||||
//! initialize from a source site
|
||||
//
|
||||
|
|
@ -228,7 +52,7 @@ public:
|
|||
//! site may have been produced from an external source, from fission, or
|
||||
//! simply as a secondary particle.
|
||||
//! \param src Source site data
|
||||
void from_source(const Bank* src);
|
||||
void from_source(const SourceSite* src);
|
||||
|
||||
// Coarse-grained particle events
|
||||
void event_calculate_xs();
|
||||
|
|
@ -277,128 +101,15 @@ public:
|
|||
|
||||
//! create a particle restart HDF5 file
|
||||
void write_restart() const;
|
||||
|
||||
//! Gets the pointer to the particle's current PRN seed
|
||||
uint64_t* current_seed() {return seeds_ + stream_;}
|
||||
const uint64_t* current_seed() const {return seeds_ + stream_;}
|
||||
|
||||
//==========================================================================
|
||||
// Data members
|
||||
|
||||
// Cross section caches
|
||||
std::vector<NuclideMicroXS> neutron_xs_; //!< Microscopic neutron cross sections
|
||||
std::vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
|
||||
MacroXS macro_xs_; //!< Macroscopic cross sections
|
||||
|
||||
int64_t id_; //!< Unique ID
|
||||
Type type_ {Type::neutron}; //!< Particle type (n, p, e, etc.)
|
||||
|
||||
int n_coord_ {1}; //!< number of current coordinate levels
|
||||
int cell_instance_; //!< offset for distributed properties
|
||||
std::vector<LocalCoord> coord_; //!< coordinates for all levels
|
||||
|
||||
// Particle coordinates before crossing a surface
|
||||
int n_coord_last_ {1}; //!< number of current coordinates
|
||||
std::vector<int> cell_last_; //!< coordinates for all levels
|
||||
|
||||
// Energy data
|
||||
double E_; //!< post-collision energy in eV
|
||||
double E_last_; //!< pre-collision energy in eV
|
||||
int g_ {0}; //!< post-collision energy group (MG only)
|
||||
int g_last_; //!< pre-collision energy group (MG only)
|
||||
|
||||
// Other physical data
|
||||
double wgt_ {1.0}; //!< particle weight
|
||||
double mu_; //!< angle of scatter
|
||||
bool alive_ {true}; //!< is particle alive?
|
||||
|
||||
// Other physical data
|
||||
Position r_last_current_; //!< coordinates of the last collision or
|
||||
//!< reflective/periodic surface crossing for
|
||||
//!< current tallies
|
||||
Position r_last_; //!< previous coordinates
|
||||
Direction u_last_; //!< previous direction coordinates
|
||||
double wgt_last_ {1.0}; //!< pre-collision particle weight
|
||||
double wgt_absorb_ {0.0}; //!< weight absorbed for survival biasing
|
||||
|
||||
// What event took place
|
||||
bool fission_ {false}; //!< did particle cause implicit fission
|
||||
TallyEvent event_; //!< scatter, absorption
|
||||
int event_nuclide_; //!< index in nuclides array
|
||||
int event_mt_; //!< reaction MT
|
||||
int delayed_group_ {0}; //!< delayed group
|
||||
|
||||
// Post-collision physical data
|
||||
int n_bank_ {0}; //!< number of fission sites banked
|
||||
int n_bank_second_ {0}; //!< number of secondary particles banked
|
||||
double wgt_bank_ {0.0}; //!< weight of fission sites banked
|
||||
int n_delayed_bank_[MAX_DELAYED_GROUPS]; //!< number of delayed fission
|
||||
//!< sites banked
|
||||
|
||||
// Indices for various arrays
|
||||
int surface_ {0}; //!< index for surface particle is on
|
||||
int cell_born_ {-1}; //!< index for cell particle was born in
|
||||
int material_ {-1}; //!< index for current material
|
||||
int material_last_ {-1}; //!< index for last material
|
||||
|
||||
// Boundary information
|
||||
BoundaryInfo boundary_;
|
||||
|
||||
// Temperature of current cell
|
||||
double sqrtkT_ {-1.0}; //!< sqrt(k_Boltzmann * temperature) in eV
|
||||
double sqrtkT_last_ {0.0}; //!< last temperature
|
||||
|
||||
// Statistical data
|
||||
int n_collision_ {0}; //!< number of collisions
|
||||
|
||||
// Track output
|
||||
bool write_track_ {false};
|
||||
|
||||
// Current PRNG state
|
||||
uint64_t seeds_[N_STREAMS]; // current seeds
|
||||
int stream_; // current RNG stream
|
||||
|
||||
// Secondary particle bank
|
||||
std::vector<Particle::Bank> secondary_bank_;
|
||||
|
||||
int64_t current_work_; // current work index
|
||||
|
||||
std::vector<double> flux_derivs_; // for derivatives for this particle
|
||||
|
||||
std::vector<FilterMatch> filter_matches_; // tally filter matches
|
||||
|
||||
std::vector<std::vector<Position>> tracks_; // tracks for outputting to file
|
||||
|
||||
std::vector<NuBank> nu_bank_; // bank of most recently fissioned particles
|
||||
|
||||
// Global tally accumulators
|
||||
double keff_tally_absorption_ {0.0};
|
||||
double keff_tally_collision_ {0.0};
|
||||
double keff_tally_tracklength_ {0.0};
|
||||
double keff_tally_leakage_ {0.0};
|
||||
|
||||
bool trace_ {false}; //!< flag to show debug information
|
||||
|
||||
double collision_distance_; // distance to particle's next closest collision
|
||||
|
||||
int n_event_ {0}; // number of events executed in this particle's history
|
||||
|
||||
// DagMC state variables
|
||||
#ifdef DAGMC
|
||||
moab::DagMC::RayHistory history_;
|
||||
Direction last_dir_;
|
||||
#endif
|
||||
|
||||
int64_t n_progeny_ {0}; // Number of progeny produced by this particle
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
//! Functions
|
||||
//============================================================================
|
||||
|
||||
std::string particle_type_to_str(Particle::Type type);
|
||||
std::string particle_type_to_str(ParticleType type);
|
||||
|
||||
Particle::Type str_to_particle_type(std::string str);
|
||||
ParticleType str_to_particle_type(std::string str);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
481
include/openmc/particle_data.h
Normal file
481
include/openmc/particle_data.h
Normal file
|
|
@ -0,0 +1,481 @@
|
|||
#ifndef OPENMC_PARTICLE_DATA_H
|
||||
#define OPENMC_PARTICLE_DATA_H
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/tallies/filter_match.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#ifdef DAGMC
|
||||
#include "DagMC.hpp"
|
||||
#endif
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Constants
|
||||
//==============================================================================
|
||||
|
||||
// Since cross section libraries come with different numbers of delayed groups
|
||||
// (e.g. ENDF/B-VII.1 has 6 and JEFF 3.1.1 has 8 delayed groups) and we don't
|
||||
// yet know what cross section library is being used when the tallies.xml file
|
||||
// is read in, we want to have an upper bound on the size of the array we
|
||||
// use to store the bins for delayed group tallies.
|
||||
constexpr int MAX_DELAYED_GROUPS {8};
|
||||
|
||||
constexpr double CACHE_INVALID {-1.0};
|
||||
|
||||
//==========================================================================
|
||||
// Aliases and type definitions
|
||||
|
||||
//! Particle types
|
||||
enum class ParticleType { neutron, photon, electron, positron };
|
||||
|
||||
//! Saved ("banked") state of a particle
|
||||
//! NOTE: This structure's MPI type is built in initialize_mpi() of
|
||||
//! initialize.cpp. Any changes made to the struct here must also be
|
||||
//! made when building the Bank MPI type in initialize_mpi().
|
||||
//! NOTE: This structure is also used on the python side, and is defined
|
||||
//! in lib/core.py. Changes made to the type here must also be made to the
|
||||
//! python defintion.
|
||||
struct SourceSite {
|
||||
Position r;
|
||||
Direction u;
|
||||
double E;
|
||||
double wgt;
|
||||
int delayed_group;
|
||||
int surf_id;
|
||||
ParticleType particle;
|
||||
int64_t parent_id;
|
||||
int64_t progeny_id;
|
||||
};
|
||||
|
||||
//! Saved ("banked") state of a particle, for nu-fission tallying
|
||||
struct NuBank {
|
||||
double E; //!< particle energy
|
||||
double wgt; //!< particle weight
|
||||
int delayed_group; //!< particle delayed group
|
||||
};
|
||||
|
||||
class LocalCoord {
|
||||
public:
|
||||
void rotate(const vector<double>& rotation);
|
||||
|
||||
//! clear data from a single coordinate level
|
||||
void reset();
|
||||
|
||||
Position r; //!< particle position
|
||||
Direction u; //!< particle direction
|
||||
int cell {-1};
|
||||
int universe {-1};
|
||||
int lattice {-1};
|
||||
array<int, 3> lattice_i {{-1, -1, -1}};
|
||||
bool rotated {false}; //!< Is the level rotated?
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Cached microscopic cross sections for a particular nuclide at the current
|
||||
//! energy
|
||||
//==============================================================================
|
||||
|
||||
struct NuclideMicroXS {
|
||||
// Microscopic cross sections in barns
|
||||
double total; //!< total cross section
|
||||
double absorption; //!< absorption (disappearance)
|
||||
double fission; //!< fission
|
||||
double nu_fission; //!< neutron production from fission
|
||||
|
||||
double elastic; //!< If sab_frac is not 1 or 0, then this value is
|
||||
//!< averaged over bound and non-bound nuclei
|
||||
double thermal; //!< Bound thermal elastic & inelastic scattering
|
||||
double thermal_elastic; //!< Bound thermal elastic scattering
|
||||
double photon_prod; //!< microscopic photon production xs
|
||||
|
||||
// Cross sections for depletion reactions (note that these are not stored in
|
||||
// macroscopic cache)
|
||||
double reaction[DEPLETION_RX.size()];
|
||||
|
||||
// Indicies and factors needed to compute cross sections from the data tables
|
||||
int index_grid; //!< Index on nuclide energy grid
|
||||
int index_temp; //!< Temperature index for nuclide
|
||||
double interp_factor; //!< Interpolation factor on nuc. energy grid
|
||||
int index_sab {-1}; //!< Index in sab_tables
|
||||
int index_temp_sab; //!< Temperature index for sab_tables
|
||||
double sab_frac; //!< Fraction of atoms affected by S(a,b)
|
||||
bool use_ptable; //!< In URR range with probability tables?
|
||||
|
||||
// Energy and temperature last used to evaluate these cross sections. If
|
||||
// these values have changed, then the cross sections must be re-evaluated.
|
||||
double last_E {0.0}; //!< Last evaluated energy
|
||||
double last_sqrtkT {0.0}; //!< Last temperature in sqrt(Boltzmann constant
|
||||
//!< * temperature (eV))
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
//! Cached microscopic photon cross sections for a particular element at the
|
||||
//! current energy
|
||||
//==============================================================================
|
||||
|
||||
struct ElementMicroXS {
|
||||
int index_grid; //!< index on element energy grid
|
||||
double last_E {0.0}; //!< last evaluated energy in [eV]
|
||||
double interp_factor; //!< interpolation factor on energy grid
|
||||
double total; //!< microscopic total photon xs
|
||||
double coherent; //!< microscopic coherent xs
|
||||
double incoherent; //!< microscopic incoherent xs
|
||||
double photoelectric; //!< microscopic photoelectric xs
|
||||
double pair_production; //!< microscopic pair production xs
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// MacroXS contains cached macroscopic cross sections for the material a
|
||||
// particle is traveling through
|
||||
//==============================================================================
|
||||
|
||||
struct MacroXS {
|
||||
double total; //!< macroscopic total xs
|
||||
double absorption; //!< macroscopic absorption xs
|
||||
double fission; //!< macroscopic fission xs
|
||||
double nu_fission; //!< macroscopic production xs
|
||||
double photon_prod; //!< macroscopic photon production xs
|
||||
|
||||
// Photon cross sections
|
||||
double coherent; //!< macroscopic coherent xs
|
||||
double incoherent; //!< macroscopic incoherent xs
|
||||
double photoelectric; //!< macroscopic photoelectric xs
|
||||
double pair_production; //!< macroscopic pair production xs
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Information about nearest boundary crossing
|
||||
//==============================================================================
|
||||
|
||||
struct BoundaryInfo {
|
||||
double distance {INFINITY}; //!< distance to nearest boundary
|
||||
int surface_index {0}; //!< if boundary is surface, index in surfaces vector
|
||||
int coord_level; //!< coordinate level after crossing boundary
|
||||
array<int, 3>
|
||||
lattice_translation {}; //!< which way lattice indices will change
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
//! Defines how particle data is laid out in memory
|
||||
//============================================================================
|
||||
|
||||
/*
|
||||
* This class was added in order to separate the layout and access of particle
|
||||
* data from particle physics operations during a development effort to get
|
||||
* OpenMC running on GPUs. In the event-based Monte Carlo method, one creates
|
||||
* an array of particles on which actions like cross section lookup and surface
|
||||
* crossing are done en masse, which works best on vector computers of yore and
|
||||
* modern GPUs. It has been shown in the below publication [1] that arranging
|
||||
* particle data into a structure of arrays rather than an array of structures
|
||||
* enhances performance on GPUs. For instance, rather than having an
|
||||
* std::vector<Particle> where consecutive particle energies would be separated
|
||||
* by about 400 bytes, one would create a structure which has a single
|
||||
* std::vector<double> of energies. The motivation here is that more coalesced
|
||||
* memory accesses occur, in the parlance of GPU programming.
|
||||
*
|
||||
* So, this class enables switching between the array-of-structures and
|
||||
* structure- of-array data layout at compile time. In GPU branches of the
|
||||
* code, our Particle class inherits from a class that provides an array of
|
||||
* particle energies, and can access them using the E() method (defined below).
|
||||
* In the CPU code, we inherit from this class which gives the conventional
|
||||
* layout of particle data, useful for history-based tracking.
|
||||
*
|
||||
* As a result, we always use the E(), r_last(), etc. methods to access
|
||||
* particle data in order to keep a unified interface between
|
||||
* structure-of-array and array-of-structure code on either CPU or GPU code
|
||||
* while sharing the same physics code on each codebase.
|
||||
*
|
||||
* [1] Hamilton, Steven P., Stuart R. Slattery, and Thomas M. Evans.
|
||||
* “Multigroup Monte Carlo on GPUs: Comparison of History- and Event-Based
|
||||
* Algorithms.” Annals of Nuclear Energy 113 (March 2018): 506–18.
|
||||
* https://doi.org/10.1016/j.anucene.2017.11.032.
|
||||
*/
|
||||
class ParticleData {
|
||||
|
||||
public:
|
||||
ParticleData();
|
||||
|
||||
private:
|
||||
//==========================================================================
|
||||
// Data members (accessor methods are below)
|
||||
|
||||
// Cross section caches
|
||||
vector<NuclideMicroXS> neutron_xs_; //!< Microscopic neutron cross sections
|
||||
vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
|
||||
MacroXS macro_xs_; //!< Macroscopic cross sections
|
||||
|
||||
int64_t id_; //!< Unique ID
|
||||
ParticleType type_ {ParticleType::neutron}; //!< Particle type (n, p, e, etc.)
|
||||
|
||||
int n_coord_ {1}; //!< number of current coordinate levels
|
||||
int cell_instance_; //!< offset for distributed properties
|
||||
vector<LocalCoord> coord_; //!< coordinates for all levels
|
||||
|
||||
// Particle coordinates before crossing a surface
|
||||
int n_coord_last_ {1}; //!< number of current coordinates
|
||||
vector<int> cell_last_; //!< coordinates for all levels
|
||||
|
||||
// Energy data
|
||||
double E_; //!< post-collision energy in eV
|
||||
double E_last_; //!< pre-collision energy in eV
|
||||
int g_ {0}; //!< post-collision energy group (MG only)
|
||||
int g_last_; //!< pre-collision energy group (MG only)
|
||||
|
||||
// Other physical data
|
||||
double wgt_ {1.0}; //!< particle weight
|
||||
double mu_; //!< angle of scatter
|
||||
bool alive_ {true}; //!< is particle alive?
|
||||
|
||||
// Other physical data
|
||||
Position r_last_current_; //!< coordinates of the last collision or
|
||||
//!< reflective/periodic surface crossing for
|
||||
//!< current tallies
|
||||
Position r_last_; //!< previous coordinates
|
||||
Direction u_last_; //!< previous direction coordinates
|
||||
double wgt_last_ {1.0}; //!< pre-collision particle weight
|
||||
double wgt_absorb_ {0.0}; //!< weight absorbed for survival biasing
|
||||
|
||||
// What event took place
|
||||
bool fission_ {false}; //!< did particle cause implicit fission
|
||||
TallyEvent event_; //!< scatter, absorption
|
||||
int event_nuclide_; //!< index in nuclides array
|
||||
int event_mt_; //!< reaction MT
|
||||
int delayed_group_ {0}; //!< delayed group
|
||||
|
||||
// Post-collision physical data
|
||||
int n_bank_ {0}; //!< number of fission sites banked
|
||||
int n_bank_second_ {0}; //!< number of secondary particles banked
|
||||
double wgt_bank_ {0.0}; //!< weight of fission sites banked
|
||||
int n_delayed_bank_[MAX_DELAYED_GROUPS]; //!< number of delayed fission
|
||||
//!< sites banked
|
||||
|
||||
// Indices for various arrays
|
||||
int surface_ {0}; //!< index for surface particle is on
|
||||
int cell_born_ {-1}; //!< index for cell particle was born in
|
||||
int material_ {-1}; //!< index for current material
|
||||
int material_last_ {-1}; //!< index for last material
|
||||
|
||||
// Boundary information
|
||||
BoundaryInfo boundary_;
|
||||
|
||||
// Temperature of current cell
|
||||
double sqrtkT_ {-1.0}; //!< sqrt(k_Boltzmann * temperature) in eV
|
||||
double sqrtkT_last_ {0.0}; //!< last temperature
|
||||
|
||||
// Statistical data
|
||||
int n_collision_ {0}; //!< number of collisions
|
||||
|
||||
// Track output
|
||||
bool write_track_ {false};
|
||||
|
||||
// Current PRNG state
|
||||
uint64_t seeds_[N_STREAMS]; // current seeds
|
||||
int stream_; // current RNG stream
|
||||
|
||||
// Secondary particle bank
|
||||
vector<SourceSite> secondary_bank_;
|
||||
|
||||
int64_t current_work_; // current work index
|
||||
|
||||
vector<double> flux_derivs_; // for derivatives for this particle
|
||||
|
||||
vector<FilterMatch> filter_matches_; // tally filter matches
|
||||
|
||||
vector<vector<Position>> tracks_; // tracks for outputting to file
|
||||
|
||||
vector<NuBank> nu_bank_; // bank of most recently fissioned particles
|
||||
|
||||
// Global tally accumulators
|
||||
double keff_tally_absorption_ {0.0};
|
||||
double keff_tally_collision_ {0.0};
|
||||
double keff_tally_tracklength_ {0.0};
|
||||
double keff_tally_leakage_ {0.0};
|
||||
|
||||
bool trace_ {false}; //!< flag to show debug information
|
||||
|
||||
double collision_distance_; // distance to particle's next closest collision
|
||||
|
||||
int n_event_ {0}; // number of events executed in this particle's history
|
||||
|
||||
// DagMC state variables
|
||||
#ifdef DAGMC
|
||||
moab::DagMC::RayHistory history_;
|
||||
Direction last_dir_;
|
||||
#endif
|
||||
|
||||
int64_t n_progeny_ {0}; // Number of progeny produced by this particle
|
||||
|
||||
public:
|
||||
//==========================================================================
|
||||
// Methods and accessors
|
||||
|
||||
NuclideMicroXS& neutron_xs(int i) { return neutron_xs_[i]; }
|
||||
const NuclideMicroXS& neutron_xs(int i) const { return neutron_xs_[i]; }
|
||||
ElementMicroXS& photon_xs(int i) { return photon_xs_[i]; }
|
||||
MacroXS& macro_xs() { return macro_xs_; }
|
||||
const MacroXS& macro_xs() const { return macro_xs_; }
|
||||
|
||||
int64_t& id() { return id_; }
|
||||
const int64_t& id() const { return id_; }
|
||||
ParticleType& type() { return type_; }
|
||||
const ParticleType& type() const { return type_; }
|
||||
|
||||
int& n_coord() { return n_coord_; }
|
||||
const int& n_coord() const { return n_coord_; }
|
||||
int& cell_instance() { return cell_instance_; }
|
||||
const int& cell_instance() const { return cell_instance_; }
|
||||
LocalCoord& coord(int i) { return coord_[i]; }
|
||||
const LocalCoord& coord(int i) const { return coord_[i]; }
|
||||
|
||||
int& n_coord_last() { return n_coord_last_; }
|
||||
const int& n_coord_last() const { return n_coord_last_; }
|
||||
int& cell_last(int i) { return cell_last_[i]; }
|
||||
const int& cell_last(int i) const { return cell_last_[i]; }
|
||||
|
||||
double& E() { return E_; }
|
||||
const double& E() const { return E_; }
|
||||
double& E_last() { return E_last_; }
|
||||
const double& E_last() const { return E_last_; }
|
||||
int& g() { return g_; }
|
||||
const int& g() const { return g_; }
|
||||
int& g_last() { return g_last_; }
|
||||
const int& g_last() const { return g_last_; }
|
||||
|
||||
double& wgt() { return wgt_; }
|
||||
double& mu() { return mu_; }
|
||||
const double& mu() const { return mu_; }
|
||||
bool& alive() { return alive_; }
|
||||
|
||||
Position& r_last_current() { return r_last_current_; }
|
||||
const Position& r_last_current() const { return r_last_current_; }
|
||||
Position& r_last() { return r_last_; }
|
||||
const Position& r_last() const { return r_last_; }
|
||||
Position& u_last() { return u_last_; }
|
||||
const Position& u_last() const { return u_last_; }
|
||||
double& wgt_last() { return wgt_last_; }
|
||||
const double& wgt_last() const { return wgt_last_; }
|
||||
double& wgt_absorb() { return wgt_absorb_; }
|
||||
const double& wgt_absorb() const { return wgt_absorb_; }
|
||||
|
||||
bool& fission() { return fission_; }
|
||||
TallyEvent& event() { return event_; }
|
||||
const TallyEvent& event() const { return event_; }
|
||||
int& event_nuclide() { return event_nuclide_; }
|
||||
const int& event_nuclide() const { return event_nuclide_; }
|
||||
int& event_mt() { return event_mt_; }
|
||||
int& delayed_group() { return delayed_group_; }
|
||||
|
||||
int& n_bank() { return n_bank_; }
|
||||
int& n_bank_second() { return n_bank_second_; }
|
||||
double& wgt_bank() { return wgt_bank_; }
|
||||
int* n_delayed_bank() { return n_delayed_bank_; }
|
||||
int& n_delayed_bank(int i) { return n_delayed_bank_[i]; }
|
||||
|
||||
int& surface() { return surface_; }
|
||||
const int& surface() const { return surface_; }
|
||||
int& cell_born() { return cell_born_; }
|
||||
const int& cell_born() const { return cell_born_; }
|
||||
int& material() { return material_; }
|
||||
const int& material() const { return material_; }
|
||||
int& material_last() { return material_last_; }
|
||||
|
||||
BoundaryInfo& boundary() { return boundary_; }
|
||||
|
||||
double& sqrtkT() { return sqrtkT_; }
|
||||
const double& sqrtkT() const { return sqrtkT_; }
|
||||
double& sqrtkT_last() { return sqrtkT_last_; }
|
||||
|
||||
int& n_collision() { return n_collision_; }
|
||||
const int& n_collision() const { return n_collision_; }
|
||||
|
||||
bool& write_track() { return write_track_; }
|
||||
uint64_t& seeds(int i) { return seeds_[i]; }
|
||||
uint64_t* seeds() { return seeds_; }
|
||||
int& stream() { return stream_; }
|
||||
|
||||
SourceSite& secondary_bank(int i) { return secondary_bank_[i]; }
|
||||
decltype(secondary_bank_)& secondary_bank() { return secondary_bank_; }
|
||||
int64_t& current_work() { return current_work_; }
|
||||
const int64_t& current_work() const { return current_work_; }
|
||||
double& flux_derivs(int i) { return flux_derivs_[i]; }
|
||||
const double& flux_derivs(int i) const { return flux_derivs_[i]; }
|
||||
decltype(filter_matches_)& filter_matches() { return filter_matches_; }
|
||||
FilterMatch& filter_matches(int i) { return filter_matches_[i]; }
|
||||
decltype(tracks_)& tracks() { return tracks_; }
|
||||
decltype(nu_bank_)& nu_bank() { return nu_bank_; }
|
||||
NuBank& nu_bank(int i) { return nu_bank_[i]; }
|
||||
|
||||
double& keff_tally_absorption() { return keff_tally_absorption_; }
|
||||
double& keff_tally_collision() { return keff_tally_collision_; }
|
||||
double& keff_tally_tracklength() { return keff_tally_tracklength_; }
|
||||
double& keff_tally_leakage() { return keff_tally_leakage_; }
|
||||
|
||||
bool& trace() { return trace_; }
|
||||
double& collision_distance() { return collision_distance_; }
|
||||
int& n_event() { return n_event_; }
|
||||
|
||||
#ifdef DAGMC
|
||||
moab::DagMC::RayHistory& history() { return history_; }
|
||||
Direction& last_dir() { return last_dir_; }
|
||||
#endif
|
||||
|
||||
int64_t& n_progeny() { return n_progeny_; }
|
||||
|
||||
// Accessors for position in global coordinates
|
||||
Position& r() { return coord_[0].r; }
|
||||
const Position& r() const { return coord_[0].r; }
|
||||
|
||||
// Accessors for position in local coordinates
|
||||
Position& r_local() { return coord_[n_coord_ - 1].r; }
|
||||
const Position& r_local() const { return coord_[n_coord_ - 1].r; }
|
||||
|
||||
// Accessors for direction in global coordinates
|
||||
Direction& u() { return coord_[0].u; }
|
||||
const Direction& u() const { return coord_[0].u; }
|
||||
|
||||
// Accessors for direction in local coordinates
|
||||
Direction& u_local() { return coord_[n_coord_ - 1].u; }
|
||||
const Direction& u_local() const { return coord_[n_coord_ - 1].u; }
|
||||
|
||||
//! Gets the pointer to the particle's current PRN seed
|
||||
uint64_t* current_seed() { return seeds_ + stream_; }
|
||||
const uint64_t* current_seed() const { return seeds_ + stream_; }
|
||||
|
||||
//! Force recalculation of neutron xs by setting last energy to zero
|
||||
void invalidate_neutron_xs()
|
||||
{
|
||||
for (auto& micro : neutron_xs_)
|
||||
micro.last_E = 0.0;
|
||||
}
|
||||
|
||||
//! resets all coordinate levels for the particle
|
||||
void clear()
|
||||
{
|
||||
for (auto& level : coord_)
|
||||
level.reset();
|
||||
n_coord_ = 1;
|
||||
}
|
||||
|
||||
void zero_delayed_bank()
|
||||
{
|
||||
for (int& n : n_delayed_bank_) {
|
||||
n = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void zero_flux_derivs()
|
||||
{
|
||||
for (double& d : flux_derivs_) {
|
||||
d = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_PARTICLE_DATA_H
|
||||
|
|
@ -2,17 +2,17 @@
|
|||
#define OPENMC_PHOTON_H
|
||||
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include <hdf5.h>
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility> // for pair
|
||||
#include <vector>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ public:
|
|||
// Photoionization and atomic relaxation data
|
||||
std::unordered_map<int, int> shell_map_; //!< Given a shell designator, e.g. 3, this
|
||||
//!< dictionary gives an index in shells_
|
||||
std::vector<ElectronSubshell> shells_;
|
||||
vector<ElectronSubshell> shells_;
|
||||
|
||||
// Compton profile data
|
||||
xt::xtensor<double, 2> profile_pdf_;
|
||||
|
|
@ -121,7 +121,7 @@ extern xt::xtensor<double, 1> compton_profile_pz; //! Compton profile momentum g
|
|||
|
||||
//! Photon interaction data for each element
|
||||
extern std::unordered_map<std::string, int> element_map;
|
||||
extern std::vector<std::unique_ptr<PhotonInteraction>> elements;
|
||||
extern vector<unique_ptr<PhotonInteraction>> elements;
|
||||
|
||||
} // namespace data
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/reaction.h"
|
||||
|
||||
#include <vector>
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -81,7 +80,7 @@ Direction sample_cxs_target_velocity(double awr, double E, Direction u, double k
|
|||
uint64_t* seed);
|
||||
|
||||
void sample_fission_neutron(int i_nuclide, const Reaction& rx, double E_in,
|
||||
Particle::Bank* site, uint64_t* seed);
|
||||
SourceSite* site, uint64_t* seed);
|
||||
|
||||
//! handles all reactions with a single secondary neutron (other than fission),
|
||||
//! i.e. level scattering, (n,np), (n,na), etc.
|
||||
|
|
|
|||
|
|
@ -5,10 +5,8 @@
|
|||
#define OPENMC_PHYSICS_MG_H
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/nuclide.h"
|
||||
|
||||
#include <vector>
|
||||
#include "openmc/particle.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Plot;
|
|||
namespace model {
|
||||
|
||||
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
|
||||
extern std::vector<Plot> plots; //!< Plot instance container
|
||||
extern vector<Plot> plots; //!< Plot instance container
|
||||
|
||||
extern uint64_t plotter_prn_seeds[N_STREAMS]; // Random number seeds used for plotter
|
||||
extern int plotter_stream; // Stream index used by the plotter
|
||||
|
|
@ -45,7 +45,8 @@ struct RGBColor {
|
|||
RGBColor(const int v[3]) : red(v[0]), green(v[1]), blue(v[2]) { };
|
||||
RGBColor(int r, int g, int b) : red(r), green(g), blue(b) { };
|
||||
|
||||
RGBColor(const std::vector<int> &v) {
|
||||
RGBColor(const vector<int>& v)
|
||||
{
|
||||
if (v.size() != 3) {
|
||||
throw std::out_of_range("Incorrect vector size for RGBColor.");
|
||||
}
|
||||
|
|
@ -121,7 +122,7 @@ public:
|
|||
Position origin_; //!< Plot origin in geometry
|
||||
Position width_; //!< Plot width in geometry
|
||||
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
|
||||
std::array<size_t, 3> pixels_; //!< Plot size in pixels
|
||||
array<size_t, 3> pixels_; //!< Plot size in pixels
|
||||
bool color_overlaps_; //!< Show overlapping cells?
|
||||
int level_; //!< Plot universe level
|
||||
};
|
||||
|
|
@ -171,7 +172,7 @@ T PlotBase::get_map() const {
|
|||
Particle p;
|
||||
p.r() = xyz;
|
||||
p.u() = dir;
|
||||
p.coord_[0].universe = model::root_universe;
|
||||
p.coord(0).universe = model::root_universe;
|
||||
int level = level_;
|
||||
int j{};
|
||||
|
||||
|
|
@ -180,10 +181,10 @@ T PlotBase::get_map() const {
|
|||
p.r()[out_i] = xyz[out_i] - out_pixel * y;
|
||||
for (int x = 0; x < width; x++) {
|
||||
p.r()[in_i] = xyz[in_i] + in_pixel * x;
|
||||
p.n_coord_ = 1;
|
||||
p.n_coord() = 1;
|
||||
// local variables
|
||||
bool found_cell = exhaustive_find_cell(p);
|
||||
j = p.n_coord_ - 1;
|
||||
j = p.n_coord() - 1;
|
||||
if (level >= 0) { j = level; }
|
||||
if (found_cell) {
|
||||
data.set_value(y, x, p, j);
|
||||
|
|
@ -230,7 +231,7 @@ public:
|
|||
RGBColor meshlines_color_; //!< Color of meshlines on the plot
|
||||
RGBColor not_found_ {WHITE}; //!< Plot background color
|
||||
RGBColor overlap_color_ {RED}; //!< Plot overlap color
|
||||
std::vector<RGBColor> colors_; //!< Plot colors
|
||||
vector<RGBColor> colors_; //!< Plot colors
|
||||
std::string path_plot_; //!< Plot output filename
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef OPENMC_POSITION_H
|
||||
#define OPENMC_POSITION_H
|
||||
|
||||
#include <array>
|
||||
#include <cmath> // for sqrt
|
||||
#include <iostream>
|
||||
#include <stdexcept> // for out_of_range
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -18,8 +19,8 @@ struct Position {
|
|||
Position() = default;
|
||||
Position(double x_, double y_, double z_) : x{x_}, y{y_}, z{z_} { };
|
||||
Position(const double xyz[]) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
|
||||
Position(const std::vector<double>& xyz) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
|
||||
Position(const std::array<double, 3>& xyz) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
|
||||
Position(const vector<double>& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
|
||||
Position(const array<double, 3>& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
|
||||
|
||||
// Unary operators
|
||||
Position& operator+=(Position);
|
||||
|
|
@ -81,7 +82,7 @@ struct Position {
|
|||
Position reflect(Position n) const;
|
||||
|
||||
//! Rotate the position based on a rotation matrix
|
||||
Position rotate(const std::vector<double>& rotation) const;
|
||||
Position rotate(const vector<double>& rotation) const;
|
||||
|
||||
// Data members
|
||||
double x = 0.;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
#define OPENMC_REACTION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/reaction_product.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ public:
|
|||
//! Construct reaction from HDF5 data
|
||||
//! \param[in] group HDF5 group containing reaction data
|
||||
//! \param[in] temperatures Desired temperatures for cross sections
|
||||
explicit Reaction(hid_t group, const std::vector<int>& temperatures);
|
||||
explicit Reaction(hid_t group, const vector<int>& temperatures);
|
||||
|
||||
//! \brief Calculate reaction rate based on group-wise flux distribution
|
||||
//
|
||||
|
|
@ -35,20 +35,20 @@ public:
|
|||
//! \param[in] grid Nuclide energy grid
|
||||
//! \return Reaction rate
|
||||
double collapse_rate(gsl::index i_temp, gsl::span<const double> energy,
|
||||
gsl::span<const double> flux, const std::vector<double>& grid) const;
|
||||
gsl::span<const double> flux, const vector<double>& grid) const;
|
||||
|
||||
//! Cross section at a single temperature
|
||||
struct TemperatureXS {
|
||||
int threshold;
|
||||
std::vector<double> value;
|
||||
vector<double> value;
|
||||
};
|
||||
|
||||
int mt_; //!< ENDF MT value
|
||||
double q_value_; //!< Reaction Q value in [eV]
|
||||
bool scatter_in_cm_; //!< scattering system in center-of-mass?
|
||||
bool redundant_; //!< redundant reaction?
|
||||
std::vector<TemperatureXS> xs_; //!< Cross section at each temperature
|
||||
std::vector<ReactionProduct> products_; //!< Reaction products
|
||||
vector<TemperatureXS> xs_; //!< Cross section at each temperature
|
||||
vector<ReactionProduct> products_; //!< Reaction products
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef OPENMC_REACTION_PRODUCT_H
|
||||
#define OPENMC_REACTION_PRODUCT_H
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/angle_energy.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h" // for vector
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -32,7 +31,7 @@ public:
|
|||
total // Delayed emission of secondary particle
|
||||
};
|
||||
|
||||
using Secondary = std::unique_ptr<AngleEnergy>;
|
||||
using Secondary = unique_ptr<AngleEnergy>;
|
||||
|
||||
//! Construct reaction product from HDF5 data
|
||||
//! \param[in] group HDF5 group containing data
|
||||
|
|
@ -45,12 +44,12 @@ public:
|
|||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
void sample(double E_in, double& E_out, double& mu, uint64_t* seed) const;
|
||||
|
||||
Particle::Type particle_; //!< Particle type
|
||||
ParticleType particle_; //!< Particle type
|
||||
EmissionMode emission_mode_; //!< Emission mode
|
||||
double decay_rate_; //!< Decay rate (for delayed neutron precursors) in [1/s]
|
||||
std::unique_ptr<Function1D> yield_; //!< Yield as a function of energy
|
||||
std::vector<Tabulated1D> applicability_; //!< Applicability of distribution
|
||||
std::vector<Secondary> distribution_; //!< Secondary angle-energy distribution
|
||||
unique_ptr<Function1D> yield_; //!< Yield as a function of energy
|
||||
vector<Tabulated1D> applicability_; //!< Applicability of distribution
|
||||
vector<Secondary> distribution_; //!< Secondary angle-energy distribution
|
||||
};
|
||||
|
||||
} // namespace opemc
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@
|
|||
#ifndef OPENMC_SCATTDATA_H
|
||||
#define OPENMC_SCATTDATA_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -32,12 +31,10 @@ class ScattData {
|
|||
const double_2dvec& in_mult);
|
||||
|
||||
//! \brief Combines microscopic ScattDatas into a macroscopic one.
|
||||
void
|
||||
base_combine(size_t max_order, size_t order_dim,
|
||||
const std::vector<ScattData*>& those_scatts,
|
||||
const std::vector<double>& scalars, xt::xtensor<int, 1>& in_gmin,
|
||||
xt::xtensor<int, 1>& in_gmax, double_2dvec& sparse_mult,
|
||||
double_3dvec& sparse_scatter);
|
||||
void base_combine(size_t max_order, size_t order_dim,
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars,
|
||||
xt::xtensor<int, 1>& in_gmin, xt::xtensor<int, 1>& in_gmax,
|
||||
double_2dvec& sparse_mult, double_3dvec& sparse_scatter);
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -85,9 +82,8 @@ class ScattData {
|
|||
//!
|
||||
//! @param those_scatts Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
virtual void
|
||||
combine(const std::vector<ScattData*>& those_scatts,
|
||||
const std::vector<double>& scalars) = 0;
|
||||
virtual void combine(const vector<ScattData*>& those_scatts,
|
||||
const vector<double>& scalars) = 0;
|
||||
|
||||
//! \brief Getter for the dimensionality of the scattering order.
|
||||
//!
|
||||
|
|
@ -151,9 +147,8 @@ class ScattDataLegendre: public ScattData {
|
|||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs);
|
||||
|
||||
void
|
||||
combine(const std::vector<ScattData*>& those_scatts,
|
||||
const std::vector<double>& scalars);
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
|
||||
//! \brief Find the maximal value of the angular distribution to use as a
|
||||
// bounding box with rejection sampling.
|
||||
|
|
@ -192,9 +187,8 @@ class ScattDataHistogram: public ScattData {
|
|||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs);
|
||||
|
||||
void
|
||||
combine(const std::vector<ScattData*>& those_scatts,
|
||||
const std::vector<double>& scalars);
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
|
||||
double
|
||||
calc_f(int gin, int gout, double mu);
|
||||
|
|
@ -233,9 +227,8 @@ class ScattDataTabular: public ScattData {
|
|||
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
|
||||
const double_2dvec& in_mult, const double_3dvec& coeffs);
|
||||
|
||||
void
|
||||
combine(const std::vector<ScattData*>& those_scatts,
|
||||
const std::vector<double>& scalars);
|
||||
void combine(
|
||||
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
|
||||
|
||||
double
|
||||
calc_f(int gin, int gout, double mu);
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef OPENMC_SECONDARY_CORRELATED_H
|
||||
#define OPENMC_SECONDARY_CORRELATED_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/angle_energy.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/distribution.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ public:
|
|||
xt::xtensor<double, 1> e_out; //!< Outgoing energies [eV]
|
||||
xt::xtensor<double, 1> p; //!< Probability density
|
||||
xt::xtensor<double, 1> c; //!< Cumulative distribution
|
||||
std::vector<std::unique_ptr<Tabular>> angle; //!< Angle distribution
|
||||
vector<unique_ptr<Tabular>> angle; //!< Angle distribution
|
||||
};
|
||||
|
||||
explicit CorrelatedAngleEnergy(hid_t group);
|
||||
|
|
@ -43,19 +42,20 @@ public:
|
|||
uint64_t* seed) const override;
|
||||
|
||||
// energy property
|
||||
std::vector<double>& energy() { return energy_; }
|
||||
const std::vector<double>& energy() const { return energy_; }
|
||||
vector<double>& energy() { return energy_; }
|
||||
const vector<double>& energy() const { return energy_; }
|
||||
|
||||
// distribution property
|
||||
std::vector<CorrTable>& distribution() { return distribution_; }
|
||||
const std::vector<CorrTable>& distribution() const { return distribution_; }
|
||||
vector<CorrTable>& distribution() { return distribution_; }
|
||||
const vector<CorrTable>& distribution() const { return distribution_; }
|
||||
|
||||
private:
|
||||
int n_region_; //!< Number of interpolation regions
|
||||
std::vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
std::vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
std::vector<double> energy_; //!< Energies [eV] at which distributions
|
||||
//!< are tabulated
|
||||
std::vector<CorrTable> distribution_; //!< Distribution at each energy
|
||||
vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
vector<double> energy_; //!< Energies [eV] at which distributions
|
||||
//!< are tabulated
|
||||
vector<CorrTable> distribution_; //!< Distribution at each energy
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef OPENMC_SECONDARY_KALBACH_H
|
||||
#define OPENMC_SECONDARY_KALBACH_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/angle_energy.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -45,11 +44,11 @@ private:
|
|||
};
|
||||
|
||||
int n_region_; //!< Number of interpolation regions
|
||||
std::vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
std::vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
std::vector<double> energy_; //!< Energies [eV] at which distributions
|
||||
//!< are tabulated
|
||||
std::vector<KMTable> distribution_; //!< Distribution at each energy
|
||||
vector<int> breakpoints_; //!< Breakpoints between regions
|
||||
vector<Interpolation> interpolation_; //!< Interpolation laws
|
||||
vector<double> energy_; //!< Energies [eV] at which distributions
|
||||
//!< are tabulated
|
||||
vector<KMTable> distribution_; //!< Distribution at each energy
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@
|
|||
#include "openmc/angle_energy.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/secondary_correlated.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <hdf5.h>
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -70,7 +69,8 @@ public:
|
|||
//
|
||||
//! \param[in] group HDF5 group
|
||||
//! \param[in] energy Energies at which cosines are tabulated
|
||||
explicit IncoherentElasticAEDiscrete(hid_t group, const std::vector<double>& energy);
|
||||
explicit IncoherentElasticAEDiscrete(
|
||||
hid_t group, const vector<double>& energy);
|
||||
|
||||
//! Sample distribution for an angle and energy
|
||||
//! \param[in] E_in Incoming energy in [eV]
|
||||
|
|
@ -80,7 +80,7 @@ public:
|
|||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
private:
|
||||
const std::vector<double>& energy_; //!< Energies at which cosines are tabulated
|
||||
const vector<double>& energy_; //!< Energies at which cosines are tabulated
|
||||
xt::xtensor<double, 2> mu_out_; //!< Cosines for each incident energy
|
||||
};
|
||||
|
||||
|
|
@ -94,7 +94,8 @@ public:
|
|||
//
|
||||
//! \param[in] group HDF5 group
|
||||
//! \param[in] energy Incident energies at which distributions are tabulated
|
||||
explicit IncoherentInelasticAEDiscrete(hid_t group, const std::vector<double>& energy);
|
||||
explicit IncoherentInelasticAEDiscrete(
|
||||
hid_t group, const vector<double>& energy);
|
||||
|
||||
//! Sample distribution for an angle and energy
|
||||
//! \param[in] E_in Incoming energy in [eV]
|
||||
|
|
@ -104,7 +105,7 @@ public:
|
|||
void sample(double E_in, double& E_out, double& mu,
|
||||
uint64_t* seed) const override;
|
||||
private:
|
||||
const std::vector<double>& energy_; //!< Incident energies
|
||||
const vector<double>& energy_; //!< Incident energies
|
||||
xt::xtensor<double, 2> energy_out_; //!< Outgoing energies for each incident energy
|
||||
xt::xtensor<double, 3> mu_out_; //!< Outgoing cosines for each incident/outgoing energy
|
||||
bool skewed_; //!< Whether outgoing energy distribution is skewed
|
||||
|
|
@ -138,9 +139,9 @@ private:
|
|||
xt::xtensor<double, 2> mu; //!< Equiprobable angles at each outgoing energy
|
||||
};
|
||||
|
||||
std::vector<double> energy_; //!< Incident energies
|
||||
std::vector<DistEnergySab> distribution_; //!< Secondary angle-energy at
|
||||
//!< each incident energy
|
||||
vector<double> energy_; //!< Incident energies
|
||||
vector<DistEnergySab> distribution_; //!< Secondary angle-energy at
|
||||
//!< each incident energy
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef OPENMC_SECONDARY_UNCORRELATED_H
|
||||
#define OPENMC_SECONDARY_UNCORRELATED_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/angle_energy.h"
|
||||
#include "openmc/distribution_angle.h"
|
||||
#include "openmc/distribution_energy.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ public:
|
|||
AngleDistribution& angle() { return angle_; }
|
||||
private:
|
||||
AngleDistribution angle_; //!< Angle distribution
|
||||
std::unique_ptr<EnergyDistribution> energy_; //!< Energy distribution
|
||||
unique_ptr<EnergyDistribution> energy_; //!< Energy distribution
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
//! \file settings.h
|
||||
//! \brief Settings for OpenMC
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -75,7 +75,8 @@ extern "C" int64_t n_particles; //!< number of particles per genera
|
|||
extern int64_t max_particles_in_flight; //!< Max num. event-based particles in flight
|
||||
|
||||
extern ElectronTreatment electron_treatment; //!< how to treat secondary electrons
|
||||
extern std::array<double, 4> energy_cutoff; //!< Energy cutoff in [eV] for each particle type
|
||||
extern array<double, 4>
|
||||
energy_cutoff; //!< Energy cutoff in [eV] for each particle type
|
||||
extern int legendre_to_tabular_points; //!< number of points to convert Legendres
|
||||
extern int max_order; //!< Maximum Legendre order for multigroup data
|
||||
extern int n_log_bins; //!< number of bins for logarithmic energy grid
|
||||
|
|
@ -84,7 +85,8 @@ extern int n_max_batches; //!< Maximum number of batches
|
|||
extern ResScatMethod res_scat_method; //!< resonance upscattering method
|
||||
extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering
|
||||
extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering
|
||||
extern std::vector<std::string> res_scat_nuclides; //!< Nuclides using res. upscattering treatment
|
||||
extern vector<std::string>
|
||||
res_scat_nuclides; //!< Nuclides using res. upscattering treatment
|
||||
extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.)
|
||||
extern std::unordered_set<int> sourcepoint_batch; //!< Batches when source should be written
|
||||
extern std::unordered_set<int> statepoint_batch; //!< Batches when state should be written
|
||||
|
|
@ -93,11 +95,13 @@ extern int64_t max_surface_particles; //!< maximum number of particles to be
|
|||
extern TemperatureMethod temperature_method; //!< method for choosing temperatures
|
||||
extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures
|
||||
extern double temperature_default; //!< Default T in [K]
|
||||
extern std::array<double, 2> temperature_range; //!< Min/max T in [K] over which to load xs
|
||||
extern array<double, 2>
|
||||
temperature_range; //!< Min/max T in [K] over which to load xs
|
||||
extern int trace_batch; //!< Batch to trace particle on
|
||||
extern int trace_gen; //!< Generation to trace particle on
|
||||
extern int64_t trace_particle; //!< Particle ID to enable trace on
|
||||
extern std::vector<std::array<int, 3>> track_identifiers; //!< Particle numbers for writing tracks
|
||||
extern vector<array<int, 3>>
|
||||
track_identifiers; //!< Particle numbers for writing tracks
|
||||
extern int trigger_batch_interval; //!< Batch interval for triggers
|
||||
extern "C" int verbosity; //!< How verbose to make output
|
||||
extern double weight_cutoff; //!< Weight cutoff for Russian roulette
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
//! \file shared_array.h
|
||||
//! \brief Shared array data structure
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "openmc/memory.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ public:
|
|||
//! space for
|
||||
SharedArray(int64_t capacity) : capacity_(capacity)
|
||||
{
|
||||
data_ = std::make_unique<T[]>(capacity);
|
||||
data_ = make_unique<T[]>(capacity);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -55,7 +54,7 @@ public:
|
|||
//! \param capacity The number of elements to allocate in the container
|
||||
void reserve(int64_t capacity)
|
||||
{
|
||||
data_ = std::make_unique<T[]>(capacity);
|
||||
data_ = make_unique<T[]>(capacity);
|
||||
capacity_ = capacity;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +119,7 @@ private:
|
|||
//==========================================================================
|
||||
// Data members
|
||||
|
||||
std::unique_ptr<T[]> data_; //!< An RAII handle to the elements
|
||||
unique_ptr<T[]> data_; //!< An RAII handle to the elements
|
||||
int64_t size_ {0}; //!< The current number of elements
|
||||
int64_t capacity_ {0}; //!< The total space allocated for elements
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include "openmc/mesh.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -42,8 +42,8 @@ extern int64_t work_per_rank; //!< number of particles per MPI rank
|
|||
extern const RegularMesh* entropy_mesh;
|
||||
extern const RegularMesh* ufs_mesh;
|
||||
|
||||
extern std::vector<double> k_generation;
|
||||
extern std::vector<int64_t> work_index;
|
||||
extern vector<double> k_generation;
|
||||
extern vector<int64_t> work_index;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
@ -69,9 +69,6 @@ void initialize_generation();
|
|||
//! Full initialization of a particle history
|
||||
void initialize_history(Particle& p, int64_t index_source);
|
||||
|
||||
//! Helper function for initialize_history() that is called independently elsewhere
|
||||
void initialize_history_partial(Particle& p);
|
||||
|
||||
//! Finalize a batch
|
||||
//!
|
||||
//! Handles synchronization and accumulation of tallies, calculation of Shannon
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#ifndef OPENMC_SOURCE_H
|
||||
#define OPENMC_SOURCE_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include "openmc/distribution_multi.h"
|
||||
#include "openmc/distribution_spatial.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ class Source;
|
|||
|
||||
namespace model {
|
||||
|
||||
extern std::vector<std::unique_ptr<Source>> external_sources;
|
||||
extern vector<unique_ptr<Source>> external_sources;
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ public:
|
|||
virtual ~Source() = default;
|
||||
|
||||
// Methods that must be implemented
|
||||
virtual Particle::Bank sample(uint64_t* seed) const = 0;
|
||||
virtual SourceSite sample(uint64_t* seed) const = 0;
|
||||
|
||||
// Methods that can be overridden
|
||||
virtual double strength() const { return 1.0; }
|
||||
|
|
@ -55,10 +54,10 @@ public:
|
|||
//! Sample from the external source distribution
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
//! \return Sampled site
|
||||
Particle::Bank sample(uint64_t* seed) const override;
|
||||
SourceSite sample(uint64_t* seed) const override;
|
||||
|
||||
// Properties
|
||||
Particle::Type particle_type() const { return particle_; }
|
||||
ParticleType particle_type() const { return particle_; }
|
||||
double strength() const override { return strength_; }
|
||||
|
||||
// Make observing pointers available
|
||||
|
|
@ -67,7 +66,7 @@ public:
|
|||
Distribution* energy() const { return energy_.get(); }
|
||||
|
||||
private:
|
||||
Particle::Type particle_ {Particle::Type::neutron}; //!< Type of particle emitted
|
||||
ParticleType particle_ {ParticleType::neutron}; //!< Type of particle emitted
|
||||
double strength_ {1.0}; //!< Source strength
|
||||
UPtrSpace space_; //!< Spatial distribution
|
||||
UPtrAngle angle_; //!< Angular distribution
|
||||
|
|
@ -84,10 +83,10 @@ public:
|
|||
explicit FileSource(std::string path);
|
||||
|
||||
// Methods
|
||||
Particle::Bank sample(uint64_t* seed) const override;
|
||||
SourceSite sample(uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
std::vector<Particle::Bank> sites_; //!< Source sites from a file
|
||||
vector<SourceSite> sites_; //!< Source sites from a file
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -101,7 +100,7 @@ public:
|
|||
~CustomSourceWrapper();
|
||||
|
||||
// Defer implementation to custom source library
|
||||
Particle::Bank sample(uint64_t* seed) const override
|
||||
SourceSite sample(uint64_t* seed) const override
|
||||
{
|
||||
return custom_source_->sample(seed);
|
||||
}
|
||||
|
|
@ -109,10 +108,10 @@ public:
|
|||
double strength() const override { return custom_source_->strength(); }
|
||||
private:
|
||||
void* shared_library_; //!< library from dlopen
|
||||
std::unique_ptr<Source> custom_source_;
|
||||
unique_ptr<Source> custom_source_;
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<Source> create_custom_source_t(std::string parameters);
|
||||
typedef unique_ptr<Source> create_custom_source_t(std::string parameters);
|
||||
|
||||
//==============================================================================
|
||||
// Functions
|
||||
|
|
@ -125,7 +124,7 @@ extern "C" void initialize_source();
|
|||
//! source strength
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
//! \return Sampled source site
|
||||
Particle::Bank sample_external_source(uint64_t* seed);
|
||||
SourceSite sample_external_source(uint64_t* seed);
|
||||
|
||||
void free_memory_source();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,20 +2,21 @@
|
|||
#define OPENMC_STATE_POINT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
void load_state_point();
|
||||
std::vector<int64_t> calculate_surf_source_size();
|
||||
vector<int64_t> calculate_surf_source_size();
|
||||
void write_source_point(const char* filename, bool surf_source_bank = false);
|
||||
void write_source_bank(hid_t group_id, bool surf_source_bank);
|
||||
void read_source_bank(hid_t group_id, std::vector<Particle::Bank>& sites, bool distribute);
|
||||
void read_source_bank(
|
||||
hid_t group_id, vector<SourceSite>& sites, bool distribute);
|
||||
void write_tally_results_nr(hid_t file_id);
|
||||
void restart_set_keff();
|
||||
void write_unstructured_mesh_results();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
#define OPENMC_STRING_UTILS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ void to_lower(std::string& str);
|
|||
|
||||
int word_count(std::string const& str);
|
||||
|
||||
std::vector<std::string> split(const std::string& in);
|
||||
vector<std::string> split(const std::string& in);
|
||||
|
||||
bool ends_with(const std::string& value, const std::string& ending);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
#ifndef OPENMC_SURFACE_H
|
||||
#define OPENMC_SURFACE_H
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <limits> // For numeric_limits
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include "dagmc.h"
|
||||
#include "openmc/boundary_condition.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
#include "dagmc.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ class Surface;
|
|||
|
||||
namespace model {
|
||||
extern std::unordered_map<int, int> surface_map;
|
||||
extern std::vector<std::unique_ptr<Surface>> surfaces;
|
||||
extern vector<unique_ptr<Surface>> surfaces;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#define OPENMC_TALLIES_DERIVATIVE_H
|
||||
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ namespace openmc {
|
|||
|
||||
namespace model {
|
||||
extern std::unordered_map<int, int> tally_deriv_map;
|
||||
extern std::vector<TallyDerivative> tally_derivs;
|
||||
extern vector<TallyDerivative> tally_derivs;
|
||||
} // namespace model
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -2,19 +2,18 @@
|
|||
#define OPENMC_TALLIES_FILTER_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/tallies/filter_match.h"
|
||||
#include "pugixml.hpp"
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -120,7 +119,7 @@ private:
|
|||
namespace model {
|
||||
extern "C" int32_t n_filters;
|
||||
extern std::unordered_map<int, int> filter_map;
|
||||
extern std::vector<std::unique_ptr<Filter>> tally_filters;
|
||||
extern vector<unique_ptr<Filter>> tally_filters;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_AZIMUTHAL_H
|
||||
#define OPENMC_TALLIES_FILTER_AZIMUTHAL_H
|
||||
|
||||
#include "openmc/vector.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ private:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<double> bins_;
|
||||
vector<double> bins_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<int32_t>& cells() const { return cells_; }
|
||||
const vector<int32_t>& cells() const { return cells_; }
|
||||
|
||||
void set_cells(gsl::span<int32_t> cells);
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ protected:
|
|||
// Data members
|
||||
|
||||
//! The indices of the cells binned by this filter.
|
||||
std::vector<int32_t> cells_;
|
||||
vector<int32_t> cells_;
|
||||
|
||||
//! A map from cell indices to filter bin indices.
|
||||
std::unordered_map<int32_t, int> map_;
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -43,7 +42,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<CellInstance>& cell_instances() const { return cell_instances_; }
|
||||
const vector<CellInstance>& cell_instances() const { return cell_instances_; }
|
||||
|
||||
void set_cell_instances(gsl::span<CellInstance> instances);
|
||||
|
||||
|
|
@ -52,7 +51,7 @@ private:
|
|||
// Data members
|
||||
|
||||
//! The indices of the cells binned by this filter.
|
||||
std::vector<CellInstance> cell_instances_;
|
||||
vector<CellInstance> cell_instances_;
|
||||
|
||||
//! A map from cell/instance indices to filter bin indices.
|
||||
std::unordered_map<CellInstance, gsl::index, CellInstanceHash> map_;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_COLLISIONS_H
|
||||
#define OPENMC_TALLIES_FILTER_COLLISIONS_H
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -37,14 +37,14 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<int>& bins() const { return bins_; }
|
||||
const vector<int>& bins() const { return bins_; }
|
||||
void set_bins(gsl::span<const int> bins);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<int> bins_;
|
||||
vector<int> bins_;
|
||||
|
||||
std::unordered_map<int,int> map_;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_DELAYEDGROUP_H
|
||||
#define OPENMC_TALLIES_FILTER_DELAYEDGROUP_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -41,7 +40,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<int>& groups() const { return groups_; }
|
||||
const vector<int>& groups() const { return groups_; }
|
||||
|
||||
void set_groups(gsl::span<int> groups);
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ private:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<int> groups_;
|
||||
vector<int> groups_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_ENERGY_H
|
||||
#define OPENMC_TALLIES_FILTER_ENERGY_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<double>& bins() const { return bins_; }
|
||||
const vector<double>& bins() const { return bins_; }
|
||||
void set_bins(gsl::span<const double> bins);
|
||||
|
||||
bool matches_transport_groups() const { return matches_transport_groups_; }
|
||||
|
|
@ -47,7 +46,7 @@ protected:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<double> bins_;
|
||||
vector<double> bins_;
|
||||
|
||||
//! True if transport group number can be used directly to get bin number
|
||||
bool matches_transport_groups_ {false};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_ENERGYFUNC_H
|
||||
#define OPENMC_TALLIES_FILTER_ENERGYFUNC_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -43,8 +42,8 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<double>& energy() const { return energy_; }
|
||||
const std::vector<double>& y() const { return y_; }
|
||||
const vector<double>& energy() const { return energy_; }
|
||||
const vector<double>& y() const { return y_; }
|
||||
void set_data(gsl::span<const double> energy, gsl::span<const double> y);
|
||||
|
||||
private:
|
||||
|
|
@ -52,10 +51,10 @@ private:
|
|||
// Data members
|
||||
|
||||
//! Incident neutron energy interpolation grid.
|
||||
std::vector<double> energy_;
|
||||
vector<double> energy_;
|
||||
|
||||
//! Interpolant values.
|
||||
std::vector<double> y_;
|
||||
vector<double> y_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ namespace openmc {
|
|||
class FilterMatch
|
||||
{
|
||||
public:
|
||||
std::vector<int> bins_;
|
||||
std::vector<double> weights_;
|
||||
vector<int> bins_;
|
||||
vector<double> weights_;
|
||||
int i_bin_;
|
||||
bool bins_present_ {false};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -40,9 +40,9 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
std::vector<int32_t>& materials() { return materials_; }
|
||||
vector<int32_t>& materials() { return materials_; }
|
||||
|
||||
const std::vector<int32_t>& materials() const { return materials_; }
|
||||
const vector<int32_t>& materials() const { return materials_; }
|
||||
|
||||
void set_materials(gsl::span<const int32_t> materials);
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ private:
|
|||
// Data members
|
||||
|
||||
//! The indices of the materials binned by this filter.
|
||||
std::vector<int32_t> materials_;
|
||||
vector<int32_t> materials_;
|
||||
|
||||
//! A map from material indices to filter bin indices.
|
||||
std::unordered_map<int32_t, int> map_;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_MU_H
|
||||
#define OPENMC_TALLIES_FILTER_MU_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -45,7 +44,7 @@ private:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<double> bins_;
|
||||
vector<double> bins_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_PARTICLE_H
|
||||
#define OPENMC_TALLIES_FILTER_PARTICLE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -37,15 +36,15 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
const std::vector<Particle::Type>& particles() const { return particles_; }
|
||||
const vector<ParticleType>& particles() const { return particles_; }
|
||||
|
||||
void set_particles(gsl::span<Particle::Type> particles);
|
||||
void set_particles(gsl::span<ParticleType> particles);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<Particle::Type> particles_;
|
||||
vector<ParticleType> particles_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
#define OPENMC_TALLIES_FILTER_POLAR_H
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ private:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
||||
std::vector<double> bins_;
|
||||
vector<double> bins_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ private:
|
|||
// Data members
|
||||
|
||||
//! The indices of the surfaces binned by this filter.
|
||||
std::vector<int32_t> surfaces_;
|
||||
vector<int32_t> surfaces_;
|
||||
|
||||
//! A map from surface indices to filter bin indices.
|
||||
std::unordered_map<int32_t, int> map_;
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ private:
|
|||
// Data members
|
||||
|
||||
//! The indices of the universes binned by this filter.
|
||||
std::vector<int32_t> universes_;
|
||||
vector<int32_t> universes_;
|
||||
|
||||
//! A map from universe indices to filter bin indices.
|
||||
std::unordered_map<int32_t, int> map_;
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
#define OPENMC_TALLIES_TALLY_H
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/tallies/trigger.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <gsl/gsl>
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xfixed.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -41,13 +41,13 @@ public:
|
|||
|
||||
void set_scores(pugi::xml_node node);
|
||||
|
||||
void set_scores(const std::vector<std::string>& scores);
|
||||
void set_scores(const vector<std::string>& scores);
|
||||
|
||||
void set_nuclides(pugi::xml_node node);
|
||||
|
||||
void set_nuclides(const std::vector<std::string>& nuclides);
|
||||
void set_nuclides(const vector<std::string>& nuclides);
|
||||
|
||||
const std::vector<int32_t>& filters() const {return filters_;}
|
||||
const vector<int32_t>& filters() const { return filters_; }
|
||||
|
||||
int32_t filters(int i) const {return filters_[i];}
|
||||
|
||||
|
|
@ -96,10 +96,10 @@ public:
|
|||
//! Number of realizations
|
||||
int n_realizations_ {0};
|
||||
|
||||
std::vector<int> scores_; //!< Filter integrands (e.g. flux, fission)
|
||||
vector<int> scores_; //!< Filter integrands (e.g. flux, fission)
|
||||
|
||||
//! Index of each nuclide to be tallied. -1 indicates total material.
|
||||
std::vector<int> nuclides_ {-1};
|
||||
vector<int> nuclides_ {-1};
|
||||
|
||||
//! True if this tally has a bin for every nuclide in the problem
|
||||
bool all_nuclides_ {false};
|
||||
|
|
@ -122,7 +122,7 @@ public:
|
|||
int energyout_filter_ {C_NONE};
|
||||
int delayedgroup_filter_ {C_NONE};
|
||||
|
||||
std::vector<Trigger> triggers_;
|
||||
vector<Trigger> triggers_;
|
||||
|
||||
int deriv_ {C_NONE}; //!< Index of a TallyDerivative object for diff tallies.
|
||||
|
||||
|
|
@ -130,10 +130,10 @@ private:
|
|||
//----------------------------------------------------------------------------
|
||||
// Private data.
|
||||
|
||||
std::vector<int32_t> filters_; //!< Filter indices in global filters array
|
||||
vector<int32_t> filters_; //!< Filter indices in global filters array
|
||||
|
||||
//! Index strides assigned to each filter to support 1D indexing.
|
||||
std::vector<int32_t> strides_;
|
||||
vector<int32_t> strides_;
|
||||
|
||||
int32_t n_filter_bins_ {0};
|
||||
|
||||
|
|
@ -146,13 +146,13 @@ private:
|
|||
|
||||
namespace model {
|
||||
extern std::unordered_map<int, int> tally_map;
|
||||
extern std::vector<std::unique_ptr<Tally>> tallies;
|
||||
extern std::vector<int> active_tallies;
|
||||
extern std::vector<int> active_analog_tallies;
|
||||
extern std::vector<int> active_tracklength_tallies;
|
||||
extern std::vector<int> active_collision_tallies;
|
||||
extern std::vector<int> active_meshsurf_tallies;
|
||||
extern std::vector<int> active_surface_tallies;
|
||||
extern vector<unique_ptr<Tally>> tallies;
|
||||
extern vector<int> active_tallies;
|
||||
extern vector<int> active_analog_tallies;
|
||||
extern vector<int> active_tracklength_tallies;
|
||||
extern vector<int> active_collision_tallies;
|
||||
extern vector<int> active_meshsurf_tallies;
|
||||
extern vector<int> active_surface_tallies;
|
||||
}
|
||||
|
||||
namespace simulation {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ public:
|
|||
//! Construct an iterator over all filter bin combinations.
|
||||
//
|
||||
//! \param end if true, the returned iterator indicates the end of a loop.
|
||||
FilterBinIter(const Tally& tally, bool end,
|
||||
std::vector<FilterMatch>* particle_filter_matches);
|
||||
FilterBinIter(
|
||||
const Tally& tally, bool end, vector<FilterMatch>* particle_filter_matches);
|
||||
|
||||
bool operator==(const FilterBinIter& other) const
|
||||
{return index_ == other.index_;}
|
||||
|
|
@ -42,7 +42,7 @@ public:
|
|||
int index_ {1};
|
||||
double weight_ {1.};
|
||||
|
||||
std::vector<FilterMatch>& filter_matches_;
|
||||
vector<FilterMatch>& filter_matches_;
|
||||
|
||||
private:
|
||||
void compute_index_weight();
|
||||
|
|
@ -93,7 +93,7 @@ void score_tracklength_tally(Particle& p, double distance);
|
|||
//
|
||||
//! \param p The particle being tracked
|
||||
//! \param tallies A vector of tallies to score to
|
||||
void score_surface_tally(Particle& p, const std::vector<int>& tallies);
|
||||
void score_surface_tally(Particle& p, const vector<int>& tallies);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
#define OPENMC_THERMAL_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/angle_energy.h"
|
||||
#include "openmc/endf.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ class ThermalScattering;
|
|||
|
||||
namespace data {
|
||||
extern std::unordered_map<std::string, int> thermal_scatt_map;
|
||||
extern std::vector<std::unique_ptr<ThermalScattering>> thermal_scatt;
|
||||
extern vector<unique_ptr<ThermalScattering>> thermal_scatt;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -58,8 +58,9 @@ private:
|
|||
Reaction() { }
|
||||
|
||||
// Data members
|
||||
std::unique_ptr<Function1D> xs; //!< Cross section
|
||||
std::unique_ptr<AngleEnergy> distribution; //!< Secondary angle-energy distribution
|
||||
unique_ptr<Function1D> xs; //!< Cross section
|
||||
unique_ptr<AngleEnergy>
|
||||
distribution; //!< Secondary angle-energy distribution
|
||||
};
|
||||
|
||||
// Inelastic scattering data
|
||||
|
|
@ -77,7 +78,7 @@ private:
|
|||
|
||||
class ThermalScattering {
|
||||
public:
|
||||
ThermalScattering(hid_t group, const std::vector<double>& temperature);
|
||||
ThermalScattering(hid_t group, const vector<double>& temperature);
|
||||
|
||||
//! Determine inelastic/elastic cross section at given energy
|
||||
//!
|
||||
|
|
@ -103,11 +104,11 @@ public:
|
|||
std::string name_; //!< name of table, e.g. "c_H_in_H2O"
|
||||
double awr_; //!< weight of nucleus in neutron masses
|
||||
double energy_max_; //!< maximum energy for thermal scattering in [eV]
|
||||
std::vector<double> kTs_; //!< temperatures in [eV] (k*T)
|
||||
std::vector<std::string> nuclides_; //!< Valid nuclides
|
||||
vector<double> kTs_; //!< temperatures in [eV] (k*T)
|
||||
vector<std::string> nuclides_; //!< Valid nuclides
|
||||
|
||||
//! cross sections and distributions at each temperature
|
||||
std::vector<ThermalData> data_;
|
||||
vector<ThermalData> data_;
|
||||
};
|
||||
|
||||
void free_memory_thermal();
|
||||
|
|
|
|||
23
include/openmc/vector.h
Normal file
23
include/openmc/vector.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef OPENMC_VECTOR_H
|
||||
#define OPENMC_VECTOR_H
|
||||
|
||||
/*
|
||||
* In an implementation of OpenMC that offloads computations to an accelerator,
|
||||
* we may need to provide replacements for standard library containers and
|
||||
* algorithms that have no native implementations on the device of interest.
|
||||
* Because some developers are currently in the process of creating such code,
|
||||
* introducing the below typedef lessens the amount of rebase conflicts that
|
||||
* happen as they rebase their code on OpenMC's develop branch.
|
||||
*
|
||||
* In an implementation of OpenMC that uses such an accelerator, we may remove
|
||||
* the use of vector below and replace it with a custom implementation
|
||||
* behaving as expected on the device.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace openmc {
|
||||
using std::vector;
|
||||
}
|
||||
|
||||
#endif // OPENMC_VECTOR_H
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include <array>
|
||||
#include "openmc/array.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#ifndef OPENMC_VOLUME_CALC_H
|
||||
#define OPENMC_VOLUME_CALC_H
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/tallies/trigger.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <gsl/gsl>
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -23,10 +23,10 @@ class VolumeCalculation {
|
|||
public:
|
||||
// Aliases, types
|
||||
struct Result {
|
||||
std::array<double, 2> volume; //!< Mean/standard deviation of volume
|
||||
std::vector<int> nuclides; //!< Index of nuclides
|
||||
std::vector<double> atoms; //!< Number of atoms for each nuclide
|
||||
std::vector<double> uncertainty; //!< Uncertainty on number of atoms
|
||||
array<double, 2> volume; //!< Mean/standard deviation of volume
|
||||
vector<int> nuclides; //!< Index of nuclides
|
||||
vector<double> atoms; //!< Number of atoms for each nuclide
|
||||
vector<double> uncertainty; //!< Uncertainty on number of atoms
|
||||
int iterations; //!< Number of iterations needed to obtain the results
|
||||
}; // Results for a single domain
|
||||
|
||||
|
|
@ -39,13 +39,14 @@ public:
|
|||
//! average number densities of nuclides within the domain
|
||||
//
|
||||
//! \return Vector of results for each user-specified domain
|
||||
std::vector<Result> execute() const;
|
||||
vector<Result> execute() const;
|
||||
|
||||
//! \brief Write volume calculation results to HDF5 file
|
||||
//
|
||||
//! \param[in] filename Path to HDF5 file to write
|
||||
//! \param[in] results Vector of results for each domain
|
||||
void to_hdf5(const std::string& filename, const std::vector<Result>& results) const;
|
||||
void to_hdf5(
|
||||
const std::string& filename, const vector<Result>& results) const;
|
||||
|
||||
// Tally filter and map types
|
||||
enum class TallyDomain {
|
||||
|
|
@ -61,7 +62,7 @@ public:
|
|||
TriggerMetric trigger_type_ {TriggerMetric::not_active}; //!< Trigger metric for the volume calculation
|
||||
Position lower_left_; //!< Lower-left position of bounding box
|
||||
Position upper_right_; //!< Upper-right position of bounding box
|
||||
std::vector<int> domain_ids_; //!< IDs of domains to find volumes of
|
||||
vector<int> domain_ids_; //!< IDs of domains to find volumes of
|
||||
|
||||
private:
|
||||
//! \brief Check whether a material has already been hit for a given domain.
|
||||
|
|
@ -70,9 +71,7 @@ private:
|
|||
//! \param[in] i_material Index in global materials vector
|
||||
//! \param[in,out] indices Vector of material indices
|
||||
//! \param[in,out] hits Number of hits corresponding to each material
|
||||
void check_hit(int i_material, std::vector<int>& indices,
|
||||
std::vector<int>& hits) const;
|
||||
|
||||
void check_hit(int i_material, vector<int>& indices, vector<int>& hits) const;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -80,7 +79,7 @@ private:
|
|||
//==============================================================================
|
||||
|
||||
namespace model {
|
||||
extern std::vector<VolumeCalculation> volume_calcs;
|
||||
extern vector<VolumeCalculation> volume_calcs;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
#include "hdf5.h"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <complex>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//========================================================================
|
||||
|
|
@ -27,7 +29,7 @@ constexpr int FIT_A {1}; // Absorption
|
|||
constexpr int FIT_F {2}; // Fission
|
||||
|
||||
// Multipole HDF5 file version
|
||||
constexpr std::array<int, 2> WMP_VERSION {1, 1};
|
||||
constexpr array<int, 2> WMP_VERSION {1, 1};
|
||||
|
||||
//========================================================================
|
||||
// Windowed multipole data
|
||||
|
|
@ -73,7 +75,7 @@ public:
|
|||
double inv_spacing_; //!< 1 / spacing in sqrt(E) space
|
||||
int fit_order_; //!< Order of the fit
|
||||
bool fissionable_; //!< Is the nuclide fissionable?
|
||||
std::vector<WindowInfo> window_info_; // Information about a window
|
||||
vector<WindowInfo> window_info_; // Information about a window
|
||||
xt::xtensor<double, 3> curvefit_; // Curve fit coefficients (window, poly order, reaction)
|
||||
xt::xtensor<std::complex<double>, 2> data_; //!< Poles and residues
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@
|
|||
#include <cstddef> // for size_t
|
||||
#include <sstream> // for stringstream
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xarray.hpp"
|
||||
#include "xtensor/xadapt.hpp"
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
inline bool
|
||||
|
|
@ -23,9 +24,9 @@ std::string get_node_value(pugi::xml_node node, const char* name,
|
|||
|
||||
bool get_node_value_bool(pugi::xml_node node, const char* name);
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> get_node_array(pugi::xml_node node, const char* name,
|
||||
bool lowercase=false)
|
||||
template<typename T>
|
||||
vector<T> get_node_array(
|
||||
pugi::xml_node node, const char* name, bool lowercase = false)
|
||||
{
|
||||
// Get value of node attribute/child
|
||||
std::string s {get_node_value(node, name, lowercase)};
|
||||
|
|
@ -33,7 +34,7 @@ std::vector<T> get_node_array(pugi::xml_node node, const char* name,
|
|||
// Read values one by one into vector
|
||||
std::stringstream iss {s};
|
||||
T value;
|
||||
std::vector<T> values;
|
||||
vector<T> values;
|
||||
while (iss >> value)
|
||||
values.push_back(value);
|
||||
|
||||
|
|
@ -44,8 +45,8 @@ template <typename T>
|
|||
xt::xarray<T> get_node_xarray(pugi::xml_node node, const char* name,
|
||||
bool lowercase=false)
|
||||
{
|
||||
std::vector<T> v = get_node_array<T>(node, name, lowercase);
|
||||
std::vector<std::size_t> shape = {v.size()};
|
||||
vector<T> v = get_node_array<T>(node, name, lowercase);
|
||||
vector<std::size_t> shape = {v.size()};
|
||||
return xt::adapt(v, shape);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@
|
|||
#ifndef OPENMC_XSDATA_H
|
||||
#define OPENMC_XSDATA_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/scattdata.h"
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -99,7 +97,7 @@ class XsData {
|
|||
// [angle][incoming group][outgoing group][delayed group]
|
||||
xt::xtensor<double, 4> chi_delayed;
|
||||
// scatter has the following dimensions: [angle]
|
||||
std::vector<std::shared_ptr<ScattData>> scatter;
|
||||
vector<std::shared_ptr<ScattData>> scatter;
|
||||
|
||||
XsData() = default;
|
||||
|
||||
|
|
@ -138,8 +136,8 @@ class XsData {
|
|||
//!
|
||||
//! @param micros Microscopic objects to combine.
|
||||
//! @param scalars Scalars to multiply the microscopic data by.
|
||||
void
|
||||
combine(const std::vector<XsData*>& those_xs, const std::vector<double>& scalars);
|
||||
void combine(
|
||||
const vector<XsData*>& those_xs, const vector<double>& scalars);
|
||||
|
||||
//! \brief Checks to see if this and that are able to be combined
|
||||
//!
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from .error import _error_handler
|
|||
import openmc.lib
|
||||
|
||||
|
||||
class _Bank(Structure):
|
||||
class _SourceSite(Structure):
|
||||
_fields_ = [('r', c_double*3),
|
||||
('u', c_double*3),
|
||||
('E', c_double),
|
||||
|
|
@ -73,7 +73,7 @@ _run_linsolver_argtypes = [_array_1d_dble, _array_1d_dble, _array_1d_dble,
|
|||
c_double]
|
||||
_dll.openmc_run_linsolver.argtypes = _run_linsolver_argtypes
|
||||
_dll.openmc_run_linsolver.restype = c_int
|
||||
_dll.openmc_source_bank.argtypes = [POINTER(POINTER(_Bank)), POINTER(c_int64)]
|
||||
_dll.openmc_source_bank.argtypes = [POINTER(POINTER(_SourceSite)), POINTER(c_int64)]
|
||||
_dll.openmc_source_bank.restype = c_int
|
||||
_dll.openmc_source_bank.errcheck = _error_handler
|
||||
_dll.openmc_simulation_init.restype = c_int
|
||||
|
|
@ -342,13 +342,13 @@ def source_bank():
|
|||
|
||||
"""
|
||||
# Get pointer to source bank
|
||||
ptr = POINTER(_Bank)()
|
||||
ptr = POINTER(_SourceSite)()
|
||||
n = c_int64()
|
||||
_dll.openmc_source_bank(ptr, n)
|
||||
|
||||
try:
|
||||
# Convert to numpy array with appropriate datatype
|
||||
bank_dtype = np.dtype(_Bank)
|
||||
bank_dtype = np.dtype(_SourceSite)
|
||||
return as_array(ptr, (n.value,)).view(bank_dtype)
|
||||
|
||||
except ValueError as err:
|
||||
|
|
|
|||
15
src/bank.cpp
15
src/bank.cpp
|
|
@ -1,8 +1,9 @@
|
|||
#include "openmc/bank.h"
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/simulation.h"
|
||||
#include "openmc/message_passing.h"
|
||||
#include "openmc/simulation.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
|
@ -15,20 +16,20 @@ namespace openmc {
|
|||
|
||||
namespace simulation {
|
||||
|
||||
std::vector<Particle::Bank> source_bank;
|
||||
vector<SourceSite> source_bank;
|
||||
|
||||
SharedArray<Particle::Bank> surf_source_bank;
|
||||
SharedArray<SourceSite> surf_source_bank;
|
||||
|
||||
// The fission bank is allocated as a SharedArray, rather than a vector, as it will
|
||||
// be shared by all threads in the simulation. It will be allocated to a fixed
|
||||
// maximum capacity in the init_fission_bank() function. Then, Elements will be
|
||||
// added to it by using SharedArray's special thread_safe_append() function.
|
||||
SharedArray<Particle::Bank> fission_bank;
|
||||
SharedArray<SourceSite> fission_bank;
|
||||
|
||||
// Each entry in this vector corresponds to the number of progeny produced
|
||||
// this generation for the particle located at that index. This vector is
|
||||
// used to efficiently sort the fission bank after each iteration.
|
||||
std::vector<int64_t> progeny_per_particle;
|
||||
vector<int64_t> progeny_per_particle;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
@ -79,8 +80,8 @@ void sort_fission_bank()
|
|||
// We need a scratch vector to make permutation of the fission bank into
|
||||
// sorted order easy. Under normal usage conditions, the fission bank is
|
||||
// over provisioned, so we can use that as scratch space.
|
||||
Particle::Bank* sorted_bank;
|
||||
std::vector<Particle::Bank> sorted_bank_holder;
|
||||
SourceSite* sorted_bank;
|
||||
vector<SourceSite> sorted_bank_holder;
|
||||
|
||||
// If there is not enough space, allocate a temporary vector and point to it
|
||||
if (simulation::fission_bank.size() > simulation::fission_bank.capacity() / 2) {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void
|
|||
TranslationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
// TODO: off-by-one on surface indices throughout this function.
|
||||
int i_particle_surf = std::abs(p.surface_) - 1;
|
||||
int i_particle_surf = std::abs(p.surface()) - 1;
|
||||
|
||||
// Figure out which of the two BC surfaces were struck then find the
|
||||
// particle's new location and surface.
|
||||
|
|
@ -121,10 +121,10 @@ TranslationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
int new_surface;
|
||||
if (i_particle_surf == i_surf_) {
|
||||
new_r = p.r() + translation_;
|
||||
new_surface = p.surface_ > 0 ? j_surf_ + 1 : -(j_surf_ + 1);
|
||||
new_surface = p.surface() > 0 ? j_surf_ + 1 : -(j_surf_ + 1);
|
||||
} else if (i_particle_surf == j_surf_) {
|
||||
new_r = p.r() - translation_;
|
||||
new_surface = p.surface_ > 0 ? i_surf_ + 1 : -(i_surf_ + 1);
|
||||
new_surface = p.surface() > 0 ? i_surf_ + 1 : -(i_surf_ + 1);
|
||||
} else {
|
||||
throw std::runtime_error("Called BoundaryCondition::handle_particle after "
|
||||
"hitting a surface, but that surface is not recognized by the BC.");
|
||||
|
|
@ -222,7 +222,7 @@ void
|
|||
RotationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
// TODO: off-by-one on surface indices throughout this function.
|
||||
int i_particle_surf = std::abs(p.surface_) - 1;
|
||||
int i_particle_surf = std::abs(p.surface()) - 1;
|
||||
|
||||
// Figure out which of the two BC surfaces were struck to figure out if a
|
||||
// forward or backward rotation is required. Specify the other surface as
|
||||
|
|
@ -231,10 +231,10 @@ RotationalPeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
int new_surface;
|
||||
if (i_particle_surf == i_surf_) {
|
||||
theta = angle_;
|
||||
new_surface = p.surface_ > 0 ? -(j_surf_ + 1) : j_surf_ + 1;
|
||||
new_surface = p.surface() > 0 ? -(j_surf_ + 1) : j_surf_ + 1;
|
||||
} else if (i_particle_surf == j_surf_) {
|
||||
theta = -angle_;
|
||||
new_surface = p.surface_ > 0 ? -(i_surf_ + 1) : i_surf_ + 1;
|
||||
new_surface = p.surface() > 0 ? -(i_surf_ + 1) : i_surf_ + 1;
|
||||
} else {
|
||||
throw std::runtime_error("Called BoundaryCondition::handle_particle after "
|
||||
"hitting a surface, but that surface is not recognized by the BC.");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace data {
|
|||
|
||||
xt::xtensor<double, 1> ttb_e_grid;
|
||||
xt::xtensor<double, 1> ttb_k_grid;
|
||||
std::vector<Bremsstrahlung> ttb;
|
||||
vector<Bremsstrahlung> ttb;
|
||||
|
||||
} // namespace data
|
||||
|
||||
|
|
@ -28,20 +28,22 @@ std::vector<Bremsstrahlung> ttb;
|
|||
|
||||
void thick_target_bremsstrahlung(Particle& p, double* E_lost)
|
||||
{
|
||||
if (p.material_ == MATERIAL_VOID) return;
|
||||
if (p.material() == MATERIAL_VOID)
|
||||
return;
|
||||
|
||||
int photon = static_cast<int>(Particle::Type::photon);
|
||||
if (p.E_ < settings::energy_cutoff[photon]) return;
|
||||
int photon = static_cast<int>(ParticleType::photon);
|
||||
if (p.E() < settings::energy_cutoff[photon])
|
||||
return;
|
||||
|
||||
// Get bremsstrahlung data for this material and particle type
|
||||
BremsstrahlungData* mat;
|
||||
if (p.type_ == Particle::Type::positron) {
|
||||
mat = &model::materials[p.material_]->ttb_->positron;
|
||||
if (p.type() == ParticleType::positron) {
|
||||
mat = &model::materials[p.material()]->ttb_->positron;
|
||||
} else {
|
||||
mat = &model::materials[p.material_]->ttb_->electron;
|
||||
mat = &model::materials[p.material()]->ttb_->electron;
|
||||
}
|
||||
|
||||
double e = std::log(p.E_);
|
||||
double e = std::log(p.E());
|
||||
auto n_e = data::ttb_e_grid.size();
|
||||
|
||||
// Find the lower bounding index of the incident electron energy
|
||||
|
|
@ -108,7 +110,7 @@ void thick_target_bremsstrahlung(Particle& p, double* E_lost)
|
|||
|
||||
if (w > settings::energy_cutoff[photon]) {
|
||||
// Create secondary photon
|
||||
p.create_secondary(p.wgt_, p.u(), w, Particle::Type::photon);
|
||||
p.create_secondary(p.wgt(), p.u(), w, ParticleType::photon);
|
||||
*E_lost += w;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
84
src/cell.cpp
84
src/cell.cpp
|
|
@ -33,10 +33,10 @@ namespace openmc {
|
|||
|
||||
namespace model {
|
||||
std::unordered_map<int32_t, int32_t> cell_map;
|
||||
std::vector<std::unique_ptr<Cell>> cells;
|
||||
vector<unique_ptr<Cell>> cells;
|
||||
|
||||
std::unordered_map<int32_t, int32_t> universe_map;
|
||||
std::vector<std::unique_ptr<Universe>> universes;
|
||||
vector<unique_ptr<Universe>> universes;
|
||||
} // namespace model
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -46,10 +46,10 @@ namespace model {
|
|||
//! operators.
|
||||
//==============================================================================
|
||||
|
||||
std::vector<int32_t>
|
||||
tokenize(const std::string region_spec) {
|
||||
vector<int32_t> tokenize(const std::string region_spec)
|
||||
{
|
||||
// Check for an empty region_spec first.
|
||||
std::vector<int32_t> tokens;
|
||||
vector<int32_t> tokens;
|
||||
if (region_spec.empty()) {
|
||||
return tokens;
|
||||
}
|
||||
|
|
@ -113,11 +113,10 @@ tokenize(const std::string region_spec) {
|
|||
//! This function uses the shunting-yard algorithm.
|
||||
//==============================================================================
|
||||
|
||||
std::vector<int32_t>
|
||||
generate_rpn(int32_t cell_id, std::vector<int32_t> infix)
|
||||
vector<int32_t> generate_rpn(int32_t cell_id, vector<int32_t> infix)
|
||||
{
|
||||
std::vector<int32_t> rpn;
|
||||
std::vector<int32_t> stack;
|
||||
vector<int32_t> rpn;
|
||||
vector<int32_t> stack;
|
||||
|
||||
for (int32_t token : infix) {
|
||||
if (token < OP_UNION) {
|
||||
|
|
@ -197,7 +196,7 @@ Universe::to_hdf5(hid_t universes_group) const
|
|||
|
||||
// Write the contained cells.
|
||||
if (cells_.size() > 0) {
|
||||
std::vector<int32_t> cell_ids;
|
||||
vector<int32_t> cell_ids;
|
||||
for (auto i_cell : cells_) cell_ids.push_back(model::cells[i_cell]->id_);
|
||||
write_dataset(group, "cells", cell_ids);
|
||||
}
|
||||
|
|
@ -333,8 +332,8 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
|
|||
// universe), more than one material (distribmats), and some materials may
|
||||
// be "void".
|
||||
if (material_present) {
|
||||
std::vector<std::string> mats
|
||||
{get_node_array<std::string>(cell_node, "material", true)};
|
||||
vector<std::string> mats {
|
||||
get_node_array<std::string>(cell_node, "material", true)};
|
||||
if (mats.size() > 0) {
|
||||
material_.reserve(mats.size());
|
||||
for (std::string mat : mats) {
|
||||
|
|
@ -563,7 +562,7 @@ CSGCell::to_hdf5(hid_t cell_group) const
|
|||
// Write fill information.
|
||||
if (type_ == Fill::MATERIAL) {
|
||||
write_dataset(group, "fill_type", "material");
|
||||
std::vector<int32_t> mat_ids;
|
||||
vector<int32_t> mat_ids;
|
||||
for (auto i_mat : material_) {
|
||||
if (i_mat != MATERIAL_VOID) {
|
||||
mat_ids.push_back(model::materials[i_mat]->id_);
|
||||
|
|
@ -577,7 +576,7 @@ CSGCell::to_hdf5(hid_t cell_group) const
|
|||
write_dataset(group, "material", mat_ids);
|
||||
}
|
||||
|
||||
std::vector<double> temps;
|
||||
vector<double> temps;
|
||||
for (auto sqrtkT_val : sqrtkT_)
|
||||
temps.push_back(sqrtkT_val * sqrtkT_val / K_BOLTZMANN);
|
||||
write_dataset(group, "temperature", temps);
|
||||
|
|
@ -590,7 +589,7 @@ CSGCell::to_hdf5(hid_t cell_group) const
|
|||
}
|
||||
if (!rotation_.empty()) {
|
||||
if (rotation_.size() == 12) {
|
||||
std::array<double, 3> rot {rotation_[9], rotation_[10], rotation_[11]};
|
||||
array<double, 3> rot {rotation_[9], rotation_[10], rotation_[11]};
|
||||
write_dataset(group, "rotation", rot);
|
||||
} else {
|
||||
write_dataset(group, "rotation", rotation_);
|
||||
|
|
@ -613,8 +612,8 @@ BoundingBox CSGCell::bounding_box_simple() const {
|
|||
return bbox;
|
||||
}
|
||||
|
||||
void CSGCell::apply_demorgan(std::vector<int32_t>::iterator start,
|
||||
std::vector<int32_t>::iterator stop)
|
||||
void CSGCell::apply_demorgan(
|
||||
vector<int32_t>::iterator start, vector<int32_t>::iterator stop)
|
||||
{
|
||||
while (start < stop) {
|
||||
if (*start < OP_UNION) { *start *= -1; }
|
||||
|
|
@ -624,9 +623,9 @@ void CSGCell::apply_demorgan(std::vector<int32_t>::iterator start,
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<int32_t>::iterator
|
||||
CSGCell::find_left_parenthesis(std::vector<int32_t>::iterator start,
|
||||
const std::vector<int32_t>& rpn) {
|
||||
vector<int32_t>::iterator CSGCell::find_left_parenthesis(
|
||||
vector<int32_t>::iterator start, const vector<int32_t>& rpn)
|
||||
{
|
||||
// start search at zero
|
||||
int parenthesis_level = 0;
|
||||
auto it = start;
|
||||
|
|
@ -657,12 +656,13 @@ CSGCell::find_left_parenthesis(std::vector<int32_t>::iterator start,
|
|||
return it;
|
||||
}
|
||||
|
||||
void CSGCell::remove_complement_ops(std::vector<int32_t>& rpn) {
|
||||
void CSGCell::remove_complement_ops(vector<int32_t>& rpn)
|
||||
{
|
||||
auto it = std::find(rpn.begin(), rpn.end(), OP_COMPLEMENT);
|
||||
while (it != rpn.end()) {
|
||||
// find the opening parenthesis (if any)
|
||||
auto left = find_left_parenthesis(it, rpn);
|
||||
std::vector<int32_t> tmp(left, it+1);
|
||||
vector<int32_t> tmp(left, it + 1);
|
||||
|
||||
// apply DeMorgan's law to any surfaces/operators between these
|
||||
// positions in the RPN
|
||||
|
|
@ -674,11 +674,12 @@ void CSGCell::remove_complement_ops(std::vector<int32_t>& rpn) {
|
|||
}
|
||||
}
|
||||
|
||||
BoundingBox CSGCell::bounding_box_complex(std::vector<int32_t> rpn) {
|
||||
BoundingBox CSGCell::bounding_box_complex(vector<int32_t> rpn)
|
||||
{
|
||||
// remove complements by adjusting surface signs and operators
|
||||
remove_complement_ops(rpn);
|
||||
|
||||
std::vector<BoundingBox> stack(rpn.size());
|
||||
vector<BoundingBox> stack(rpn.size());
|
||||
int i_stack = -1;
|
||||
|
||||
for (auto& token : rpn) {
|
||||
|
|
@ -731,7 +732,7 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const
|
|||
{
|
||||
// Make a stack of booleans. We don't know how big it needs to be, but we do
|
||||
// know that rpn.size() is an upper-bound.
|
||||
std::vector<bool> stack(rpn_.size());
|
||||
vector<bool> stack(rpn_.size());
|
||||
int i_stack = -1;
|
||||
|
||||
for (int32_t token : rpn_) {
|
||||
|
|
@ -787,9 +788,9 @@ DAGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) cons
|
|||
Expects(p);
|
||||
// if we've changed direction or we're not on a surface,
|
||||
// reset the history and update last direction
|
||||
if (u != p->last_dir_ || on_surface == 0) {
|
||||
p->history_.reset();
|
||||
p->last_dir_ = u;
|
||||
if (u != p->last_dir() || on_surface == 0) {
|
||||
p->history().reset();
|
||||
p->last_dir() = u;
|
||||
}
|
||||
|
||||
moab::ErrorCode rval;
|
||||
|
|
@ -798,7 +799,7 @@ DAGCell::distance(Position r, Direction u, int32_t on_surface, Particle* p) cons
|
|||
double dist;
|
||||
double pnt[3] = {r.x, r.y, r.z};
|
||||
double dir[3] = {u.x, u.y, u.z};
|
||||
rval = dagmc_ptr_->ray_fire(vol, pnt, dir, hit_surf, dist, &p->history_);
|
||||
rval = dagmc_ptr_->ray_fire(vol, pnt, dir, hit_surf, dist, &p->history());
|
||||
MB_CHK_ERR_CONT(rval);
|
||||
int surf_idx;
|
||||
if (hit_surf != 0) {
|
||||
|
|
@ -945,8 +946,8 @@ UniversePartitioner::UniversePartitioner(const Universe& univ)
|
|||
}
|
||||
}
|
||||
|
||||
const std::vector<int32_t>&
|
||||
UniversePartitioner::get_cells(Position r, Direction u) const
|
||||
const vector<int32_t>& UniversePartitioner::get_cells(
|
||||
Position r, Direction u) const
|
||||
{
|
||||
// Perform a binary search for the partition containing the given coordinates.
|
||||
int left = 0;
|
||||
|
|
@ -998,7 +999,7 @@ void read_cells(pugi::xml_node node)
|
|||
// Loop over XML cell elements and populate the array.
|
||||
model::cells.reserve(n_cells);
|
||||
for (pugi::xml_node cell_node : node.children("cell")) {
|
||||
model::cells.push_back(std::make_unique<CSGCell>(cell_node));
|
||||
model::cells.push_back(make_unique<CSGCell>(cell_node));
|
||||
}
|
||||
|
||||
// Fill the cell map.
|
||||
|
|
@ -1017,7 +1018,7 @@ void read_cells(pugi::xml_node node)
|
|||
int32_t uid = model::cells[i]->universe_;
|
||||
auto it = model::universe_map.find(uid);
|
||||
if (it == model::universe_map.end()) {
|
||||
model::universes.push_back(std::make_unique<Universe>());
|
||||
model::universes.push_back(make_unique<Universe>());
|
||||
model::universes.back()->id_ = uid;
|
||||
model::universes.back()->cells_.push_back(i);
|
||||
model::universe_map[uid] = model::universes.size() - 1;
|
||||
|
|
@ -1175,11 +1176,10 @@ openmc_cell_set_name(int32_t index, const char* name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
std::unordered_map<int32_t, std::vector<int32_t>>
|
||||
Cell::get_contained_cells() const {
|
||||
std::unordered_map<int32_t, std::vector<int32_t>> contained_cells;
|
||||
std::vector<ParentCell> parent_cells;
|
||||
std::unordered_map<int32_t, vector<int32_t>> Cell::get_contained_cells() const
|
||||
{
|
||||
std::unordered_map<int32_t, vector<int32_t>> contained_cells;
|
||||
vector<ParentCell> parent_cells;
|
||||
|
||||
// if this cell is filled w/ a material, it contains no other cells
|
||||
if (type_ != Fill::MATERIAL) {
|
||||
|
|
@ -1190,9 +1190,9 @@ Cell::get_contained_cells() const {
|
|||
}
|
||||
|
||||
//! Get all cells within this cell
|
||||
void
|
||||
Cell::get_contained_cells_inner(std::unordered_map<int32_t, std::vector<int32_t>>& contained_cells,
|
||||
std::vector<ParentCell>& parent_cells) const
|
||||
void Cell::get_contained_cells_inner(
|
||||
std::unordered_map<int32_t, vector<int32_t>>& contained_cells,
|
||||
vector<ParentCell>& parent_cells) const
|
||||
{
|
||||
|
||||
// filled by material, determine instance based on parent cells
|
||||
|
|
@ -1285,7 +1285,7 @@ openmc_extend_cells(int32_t n, int32_t* index_start, int32_t* index_end)
|
|||
if (index_start) *index_start = model::cells.size();
|
||||
if (index_end) *index_end = model::cells.size() + n - 1;
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
model::cells.push_back(std::make_unique<CSGCell>());
|
||||
model::cells.push_back(make_unique<CSGCell>());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "openmc/cmfd_solver.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef _OPENMP
|
||||
|
|
@ -9,14 +8,15 @@
|
|||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include "openmc/bank.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/mesh.h"
|
||||
#include "openmc/message_passing.h"
|
||||
#include "openmc/tallies/filter_energy.h"
|
||||
#include "openmc/tallies/filter_mesh.h"
|
||||
#include "openmc/tallies/tally.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -26,9 +26,9 @@ namespace cmfd {
|
|||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
std::vector<int> indptr;
|
||||
vector<int> indptr;
|
||||
|
||||
std::vector<int> indices;
|
||||
vector<int> indices;
|
||||
|
||||
int dim;
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ int use_all_threads;
|
|||
|
||||
StructuredMesh* mesh;
|
||||
|
||||
std::vector<double> egrid;
|
||||
vector<double> egrid;
|
||||
|
||||
double norm;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ xt::xtensor<double, 1> count_bank_sites(xt::xtensor<int, 1>& bins, bool* outside
|
|||
{
|
||||
// Determine shape of array for counts
|
||||
std::size_t cnt_size = cmfd::nx * cmfd::ny * cmfd::nz * cmfd::ng;
|
||||
std::vector<std::size_t> cnt_shape = {cnt_size};
|
||||
vector<std::size_t> cnt_shape = {cnt_size};
|
||||
|
||||
// Create array of zeros
|
||||
xt::xarray<double> cnt {cnt_shape, 0.0};
|
||||
|
|
@ -299,7 +299,7 @@ int cmfd_linsolver_1g(const double* A_data, const double* b, double* x,
|
|||
double err = 0.0;
|
||||
|
||||
// Copy over x vector
|
||||
std::vector<double> tmpx {x, x+cmfd::dim};
|
||||
vector<double> tmpx {x, x + cmfd::dim};
|
||||
|
||||
// Perform red/black Gauss-Seidel iterations
|
||||
for (int irb = 0; irb < 2; irb++) {
|
||||
|
|
@ -366,7 +366,7 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x,
|
|||
double err = 0.0;
|
||||
|
||||
// Copy over x vector
|
||||
std::vector<double> tmpx {x, x+cmfd::dim};
|
||||
vector<double> tmpx {x, x + cmfd::dim};
|
||||
|
||||
// Perform red/black Gauss-Seidel iterations
|
||||
for (int irb = 0; irb < 2; irb++) {
|
||||
|
|
@ -458,7 +458,7 @@ int cmfd_linsolver_ng(const double* A_data, const double* b, double* x,
|
|||
double err = 0.0;
|
||||
|
||||
// Copy over x vector
|
||||
std::vector<double> tmpx {x, x+cmfd::dim};
|
||||
vector<double> tmpx {x, x + cmfd::dim};
|
||||
|
||||
// Loop around matrix rows
|
||||
for (int irow = 0; irow < cmfd::dim; irow++) {
|
||||
|
|
@ -554,7 +554,7 @@ int openmc_run_linsolver(const double* A_data, const double* b, double* x,
|
|||
|
||||
void free_memory_cmfd()
|
||||
{
|
||||
// Clear std::vectors
|
||||
// Clear vectors
|
||||
cmfd::indptr.clear();
|
||||
cmfd::indices.clear();
|
||||
cmfd::egrid.clear();
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ namespace openmc {
|
|||
namespace data {
|
||||
|
||||
std::map<LibraryKey, std::size_t> library_map;
|
||||
std::vector<Library> libraries;
|
||||
|
||||
vector<Library> libraries;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -182,16 +181,15 @@ void read_cross_sections_xml()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
read_ce_cross_sections(const std::vector<std::vector<double>>& nuc_temps,
|
||||
const std::vector<std::vector<double>>& thermal_temps)
|
||||
void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
||||
const vector<vector<double>>& thermal_temps)
|
||||
{
|
||||
std::unordered_set<std::string> already_read;
|
||||
|
||||
// Construct a vector of nuclide names because we haven't loaded nuclide data
|
||||
// yet, but we need to know the name of the i-th nuclide
|
||||
std::vector<std::string> nuclide_names(data::nuclide_map.size());
|
||||
std::vector<std::string> thermal_names(data::thermal_scatt_map.size());
|
||||
vector<std::string> nuclide_names(data::nuclide_map.size());
|
||||
vector<std::string> thermal_names(data::thermal_scatt_map.size());
|
||||
for (const auto& kv : data::nuclide_map) {
|
||||
nuclide_names[kv.second] = kv.first;
|
||||
}
|
||||
|
|
@ -238,8 +236,8 @@ read_ce_cross_sections(const std::vector<std::vector<double>>& nuc_temps,
|
|||
|
||||
// Read thermal scattering data from HDF5
|
||||
hid_t group = open_group(file_id, name.c_str());
|
||||
data::thermal_scatt.push_back(std::make_unique<ThermalScattering>(
|
||||
group, thermal_temps[i_table]));
|
||||
data::thermal_scatt.push_back(
|
||||
make_unique<ThermalScattering>(group, thermal_temps[i_table]));
|
||||
close_group(group);
|
||||
file_close(file_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ void load_dagmc_geometry()
|
|||
dagmcMetaData DMD(model::DAG, false, false);
|
||||
DMD.load_property_data();
|
||||
|
||||
std::vector<std::string> keywords {"temp"};
|
||||
vector<std::string> keywords {"temp"};
|
||||
std::map<std::string, std::string> dum;
|
||||
std::string delimiters = ":/";
|
||||
rval = model::DAG->parse_properties(keywords, dum, delimiters.c_str());
|
||||
|
|
@ -211,7 +211,7 @@ void load_dagmc_geometry()
|
|||
// Populate the Universe vector and dict
|
||||
auto it = model::universe_map.find(dagmc_univ_id);
|
||||
if (it == model::universe_map.end()) {
|
||||
model::universes.push_back(std::make_unique<Universe>());
|
||||
model::universes.push_back(make_unique<Universe>());
|
||||
model::universes.back()->id_ = dagmc_univ_id;
|
||||
model::universes.back()->cells_.push_back(i);
|
||||
model::universe_map[dagmc_univ_id] = model::universes.size() - 1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "openmc/distribution_angle.h"
|
||||
|
||||
#include <cmath> // for abs, copysign
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "xtensor/xarray.hpp"
|
||||
#include "xtensor/xview.hpp"
|
||||
|
|
@ -10,6 +9,7 @@
|
|||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/search.h"
|
||||
#include "openmc/vector.h" // for vector
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ AngleDistribution::AngleDistribution(hid_t group)
|
|||
int n_energy = energy_.size();
|
||||
|
||||
// Get outgoing energy distribution data
|
||||
std::vector<int> offsets;
|
||||
std::vector<int> interp;
|
||||
vector<int> offsets;
|
||||
vector<int> interp;
|
||||
hid_t dset = open_dataset(group, "mu");
|
||||
read_attribute(dset, "offsets", offsets);
|
||||
read_attribute(dset, "interpolation", interp);
|
||||
|
|
@ -47,9 +47,9 @@ AngleDistribution::AngleDistribution(hid_t group)
|
|||
auto xs = xt::view(temp, 0, xt::range(j, j+n));
|
||||
auto ps = xt::view(temp, 1, xt::range(j, j+n));
|
||||
auto cs = xt::view(temp, 2, xt::range(j, j+n));
|
||||
std::vector<double> x {xs.begin(), xs.end()};
|
||||
std::vector<double> p {ps.begin(), ps.end()};
|
||||
std::vector<double> c {cs.begin(), cs.end()};
|
||||
vector<double> x {xs.begin(), xs.end()};
|
||||
vector<double> p {ps.begin(), ps.end()};
|
||||
vector<double> c {cs.begin(), cs.end()};
|
||||
|
||||
// To get answers that match ACE data, for now we still use the tabulated
|
||||
// CDF values that were passed through to the HDF5 library. At a later
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ ContinuousTabular::ContinuousTabular(hid_t group)
|
|||
|
||||
// Get outgoing energy distribution data
|
||||
dset = open_dataset(group, "distribution");
|
||||
std::vector<int> offsets;
|
||||
std::vector<int> interp;
|
||||
std::vector<int> n_discrete;
|
||||
vector<int> offsets;
|
||||
vector<int> interp;
|
||||
vector<int> n_discrete;
|
||||
read_attribute(dset, "offsets", offsets);
|
||||
read_attribute(dset, "interpolation", interp);
|
||||
read_attribute(dset, "n_discrete_lines", n_discrete);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ CylindricalIndependent::CylindricalIndependent(pugi::xml_node node)
|
|||
// If no distribution was specified, default to a single point at r=0
|
||||
double x[] {0.0};
|
||||
double p[] {1.0};
|
||||
r_ = std::make_unique<Discrete>(x, p, 1);
|
||||
r_ = make_unique<Discrete>(x, p, 1);
|
||||
}
|
||||
|
||||
// Read distribution for phi-coordinate
|
||||
|
|
@ -76,7 +76,7 @@ CylindricalIndependent::CylindricalIndependent(pugi::xml_node node)
|
|||
// If no distribution was specified, default to a single point at phi=0
|
||||
double x[] {0.0};
|
||||
double p[] {1.0};
|
||||
phi_ = std::make_unique<Discrete>(x, p, 1);
|
||||
phi_ = make_unique<Discrete>(x, p, 1);
|
||||
}
|
||||
|
||||
// Read distribution for z-coordinate
|
||||
|
|
@ -87,7 +87,7 @@ CylindricalIndependent::CylindricalIndependent(pugi::xml_node node)
|
|||
// If no distribution was specified, default to a single point at z=0
|
||||
double x[] {0.0};
|
||||
double p[] {1.0};
|
||||
z_ = std::make_unique<Discrete>(x, p, 1);
|
||||
z_ = make_unique<Discrete>(x, p, 1);
|
||||
}
|
||||
|
||||
// Read cylinder center coordinates
|
||||
|
|
@ -129,7 +129,7 @@ SphericalIndependent::SphericalIndependent(pugi::xml_node node)
|
|||
// If no distribution was specified, default to a single point at r=0
|
||||
double x[] {0.0};
|
||||
double p[] {1.0};
|
||||
r_ = std::make_unique<Discrete>(x, p, 1);
|
||||
r_ = make_unique<Discrete>(x, p, 1);
|
||||
}
|
||||
|
||||
// Read distribution for theta-coordinate
|
||||
|
|
@ -140,7 +140,7 @@ SphericalIndependent::SphericalIndependent(pugi::xml_node node)
|
|||
// If no distribution was specified, default to a single point at theta=0
|
||||
double x[] {0.0};
|
||||
double p[] {1.0};
|
||||
theta_ = std::make_unique<Discrete>(x, p, 1);
|
||||
theta_ = make_unique<Discrete>(x, p, 1);
|
||||
}
|
||||
|
||||
// Read distribution for phi-coordinate
|
||||
|
|
@ -151,7 +151,7 @@ SphericalIndependent::SphericalIndependent(pugi::xml_node node)
|
|||
// If no distribution was specified, default to a single point at phi=0
|
||||
double x[] {0.0};
|
||||
double p[] {1.0};
|
||||
phi_ = std::make_unique<Discrete>(x, p, 1);
|
||||
phi_ = make_unique<Discrete>(x, p, 1);
|
||||
}
|
||||
|
||||
// Read sphere center coordinates
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "xtensor/xtensor.hpp"
|
||||
#include "xtensor/xview.hpp"
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/bank.h"
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
|
|
@ -17,11 +18,10 @@
|
|||
#include "openmc/search.h"
|
||||
#include "openmc/settings.h"
|
||||
#include "openmc/simulation.h"
|
||||
#include "openmc/timer.h"
|
||||
#include "openmc/tallies/tally.h"
|
||||
#include "openmc/timer.h"
|
||||
|
||||
#include <algorithm> // for min
|
||||
#include <array>
|
||||
#include <cmath> // for sqrt, abs, pow
|
||||
#include <iterator> // for back_inserter
|
||||
#include <string>
|
||||
|
|
@ -36,8 +36,8 @@ namespace openmc {
|
|||
namespace simulation {
|
||||
|
||||
double keff_generation;
|
||||
std::array<double, 2> k_sum;
|
||||
std::vector<double> entropy;
|
||||
array<double, 2> k_sum;
|
||||
vector<double> entropy;
|
||||
xt::xtensor<double, 1> source_frac;
|
||||
|
||||
} // namespace simulation
|
||||
|
|
@ -137,7 +137,7 @@ void synchronize_bank()
|
|||
// Allocate temporary source bank -- we don't really know how many fission
|
||||
// sites were created, so overallocate by a factor of 3
|
||||
int64_t index_temp = 0;
|
||||
std::vector<Particle::Bank> temp_sites(3*simulation::work_per_rank);
|
||||
vector<SourceSite> temp_sites(3 * simulation::work_per_rank);
|
||||
|
||||
for (int64_t i = 0; i < simulation::fission_bank.size(); i++ ) {
|
||||
const auto& site = simulation::fission_bank[i];
|
||||
|
|
@ -214,7 +214,7 @@ void synchronize_bank()
|
|||
// SEND BANK SITES TO NEIGHBORS
|
||||
|
||||
int64_t index_local = 0;
|
||||
std::vector<MPI_Request> requests;
|
||||
vector<MPI_Request> requests;
|
||||
|
||||
if (start < settings::n_particles) {
|
||||
// Determine the index of the processor which has the first part of the
|
||||
|
|
@ -230,7 +230,7 @@ void synchronize_bank()
|
|||
// process
|
||||
if (neighbor != mpi::rank) {
|
||||
requests.emplace_back();
|
||||
MPI_Isend(&temp_sites[index_local], static_cast<int>(n), mpi::bank,
|
||||
MPI_Isend(&temp_sites[index_local], static_cast<int>(n), mpi::source_site,
|
||||
neighbor, mpi::rank, mpi::intracomm, &requests.back());
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ void synchronize_bank()
|
|||
// asynchronous receive for the source sites
|
||||
|
||||
requests.emplace_back();
|
||||
MPI_Irecv(&simulation::source_bank[index_local], static_cast<int>(n), mpi::bank,
|
||||
MPI_Irecv(&simulation::source_bank[index_local], static_cast<int>(n), mpi::source_site,
|
||||
neighbor, neighbor, mpi::intracomm, &requests.back());
|
||||
|
||||
} else {
|
||||
|
|
@ -372,7 +372,7 @@ int openmc_get_keff(double* k_combined)
|
|||
// Copy estimates of k-effective and its variance (not variance of the mean)
|
||||
const auto& gt = simulation::global_tallies;
|
||||
|
||||
std::array<double, 3> kv {};
|
||||
array<double, 3> kv {};
|
||||
xt::xtensor<double, 2> cov = xt::zeros<double>({3, 3});
|
||||
kv[0] = gt(GlobalTally::K_COLLISION, TallyResult::SUM) / n;
|
||||
kv[1] = gt(GlobalTally::K_ABSORPTION, TallyResult::SUM) / n;
|
||||
|
|
@ -427,7 +427,7 @@ int openmc_get_keff(double* k_combined)
|
|||
|
||||
// Initialize variables
|
||||
double g = 0.0;
|
||||
std::array<double, 3> S {};
|
||||
array<double, 3> S {};
|
||||
|
||||
for (int l = 0; l < 3; ++l) {
|
||||
// Permutations of estimates
|
||||
|
|
@ -601,7 +601,7 @@ void write_eigenvalue_hdf5(hid_t group)
|
|||
write_dataset(group, "k_col_abs", simulation::k_col_abs);
|
||||
write_dataset(group, "k_col_tra", simulation::k_col_tra);
|
||||
write_dataset(group, "k_abs_tra", simulation::k_abs_tra);
|
||||
std::array<double, 2> k_combined;
|
||||
array<double, 2> k_combined;
|
||||
openmc_get_keff(k_combined.data());
|
||||
write_dataset(group, "k_combined", k_combined);
|
||||
}
|
||||
|
|
|
|||
19
src/endf.cpp
19
src/endf.cpp
|
|
@ -1,7 +1,6 @@
|
|||
#include "openmc/endf.h"
|
||||
|
||||
#include <algorithm> // for copy
|
||||
#include <array>
|
||||
#include <cmath> // for log, exp
|
||||
#include <iterator> // for back_inserter
|
||||
#include <stdexcept> // for runtime_error
|
||||
|
|
@ -9,6 +8,7 @@
|
|||
#include "xtensor/xarray.hpp"
|
||||
#include "xtensor/xview.hpp"
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/search.h"
|
||||
|
|
@ -77,21 +77,20 @@ bool is_inelastic_scatter(int mt)
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Function1D>
|
||||
read_function(hid_t group, const char* name)
|
||||
unique_ptr<Function1D> read_function(hid_t group, const char* name)
|
||||
{
|
||||
hid_t dset = open_dataset(group, name);
|
||||
std::string func_type;
|
||||
read_attribute(dset, "type", func_type);
|
||||
std::unique_ptr<Function1D> func;
|
||||
unique_ptr<Function1D> func;
|
||||
if (func_type == "Tabulated1D") {
|
||||
func = std::make_unique<Tabulated1D>(dset);
|
||||
func = make_unique<Tabulated1D>(dset);
|
||||
} else if (func_type == "Polynomial") {
|
||||
func = std::make_unique<Polynomial>(dset);
|
||||
func = make_unique<Polynomial>(dset);
|
||||
} else if (func_type == "CoherentElastic") {
|
||||
func = std::make_unique<CoherentElasticXS>(dset);
|
||||
func = make_unique<CoherentElasticXS>(dset);
|
||||
} else if (func_type == "IncoherentElastic") {
|
||||
func = std::make_unique<IncoherentElasticXS>(dset);
|
||||
func = make_unique<IncoherentElasticXS>(dset);
|
||||
} else {
|
||||
throw std::runtime_error{"Unknown function type " + func_type +
|
||||
" for dataset " + object_name(dset)};
|
||||
|
|
@ -133,7 +132,7 @@ Tabulated1D::Tabulated1D(hid_t dset)
|
|||
// Change 1-indexing to 0-indexing
|
||||
for (auto& b : nbt_) --b;
|
||||
|
||||
std::vector<int> int_temp;
|
||||
vector<int> int_temp;
|
||||
read_attribute(dset, "interpolation", int_temp);
|
||||
|
||||
// Convert vector of ints into Interpolation
|
||||
|
|
@ -245,7 +244,7 @@ double CoherentElasticXS::operator()(double E) const
|
|||
|
||||
IncoherentElasticXS::IncoherentElasticXS(hid_t dset)
|
||||
{
|
||||
std::array<double, 2> tmp;
|
||||
array<double, 2> tmp;
|
||||
read_dataset(dset, nullptr, tmp);
|
||||
bound_xs_ = tmp[0];
|
||||
debye_waller_ = tmp[1];
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ SharedArray<EventQueueItem> advance_particle_queue;
|
|||
SharedArray<EventQueueItem> surface_crossing_queue;
|
||||
SharedArray<EventQueueItem> collision_queue;
|
||||
|
||||
std::vector<Particle> particles;
|
||||
vector<Particle> particles;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
|
|
@ -50,7 +50,8 @@ void free_event_queues(void)
|
|||
void dispatch_xs_event(int64_t buffer_idx)
|
||||
{
|
||||
Particle& p = simulation::particles[buffer_idx];
|
||||
if (p.material_ == MATERIAL_VOID || !model::materials[p.material_]->fissionable_) {
|
||||
if (p.material() == MATERIAL_VOID ||
|
||||
!model::materials[p.material()]->fissionable_) {
|
||||
simulation::calculate_nonfuel_xs_queue.thread_safe_append({p, buffer_idx});
|
||||
} else {
|
||||
simulation::calculate_fuel_xs_queue.thread_safe_append({p, buffer_idx});
|
||||
|
|
@ -109,7 +110,7 @@ void process_advance_particle_events()
|
|||
int64_t buffer_idx = simulation::advance_particle_queue[i].idx;
|
||||
Particle& p = simulation::particles[buffer_idx];
|
||||
p.event_advance();
|
||||
if (p.collision_distance_ > p.boundary_.distance) {
|
||||
if (p.collision_distance() > p.boundary().distance) {
|
||||
simulation::surface_crossing_queue.thread_safe_append({p, buffer_idx});
|
||||
} else {
|
||||
simulation::collision_queue.thread_safe_append({p, buffer_idx});
|
||||
|
|
@ -131,7 +132,7 @@ void process_surface_crossing_events()
|
|||
Particle& p = simulation::particles[buffer_idx];
|
||||
p.event_cross_surface();
|
||||
p.event_revive_from_secondary();
|
||||
if (p.alive_)
|
||||
if (p.alive())
|
||||
dispatch_xs_event(buffer_idx);
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +151,7 @@ void process_collision_events()
|
|||
Particle& p = simulation::particles[buffer_idx];
|
||||
p.event_collide();
|
||||
p.event_revive_from_secondary();
|
||||
if (p.alive_)
|
||||
if (p.alive())
|
||||
dispatch_xs_event(buffer_idx);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ int openmc_finalize()
|
|||
|
||||
// Free all MPI types
|
||||
#ifdef OPENMC_MPI
|
||||
if (mpi::bank != MPI_DATATYPE_NULL) MPI_Type_free(&mpi::bank);
|
||||
if (mpi::source_site != MPI_DATATYPE_NULL) MPI_Type_free(&mpi::source_site);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
158
src/geometry.cpp
158
src/geometry.cpp
|
|
@ -1,10 +1,9 @@
|
|||
#include "openmc/geometry.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/ostream.h>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
|
|
@ -27,7 +26,7 @@ namespace model {
|
|||
int root_universe {-1};
|
||||
int n_coord_levels;
|
||||
|
||||
std::vector<int64_t> overlap_check_count;
|
||||
vector<int64_t> overlap_check_count;
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -37,25 +36,25 @@ std::vector<int64_t> overlap_check_count;
|
|||
|
||||
bool check_cell_overlap(Particle& p, bool error)
|
||||
{
|
||||
int n_coord = p.n_coord_;
|
||||
int n_coord = p.n_coord();
|
||||
|
||||
// Loop through each coordinate level
|
||||
for (int j = 0; j < n_coord; j++) {
|
||||
Universe& univ = *model::universes[p.coord_[j].universe];
|
||||
Universe& univ = *model::universes[p.coord(j).universe];
|
||||
|
||||
// Loop through each cell on this level
|
||||
for (auto index_cell : univ.cells_) {
|
||||
Cell& c = *model::cells[index_cell];
|
||||
if (c.contains(p.coord_[j].r, p.coord_[j].u, p.surface_)) {
|
||||
if (index_cell != p.coord_[j].cell) {
|
||||
if (c.contains(p.coord(j).r, p.coord(j).u, p.surface())) {
|
||||
if (index_cell != p.coord(j).cell) {
|
||||
if (error) {
|
||||
fatal_error(fmt::format(
|
||||
"Overlapping cells detected: {}, {} on universe {}",
|
||||
c.id_, model::cells[p.coord_[j].cell]->id_, univ.id_));
|
||||
fatal_error(
|
||||
fmt::format("Overlapping cells detected: {}, {} on universe {}",
|
||||
c.id_, model::cells[p.coord(j).cell]->id_, univ.id_));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#pragma omp atomic
|
||||
#pragma omp atomic
|
||||
++model::overlap_check_count[index_cell];
|
||||
}
|
||||
}
|
||||
|
|
@ -78,15 +77,15 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
i_cell = *it;
|
||||
|
||||
// Make sure the search cell is in the same universe.
|
||||
int i_universe = p.coord_[p.n_coord_-1].universe;
|
||||
int i_universe = p.coord(p.n_coord() - 1).universe;
|
||||
if (model::cells[i_cell]->universe_ != i_universe) continue;
|
||||
|
||||
// Check if this cell contains the particle.
|
||||
Position r {p.r_local()};
|
||||
Direction u {p.u_local()};
|
||||
auto surf = p.surface_;
|
||||
auto surf = p.surface();
|
||||
if (model::cells[i_cell]->contains(r, u, surf)) {
|
||||
p.coord_[p.n_coord_-1].cell = i_cell;
|
||||
p.coord(p.n_coord() - 1).cell = i_cell;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -102,7 +101,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
}
|
||||
|
||||
// Check successively lower coordinate levels until finding material fill
|
||||
for (;;++p.n_coord_) {
|
||||
for (;;++p.n_coord()) {
|
||||
// If we did not attempt to use neighbor lists, i_cell is still C_NONE. In
|
||||
// that case, we should now do an exhaustive search to find the right value
|
||||
// of i_cell.
|
||||
|
|
@ -112,7 +111,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
// code below this conditional, we set i_cell back to C_NONE to indicate
|
||||
// that.
|
||||
if (i_cell == C_NONE) {
|
||||
int i_universe = p.coord_[p.n_coord_-1].universe;
|
||||
int i_universe = p.coord(p.n_coord() - 1).universe;
|
||||
const auto& univ {*model::universes[i_universe]};
|
||||
const auto& cells {
|
||||
!univ.partitioner_
|
||||
|
|
@ -124,15 +123,15 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
i_cell = *it;
|
||||
|
||||
// Make sure the search cell is in the same universe.
|
||||
int i_universe = p.coord_[p.n_coord_-1].universe;
|
||||
int i_universe = p.coord(p.n_coord() - 1).universe;
|
||||
if (model::cells[i_cell]->universe_ != i_universe) continue;
|
||||
|
||||
// Check if this cell contains the particle.
|
||||
Position r {p.r_local()};
|
||||
Direction u {p.u_local()};
|
||||
auto surf = p.surface_;
|
||||
auto surf = p.surface();
|
||||
if (model::cells[i_cell]->contains(r, u, surf)) {
|
||||
p.coord_[p.n_coord_-1].cell = i_cell;
|
||||
p.coord(p.n_coord() - 1).cell = i_cell;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -143,7 +142,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
}
|
||||
|
||||
// Announce the cell that the particle is entering.
|
||||
if (found && (settings::verbosity >= 10 || p.trace_)) {
|
||||
if (found && (settings::verbosity >= 10 || p.trace())) {
|
||||
auto msg = fmt::format(" Entering cell {}", model::cells[i_cell]->id_);
|
||||
write_message(msg, 1);
|
||||
}
|
||||
|
|
@ -155,34 +154,33 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
// Find the distribcell instance number.
|
||||
int offset = 0;
|
||||
if (c.distribcell_index_ >= 0) {
|
||||
for (int i = 0; i < p.n_coord_; i++) {
|
||||
const auto& c_i {*model::cells[p.coord_[i].cell]};
|
||||
for (int i = 0; i < p.n_coord(); i++) {
|
||||
const auto& c_i {*model::cells[p.coord(i).cell]};
|
||||
if (c_i.type_ == Fill::UNIVERSE) {
|
||||
offset += c_i.offset_[c.distribcell_index_];
|
||||
} else if (c_i.type_ == Fill::LATTICE) {
|
||||
auto& lat {*model::lattices[p.coord_[i + 1].lattice]};
|
||||
int i_xyz[3] {p.coord_[i + 1].lattice_x, p.coord_[i + 1].lattice_y,
|
||||
p.coord_[i + 1].lattice_z};
|
||||
auto& lat {*model::lattices[p.coord(i + 1).lattice]};
|
||||
const auto& i_xyz {p.coord(i + 1).lattice_i};
|
||||
if (lat.are_valid_indices(i_xyz)) {
|
||||
offset += lat.offset(c.distribcell_index_, i_xyz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p.cell_instance_ = offset;
|
||||
p.cell_instance() = offset;
|
||||
|
||||
// Set the material and temperature.
|
||||
p.material_last_ = p.material_;
|
||||
p.material_last() = p.material();
|
||||
if (c.material_.size() > 1) {
|
||||
p.material_ = c.material_[p.cell_instance_];
|
||||
p.material() = c.material_[p.cell_instance()];
|
||||
} else {
|
||||
p.material_ = c.material_[0];
|
||||
p.material() = c.material_[0];
|
||||
}
|
||||
p.sqrtkT_last_ = p.sqrtkT_;
|
||||
p.sqrtkT_last() = p.sqrtkT();
|
||||
if (c.sqrtkT_.size() > 1) {
|
||||
p.sqrtkT_ = c.sqrtkT_[p.cell_instance_];
|
||||
p.sqrtkT() = c.sqrtkT_[p.cell_instance()];
|
||||
} else {
|
||||
p.sqrtkT_ = c.sqrtkT_[0];
|
||||
p.sqrtkT() = c.sqrtkT_[0];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -192,7 +190,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
//! Found a lower universe, update this coord level then search the next.
|
||||
|
||||
// Set the lower coordinate level universe.
|
||||
auto& coord {p.coord_[p.n_coord_]};
|
||||
auto& coord {p.coord(p.n_coord())};
|
||||
coord.universe = c.fill_;
|
||||
|
||||
// Set the position and direction.
|
||||
|
|
@ -214,7 +212,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
Lattice& lat {*model::lattices[c.fill_]};
|
||||
|
||||
// Set the position and direction.
|
||||
auto& coord {p.coord_[p.n_coord_]};
|
||||
auto& coord {p.coord(p.n_coord())};
|
||||
coord.r = p.r_local();
|
||||
coord.u = p.u_local();
|
||||
|
||||
|
|
@ -227,16 +225,14 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
}
|
||||
|
||||
// Determine lattice indices.
|
||||
auto i_xyz = lat.get_indices(coord.r, coord.u);
|
||||
auto& i_xyz {coord.lattice_i};
|
||||
lat.get_indices(coord.r, coord.u, i_xyz);
|
||||
|
||||
// Get local position in appropriate lattice cell
|
||||
coord.r = lat.get_local_position(coord.r, i_xyz);
|
||||
|
||||
// Set lattice indices.
|
||||
coord.lattice = c.fill_;
|
||||
coord.lattice_x = i_xyz[0];
|
||||
coord.lattice_y = i_xyz[1];
|
||||
coord.lattice_z = i_xyz[2];
|
||||
|
||||
// Set the lower coordinate level universe.
|
||||
if (lat.are_valid_indices(i_xyz)) {
|
||||
|
|
@ -247,7 +243,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
} else {
|
||||
warning(fmt::format("Particle {} is outside lattice {} but the "
|
||||
"lattice has no defined outer universe.",
|
||||
p.id_, lat.id_));
|
||||
p.id(), lat.id_));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -265,13 +261,13 @@ bool neighbor_list_find_cell(Particle& p)
|
|||
{
|
||||
|
||||
// Reset all the deeper coordinate levels.
|
||||
for (int i = p.n_coord_; i < p.coord_.size(); i++) {
|
||||
p.coord_[i].reset();
|
||||
for (int i = p.n_coord(); i < model::n_coord_levels; i++) {
|
||||
p.coord(i).reset();
|
||||
}
|
||||
|
||||
// Get the cell this particle was in previously.
|
||||
auto coord_lvl = p.n_coord_ - 1;
|
||||
auto i_cell = p.coord_[coord_lvl].cell;
|
||||
auto coord_lvl = p.n_coord() - 1;
|
||||
auto i_cell = p.coord(coord_lvl).cell;
|
||||
Cell& c {*model::cells[i_cell]};
|
||||
|
||||
// Search for the particle in that cell's neighbor list. Return if we
|
||||
|
|
@ -285,21 +281,21 @@ bool neighbor_list_find_cell(Particle& p)
|
|||
// neighboring cell.
|
||||
found = find_cell_inner(p, nullptr);
|
||||
if (found)
|
||||
c.neighbors_.push_back(p.coord_[coord_lvl].cell);
|
||||
c.neighbors_.push_back(p.coord(coord_lvl).cell);
|
||||
return found;
|
||||
}
|
||||
|
||||
bool exhaustive_find_cell(Particle& p)
|
||||
{
|
||||
int i_universe = p.coord_[p.n_coord_-1].universe;
|
||||
int i_universe = p.coord(p.n_coord() - 1).universe;
|
||||
if (i_universe == C_NONE) {
|
||||
p.coord_[0].universe = model::root_universe;
|
||||
p.n_coord_ = 1;
|
||||
p.coord(0).universe = model::root_universe;
|
||||
p.n_coord() = 1;
|
||||
i_universe = model::root_universe;
|
||||
}
|
||||
// Reset all the deeper coordinate levels.
|
||||
for (int i = p.n_coord_; i < p.coord_.size(); i++) {
|
||||
p.coord_[i].reset();
|
||||
for (int i = p.n_coord(); i < model::n_coord_levels; i++) {
|
||||
p.coord(i).reset();
|
||||
}
|
||||
return find_cell_inner(p, nullptr);
|
||||
}
|
||||
|
|
@ -309,53 +305,54 @@ bool exhaustive_find_cell(Particle& p)
|
|||
void
|
||||
cross_lattice(Particle& p, const BoundaryInfo& boundary)
|
||||
{
|
||||
auto& coord {p.coord_[p.n_coord_ - 1]};
|
||||
auto& coord {p.coord(p.n_coord() - 1)};
|
||||
auto& lat {*model::lattices[coord.lattice]};
|
||||
|
||||
if (settings::verbosity >= 10 || p.trace_) {
|
||||
if (settings::verbosity >= 10 || p.trace()) {
|
||||
write_message(fmt::format(
|
||||
" Crossing lattice {}. Current position ({},{},{}). r={}",
|
||||
lat.id_, coord.lattice_x, coord.lattice_y, coord.lattice_z, p.r()), 1);
|
||||
lat.id_, coord.lattice_i[0], coord.lattice_i[1], coord.lattice_i[2], p.r()), 1);
|
||||
}
|
||||
|
||||
// Set the lattice indices.
|
||||
coord.lattice_x += boundary.lattice_translation[0];
|
||||
coord.lattice_y += boundary.lattice_translation[1];
|
||||
coord.lattice_z += boundary.lattice_translation[2];
|
||||
std::array<int, 3> i_xyz {coord.lattice_x, coord.lattice_y, coord.lattice_z};
|
||||
coord.lattice_i[0] += boundary.lattice_translation[0];
|
||||
coord.lattice_i[1] += boundary.lattice_translation[1];
|
||||
coord.lattice_i[2] += boundary.lattice_translation[2];
|
||||
|
||||
// Set the new coordinate position.
|
||||
const auto& upper_coord {p.coord_[p.n_coord_ - 2]};
|
||||
const auto& upper_coord {p.coord(p.n_coord() - 2)};
|
||||
const auto& cell {model::cells[upper_coord.cell]};
|
||||
Position r = upper_coord.r;
|
||||
r -= cell->translation_;
|
||||
if (!cell->rotation_.empty()) {
|
||||
r = r.rotate(cell->rotation_);
|
||||
}
|
||||
p.r_local() = lat.get_local_position(r, i_xyz);
|
||||
p.r_local() = lat.get_local_position(r, coord.lattice_i);
|
||||
|
||||
if (!lat.are_valid_indices(i_xyz)) {
|
||||
if (!lat.are_valid_indices(coord.lattice_i)) {
|
||||
// The particle is outside the lattice. Search for it from the base coords.
|
||||
p.n_coord_ = 1;
|
||||
p.n_coord() = 1;
|
||||
bool found = exhaustive_find_cell(p);
|
||||
if (!found && p.alive_) {
|
||||
if (!found && p.alive()) {
|
||||
p.mark_as_lost(fmt::format("Could not locate particle {} after "
|
||||
"crossing a lattice boundary", p.id_));
|
||||
"crossing a lattice boundary",
|
||||
p.id()));
|
||||
}
|
||||
|
||||
} else {
|
||||
// Find cell in next lattice element.
|
||||
p.coord_[p.n_coord_-1].universe = lat[i_xyz];
|
||||
p.coord(p.n_coord() - 1).universe = lat[coord.lattice_i];
|
||||
bool found = exhaustive_find_cell(p);
|
||||
|
||||
if (!found) {
|
||||
// A particle crossing the corner of a lattice tile may not be found. In
|
||||
// this case, search for it from the base coords.
|
||||
p.n_coord_ = 1;
|
||||
p.n_coord() = 1;
|
||||
bool found = exhaustive_find_cell(p);
|
||||
if (!found && p.alive_) {
|
||||
if (!found && p.alive()) {
|
||||
p.mark_as_lost(fmt::format("Could not locate particle {} after "
|
||||
"crossing a lattice boundary", p.id_));
|
||||
"crossing a lattice boundary",
|
||||
p.id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -369,40 +366,39 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
double d_lat = INFINITY;
|
||||
double d_surf = INFINITY;
|
||||
int32_t level_surf_cross;
|
||||
std::array<int, 3> level_lat_trans {};
|
||||
array<int, 3> level_lat_trans {};
|
||||
|
||||
// Loop over each coordinate level.
|
||||
for (int i = 0; i < p.n_coord_; i++) {
|
||||
const auto& coord {p.coord_[i]};
|
||||
Position r {coord.r};
|
||||
Direction u {coord.u};
|
||||
for (int i = 0; i < p.n_coord(); i++) {
|
||||
const auto& coord {p.coord(i)};
|
||||
const Position& r {coord.r};
|
||||
const Direction& u {coord.u};
|
||||
Cell& c {*model::cells[coord.cell]};
|
||||
|
||||
// Find the oncoming surface in this cell and the distance to it.
|
||||
auto surface_distance = c.distance(r, u, p.surface_, &p);
|
||||
auto surface_distance = c.distance(r, u, p.surface(), &p);
|
||||
d_surf = surface_distance.first;
|
||||
level_surf_cross = surface_distance.second;
|
||||
|
||||
// Find the distance to the next lattice tile crossing.
|
||||
if (coord.lattice != C_NONE) {
|
||||
auto& lat {*model::lattices[coord.lattice]};
|
||||
std::array<int, 3> i_xyz {coord.lattice_x, coord.lattice_y, coord.lattice_z};
|
||||
//TODO: refactor so both lattice use the same position argument (which
|
||||
//also means the lat.type attribute can be removed)
|
||||
std::pair<double, std::array<int, 3>> lattice_distance;
|
||||
std::pair<double, array<int, 3>> lattice_distance;
|
||||
switch (lat.type_) {
|
||||
case LatticeType::rect:
|
||||
lattice_distance = lat.distance(r, u, i_xyz);
|
||||
lattice_distance = lat.distance(r, u, coord.lattice_i);
|
||||
break;
|
||||
case LatticeType::hex:
|
||||
auto& cell_above {model::cells[p.coord_[i-1].cell]};
|
||||
Position r_hex {p.coord_[i-1].r};
|
||||
auto& cell_above {model::cells[p.coord(i - 1).cell]};
|
||||
Position r_hex {p.coord(i - 1).r};
|
||||
r_hex -= cell_above->translation_;
|
||||
if (coord.rotated) {
|
||||
r_hex = r_hex.rotate(cell_above->rotation_);
|
||||
}
|
||||
r_hex.z = coord.r.z;
|
||||
lattice_distance = lat.distance(r_hex, u, i_xyz);
|
||||
lattice_distance = lat.distance(r_hex, u, coord.lattice_i);
|
||||
break;
|
||||
}
|
||||
d_lat = lattice_distance.first;
|
||||
|
|
@ -410,7 +406,7 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
|
||||
if (d_lat < 0) {
|
||||
p.mark_as_lost(fmt::format(
|
||||
"Particle {} had a negative distance to a lattice boundary", p.id_));
|
||||
"Particle {} had a negative distance to a lattice boundary", p.id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -473,8 +469,8 @@ openmc_find_cell(const double* xyz, int32_t* index, int32_t* instance)
|
|||
return OPENMC_E_GEOMETRY;
|
||||
}
|
||||
|
||||
*index = p.coord_[p.n_coord_-1].cell;
|
||||
*instance = p.cell_instance_;
|
||||
*index = p.coord(p.n_coord() - 1).cell;
|
||||
*instance = p.cell_instance();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ partition_universes()
|
|||
if (dynamic_cast<const SurfaceZPlane*>(model::surfaces[i_surf].get())) {
|
||||
++n_zplanes;
|
||||
if (n_zplanes > 5) {
|
||||
univ->partitioner_ = std::make_unique<UniversePartitioner>(*univ);
|
||||
univ->partitioner_ = make_unique<UniversePartitioner>(*univ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -191,9 +191,8 @@ assign_temperatures()
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
get_temperatures(std::vector<std::vector<double>>& nuc_temps,
|
||||
std::vector<std::vector<double>>& thermal_temps)
|
||||
void get_temperatures(
|
||||
vector<vector<double>>& nuc_temps, vector<vector<double>>& thermal_temps)
|
||||
{
|
||||
for (const auto& cell : model::cells) {
|
||||
// Skip non-material cells.
|
||||
|
|
@ -205,7 +204,7 @@ get_temperatures(std::vector<std::vector<double>>& nuc_temps,
|
|||
if (i_material == MATERIAL_VOID) continue;
|
||||
|
||||
// Get temperature(s) of cell (rounding to nearest integer)
|
||||
std::vector<double> cell_temps;
|
||||
vector<double> cell_temps;
|
||||
if (cell->sqrtkT_.size() == 1) {
|
||||
double sqrtkT = cell->sqrtkT_[0];
|
||||
cell_temps.push_back(sqrtkT*sqrtkT / K_BOLTZMANN);
|
||||
|
|
@ -351,7 +350,7 @@ prepare_distribcell()
|
|||
// Search through universes for material cells and assign each one a
|
||||
// unique distribcell array index.
|
||||
int distribcell_index = 0;
|
||||
std::vector<int32_t> target_univ_ids;
|
||||
vector<int32_t> target_univ_ids;
|
||||
for (const auto& u : model::universes) {
|
||||
for (auto idx : u->cells_) {
|
||||
if (distribcells.find(idx) != distribcells.end()) {
|
||||
|
|
@ -495,8 +494,8 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset,
|
|||
// The target must be further down the geometry tree and contained in a fill
|
||||
// cell or lattice cell in this universe. Find which cell contains the
|
||||
// target.
|
||||
std::vector<std::int32_t>::const_reverse_iterator cell_it
|
||||
{search_univ.cells_.crbegin()};
|
||||
vector<std::int32_t>::const_reverse_iterator cell_it {
|
||||
search_univ.cells_.crbegin()};
|
||||
for (; cell_it != search_univ.cells_.crend(); ++cell_it) {
|
||||
Cell& c = *model::cells[*cell_it];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "openmc/hdf5_interface.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
|
@ -16,6 +15,7 @@
|
|||
#include "openmc/message_passing.h"
|
||||
#endif
|
||||
|
||||
#include "openmc/array.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -56,16 +56,15 @@ get_shape(hid_t obj_id, hsize_t* dims)
|
|||
H5Sclose(dspace);
|
||||
}
|
||||
|
||||
|
||||
std::vector<hsize_t> attribute_shape(hid_t obj_id, const char* name)
|
||||
vector<hsize_t> attribute_shape(hid_t obj_id, const char* name)
|
||||
{
|
||||
hid_t attr = H5Aopen(obj_id, name, H5P_DEFAULT);
|
||||
std::vector<hsize_t> shape = object_shape(attr);
|
||||
vector<hsize_t> shape = object_shape(attr);
|
||||
H5Aclose(attr);
|
||||
return shape;
|
||||
}
|
||||
|
||||
std::vector<hsize_t> object_shape(hid_t obj_id)
|
||||
vector<hsize_t> object_shape(hid_t obj_id)
|
||||
{
|
||||
// Get number of dimensions
|
||||
auto type = H5Iget_type(obj_id);
|
||||
|
|
@ -81,7 +80,7 @@ std::vector<hsize_t> object_shape(hid_t obj_id)
|
|||
int n = H5Sget_simple_extent_ndims(dspace);
|
||||
|
||||
// Get shape of array
|
||||
std::vector<hsize_t> shape(n);
|
||||
vector<hsize_t> shape(n);
|
||||
H5Sget_simple_extent_dims(dspace, shape.data(), nullptr);
|
||||
|
||||
// Free resources and return
|
||||
|
|
@ -337,8 +336,7 @@ get_groups(hid_t group_id, char* name[])
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
member_names(hid_t group_id, H5O_type_t type)
|
||||
vector<std::string> member_names(hid_t group_id, H5O_type_t type)
|
||||
{
|
||||
// Determine number of links in the group
|
||||
H5G_info_t info;
|
||||
|
|
@ -347,7 +345,7 @@ member_names(hid_t group_id, H5O_type_t type)
|
|||
// Iterate over links to get names
|
||||
H5O_info_t oinfo;
|
||||
size_t size;
|
||||
std::vector<std::string> names;
|
||||
vector<std::string> names;
|
||||
for (hsize_t i = 0; i < info.nlinks; ++i) {
|
||||
// Determine type of object (and skip non-group)
|
||||
H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo,
|
||||
|
|
@ -368,14 +366,12 @@ member_names(hid_t group_id, H5O_type_t type)
|
|||
return names;
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
group_names(hid_t group_id)
|
||||
vector<std::string> group_names(hid_t group_id)
|
||||
{
|
||||
return member_names(group_id, H5O_TYPE_GROUP);
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
dataset_names(hid_t group_id)
|
||||
vector<std::string> dataset_names(hid_t group_id)
|
||||
{
|
||||
return member_names(group_id, H5O_TYPE_DATASET);
|
||||
}
|
||||
|
|
@ -492,13 +488,13 @@ template<>
|
|||
void read_dataset(hid_t dset, xt::xarray<std::complex<double>>& arr, bool indep)
|
||||
{
|
||||
// Get shape of dataset
|
||||
std::vector<hsize_t> shape = object_shape(dset);
|
||||
vector<hsize_t> shape = object_shape(dset);
|
||||
|
||||
// Allocate new array to read data into
|
||||
std::size_t size = 1;
|
||||
for (const auto x : shape)
|
||||
size *= x;
|
||||
std::vector<std::complex<double>> buffer(size);
|
||||
vector<std::complex<double>> buffer(size);
|
||||
|
||||
// Read data from attribute
|
||||
read_complex(dset, nullptr, buffer.data(), indep);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
#include <cstddef>
|
||||
#include <cstdlib> // for getenv
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
|
|
@ -19,6 +17,7 @@
|
|||
#include "openmc/geometry_aux.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/material.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/message_passing.h"
|
||||
#include "openmc/mgxs_interface.h"
|
||||
#include "openmc/nuclide.h"
|
||||
|
|
@ -32,6 +31,7 @@
|
|||
#include "openmc/tallies/tally.h"
|
||||
#include "openmc/thermal.h"
|
||||
#include "openmc/timer.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#ifdef LIBMESH
|
||||
#include "libmesh/libmesh.h"
|
||||
|
|
@ -74,10 +74,12 @@ if (!settings::libmesh_init && !libMesh::initialized()) {
|
|||
// pass command line args, empty MPI communicator, and number of threads.
|
||||
// Because libMesh was not initialized, we assume that OpenMC is the primary
|
||||
// application and that its main MPI comm should be used.
|
||||
settings::libmesh_init = std::make_unique<libMesh::LibMeshInit>(argc, argv, comm, n_threads);
|
||||
settings::libmesh_init =
|
||||
make_unique<libMesh::LibMeshInit>(argc, argv, comm, n_threads);
|
||||
#else
|
||||
// pass command line args, empty MPI communicator, and number of threads
|
||||
settings::libmesh_init = std::make_unique<libMesh::LibMeshInit>(argc, argv, 0, n_threads);
|
||||
settings::libmesh_init =
|
||||
make_unique<libMesh::LibMeshInit>(argc, argv, 0, n_threads);
|
||||
#endif
|
||||
|
||||
settings::libmesh_comm = &(settings::libmesh_init->comm());
|
||||
|
|
@ -132,7 +134,7 @@ void initialize_mpi(MPI_Comm intracomm)
|
|||
mpi::master = (mpi::rank == 0);
|
||||
|
||||
// Create bank datatype
|
||||
Particle::Bank b;
|
||||
SourceSite b;
|
||||
MPI_Aint disp[9];
|
||||
MPI_Get_address(&b.r, &disp[0]);
|
||||
MPI_Get_address(&b.u, &disp[1]);
|
||||
|
|
@ -149,8 +151,8 @@ void initialize_mpi(MPI_Comm intracomm)
|
|||
|
||||
int blocks[] {3, 3, 1, 1, 1, 1, 1, 1, 1};
|
||||
MPI_Datatype types[] {MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT, MPI_INT, MPI_LONG, MPI_LONG};
|
||||
MPI_Type_create_struct(9, blocks, disp, types, &mpi::bank);
|
||||
MPI_Type_commit(&mpi::bank);
|
||||
MPI_Type_create_struct(9, blocks, disp, types, &mpi::source_site);
|
||||
MPI_Type_commit(&mpi::source_site);
|
||||
}
|
||||
#endif // OPENMC_MPI
|
||||
|
||||
|
|
|
|||
191
src/lattice.cpp
191
src/lattice.cpp
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
|
|
@ -12,9 +11,9 @@
|
|||
#include "openmc/geometry_aux.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/string_utils.h"
|
||||
#include "openmc/vector.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -23,7 +22,7 @@ namespace openmc {
|
|||
|
||||
namespace model {
|
||||
std::unordered_map<int32_t, int32_t> lattice_map;
|
||||
std::vector<std::unique_ptr<Lattice>> lattices;
|
||||
vector<unique_ptr<Lattice>> lattices;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -142,7 +141,7 @@ RectLattice::RectLattice(pugi::xml_node lat_node)
|
|||
|
||||
// Read the number of lattice cells in each dimension.
|
||||
std::string dimension_str {get_node_value(lat_node, "dimension")};
|
||||
std::vector<std::string> dimension_words {split(dimension_str)};
|
||||
vector<std::string> dimension_words {split(dimension_str)};
|
||||
if (dimension_words.size() == 2) {
|
||||
n_cells_[0] = std::stoi(dimension_words[0]);
|
||||
n_cells_[1] = std::stoi(dimension_words[1]);
|
||||
|
|
@ -159,7 +158,7 @@ RectLattice::RectLattice(pugi::xml_node lat_node)
|
|||
|
||||
// Read the lattice lower-left location.
|
||||
std::string ll_str {get_node_value(lat_node, "lower_left")};
|
||||
std::vector<std::string> ll_words {split(ll_str)};
|
||||
vector<std::string> ll_words {split(ll_str)};
|
||||
if (ll_words.size() != dimension_words.size()) {
|
||||
fatal_error("Number of entries on <lower_left> must be the same as the "
|
||||
"number of entries on <dimension>.");
|
||||
|
|
@ -170,7 +169,7 @@ RectLattice::RectLattice(pugi::xml_node lat_node)
|
|||
|
||||
// Read the lattice pitches.
|
||||
std::string pitch_str {get_node_value(lat_node, "pitch")};
|
||||
std::vector<std::string> pitch_words {split(pitch_str)};
|
||||
vector<std::string> pitch_words {split(pitch_str)};
|
||||
if (pitch_words.size() != dimension_words.size()) {
|
||||
fatal_error("Number of entries on <pitch> must be the same as the "
|
||||
"number of entries on <dimension>.");
|
||||
|
|
@ -181,20 +180,23 @@ RectLattice::RectLattice(pugi::xml_node lat_node)
|
|||
|
||||
// Read the universes and make sure the correct number was specified.
|
||||
std::string univ_str {get_node_value(lat_node, "universes")};
|
||||
std::vector<std::string> univ_words {split(univ_str)};
|
||||
if (univ_words.size() != nx*ny*nz) {
|
||||
vector<std::string> univ_words {split(univ_str)};
|
||||
if (univ_words.size() != n_cells_[0] * n_cells_[1] * n_cells_[2]) {
|
||||
fatal_error(fmt::format(
|
||||
"Expected {} universes for a rectangular lattice of size {}x{}x{} but {} "
|
||||
"were specified.", nx*ny*nz, nx, ny, nz, univ_words.size()));
|
||||
"were specified.",
|
||||
n_cells_[0] * n_cells_[1] * n_cells_[2], n_cells_[0], n_cells_[1],
|
||||
n_cells_[2], univ_words.size()));
|
||||
}
|
||||
|
||||
// Parse the universes.
|
||||
universes_.resize(nx*ny*nz, C_NONE);
|
||||
for (int iz = 0; iz < nz; iz++) {
|
||||
for (int iy = ny-1; iy > -1; iy--) {
|
||||
for (int ix = 0; ix < nx; ix++) {
|
||||
int indx1 = nx*ny*iz + nx*(ny-iy-1) + ix;
|
||||
int indx2 = nx*ny*iz + nx*iy + ix;
|
||||
universes_.resize(n_cells_[0] * n_cells_[1] * n_cells_[2], C_NONE);
|
||||
for (int iz = 0; iz < n_cells_[2]; iz++) {
|
||||
for (int iy = n_cells_[1] - 1; iy > -1; iy--) {
|
||||
for (int ix = 0; ix < n_cells_[0]; ix++) {
|
||||
int indx1 = n_cells_[0] * n_cells_[1] * iz +
|
||||
n_cells_[0] * (n_cells_[1] - iy - 1) + ix;
|
||||
int indx2 = n_cells_[0] * n_cells_[1] * iz + n_cells_[0] * iy + ix;
|
||||
universes_[indx1] = std::stoi(univ_words[indx2]);
|
||||
}
|
||||
}
|
||||
|
|
@ -203,17 +205,16 @@ RectLattice::RectLattice(pugi::xml_node lat_node)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
int32_t&
|
||||
RectLattice::operator[](std::array<int, 3> i_xyz)
|
||||
int32_t const& RectLattice::operator[](array<int, 3> const& i_xyz)
|
||||
{
|
||||
int indx = nx*ny*i_xyz[2] + nx*i_xyz[1] + i_xyz[0];
|
||||
int indx =
|
||||
n_cells_[0] * n_cells_[1] * i_xyz[2] + n_cells_[0] * i_xyz[1] + i_xyz[0];
|
||||
return universes_[indx];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
RectLattice::are_valid_indices(const int i_xyz[3]) const
|
||||
bool RectLattice::are_valid_indices(array<int, 3> const& i_xyz) const
|
||||
{
|
||||
return ( (i_xyz[0] >= 0) && (i_xyz[0] < n_cells_[0])
|
||||
&& (i_xyz[1] >= 0) && (i_xyz[1] < n_cells_[1])
|
||||
|
|
@ -222,9 +223,8 @@ RectLattice::are_valid_indices(const int i_xyz[3]) const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
std::pair<double, std::array<int, 3>>
|
||||
RectLattice::distance(Position r, Direction u, const std::array<int, 3>& i_xyz)
|
||||
const
|
||||
std::pair<double, array<int, 3>> RectLattice::distance(
|
||||
Position r, Direction u, const array<int, 3>& i_xyz) const
|
||||
{
|
||||
// Get short aliases to the coordinates.
|
||||
double x = r.x;
|
||||
|
|
@ -237,7 +237,7 @@ const
|
|||
|
||||
// Left and right sides
|
||||
double d {INFTY};
|
||||
std::array<int, 3> lattice_trans;
|
||||
array<int, 3> lattice_trans;
|
||||
if ((std::abs(x - x0) > FP_PRECISION) && u.x != 0) {
|
||||
d = (x0 - x) / u.x;
|
||||
if (u.x > 0) {
|
||||
|
|
@ -281,48 +281,44 @@ const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
std::array<int, 3>
|
||||
RectLattice::get_indices(Position r, Direction u) const
|
||||
void RectLattice::get_indices(
|
||||
Position r, Direction u, array<int, 3>& result) const
|
||||
{
|
||||
// Determine x index, accounting for coincidence
|
||||
double ix_ {(r.x - lower_left_.x) / pitch_.x};
|
||||
long ix_close {std::lround(ix_)};
|
||||
int ix;
|
||||
if (coincident(ix_, ix_close)) {
|
||||
ix = (u.x > 0) ? ix_close : ix_close - 1;
|
||||
result[0] = (u.x > 0) ? ix_close : ix_close - 1;
|
||||
} else {
|
||||
ix = std::floor(ix_);
|
||||
result[0] = std::floor(ix_);
|
||||
}
|
||||
|
||||
// Determine y index, accounting for coincidence
|
||||
double iy_ {(r.y - lower_left_.y) / pitch_.y};
|
||||
long iy_close {std::lround(iy_)};
|
||||
int iy;
|
||||
if (coincident(iy_, iy_close)) {
|
||||
iy = (u.y > 0) ? iy_close : iy_close - 1;
|
||||
result[1] = (u.y > 0) ? iy_close : iy_close - 1;
|
||||
} else {
|
||||
iy = std::floor(iy_);
|
||||
result[1] = std::floor(iy_);
|
||||
}
|
||||
|
||||
// Determine z index, accounting for coincidence
|
||||
int iz = 0;
|
||||
result[2] = 0;
|
||||
if (is_3d_) {
|
||||
double iz_ {(r.z - lower_left_.z) / pitch_.z};
|
||||
long iz_close {std::lround(iz_)};
|
||||
if (coincident(iz_, iz_close)) {
|
||||
iz = (u.z > 0) ? iz_close : iz_close - 1;
|
||||
result[2] = (u.z > 0) ? iz_close : iz_close - 1;
|
||||
} else {
|
||||
iz = std::floor(iz_);
|
||||
result[2] = std::floor(iz_);
|
||||
}
|
||||
}
|
||||
return {ix, iy, iz};
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
Position
|
||||
RectLattice::get_local_position(Position r, const std::array<int, 3> i_xyz)
|
||||
const
|
||||
Position RectLattice::get_local_position(
|
||||
Position r, const array<int, 3>& i_xyz) const
|
||||
{
|
||||
r.x -= (lower_left_.x + (i_xyz[0] + 0.5)*pitch_.x);
|
||||
r.y -= (lower_left_.y + (i_xyz[1] + 0.5)*pitch_.y);
|
||||
|
|
@ -334,10 +330,11 @@ const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
int32_t&
|
||||
RectLattice::offset(int map, const int i_xyz[3])
|
||||
int32_t& RectLattice::offset(int map, array<int, 3> const& i_xyz)
|
||||
{
|
||||
return offsets_[nx*ny*nz*map + nx*ny*i_xyz[2] + nx*i_xyz[1] + i_xyz[0]];
|
||||
return offsets_[n_cells_[0] * n_cells_[1] * n_cells_[2] * map +
|
||||
n_cells_[0] * n_cells_[1] * i_xyz[2] +
|
||||
n_cells_[0] * i_xyz[1] + i_xyz[0]];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -345,7 +342,7 @@ RectLattice::offset(int map, const int i_xyz[3])
|
|||
int32_t
|
||||
RectLattice::offset(int map, int indx) const
|
||||
{
|
||||
return offsets_[nx*ny*nz*map + indx];
|
||||
return offsets_[n_cells_[0] * n_cells_[1] * n_cells_[2] * map + indx];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -353,9 +350,9 @@ RectLattice::offset(int map, int indx) const
|
|||
std::string
|
||||
RectLattice::index_to_string(int indx) const
|
||||
{
|
||||
int iz {indx / (nx * ny)};
|
||||
int iy {(indx - nx * ny * iz) / nx};
|
||||
int ix {indx - nx * ny * iz - nx * iy};
|
||||
int iz {indx / (n_cells_[0] * n_cells_[1])};
|
||||
int iy {(indx - n_cells_[0] * n_cells_[1] * iz) / n_cells_[0]};
|
||||
int ix {indx - n_cells_[0] * n_cells_[1] * iz - n_cells_[0] * iy};
|
||||
std::string out {std::to_string(ix)};
|
||||
out += ',';
|
||||
out += std::to_string(iy);
|
||||
|
|
@ -378,11 +375,11 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const
|
|||
write_dataset(lat_group, "lower_left", lower_left_);
|
||||
write_dataset(lat_group, "dimension", n_cells_);
|
||||
} else {
|
||||
std::array<double, 2> pitch_short {{pitch_[0], pitch_[1]}};
|
||||
array<double, 2> pitch_short {{pitch_[0], pitch_[1]}};
|
||||
write_dataset(lat_group, "pitch", pitch_short);
|
||||
std::array<double, 2> ll_short {{lower_left_[0], lower_left_[1]}};
|
||||
array<double, 2> ll_short {{lower_left_[0], lower_left_[1]}};
|
||||
write_dataset(lat_group, "lower_left", ll_short);
|
||||
std::array<int, 2> nc_short {{n_cells_[0], n_cells_[1]}};
|
||||
array<int, 2> nc_short {{n_cells_[0], n_cells_[1]}};
|
||||
write_dataset(lat_group, "dimension", nc_short);
|
||||
}
|
||||
|
||||
|
|
@ -392,7 +389,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const
|
|||
hsize_t nx {static_cast<hsize_t>(n_cells_[0])};
|
||||
hsize_t ny {static_cast<hsize_t>(n_cells_[1])};
|
||||
hsize_t nz {static_cast<hsize_t>(n_cells_[2])};
|
||||
std::vector<int> out(nx*ny*nz);
|
||||
vector<int> out(nx * ny * nz);
|
||||
|
||||
for (int m = 0; m < nz; m++) {
|
||||
for (int k = 0; k < ny; k++) {
|
||||
|
|
@ -410,7 +407,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const
|
|||
} else {
|
||||
hsize_t nx {static_cast<hsize_t>(n_cells_[0])};
|
||||
hsize_t ny {static_cast<hsize_t>(n_cells_[1])};
|
||||
std::vector<int> out(nx*ny);
|
||||
vector<int> out(nx * ny);
|
||||
|
||||
for (int k = 0; k < ny; k++) {
|
||||
for (int j = 0; j < nx; j++) {
|
||||
|
|
@ -461,7 +458,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node)
|
|||
|
||||
// Read the lattice center.
|
||||
std::string center_str {get_node_value(lat_node, "center")};
|
||||
std::vector<std::string> center_words {split(center_str)};
|
||||
vector<std::string> center_words {split(center_str)};
|
||||
if (is_3d_ && (center_words.size() != 3)) {
|
||||
fatal_error("A hexagonal lattice with <n_axial> must have <center> "
|
||||
"specified by 3 numbers.");
|
||||
|
|
@ -475,7 +472,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node)
|
|||
|
||||
// Read the lattice pitches.
|
||||
std::string pitch_str {get_node_value(lat_node, "pitch")};
|
||||
std::vector<std::string> pitch_words {split(pitch_str)};
|
||||
vector<std::string> pitch_words {split(pitch_str)};
|
||||
if (is_3d_ && (pitch_words.size() != 2)) {
|
||||
fatal_error("A hexagonal lattice with <n_axial> must have <pitch> "
|
||||
"specified by 2 numbers.");
|
||||
|
|
@ -489,7 +486,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node)
|
|||
// Read the universes and make sure the correct number was specified.
|
||||
int n_univ = (3*n_rings_*n_rings_ - 3*n_rings_ + 1) * n_axial_;
|
||||
std::string univ_str {get_node_value(lat_node, "universes")};
|
||||
std::vector<std::string> univ_words {split(univ_str)};
|
||||
vector<std::string> univ_words {split(univ_str)};
|
||||
if (univ_words.size() != n_univ) {
|
||||
fatal_error(fmt::format(
|
||||
"Expected {} universes for a hexagonal lattice with {} rings and {} "
|
||||
|
|
@ -516,8 +513,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
HexLattice::fill_lattice_x(const std::vector<std::string>& univ_words)
|
||||
void HexLattice::fill_lattice_x(const vector<std::string>& univ_words)
|
||||
{
|
||||
int input_index = 0;
|
||||
for (int m = 0; m < n_axial_; m++) {
|
||||
|
|
@ -569,8 +565,7 @@ HexLattice::fill_lattice_x(const std::vector<std::string>& univ_words)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
HexLattice::fill_lattice_y(const std::vector<std::string>& univ_words)
|
||||
void HexLattice::fill_lattice_y(const vector<std::string>& univ_words)
|
||||
{
|
||||
int input_index = 0;
|
||||
for (int m = 0; m < n_axial_; m++) {
|
||||
|
|
@ -657,8 +652,7 @@ HexLattice::fill_lattice_y(const std::vector<std::string>& univ_words)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
int32_t&
|
||||
HexLattice::operator[](std::array<int, 3> i_xyz)
|
||||
int32_t const& HexLattice::operator[](array<int, 3> const& i_xyz)
|
||||
{
|
||||
int indx = (2*n_rings_-1)*(2*n_rings_-1) * i_xyz[2]
|
||||
+ (2*n_rings_-1) * i_xyz[1]
|
||||
|
|
@ -676,8 +670,7 @@ ReverseLatticeIter HexLattice::rbegin()
|
|||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
HexLattice::are_valid_indices(const int i_xyz[3]) const
|
||||
bool HexLattice::are_valid_indices(array<int, 3> const& i_xyz) const
|
||||
{
|
||||
// Check if (x, alpha, z) indices are valid, accounting for number of rings
|
||||
return ((i_xyz[0] >= 0) && (i_xyz[1] >= 0) && (i_xyz[2] >= 0)
|
||||
|
|
@ -689,9 +682,8 @@ HexLattice::are_valid_indices(const int i_xyz[3]) const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
std::pair<double, std::array<int, 3>>
|
||||
HexLattice::distance(Position r, Direction u, const std::array<int, 3>& i_xyz)
|
||||
const
|
||||
std::pair<double, array<int, 3>> HexLattice::distance(
|
||||
Position r, Direction u, const array<int, 3>& i_xyz) const
|
||||
{
|
||||
// Short description of the direction vectors used here. The beta, gamma, and
|
||||
// delta vectors point towards the flat sides of each hexagonal tile.
|
||||
|
|
@ -729,14 +721,14 @@ const
|
|||
|
||||
// beta direction
|
||||
double d {INFTY};
|
||||
std::array<int, 3> lattice_trans;
|
||||
array<int, 3> lattice_trans;
|
||||
double edge = -copysign(0.5*pitch_[0], beta_dir); // Oncoming edge
|
||||
Position r_t;
|
||||
if (beta_dir > 0) {
|
||||
const std::array<int, 3> i_xyz_t {i_xyz[0]+1, i_xyz[1], i_xyz[2]};
|
||||
const array<int, 3> i_xyz_t {i_xyz[0] + 1, i_xyz[1], i_xyz[2]};
|
||||
r_t = get_local_position(r, i_xyz_t);
|
||||
} else {
|
||||
const std::array<int, 3> i_xyz_t {i_xyz[0]-1, i_xyz[1], i_xyz[2]};
|
||||
const array<int, 3> i_xyz_t {i_xyz[0] - 1, i_xyz[1], i_xyz[2]};
|
||||
r_t = get_local_position(r, i_xyz_t);
|
||||
}
|
||||
double beta;
|
||||
|
|
@ -757,10 +749,10 @@ const
|
|||
// gamma direction
|
||||
edge = -copysign(0.5*pitch_[0], gamma_dir);
|
||||
if (gamma_dir > 0) {
|
||||
const std::array<int, 3> i_xyz_t {i_xyz[0]+1, i_xyz[1]-1, i_xyz[2]};
|
||||
const array<int, 3> i_xyz_t {i_xyz[0] + 1, i_xyz[1] - 1, i_xyz[2]};
|
||||
r_t = get_local_position(r, i_xyz_t);
|
||||
} else {
|
||||
const std::array<int, 3> i_xyz_t {i_xyz[0]-1, i_xyz[1]+1, i_xyz[2]};
|
||||
const array<int, 3> i_xyz_t {i_xyz[0] - 1, i_xyz[1] + 1, i_xyz[2]};
|
||||
r_t = get_local_position(r, i_xyz_t);
|
||||
}
|
||||
double gamma;
|
||||
|
|
@ -784,10 +776,10 @@ const
|
|||
// delta direction
|
||||
edge = -copysign(0.5*pitch_[0], delta_dir);
|
||||
if (delta_dir > 0) {
|
||||
const std::array<int, 3> i_xyz_t {i_xyz[0], i_xyz[1]+1, i_xyz[2]};
|
||||
const array<int, 3> i_xyz_t {i_xyz[0], i_xyz[1] + 1, i_xyz[2]};
|
||||
r_t = get_local_position(r, i_xyz_t);
|
||||
} else {
|
||||
const std::array<int, 3> i_xyz_t {i_xyz[0], i_xyz[1]-1, i_xyz[2]};
|
||||
const array<int, 3> i_xyz_t {i_xyz[0], i_xyz[1] - 1, i_xyz[2]};
|
||||
r_t = get_local_position(r, i_xyz_t);
|
||||
}
|
||||
double delta;
|
||||
|
|
@ -831,44 +823,43 @@ const
|
|||
|
||||
//==============================================================================
|
||||
|
||||
std::array<int, 3>
|
||||
HexLattice::get_indices(Position r, Direction u) const
|
||||
void HexLattice::get_indices(
|
||||
Position r, Direction u, array<int, 3>& result) const
|
||||
{
|
||||
// Offset the xyz by the lattice center.
|
||||
Position r_o {r.x - center_.x, r.y - center_.y, r.z};
|
||||
if (is_3d_) {r_o.z -= center_.z;}
|
||||
|
||||
// Index the z direction, accounting for coincidence
|
||||
int iz = 0;
|
||||
result[2] = 0;
|
||||
if (is_3d_) {
|
||||
double iz_ {r_o.z / pitch_[1] + 0.5 * n_axial_};
|
||||
long iz_close {std::lround(iz_)};
|
||||
if (coincident(iz_, iz_close)) {
|
||||
iz = (u.z > 0) ? iz_close : iz_close - 1;
|
||||
result[2] = (u.z > 0) ? iz_close : iz_close - 1;
|
||||
} else {
|
||||
iz = std::floor(iz_);
|
||||
result[2] = std::floor(iz_);
|
||||
}
|
||||
}
|
||||
|
||||
int i1, i2;
|
||||
if (orientation_ == Orientation::y) {
|
||||
// Convert coordinates into skewed bases. The (x, alpha) basis is used to
|
||||
// find the index of the global coordinates to within 4 cells.
|
||||
double alpha = r_o.y - r_o.x / std::sqrt(3.0);
|
||||
i1 = std::floor(r_o.x / (0.5*std::sqrt(3.0) * pitch_[0]));
|
||||
i2 = std::floor(alpha / pitch_[0]);
|
||||
result[0] = std::floor(r_o.x / (0.5 * std::sqrt(3.0) * pitch_[0]));
|
||||
result[1] = std::floor(alpha / pitch_[0]);
|
||||
} else {
|
||||
// Convert coordinates into skewed bases. The (alpha, y) basis is used to
|
||||
// find the index of the global coordinates to within 4 cells.
|
||||
double alpha = r_o.y - r_o.x * std::sqrt(3.0);
|
||||
i1 = std::floor(-alpha / (std::sqrt(3.0) * pitch_[0]));
|
||||
i2 = std::floor(r_o.y / (0.5*std::sqrt(3.0) * pitch_[0]));
|
||||
result[0] = std::floor(-alpha / (std::sqrt(3.0) * pitch_[0]));
|
||||
result[1] = std::floor(r_o.y / (0.5 * std::sqrt(3.0) * pitch_[0]));
|
||||
}
|
||||
|
||||
// Add offset to indices (the center cell is (i1, i2) = (0, 0) but
|
||||
// the array is offset so that the indices never go below 0).
|
||||
i1 += n_rings_-1;
|
||||
i2 += n_rings_-1;
|
||||
result[0] += n_rings_ - 1;
|
||||
result[1] += n_rings_ - 1;
|
||||
|
||||
// Calculate the (squared) distance between the particle and the centers of
|
||||
// the four possible cells. Regular hexagonal tiles form a Voronoi
|
||||
|
|
@ -887,14 +878,14 @@ HexLattice::get_indices(Position r, Direction u) const
|
|||
// is kept (i.e. the cell with the lowest dot product as the vectors will be
|
||||
// completely opposed if the particle is moving directly toward the center of
|
||||
// the cell).
|
||||
int i1_chg {};
|
||||
int i2_chg {};
|
||||
int i1_chg;
|
||||
int i2_chg;
|
||||
double d_min {INFTY};
|
||||
double dp_min {INFTY};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
// get local coordinates
|
||||
const std::array<int, 3> i_xyz {i1 + j, i2 + i, 0};
|
||||
const array<int, 3> i_xyz {result[0] + j, result[1] + i, 0};
|
||||
Position r_t = get_local_position(r, i_xyz);
|
||||
// calculate distance
|
||||
double d = r_t.x*r_t.x + r_t.y*r_t.y;
|
||||
|
|
@ -921,17 +912,14 @@ HexLattice::get_indices(Position r, Direction u) const
|
|||
}
|
||||
|
||||
// update outgoing indices
|
||||
i1 += i1_chg;
|
||||
i2 += i2_chg;
|
||||
|
||||
return {i1, i2, iz};
|
||||
result[0] += i1_chg;
|
||||
result[1] += i2_chg;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
Position
|
||||
HexLattice::get_local_position(Position r, const std::array<int, 3> i_xyz)
|
||||
const
|
||||
Position HexLattice::get_local_position(
|
||||
Position r, const array<int, 3>& i_xyz) const
|
||||
{
|
||||
if (orientation_ == Orientation::y) {
|
||||
// x_l = x_g - (center + pitch_x*cos(30)*index_x)
|
||||
|
|
@ -966,14 +954,13 @@ HexLattice::is_valid_index(int indx) const
|
|||
int iz = indx / (nx * ny);
|
||||
int iy = (indx - nx*ny*iz) / nx;
|
||||
int ix = indx - nx*ny*iz - nx*iy;
|
||||
int i_xyz[3] {ix, iy, iz};
|
||||
array<int, 3> i_xyz {ix, iy, iz};
|
||||
return are_valid_indices(i_xyz);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
int32_t&
|
||||
HexLattice::offset(int map, const int i_xyz[3])
|
||||
int32_t& HexLattice::offset(int map, array<int, 3> const& i_xyz)
|
||||
{
|
||||
int nx {2*n_rings_ - 1};
|
||||
int ny {2*n_rings_ - 1};
|
||||
|
|
@ -1028,9 +1015,9 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const
|
|||
write_dataset(lat_group, "pitch", pitch_);
|
||||
write_dataset(lat_group, "center", center_);
|
||||
} else {
|
||||
std::array<double, 1> pitch_short {{pitch_[0]}};
|
||||
array<double, 1> pitch_short {{pitch_[0]}};
|
||||
write_dataset(lat_group, "pitch", pitch_short);
|
||||
std::array<double, 2> center_short {{center_[0], center_[1]}};
|
||||
array<double, 2> center_short {{center_[0], center_[1]}};
|
||||
write_dataset(lat_group, "center", center_short);
|
||||
}
|
||||
|
||||
|
|
@ -1038,7 +1025,7 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const
|
|||
hsize_t nx {static_cast<hsize_t>(2*n_rings_ - 1)};
|
||||
hsize_t ny {static_cast<hsize_t>(2*n_rings_ - 1)};
|
||||
hsize_t nz {static_cast<hsize_t>(n_axial_)};
|
||||
std::vector<int> out(nx*ny*nz);
|
||||
vector<int> out(nx * ny * nz);
|
||||
|
||||
for (int m = 0; m < nz; m++) {
|
||||
for (int k = 0; k < ny; k++) {
|
||||
|
|
@ -1068,10 +1055,10 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const
|
|||
void read_lattices(pugi::xml_node node)
|
||||
{
|
||||
for (pugi::xml_node lat_node : node.children("lattice")) {
|
||||
model::lattices.push_back(std::make_unique<RectLattice>(lat_node));
|
||||
model::lattices.push_back(make_unique<RectLattice>(lat_node));
|
||||
}
|
||||
for (pugi::xml_node lat_node : node.children("hex_lattice")) {
|
||||
model::lattices.push_back(std::make_unique<HexLattice>(lat_node));
|
||||
model::lattices.push_back(make_unique<HexLattice>(lat_node));
|
||||
}
|
||||
|
||||
// Fill the lattice map.
|
||||
|
|
|
|||
102
src/material.cpp
102
src/material.cpp
|
|
@ -39,7 +39,7 @@ namespace openmc {
|
|||
namespace model {
|
||||
|
||||
std::unordered_map<int32_t, int32_t> material_map;
|
||||
std::vector<std::unique_ptr<Material>> materials;
|
||||
vector<unique_ptr<Material>> materials;
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -127,8 +127,8 @@ Material::Material(pugi::xml_node node)
|
|||
auto node_macros = node.children("macroscopic");
|
||||
int num_macros = std::distance(node_macros.begin(), node_macros.end());
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::vector<double> densities;
|
||||
vector<std::string> names;
|
||||
vector<double> densities;
|
||||
if (settings::run_CE && num_macros > 0) {
|
||||
fatal_error("Macroscopic can not be used in continuous-energy mode.");
|
||||
} else if (num_macros > 1) {
|
||||
|
|
@ -194,7 +194,7 @@ Material::Material(pugi::xml_node node)
|
|||
// =======================================================================
|
||||
// READ AND PARSE <isotropic> element
|
||||
|
||||
std::vector<std::string> iso_lab;
|
||||
vector<std::string> iso_lab;
|
||||
if (check_for_node(node, "isotropic")) {
|
||||
iso_lab = get_node_array<std::string>(node, "isotropic");
|
||||
}
|
||||
|
|
@ -295,7 +295,7 @@ Material::Material(pugi::xml_node node)
|
|||
if (settings::run_CE) {
|
||||
// Loop over <sab> elements
|
||||
|
||||
std::vector<std::string> sab_names;
|
||||
vector<std::string> sab_names;
|
||||
for (auto node_sab : node.children("sab")) {
|
||||
// Determine name of thermal scattering table
|
||||
if (!check_for_node(node_sab, "name")) {
|
||||
|
|
@ -413,7 +413,7 @@ void Material::normalize_density()
|
|||
|
||||
void Material::init_thermal()
|
||||
{
|
||||
std::vector<ThermalTable> tables;
|
||||
vector<ThermalTable> tables;
|
||||
|
||||
std::unordered_set<int> already_checked;
|
||||
for (const auto& table : thermal_tables_) {
|
||||
|
|
@ -481,8 +481,8 @@ void Material::collision_stopping_power(double* s_col, bool positron)
|
|||
|
||||
// Oscillator strength and square of the binding energy for each oscillator
|
||||
// in material
|
||||
std::vector<double> f;
|
||||
std::vector<double> e_b_sq;
|
||||
vector<double> f;
|
||||
vector<double> e_b_sq;
|
||||
|
||||
for (int i = 0; i < element_.size(); ++i) {
|
||||
const auto& elm = *data::elements[element_[i]];
|
||||
|
|
@ -565,7 +565,7 @@ void Material::collision_stopping_power(double* s_col, bool positron)
|
|||
void Material::init_bremsstrahlung()
|
||||
{
|
||||
// Create new object
|
||||
ttb_ = std::make_unique<Bremsstrahlung>();
|
||||
ttb_ = make_unique<Bremsstrahlung>();
|
||||
|
||||
// Get the size of the energy grids
|
||||
auto n_k = data::ttb_k_grid.size();
|
||||
|
|
@ -748,14 +748,14 @@ void Material::init_nuclide_index()
|
|||
void Material::calculate_xs(Particle& p) const
|
||||
{
|
||||
// Set all material macroscopic cross sections to zero
|
||||
p.macro_xs_.total = 0.0;
|
||||
p.macro_xs_.absorption = 0.0;
|
||||
p.macro_xs_.fission = 0.0;
|
||||
p.macro_xs_.nu_fission = 0.0;
|
||||
p.macro_xs().total = 0.0;
|
||||
p.macro_xs().absorption = 0.0;
|
||||
p.macro_xs().fission = 0.0;
|
||||
p.macro_xs().nu_fission = 0.0;
|
||||
|
||||
if (p.type_ == Particle::Type::neutron) {
|
||||
if (p.type() == ParticleType::neutron) {
|
||||
this->calculate_neutron_xs(p);
|
||||
} else if (p.type_ == Particle::Type::photon) {
|
||||
} else if (p.type() == ParticleType::photon) {
|
||||
this->calculate_photon_xs(p);
|
||||
}
|
||||
}
|
||||
|
|
@ -763,8 +763,9 @@ void Material::calculate_xs(Particle& p) const
|
|||
void Material::calculate_neutron_xs(Particle& p) const
|
||||
{
|
||||
// Find energy index on energy grid
|
||||
int neutron = static_cast<int>(Particle::Type::neutron);
|
||||
int i_grid = std::log(p.E_/data::energy_min[neutron])/simulation::log_spacing;
|
||||
int neutron = static_cast<int>(ParticleType::neutron);
|
||||
int i_grid =
|
||||
std::log(p.E() / data::energy_min[neutron]) / simulation::log_spacing;
|
||||
|
||||
// Determine if this material has S(a,b) tables
|
||||
bool check_sab = (thermal_tables_.size() > 0);
|
||||
|
|
@ -791,7 +792,8 @@ void Material::calculate_neutron_xs(Particle& p) const
|
|||
|
||||
// If particle energy is greater than the highest energy for the
|
||||
// S(a,b) table, then don't use the S(a,b) table
|
||||
if (p.E_ > data::thermal_scatt[i_sab]->energy_max_) i_sab = C_NONE;
|
||||
if (p.E() > data::thermal_scatt[i_sab]->energy_max_)
|
||||
i_sab = C_NONE;
|
||||
|
||||
// Increment position in thermal_tables_
|
||||
++j;
|
||||
|
|
@ -808,11 +810,9 @@ void Material::calculate_neutron_xs(Particle& p) const
|
|||
int i_nuclide = nuclide_[i];
|
||||
|
||||
// Calculate microscopic cross section for this nuclide
|
||||
const auto& micro {p.neutron_xs_[i_nuclide]};
|
||||
if (p.E_ != micro.last_E
|
||||
|| p.sqrtkT_ != micro.last_sqrtkT
|
||||
|| i_sab != micro.index_sab
|
||||
|| sab_frac != micro.sab_frac) {
|
||||
const auto& micro {p.neutron_xs(i_nuclide)};
|
||||
if (p.E() != micro.last_E || p.sqrtkT() != micro.last_sqrtkT ||
|
||||
i_sab != micro.index_sab || sab_frac != micro.sab_frac) {
|
||||
data::nuclides[i_nuclide]->calculate_xs(i_sab, i_grid, sab_frac, p);
|
||||
}
|
||||
|
||||
|
|
@ -823,19 +823,19 @@ void Material::calculate_neutron_xs(Particle& p) const
|
|||
double atom_density = atom_density_(i);
|
||||
|
||||
// Add contributions to cross sections
|
||||
p.macro_xs_.total += atom_density * micro.total;
|
||||
p.macro_xs_.absorption += atom_density * micro.absorption;
|
||||
p.macro_xs_.fission += atom_density * micro.fission;
|
||||
p.macro_xs_.nu_fission += atom_density * micro.nu_fission;
|
||||
p.macro_xs().total += atom_density * micro.total;
|
||||
p.macro_xs().absorption += atom_density * micro.absorption;
|
||||
p.macro_xs().fission += atom_density * micro.fission;
|
||||
p.macro_xs().nu_fission += atom_density * micro.nu_fission;
|
||||
}
|
||||
}
|
||||
|
||||
void Material::calculate_photon_xs(Particle& p) const
|
||||
{
|
||||
p.macro_xs_.coherent = 0.0;
|
||||
p.macro_xs_.incoherent = 0.0;
|
||||
p.macro_xs_.photoelectric = 0.0;
|
||||
p.macro_xs_.pair_production = 0.0;
|
||||
p.macro_xs().coherent = 0.0;
|
||||
p.macro_xs().incoherent = 0.0;
|
||||
p.macro_xs().photoelectric = 0.0;
|
||||
p.macro_xs().pair_production = 0.0;
|
||||
|
||||
// Add contribution from each nuclide in material
|
||||
for (int i = 0; i < nuclide_.size(); ++i) {
|
||||
|
|
@ -846,8 +846,8 @@ void Material::calculate_photon_xs(Particle& p) const
|
|||
int i_element = element_[i];
|
||||
|
||||
// Calculate microscopic cross section for this nuclide
|
||||
const auto& micro {p.photon_xs_[i_element]};
|
||||
if (p.E_ != micro.last_E) {
|
||||
const auto& micro {p.photon_xs(i_element)};
|
||||
if (p.E() != micro.last_E) {
|
||||
data::elements[i_element]->calculate_xs(p);
|
||||
}
|
||||
|
||||
|
|
@ -858,11 +858,11 @@ void Material::calculate_photon_xs(Particle& p) const
|
|||
double atom_density = atom_density_(i);
|
||||
|
||||
// Add contributions to material macroscopic cross sections
|
||||
p.macro_xs_.total += atom_density * micro.total;
|
||||
p.macro_xs_.coherent += atom_density * micro.coherent;
|
||||
p.macro_xs_.incoherent += atom_density * micro.incoherent;
|
||||
p.macro_xs_.photoelectric += atom_density * micro.photoelectric;
|
||||
p.macro_xs_.pair_production += atom_density * micro.pair_production;
|
||||
p.macro_xs().total += atom_density * micro.total;
|
||||
p.macro_xs().coherent += atom_density * micro.coherent;
|
||||
p.macro_xs().incoherent += atom_density * micro.incoherent;
|
||||
p.macro_xs().photoelectric += atom_density * micro.photoelectric;
|
||||
p.macro_xs().pair_production += atom_density * micro.pair_production;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -936,8 +936,8 @@ void Material::set_density(double density, gsl::cstring_span units)
|
|||
}
|
||||
}
|
||||
|
||||
void Material::set_densities(const std::vector<std::string>& name,
|
||||
const std::vector<double>& density)
|
||||
void Material::set_densities(
|
||||
const vector<std::string>& name, const vector<double>& density)
|
||||
{
|
||||
auto n = name.size();
|
||||
Expects(n > 0);
|
||||
|
|
@ -1010,9 +1010,9 @@ void Material::to_hdf5(hid_t group) const
|
|||
write_dataset(material_group, "atom_density", density_);
|
||||
|
||||
// Copy nuclide/macro name for each nuclide to vector
|
||||
std::vector<std::string> nuc_names;
|
||||
std::vector<std::string> macro_names;
|
||||
std::vector<double> nuc_densities;
|
||||
vector<std::string> nuc_names;
|
||||
vector<std::string> macro_names;
|
||||
vector<double> nuc_densities;
|
||||
if (settings::run_CE) {
|
||||
for (int i = 0; i < nuclide_.size(); ++i) {
|
||||
int i_nuc = nuclide_[i];
|
||||
|
|
@ -1043,7 +1043,7 @@ void Material::to_hdf5(hid_t group) const
|
|||
}
|
||||
|
||||
if (!thermal_tables_.empty()) {
|
||||
std::vector<std::string> sab_names;
|
||||
vector<std::string> sab_names;
|
||||
for (const auto& table : thermal_tables_) {
|
||||
sab_names.push_back(data::thermal_scatt[table.index_table]->name_);
|
||||
}
|
||||
|
|
@ -1099,9 +1099,9 @@ void Material::add_nuclide(const std::string& name, double density)
|
|||
// Non-method functions
|
||||
//==============================================================================
|
||||
|
||||
double sternheimer_adjustment(const std::vector<double>& f, const
|
||||
std::vector<double>& e_b_sq, double e_p_sq, double n_conduction, double
|
||||
log_I, double tol, int max_iter)
|
||||
double sternheimer_adjustment(const vector<double>& f,
|
||||
const vector<double>& e_b_sq, double e_p_sq, double n_conduction,
|
||||
double log_I, double tol, int max_iter)
|
||||
{
|
||||
// Get the total number of oscillators
|
||||
int n = f.size();
|
||||
|
|
@ -1144,8 +1144,8 @@ double sternheimer_adjustment(const std::vector<double>& f, const
|
|||
return rho;
|
||||
}
|
||||
|
||||
double density_effect(const std::vector<double>& f, const std::vector<double>&
|
||||
e_b_sq, double e_p_sq, double n_conduction, double rho, double E, double tol,
|
||||
double density_effect(const vector<double>& f, const vector<double>& e_b_sq,
|
||||
double e_p_sq, double n_conduction, double rho, double E, double tol,
|
||||
int max_iter)
|
||||
{
|
||||
// Get the total number of oscillators
|
||||
|
|
@ -1245,7 +1245,7 @@ void read_materials_xml()
|
|||
// Loop over XML material elements and populate the array.
|
||||
pugi::xml_node root = doc.document_element();
|
||||
for (pugi::xml_node material_node : root.children("material")) {
|
||||
model::materials.push_back(std::make_unique<Material>(material_node));
|
||||
model::materials.push_back(make_unique<Material>(material_node));
|
||||
}
|
||||
model::materials.shrink_to_fit();
|
||||
}
|
||||
|
|
@ -1475,7 +1475,7 @@ openmc_extend_materials(int32_t n, int32_t* index_start, int32_t* index_end)
|
|||
if (index_start) *index_start = model::materials.size();
|
||||
if (index_end) *index_end = model::materials.size() + n - 1;
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
model::materials.push_back(std::make_unique<Material>());
|
||||
model::materials.push_back(make_unique<Material>());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -540,8 +540,8 @@ void calc_zn(int n, double rho, double phi, double zn[]) {
|
|||
double sin_phi = std::sin(phi);
|
||||
double cos_phi = std::cos(phi);
|
||||
|
||||
std::vector<double> sin_phi_vec(n + 1); // Sin[n * phi]
|
||||
std::vector<double> cos_phi_vec(n + 1); // Cos[n * phi]
|
||||
vector<double> sin_phi_vec(n + 1); // Sin[n * phi]
|
||||
vector<double> cos_phi_vec(n + 1); // Cos[n * phi]
|
||||
sin_phi_vec[0] = 1.0;
|
||||
cos_phi_vec[0] = 1.0;
|
||||
sin_phi_vec[1] = 2.0 * cos_phi;
|
||||
|
|
@ -559,7 +559,7 @@ void calc_zn(int n, double rho, double phi, double zn[]) {
|
|||
// ===========================================================================
|
||||
// Calculate R_pq(rho)
|
||||
// Matrix forms of the coefficients which are easier to work with
|
||||
std::vector<std::vector<double>> zn_mat(n + 1, std::vector<double>(n + 1));
|
||||
vector<vector<double>> zn_mat(n + 1, vector<double>(n + 1));
|
||||
|
||||
// Fill the main diagonal first (Eq 3.9 in Chong)
|
||||
for (int p = 0; p <= n; p++) {
|
||||
|
|
@ -674,7 +674,7 @@ Direction rotate_angle(Direction u, double mu, const double* phi, uint64_t* seed
|
|||
|
||||
void spline(int n, const double x[], const double y[], double z[])
|
||||
{
|
||||
std::vector<double> c_new(n-1);
|
||||
vector<double> c_new(n - 1);
|
||||
|
||||
// Set natural boundary conditions
|
||||
c_new[0] = 0.0;
|
||||
|
|
|
|||
162
src/mesh.cpp
162
src/mesh.cpp
|
|
@ -2,7 +2,6 @@
|
|||
#include <algorithm> // for copy, equal, min, min_element
|
||||
#include <cstddef> // for size_t
|
||||
#include <cmath> // for ceil
|
||||
#include <memory> // for allocator
|
||||
#include <string>
|
||||
#include <gsl/gsl>
|
||||
|
||||
|
|
@ -25,11 +24,12 @@
|
|||
#include "openmc/error.h"
|
||||
#include "openmc/file_utils.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
#include "openmc/memory.h"
|
||||
#include "openmc/message_passing.h"
|
||||
#include "openmc/search.h"
|
||||
#include "openmc/settings.h"
|
||||
#include "openmc/tallies/tally.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/tallies/tally.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
#ifdef LIBMESH
|
||||
|
|
@ -53,13 +53,13 @@ const bool LIBMESH_ENABLED = false;
|
|||
namespace model {
|
||||
|
||||
std::unordered_map<int32_t, int32_t> mesh_map;
|
||||
std::vector<std::unique_ptr<Mesh>> meshes;
|
||||
vector<unique_ptr<Mesh>> meshes;
|
||||
|
||||
} // namespace model
|
||||
|
||||
#ifdef LIBMESH
|
||||
namespace settings {
|
||||
std::unique_ptr<libMesh::LibMeshInit> libmesh_init;
|
||||
unique_ptr<libMesh::LibMeshInit> libmesh_init;
|
||||
const libMesh::Parallel::Communicator* libmesh_comm {nullptr};
|
||||
}
|
||||
#endif
|
||||
|
|
@ -143,7 +143,7 @@ Mesh::set_id(int32_t id) {
|
|||
|
||||
std::string
|
||||
StructuredMesh::bin_label(int bin) const {
|
||||
std::vector<int> ijk(n_dimension_);
|
||||
vector<int> ijk(n_dimension_);
|
||||
get_indices_from_bin(bin, ijk.data());
|
||||
|
||||
if (n_dimension_ > 2) {
|
||||
|
|
@ -192,7 +192,7 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) {
|
|||
void
|
||||
UnstructuredMesh::surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
std::vector<int>& bins) const {
|
||||
vector<int>& bins) const {
|
||||
fatal_error("Unstructured mesh surface tallies are not implemented.");
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ UnstructuredMesh::to_hdf5(hid_t group) const
|
|||
write_dataset(mesh_group, "filename", filename_);
|
||||
write_dataset(mesh_group, "library", this->library());
|
||||
// write volume of each element
|
||||
std::vector<double> tet_vols;
|
||||
vector<double> tet_vols;
|
||||
xt::xtensor<double, 2> centroids({static_cast<size_t>(this->n_bins()), 3});
|
||||
for (int i = 0; i < this->n_bins(); i++) {
|
||||
tet_vols.emplace_back(this->volume(i));
|
||||
|
|
@ -264,7 +264,7 @@ void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const
|
|||
int StructuredMesh::get_bin(Position r) const
|
||||
{
|
||||
// Determine indices
|
||||
std::vector<int> ijk(n_dimension_);
|
||||
vector<int> ijk(n_dimension_);
|
||||
bool in_mesh;
|
||||
get_indices(r, ijk.data(), &in_mesh);
|
||||
if (!in_mesh) return -1;
|
||||
|
|
@ -283,14 +283,12 @@ int StructuredMesh::n_surface_bins() const
|
|||
return 4 * n_dimension_ * n_bins();
|
||||
}
|
||||
|
||||
xt::xtensor<double, 1>
|
||||
StructuredMesh::count_sites(const Particle::Bank* bank,
|
||||
int64_t length,
|
||||
bool* outside) const
|
||||
xt::xtensor<double, 1> StructuredMesh::count_sites(
|
||||
const SourceSite* bank, int64_t length, bool* outside) const
|
||||
{
|
||||
// Determine shape of array for counts
|
||||
std::size_t m = this->n_bins();
|
||||
std::vector<std::size_t> shape = {m};
|
||||
vector<std::size_t> shape = {m};
|
||||
|
||||
// Create array of zeros
|
||||
xt::xarray<double> cnt {shape, 0.0};
|
||||
|
|
@ -585,8 +583,8 @@ bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
void StructuredMesh::bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const
|
||||
{
|
||||
// ========================================================================
|
||||
// Determine where the track intersects the mesh and if it intersects at all.
|
||||
|
|
@ -602,7 +600,7 @@ void StructuredMesh::bins_crossed(Position r0,
|
|||
Position r = r1 - TINY_BIT*u;
|
||||
|
||||
// Determine the mesh indices for the starting and ending coords. Here, we
|
||||
// use arrays for ijk0 and ijk1 instead of std::vector because we obtain a
|
||||
// use arrays for ijk0 and ijk1 instead of vector because we obtain a
|
||||
// small performance improvement by forcing this data to live on the stack,
|
||||
// rather than on the heap. We know the maximum length is 3, and by
|
||||
// ensuring that all loops are only indexed up to n_dimension, we will not
|
||||
|
|
@ -800,11 +798,11 @@ void
|
|||
RegularMesh::surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const
|
||||
vector<int>& bins) const
|
||||
{
|
||||
// Determine indices for starting and ending location.
|
||||
int n = n_dimension_;
|
||||
std::vector<int> ijk0(n), ijk1(n);
|
||||
vector<int> ijk0(n), ijk1(n);
|
||||
bool start_in_mesh;
|
||||
get_indices(r0, ijk0.data(), &start_in_mesh);
|
||||
bool end_in_mesh;
|
||||
|
|
@ -813,7 +811,7 @@ RegularMesh::surface_bins_crossed(Position r0,
|
|||
// Check if the track intersects any part of the mesh.
|
||||
if (!start_in_mesh) {
|
||||
Position r0_copy = r0;
|
||||
std::vector<int> ijk0_copy(ijk0);
|
||||
vector<int> ijk0_copy(ijk0);
|
||||
if (!intersects(r0_copy, r1, ijk0_copy.data())) return;
|
||||
}
|
||||
|
||||
|
|
@ -940,11 +938,11 @@ RegularMesh::surface_bins_crossed(Position r0,
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
RegularMesh::plot(Position plot_ll, Position plot_ur) const
|
||||
std::pair<vector<double>, vector<double>> RegularMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
// Figure out which axes lie in the plane of the plot.
|
||||
std::array<int, 2> axes {-1, -1};
|
||||
array<int, 2> axes {-1, -1};
|
||||
if (plot_ur.z == plot_ll.z) {
|
||||
axes[0] = 0;
|
||||
if (n_dimension_ > 1) axes[1] = 1;
|
||||
|
|
@ -959,7 +957,7 @@ RegularMesh::plot(Position plot_ll, Position plot_ur) const
|
|||
}
|
||||
|
||||
// Get the coordinates of the mesh lines along both of the axes.
|
||||
std::array<std::vector<double>, 2> axis_lines;
|
||||
array<vector<double>, 2> axis_lines;
|
||||
for (int i_ax = 0; i_ax < 2; ++i_ax) {
|
||||
int axis = axes[i_ax];
|
||||
if (axis == -1) continue;
|
||||
|
|
@ -989,14 +987,12 @@ void RegularMesh::to_hdf5(hid_t group) const
|
|||
close_group(mesh_group);
|
||||
}
|
||||
|
||||
xt::xtensor<double, 1>
|
||||
RegularMesh::count_sites(const Particle::Bank* bank,
|
||||
int64_t length,
|
||||
bool* outside) const
|
||||
xt::xtensor<double, 1> RegularMesh::count_sites(
|
||||
const SourceSite* bank, int64_t length, bool* outside) const
|
||||
{
|
||||
// Determine shape of array for counts
|
||||
std::size_t m = this->n_bins();
|
||||
std::vector<std::size_t> shape = {m};
|
||||
vector<std::size_t> shape = {m};
|
||||
|
||||
// Create array of zeros
|
||||
xt::xarray<double> cnt {shape, 0.0};
|
||||
|
|
@ -1104,7 +1100,7 @@ int RectilinearMesh::set_grid()
|
|||
void RectilinearMesh::surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const
|
||||
vector<int>& bins) const
|
||||
{
|
||||
// Determine indices for starting and ending location.
|
||||
int ijk0[3], ijk1[3];
|
||||
|
|
@ -1268,11 +1264,11 @@ int RectilinearMesh::get_index_in_direction(double r, int i) const
|
|||
return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1;
|
||||
}
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
RectilinearMesh::plot(Position plot_ll, Position plot_ur) const
|
||||
std::pair<vector<double>, vector<double>> RectilinearMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
// Figure out which axes lie in the plane of the plot.
|
||||
std::array<int, 2> axes {-1, -1};
|
||||
array<int, 2> axes {-1, -1};
|
||||
if (plot_ur.z == plot_ll.z) {
|
||||
axes = {0, 1};
|
||||
} else if (plot_ur.y == plot_ll.y) {
|
||||
|
|
@ -1284,10 +1280,10 @@ RectilinearMesh::plot(Position plot_ll, Position plot_ur) const
|
|||
}
|
||||
|
||||
// Get the coordinates of the mesh lines along both of the axes.
|
||||
std::array<std::vector<double>, 2> axis_lines;
|
||||
array<vector<double>, 2> axis_lines;
|
||||
for (int i_ax = 0; i_ax < 2; ++i_ax) {
|
||||
int axis = axes[i_ax];
|
||||
std::vector<double>& lines {axis_lines[i_ax]};
|
||||
vector<double>& lines {axis_lines[i_ax]};
|
||||
|
||||
for (auto coord : grid_[axis]) {
|
||||
if (coord >= plot_ll[axis] && coord <= plot_ur[axis])
|
||||
|
|
@ -1370,9 +1366,9 @@ openmc_extend_meshes(int32_t n, const char* type, int32_t* index_start,
|
|||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (std::strcmp(type, "regular") == 0) {
|
||||
model::meshes.push_back(std::make_unique<RegularMesh>());
|
||||
model::meshes.push_back(make_unique<RegularMesh>());
|
||||
} else if (std::strcmp(type, "rectilinear") == 0) {
|
||||
model::meshes.push_back(std::make_unique<RectilinearMesh>());
|
||||
model::meshes.push_back(make_unique<RectilinearMesh>());
|
||||
} else {
|
||||
throw std::runtime_error{"Unknown mesh type: " + std::string(type)};
|
||||
}
|
||||
|
|
@ -1393,14 +1389,14 @@ extern "C" int openmc_add_unstructured_mesh(const char filename[],
|
|||
|
||||
#ifdef DAGMC
|
||||
if (lib_name == "moab") {
|
||||
model::meshes.push_back(std::move(std::make_unique<MOABMesh>(mesh_file)));
|
||||
model::meshes.push_back(std::move(make_unique<MOABMesh>(mesh_file)));
|
||||
valid_lib = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LIBMESH
|
||||
if (lib_name == "libmesh") {
|
||||
model::meshes.push_back(std::move(std::make_unique<LibMesh>(mesh_file)));
|
||||
model::meshes.push_back(std::move(make_unique<LibMesh>(mesh_file)));
|
||||
valid_lib = true;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1470,7 +1466,7 @@ openmc_regular_mesh_set_dimension(int32_t index, int n, const int* dims)
|
|||
RegularMesh* mesh = dynamic_cast<RegularMesh*>(model::meshes[index].get());
|
||||
|
||||
// Copy dimension
|
||||
std::vector<std::size_t> shape = {static_cast<std::size_t>(n)};
|
||||
vector<std::size_t> shape = {static_cast<std::size_t>(n)};
|
||||
mesh->shape_ = xt::adapt(dims, n, xt::no_ownership(), shape);
|
||||
mesh->n_dimension_ = mesh->shape_.size();
|
||||
return 0;
|
||||
|
|
@ -1504,7 +1500,7 @@ openmc_regular_mesh_set_params(int32_t index, int n, const double* ll,
|
|||
if (int err = check_mesh_type<RegularMesh>(index)) return err;
|
||||
RegularMesh* m = dynamic_cast<RegularMesh*>(model::meshes[index].get());
|
||||
|
||||
std::vector<std::size_t> shape = {static_cast<std::size_t>(n)};
|
||||
vector<std::size_t> shape = {static_cast<std::size_t>(n)};
|
||||
if (ll && ur) {
|
||||
m->lower_left_ = xt::adapt(ll, n, xt::no_ownership(), shape);
|
||||
m->upper_right_ = xt::adapt(ur, n, xt::no_ownership(), shape);
|
||||
|
|
@ -1587,7 +1583,7 @@ MOABMesh::MOABMesh(const std::string& filename) {
|
|||
|
||||
void MOABMesh::initialize() {
|
||||
// create MOAB instance
|
||||
mbi_ = std::make_unique<moab::Core>();
|
||||
mbi_ = make_unique<moab::Core>();
|
||||
// load unstructured mesh file
|
||||
moab::ErrorCode rval = mbi_->load_file(filename_.c_str());
|
||||
if (rval != moab::MB_SUCCESS) {
|
||||
|
|
@ -1647,7 +1643,7 @@ MOABMesh::build_kdtree(const moab::Range& all_tets)
|
|||
all_tets_and_tris.merge(all_tris);
|
||||
|
||||
// create a kd-tree instance
|
||||
kdtree_ = std::make_unique<moab::AdaptiveKDTree>(mbi_.get());
|
||||
kdtree_ = make_unique<moab::AdaptiveKDTree>(mbi_.get());
|
||||
|
||||
// build the tree
|
||||
rval = kdtree_->build_tree(all_tets_and_tris, &kdtree_root_);
|
||||
|
|
@ -1657,15 +1653,13 @@ MOABMesh::build_kdtree(const moab::Range& all_tets)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MOABMesh::intersect_track(const moab::CartVect& start,
|
||||
const moab::CartVect& dir,
|
||||
double track_len,
|
||||
std::vector<double>& hits) const {
|
||||
void MOABMesh::intersect_track(const moab::CartVect& start,
|
||||
const moab::CartVect& dir, double track_len, vector<double>& hits) const
|
||||
{
|
||||
hits.clear();
|
||||
|
||||
moab::ErrorCode rval;
|
||||
std::vector<moab::EntityHandle> tris;
|
||||
vector<moab::EntityHandle> tris;
|
||||
// get all intersections with triangles in the tet mesh
|
||||
// (distances are relative to the start point, not the previous intersection)
|
||||
rval = kdtree_->ray_intersect_triangles(kdtree_root_,
|
||||
|
|
@ -1685,15 +1679,14 @@ MOABMesh::intersect_track(const moab::CartVect& start,
|
|||
|
||||
// sorts by first component of std::pair by default
|
||||
std::sort(hits.begin(), hits.end());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MOABMesh::bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const
|
||||
{
|
||||
moab::CartVect start(r0.x, r0.y, r0.z);
|
||||
moab::CartVect end(r1.x, r1.y, r1.z);
|
||||
|
|
@ -1706,7 +1699,7 @@ MOABMesh::bins_crossed(Position r0,
|
|||
start -= TINY_BIT * dir;
|
||||
end += TINY_BIT * dir;
|
||||
|
||||
std::vector<double> hits;
|
||||
vector<double> hits;
|
||||
intersect_track(start, dir, track_len, hits);
|
||||
|
||||
bins.clear();
|
||||
|
|
@ -1805,7 +1798,7 @@ std::string MOABMesh::library() const
|
|||
|
||||
double MOABMesh::tet_volume(moab::EntityHandle tet) const
|
||||
{
|
||||
std::vector<moab::EntityHandle> conn;
|
||||
vector<moab::EntityHandle> conn;
|
||||
moab::ErrorCode rval = mbi_->get_connectivity(&tet, 1, conn);
|
||||
if (rval != moab::MB_SUCCESS) {
|
||||
fatal_error("Failed to get tet connectivity");
|
||||
|
|
@ -1820,10 +1813,8 @@ double MOABMesh::tet_volume(moab::EntityHandle tet) const
|
|||
return 1.0 / 6.0 * (((p[1] - p[0]) * (p[2] - p[0])) % (p[3] - p[0]));
|
||||
}
|
||||
|
||||
void MOABMesh::surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const
|
||||
void MOABMesh::surface_bins_crossed(
|
||||
Position r0, Position r1, const Direction& u, vector<int>& bins) const
|
||||
{
|
||||
|
||||
// TODO: Implement triangle crossings here
|
||||
|
|
@ -1850,7 +1841,7 @@ MOABMesh::compute_barycentric_data(const moab::Range& tets) {
|
|||
// compute the barycentric data for each tet element
|
||||
// and store it as a 3x3 matrix
|
||||
for (auto& tet : tets) {
|
||||
std::vector<moab::EntityHandle> verts;
|
||||
vector<moab::EntityHandle> verts;
|
||||
rval = mbi_->get_connectivity(&tet, 1, verts);
|
||||
if (rval != moab::MB_SUCCESS) {
|
||||
fatal_error("Failed to get connectivity of tet on umesh: " + filename_);
|
||||
|
|
@ -1878,7 +1869,7 @@ MOABMesh::point_in_tet(const moab::CartVect& r,
|
|||
moab::ErrorCode rval;
|
||||
|
||||
// get tet vertices
|
||||
std::vector<moab::EntityHandle> verts;
|
||||
vector<moab::EntityHandle> verts;
|
||||
rval = mbi_->get_connectivity(&tet, 1, verts);
|
||||
if (rval != moab::MB_SUCCESS) {
|
||||
warning("Failed to get vertices of tet in umesh: " + filename_);
|
||||
|
|
@ -1930,8 +1921,8 @@ int MOABMesh::get_index_from_bin(int bin) const
|
|||
return bin;
|
||||
}
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
MOABMesh::plot(Position plot_ll, Position plot_ur) const
|
||||
std::pair<vector<double>, vector<double>> MOABMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
// TODO: Implement mesh lines
|
||||
return {};
|
||||
|
|
@ -1982,7 +1973,7 @@ MOABMesh::centroid(int bin) const
|
|||
auto tet = this->get_ent_handle_from_bin(bin);
|
||||
|
||||
// look up the tet connectivity
|
||||
std::vector<moab::EntityHandle> conn;
|
||||
vector<moab::EntityHandle> conn;
|
||||
rval = mbi_->get_connectivity(&tet, 1, conn);
|
||||
if (rval != moab::MB_SUCCESS) {
|
||||
warning("Failed to get connectivity of a mesh element.");
|
||||
|
|
@ -1990,7 +1981,7 @@ MOABMesh::centroid(int bin) const
|
|||
}
|
||||
|
||||
// get the coordinates
|
||||
std::vector<moab::CartVect> coords(conn.size());
|
||||
vector<moab::CartVect> coords(conn.size());
|
||||
rval = mbi_->get_coords(conn.data(), conn.size(), coords[0].array());
|
||||
if (rval != moab::MB_SUCCESS) {
|
||||
warning("Failed to get the coordinates of a mesh element.");
|
||||
|
|
@ -2089,10 +2080,8 @@ void MOABMesh::remove_scores()
|
|||
tag_names_.clear();
|
||||
}
|
||||
|
||||
void
|
||||
MOABMesh::set_score_data(const std::string& score,
|
||||
const std::vector<double>& values,
|
||||
const std::vector<double>& std_dev)
|
||||
void MOABMesh::set_score_data(const std::string& score,
|
||||
const vector<double>& values, const vector<double>& std_dev)
|
||||
{
|
||||
auto score_tags = this->get_score_tags(score);
|
||||
|
||||
|
|
@ -2157,7 +2146,7 @@ void LibMesh::initialize()
|
|||
// assuming that unstructured meshes used in OpenMC are 3D
|
||||
n_dimension_ = 3;
|
||||
|
||||
m_ = std::make_unique<libMesh::Mesh>(*settings::libmesh_comm, n_dimension_);
|
||||
m_ = make_unique<libMesh::Mesh>(*settings::libmesh_comm, n_dimension_);
|
||||
m_->read(filename_);
|
||||
m_->prepare_for_use();
|
||||
|
||||
|
|
@ -2169,7 +2158,7 @@ void LibMesh::initialize()
|
|||
// create an equation system for storing values
|
||||
eq_system_name_ = fmt::format("mesh_{}_system", id_);
|
||||
|
||||
equation_systems_ = std::make_unique<libMesh::EquationSystems>(*m_);
|
||||
equation_systems_ = make_unique<libMesh::EquationSystems>(*m_);
|
||||
libMesh::ExplicitSystem& eq_sys =
|
||||
equation_systems_->add_system<libMesh::ExplicitSystem>(eq_system_name_);
|
||||
|
||||
|
|
@ -2209,11 +2198,8 @@ int LibMesh::n_bins() const
|
|||
return m_->n_elem();
|
||||
}
|
||||
|
||||
void
|
||||
LibMesh::surface_bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins) const
|
||||
void LibMesh::surface_bins_crossed(
|
||||
Position r0, Position r1, const Direction& u, vector<int>& bins) const
|
||||
{
|
||||
// TODO: Implement triangle crossings here
|
||||
throw std::runtime_error{"Unstructured mesh surface tallies are not implemented."};
|
||||
|
|
@ -2263,10 +2249,8 @@ LibMesh::remove_scores()
|
|||
variable_map_.clear();
|
||||
}
|
||||
|
||||
void
|
||||
LibMesh::set_score_data(const std::string& var_name,
|
||||
const std::vector<double>& values,
|
||||
const std::vector<double>& std_dev)
|
||||
void LibMesh::set_score_data(const std::string& var_name,
|
||||
const vector<double>& values, const vector<double>& std_dev)
|
||||
{
|
||||
auto& eqn_sys = equation_systems_->get_system(eq_system_name_);
|
||||
|
||||
|
|
@ -2285,13 +2269,13 @@ LibMesh::set_score_data(const std::string& var_name,
|
|||
auto bin = get_bin_from_element(*it);
|
||||
|
||||
// set value
|
||||
std::vector<libMesh::dof_id_type> value_dof_indices;
|
||||
vector<libMesh::dof_id_type> value_dof_indices;
|
||||
dof_map.dof_indices(*it, value_dof_indices, value_num);
|
||||
Ensures(value_dof_indices.size() == 1);
|
||||
eqn_sys.solution->set(value_dof_indices[0], values.at(bin));
|
||||
|
||||
// set std dev
|
||||
std::vector<libMesh::dof_id_type> std_dev_dof_indices;
|
||||
vector<libMesh::dof_id_type> std_dev_dof_indices;
|
||||
dof_map.dof_indices(*it, std_dev_dof_indices, std_dev_num);
|
||||
Ensures(std_dev_dof_indices.size() == 1);
|
||||
eqn_sys.solution->set(std_dev_dof_indices[0], std_dev.at(bin));
|
||||
|
|
@ -2310,8 +2294,8 @@ void
|
|||
LibMesh::bins_crossed(Position r0,
|
||||
Position r1,
|
||||
const Direction& u,
|
||||
std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
vector<int>& bins,
|
||||
vector<double>& lengths) const
|
||||
{
|
||||
// TODO: Implement triangle crossings here
|
||||
fatal_error("Tracklength tallies on libMesh instances are not implemented.");
|
||||
|
|
@ -2348,8 +2332,8 @@ LibMesh::get_bin_from_element(const libMesh::Elem* elem) const
|
|||
return bin;
|
||||
}
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
LibMesh::plot(Position plot_ll, Position plot_ur) const
|
||||
std::pair<vector<double>, vector<double>> LibMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
|
@ -2389,16 +2373,16 @@ void read_meshes(pugi::xml_node root)
|
|||
|
||||
// Read mesh and add to vector
|
||||
if (mesh_type == "regular") {
|
||||
model::meshes.push_back(std::make_unique<RegularMesh>(node));
|
||||
model::meshes.push_back(make_unique<RegularMesh>(node));
|
||||
} else if (mesh_type == "rectilinear") {
|
||||
model::meshes.push_back(std::make_unique<RectilinearMesh>(node));
|
||||
model::meshes.push_back(make_unique<RectilinearMesh>(node));
|
||||
#ifdef DAGMC
|
||||
} else if (mesh_type == "unstructured" && mesh_lib == "moab") {
|
||||
model::meshes.push_back(std::make_unique<MOABMesh>(node));
|
||||
model::meshes.push_back(make_unique<MOABMesh>(node));
|
||||
#endif
|
||||
#ifdef LIBMESH
|
||||
} else if (mesh_type == "unstructured" && mesh_lib == "libmesh") {
|
||||
model::meshes.push_back(std::make_unique<LibMesh>(node));
|
||||
model::meshes.push_back(make_unique<LibMesh>(node));
|
||||
#endif
|
||||
} else if (mesh_type == "unstructured") {
|
||||
fatal_error("Unstructured mesh support is not enabled or the mesh library is invalid.");
|
||||
|
|
@ -2420,7 +2404,7 @@ void meshes_to_hdf5(hid_t group)
|
|||
|
||||
if (n_meshes > 0) {
|
||||
// Write IDs of meshes
|
||||
std::vector<int> ids;
|
||||
vector<int> ids;
|
||||
for (const auto& m : model::meshes) {
|
||||
m->to_hdf5(meshes_group);
|
||||
ids.push_back(m->id_);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ bool master {true};
|
|||
|
||||
#ifdef OPENMC_MPI
|
||||
MPI_Comm intracomm {MPI_COMM_NULL};
|
||||
MPI_Datatype bank {MPI_DATATYPE_NULL};
|
||||
MPI_Datatype source_site {MPI_DATATYPE_NULL};
|
||||
#endif
|
||||
|
||||
extern "C" bool openmc_master() { return mpi::master; }
|
||||
|
|
|
|||
73
src/mgxs.cpp
73
src/mgxs.cpp
|
|
@ -29,11 +29,10 @@ namespace openmc {
|
|||
// Mgxs base-class methods
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
Mgxs::init(const std::string& in_name, double in_awr,
|
||||
const std::vector<double>& in_kTs, bool in_fissionable,
|
||||
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const std::vector<double>& in_polar, const std::vector<double>& in_azimuthal)
|
||||
void Mgxs::init(const std::string& in_name, double in_awr,
|
||||
const vector<double>& in_kTs, bool in_fissionable,
|
||||
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const vector<double>& in_polar, const vector<double>& in_azimuthal)
|
||||
{
|
||||
// Set the metadata
|
||||
name = in_name;
|
||||
|
|
@ -56,14 +55,13 @@ Mgxs::init(const std::string& in_name, double in_awr,
|
|||
int n_threads = 1;
|
||||
#endif
|
||||
cache.resize(n_threads);
|
||||
// std::vector.resize() will value-initialize the members of cache[:]
|
||||
// vector.resize() will value-initialize the members of cache[:]
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
|
||||
std::vector<int>& temps_to_read, int& order_dim)
|
||||
void Mgxs::metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
|
||||
vector<int>& temps_to_read, int& order_dim)
|
||||
{
|
||||
// get name
|
||||
char char_name[MAX_WORD_LEN];
|
||||
|
|
@ -88,7 +86,7 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
|
|||
dset_names[i] = new char[151];
|
||||
}
|
||||
get_datasets(kT_group, dset_names);
|
||||
std::vector<size_t> shape = {num_temps};
|
||||
vector<size_t> shape = {num_temps};
|
||||
xt::xarray<double> available_temps(shape);
|
||||
for (int i = 0; i < num_temps; i++) {
|
||||
read_double(kT_group, dset_names[i], &available_temps[i], true);
|
||||
|
|
@ -160,7 +158,7 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
|
|||
|
||||
// Get the library's temperatures
|
||||
int n_temperature = temps_to_read.size();
|
||||
std::vector<double> in_kTs(n_temperature);
|
||||
vector<double> in_kTs(n_temperature);
|
||||
for (int i = 0; i < n_temperature; i++) {
|
||||
std::string temp_str(std::to_string(temps_to_read[i]) + "K");
|
||||
|
||||
|
|
@ -254,12 +252,12 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
|
|||
}
|
||||
|
||||
// Set the angular bins to use equally-spaced bins
|
||||
std::vector<double> in_polar(in_n_pol);
|
||||
vector<double> in_polar(in_n_pol);
|
||||
double dangle = PI / in_n_pol;
|
||||
for (int p = 0; p < in_n_pol; p++) {
|
||||
in_polar[p] = (p + 0.5) * dangle;
|
||||
}
|
||||
std::vector<double> in_azimuthal(in_n_azi);
|
||||
vector<double> in_azimuthal(in_n_azi);
|
||||
dangle = 2. * PI / in_n_azi;
|
||||
for (int a = 0; a < in_n_azi; a++) {
|
||||
in_azimuthal[a] = (a + 0.5) * dangle - PI;
|
||||
|
|
@ -273,14 +271,13 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
|
|||
|
||||
//==============================================================================
|
||||
|
||||
Mgxs::Mgxs(hid_t xs_id, const std::vector<double>& temperature,
|
||||
int num_group, int num_delay) :
|
||||
num_groups(num_group),
|
||||
num_delayed_groups(num_delay)
|
||||
Mgxs::Mgxs(
|
||||
hid_t xs_id, const vector<double>& temperature, int num_group, int num_delay)
|
||||
: num_groups(num_group), num_delayed_groups(num_delay)
|
||||
{
|
||||
// Call generic data gathering routine (will populate the metadata)
|
||||
int order_data;
|
||||
std::vector<int> temps_to_read;
|
||||
vector<int> temps_to_read;
|
||||
metadata_from_hdf5(xs_id, temperature, temps_to_read, order_data);
|
||||
|
||||
// Set number of energy and delayed groups
|
||||
|
|
@ -309,11 +306,10 @@ Mgxs::Mgxs(hid_t xs_id, const std::vector<double>& temperature,
|
|||
|
||||
//==============================================================================
|
||||
|
||||
Mgxs::Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
|
||||
const std::vector<Mgxs*>& micros, const std::vector<double>& atom_densities,
|
||||
int num_group, int num_delay) :
|
||||
num_groups(num_group),
|
||||
num_delayed_groups(num_delay)
|
||||
Mgxs::Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
||||
const vector<Mgxs*>& micros, const vector<double>& atom_densities,
|
||||
int num_group, int num_delay)
|
||||
: num_groups(num_group), num_delayed_groups(num_delay)
|
||||
{
|
||||
// Get the minimum data needed to initialize:
|
||||
// Dont need awr, but lets just initialize it anyways
|
||||
|
|
@ -328,8 +324,8 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
|
|||
// to be true later
|
||||
AngleDistributionType in_scatter_format = micros[0]->scatter_format;
|
||||
bool in_is_isotropic = micros[0]->is_isotropic;
|
||||
std::vector<double> in_polar = micros[0]->polar;
|
||||
std::vector<double> in_azimuthal = micros[0]->azimuthal;
|
||||
vector<double> in_polar = micros[0]->polar;
|
||||
vector<double> in_azimuthal = micros[0]->azimuthal;
|
||||
|
||||
init(in_name, in_awr, mat_kTs, in_fissionable, in_scatter_format,
|
||||
in_is_isotropic, in_polar, in_azimuthal);
|
||||
|
|
@ -344,8 +340,8 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
|
|||
|
||||
// Create the list of temperature indices and interpolation factors for
|
||||
// each microscopic data at the material temperature
|
||||
std::vector<int> micro_t(micros.size(), 0);
|
||||
std::vector<double> micro_t_interp(micros.size(), 0.);
|
||||
vector<int> micro_t(micros.size(), 0);
|
||||
vector<double> micro_t_interp(micros.size(), 0.);
|
||||
for (int m = 0; m < micros.size(); m++) {
|
||||
switch(settings::temperature_method) {
|
||||
case TemperatureMethod::NEAREST:
|
||||
|
|
@ -383,9 +379,9 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
|
|||
// a different nuclide. Mathematically this just means the temperature
|
||||
// interpolant is included in the number density.
|
||||
// These interpolants are contained within interpolant.
|
||||
std::vector<double> interpolant; // the interpolant for the Mgxs
|
||||
std::vector<int> temp_indices; // the temperature index for each Mgxs
|
||||
std::vector<Mgxs*> mgxs_to_combine; // The Mgxs to combine
|
||||
vector<double> interpolant; // the interpolant for the Mgxs
|
||||
vector<int> temp_indices; // the temperature index for each Mgxs
|
||||
vector<Mgxs*> mgxs_to_combine; // The Mgxs to combine
|
||||
// Now go through and build the above vectors so that we can use them to
|
||||
// combine the data. We will step through each microscopic data and
|
||||
// add in its lower and upper temperature points
|
||||
|
|
@ -419,12 +415,11 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
Mgxs::combine(const std::vector<Mgxs*>& micros, const std::vector<double>& scalars,
|
||||
const std::vector<int>& micro_ts, int this_t)
|
||||
void Mgxs::combine(const vector<Mgxs*>& micros, const vector<double>& scalars,
|
||||
const vector<int>& micro_ts, int this_t)
|
||||
{
|
||||
// Build the vector of pointers to the xs objects within micros
|
||||
std::vector<XsData*> those_xs(micros.size());
|
||||
vector<XsData*> those_xs(micros.size());
|
||||
for (int i = 0; i < micros.size(); i++) {
|
||||
those_xs[i] = &(micros[i]->xs[micro_ts[i]]);
|
||||
}
|
||||
|
|
@ -627,13 +622,13 @@ Mgxs::calculate_xs(Particle& p)
|
|||
#else
|
||||
int tid = 0;
|
||||
#endif
|
||||
set_temperature_index(p.sqrtkT_);
|
||||
set_temperature_index(p.sqrtkT());
|
||||
set_angle_index(p.u_local());
|
||||
XsData* xs_t = &xs[cache[tid].t];
|
||||
p.macro_xs_.total = xs_t->total(cache[tid].a, p.g_);
|
||||
p.macro_xs_.absorption = xs_t->absorption(cache[tid].a, p.g_);
|
||||
p.macro_xs_.nu_fission =
|
||||
fissionable ? xs_t->nu_fission(cache[tid].a, p.g_) : 0.;
|
||||
p.macro_xs().total = xs_t->total(cache[tid].a, p.g());
|
||||
p.macro_xs().absorption = xs_t->absorption(cache[tid].a, p.g());
|
||||
p.macro_xs().nu_fission =
|
||||
fissionable ? xs_t->nu_fission(cache[tid].a, p.g()) : 0.;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue