Skip to content
Snippets Groups Projects
Commit 693070a8 authored by Rafael Ravedutti's avatar Rafael Ravedutti
Browse files

Do not write infinite particles into VTK file

parent be48dae6
No related branches found
No related tags found
1 merge request!1Implement DEM and many other features
......@@ -12,8 +12,9 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
std::string output_filename(filename);
auto masses = ps->getAsFloatProperty(ps->getPropertyByName("mass"));
auto positions = ps->getAsVectorProperty(ps->getPropertyByName("position"));
const int n = end - start;
auto flags = ps->getAsIntegerProperty(ps->getPropertyByName("flags"));
const int prec = 8;
int n = end - start;
std::ostringstream filename_oss;
if(frequency != 0 && timestep % frequency != 0) {
......@@ -31,6 +32,12 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
ps->copyPropertyToHost(masses);
ps->copyPropertyToHost(positions);
for(int i = start; i < end; i++) {
if(!(flags(i) & FLAGS_INFINITE)) {
n--;
}
}
if(out_file.is_open()) {
out_file << "# vtk DataFile Version 2.0\n";
out_file << "Particle data\n";
......@@ -39,21 +46,27 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
out_file << "POINTS " << n << " double\n";
for(int i = start; i < end; i++) {
out_file << std::fixed << std::setprecision(prec) << positions(i, 0) << " ";
out_file << std::fixed << std::setprecision(prec) << positions(i, 1) << " ";
out_file << std::fixed << std::setprecision(prec) << positions(i, 2) << "\n";
if(!(flags(i) & FLAGS_INFINITE)) {
out_file << std::fixed << std::setprecision(prec) << positions(i, 0) << " ";
out_file << std::fixed << std::setprecision(prec) << positions(i, 1) << " ";
out_file << std::fixed << std::setprecision(prec) << positions(i, 2) << "\n";
}
}
out_file << "\n\n";
out_file << "CELLS " << n << " " << (n * 2) << "\n";
for(int i = start; i < end; i++) {
out_file << "1 " << (i - start) << "\n";
if(!(flags(i) & FLAGS_INFINITE)) {
out_file << "1 " << (i - start) << "\n";
}
}
out_file << "\n\n";
out_file << "CELL_TYPES " << n << "\n";
for(int i = start; i < end; i++) {
out_file << "1\n";
if(!(flags(i) & FLAGS_INFINITE)) {
out_file << "1\n";
}
}
out_file << "\n\n";
......@@ -61,7 +74,9 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
out_file << "SCALARS mass double\n";
out_file << "LOOKUP_TABLE default\n";
for(int i = start; i < end; i++) {
out_file << std::fixed << std::setprecision(prec) << masses(i) << "\n";
if(!(flags(i) & FLAGS_INFINITE)) {
out_file << std::fixed << std::setprecision(prec) << masses(i) << "\n";
}
}
out_file << "\n\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment