diff options
author | shusa <shusa> | 2004-10-27 18:44:58 +0000 |
---|---|---|
committer | shusa <shusa> | 2004-10-27 18:44:58 +0000 |
commit | 374b5f195deaedf15698cc2baad205d3da52b1a0 (patch) | |
tree | 59a8825b9c655fbfe6284000d1e012d2f61707fa /Tools/CodeGen/CodeGen.m | |
parent | 048e5a385b18fa1641fd33780e6b701b6c735325 (diff) |
changed detail about how stencil widths in grid loops are computed in C
Diffstat (limited to 'Tools/CodeGen/CodeGen.m')
-rw-r--r-- | Tools/CodeGen/CodeGen.m | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Tools/CodeGen/CodeGen.m b/Tools/CodeGen/CodeGen.m index e848470..82e441b 100644 --- a/Tools/CodeGen/CodeGen.m +++ b/Tools/CodeGen/CodeGen.m @@ -336,19 +336,23 @@ arrayIndex[i_] := i, If[NumberQ[i], i+1, {i, " + 1"}]]; +max[]:= If[SOURCELANGUAGE == "C", "IMAX", "max"]; + InitialiseGridLoopVariables[derivativesUsedSwitch_] := CommentedBlock["Set up variables used in the grid loop for the physical grid points", If[ (derivativesUsedSwitch), { - AssignVariable["index_offset_x", "Max(stencil_width, stencil_width_x)"], - AssignVariable["index_offset_y", "Max(stencil_width, stencil_width_y)"], - AssignVariable["index_offset_z", "Max(stencil_width, stencil_width_z)"], + AssignVariable["index_offset_x", max[] <>"(stencil_width, stencil_width_x)"], + AssignVariable["index_offset_y", max[] <>"(stencil_width, stencil_width_y)"], + AssignVariable["index_offset_z", max[] <>"(stencil_width, stencil_width_z)"], + "\n", AssignVariable["istart", arrayIndex["index_offset_x"]], AssignVariable["jstart", arrayIndex["index_offset_y"]], AssignVariable["kstart", arrayIndex["index_offset_z"]], + "\n", AssignVariable["iend", {arrayElement["cctk_lsh", 0], " - index_offset_x"}], AssignVariable["jend", {arrayElement["cctk_lsh", 1], " - index_offset_y"}], AssignVariable["kend", {arrayElement["cctk_lsh", 2], " - index_offset_z"}] @@ -359,6 +363,7 @@ InitialiseGridLoopVariables[derivativesUsedSwitch_] := AssignVariable["jstart", arrayIndex[0]], AssignVariable["kstart", arrayIndex[0]], + "\n", AssignVariable["iend", arrayElement["cctk_lsh", 0]], AssignVariable["jend", arrayElement["cctk_lsh", 1]], AssignVariable["kend", arrayElement["cctk_lsh", 2]] @@ -438,6 +443,13 @@ ReplacePowers[x_] := Module[{}, rhs = rhs /. Power[E, power_] -> exp[power]; rhs = rhs /. Power[xx_, 0.5] -> sqrt[xx]; + + (* there have been some problems doing the Max/Min + replacement via the preprocessor for C, so we do it + here *) + rhs = rhs /. Max[xx_, yy_] -> fmax[xx, yy]; + rhs = rhs /. Min[xx_, yy_] -> fmin[xx, yy]; + rhs = rhs /. Power[xx_, power_] -> pow[xx, power]], rhs = rhs /. Power[xx_, power_] -> xx^power |