aboutsummaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2013-07-17 15:50:46 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2013-07-17 15:50:46 +0200
commit18b779d93b6f2a11ed1b45fcb9dc4f657abd969f (patch)
tree861bed8a93b5264efb1b2ecaf88fb009cf1ed502 /Tests
parent644c8cd8d199dc818045e19df9e642a046892c00 (diff)
Add test for IfThen factoring
Diffstat (limited to 'Tests')
-rw-r--r--Tests/IfThenTest.m50
1 files changed, 50 insertions, 0 deletions
diff --git a/Tests/IfThenTest.m b/Tests/IfThenTest.m
new file mode 100644
index 0000000..bf1d3b5
--- /dev/null
+++ b/Tests/IfThenTest.m
@@ -0,0 +1,50 @@
+<< "KrancThorn.m";
+
+derivatives = {
+ PDstandard2nd[i_] -> StandardCenteredDifferenceOperator[1,1,i],
+ PDstandard2nd[i_, i_] -> StandardCenteredDifferenceOperator[2,1,i]};
+
+PD = PDstandard2nd;
+
+groups = {{"evolved_group", {phi, pi}}};
+
+initialSineCalc = {
+ Name -> "initial_sine",
+ Schedule -> {"AT initial"},
+ Equations ->
+ {
+ phi -> IfThen[x > 0, Sin[2 Pi (x - t)], 0],
+ pi -> IfThen[x > 0, -2 Pi Cos[2 Pi (x - t)], 0]
+ }};
+
+evolveCalc = {
+ Name -> "calc_rhs",
+ Schedule -> {"IN MoL_CalcRHS"},
+ Where -> Interior,
+ Equations ->
+ {
+ dot[phi] -> IfThen[alpha>0, pi, 2 pi],
+ dot[pi] -> IfThen[alpha>0, Euc[ui,uj] PD[phi,li,lj], 2 Euc[ui,uj] PD[phi,li,lj]]
+ }};
+
+CreateKrancThornTT[
+ groups, ".",
+ "IfThenTest",
+ PartialDerivatives -> derivatives,
+ RealParameters -> {alpha},
+ DeclaredGroups -> {"evolved_group"},
+ Calculations -> {initialSineCalc, evolveCalc}];
+
+failures = 0;
+
+If[!StringMatchQ[Import["IfThenTest/src/calc_rhs.cc","Text"],
+ __~~"if (alpha > 0.)"~~__],
+ failures++;
+ Print["Test failed"]];
+
+If[!StringMatchQ[Import["IfThenTest/src/initial_sine.cc","Text"],
+ __~~"IfThen(xL"~~Whitespace~~">"~~Whitespace~~"0."~~__],
+ failures++;
+ Print["Test failed"]];
+
+Quit[failures]