• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 5979019501

25 Aug 2023 06:04PM UTC coverage: 84.434% (-0.003%) from 84.437%
5979019501

push

github

web-flow
Always set html_theme in readthedocs configuration (#2667)

46790 of 55416 relevant lines covered (84.43%)

78088697.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.78
/src/plot.cpp
1
#include "openmc/plot.h"
2

3
#include <algorithm>
4
#include <cstdio>
5
#include <fstream>
6
#include <sstream>
7

8
#include "xtensor/xmanipulation.hpp"
9
#include "xtensor/xview.hpp"
10
#include <fmt/core.h>
11
#include <fmt/ostream.h>
12
#ifdef USE_LIBPNG
13
#include <png.h>
14
#endif
15

16
#include "openmc/constants.h"
17
#include "openmc/container_util.h"
18
#include "openmc/dagmc.h"
19
#include "openmc/error.h"
20
#include "openmc/file_utils.h"
21
#include "openmc/geometry.h"
22
#include "openmc/hdf5_interface.h"
23
#include "openmc/material.h"
24
#include "openmc/mesh.h"
25
#include "openmc/message_passing.h"
26
#include "openmc/output.h"
27
#include "openmc/particle.h"
28
#include "openmc/progress_bar.h"
29
#include "openmc/random_lcg.h"
30
#include "openmc/settings.h"
31
#include "openmc/simulation.h"
32
#include "openmc/string_utils.h"
33

34
namespace openmc {
35

36
//==============================================================================
37
// Constants
38
//==============================================================================
39

40
constexpr int PLOT_LEVEL_LOWEST {-1}; //!< lower bound on plot universe level
41
constexpr int32_t NOT_FOUND {-2};
42
constexpr int32_t OVERLAP {-3};
43

44
IdData::IdData(size_t h_res, size_t v_res) : data_({v_res, h_res, 3}, NOT_FOUND)
6,286✔
45
{}
6,286✔
46

47
void IdData::set_value(size_t y, size_t x, const Particle& p, int level)
45,065,174✔
48
{
49
  // set cell data
50
  if (p.n_coord() <= level) {
45,065,174✔
51
    data_(y, x, 0) = NOT_FOUND;
×
52
    data_(y, x, 1) = NOT_FOUND;
×
53
  } else {
54
    data_(y, x, 0) = model::cells.at(p.coord(level).cell)->id_;
45,065,174✔
55
    data_(y, x, 1) = level == p.n_coord() - 1
90,130,348✔
56
                       ? p.cell_instance()
45,065,174✔
57
                       : cell_instance_at_level(p, level);
×
58
  }
59

60
  // set material data
61
  Cell* c = model::cells.at(p.lowest_coord().cell).get();
45,065,174✔
62
  if (p.material() == MATERIAL_VOID) {
45,065,174✔
63
    data_(y, x, 2) = MATERIAL_VOID;
34,747,664✔
64
    return;
34,747,664✔
65
  } else if (c->type_ == Fill::MATERIAL) {
10,317,510✔
66
    Material* m = model::materials.at(p.material()).get();
10,317,510✔
67
    data_(y, x, 2) = m->id_;
10,317,510✔
68
  }
69
}
70

71
void IdData::set_overlap(size_t y, size_t x)
35,952✔
72
{
73
  xt::view(data_, y, x, xt::all()) = OVERLAP;
35,952✔
74
}
35,952✔
75

76
PropertyData::PropertyData(size_t h_res, size_t v_res)
14✔
77
  : data_({v_res, h_res, 2}, NOT_FOUND)
14✔
78
{}
14✔
79

80
void PropertyData::set_value(size_t y, size_t x, const Particle& p, int level)
126✔
81
{
82
  Cell* c = model::cells.at(p.lowest_coord().cell).get();
126✔
83
  data_(y, x, 0) = (p.sqrtkT() * p.sqrtkT()) / K_BOLTZMANN;
126✔
84
  if (c->type_ != Fill::UNIVERSE && p.material() != MATERIAL_VOID) {
126✔
85
    Material* m = model::materials.at(p.material()).get();
126✔
86
    data_(y, x, 1) = m->density_gpcc_;
126✔
87
  }
88
}
126✔
89

90
void PropertyData::set_overlap(size_t y, size_t x)
×
91
{
92
  data_(y, x) = OVERLAP;
×
93
}
94

95
//==============================================================================
96
// Global variables
97
//==============================================================================
98

99
namespace model {
100

101
std::unordered_map<int, int> plot_map;
102
vector<std::unique_ptr<PlottableInterface>> plots;
103
uint64_t plotter_seed = 1;
104

105
} // namespace model
106

107
//==============================================================================
108
// RUN_PLOT controls the logic for making one or many plots
109
//==============================================================================
110

111
extern "C" int openmc_plot_geometry()
224✔
112
{
113

114
  for (auto& pl : model::plots) {
616✔
115
    write_message(5, "Processing plot {}: {}...", pl->id(), pl->path_plot());
392✔
116
    pl->create_output();
392✔
117
  }
118

119
  return 0;
224✔
120
}
121

122
void Plot::create_output() const
322✔
123
{
124
  if (PlotType::slice == type_) {
322✔
125
    // create 2D image
126
    create_image();
252✔
127
  } else if (PlotType::voxel == type_) {
70✔
128
    // create voxel file for 3D viewing
129
    create_voxel();
70✔
130
  }
131
}
322✔
132

133
void Plot::print_info() const
294✔
134
{
135
  // Plot type
136
  if (PlotType::slice == type_) {
294✔
137
    fmt::print("Plot Type: Slice\n");
448✔
138
  } else if (PlotType::voxel == type_) {
70✔
139
    fmt::print("Plot Type: Voxel\n");
140✔
140
  }
141

142
  // Plot parameters
143
  fmt::print("Origin: {} {} {}\n", origin_[0], origin_[1], origin_[2]);
294✔
144

145
  if (PlotType::slice == type_) {
294✔
146
    fmt::print("Width: {:4} {:4}\n", width_[0], width_[1]);
448✔
147
  } else if (PlotType::voxel == type_) {
70✔
148
    fmt::print("Width: {:4} {:4} {:4}\n", width_[0], width_[1], width_[2]);
140✔
149
  }
150

151
  if (PlotColorBy::cells == color_by_) {
294✔
152
    fmt::print("Coloring: Cells\n");
392✔
153
  } else if (PlotColorBy::mats == color_by_) {
98✔
154
    fmt::print("Coloring: Materials\n");
196✔
155
  }
156

157
  if (PlotType::slice == type_) {
294✔
158
    switch (basis_) {
224✔
159
    case PlotBasis::xy:
112✔
160
      fmt::print("Basis: XY\n");
112✔
161
      break;
112✔
162
    case PlotBasis::xz:
56✔
163
      fmt::print("Basis: XZ\n");
56✔
164
      break;
56✔
165
    case PlotBasis::yz:
56✔
166
      fmt::print("Basis: YZ\n");
56✔
167
      break;
56✔
168
    }
169
    fmt::print("Pixels: {} {}\n", pixels_[0], pixels_[1]);
448✔
170
  } else if (PlotType::voxel == type_) {
70✔
171
    fmt::print("Voxels: {} {} {}\n", pixels_[0], pixels_[1], pixels_[2]);
140✔
172
  }
173
}
294✔
174

175
void read_plots_xml()
1,779✔
176
{
177
  // Check if plots.xml exists; this is only necessary when the plot runmode is
178
  // initiated. Otherwise, we want to read plots.xml because it may be called
179
  // later via the API. In that case, its ok for a plots.xml to not exist
180
  std::string filename = settings::path_input + "plots.xml";
1,779✔
181
  if (!file_exists(filename) && settings::run_mode == RunMode::PLOTTING) {
1,779✔
182
    fatal_error(fmt::format("Plots XML file '{}' does not exist!", filename));
×
183
  }
184

185
  write_message("Reading plot XML file...", 5);
1,779✔
186

187
  // Parse plots.xml file
188
  pugi::xml_document doc;
1,779✔
189
  doc.load_file(filename.c_str());
1,779✔
190

191
  pugi::xml_node root = doc.document_element();
1,779✔
192

193
  read_plots_xml(root);
1,779✔
194
}
1,779✔
195

196
void read_plots_xml(pugi::xml_node root)
1,966✔
197
{
198
  for (auto node : root.children("plot")) {
2,850✔
199
    std::string id_string = get_node_value(node, "id", true);
884✔
200
    int id = std::stoi(id_string);
884✔
201
    if (check_for_node(node, "type")) {
884✔
202
      std::string type_str = get_node_value(node, "type", true);
884✔
203
      if (type_str == "slice")
884✔
204
        model::plots.emplace_back(
744✔
205
          std::make_unique<Plot>(node, Plot::PlotType::slice));
1,488✔
206
      else if (type_str == "voxel")
140✔
207
        model::plots.emplace_back(
70✔
208
          std::make_unique<Plot>(node, Plot::PlotType::voxel));
140✔
209
      else if (type_str == "projection")
70✔
210
        model::plots.emplace_back(std::make_unique<ProjectionPlot>(node));
70✔
211
      else
212
        fatal_error(
×
213
          fmt::format("Unsupported plot type '{}' in plot {}", type_str, id));
×
214

215
      model::plot_map[model::plots.back()->id()] = model::plots.size() - 1;
884✔
216
    } else {
884✔
217
      fatal_error(fmt::format("Must specify plot type in plot {}", id));
×
218
    }
219
  }
884✔
220
}
1,966✔
221

222
void free_memory_plot()
6,472✔
223
{
224
  model::plots.clear();
6,472✔
225
  model::plot_map.clear();
6,472✔
226
}
6,472✔
227

228
// creates an image based on user input from a plots.xml <plot>
229
// specification in the PNG/PPM format
230
void Plot::create_image() const
252✔
231
{
232

233
  size_t width = pixels_[0];
252✔
234
  size_t height = pixels_[1];
252✔
235

236
  ImageData data({width, height}, not_found_);
252✔
237

238
  // generate ids for the plot
239
  auto ids = get_map<IdData>();
252✔
240

241
  // assign colors
242
  for (size_t y = 0; y < height; y++) {
39,032✔
243
    for (size_t x = 0; x < width; x++) {
9,708,580✔
244
      int idx = color_by_ == PlotColorBy::cells ? 0 : 2;
9,669,800✔
245
      auto id = ids.data_(y, x, idx);
9,669,800✔
246
      // no setting needed if not found
247
      if (id == NOT_FOUND) {
9,669,800✔
248
        continue;
1,378,328✔
249
      }
250
      if (id == OVERLAP) {
8,327,424✔
251
        data(x, y) = overlap_color_;
35,952✔
252
        continue;
35,952✔
253
      }
254
      if (PlotColorBy::cells == color_by_) {
8,291,472✔
255
        data(x, y) = colors_[model::cell_map[id]];
3,837,512✔
256
      } else if (PlotColorBy::mats == color_by_) {
4,453,960✔
257
        if (id == MATERIAL_VOID) {
4,453,960✔
258
          data(x, y) = WHITE;
×
259
          continue;
×
260
        }
261
        data(x, y) = colors_[model::material_map[id]];
4,453,960✔
262
      } // color_by if-else
263
    }   // x for loop
264
  }     // y for loop
265

266
  // draw mesh lines if present
267
  if (index_meshlines_mesh_ >= 0) {
252✔
268
    draw_mesh_lines(data);
42✔
269
  }
270

271
// create image file
272
#ifdef USE_LIBPNG
273
  output_png(path_plot(), data);
252✔
274
#else
275
  output_ppm(path_plot(), data);
276
#endif
277
}
252✔
278

279
void PlottableInterface::set_id(pugi::xml_node plot_node)
884✔
280
{
281
  // Copy data into plots
282
  if (check_for_node(plot_node, "id")) {
884✔
283
    id_ = std::stoi(get_node_value(plot_node, "id"));
884✔
284
  } else {
285
    fatal_error("Must specify plot id in plots XML file.");
×
286
  }
287

288
  // Check to make sure 'id' hasn't been used
289
  if (model::plot_map.find(id_) != model::plot_map.end()) {
884✔
290
    fatal_error(
×
291
      fmt::format("Two or more plots use the same unique ID: {}", id_));
×
292
  }
293
}
884✔
294

295
// Checks if png or ppm is already present
296
bool file_extension_present(
884✔
297
  const std::string& filename, const std::string& extension)
298
{
299
  std::string file_extension_if_present =
300
    filename.substr(filename.find_last_of(".") + 1);
884✔
301
  if (file_extension_if_present == extension)
884✔
302
    return true;
28✔
303
  return false;
856✔
304
}
884✔
305

306
void Plot::set_output_path(pugi::xml_node plot_node)
814✔
307
{
308
  // Set output file path
309
  std::string filename;
814✔
310

311
  if (check_for_node(plot_node, "filename")) {
814✔
312
    filename = get_node_value(plot_node, "filename");
254✔
313
  } else {
314
    filename = fmt::format("plot_{}", id());
1,120✔
315
  }
316
  // add appropriate file extension to name
317
  switch (type_) {
814✔
318
  case PlotType::slice:
744✔
319
#ifdef USE_LIBPNG
320
    if (!file_extension_present(filename, "png"))
744✔
321
      filename.append(".png");
744✔
322
#else
323
    if (!file_extension_present(filename, "ppm"))
324
      filename.append(".ppm");
325
#endif
326
    break;
744✔
327
  case PlotType::voxel:
70✔
328
    if (!file_extension_present(filename, "h5"))
70✔
329
      filename.append(".h5");
70✔
330
    break;
70✔
331
  }
332

333
  path_plot_ = filename;
814✔
334

335
  // Copy plot pixel size
336
  vector<int> pxls = get_node_array<int>(plot_node, "pixels");
1,628✔
337
  if (PlotType::slice == type_) {
814✔
338
    if (pxls.size() == 2) {
744✔
339
      pixels_[0] = pxls[0];
744✔
340
      pixels_[1] = pxls[1];
744✔
341
    } else {
342
      fatal_error(
×
343
        fmt::format("<pixels> must be length 2 in slice plot {}", id()));
×
344
    }
345
  } else if (PlotType::voxel == type_) {
70✔
346
    if (pxls.size() == 3) {
70✔
347
      pixels_[0] = pxls[0];
70✔
348
      pixels_[1] = pxls[1];
70✔
349
      pixels_[2] = pxls[2];
70✔
350
    } else {
351
      fatal_error(
×
352
        fmt::format("<pixels> must be length 3 in voxel plot {}", id()));
×
353
    }
354
  }
355
}
814✔
356

357
void PlottableInterface::set_bg_color(pugi::xml_node plot_node)
884✔
358
{
359
  // Copy plot background color
360
  if (check_for_node(plot_node, "background")) {
884✔
361
    vector<int> bg_rgb = get_node_array<int>(plot_node, "background");
56✔
362
    if (bg_rgb.size() == 3) {
56✔
363
      not_found_ = bg_rgb;
56✔
364
    } else {
365
      fatal_error(fmt::format("Bad background RGB in plot {}", id()));
×
366
    }
367
  }
56✔
368
}
884✔
369

370
void Plot::set_basis(pugi::xml_node plot_node)
814✔
371
{
372
  // Copy plot basis
373
  if (PlotType::slice == type_) {
814✔
374
    std::string pl_basis = "xy";
744✔
375
    if (check_for_node(plot_node, "basis")) {
744✔
376
      pl_basis = get_node_value(plot_node, "basis", true);
744✔
377
    }
378
    if ("xy" == pl_basis) {
744✔
379
      basis_ = PlotBasis::xy;
594✔
380
    } else if ("xz" == pl_basis) {
150✔
381
      basis_ = PlotBasis::xz;
56✔
382
    } else if ("yz" == pl_basis) {
94✔
383
      basis_ = PlotBasis::yz;
94✔
384
    } else {
385
      fatal_error(
×
386
        fmt::format("Unsupported plot basis '{}' in plot {}", pl_basis, id()));
×
387
    }
388
  }
744✔
389
}
814✔
390

391
void Plot::set_origin(pugi::xml_node plot_node)
814✔
392
{
393
  // Copy plotting origin
394
  auto pl_origin = get_node_array<double>(plot_node, "origin");
814✔
395
  if (pl_origin.size() == 3) {
814✔
396
    origin_ = pl_origin;
814✔
397
  } else {
398
    fatal_error(fmt::format("Origin must be length 3 in plot {}", id()));
×
399
  }
400
}
814✔
401

402
void Plot::set_width(pugi::xml_node plot_node)
814✔
403
{
404
  // Copy plotting width
405
  vector<double> pl_width = get_node_array<double>(plot_node, "width");
814✔
406
  if (PlotType::slice == type_) {
814✔
407
    if (pl_width.size() == 2) {
744✔
408
      width_.x = pl_width[0];
744✔
409
      width_.y = pl_width[1];
744✔
410
    } else {
411
      fatal_error(
×
412
        fmt::format("<width> must be length 2 in slice plot {}", id()));
×
413
    }
414
  } else if (PlotType::voxel == type_) {
70✔
415
    if (pl_width.size() == 3) {
70✔
416
      pl_width = get_node_array<double>(plot_node, "width");
70✔
417
      width_ = pl_width;
70✔
418
    } else {
419
      fatal_error(
×
420
        fmt::format("<width> must be length 3 in voxel plot {}", id()));
×
421
    }
422
  }
423
}
814✔
424

425
void PlottableInterface::set_universe(pugi::xml_node plot_node)
884✔
426
{
427
  // Copy plot universe level
428
  if (check_for_node(plot_node, "level")) {
884✔
429
    level_ = std::stoi(get_node_value(plot_node, "level"));
×
430
    if (level_ < 0) {
×
431
      fatal_error(fmt::format("Bad universe level in plot {}", id()));
×
432
    }
433
  } else {
434
    level_ = PLOT_LEVEL_LOWEST;
884✔
435
  }
436
}
884✔
437

438
void PlottableInterface::set_default_colors(pugi::xml_node plot_node)
884✔
439
{
440
  // Copy plot color type and initialize all colors randomly
441
  std::string pl_color_by = "cell";
884✔
442
  if (check_for_node(plot_node, "color_by")) {
884✔
443
    pl_color_by = get_node_value(plot_node, "color_by", true);
842✔
444
  }
445
  if ("cell" == pl_color_by) {
884✔
446
    color_by_ = PlotColorBy::cells;
407✔
447
    colors_.resize(model::cells.size());
407✔
448
  } else if ("material" == pl_color_by) {
477✔
449
    color_by_ = PlotColorBy::mats;
477✔
450
    colors_.resize(model::materials.size());
477✔
451
  } else {
452
    fatal_error(fmt::format(
×
453
      "Unsupported plot color type '{}' in plot {}", pl_color_by, id()));
×
454
  }
455

456
  for (auto& c : colors_) {
4,007✔
457
    c = random_color();
3,123✔
458
    // make sure we don't interfere with some default colors
459
    while (c == RED || c == WHITE) {
3,123✔
460
      c = random_color();
×
461
    }
462
  }
463
}
884✔
464

465
void PlottableInterface::set_user_colors(pugi::xml_node plot_node)
884✔
466
{
467
  for (auto cn : plot_node.children("color")) {
1,164✔
468
    // Make sure 3 values are specified for RGB
469
    vector<int> user_rgb = get_node_array<int>(cn, "rgb");
280✔
470
    if (user_rgb.size() != 3) {
280✔
471
      fatal_error(fmt::format("Bad RGB in plot {}", id()));
×
472
    }
473
    // Ensure that there is an id for this color specification
474
    int col_id;
475
    if (check_for_node(cn, "id")) {
280✔
476
      col_id = std::stoi(get_node_value(cn, "id"));
280✔
477
    } else {
478
      fatal_error(fmt::format(
×
479
        "Must specify id for color specification in plot {}", id()));
×
480
    }
481
    // Add RGB
482
    if (PlotColorBy::cells == color_by_) {
280✔
483
      if (model::cell_map.find(col_id) != model::cell_map.end()) {
154✔
484
        col_id = model::cell_map[col_id];
112✔
485
        colors_[col_id] = user_rgb;
112✔
486
      } else {
487
        warning(fmt::format(
42✔
488
          "Could not find cell {} specified in plot {}", col_id, id()));
84✔
489
      }
490
    } else if (PlotColorBy::mats == color_by_) {
126✔
491
      if (model::material_map.find(col_id) != model::material_map.end()) {
126✔
492
        col_id = model::material_map[col_id];
126✔
493
        colors_[col_id] = user_rgb;
126✔
494
      } else {
495
        warning(fmt::format(
×
496
          "Could not find material {} specified in plot {}", col_id, id()));
×
497
      }
498
    }
499
  } // color node loop
280✔
500
}
884✔
501

502
void Plot::set_meshlines(pugi::xml_node plot_node)
814✔
503
{
504
  // Deal with meshlines
505
  pugi::xpath_node_set mesh_line_nodes = plot_node.select_nodes("meshlines");
814✔
506

507
  if (!mesh_line_nodes.empty()) {
814✔
508
    if (PlotType::voxel == type_) {
42✔
509
      warning(fmt::format("Meshlines ignored in voxel plot {}", id()));
×
510
    }
511

512
    if (mesh_line_nodes.size() == 1) {
42✔
513
      // Get first meshline node
514
      pugi::xml_node meshlines_node = mesh_line_nodes[0].node();
42✔
515

516
      // Check mesh type
517
      std::string meshtype;
42✔
518
      if (check_for_node(meshlines_node, "meshtype")) {
42✔
519
        meshtype = get_node_value(meshlines_node, "meshtype");
42✔
520
      } else {
521
        fatal_error(fmt::format(
×
522
          "Must specify a meshtype for meshlines specification in plot {}",
523
          id()));
×
524
      }
525

526
      // Ensure that there is a linewidth for this meshlines specification
527
      std::string meshline_width;
42✔
528
      if (check_for_node(meshlines_node, "linewidth")) {
42✔
529
        meshline_width = get_node_value(meshlines_node, "linewidth");
42✔
530
        meshlines_width_ = std::stoi(meshline_width);
42✔
531
      } else {
532
        fatal_error(fmt::format(
×
533
          "Must specify a linewidth for meshlines specification in plot {}",
534
          id()));
×
535
      }
536

537
      // Check for color
538
      if (check_for_node(meshlines_node, "color")) {
42✔
539
        // Check and make sure 3 values are specified for RGB
540
        vector<int> ml_rgb = get_node_array<int>(meshlines_node, "color");
×
541
        if (ml_rgb.size() != 3) {
×
542
          fatal_error(
×
543
            fmt::format("Bad RGB for meshlines color in plot {}", id()));
×
544
        }
545
        meshlines_color_ = ml_rgb;
×
546
      }
547

548
      // Set mesh based on type
549
      if ("ufs" == meshtype) {
42✔
550
        if (!simulation::ufs_mesh) {
×
551
          fatal_error(
×
552
            fmt::format("No UFS mesh for meshlines on plot {}", id()));
×
553
        } else {
554
          for (int i = 0; i < model::meshes.size(); ++i) {
×
555
            if (const auto* m =
×
556
                  dynamic_cast<const RegularMesh*>(model::meshes[i].get())) {
×
557
              if (m == simulation::ufs_mesh) {
×
558
                index_meshlines_mesh_ = i;
×
559
              }
560
            }
561
          }
562
          if (index_meshlines_mesh_ == -1)
×
563
            fatal_error("Could not find the UFS mesh for meshlines plot");
×
564
        }
565
      } else if ("entropy" == meshtype) {
42✔
566
        if (!simulation::entropy_mesh) {
28✔
567
          fatal_error(
×
568
            fmt::format("No entropy mesh for meshlines on plot {}", id()));
×
569
        } else {
570
          for (int i = 0; i < model::meshes.size(); ++i) {
70✔
571
            if (const auto* m =
42✔
572
                  dynamic_cast<const RegularMesh*>(model::meshes[i].get())) {
42✔
573
              if (m == simulation::entropy_mesh) {
28✔
574
                index_meshlines_mesh_ = i;
28✔
575
              }
576
            }
577
          }
578
          if (index_meshlines_mesh_ == -1)
28✔
579
            fatal_error("Could not find the entropy mesh for meshlines plot");
×
580
        }
581
      } else if ("tally" == meshtype) {
14✔
582
        // Ensure that there is a mesh id if the type is tally
583
        int tally_mesh_id;
584
        if (check_for_node(meshlines_node, "id")) {
14✔
585
          tally_mesh_id = std::stoi(get_node_value(meshlines_node, "id"));
14✔
586
        } else {
587
          std::stringstream err_msg;
×
588
          fatal_error(fmt::format("Must specify a mesh id for meshlines tally "
×
589
                                  "mesh specification in plot {}",
590
            id()));
×
591
        }
×
592
        // find the tally index
593
        int idx;
594
        int err = openmc_get_mesh_index(tally_mesh_id, &idx);
14✔
595
        if (err != 0) {
14✔
596
          fatal_error(fmt::format("Could not find mesh {} specified in "
×
597
                                  "meshlines for plot {}",
598
            tally_mesh_id, id()));
×
599
        }
600
        index_meshlines_mesh_ = idx;
14✔
601
      } else {
602
        fatal_error(fmt::format("Invalid type for meshlines on plot {}", id()));
×
603
      }
604
    } else {
42✔
605
      fatal_error(fmt::format("Mutliple meshlines specified in plot {}", id()));
×
606
    }
607
  }
608
}
814✔
609

610
void PlottableInterface::set_mask(pugi::xml_node plot_node)
884✔
611
{
612
  // Deal with masks
613
  pugi::xpath_node_set mask_nodes = plot_node.select_nodes("mask");
884✔
614

615
  if (!mask_nodes.empty()) {
884✔
616
    if (mask_nodes.size() == 1) {
42✔
617
      // Get pointer to mask
618
      pugi::xml_node mask_node = mask_nodes[0].node();
42✔
619

620
      // Determine how many components there are and allocate
621
      vector<int> iarray = get_node_array<int>(mask_node, "components");
42✔
622
      if (iarray.size() == 0) {
42✔
623
        fatal_error(
×
624
          fmt::format("Missing <components> in mask of plot {}", id()));
×
625
      }
626

627
      // First we need to change the user-specified identifiers to indices
628
      // in the cell and material arrays
629
      for (auto& col_id : iarray) {
126✔
630
        if (PlotColorBy::cells == color_by_) {
84✔
631
          if (model::cell_map.find(col_id) != model::cell_map.end()) {
84✔
632
            col_id = model::cell_map[col_id];
84✔
633
          } else {
634
            fatal_error(fmt::format("Could not find cell {} specified in the "
×
635
                                    "mask in plot {}",
636
              col_id, id()));
×
637
          }
638
        } else if (PlotColorBy::mats == color_by_) {
×
639
          if (model::material_map.find(col_id) != model::material_map.end()) {
×
640
            col_id = model::material_map[col_id];
×
641
          } else {
642
            fatal_error(fmt::format("Could not find material {} specified in "
×
643
                                    "the mask in plot {}",
644
              col_id, id()));
×
645
          }
646
        }
647
      }
648

649
      // Alter colors based on mask information
650
      for (int j = 0; j < colors_.size(); j++) {
168✔
651
        if (contains(iarray, j)) {
126✔
652
          if (check_for_node(mask_node, "background")) {
84✔
653
            vector<int> bg_rgb = get_node_array<int>(mask_node, "background");
84✔
654
            colors_[j] = bg_rgb;
84✔
655
          } else {
84✔
656
            colors_[j] = WHITE;
×
657
          }
658
        }
659
      }
660

661
    } else {
42✔
662
      fatal_error(fmt::format("Mutliple masks specified in plot {}", id()));
×
663
    }
664
  }
665
}
884✔
666

667
void PlottableInterface::set_overlap_color(pugi::xml_node plot_node)
884✔
668
{
669
  color_overlaps_ = false;
884✔
670
  if (check_for_node(plot_node, "show_overlaps")) {
884✔
671
    color_overlaps_ = get_node_value_bool(plot_node, "show_overlaps");
28✔
672
    // check for custom overlap color
673
    if (check_for_node(plot_node, "overlap_color")) {
28✔
674
      if (!color_overlaps_) {
14✔
675
        warning(fmt::format(
×
676
          "Overlap color specified in plot {} but overlaps won't be shown.",
677
          id()));
×
678
      }
679
      vector<int> olap_clr = get_node_array<int>(plot_node, "overlap_color");
14✔
680
      if (olap_clr.size() == 3) {
14✔
681
        overlap_color_ = olap_clr;
14✔
682
      } else {
683
        fatal_error(fmt::format("Bad overlap RGB in plot {}", id()));
×
684
      }
685
    }
14✔
686
  }
687

688
  // make sure we allocate the vector for counting overlap checks if
689
  // they're going to be plotted
690
  if (color_overlaps_ && settings::run_mode == RunMode::PLOTTING) {
884✔
691
    settings::check_overlaps = true;
28✔
692
    model::overlap_check_count.resize(model::cells.size(), 0);
28✔
693
  }
694
}
884✔
695

696
PlottableInterface::PlottableInterface(pugi::xml_node plot_node)
884✔
697
{
698
  set_id(plot_node);
884✔
699
  set_bg_color(plot_node);
884✔
700
  set_universe(plot_node);
884✔
701
  set_default_colors(plot_node);
884✔
702
  set_user_colors(plot_node);
884✔
703
  set_mask(plot_node);
884✔
704
  set_overlap_color(plot_node);
884✔
705
}
884✔
706

707
Plot::Plot(pugi::xml_node plot_node, PlotType type)
814✔
708
  : PlottableInterface(plot_node), type_(type), index_meshlines_mesh_ {-1}
814✔
709
{
710
  set_output_path(plot_node);
814✔
711
  set_basis(plot_node);
814✔
712
  set_origin(plot_node);
814✔
713
  set_width(plot_node);
814✔
714
  set_meshlines(plot_node);
814✔
715
  slice_level_ = level_; // Copy level employed in SlicePlotBase::get_map
814✔
716
  slice_color_overlaps_ = color_overlaps_;
814✔
717
}
814✔
718

719
//==============================================================================
720
// OUTPUT_PPM writes out a previously generated image to a PPM file
721
//==============================================================================
722

723
void output_ppm(const std::string& filename, const ImageData& data)
×
724
{
725
  // Open PPM file for writing
726
  std::string fname = filename;
×
727
  fname = strtrim(fname);
×
728
  std::ofstream of;
×
729

730
  of.open(fname);
×
731

732
  // Write header
733
  of << "P6\n";
×
734
  of << data.shape()[0] << " " << data.shape()[1] << "\n";
×
735
  of << "255\n";
×
736
  of.close();
×
737

738
  of.open(fname, std::ios::binary | std::ios::app);
×
739
  // Write color for each pixel
740
  for (int y = 0; y < data.shape()[1]; y++) {
×
741
    for (int x = 0; x < data.shape()[0]; x++) {
×
742
      RGBColor rgb = data(x, y);
×
743
      of << rgb.red << rgb.green << rgb.blue;
×
744
    }
745
  }
746
  of << "\n";
×
747
}
748

749
//==============================================================================
750
// OUTPUT_PNG writes out a previously generated image to a PNG file
751
//==============================================================================
752

753
#ifdef USE_LIBPNG
754
void output_png(const std::string& filename, const ImageData& data)
322✔
755
{
756
  // Open PNG file for writing
757
  std::string fname = filename;
322✔
758
  fname = strtrim(fname);
322✔
759
  auto fp = std::fopen(fname.c_str(), "wb");
322✔
760

761
  // Initialize write and info structures
762
  auto png_ptr =
763
    png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
322✔
764
  auto info_ptr = png_create_info_struct(png_ptr);
322✔
765

766
  // Setup exception handling
767
  if (setjmp(png_jmpbuf(png_ptr)))
322✔
768
    fatal_error("Error during png creation");
×
769

770
  png_init_io(png_ptr, fp);
322✔
771

772
  // Write header (8 bit colour depth)
773
  int width = data.shape()[0];
322✔
774
  int height = data.shape()[1];
322✔
775
  png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
322✔
776
    PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
777
  png_write_info(png_ptr, info_ptr);
322✔
778

779
  // Allocate memory for one row (3 bytes per pixel - RGB)
780
  std::vector<png_byte> row(3 * width);
322✔
781

782
  // Write color for each pixel
783
  for (int y = 0; y < height; y++) {
53,102✔
784
    for (int x = 0; x < width; x++) {
12,522,580✔
785
      RGBColor rgb = data(x, y);
12,469,800✔
786
      row[3 * x] = rgb.red;
12,469,800✔
787
      row[3 * x + 1] = rgb.green;
12,469,800✔
788
      row[3 * x + 2] = rgb.blue;
12,469,800✔
789
    }
790
    png_write_row(png_ptr, row.data());
52,780✔
791
  }
792

793
  // End write
794
  png_write_end(png_ptr, nullptr);
322✔
795

796
  // Clean up data structures
797
  std::fclose(fp);
322✔
798
  png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
322✔
799
  png_destroy_write_struct(&png_ptr, &info_ptr);
322✔
800
}
322✔
801
#endif
802

803
//==============================================================================
804
// DRAW_MESH_LINES draws mesh line boundaries on an image
805
//==============================================================================
806

807
void Plot::draw_mesh_lines(ImageData& data) const
42✔
808
{
809
  RGBColor rgb;
42✔
810
  rgb = meshlines_color_;
42✔
811

812
  int ax1, ax2;
813
  switch (basis_) {
42✔
814
  case PlotBasis::xy:
28✔
815
    ax1 = 0;
28✔
816
    ax2 = 1;
28✔
817
    break;
28✔
818
  case PlotBasis::xz:
14✔
819
    ax1 = 0;
14✔
820
    ax2 = 2;
14✔
821
    break;
14✔
822
  case PlotBasis::yz:
×
823
    ax1 = 1;
×
824
    ax2 = 2;
×
825
    break;
×
826
  default:
×
827
    UNREACHABLE();
×
828
  }
829

830
  Position ll_plot {origin_};
42✔
831
  Position ur_plot {origin_};
42✔
832

833
  ll_plot[ax1] -= width_[0] / 2.;
42✔
834
  ll_plot[ax2] -= width_[1] / 2.;
42✔
835
  ur_plot[ax1] += width_[0] / 2.;
42✔
836
  ur_plot[ax2] += width_[1] / 2.;
42✔
837

838
  Position width = ur_plot - ll_plot;
42✔
839

840
  // Find the (axis-aligned) lines of the mesh that intersect this plot.
841
  auto axis_lines =
842
    model::meshes[index_meshlines_mesh_]->plot(ll_plot, ur_plot);
42✔
843

844
  // Find the bounds along the second axis (accounting for low-D meshes).
845
  int ax2_min, ax2_max;
846
  if (axis_lines.second.size() > 0) {
42✔
847
    double frac = (axis_lines.second.back() - ll_plot[ax2]) / width[ax2];
42✔
848
    ax2_min = (1.0 - frac) * pixels_[1];
42✔
849
    if (ax2_min < 0)
42✔
850
      ax2_min = 0;
×
851
    frac = (axis_lines.second.front() - ll_plot[ax2]) / width[ax2];
42✔
852
    ax2_max = (1.0 - frac) * pixels_[1];
42✔
853
    if (ax2_max > pixels_[1])
42✔
854
      ax2_max = pixels_[1];
×
855
  } else {
856
    ax2_min = 0;
×
857
    ax2_max = pixels_[1];
×
858
  }
859

860
  // Iterate across the first axis and draw lines.
861
  for (auto ax1_val : axis_lines.first) {
238✔
862
    double frac = (ax1_val - ll_plot[ax1]) / width[ax1];
196✔
863
    int ax1_ind = frac * pixels_[0];
196✔
864
    for (int ax2_ind = ax2_min; ax2_ind < ax2_max; ++ax2_ind) {
31,752✔
865
      for (int plus = 0; plus <= meshlines_width_; plus++) {
63,112✔
866
        if (ax1_ind + plus >= 0 && ax1_ind + plus < pixels_[0])
31,556✔
867
          data(ax1_ind + plus, ax2_ind) = rgb;
31,556✔
868
        if (ax1_ind - plus >= 0 && ax1_ind - plus < pixels_[0])
31,556✔
869
          data(ax1_ind - plus, ax2_ind) = rgb;
31,556✔
870
      }
871
    }
872
  }
873

874
  // Find the bounds along the first axis.
875
  int ax1_min, ax1_max;
876
  if (axis_lines.first.size() > 0) {
42✔
877
    double frac = (axis_lines.first.front() - ll_plot[ax1]) / width[ax1];
42✔
878
    ax1_min = frac * pixels_[0];
42✔
879
    if (ax1_min < 0)
42✔
880
      ax1_min = 0;
×
881
    frac = (axis_lines.first.back() - ll_plot[ax1]) / width[ax1];
42✔
882
    ax1_max = frac * pixels_[0];
42✔
883
    if (ax1_max > pixels_[0])
42✔
884
      ax1_max = pixels_[0];
×
885
  } else {
886
    ax1_min = 0;
×
887
    ax1_max = pixels_[0];
×
888
  }
889

890
  // Iterate across the second axis and draw lines.
891
  for (auto ax2_val : axis_lines.second) {
266✔
892
    double frac = (ax2_val - ll_plot[ax2]) / width[ax2];
224✔
893
    int ax2_ind = (1.0 - frac) * pixels_[1];
224✔
894
    for (int ax1_ind = ax1_min; ax1_ind < ax1_max; ++ax1_ind) {
36,064✔
895
      for (int plus = 0; plus <= meshlines_width_; plus++) {
71,680✔
896
        if (ax2_ind + plus >= 0 && ax2_ind + plus < pixels_[1])
35,840✔
897
          data(ax1_ind, ax2_ind + plus) = rgb;
35,840✔
898
        if (ax2_ind - plus >= 0 && ax2_ind - plus < pixels_[1])
35,840✔
899
          data(ax1_ind, ax2_ind - plus) = rgb;
35,840✔
900
      }
901
    }
902
  }
903
}
42✔
904

905
/* outputs a binary file that can be input into silomesh for 3D geometry
906
 * visualization.  It works the same way as create_image by dragging a particle
907
 * across the geometry for the specified number of voxels. The first 3 int's in
908
 * the binary are the number of x, y, and z voxels.  The next 3 double's are
909
 * the widths of the voxels in the x, y, and z directions. The next 3 double's
910
 * are the x, y, and z coordinates of the lower left point. Finally the binary
911
 * is filled with entries of four int's each. Each 'row' in the binary contains
912
 * four int's: 3 for x,y,z position and 1 for cell or material id.  For 1
913
 * million voxels this produces a file of approximately 15MB.
914
 */
915
void Plot::create_voxel() const
70✔
916
{
917
  // compute voxel widths in each direction
918
  array<double, 3> vox;
919
  vox[0] = width_[0] / static_cast<double>(pixels_[0]);
70✔
920
  vox[1] = width_[1] / static_cast<double>(pixels_[1]);
70✔
921
  vox[2] = width_[2] / static_cast<double>(pixels_[2]);
70✔
922

923
  // initial particle position
924
  Position ll = origin_ - width_ / 2.;
70✔
925

926
  // Open binary plot file for writing
927
  std::ofstream of;
70✔
928
  std::string fname = std::string(path_plot_);
70✔
929
  fname = strtrim(fname);
70✔
930
  hid_t file_id = file_open(fname, 'w');
70✔
931

932
  // write header info
933
  write_attribute(file_id, "filetype", "voxel");
70✔
934
  write_attribute(file_id, "version", VERSION_VOXEL);
70✔
935
  write_attribute(file_id, "openmc_version", VERSION);
70✔
936

937
#ifdef GIT_SHA1
938
  write_attribute(file_id, "git_sha1", GIT_SHA1);
70✔
939
#endif
940

941
  // Write current date and time
942
  write_attribute(file_id, "date_and_time", time_stamp().c_str());
70✔
943
  array<int, 3> pixels;
944
  std::copy(pixels_.begin(), pixels_.end(), pixels.begin());
70✔
945
  write_attribute(file_id, "num_voxels", pixels);
70✔
946
  write_attribute(file_id, "voxel_width", vox);
70✔
947
  write_attribute(file_id, "lower_left", ll);
70✔
948

949
  // Create dataset for voxel data -- note that the dimensions are reversed
950
  // since we want the order in the file to be z, y, x
951
  hsize_t dims[3];
952
  dims[0] = pixels_[2];
70✔
953
  dims[1] = pixels_[1];
70✔
954
  dims[2] = pixels_[0];
70✔
955
  hid_t dspace, dset, memspace;
956
  voxel_init(file_id, &(dims[0]), &dspace, &dset, &memspace);
70✔
957

958
  SlicePlotBase pltbase;
70✔
959
  pltbase.width_ = width_;
70✔
960
  pltbase.origin_ = origin_;
70✔
961
  pltbase.basis_ = PlotBasis::xy;
70✔
962
  pltbase.pixels_ = pixels_;
70✔
963
  pltbase.slice_color_overlaps_ = color_overlaps_;
70✔
964

965
  ProgressBar pb;
70✔
966
  for (int z = 0; z < pixels_[2]; z++) {
6,090✔
967
    // update progress bar
968
    pb.set_value(
6,020✔
969
      100. * static_cast<double>(z) / static_cast<double>((pixels_[2] - 1)));
6,020✔
970

971
    // update z coordinate
972
    pltbase.origin_.z = ll.z + z * vox[2];
6,020✔
973

974
    // generate ids using plotbase
975
    IdData ids = pltbase.get_map<IdData>();
6,020✔
976

977
    // select only cell/material ID data and flip the y-axis
978
    int idx = color_by_ == PlotColorBy::cells ? 0 : 2;
6,020✔
979
    xt::xtensor<int32_t, 2> data_slice =
980
      xt::view(ids.data_, xt::all(), xt::all(), idx);
6,020✔
981
    xt::xtensor<int32_t, 2> data_flipped = xt::flip(data_slice, 0);
6,020✔
982

983
    // Write to HDF5 dataset
984
    voxel_write_slice(z, dspace, dset, memspace, data_flipped.data());
6,020✔
985
  }
6,020✔
986

987
  voxel_finalize(dspace, dset, memspace);
70✔
988
  file_close(file_id);
70✔
989
}
70✔
990

991
void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace, hid_t* dset,
70✔
992
  hid_t* memspace)
993
{
994
  // Create dataspace/dataset for voxel data
995
  *dspace = H5Screate_simple(3, dims, nullptr);
70✔
996
  *dset = H5Dcreate(file_id, "data", H5T_NATIVE_INT, *dspace, H5P_DEFAULT,
70✔
997
    H5P_DEFAULT, H5P_DEFAULT);
998

999
  // Create dataspace for a slice of the voxel
1000
  hsize_t dims_slice[2] {dims[1], dims[2]};
70✔
1001
  *memspace = H5Screate_simple(2, dims_slice, nullptr);
70✔
1002

1003
  // Select hyperslab in dataspace
1004
  hsize_t start[3] {0, 0, 0};
70✔
1005
  hsize_t count[3] {1, dims[1], dims[2]};
70✔
1006
  H5Sselect_hyperslab(*dspace, H5S_SELECT_SET, start, nullptr, count, nullptr);
70✔
1007
}
70✔
1008

1009
void voxel_write_slice(
6,020✔
1010
  int x, hid_t dspace, hid_t dset, hid_t memspace, void* buf)
1011
{
1012
  hssize_t offset[3] {x, 0, 0};
6,020✔
1013
  H5Soffset_simple(dspace, offset);
6,020✔
1014
  H5Dwrite(dset, H5T_NATIVE_INT, memspace, dspace, H5P_DEFAULT, buf);
6,020✔
1015
}
6,020✔
1016

1017
void voxel_finalize(hid_t dspace, hid_t dset, hid_t memspace)
70✔
1018
{
1019
  H5Dclose(dset);
70✔
1020
  H5Sclose(dspace);
70✔
1021
  H5Sclose(memspace);
70✔
1022
}
70✔
1023

1024
RGBColor random_color(void)
3,123✔
1025
{
1026
  return {int(prn(&model::plotter_seed) * 255),
3,123✔
1027
    int(prn(&model::plotter_seed) * 255), int(prn(&model::plotter_seed) * 255)};
3,123✔
1028
}
1029

1030
ProjectionPlot::ProjectionPlot(pugi::xml_node node) : PlottableInterface(node)
70✔
1031
{
1032
  set_output_path(node);
70✔
1033
  set_look_at(node);
70✔
1034
  set_camera_position(node);
70✔
1035
  set_field_of_view(node);
70✔
1036
  set_pixels(node);
70✔
1037
  set_opacities(node);
70✔
1038
  set_orthographic_width(node);
70✔
1039
  set_wireframe_thickness(node);
70✔
1040
  set_wireframe_ids(node);
70✔
1041
  set_wireframe_color(node);
70✔
1042

1043
  if (check_for_node(node, "orthographic_width") &&
84✔
1044
      check_for_node(node, "field_of_view"))
14✔
1045
    fatal_error("orthographic_width and field_of_view are mutually exclusive "
×
1046
                "parameters.");
1047
}
70✔
1048

1049
void ProjectionPlot::set_wireframe_color(pugi::xml_node plot_node)
70✔
1050
{
1051
  // Copy plot background color
1052
  if (check_for_node(plot_node, "wireframe_color")) {
70✔
1053
    vector<int> w_rgb = get_node_array<int>(plot_node, "wireframe_color");
×
1054
    if (w_rgb.size() == 3) {
×
1055
      wireframe_color_ = w_rgb;
×
1056
    } else {
1057
      fatal_error(fmt::format("Bad wireframe RGB in plot {}", id()));
×
1058
    }
1059
  }
1060
}
70✔
1061

1062
void ProjectionPlot::set_output_path(pugi::xml_node node)
70✔
1063
{
1064
  // Set output file path
1065
  std::string filename;
70✔
1066

1067
  if (check_for_node(node, "filename")) {
70✔
1068
    filename = get_node_value(node, "filename");
56✔
1069
  } else {
1070
    filename = fmt::format("plot_{}", id());
28✔
1071
  }
1072

1073
#ifdef USE_LIBPNG
1074
  if (!file_extension_present(filename, "png"))
70✔
1075
    filename.append(".png");
42✔
1076
#else
1077
  if (!file_extension_present(filename, "ppm"))
1078
    filename.append(".ppm");
1079
#endif
1080
  path_plot_ = filename;
70✔
1081
}
70✔
1082

1083
// Advances to the next boundary from outside the geometry
1084
// Returns -1 if no intersection found, and the surface index
1085
// if an intersection was found.
1086
int ProjectionPlot::advance_to_boundary_from_void(Particle& p)
14,654,472✔
1087
{
1088
  constexpr double scoot = 1e-5;
14,654,472✔
1089
  double min_dist = {INFINITY};
14,654,472✔
1090
  auto coord = p.coord(0);
14,654,472✔
1091
  Universe* uni = model::universes[model::root_universe].get();
14,654,472✔
1092
  int intersected_surface = -1;
14,654,472✔
1093
  for (auto c_i : uni->cells_) {
58,617,888✔
1094
    auto dist = model::cells.at(c_i)->distance(coord.r, coord.u, 0, &p);
43,963,416✔
1095
    if (dist.first < min_dist) {
43,963,416✔
1096
      min_dist = dist.first;
19,151,076✔
1097
      intersected_surface = dist.second;
19,151,076✔
1098
    }
1099
  }
1100
  if (min_dist > 1e300)
14,654,472✔
1101
    return -1;
2,800,000✔
1102
  else { // advance the particle
1103
    for (int j = 0; j < p.n_coord(); ++j)
23,708,944✔
1104
      p.coord(j).r += (min_dist + scoot) * p.coord(j).u;
11,854,472✔
1105
    return std::abs(intersected_surface);
11,854,472✔
1106
  }
1107
}
1108

1109
bool ProjectionPlot::trackstack_equivalent(
5,586,000✔
1110
  const std::vector<TrackSegment>& track1,
1111
  const std::vector<TrackSegment>& track2) const
1112
{
1113
  if (wireframe_ids_.empty()) {
5,586,000✔
1114
    // Draw wireframe for all surfaces/cells/materials
1115
    if (track1.size() != track2.size())
4,468,800✔
1116
      return false;
78,596✔
1117
    for (int i = 0; i < track1.size(); ++i) {
9,376,360✔
1118
      if (track1[i].id != track2[i].id ||
10,023,412✔
1119
          track1[i].surface != track2[i].surface) {
5,011,678✔
1120
        return false;
25,578✔
1121
      }
1122
    }
1123
    return true;
4,364,626✔
1124
  } else {
1125
    // This runs in O(nm) where n is the intersection stack size
1126
    // and m is the number of IDs we are wireframing. A simpler
1127
    // algorithm can likely be found.
1128
    for (const int id : wireframe_ids_) {
2,226,686✔
1129
      int t1_i = 0;
1,117,200✔
1130
      int t2_i = 0;
1,117,200✔
1131

1132
      // Advance to first instance of the ID
1133
      while (t1_i < track1.size() && t2_i < track2.size()) {
1,227,380✔
1134
        while (t1_i < track1.size() && track1[t1_i].id != id)
633,038✔
1135
          t1_i++;
369,488✔
1136
        while (t2_i < track2.size() && track2[t2_i].id != id)
633,038✔
1137
          t2_i++;
369,488✔
1138

1139
        // This one is really important!
1140
        if ((t1_i == track1.size() && t2_i != track2.size()) ||
641,438✔
1141
            (t1_i != track1.size() && t2_i == track2.size()))
377,888✔
1142
          return false;
7,714✔
1143
        if (t1_i == track1.size() && t2_i == track2.size())
260,064✔
1144
          break;
145,656✔
1145
        // Check if surface different
1146
        if (track1[t1_i].surface != track2[t2_i].surface)
114,408✔
1147
          return false;
4,228✔
1148

1149
        // Pretty sure this should not be used:
1150
        // if (t2_i != track2.size() - 1 &&
1151
        //     t1_i != track1.size() - 1 &&
1152
        //     track1[t1_i+1].id != track2[t2_i+1].id) return false;
1153
        if (t2_i != 0 && t1_i != 0 &&
198,310✔
1154
            track1[t1_i - 1].surface != track2[t2_i - 1].surface)
88,130✔
1155
          return false;
×
1156

1157
        // Check if neighboring cells are different
1158
        // if (track1[t1_i ? t1_i - 1 : 0].id != track2[t2_i ? t2_i - 1 : 0].id)
1159
        // return false; if (track1[t1_i < track1.size() - 1 ? t1_i + 1 : t1_i
1160
        // ].id !=
1161
        //    track2[t2_i < track2.size() - 1 ? t2_i + 1 : t2_i].id) return
1162
        //    false;
1163
        t1_i++, t2_i++;
110,180✔
1164
      }
1165
    }
1166
    return true;
1,109,486✔
1167
  }
1168
}
1169

1170
void ProjectionPlot::create_output() const
70✔
1171
{
1172
  // Get centerline vector for camera-to-model. We create vectors around this
1173
  // that form a pixel array, and then trace rays along that.
1174
  auto up = up_ / up_.norm();
70✔
1175
  Direction looking_direction = look_at_ - camera_position_;
70✔
1176
  looking_direction /= looking_direction.norm();
70✔
1177
  if (std::abs(std::abs(looking_direction.dot(up)) - 1.0) < 1e-9)
70✔
1178
    fatal_error("Up vector cannot align with vector between camera position "
×
1179
                "and look_at!");
1180
  Direction cam_yaxis = looking_direction.cross(up);
70✔
1181
  cam_yaxis /= cam_yaxis.norm();
70✔
1182
  Direction cam_zaxis = cam_yaxis.cross(looking_direction);
70✔
1183
  cam_zaxis /= cam_zaxis.norm();
70✔
1184

1185
  // Transformation matrix for directions
1186
  std::vector<double> camera_to_model = {looking_direction.x, cam_yaxis.x,
70✔
1187
    cam_zaxis.x, looking_direction.y, cam_yaxis.y, cam_zaxis.y,
70✔
1188
    looking_direction.z, cam_yaxis.z, cam_zaxis.z};
70✔
1189

1190
  // Now we convert to the polar coordinate system with the polar angle
1191
  // measuring the angle from the vector up_. Phi is the rotation about up_. For
1192
  // now, up_ is hard-coded to be +z.
1193
  constexpr double DEGREE_TO_RADIAN = M_PI / 180.0;
70✔
1194
  double horiz_fov_radians = horizontal_field_of_view_ * DEGREE_TO_RADIAN;
70✔
1195
  double p0 = static_cast<double>(pixels_[0]);
70✔
1196
  double p1 = static_cast<double>(pixels_[1]);
70✔
1197
  double vert_fov_radians = horiz_fov_radians * p1 / p0;
70✔
1198
  double dphi = horiz_fov_radians / p0;
70✔
1199
  double dmu = vert_fov_radians / p1;
70✔
1200

1201
  size_t width = pixels_[0];
70✔
1202
  size_t height = pixels_[1];
70✔
1203
  ImageData data({width, height}, not_found_);
70✔
1204

1205
  // This array marks where the initial wireframe was drawn.
1206
  // We convolve it with a filter that gets adjusted with the
1207
  // wireframe thickness in order to thicken the lines.
1208
  xt::xtensor<int, 2> wireframe_initial({width, height}, 0);
70✔
1209

1210
  /* Holds all of the track segments for the current rendered line of pixels.
1211
   * old_segments holds a copy of this_line_segments from the previous line.
1212
   * By holding both we can check if the cell/material intersection stack
1213
   * differs from the left or upper neighbor. This allows a robustly drawn
1214
   * wireframe. If only checking the left pixel (which requires substantially
1215
   * less memory), the wireframe tends to be spotty and be disconnected for
1216
   * surface edges oriented horizontally in the rendering.
1217
   *
1218
   * Note that a vector of vectors is required rather than a 2-tensor,
1219
   * since the stack size varies within each column.
1220
   */
1221
#ifdef _OPENMP
1222
  const int n_threads = omp_get_max_threads();
30✔
1223
#else
1224
  const int n_threads = 1;
40✔
1225
#endif
1226
  std::vector<std::vector<std::vector<TrackSegment>>> this_line_segments(
1227
    n_threads);
70✔
1228
  for (int t = 0; t < n_threads; ++t) {
170✔
1229
    this_line_segments[t].resize(pixels_[0]);
100✔
1230
  }
1231

1232
  // The last thread writes to this, and the first thread reads from it.
1233
  std::vector<std::vector<TrackSegment>> old_segments(pixels_[0]);
70✔
1234

1235
#pragma omp parallel
30✔
1236
  {
1237

1238
#ifdef _OPENMP
1239
    const int n_threads = omp_get_max_threads();
1240
    const int tid = omp_get_thread_num();
1241
#else
1242
    int n_threads = 1;
40✔
1243
    int tid = 0;
40✔
1244
#endif
1245

1246
    SourceSite s; // Where particle starts from (camera)
40✔
1247
    s.E = 1;
40✔
1248
    s.wgt = 1;
40✔
1249
    s.delayed_group = 0;
40✔
1250
    s.particle = ParticleType::photon; // just has to be something reasonable
40✔
1251
    s.parent_id = 1;
40✔
1252
    s.progeny_id = 2;
40✔
1253
    s.r = camera_position_;
40✔
1254

1255
    Particle p;
40✔
1256
    s.u.x = 1.0;
40✔
1257
    s.u.y = 0.0;
40✔
1258
    s.u.z = 0.0;
40✔
1259
    p.from_source(&s);
40✔
1260

1261
    int vert = tid;
40✔
1262
    for (int iter = 0; iter <= pixels_[1] / n_threads; iter++) {
8,080✔
1263

1264
      // Save bottom line of current work chunk to compare against later
1265
      // I used to have this inside the below if block, but it causes a
1266
      // spurious line to be drawn at the bottom of the image. Not sure
1267
      // why, but moving it here fixes things.
1268
      if (tid == n_threads - 1)
8,040✔
1269
        old_segments = this_line_segments[n_threads - 1];
8,040✔
1270

1271
      if (vert < pixels_[1]) {
8,040✔
1272

1273
        for (int horiz = 0; horiz < pixels_[0]; ++horiz) {
1,608,000✔
1274

1275
          // Generate the starting position/direction of the ray
1276
          if (orthographic_width_ == 0.0) { // perspective projection
1,600,000✔
1277
            double this_phi =
1,280,000✔
1278
              -horiz_fov_radians / 2.0 + dphi * horiz + 0.5 * dphi;
1,280,000✔
1279
            double this_mu =
1,280,000✔
1280
              -vert_fov_radians / 2.0 + dmu * vert + M_PI / 2.0 + 0.5 * dmu;
1,280,000✔
1281
            Direction camera_local_vec;
1,280,000✔
1282
            camera_local_vec.x = std::cos(this_phi) * std::sin(this_mu);
1,280,000✔
1283
            camera_local_vec.y = std::sin(this_phi) * std::sin(this_mu);
1,280,000✔
1284
            camera_local_vec.z = std::cos(this_mu);
1,280,000✔
1285
            s.u = camera_local_vec.rotate(camera_to_model);
1,280,000✔
1286
          } else { // orthographic projection
1287
            s.u = looking_direction;
320,000✔
1288

1289
            double x_pix_coord = (static_cast<double>(horiz) - p0 / 2.0) / p0;
320,000✔
1290
            double y_pix_coord = (static_cast<double>(vert) - p1 / 2.0) / p0;
320,000✔
1291
            s.r = camera_position_ +
1292
                  cam_yaxis * x_pix_coord * orthographic_width_ +
320,000✔
1293
                  cam_zaxis * y_pix_coord * orthographic_width_;
320,000✔
1294
          }
1295

1296
          p.from_source(&s); // put particle at camera
1,600,000✔
1297
          bool hitsomething = false;
1,600,000✔
1298
          bool intersection_found = true;
1,600,000✔
1299
          int loop_counter = 0;
1,600,000✔
1300

1301
          this_line_segments[tid][horiz].clear();
1,600,000✔
1302

1303
          int first_surface =
1,600,000✔
1304
            -1; // surface first passed when entering the model
1305
          bool first_inside_model = true; // false after entering the model
1,600,000✔
1306
          while (intersection_found) {
11,014,040✔
1307
            bool inside_cell = false;
9,414,040✔
1308

1309
            int32_t i_surface = std::abs(p.surface()) - 1;
9,414,040✔
1310
            if (i_surface > 0 &&
11,179,064✔
1311
                model::surfaces[i_surface]->geom_type_ == GeometryType::DAG) {
1,765,024✔
1312
#ifdef DAGMC
1313
              int32_t i_cell = next_cell(i_surface,
1314
                p.cell_last(p.n_coord() - 1), p.lowest_coord().universe);
1315
              inside_cell = i_cell >= 0;
1316
#else
1317
              fatal_error(
1318
                "Not compiled for DAGMC, but somehow you have a DAGCell!");
1319
#endif
1320
            } else {
1321
              inside_cell = exhaustive_find_cell(p);
9,414,040✔
1322
            }
1323

1324
            if (inside_cell) {
9,414,040✔
1325

1326
              // This allows drawing wireframes with surface intersection
1327
              // edges on the model boundary for the same cell.
1328
              if (first_inside_model) {
1,040,056✔
1329
                this_line_segments[tid][horiz].emplace_back(
1,191,872✔
1330
                  color_by_ == PlotColorBy::mats ? p.material()
185,272✔
1331
                                                 : p.lowest_coord().cell,
410,664✔
1332
                  0.0, first_surface);
595,936✔
1333
                first_inside_model = false;
595,936✔
1334
              }
1335

1336
              hitsomething = true;
1,040,056✔
1337
              intersection_found = true;
1,040,056✔
1338
              auto dist = distance_to_boundary(p);
1,040,056✔
1339
              this_line_segments[tid][horiz].emplace_back(
2,080,112✔
1340
                color_by_ == PlotColorBy::mats ? p.material()
282,648✔
1341
                                               : p.lowest_coord().cell,
757,408✔
1342
                dist.distance, std::abs(dist.surface_index));
1,040,056✔
1343

1344
              // Advance particle
1345
              for (int lev = 0; lev < p.n_coord(); ++lev) {
2,080,112✔
1346
                p.coord(lev).r += dist.distance * p.coord(lev).u;
1,040,056✔
1347
              }
1348
              p.surface() = dist.surface_index;
1,040,056✔
1349
              p.n_coord_last() = p.n_coord();
1,040,056✔
1350
              p.n_coord() = dist.coord_level;
1,040,056✔
1351
              if (dist.lattice_translation[0] != 0 ||
1,040,056✔
1352
                  dist.lattice_translation[1] != 0 ||
2,080,112✔
1353
                  dist.lattice_translation[2] != 0) {
1,040,056✔
1354
                cross_lattice(p, dist);
1355
              }
1356

1357
            } else {
1358
              first_surface = advance_to_boundary_from_void(p);
8,373,984✔
1359
              intersection_found =
8,373,984✔
1360
                first_surface != -1; // -1 if no surface found
8,373,984✔
1361
            }
1362
            loop_counter++;
9,414,040✔
1363
            if (loop_counter > MAX_INTERSECTIONS)
9,414,040✔
1364
              fatal_error("Infinite loop in projection plot");
1365
          }
1366

1367
          // Now color the pixel based on what we have intersected...
1368
          // Loops backwards over intersections.
1369
          Position current_color(
1370
            not_found_.red, not_found_.green, not_found_.blue);
1,600,000✔
1371
          const auto& segments = this_line_segments[tid][horiz];
1,600,000✔
1372
          for (unsigned i = segments.size(); i-- > 0;) {
3,235,992✔
1373
            int colormap_idx = segments[i].id;
1,635,992✔
1374
            RGBColor seg_color = colors_[colormap_idx];
1,635,992✔
1375
            Position seg_color_vec(
1376
              seg_color.red, seg_color.green, seg_color.blue);
1,635,992✔
1377
            double mixing = std::exp(-xs_[colormap_idx] * segments[i].length);
1,635,992✔
1378
            current_color =
1379
              current_color * mixing + (1.0 - mixing) * seg_color_vec;
1,635,992✔
1380
            RGBColor result;
1,635,992✔
1381
            result.red = static_cast<uint8_t>(current_color.x);
1,635,992✔
1382
            result.green = static_cast<uint8_t>(current_color.y);
1,635,992✔
1383
            result.blue = static_cast<uint8_t>(current_color.z);
1,635,992✔
1384
            data(horiz, vert) = result;
1,635,992✔
1385
          }
1386

1387
          // Check to draw wireframe in horizontal direction. No inter-thread
1388
          // comm.
1389
          if (horiz > 0) {
1,600,000✔
1390
            if (!trackstack_equivalent(this_line_segments[tid][horiz],
1,592,000✔
1391
                  this_line_segments[tid][horiz - 1])) {
1,592,000✔
1392
              wireframe_initial(horiz, vert) = 1;
30,224✔
1393
            }
1394
          }
1395
        }
1396
      } // end "if" vert in correct range
1397

1398
      // We require a barrier before comparing vertical neighbors' intersection
1399
      // stacks. i.e. all threads must be done with their line.
1400
#pragma omp barrier
1401

1402
      // Now that the horizontal line has finished rendering, we can fill in
1403
      // wireframe entries that require comparison among all the threads. Hence
1404
      // the omp barrier being used. It has to be OUTSIDE any if blocks!
1405
      if (vert < pixels_[1]) {
8,040✔
1406
        // Loop over horizontal pixels, checking intersection stack of upper
1407
        // neighbor
1408

1409
        const std::vector<std::vector<TrackSegment>>* top_cmp = nullptr;
8,000✔
1410
        if (tid == 0)
8,000✔
1411
          top_cmp = &old_segments;
8,000✔
1412
        else
1413
          top_cmp = &this_line_segments[tid - 1];
1414

1415
        for (int horiz = 0; horiz < pixels_[0]; ++horiz) {
1,608,000✔
1416
          if (!trackstack_equivalent(
1,600,000✔
1417
                this_line_segments[tid][horiz], (*top_cmp)[horiz])) {
1,600,000✔
1418
            wireframe_initial(horiz, vert) = 1;
33,712✔
1419
          }
1420
        }
1421
      }
1422

1423
      // We need another barrier to ensure threads don't proceed to modify their
1424
      // intersection stacks on that horizontal line while others are
1425
      // potentially still working on the above.
1426
#pragma omp barrier
1427
      vert += n_threads;
8,040✔
1428
    }
1429
  } // end omp parallel
40✔
1430

1431
  // Now thicken the wireframe lines and apply them to our image
1432
  for (int vert = 0; vert < pixels_[1]; ++vert) {
14,070✔
1433
    for (int horiz = 0; horiz < pixels_[0]; ++horiz) {
2,814,000✔
1434
      if (wireframe_initial(horiz, vert)) {
2,800,000✔
1435
        if (wireframe_thickness_ == 1)
97,902✔
1436
          data(horiz, vert) = wireframe_color_;
44,226✔
1437
        for (int i = -wireframe_thickness_ / 2; i < wireframe_thickness_ / 2;
260,890✔
1438
             ++i)
1439
          for (int j = -wireframe_thickness_ / 2; j < wireframe_thickness_ / 2;
711,508✔
1440
               ++j)
1441
            if (i * i + j * j < wireframe_thickness_ * wireframe_thickness_) {
548,520✔
1442

1443
              // Check if wireframe pixel is out of bounds
1444
              int w_i = std::max(std::min(horiz + i, pixels_[0] - 1), 0);
548,520✔
1445
              int w_j = std::max(std::min(vert + j, pixels_[1] - 1), 0);
548,520✔
1446
              data(w_i, w_j) = wireframe_color_;
548,520✔
1447
            }
1448
      }
1449
    }
1450
  }
1451

1452
#ifdef USE_LIBPNG
1453
  output_png(path_plot(), data);
70✔
1454
#else
1455
  output_ppm(path_plot(), data);
1456
#endif
1457
}
70✔
1458

1459
void ProjectionPlot::print_info() const
70✔
1460
{
1461
  fmt::print("Plot Type: Projection\n");
70✔
1462
  fmt::print("Camera position: {} {} {}\n", camera_position_.x,
×
1463
    camera_position_.y, camera_position_.z);
70✔
1464
  fmt::print("Look at: {} {} {}\n", look_at_.x, look_at_.y, look_at_.z);
70✔
1465
  fmt::print(
×
1466
    "Horizontal field of view: {} degrees\n", horizontal_field_of_view_);
70✔
1467
  fmt::print("Pixels: {} {}\n", pixels_[0], pixels_[1]);
70✔
1468
}
70✔
1469

1470
void ProjectionPlot::set_opacities(pugi::xml_node node)
70✔
1471
{
1472
  xs_.resize(colors_.size(), 1e6); // set to large value for opaque by default
70✔
1473

1474
  for (auto cn : node.children("color")) {
154✔
1475
    // Make sure 3 values are specified for RGB
1476
    double user_xs = std::stod(get_node_value(cn, "xs"));
84✔
1477
    int col_id = std::stoi(get_node_value(cn, "id"));
84✔
1478

1479
    // Add RGB
1480
    if (PlotColorBy::cells == color_by_) {
84✔
1481
      if (model::cell_map.find(col_id) != model::cell_map.end()) {
84✔
1482
        col_id = model::cell_map[col_id];
84✔
1483
        xs_[col_id] = user_xs;
84✔
1484
      } else {
1485
        warning(fmt::format(
×
1486
          "Could not find cell {} specified in plot {}", col_id, id()));
×
1487
      }
1488
    } else if (PlotColorBy::mats == color_by_) {
×
1489
      if (model::material_map.find(col_id) != model::material_map.end()) {
×
1490
        col_id = model::material_map[col_id];
×
1491
        xs_[col_id] = user_xs;
×
1492
      } else {
1493
        warning(fmt::format(
×
1494
          "Could not find material {} specified in plot {}", col_id, id()));
×
1495
      }
1496
    }
1497
  }
1498
}
70✔
1499

1500
void ProjectionPlot::set_orthographic_width(pugi::xml_node node)
70✔
1501
{
1502
  if (check_for_node(node, "orthographic_width")) {
70✔
1503
    double orthographic_width =
1504
      std::stod(get_node_value(node, "orthographic_width", true));
14✔
1505
    if (orthographic_width < 0.0)
14✔
1506
      fatal_error("Requires positive orthographic_width");
×
1507
    orthographic_width_ = orthographic_width;
14✔
1508
  }
1509
}
70✔
1510

1511
void ProjectionPlot::set_wireframe_thickness(pugi::xml_node node)
70✔
1512
{
1513
  if (check_for_node(node, "wireframe_thickness")) {
70✔
1514
    int wireframe_thickness =
1515
      std::stoi(get_node_value(node, "wireframe_thickness", true));
28✔
1516
    if (wireframe_thickness < 0)
28✔
1517
      fatal_error("Requires non-negative wireframe thickness");
×
1518
    wireframe_thickness_ = wireframe_thickness;
28✔
1519
  }
1520
}
70✔
1521

1522
void ProjectionPlot::set_wireframe_ids(pugi::xml_node node)
70✔
1523
{
1524
  if (check_for_node(node, "wireframe_ids")) {
70✔
1525
    wireframe_ids_ = get_node_array<int>(node, "wireframe_ids");
14✔
1526
    // It is read in as actual ID values, but we have to convert to indices in
1527
    // mat/cell array
1528
    for (auto& x : wireframe_ids_)
28✔
1529
      x = color_by_ == PlotColorBy::mats ? model::material_map[x]
14✔
1530
                                         : model::cell_map[x];
×
1531
  }
1532
  // We make sure the list is sorted in order to later use
1533
  // std::binary_search.
1534
  std::sort(wireframe_ids_.begin(), wireframe_ids_.end());
70✔
1535
}
70✔
1536

1537
void ProjectionPlot::set_pixels(pugi::xml_node node)
70✔
1538
{
1539
  vector<int> pxls = get_node_array<int>(node, "pixels");
70✔
1540
  if (pxls.size() != 2)
70✔
1541
    fatal_error(
×
1542
      fmt::format("<pixels> must be length 2 in projection plot {}", id()));
×
1543
  pixels_[0] = pxls[0];
70✔
1544
  pixels_[1] = pxls[1];
70✔
1545
}
70✔
1546

1547
void ProjectionPlot::set_camera_position(pugi::xml_node node)
70✔
1548
{
1549
  vector<double> camera_pos = get_node_array<double>(node, "camera_position");
70✔
1550
  if (camera_pos.size() != 3) {
70✔
1551
    fatal_error(
×
1552
      fmt::format("look_at element must have three floating point values"));
×
1553
  }
1554
  camera_position_.x = camera_pos[0];
70✔
1555
  camera_position_.y = camera_pos[1];
70✔
1556
  camera_position_.z = camera_pos[2];
70✔
1557
}
70✔
1558

1559
void ProjectionPlot::set_look_at(pugi::xml_node node)
70✔
1560
{
1561
  vector<double> look_at = get_node_array<double>(node, "look_at");
70✔
1562
  if (look_at.size() != 3) {
70✔
1563
    fatal_error("look_at element must have three floating point values");
×
1564
  }
1565
  look_at_.x = look_at[0];
70✔
1566
  look_at_.y = look_at[1];
70✔
1567
  look_at_.z = look_at[2];
70✔
1568
}
70✔
1569

1570
void ProjectionPlot::set_field_of_view(pugi::xml_node node)
70✔
1571
{
1572
  // Defaults to 70 degree horizontal field of view (see .h file)
1573
  if (check_for_node(node, "field_of_view")) {
70✔
1574
    double fov = std::stod(get_node_value(node, "field_of_view", true));
28✔
1575
    if (fov < 180.0 && fov > 0.0) {
28✔
1576
      horizontal_field_of_view_ = fov;
28✔
1577
    } else {
1578
      fatal_error(fmt::format(
×
1579
        "Field of view for plot {} out-of-range. Must be in (0, 180).", id()));
×
1580
    }
1581
  }
1582
}
70✔
1583

1584
extern "C" int openmc_id_map(const void* plot, int32_t* data_out)
14✔
1585
{
1586

1587
  auto plt = reinterpret_cast<const SlicePlotBase*>(plot);
14✔
1588
  if (!plt) {
14✔
1589
    set_errmsg("Invalid slice pointer passed to openmc_id_map");
×
1590
    return OPENMC_E_INVALID_ARGUMENT;
×
1591
  }
1592

1593
  if (plt->slice_color_overlaps_ && model::overlap_check_count.size() == 0) {
14✔
1594
    model::overlap_check_count.resize(model::cells.size());
×
1595
  }
1596

1597
  auto ids = plt->get_map<IdData>();
14✔
1598

1599
  // write id data to array
1600
  std::copy(ids.data_.begin(), ids.data_.end(), data_out);
14✔
1601

1602
  return 0;
14✔
1603
}
14✔
1604

1605
extern "C" int openmc_property_map(const void* plot, double* data_out)
14✔
1606
{
1607

1608
  auto plt = reinterpret_cast<const SlicePlotBase*>(plot);
14✔
1609
  if (!plt) {
14✔
1610
    set_errmsg("Invalid slice pointer passed to openmc_id_map");
×
1611
    return OPENMC_E_INVALID_ARGUMENT;
×
1612
  }
1613

1614
  if (plt->slice_color_overlaps_ && model::overlap_check_count.size() == 0) {
14✔
1615
    model::overlap_check_count.resize(model::cells.size());
×
1616
  }
1617

1618
  auto props = plt->get_map<PropertyData>();
14✔
1619

1620
  // write id data to array
1621
  std::copy(props.data_.begin(), props.data_.end(), data_out);
14✔
1622

1623
  return 0;
14✔
1624
}
14✔
1625

1626
} // namespace openmc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc