aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen
diff options
context:
space:
mode:
authorBarry Wardell <barry.wardell@gmail.com>2012-02-17 10:51:18 +0000
committerBarry Wardell <barry.wardell@gmail.com>2012-02-17 10:51:18 +0000
commit1ab860f4a74d37423f44450ea9d67023a68adb80 (patch)
treecb36fd4ee799327d4d9f5a45e48b7b071462e7b2 /Tools/CodeGen
parent2b4de59a57a3491f4271f1749576b6a3a19559b5 (diff)
parent5ad2f1ba5ac386c91308e84765136d2307c5758f (diff)
Merge remote-tracking branch 'origin/dgfe'
Conflicts: Tools/CodeGen/CalculationFunction.m
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r--Tools/CodeGen/CalculationFunction.m51
1 files changed, 38 insertions, 13 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m
index a36691f..4d77c2b 100644
--- a/Tools/CodeGen/CalculationFunction.m
+++ b/Tools/CodeGen/CalculationFunction.m
@@ -378,7 +378,7 @@ DefFn[
shorts, eqs, parameters, parameterRules, odeGroups,
functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where,
addToStencilWidth, pDefs, haveCondTextuals, condTextuals, calc,
- kernelCall, DGFEDefs, DGFECall, debug, imp, gridName, stencilSize},
+ kernelCall, DGFEDefs, DGFEInit, DGFECall, debug, imp, gridName, stencilSize},
debug = OptionValue[Debug];
imp = lookup[calcp, Implementation];
@@ -480,21 +480,21 @@ DefFn[
kernelCall = Switch[where,
Everywhere,
- "GenericFD_LoopOverEverything(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverEverything(cctkGH, " <> bodyFunctionName <> ");\n",
Interior,
- "GenericFD_LoopOverInterior(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverInterior(cctkGH, " <> bodyFunctionName <> ");\n",
InteriorNoSync,
- "GenericFD_LoopOverInterior(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverInterior(cctkGH, " <> bodyFunctionName <> ");\n",
Boundary,
- "GenericFD_LoopOverBoundary(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverBoundary(cctkGH, " <> bodyFunctionName <> ");\n",
BoundaryWithGhosts,
- "GenericFD_LoopOverBoundaryWithGhosts(cctkGH, &" <> bodyFunctionName <> ");\n",
+ "GenericFD_LoopOverBoundaryWithGhosts(cctkGH, " <> bodyFunctionName <> ");\n",
_,
ThrowError["Unknown 'Where' entry in calculation " <>
functionName <> ": " <> ToString[where]]];
DGFEDefs =
- If[OptionValue[UseDGFE] && lookupDefault[cleancalc, UseDGFE, False],
+ If[OptionValue[UseDGFE],
Module[
{name, lhss, gfsInLHS, vars},
InfoMessage[InfoFull, "Generating DGFE boilerplate"];
@@ -671,11 +671,38 @@ DefFn[
"}",
"",
"",
+ "",
+ "/* A solver, DGFE's equivalent of cctkGH */",
+ "static "<>name<>"_solver *solver = NULL;",
+ "",
+ "",
+ "",
+ "/* Call the pointwise DGFE derivative operator */",
+ "#undef PDstandardNth1",
+ "#undef PDstandardNth2",
+ "#undef PDstandardNth3",
+ "#define PDstandardNth1(u) (solver->diff<hrscc::policy::x>(&(u)[-index], i,j,k))",
+ "#define PDstandardNth2(u) (solver->diff<hrscc::policy::y>(&(u)[-index], i,j,k))",
+ "#define PDstandardNth3(u) (solver->diff<hrscc::policy::z>(&(u)[-index], i,j,k))",
+ "",
+ "",
""
} // Flatten // Map[# <> "\n" &, #] &],
{}
];
+ DGFEInit =
+ If[OptionValue[UseDGFE],
+ Module[
+ {name},
+ name = lookup[cleancalc, Name];
+ {
+ "",
+ "if (not solver) solver = new "<>name<>"_method(cctkGH);"
+ } // Flatten // Map[# <> "\n" &, #] &],
+ {}
+ ];
+
DGFECall =
If[OptionValue[UseDGFE] && lookupDefault[cleancalc, UseDGFE, False],
Module[
@@ -683,12 +710,8 @@ DefFn[
name = lookup[cleancalc, Name];
{
"",
- "{",
- " static "<>name<>"_solver *solver = NULL;",
- " if (not solver) solver = new "<>name<>"_method(cctkGH);",
- " solver->compute_rhs();",
- " // delete solver;",
- "}"
+ "/* Add the flux terms to the RHS */",
+ "solver->compute_rhs();"
} // Flatten // Map[# <> "\n" &, #] &],
{}
];
@@ -778,6 +801,8 @@ DefFn[
If[haveCondTextuals, Map[ConditionalOnParameterTextual["!(" <> # <> ")", "return;\n"] &,condTextuals], {}],
+ DGFEInit,
+
kernelCall,
DGFECall,