aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Hinder <ian@vaio.(none)>2008-02-01 23:24:35 -0500
committerIan Hinder <ian@vaio.(none)>2008-02-02 01:40:11 -0500
commit19459dc5d9b9f0d986d3cb27389a311ade39356c (patch)
tree4c8d92e2eab454fadb22df2d404d7157a9ff0c41
parentffa08a3ff0341caf5f1da381048935a676ef714a (diff)
Erik: Add ability to specify number of timelevels for evolved variables at runtime
-rw-r--r--Tools/CodeGen/KrancThorn.m41
-rw-r--r--Tools/CodeGen/Thorn.m14
2 files changed, 42 insertions, 13 deletions
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index 9f46d7f..720247a 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -31,10 +31,9 @@ BeginPackage["sym`"];
KeywordParameters,
InheritedRealParameters,InheritedIntParameters,InheritedKeywordParameters,
ExtendedRealParameters,ExtendedIntParameters,ExtendedKeywordParameters,
- Parameters, PartialDerivatives, InheritedImplementations,
- ConditionalOnKeyword, ReflectionSymmetries, ZeroDimensions,
- CollectList, Interior, Boundary, Where, PreDefinitions,
- AllowedSymbols};
+ Parameters,
+ EvolutionTimelevels,
+ PartialDerivatives, InheritedImplementations, ConditionalOnKeyword, ReflectionSymmetries, ZeroDimensions, CollectList, Interior, Boundary, Where, PreDefinitions, AllowedSymbols};
EndPackage[];
@@ -192,6 +191,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts___] :=
thornName, realParamDefs, intParamDefs, keywordParams,
inheritedRealParams, inheritedIntParams, inheritedKeywordParams,
extendedRealParams, extendedIntParams, extendedKeywordParams,
+ evolutionTimelevels,
calcs];
(* Construct the schedule file *)
@@ -490,9 +490,11 @@ extendParameters[imp_, reals_, ints_, keywords_] :=
];
createKrancParam[evolvedGroups_, nonevolvedGroups_, groups_, thornName_,
- reals_, ints_, keywords_, inheritedReals_, inheritedInts_,
- inheritedKeywords_, extendedReals_, extendedInts_,
- extendedKeywords_, calcs_] :=
+ reals_, ints_, keywords_,
+ inheritedReals_, inheritedInts_, inheritedKeywords_,
+ extendedReals_, extendedInts_, extendedKeywords_,
+ evolutionTimelevels_,
+ calcs_] :=
Module[{nEvolved, nPrimitive, evolvedMoLParam, evolvedGFs,
constrainedMoLParam, genericfdStruct, realStructs, intStructs,
@@ -535,6 +537,17 @@ createKrancParam[evolvedGroups_, nonevolvedGroups_, groups_, thornName_,
Description -> "Number of constrained variables used by this thorn"}}
};
+ timelevelsParam =
+ {
+ Name -> "timelevels",
+ Type -> "CCTK_INT",
+ Default -> evolutionTimelevels,
+ Description -> "Number of active timelevels",
+ Visibility -> "private",
+ AllowedValues -> {{Value -> ToString[0] <> ":" <> ToString[evolutionTimelevels],
+ Description -> ""}}
+ };
+
genericfdStruct =
{
Name -> "GenericFD",
@@ -590,7 +603,8 @@ createKrancParam[evolvedGroups_, nonevolvedGroups_, groups_, thornName_,
userImplementations2 = If[userImplementations2=={{}},{},userImplementations2];
implementations = Join[userImplementations, userImplementations2, {genericfdStruct, molImplementation}];
- params = Join[{verboseStruct}, realStructs, intStructs, keywordStructs, {evolvedMoLParam, constrainedMoLParam}, calcEveryStructs, calcOffsetStructs,
+ params = Join[{verboseStruct}, realStructs, intStructs, keywordStructs, {evolvedMoLParam, constrainedMoLParam, timelevelsParam},
+ calcEveryStructs, calcOffsetStructs,
CactusBoundary`GetParameters[evolvedGFs, evolvedGroups]];
paramspec = {Implementations -> implementations,
@@ -608,6 +622,13 @@ simpleGroupStruct[groupName_, timelevels_] :=
Timelevels -> timelevels
};
+evolvedGroupStruct[groupName_, timelevels_, maxtimelevels_] :=
+{
+ Group -> groupName,
+ Timelevels -> timelevels,
+ MaxTimelevels -> maxtimelevels
+};
+
groupsSetInCalc[calc_, groups_] :=
Module[{gfs, eqs, lhss, gfsInLHS, lhsGroupNames},
gfs = allVariables[groups];
@@ -690,7 +711,8 @@ createKrancScheduleFile[calcs_, groups_, evolvedGroups_, nonevolvedGroups_, thor
};
globalStorageGroups = Join[Map[simpleGroupStruct[#, nonevolvedTimelevels[groupFromName[#, groups]]] &, nonevolvedGroups],
- Map[simpleGroupStruct[#, evolutionTimelevels] &, evolvedGroups]];
+ Map[evolvedGroupStruct[#, evolutionTimelevels, evolutionTimelevels] &, evolvedGroups]];
+(* Print["globalStorageGroups == ", globalStorageGroups];*)
scheduledFunctions =
Join[{scheduledStartup, scheduleMoLRegister, scheduleRegisterSymmetries},
@@ -766,6 +788,7 @@ CreateKrancThornTT[groups_, parentDirectory_, thornName_, opts___] :=
options = Join[DeleteCases[options, PartialDerivatives -> _], {PartialDerivatives -> expDerivs}];
declaredGroups = lookupDefault[{opts}, DeclaredGroups, {}];
+ evolutionTimelevels = lookupDefault[{opts}, EvolutionTimelevels, 3];
InfoMessage[Info, "Declared groups: " <> ToString[declaredGroups]];
InfoMessage[Terse, "Computing reflection symmetries"];
reflectionSymmetries = computeReflectionSymmetries[declaredGroups, groups];
diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m
index ebffde5..418aeb7 100644
--- a/Tools/CodeGen/Thorn.m
+++ b/Tools/CodeGen/Thorn.m
@@ -32,7 +32,8 @@ BeginPackage["sym`"];
{AccumulatorBase, ThornImplementation, Name, Type, Extend, Default,
Comment, Range, Implementation, Group, SchedulePoint, Language,
-SynchronizedGroups, StorageGroups, Timelevels, VariableType, GridType,
+SynchronizedGroups, StorageGroups, Timelevels, MaxTimelevels,
+VariableType, GridType,
Visibility, Variables, Implementations, Value, AllowedValues,
UsedParameters, Description, ExtendedParameters, NewParameters,
Directory, Interface, Param, Schedule, Sources, Makefile, Filename,
@@ -240,8 +241,8 @@ A 'tag' is of the form {"tensortypealias" -> "Scalar"}
interfaceGroupBlock[spec_] :=
{lookup[spec, Visibility], ":\n",
lookup[spec, VariableType], " ", lookup[spec, Name],
- " type=", lookup[spec,GridType], " ",
- "timelevels=", lookup[spec, Timelevels],
+ " type=", lookup[spec,GridType],
+ " timelevels=", lookup[spec, Timelevels],
If[mapContains[spec,Tags], {" tags='", interfaceTags[lookupDefault[spec,Tags, {}]], "'"}, ""],
"\n",
SuffixedCBlock[{CommaNewlineSeparated[lookup[spec, Variables]],"\n"},
@@ -346,7 +347,12 @@ CreateInterface[implementation_, inheritedImplementations_, includeFiles_,
structure for inclusion in the schedule.ccl file to allocate
storage for this group. *)
groupStorage[spec_] :=
- {"STORAGE: ", lookup[spec, Group], "[", lookup[spec, Timelevels], "]\n"}
+ If[mapContains[spec, MaxTimelevels],
+ Flatten[Table[{"if (timelevels == ", i, ")\n",
+ "{\n",
+ " STORAGE: ", lookup[spec, Group], "[", i, "]\n",
+ "}\n"}, {i, 1, lookup[spec, Timelevels]}], 1],
+ {"STORAGE: ", lookup[spec, Group], "[", lookup[spec, Timelevels], "]\n"}]
(* Given a function scheduling specification as defined above, return