1 | # ---------------------------------------------------------------------- |
---|
2 | # EXAMPLE: Rappture <cloud> elements |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Michael McLennan, Purdue University |
---|
5 | # Copyright (c) 2004-2005 Purdue Research Foundation |
---|
6 | # |
---|
7 | # See the file "license.terms" for information on usage and |
---|
8 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
9 | # ====================================================================== |
---|
10 | package require Rappture |
---|
11 | |
---|
12 | # open the XML file containing the run parameters |
---|
13 | set driver [Rappture::library [lindex $argv 0]] |
---|
14 | |
---|
15 | # get the formula and make it ready for evaluation |
---|
16 | set formula [$driver get input.string(formula).current] |
---|
17 | regsub -all {[xyz]} $formula {$\0} formula |
---|
18 | |
---|
19 | # get the number of points for the cloud |
---|
20 | set npts [$driver get input.integer(npts).current] |
---|
21 | |
---|
22 | # |
---|
23 | # Generate the 2D mesh and field values... |
---|
24 | # |
---|
25 | $driver put output.cloud(m2d).about.label "2D Mesh" |
---|
26 | $driver put output.cloud(m2d).units "um" |
---|
27 | $driver put output.cloud(m2d).hide "yes" |
---|
28 | |
---|
29 | $driver put output.field(f2d).about.label "2D Field" |
---|
30 | $driver put output.field(f2d).component.mesh "output.cloud(m2d)" |
---|
31 | set z 1 |
---|
32 | for {set n 0} {$n < $npts} {incr n} { |
---|
33 | set x [expr {rand()}] |
---|
34 | set y [expr {rand()}] |
---|
35 | $driver put -append yes output.cloud(m2d).points "$x $y\n" |
---|
36 | |
---|
37 | set fval [expr $formula] |
---|
38 | $driver put -append yes output.field(f2d).component.values "$fval\n" |
---|
39 | } |
---|
40 | |
---|
41 | # |
---|
42 | # Generate the 3D mesh and field values... |
---|
43 | # |
---|
44 | $driver put output.cloud(m3d).about.label "3D Mesh" |
---|
45 | $driver put output.cloud(m3d).units "um" |
---|
46 | $driver put output.cloud(m3d).hide "yes" |
---|
47 | |
---|
48 | $driver put output.field(f3d).about.label "3D Field" |
---|
49 | $driver put output.field(f3d).component.mesh "output.cloud(m3d)" |
---|
50 | for {set n 0} {$n < $npts} {incr n} { |
---|
51 | set x [expr {rand()}] |
---|
52 | set y [expr {rand()}] |
---|
53 | set z [expr {rand()}] |
---|
54 | $driver put -append yes output.cloud(m3d).points "$x $y $z\n" |
---|
55 | |
---|
56 | set fval [expr $formula] |
---|
57 | $driver put -append yes output.field(f3d).component.values "$fval\n" |
---|
58 | } |
---|
59 | |
---|
60 | # |
---|
61 | # Save the updated XML describing the run... |
---|
62 | # |
---|
63 | Rappture::result $driver |
---|
64 | exit 0 |
---|