Skip to content

Commit

Permalink
Fix RBC cell output path construction bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertnash committed Sep 11, 2023
1 parent 1823f89 commit e00deed
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Code/redblood/CellControllerBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "redblood/CellControllerBuilder.h"

#include <boost/uuid/uuid_io.hpp>

#include "io/PathManager.h"
#include "redblood/FaderCell.h"
#include "redblood/MeshIO.h"
Expand Down Expand Up @@ -366,9 +368,11 @@ namespace hemelb::redblood {
ioComms.Barrier();

for (auto& cell : cells) {
std::stringstream filename;
filename << rbcOutputDir << cell->GetTag() << "_t_" << timestep << ".vtp";

// to_chars guarantees to write exactly 36 chars, also need .vtp\0
char name[41];
boost::uuids::to_chars(cell->GetTag(), name);
std::strncpy(name + 36, ".vtp", 5);
auto filename = rbcOutputDir / name;
std::shared_ptr<redblood::CellBase> cell_base = [&cell]() {
if (auto fader = std::dynamic_pointer_cast<redblood::FaderCell>(cell)) {
return fader->GetWrapeeCell();
Expand All @@ -380,7 +384,7 @@ namespace hemelb::redblood {
auto cell_cast = std::dynamic_pointer_cast<redblood::Cell>(cell_base);
assert(cell_cast);
auto meshio = redblood::VTKMeshIO{};
meshio.writeFile(filename.str(), *cell_cast, *unitConverter);
meshio.writeFile(filename.native(), *cell_cast, *unitConverter);
}
}
};
Expand Down

0 comments on commit e00deed

Please sign in to comment.