Skip to content

Commit

Permalink
Added documentation for lbboundary print velocity vtk bounding box an…
Browse files Browse the repository at this point in the history
…d removed velocitycut feature and documentation.
  • Loading branch information
rempferg committed May 24, 2016
1 parent 5292b0f commit c12e04b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 154 deletions.
5 changes: 3 additions & 2 deletions doc/ug/lb.tex
Expand Up @@ -356,14 +356,15 @@ \section{Removing total fluid momentum}
\section{Visualization}
\label{ssec:LBvisualization}
\begin{essyntax}
lbfluid print \opt{vtk} \var{property} \var{filename} [\var{filename}]
\variant{1} lbfluid print \opt{vtk} \var{property} \var{filename}
\variant{2} lbfluid print vtk velocity \opt{bb1_x bb1_y bb1_z bb2_x bb2_y bb2_z} \var{filename}
\end{essyntax}
The print parameter of the \lit{lbfluid} command is a feature to simplify visualization. It allows for the export of the whole fluid field data into a
file with name \var{filename} at once. Currently supported values for the
parameter \var{property} are boundary and velocity when using \lit{LB} or \lit{LB_GPU} and density and velocity when using \lit{SHANCHEN}. The additional option
\lit{vtk} enables export in the vtk format which is readable by visualization software such as paraview\footnote{http://www.paraview.org/} or mayavi2\footnote{http://code.enthought.com/projects/mayavi/}. Otherwise gnuplot readable data will be
exported. If you plan to use paraview for visualization, note that also the
particle positions can be exported in the VTK format \ref{sec:writevtk}. For VTK visualisation of 2D cut of the velocity field you may use the "velocitycut xcut ycut zcut" as \lit{property}. Here, only one value of the three values xcut, ycut and zcut may be nonzero. This value determines the position of the cutting plane. As an example, using "velocitycut 0 10 0" will output the cross-section of the velocity field by a plane perpendicular to $y$-axis at $y = 10$.
particle positions can be exported in the VTK format \ref{sec:writevtk}. \variant{2} allows you to only output part of the flow field by specifiying an axis aligned bounding box through the coordinates of two of its corners. This bounding box can be used to output a slice of the flow field. As an example, executing \texttt{lbfluid print vtk velocity 0 0 5 10 10 5 filename} will output the cross-section of the velocity field in a plane perpendicular to the $z$-axis at $z = 5$ (assuming the box size is 10 in the $x$- and $y$-direction).
If the \lit{SHANCHEN} bicomponent fluid is used, two filenames have to be supplied when exporting the density field, to save both components.

\section{Setting up boundary conditions}
Expand Down
127 changes: 1 addition & 126 deletions src/core/lb.cpp
Expand Up @@ -782,20 +782,6 @@ int lb_lbfluid_print_vtk_velocity(char* filename, std::vector<int> bb1, std::vec

bb_low.push_back(std::min(*val1, *val2));
bb_high.push_back(std::max(*val1, *val2));

//TODO delete
std::cout << std::endl << *val1;
std::cout << std::endl << *val2;
std::cout << std::endl << std::min(*val1, *val2);
std::cout << std::endl << std::max(*val1, *val2) << std::endl;

std::cout << std::endl << std::endl << std::endl;
for(auto i: bb_low)
std::cout << ' ' << i;
std::cout << std::endl;
for(auto i: bb_high)
std::cout << ' ' << i;
std::cout << std::endl << std::endl << std::endl;
}

int pos[3];
Expand Down Expand Up @@ -833,14 +819,13 @@ int lb_lbfluid_print_vtk_velocity(char* filename, std::vector<int> bb1, std::vec
(bb_low[0]+0.5)*lblattice.agrid[0], (bb_low[1]+0.5)*lblattice.agrid[1], (bb_low[2]+0.5)*lblattice.agrid[2],
lblattice.agrid[0], lblattice.agrid[1], lblattice.agrid[2],
(bb_high[0]-bb_low[0]+1) * (bb_high[1]-bb_low[1]+1) * (bb_high[2]-bb_low[2]+1) );
std::cout << std::endl << std::endl << std::endl; //TODO delete

for(pos[2] = bb_low[2]; pos[2] <= bb_high[2]; pos[2]++)
for(pos[1] = bb_low[1]; pos[1] <= bb_high[1]; pos[1]++)
for(pos[0] = bb_low[0]; pos[0] <= bb_high[0]; pos[0]++)
{
lb_lbnode_get_u(pos, u);
fprintf(fp, "%f %f %f\n", u[0], u[1], u[2]);
std::cout << '[' << pos[0] << ' ' << pos[1] << ' ' << pos[2] << ']' << ' ' << '[' << u[0] << ' ' << u[1] << ' ' << u[2] << ']' << std::endl; //TODO delete
}
#endif // LB
}
Expand All @@ -849,116 +834,6 @@ std::cout << std::endl << std::endl << std::endl; //TODO delete
return 0;
}

int lb_lbfluid_print_vtk_velocitycut(int cutx, int cuty, int cutz, char* filename) {
FILE* fp = fopen(filename, "w");

if(fp == NULL)
{
return 1;
}

if (lattice_switch & LATTICE_LB_GPU) {
#ifdef LB_GPU
fprintf(stderr, "Not implemented yet (%s:%d) ",__FILE__,__LINE__);
errexit();
#endif // LB_GPU
} else {
#ifdef LB
int pos[3];
double u[3];
int gridsize[3];

gridsize[0] = box_l[0] / lbpar.agrid;
gridsize[1] = box_l[1] / lbpar.agrid;
gridsize[2] = box_l[2] / lbpar.agrid;


if(cutx != 0){
if((cuty!=0)||(cutz!=0)) {
printf("Too many non-zero parameters for lbfluid print vtk velocity_cut\n");
return 1;
}

fprintf(fp, "# vtk DataFile Version 2.0\nlbfluid_cut_x\n"
"ASCII\nDATASET STRUCTURED_POINTS\nDIMENSIONS 1 %d %d\n"
"ORIGIN %f %f %f\nSPACING %f %f %f\nPOINT_DATA %d\n"
"SCALARS velocity float 3\nLOOKUP_TABLE default\n",
gridsize[1], gridsize[2],
cutx+lblattice.agrid[0]*0.5, lblattice.agrid[1]*0.5, lblattice.agrid[2]*0.5,
lblattice.agrid[0], lblattice.agrid[1], lblattice.agrid[2],
gridsize[1]*gridsize[2]);
pos[0] = cutx;

for(pos[2] = 0; pos[2] < gridsize[2]; pos[2]++)
{
for(pos[1] = 0; pos[1] < gridsize[1]; pos[1]++)
{
lb_lbnode_get_u(pos, u);
fprintf(fp, "%f %f %f\n", u[0], u[1], u[2]);
}
}
}

if(cuty != 0){
if((cutx!=0)||(cutz!=0)) {
printf("Too many non-zero parameters for lbfluid print vtk velocity_cut \n");
return 1;
}

fprintf(fp, "# vtk DataFile Version 2.0\nlbfluid_cut_y\n"
"ASCII\nDATASET STRUCTURED_POINTS\nDIMENSIONS %d 1 %d\n"
"ORIGIN %f %f %f\nSPACING %f %f %f\nPOINT_DATA %d\n"
"SCALARS velocity float 3\nLOOKUP_TABLE default\n",
gridsize[0], gridsize[2],
lblattice.agrid[0]*0.5, cuty+lblattice.agrid[1]*0.5, lblattice.agrid[2]*0.5,
lblattice.agrid[0], lblattice.agrid[1], lblattice.agrid[2],
gridsize[0]*gridsize[2]);
pos[1] = cuty;

for(pos[2] = 0; pos[2] < gridsize[2]; pos[2]++)
{
for(pos[0] = 0; pos[0] < gridsize[0]; pos[0]++)
{
lb_lbnode_get_u(pos, u);
fprintf(fp, "%f %f %f\n", u[0], u[1], u[2]);
}
}
}

if(cutz != 0){
if((cutx!=0)||(cuty!=0)) {
printf("Too many non-zero parameters for lbfluid print vtk velocity_cut \n");
return 1;
}

fprintf(fp, "# vtk DataFile Version 2.0\nlbfluid_cut_z\n"
"ASCII\nDATASET STRUCTURED_POINTS\nDIMENSIONS %d %d 1\n"
"ORIGIN %f %f %f\nSPACING %f %f %f\nPOINT_DATA %d\n"
"SCALARS velocity float 3\nLOOKUP_TABLE default\n",
gridsize[0], gridsize[1],
lblattice.agrid[0]*0.5, lblattice.agrid[1]*0.5, cutz+lblattice.agrid[2]*0.5,
lblattice.agrid[0], lblattice.agrid[1], lblattice.agrid[2],
gridsize[0]*gridsize[1]);
pos[2] = cutz;

for(pos[1] = 0; pos[1] < gridsize[1]; pos[1]++)
{
for(pos[0] = 0; pos[0] < gridsize[0]; pos[0]++)
{
lb_lbnode_get_u(pos, u);
fprintf(fp, "%f %f %f\n", u[0], u[1], u[2]);
}
}
}

#endif // LB
}
fclose(fp);

return 0;
}


int lb_lbfluid_print_boundary(char* filename) {
FILE* fp = fopen(filename, "w");

Expand Down
1 change: 0 additions & 1 deletion src/core/lb.hpp
Expand Up @@ -538,7 +538,6 @@ int lb_get_lattice_switch(int* py_switch);
/* IO routines */
int lb_lbfluid_print_vtk_boundary(char* filename);
int lb_lbfluid_print_vtk_velocity(char* filename, std::vector<int> = {-1, -1, -1}, std::vector<int> = {-1, -1, -1});
int lb_lbfluid_print_vtk_velocitycut(int cutx, int cuty, int cutz, char* filename);
int lb_lbfluid_print_vtk_density(char** filename);
int lb_lbfluid_print_boundary(char* filename);
int lb_lbfluid_print_velocity(char* filename);
Expand Down
18 changes: 0 additions & 18 deletions src/tcl/lb_tcl.cpp
Expand Up @@ -774,24 +774,6 @@ int tclcommand_lbfluid(ClientData data, Tcl_Interp *interp, int argc, char **arg
return TCL_ERROR;
}
}
else if (ARG1_IS_S_EXACT("velocitycut"))
{
int cutx, cuty, cutz;
if (!ARG_IS_I(2,cutx) || !ARG_IS_I(3,cuty) || !ARG_IS_I(4,cutz))
{
Tcl_AppendResult(interp, "Coordinates are not integer.", (char *)NULL);
return TCL_ERROR;
}

if ( lb_lbfluid_print_vtk_velocitycut(cutx, cuty, cutz, argv[5]) != 0 )
{
Tcl_AppendResult(interp, "Unknown Error at lbfluid print vtk velocity_cut", (char *)NULL);
return TCL_ERROR;
}

argc -= 6;
argv += 6;
}
else if (ARG1_IS_S_EXACT("density"))
{
argc -= 2;
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tcl/engine_lb.tcl
Expand Up @@ -133,7 +133,7 @@ integrate $sampsteps
if { $new_configuration != 0 } {
lbfluid print vtk velocity "engine_lb.vtk"
} else {
lbfluid print vtk velocity "engine_lb_tmp.vtk"
lbfluid print vtk velocity 1 1 5 11 11 5 "engine_lb_tmp.vtk"
set difference [calculate_vtk_max_pointwise_difference "./engine_lb.vtk" "./engine_lb_tmp.vtk"]
#file delete "./engine_lb_tmp.vtk"

Expand Down
12 changes: 6 additions & 6 deletions testsuite/tcl/engine_lbgpu.tcl
Expand Up @@ -128,9 +128,9 @@ integrate $sampsteps
if { $new_configuration != 0 } {
lbfluid print vtk velocity "engine_lbgpu_2pt.vtk"
} else {
lbfluid print vtk velocity "engine_lbgpu_tmp.vtk"
set difference [calculate_vtk_max_pointwise_difference "./engine_lbgpu_2pt.vtk" "./engine_lbgpu_tmp.vtk"]
file delete "./engine_lbgpu_tmp.vtk"
lbfluid print vtk velocity 1 1 5 11 11 5 "engine_lbgpu_2pt_tmp.vtk"
set difference [calculate_vtk_max_pointwise_difference "./engine_lbgpu_2pt.vtk" "./engine_lbgpu_2pt_tmp.vtk"]
#file delete "./engine_lbgpu_2pt_tmp.vtk"

puts "Maximum deviation to the reference point is: $difference\n"

Expand All @@ -154,9 +154,9 @@ integrate $sampsteps
if { $new_configuration != 0 } {
lbfluid print vtk velocity "engine_lbgpu_3pt.vtk"
} else {
lbfluid print vtk velocity "engine_lbgpu_tmp.vtk"
set difference [calculate_vtk_max_pointwise_difference "./engine_lbgpu_3pt.vtk" "./engine_lbgpu_tmp.vtk"]
file delete "./engine_lbgpu_tmp.vtk"
lbfluid print vtk velocity "engine_lbgpu_3pt_tmp.vtk"
set difference [calculate_vtk_max_pointwise_difference "./engine_lbgpu_3pt.vtk" "./engine_lbgpu_3pt_tmp.vtk"]
#file delete "./engine_lbgpu_3pt_tmp.vtk"

puts "Maximum deviation to the reference point is: $difference\n"

Expand Down

0 comments on commit c12e04b

Please sign in to comment.