Skip to content

Commit

Permalink
Merge pull request #574 from IAS-Astrophysics/bugfix/particles-vtk
Browse files Browse the repository at this point in the history
fix vtk format bug with POINT_DATA header
  • Loading branch information
jmstone authored Aug 16, 2024
2 parents 826fbd9 + e137670 commit 0d6d87a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ void Mesh::AddCoordinatesAndPhysics(ParameterInput *pinput) {
// Determine total number of particles across all ranks
particles::Particles *ppart = pmb_pack->ppart;
if (ppart != nullptr) {
nprtcl_thisrank = 0;
for (int n=0; n<nmb_packs_thisrank; ++n) {
nprtcl_thisrank += pmb_pack->ppart->nprtcl_thispack;
}
Expand Down
18 changes: 14 additions & 4 deletions src/outputs/vtk_prtcl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,29 @@ void ParticleVTKOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin) {
}

// Write Part 6: scalar particle data
bool have_written_pointdata_header = false;

// Write gid of points
for (int n=0; n<(pm->pmb_pack->ppart->nidata); ++n) {
std::stringstream msg;

if (!have_written_pointdata_header) {
have_written_pointdata_header = true;
msg << std::endl << std::endl << "POINT_DATA " << npout_total << std::endl;
}

if (n == static_cast<int>(PGID)) {
msg << std::endl << std::endl << "POINT_DATA " << npout_total << std::endl
<< "SCALARS gid float" << std::endl << "LOOKUP_TABLE default" << std::endl;
msg << std::endl << "SCALARS gid float" << std::endl
<< "LOOKUP_TABLE default" << std::endl;
} else if (n == static_cast<int>(PTAG)) {
msg << std::endl << std::endl << "POINT_DATA " << npout_total << std::endl
<< "SCALARS ptag float" << std::endl << "LOOKUP_TABLE default" << std::endl;
msg << std::endl << "SCALARS ptag float" << std::endl
<< "LOOKUP_TABLE default" << std::endl;
}

if (global_variable::my_rank == 0) {
partfile.Write_any_type_at(msg.str().c_str(),msg.str().size(),header_offset,"byte");
}

header_offset += msg.str().size();

// Loop over particles, load gid into data[]
Expand Down

0 comments on commit 0d6d87a

Please sign in to comment.