while do command
Purpose
This command allows writing while loops in input scripts.
Warning
GPU support for this command has not been tested and may not work as expected.Syntax
while boolean do
t1 t2 ...
done
boolean = a Boolean expression evaluated as TRUE or FALSE (see below)
do = required keyword
t1,t2,…,tN = one or more Aspherix® commands to execute if condition is met, each enclosed in quotes
done = required keyword
Examples
while "$i < 2" do
print "iter $i"
variable i equal $i+1
done
while "$i < 4" do
variable j equal 0
print "i = $i"
while "$j < 2" do
print "j = $j"
variable j equal $j+1
done
variable i equal $i+1
done
variable quote string "'"
variable nMeshes equal 128
variable i equal 1
while "$i <= ${nMeshes}" do
mesh id walls_${i} file meshes/mesh${i}.stl material steel &
element_exclusion_list mode read file meshes/exclustionList${i}.txt &
heal auto_remove_duplicates curvature 1e-10
# NOTE: needs quotes as variables for immediate substitution of var ${i}
# -- do NOT use "real" quotes here! --
write_to_file string ${quote}id_time id_walls_${i}[1]${quote} file force_${i}.txt &
write_every_time 0.01
variable i equal $i+1
done
Description
This command provides a do-while-loop capability within an input script. A Boolean expression is evaluated and the result is TRUE or FALSE. Note that as in the examples above, the expression can contain variables, as defined by the variable command, which will be evaluated as part of the expression. Thus a user-defined formula that reflects the current state of the simulation can be used to repeatedly issue possibly variable dependent commands.
If the result of the Boolean expression is TRUE, then one or more commands (t1, t2, …, tN) are executed. When the done keyword is reached, the boolean is evaluated again. If it is FALSE, the commands (t1, t2, …, tN) are omitted and the next command after the done keyword is executed. The may be multiple nested as well as multiple consecutive while done blocks.
A description of Boolean expression can be found in if command description.
Default
none