source: trunk/examples/zoo/cloud/cloud.tcl @ 2418

Last change on this file since 2418 was 2418, checked in by ldelgass, 11 years ago

Fix label on 3D field

File size: 2.1 KB
Line 
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# ======================================================================
10package require Rappture
11
12# open the XML file containing the run parameters
13set driver [Rappture::library [lindex $argv 0]]
14
15# get the formula and make it ready for evaluation
16set formula [$driver get input.string(formula).current]
17regsub -all {[xyz]} $formula {$\0} formula
18
19# get the number of points for the cloud
20set 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)"
31set z 1
32for {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)"
50for {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#
63Rappture::result $driver
64exit 0
Note: See TracBrowser for help on using the repository browser.