aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen/KrancThorn.m
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/CodeGen/KrancThorn.m')
-rw-r--r--Tools/CodeGen/KrancThorn.m140
1 files changed, 3 insertions, 137 deletions
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 3f2af1f..96df0bf 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -59,7 +59,7 @@ EndPackage[];
BeginPackage["KrancThorn`", {"CodeGen`", "sym`", "Thorn`",
"MapLookup`", "KrancGroups`", "Differencing`",
"CalculationFunction`", "Errors`", "Helpers`", "CactusBoundary`",
- "TensorTools`", "Param`"}];
+ "TensorTools`", "Param`", "Schedule`"}];
CreateKrancThorn::usage = "Construct a Kranc thorn";
CreateKrancThornTT::usage = "Construct a Kranc thorn using TensorTools";
@@ -214,7 +214,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[
(* Construct the schedule file *)
InfoMessage[Terse, "Creating schedule file"];
- schedule = createKrancScheduleFile[calcs, groups, evolvedGroups,
+ schedule = CreateKrancScheduleFile[calcs, groups, evolvedGroups,
rhsGroups, nonevolvedGroups, thornName,
evolutionTimelevels];
@@ -329,7 +329,7 @@ nonevolvedGroupInterfaceStructure[group_] :=
{
Name -> groupName[group],
VariableType -> "CCTK_REAL",
- Timelevels -> nonevolvedTimelevels[group],
+ Timelevels -> NonevolvedTimelevels[group],
GridType -> "GF",
Comment -> groupName[group],
Visibility -> "public",
@@ -361,9 +361,6 @@ rhsGroupInterfaceStructure[group_, timelevels_] :=
Variables -> groupVariables[group]
}
-nonevolvedTimelevels[group_] :=
- Module[{tls = GroupTimelevels[group]},
- If[ tls === False, 1, tls]];
Options[createKrancInterface] = ThornOptions;
@@ -434,137 +431,6 @@ createKrancInterface[nonevolvedGroups_, evolvedGroups_, rhsGroups_, groups_,
CactusBoundary`GetUsedFunctions[]]];
Return[interface]];
-(* --------------------------------------------------------------------------
- Scheduling
- -------------------------------------------------------------------------- *)
-
-simpleGroupStruct[groupName_, timelevels_] :=
-{
- Group -> groupName,
- Timelevels -> timelevels
-};
-
-evolvedGroupStruct[groupName_, timelevels_, maxtimelevels_] :=
-{
- Group -> groupName,
- Timelevels -> timelevels,
- MaxTimelevels -> "timelevels"
-};
-
-rhsGroupStruct[groupName_, timelevels_, maxtimelevels_] :=
-{
- Group -> groupName,
- Timelevels -> timelevels,
- MaxTimelevels -> "rhs_timelevels"
-};
-
-groupsSetInCalc[calc_, groups_] :=
- Module[{gfs, eqs, lhss, gfsInLHS, lhsGroupNames},
- gfs = allGroupVariables[groups];
- eqs = lookup[calc, Equations];
- lhss = Map[First, eqs];
- gfsInLHS = Union[Cases[lhss, _ ? (MemberQ[gfs,#] &), Infinity]];
-
- lhsGroupNames = containingGroups[gfsInLHS, groups];
- Return[lhsGroupNames]
- ];
-
-(* Each calculation can be scheduled at multiple points, so this
- function returns a LIST of schedule structures for each calculation
- *)
-scheduleCalc[calc_, groups_] :=
- Module[{points, conditional, conditionals, keywordConditional, keywordConditionals, triggered, keyword, value, keywordvaluepairs, groupsToSync},
- conditional = mapContains[calc, ConditionalOnKeyword];
- conditionals = mapContains[calc, ConditionalOnKeywords];
- triggered = mapContains[calc, TriggerGroups];
- If[conditional,
- keywordConditional = lookup[calc, ConditionalOnKeyword];
- If[! MatchQ[keywordConditional, {lhs_String, rhs_String}],
- ThrowError["ConditionalOnKeyword entry in calculation expected to be of the form {parameter, value}, but was ", keywordConditional, "Calculation is ", calc]];
-
- keyword = keywordConditional[[1]];
- value = keywordConditional[[2]];
- ];
- If[conditionals,
- keywordConditionals = lookup[calc, ConditionalOnKeywords];
- If[! MatchQ[keywordConditionals, {{_, _} ...}],
- ThrowError["ConditionalOnKeywords entry in calculation expected to be of the form {{parameter, value}}, but was ", keywordConditionals, "Calculation is ", calc]];
-
- keywordvaluepairs =
- Map[# /. {keyword_, value_} -> {Parameter -> keyword, Value -> value} &,
- keywordConditionals];
- ];
-
- groupsToSync = If[lookupDefault[calc, Where, Everywhere] === Interior ||
- lookupDefault[calc, Where, Everywhere] === Boundary,
- groupsSetInCalc[calc, groups],
- {}];
-
- Map[
- Join[
- {
- Name -> lookup[calc, Name],
- SchedulePoint -> #,
- SynchronizedGroups -> If[StringMatchQ[#, "*MoL_CalcRHS*", IgnoreCase -> True] || StringMatchQ[#, "*MoL_RHSBoundaries*", IgnoreCase -> True],
- {},
- groupsToSync],
- Language -> CodeGen`SOURCELANGUAGE,
- Comment -> lookup[calc, Name]
- },
- If[triggered, {TriggerGroups -> lookup[calc, TriggerGroups]},
- {}],
- If[conditional, {Conditional -> {Parameter -> keyword, Value -> value}},
- {}],
- If[conditionals, {Conditionals -> keywordvaluepairs},
- {}]
- ] &,
- lookup[calc, Schedule]]];
-
-createKrancScheduleFile[calcs_, groups_, evolvedGroups_, rhsGroups_, nonevolvedGroups_, thornName_,
- evolutionTimelevels_] :=
- Module[{scheduledCalcs, scheduledStartup, scheduleMoLRegister, globalStorageGroups, scheduledFunctions, schedule},
-
- scheduledCalcs = Flatten[Map[scheduleCalc[#, groups] &, calcs], 1];
-
- scheduledStartup =
- {
- Name -> thornName <> "_Startup",
- SchedulePoint -> "at STARTUP",
- Language -> "C",
- Options -> "meta",
- Comment -> "create banner"
- };
-
- scheduleMoLRegister =
- {
- Name -> thornName <> "_RegisterVars",
- SchedulePoint -> "in MoL_Register",
- Language -> "C",
- Options -> "meta",
- Comment -> "Register Variables for MoL"
- };
-
- scheduleRegisterSymmetries =
- {
- Name -> thornName <> "_RegisterSymmetries",
- SchedulePoint -> "in SymmetryRegister",
- Language -> "C",
- Options -> "meta",
- Comment -> "register symmetries"
- };
-
- globalStorageGroups = Join[Map[simpleGroupStruct[#, nonevolvedTimelevels[groupFromName[#, groups]]] &, nonevolvedGroups],
- Map[evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, evolvedGroups],
- Map[rhsGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, rhsGroups]];
-
- scheduledFunctions =
- Join[{scheduledStartup, scheduleMoLRegister, scheduleRegisterSymmetries},
- scheduledCalcs, CactusBoundary`GetScheduledFunctions[thornName, evolvedGroups]];
-
- schedule = CreateSchedule[globalStorageGroups,
- CactusBoundary`GetScheduledGroups[thornName], scheduledFunctions];
-
- Return[schedule]];
Options[CreateSetterSourceWrapper] = ThornOptions;