Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Moved the tcl vtk particle output to its own file.

  • Loading branch information...
commit 52c3abfaace79d56f2b69e74543ff31b0acb4d9d 1 parent 07a9bb9
Georg Rempfer authored July 13, 2012
1  scripts/init.tcl
@@ -104,6 +104,7 @@ source polymer.tcl
104 104
 source statistics.tcl
105 105
 source ABHmath.tcl
106 106
 source vtf.tcl
  107
+source vtk.tcl
107 108
 source dielectrics.tcl
108 109
 
109 110
 # make available readline if Espresso is interactive
26  scripts/vtf.tcl
@@ -287,32 +287,6 @@ proc writevcf { file args } {
287 287
     if { ! $short } then { puts $file "" }
288 288
 }
289 289
 
290  
-#dumps particle positions into a file so that paraview can visualize them
291  
-proc writevtk {filename {type "all"}} {
292  
-	set max_pid [setmd max_part]
293  
-	set n 0
294  
-	set fp [open $filename "w"]
295  
-
296  
-	for { set pid 0 } { $pid <= $max_pid } { incr pid } {
297  
-		if {[part $pid print type] == $type || ([part $pid print type] != "na" && $type == "all")} then {
298  
-			incr n
299  
-		}
300  
-	}
301  
-
302  
-	puts $fp "# vtk DataFile Version 2.0\nparticles\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS $n floats"
303  
-
304  
-	for { set pid 0 } { $pid <= $max_pid } { incr pid } {
305  
-		if {[part $pid print type] == $type || ([part $pid print type] != "na" && $type == "all")} then {
306  
-			set xpos [expr [lindex [part $pid print folded_pos] 0]]
307  
-			set ypos [expr [lindex [part $pid print folded_pos] 1]]
308  
-			set zpos [expr [lindex [part $pid print folded_pos] 2]]
309  
-			puts $fp "$xpos $ypos $zpos"
310  
-		}
311  
-	}
312  
-
313  
-	close $fp
314  
-}
315  
-
316 290
 # get the VMD pid of a given ESPResSo-PID
317 291
 proc vtfpid { pid } {
318 292
     global vtf_pid
53  scripts/vtk.tcl
... ...
@@ -0,0 +1,53 @@
  1
+#
  2
+# Copyright (C) 2012 The ESPResSo project
  3
+# Copyright (C) 2006,2007,2008,2009,2010,2011 Olaf Lenz
  4
+#  
  5
+# This file is part of ESPResSo.
  6
+#  
  7
+# ESPResSo is free software: you can redistribute it and/or modify
  8
+# it under the terms of the GNU General Public License as published by
  9
+# the Free Software Foundation, either version 3 of the License, or
  10
+# (at your option) any later version.
  11
+#  
  12
+# ESPResSo is distributed in the hope that it will be useful,
  13
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15
+# GNU General Public License for more details.
  16
+#  
  17
+# You should have received a copy of the GNU General Public License
  18
+# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
  19
+#  
  20
+#############################################################
  21
+#                                                           #
  22
+# vtk.tcl                                                   #
  23
+# =======                                                   #
  24
+#                                                           #
  25
+# Functions that allow writing VTK files.                   #
  26
+#                                                           #
  27
+#############################################################
  28
+
  29
+#dumps particle positions into a file so that paraview can visualize them
  30
+proc writevtk {filename {type "all"}} {
  31
+	set max_pid [setmd max_part]
  32
+	set n 0
  33
+	set fp [open $filename "w"]
  34
+
  35
+	for { set pid 0 } { $pid <= $max_pid } { incr pid } {
  36
+		if {[part $pid print type] == $type || ([part $pid print type] != "na" && $type == "all")} then {
  37
+			incr n
  38
+		}
  39
+	}
  40
+
  41
+	puts $fp "# vtk DataFile Version 2.0\nparticles\nASCII\nDATASET UNSTRUCTURED_GRID\nPOINTS $n floats"
  42
+
  43
+	for { set pid 0 } { $pid <= $max_pid } { incr pid } {
  44
+		if {[part $pid print type] == $type || ([part $pid print type] != "na" && $type == "all")} then {
  45
+			set xpos [expr [lindex [part $pid print folded_pos] 0]]
  46
+			set ypos [expr [lindex [part $pid print folded_pos] 1]]
  47
+			set zpos [expr [lindex [part $pid print folded_pos] 2]]
  48
+			puts $fp "$xpos $ypos $zpos"
  49
+		}
  50
+	}
  51
+
  52
+	close $fp
  53
+}

0 notes on commit 52c3abf

Please sign in to comment.
Something went wrong with that request. Please try again.