Permalink
Browse files

Merge branch 'particle_vtk_export' of git://github.com/rempferg/espre…

…sso into rempferg-particle_vtk_export

Conflicts:
	doc/ug/io.tex
  • Loading branch information...
2 parents 3faac07 + 30989af commit 90a37c2914873466aaa1adc95f3e4d40a95795e2 @olenz olenz committed Mar 9, 2012
Showing with 73 additions and 11 deletions.
  1. +35 −1 doc/ug/io.tex
  2. +12 −10 doc/ug/lb.tex
  3. +26 −0 scripts/vtf.tcl
View
@@ -522,6 +522,7 @@ \subsection{\texttt{writevcf}: Writing the coordinates}
\minisec{Example} \verb!userdata {"red" "blue" "green"}!
\end{arguments}
+
\subsection{\texttt{vtfpid}: Translating \es particles ids to VMD
particle ids}
\begin{essyntax}
@@ -530,6 +531,40 @@ \subsection{\texttt{vtfpid}: Translating \es particles ids to VMD
If \var{pid} is the id of a particle as used in \es, this command
returns the atom id used in the VTF, VSF or VCF formats.
+\section{\texttt{writevtk}: Particle Visualization in paraview}
+\label{sec:writevtk}
+\newescommand{writevtk}
+
+This feature allows to export the particle positions in a paraview
+\footnote{\url{http://www.paraview.org/}} compatible VTK
+file. Paraview is a powerful and easy to use open-source visualization
+program for scientific data. Since \es can export the
+lattice-Boltzmann velocity field \ref{ssec:LBvisualization} in the VTK
+format as well and paraview allows to visualize particles with glyphs
+and vector fields with stream lines, glyphs, contourplots, etc., one
+can use it so completely visualize a coupled lattice-Boltzmann MD
+simulation. It can also create videos without much effort if one
+exports data of individual time steps into separate files with
+filenames including a running index (\texttt{data_0.vtk},
+\texttt{data_1.vtk}, ...).
+
+\begin{essyntax}
+ writevtk \var{filename}
+ \opt{\alt{all \asep \var{type}}}
+\end{essyntax}
+
+\begin{arguments}
+\item[\var{filename}]
+ Name of the file to export the particle positions into.
+
+\item[\opt{\alt{all \asep \var{type}}}] Specifies which particle type
+ should be exportet. The default is \keyword{all}. Alternatively, a
+ type number can be given. Exporting the positions of all particles
+ but in separate files might make sense if one wants to distinguish
+ the different particle types in the visualization (i.e. by color or
+ size).
+\end{arguments}
+
\section{Writing PDB/PSF files}
The PDB (Brookhaven Protein DataBase) format is a widely used format
for describing atomistic configurations. PSF is a format that is used
@@ -587,7 +622,6 @@ \subsection{\lit{writepdb}: Writing the coordinates}
tcl list consisting of x, y, and z shifts respectively and each number
should be a floating point (ie with decimal point).
-
\section{Online-visualisation with VMD}
\label{sec:IMD}
\index{IMD}
View
@@ -107,16 +107,6 @@ \section{Setting up a LB fluid}
the lattice constant.
\begin{essyntax}
- lbfluid print \opt{vtk} \var{property} \var{filename}
-\end{essyntax}
-The print parameter 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. The additional option \lit{vtk} enables export in the vtk format
-which is readable by visualization software such as paraview or mayavi.
-Otherwise gnuplot readable data will be exported.
-
-\begin{essyntax}
lbfluid save_ascii_checkpoint \var{filename}
lbfluid save_binary_checkpoint \var{filename}
lbfluid load_ascii_checkpoint \var{filename}
@@ -187,6 +177,18 @@ \section{Reading and setting single lattice nodes}
puts [ lbnode 0 0 0 set u 0.01 0. 0.]
\end{tclcode}
+\section{Visualization}
+\label{ssec:LBvisualization}
+\begin{essyntax}
+ lbfluid print \opt{vtk} \var{property} \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. 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 exportet in the VTK format \ref{sec:writevtk}.
+
\section{Setting up boundary conditions}
\begin{essyntax}
lbboundary \var{shape} \var{shape\_args} \opt{velocity \var{vx} \var{vy} \var{vz}}
View
@@ -287,6 +287,32 @@ proc writevcf { file args } {
if { ! $short } then { puts $file "" }
}
+#dumps particle positions into a file so that paraview can visualize them
+proc writevtk {filename {type "all"}} {
+ set max_pid [setmd max_part]
+ set n 0
+ set fp [open $filename "w"]
+
+ for { set pid 0 } { $pid <= $max_pid } { incr pid } {
+ if {[part $pid print type] == $type || ([part $pid print type] != "na" && $type == "all")} then {
+ incr n
+ }
+ }
+
+ puts $fp "# vtk DataFile Version 2.0\nparticles\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS $n floats"
+
+ for { set pid 0 } { $pid <= $max_pid } { incr pid } {
+ if {[part $pid print type] == $type || ([part $pid print type] != "na" && $type == "all")} then {
+ set xpos [expr [lindex [part $pid print folded_pos] 0] - 0.5] ;#shifted since the LB and MD grid are shifted but the vtk output for the LB field doesn't acknowledge that
+ set ypos [expr [lindex [part $pid print folded_pos] 1] - 0.5]
+ set zpos [expr [lindex [part $pid print folded_pos] 2] - 0.5]
+ puts $fp "$xpos $ypos $zpos"
+ }
+ }
+
+ close $fp
+}
+
# get the VMD pid of a given ESPResSo-PID
proc vtfpid { pid } {
global vtf_pid

0 comments on commit 90a37c2

Please sign in to comment.