Skip to content

Commit

Permalink
Chemora Ticket 169: Chemora: Handle EDL conditional (if/then) express…
Browse files Browse the repository at this point in the history
…ions.

Use ChemoraOpEqual and ChemoraOpNotEqual instead of Equal and Unequal
to avoid premature mapping. MMA won't map Greater["a","a"] but it will
map Equal["a",0] (to False).

process: Use ChemoraOpEqual and ChemoraOpNotEqual.
Kranc.hh: CPP macros ChemoraOpEqual, ChemoraOpNotEqual: New.
Kranc.m: Add symbols for ChemoraOpNotEqual, ChemoraOpNotEqual.
  • Loading branch information
dmkoppelman committed Nov 1, 2015
1 parent 47717dc commit 6b4a646
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Auxiliary/Cactus/SourceFiles/Kranc.hh
Expand Up @@ -130,6 +130,15 @@ void AssertGroupStorage(cGH const * restrict const cctkGH,
#define VanLeer(x, y) ((x) * (y) < 0 ? 0 : (Min3(2*fabs(x),2*fabs(y),0.5*(fabs(x)+fabs(y)))*Sign((x)+(y))))
#define StepFunction(x) ((x)>0)


/*********************************************************************
* Macros used in Chemora expressions
*********************************************************************/

#define ChemoraOpEqual(a,b) ((a)==(b))
#define ChemoraOpNotEqual(a,b) ((a)!=(b))


/*********************************************************************
* Numerical constants not defined in C++
*********************************************************************/
Expand Down
10 changes: 6 additions & 4 deletions Tools/CodeGen/Kranc.m
Expand Up @@ -42,7 +42,6 @@
{GridFunctions, Shorthands, Equations, t, DeclarationIncludes,
LoopPreIncludes, GroupImplementations, PartialDerivatives, NoSimplify,
Boundary, Interior, InteriorNoSync, Where, AddToStencilWidth,
ChemoraContents,
Everywhere, normal1, normal2, normal3, INV, SQR, CUB, QAD, dot, pow,
exp, t, cctkOriginSpace1, cctkOriginSpace2, cctkOriginSpace3,
dt, dx, dy, dz, idx, idy, idz, cctkLbnd1, cctkLbnd2, cctkLbnd3,
Expand Down Expand Up @@ -168,11 +167,14 @@
CArray;
ConditionExpression;

(* Chemora Symobls *)
(* Chemora Symbols *)

chemoraQuote;
{ ChemoraContents,

ChemoraNOffset;
ChemoraOpEqual, ChemoraOpNotEqual,

chemoraQuote,
ChemoraNOffset };


EndPackage[];
6 changes: 3 additions & 3 deletions Tools/CodeGen/KrancScript.m
Expand Up @@ -246,9 +246,9 @@

process["coexpr"[v1_, "cmpop"[cmpop_], v2_]] :=
Module[
{ opMap = { "<" -> Less, "<=" -> LessEqual,
"==" -> Equal, "!=" -> Unequal,
">=" -> GreaterEqual, ">" -> Greater },
{ opMap = { "<" -> Less, "<=" -> LessEqual,
"==" -> ChemoraOpEqual, "!=" -> ChemoraOpNotEqual,
">=" -> GreaterEqual, ">" -> Greater },
mappedOp },
mappedOp = cmpop /. opMap;
If[ StringQ[mappedOp],
Expand Down

0 comments on commit 6b4a646

Please sign in to comment.