mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-25 20:45:35 -04:00
Adding skeleton for create_ppm.
This commit is contained in:
parent
7637db6774
commit
2f8e5a4c9d
2 changed files with 92 additions and 14 deletions
101
src/plot.cpp
101
src/plot.cpp
|
|
@ -2,6 +2,8 @@
|
|||
#include "openmc/constants.h"
|
||||
#include "openmc/settings.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/geometry.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -9,17 +11,21 @@ const int RED = 1;
|
|||
const int GREEN = 2;
|
||||
const int BLUE = 3;
|
||||
|
||||
int openmc_plot_geometry() {
|
||||
int err;
|
||||
//===============================================================================
|
||||
// RUN_PLOT controls the logic for making one or many plots
|
||||
//===============================================================================
|
||||
|
||||
int openmc_plot_geometry() {
|
||||
int err;
|
||||
|
||||
for(auto i : n_plots) {
|
||||
ObjectPlot* pl = plots[i];
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Processing plot " << pl->id_ << ": "
|
||||
<< pl->path_plot_ << "...";
|
||||
for(auto i : n_plots) {
|
||||
ObjectPlot* pl = plots[i];
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Processing plot " << pl->id_ << ": "
|
||||
<< pl->path_plot_ << "...";
|
||||
write_message(ss.str(), 5);
|
||||
|
||||
|
||||
if (pl->type_ == PLOT_TYPE::SLICE) {
|
||||
// create 2D image
|
||||
// create_ppm(pl);
|
||||
|
|
@ -30,11 +36,80 @@ const int BLUE = 3;
|
|||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
// CREATE_PPM creates an image based on user input from a plots.xml <plot>
|
||||
// specification in the portable pixmap format (PPM)
|
||||
//===============================================================================
|
||||
|
||||
void create_ppm(ObjectPlot* pl) {
|
||||
|
||||
int width = pl->pixels_[0];
|
||||
int height = pl->pixels_[1];
|
||||
|
||||
double in_pixel = (pl->width_[0])/double(width);
|
||||
double out_pixel = (pl->width_[1])/double(height);
|
||||
|
||||
std::vector< std::vector< std::vector<int>>> data;
|
||||
|
||||
data.resize(width);
|
||||
for (auto i : data) {
|
||||
i.resize(height);
|
||||
for (auto j : i) { j.resize(3); }
|
||||
}
|
||||
|
||||
int in_i, out_i;
|
||||
double xyz[3];
|
||||
if (pl->basis_ == PLOT_BASIS::XY) {
|
||||
in_i = 0;
|
||||
out_i = 1;
|
||||
xyz[0] = pl->origin_[0] - pl->width_[0] / TWO;
|
||||
xyz[1] = pl->origin_[1] - pl->width_[1] / TWO;
|
||||
xyz[2] = pl->origin_[2];
|
||||
} else if (pl->basis_ == PLOT_BASIS::XZ) {
|
||||
in_i = 0;
|
||||
out_i = 2;
|
||||
xyz[0] = pl->origin_[0] - pl->width_[0] / TWO;
|
||||
xyz[1] = pl->origin_[1];
|
||||
xyz[2] = pl->origin_[2] - pl->width_[1] / TWO;
|
||||
} else if (pl->basis_ == PLOT_BASIS::YZ) {
|
||||
in_i = 1;
|
||||
out_i = 2;
|
||||
xyz[0] = pl->origin_[0];
|
||||
xyz[1] = pl->origin_[1] - pl->width_[0] / TWO;
|
||||
xyz[2] = pl->origin_[2] - pl->width_[1] / TWO;
|
||||
}
|
||||
|
||||
double dir[3];
|
||||
Particle *p = new Particle();
|
||||
p->initialize();
|
||||
std::copy(xyz, xyz+3, p->coord[0].xyz);
|
||||
std::copy(dir, dir+3, p->coord[0].uvw);
|
||||
p->coord[0].universe = openmc_root_universe;
|
||||
|
||||
// local variables
|
||||
int rgb[3];
|
||||
int id;
|
||||
for(int y = 0; y < height; y++) {
|
||||
p->coord[0].xyz[out_i] = xyz[out_i] - out_pixel*(y);
|
||||
for(int x = 0; x < width; x++) {
|
||||
p->coord[0].xyz[in_i] = xyz[in_i] + in_pixel*(x);
|
||||
// position_rgb(p, pl, rgb, id);
|
||||
|
||||
std::copy(rgb, rgb+3, &(data[x][y][0]));
|
||||
}
|
||||
}
|
||||
|
||||
//output_ppm(pl, data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace, hid_t* dset,
|
||||
hid_t* memspace)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue