Separate local and ghost cluster edges on VTK output
Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
parent
6a35a7a482
commit
769bab0faa
@ -24,7 +24,9 @@
|
||||
|
||||
#ifndef __VTK_H_
|
||||
#define __VTK_H_
|
||||
extern void write_data_to_vtk_file(const char *filename, Atom* atom, int timestep);
|
||||
extern int write_local_atoms_to_vtk_file(const char* filename, Atom* atom, int timestep);
|
||||
extern int write_ghost_atoms_to_vtk_file(const char* filename, Atom* atom, int timestep);
|
||||
extern int write_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timestep);
|
||||
extern int write_local_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timestep);
|
||||
extern int write_ghost_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timestep);
|
||||
#endif
|
||||
|
@ -271,9 +271,7 @@ int main(int argc, char** argv) {
|
||||
timer[TOTAL] = getTimeStamp();
|
||||
|
||||
if(param.vtk_file != NULL) {
|
||||
write_local_atoms_to_vtk_file(param.vtk_file, &atom, 0);
|
||||
write_ghost_atoms_to_vtk_file(param.vtk_file, &atom, 0);
|
||||
write_cluster_edges_to_vtk_file(param.vtk_file, &atom, 0);
|
||||
write_data_to_vtk_file(param.vtk_file, &atom, 0);
|
||||
}
|
||||
|
||||
for(int n = 0; n < param.ntimes; n++) {
|
||||
@ -302,9 +300,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if(param.vtk_file != NULL) {
|
||||
write_local_atoms_to_vtk_file(param.vtk_file, &atom, n + 1);
|
||||
write_ghost_atoms_to_vtk_file(param.vtk_file, &atom, n + 1);
|
||||
write_cluster_edges_to_vtk_file(param.vtk_file, &atom, n + 1);
|
||||
write_data_to_vtk_file(param.vtk_file, &atom, n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,14 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <atom.h>
|
||||
#include <vtk.h>
|
||||
|
||||
void write_data_to_vtk_file(const char *filename, Atom* atom, int timestep) {
|
||||
write_local_atoms_to_vtk_file(filename, atom, timestep);
|
||||
write_ghost_atoms_to_vtk_file(filename, atom, timestep);
|
||||
write_local_cluster_edges_to_vtk_file(filename, atom, timestep);
|
||||
write_ghost_cluster_edges_to_vtk_file(filename, atom, timestep);
|
||||
}
|
||||
|
||||
int write_local_atoms_to_vtk_file(const char* filename, Atom* atom, int timestep) {
|
||||
char timestep_filename[128];
|
||||
@ -89,11 +97,11 @@ int write_ghost_atoms_to_vtk_file(const char* filename, Atom* atom, int timestep
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timestep) {
|
||||
int write_local_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timestep) {
|
||||
char timestep_filename[128];
|
||||
snprintf(timestep_filename, sizeof timestep_filename, "%s_edges_%d.vtk", filename, timestep);
|
||||
snprintf(timestep_filename, sizeof timestep_filename, "%s_local_edges_%d.vtk", filename, timestep);
|
||||
FILE* fp = fopen(timestep_filename, "wb");
|
||||
int Nclusters_all = atom->Nclusters_local + atom->Nclusters_ghost;
|
||||
int N = atom->Nclusters_local;
|
||||
int tot_lines = 0;
|
||||
int i = 0;
|
||||
|
||||
@ -106,8 +114,8 @@ int write_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timest
|
||||
fprintf(fp, "Particle data\n");
|
||||
fprintf(fp, "ASCII\n");
|
||||
fprintf(fp, "DATASET POLYDATA\n");
|
||||
fprintf(fp, "POINTS %d double\n", atom->Nlocal + atom->Nghost);
|
||||
for(int ci = 0; ci < Nclusters_all; ++ci) {
|
||||
fprintf(fp, "POINTS %d double\n", atom->Nlocal);
|
||||
for(int ci = 0; ci < N; ++ci) {
|
||||
MD_FLOAT *cptr = cluster_pos_ptr(ci);
|
||||
for(int cii = 0; cii < atom->clusters[ci].natoms; ++cii) {
|
||||
fprintf(fp, "%.4f %.4f %.4f\n", cluster_x(cptr, cii), cluster_y(cptr, cii), cluster_z(cptr, cii));
|
||||
@ -116,8 +124,49 @@ int write_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timest
|
||||
tot_lines += atom->clusters[ci].natoms;
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
fprintf(fp, "LINES %d %d\n", Nclusters_all, Nclusters_all + tot_lines);
|
||||
for(int ci = 0; ci < Nclusters_all; ++ci) {
|
||||
fprintf(fp, "LINES %d %d\n", N, N + tot_lines);
|
||||
for(int ci = 0; ci < N; ++ci) {
|
||||
fprintf(fp, "%d ", atom->clusters[ci].natoms);
|
||||
for(int cii = 0; cii < atom->clusters[ci].natoms; ++cii) {
|
||||
fprintf(fp, "%d ", i++);
|
||||
}
|
||||
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int write_ghost_cluster_edges_to_vtk_file(const char* filename, Atom* atom, int timestep) {
|
||||
char timestep_filename[128];
|
||||
snprintf(timestep_filename, sizeof timestep_filename, "%s_ghost_edges_%d.vtk", filename, timestep);
|
||||
FILE* fp = fopen(timestep_filename, "wb");
|
||||
int N = atom->Nclusters_local + atom->Nclusters_ghost;
|
||||
int tot_lines = 0;
|
||||
int i = 0;
|
||||
|
||||
if(fp == NULL) {
|
||||
fprintf(stderr, "Could not open VTK file for writing!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(fp, "# vtk DataFile Version 2.0\n");
|
||||
fprintf(fp, "Particle data\n");
|
||||
fprintf(fp, "ASCII\n");
|
||||
fprintf(fp, "DATASET POLYDATA\n");
|
||||
fprintf(fp, "POINTS %d double\n", atom->Nghost);
|
||||
for(int ci = atom->Nclusters_local; ci < N; ++ci) {
|
||||
MD_FLOAT *cptr = cluster_pos_ptr(ci);
|
||||
for(int cii = 0; cii < atom->clusters[ci].natoms; ++cii) {
|
||||
fprintf(fp, "%.4f %.4f %.4f\n", cluster_x(cptr, cii), cluster_y(cptr, cii), cluster_z(cptr, cii));
|
||||
}
|
||||
|
||||
tot_lines += atom->clusters[ci].natoms;
|
||||
}
|
||||
fprintf(fp, "\n\n");
|
||||
fprintf(fp, "LINES %d %d\n", atom->Nclusters_ghost, atom->Nclusters_ghost + tot_lines);
|
||||
for(int ci = atom->Nclusters_local; ci < N; ++ci) {
|
||||
fprintf(fp, "%d ", atom->clusters[ci].natoms);
|
||||
for(int cii = 0; cii < atom->clusters[ci].natoms; ++cii) {
|
||||
fprintf(fp, "%d ", i++);
|
||||
|
Loading…
Reference in New Issue
Block a user