1 | # ---------------------------------------------------------------------- |
---|
2 | # EXAMPLE: Rappture <field> elements |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Michael McLennan, Purdue University |
---|
5 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
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 | # |
---|
20 | # Generate a uniform grid 2D mesh and field values... |
---|
21 | # |
---|
22 | |
---|
23 | $driver put output.mesh(m2d).about.label "2D Mesh" |
---|
24 | $driver put output.mesh(m2d).dim 2 |
---|
25 | $driver put output.mesh(m2d).units "um" |
---|
26 | $driver put output.mesh(m2d).hide "yes" |
---|
27 | $driver put output.mesh(m2d).grid.xaxis.min 0.0 |
---|
28 | $driver put output.mesh(m2d).grid.xaxis.max 4.0 |
---|
29 | $driver put output.mesh(m2d).grid.xaxis.numpoints 5 |
---|
30 | $driver put output.mesh(m2d).grid.yaxis.min 0.0 |
---|
31 | $driver put output.mesh(m2d).grid.yaxis.max 4.0 |
---|
32 | $driver put output.mesh(m2d).grid.yaxis.numpoints 5 |
---|
33 | |
---|
34 | $driver put output.field(f2d).about.label "2D Field" |
---|
35 | $driver put output.field(f2d).component.mesh "output.mesh(m2d)" |
---|
36 | |
---|
37 | set z 1 |
---|
38 | for {set y 0} {$y < 5} {incr y} { |
---|
39 | for {set x 0} {$x < 5} {incr x} { |
---|
40 | set fval [expr $formula] |
---|
41 | $driver put -append yes output.field(f2d).component.values "$fval\n" |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | # |
---|
46 | # See what sort of 3D data to generate... |
---|
47 | # |
---|
48 | set vizmethod [$driver get input.choice(3D).current] |
---|
49 | |
---|
50 | if {$vizmethod == "grid"} { |
---|
51 | # |
---|
52 | # Generate a uniform grid 3D mesh and field values... |
---|
53 | # |
---|
54 | $driver put output.mesh(m3d).about.label "3D Uniform Mesh" |
---|
55 | $driver put output.mesh(m3d).dim 3 |
---|
56 | $driver put output.mesh(m3d).units "um" |
---|
57 | $driver put output.mesh(m3d).hide "yes" |
---|
58 | $driver put output.mesh(m3d).grid.xaxis.min 0.0 |
---|
59 | $driver put output.mesh(m3d).grid.xaxis.max 4.0 |
---|
60 | $driver put output.mesh(m3d).grid.xaxis.numpoints 5 |
---|
61 | $driver put output.mesh(m3d).grid.yaxis.min 0.0 |
---|
62 | $driver put output.mesh(m3d).grid.yaxis.max 4.0 |
---|
63 | $driver put output.mesh(m3d).grid.yaxis.numpoints 5 |
---|
64 | $driver put output.mesh(m3d).grid.zaxis.min 0.0 |
---|
65 | $driver put output.mesh(m3d).grid.zaxis.max 1.0 |
---|
66 | $driver put output.mesh(m3d).grid.zaxis.numpoints 2 |
---|
67 | |
---|
68 | $driver put output.field(f3d).about.label "3D Field" |
---|
69 | $driver put output.field(f3d).component.mesh "output.mesh(m3d)" |
---|
70 | |
---|
71 | for {set z 0} {$z < 2} {incr z} { |
---|
72 | for {set y 0} {$y < 5} {incr y} { |
---|
73 | for {set x 0} {$x < 5} {incr x} { |
---|
74 | set fval [expr $formula] |
---|
75 | $driver put -append yes output.field(f3d).component.values "$fval\n" |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | if {$vizmethod == "unstructured"} { |
---|
82 | # |
---|
83 | # Generate an unstructured grid 3D mesh and field values... |
---|
84 | # |
---|
85 | $driver put output.mesh(m3d).about.label "3D Unstructured Mesh" |
---|
86 | $driver put output.mesh(m3d).dim 3 |
---|
87 | $driver put output.mesh(m3d).units "um" |
---|
88 | $driver put output.mesh(m3d).hide "yes" |
---|
89 | |
---|
90 | $driver put output.field(f3d).about.label "3D Field" |
---|
91 | $driver put output.field(f3d).component.mesh "output.mesh(m3d)" |
---|
92 | |
---|
93 | for {set z 0} {$z < 2} {incr z} { |
---|
94 | for {set y 0} {$y < 5} {incr y} { |
---|
95 | for {set x 0} {$x < 5} {incr x} { |
---|
96 | $driver put -append yes output.mesh(m3d).unstructured.points "$x $y $z\n" |
---|
97 | set fval [expr $formula] |
---|
98 | $driver put -append yes output.field(f3d).component.values "$fval\n" |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "0 1 6 5 25 26 31 30\n" |
---|
104 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "1 2 7 6 26 27 32 31\n" |
---|
105 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "2 3 8 7 27 28 33 32\n" |
---|
106 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "3 4 9 8 28 29 34 33\n" |
---|
107 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "5 6 11 10 30 31 36 35\n" |
---|
108 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "8 9 14 13 33 34 39 38\n" |
---|
109 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "10 11 16 15 35 36 41 40\n" |
---|
110 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "13 14 19 18 38 39 44 43\n" |
---|
111 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "15 16 21 20 40 41 46 45\n" |
---|
112 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "16 17 22 21 41 42 47 46\n" |
---|
113 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "17 18 23 22 42 43 48 47\n" |
---|
114 | $driver put -append yes output.mesh(m3d).unstructured.hexahedrons "18 19 24 23 43 44 49 48\n" |
---|
115 | } |
---|
116 | |
---|
117 | # |
---|
118 | # Save the updated XML describing the run... |
---|
119 | # |
---|
120 | Rappture::result $driver |
---|
121 | exit 0 |
---|