Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix vtk format bug with POINT_DATA header #574

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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