mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Apply clang-format on entire source
This commit is contained in:
parent
4c17061a1d
commit
1bc2bd8460
181 changed files with 7372 additions and 6952 deletions
|
|
@ -1,21 +1,21 @@
|
|||
#ifndef OPENMC_PLOT_H
|
||||
#define OPENMC_PLOT_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xarray.hpp"
|
||||
|
||||
#include "hdf5.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/geometry.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -30,8 +30,9 @@ namespace model {
|
|||
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
|
||||
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
|
||||
extern uint64_t
|
||||
plotter_prn_seeds[N_STREAMS]; // Random number seeds used for plotter
|
||||
extern int plotter_stream; // Stream index used by the plotter
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -40,10 +41,10 @@ extern int plotter_stream; // Stream index used by the plotter
|
|||
//===============================================================================
|
||||
|
||||
struct RGBColor {
|
||||
//Constructors
|
||||
RGBColor() : red(0), green(0), blue(0) { };
|
||||
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) { };
|
||||
// Constructors
|
||||
RGBColor() : red(0), green(0), blue(0) {};
|
||||
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 vector<int>& v)
|
||||
{
|
||||
|
|
@ -55,7 +56,8 @@ struct RGBColor {
|
|||
blue = v[2];
|
||||
}
|
||||
|
||||
bool operator ==(const RGBColor& other) {
|
||||
bool operator==(const RGBColor& other)
|
||||
{
|
||||
return red == other.red && green == other.green && blue == other.blue;
|
||||
}
|
||||
|
||||
|
|
@ -65,8 +67,7 @@ struct RGBColor {
|
|||
|
||||
// some default colors
|
||||
const RGBColor WHITE {255, 255, 255};
|
||||
const RGBColor RED {255, 0, 0};
|
||||
|
||||
const RGBColor RED {255, 0, 0};
|
||||
|
||||
typedef xt::xtensor<RGBColor, 2> ImageData;
|
||||
|
||||
|
|
@ -94,48 +95,40 @@ struct PropertyData {
|
|||
xt::xtensor<double, 3> data_; //!< 2D array of temperature & density data
|
||||
};
|
||||
|
||||
enum class PlotType {
|
||||
slice = 1,
|
||||
voxel = 2
|
||||
};
|
||||
enum class PlotType { slice = 1, voxel = 2 };
|
||||
|
||||
enum class PlotBasis {
|
||||
xy = 1,
|
||||
xz = 2,
|
||||
yz = 3
|
||||
};
|
||||
enum class PlotBasis { xy = 1, xz = 2, yz = 3 };
|
||||
|
||||
enum class PlotColorBy {
|
||||
cells = 0,
|
||||
mats = 1
|
||||
};
|
||||
enum class PlotColorBy { cells = 0, mats = 1 };
|
||||
|
||||
//===============================================================================
|
||||
// Plot class
|
||||
//===============================================================================
|
||||
class PlotBase {
|
||||
public:
|
||||
template<class T> T get_map() const;
|
||||
template<class T>
|
||||
T get_map() const;
|
||||
|
||||
// Members
|
||||
public:
|
||||
Position origin_; //!< Plot origin in geometry
|
||||
Position width_; //!< Plot width in geometry
|
||||
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
|
||||
Position origin_; //!< Plot origin in geometry
|
||||
Position width_; //!< Plot width in geometry
|
||||
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
|
||||
array<size_t, 3> pixels_; //!< Plot size in pixels
|
||||
bool color_overlaps_; //!< Show overlapping cells?
|
||||
int level_; //!< Plot universe level
|
||||
bool color_overlaps_; //!< Show overlapping cells?
|
||||
int level_; //!< Plot universe level
|
||||
};
|
||||
|
||||
template<class T>
|
||||
T PlotBase::get_map() const {
|
||||
T PlotBase::get_map() const
|
||||
{
|
||||
|
||||
size_t width = pixels_[0];
|
||||
size_t height = pixels_[1];
|
||||
|
||||
// get pixel size
|
||||
double in_pixel = (width_[0])/static_cast<double>(width);
|
||||
double out_pixel = (width_[1])/static_cast<double>(height);
|
||||
double in_pixel = (width_[0]) / static_cast<double>(width);
|
||||
double out_pixel = (width_[1]) / static_cast<double>(height);
|
||||
|
||||
// size data array
|
||||
T data(width, height);
|
||||
|
|
@ -143,16 +136,16 @@ T PlotBase::get_map() const {
|
|||
// setup basis indices and initial position centered on pixel
|
||||
int in_i, out_i;
|
||||
Position xyz = origin_;
|
||||
switch(basis_) {
|
||||
case PlotBasis::xy :
|
||||
switch (basis_) {
|
||||
case PlotBasis::xy:
|
||||
in_i = 0;
|
||||
out_i = 1;
|
||||
break;
|
||||
case PlotBasis::xz :
|
||||
case PlotBasis::xz:
|
||||
in_i = 0;
|
||||
out_i = 2;
|
||||
break;
|
||||
case PlotBasis::yz :
|
||||
case PlotBasis::yz:
|
||||
in_i = 1;
|
||||
out_i = 2;
|
||||
break;
|
||||
|
|
@ -167,25 +160,27 @@ T PlotBase::get_map() const {
|
|||
// arbitrary direction
|
||||
Direction dir = {0.7071, 0.7071, 0.0};
|
||||
|
||||
#pragma omp parallel
|
||||
#pragma omp parallel
|
||||
{
|
||||
Particle p;
|
||||
p.r() = xyz;
|
||||
p.u() = dir;
|
||||
p.coord(0).universe = model::root_universe;
|
||||
int level = level_;
|
||||
int j{};
|
||||
int j {};
|
||||
|
||||
#pragma omp for
|
||||
#pragma omp for
|
||||
for (int y = 0; y < height; y++) {
|
||||
p.r()[out_i] = xyz[out_i] - out_pixel * y;
|
||||
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;
|
||||
// local variables
|
||||
bool found_cell = exhaustive_find_cell(p);
|
||||
j = p.n_coord() - 1;
|
||||
if (level >= 0) { j = level; }
|
||||
if (level >= 0) {
|
||||
j = level;
|
||||
}
|
||||
if (found_cell) {
|
||||
data.set_value(y, x, p, j);
|
||||
}
|
||||
|
|
@ -193,8 +188,8 @@ T PlotBase::get_map() const {
|
|||
data.set_overlap(y, x);
|
||||
}
|
||||
} // inner for
|
||||
} // outer for
|
||||
} // omp parallel
|
||||
} // outer for
|
||||
} // omp parallel
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -221,18 +216,18 @@ private:
|
|||
void set_mask(pugi::xml_node plot_node);
|
||||
void set_overlap_color(pugi::xml_node plot_node);
|
||||
|
||||
// Members
|
||||
// Members
|
||||
public:
|
||||
int id_; //!< Plot ID
|
||||
PlotType type_; //!< Plot type (Slice/Voxel)
|
||||
PlotColorBy color_by_; //!< Plot coloring (cell/material)
|
||||
int meshlines_width_; //!< Width of lines added to the plot
|
||||
int id_; //!< Plot ID
|
||||
PlotType type_; //!< Plot type (Slice/Voxel)
|
||||
PlotColorBy color_by_; //!< Plot coloring (cell/material)
|
||||
int meshlines_width_; //!< Width of lines added to the plot
|
||||
int index_meshlines_mesh_ {-1}; //!< Index of the mesh to draw on the plot
|
||||
RGBColor meshlines_color_; //!< Color of meshlines on the plot
|
||||
RGBColor not_found_ {WHITE}; //!< Plot background color
|
||||
RGBColor overlap_color_ {RED}; //!< Plot overlap color
|
||||
vector<RGBColor> colors_; //!< Plot colors
|
||||
std::string path_plot_; //!< Plot output filename
|
||||
RGBColor meshlines_color_; //!< Color of meshlines on the plot
|
||||
RGBColor not_found_ {WHITE}; //!< Plot background color
|
||||
RGBColor overlap_color_ {RED}; //!< Plot overlap color
|
||||
vector<RGBColor> colors_; //!< Plot colors
|
||||
std::string path_plot_; //!< Plot output filename
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
|
|
@ -255,16 +250,16 @@ void output_ppm(Plot const& pl, const ImageData& data);
|
|||
//! \param[out] dataspace pointer to voxel data
|
||||
//! \param[out] dataset pointer to voxesl data
|
||||
//! \param[out] pointer to memory space of voxel data
|
||||
void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace,
|
||||
hid_t* dset, hid_t* memspace);
|
||||
void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace, hid_t* dset,
|
||||
hid_t* memspace);
|
||||
|
||||
//! Write a section of the voxel data to hdf5
|
||||
//! \param[in] voxel slice
|
||||
//! \param[out] dataspace pointer to voxel data
|
||||
//! \param[out] dataset pointer to voxesl data
|
||||
//! \param[out] pointer to data to write
|
||||
void voxel_write_slice(int x, hid_t dspace, hid_t dset,
|
||||
hid_t memspace, void* buf);
|
||||
void voxel_write_slice(
|
||||
int x, hid_t dspace, hid_t dset, hid_t memspace, void* buf);
|
||||
|
||||
//! Close voxel file entities
|
||||
//! \param[in] data space to close
|
||||
|
|
@ -291,6 +286,5 @@ void create_voxel(Plot const& pl);
|
|||
//! \return RGBColor with random value
|
||||
RGBColor random_color();
|
||||
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_PLOT_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue