BUG FIX: Symbolic Expressions

1 view
Skip to first unread message

James Quirk

unread,
Jul 1, 2010, 1:58:51 PM7/1/10
to amrita-ebook
I've just discovered a bug in AMRITA's symbolic expression machinery.
Consider the following script:

plugin amr_sol
EulerEquations
fold::amr_sol'Domain {
patch <1,1,10,10>
}
fold::amr_sol'BoundaryConditions {
W'inflow ::= <RHO=1,U=1,V=0,P=1>
QQ ::= 123
Nbdy domain: reflect
Sbdy domain: reflect
Ebdy domain: extrapolate
Wbdy domain: prescribe W'inflow
export QQ[]
}

If you save it to a file, expr_bug, and run it using:

amrita -debug expr_bug

Then examine the file debug.isl, you'll see that the expression
QQ has been corrupted and is exported as 3 instead of 123.
The culprit is the prescribe W'inflow command which causes
the last component of the solution vector to overwrite the
definition of QQ; hence the 3 which is the result of
assigning P/(GAMMA-1)+0.5*RHO*(U*U+V*V). Pending a new
AMRITA kit the problem can be fixed as follows.

In the file, $AMRITATA/Amrita/expression.pl, replace:

sub symbolic_expand {
my $ref = shift;
my $sym = shift;
my $vars = shift;
my $expr = $AMRITA::SYMBOLIC;
my $expanded = $expr->expand_reqvar($sym,$vars);
$expanded = $expr->optimize($expanded);
}

by:

sub symbolic_expand {
my $ref = shift;
my $sym = shift;
my $vars = shift;
my $expr = new Amrita::symbolic::expr;
my $expanded = $expr->expand_reqvar($sym,$vars);
$expanded = $expr->optimize($expanded);
}

James

Reply all
Reply to author
Forward
0 new messages