aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen
diff options
context:
space:
mode:
authorshusa <shusa>2005-02-02 13:21:46 +0000
committershusa <shusa>2005-02-02 13:21:46 +0000
commit1098557134b7bf7e8f5eeed24a4e10d0676808de (patch)
tree1e618ce2ee27adbb360551c3a7c3f9fada954b1c /Tools/CodeGen
parente9246dbd525db0db3063b669370b5b6d5bb590c7 (diff)
correct bug in SafeDelete and move to Helpers.m, move ensureDirectory to
Helpers.m : EnsureDirectory
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r--Tools/CodeGen/CalculationFunction.m4
-rw-r--r--Tools/CodeGen/Helpers.m25
-rw-r--r--Tools/CodeGen/KrancThorns.m43
-rw-r--r--Tools/CodeGen/Thorn.m12
4 files changed, 45 insertions, 39 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m
index b497d72..c9aadd9 100644
--- a/Tools/CodeGen/CalculationFunction.m
+++ b/Tools/CodeGen/CalculationFunction.m
@@ -168,10 +168,10 @@ debugInLoop = False;
declareVariablesForCalculation[calc_] :=
Module[{shorthands, localGFs},
- shorthands = Union@Map[ToString, Union@Flatten@calculationUsedShorthands@calc];
+ shorthands = Sort@Union@Map[ToString, Union@Flatten@calculationUsedShorthands@calc];
shorthands = PartitionVarList@shorthands;
- localGFs = Map[localName, Union@Map[ToString, Union@Flatten@calculationUsedGFs@calc]];
+ localGFs = Map[localName, Sort@Union@Map[ToString, Union@Flatten@calculationUsedGFs@calc]];
localGFs = PartitionVarList@localGFs;
{CommentedBlock["Declare shorthands",
diff --git a/Tools/CodeGen/Helpers.m b/Tools/CodeGen/Helpers.m
index caa1285..a55fa34 100644
--- a/Tools/CodeGen/Helpers.m
+++ b/Tools/CodeGen/Helpers.m
@@ -26,9 +26,17 @@ EndPackage[];
BeginPackage["Helpers`", {"sym`"}];
TensorName::usage = "get the base name of a tensor object, i.e. TensorName[g[la, lb]]";
+
EnsureDirectory::usage = "create a directory if it does not already exist"
+SafeDelete::usage = "SafeDelete[filename_] deletes a file only after checking that the file actually exists and is a normal file";
+
AddSuffix::usage = "AddSuffix[object_,suffixString_] adds a suffix to an object";
-GFsFromGroupList::usage = "GFsFromGroupList[g_] gives the GFs from a group list in the from {\"group\", {gf1, gf2, ...}}";
+
+GFsFromGroupList::usage = "GFsFromGroupList[g_] gives the GFs from a group list in the form {\"group\", {gf1, gf2, ...}}";
+GroupStruct::usage = "GroupStruct[g_] returns a group structure the from {\"group\", {gf1, gf2, ...}}";
+
+ComponentList::usage = "ComponentList[T_[index_]] creates a list of tensor components.";
+TextComponentList::usage = "TextComponentList[T_[index_]] call ComponentList and converts to plain text format (no sub- or superscripts).";
Begin["`Private`"];
@@ -38,8 +46,23 @@ AddSuffix[object_,suffix_]:=ToExpression[ToString@object<>ToString@suffix]
EnsureDirectory[name_] := If[FileType[name] == None, CreateDirectory[name]];
+SafeDelete[filename_?StringQ] := If[FileType@filename == File, DeleteFile@filename];
+
GFsFromGroupList[g_] := Flatten@Map[Last,g]
+If[ValueQ@Global`tensorNames2componentNames[x],
+(* DecomposeTools.m is loaded *)
+
+ ComponentList[T_] := T /. Global`makeSplitRules[T];
+ TextComponentList[T_] := Global`tensorNames2componentNames@ComponentList[T];
+
+ ComponentList[expr_, T_?AtomQ[index__]] := expr /. Global`makeSplitRules[T[index]];
+ TextComponentList[expr_, T_?AtomQ[index__]] := Global`tensorNames2componentNames@ComponentList[expr, T[index]];
+
+ GroupStruct[t_[i__]] := {ToString@t, ComponentList@t[i]} // Global`tensorNames2componentNames;
+ GroupStruct[S_?AtomQ] := {ToString@S,{S}};
+];
+
End[];
diff --git a/Tools/CodeGen/KrancThorns.m b/Tools/CodeGen/KrancThorns.m
index fbef2e4..7688de1 100644
--- a/Tools/CodeGen/KrancThorns.m
+++ b/Tools/CodeGen/KrancThorns.m
@@ -51,7 +51,7 @@ EndPackage[];
BeginPackage["KrancThorns`",
- {"CodeGen`", "sym`", "Thorn`", "MapLookup`", "KrancGroups`", "Differencing`", "CalculationFunction`"}];
+ {"CodeGen`", "sym`", "Thorn`", "MapLookup`", "KrancGroups`", "Differencing`", "CalculationFunction`", "Helpers`"}];
CodeGen`SetSourceLanguage["C"];
@@ -106,8 +106,6 @@ ThornType::usage = "symbol to specify thorn types in ThornList structures
CactusGroup::usage = "CactusGroup[Thorns_, groupname_] extracts a Cactus
style group name from a Kranc thorns list, i.e. metric -> ADMBase::metric";
-SafeDelete::usage = "SafeDelete[filename_] deletes a file only after checking that the file actually exists and is a normal file";
-
Begin["`Private`"];
(****************************************************************************)
@@ -124,12 +122,6 @@ GetOptions[f_, optList_] :=
lookupDefault[Options[f],#, "NOT FOUND"]] &,
allKeys]];
-
-
-
-ensureDirectory[name_] := If[FileType[name] == None, CreateDirectory[name]];
-
-
simpleGroupStruct[thisgroup_, thistimelevel_] := {Group -> thisgroup,
Timelevels -> thistimelevel};
@@ -174,9 +166,6 @@ CactusGroup[Thorns_, gr_] := Module[{newthorns, name},
First@Cases[Map[name, newthorns], x_?StringQ]
];
-SafeDelete[filename_?StringQ] :=
- If[FileType@filename == "File", DeleteFile@filename];
-
(* "constants" used to specify default options *)
@@ -284,8 +273,8 @@ If[debug,
(* define directories and create if needed *)
arrangementDirectory = parentDirectory <> "/" <> systemName;
-ensureDirectory[parentDirectory];
-ensureDirectory[arrangementDirectory];
+EnsureDirectory[parentDirectory];
+EnsureDirectory[arrangementDirectory];
(* create parameter, GF and Groups lists *)
baseParamsTrueQ = Length@realBaseParameters + Length@intBaseParameters > 0;
@@ -791,8 +780,8 @@ baseParamsTrueQ = Length@realBaseParameters + Length@intBaseParameters > 0;
(* define directories and create if needed *)
arrangementDirectory = parentDirectory <> "/" <> systemName;
-ensureDirectory[parentDirectory];
-ensureDirectory[arrangementDirectory];
+EnsureDirectory[parentDirectory];
+EnsureDirectory[arrangementDirectory];
(* the list of thorns = return argument! *)
@@ -1016,8 +1005,8 @@ pddefs = lookupDefault[opts, PartialDerivatives, {}];
arrangementDirectory = parentDirectory <> "/" <> systemName;
-ensureDirectory[parentDirectory];
-ensureDirectory[arrangementDirectory];
+EnsureDirectory[parentDirectory];
+EnsureDirectory[arrangementDirectory];
Print["Creating files in directory " <> arrangementDirectory];
@@ -1277,8 +1266,8 @@ arrangementDirectory = parentDirectory <> "/" <> systemName;
Print["Creating files in directory " <> arrangementDirectory];
-ensureDirectory[parentDirectory];
-ensureDirectory[arrangementDirectory];
+EnsureDirectory[parentDirectory];
+EnsureDirectory[arrangementDirectory];
(* the list of thorns = return argument! *)
thornList =
@@ -1310,9 +1299,9 @@ thornList =
ThornParameters -> {}, ThornType -> "Driver"}};
-(****************************************************************)
-(* Add some new groups that the user doesn't need to know about *)
-(****************************************************************)
+(*****************************************************************)
+(* Add some new groups that the user does not need to know about *)
+(*****************************************************************)
(* This is needed for excision *)
excisionGroup = {"ExcisionNormals", {exnormx, exnormy, exnormz}};
@@ -1562,8 +1551,8 @@ pddefs = lookupDefault[opts, PartialDerivatives, {}];
baseParamsTrueQ = Length@realBaseParameters + Length@intBaseParameters > 0;
- ensureDirectory[parentDirectory];
- ensureDirectory[arrangementDirectory];
+ EnsureDirectory[parentDirectory];
+ EnsureDirectory[arrangementDirectory];
Print["Creating files in directory " <> arrangementDirectory];
@@ -1805,8 +1794,8 @@ debug = lookup[opts, DeBug];
arrangementDirectory = parentDirectory <> "/" <> systemName;
-ensureDirectory[parentDirectory];
-ensureDirectory[arrangementDirectory];
+EnsureDirectory[parentDirectory];
+EnsureDirectory[arrangementDirectory];
Print["Creating files in directory " <> arrangementDirectory];
diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m
index 71161e1..ecac4c3 100644
--- a/Tools/CodeGen/Thorn.m
+++ b/Tools/CodeGen/Thorn.m
@@ -45,7 +45,7 @@ Textual, TriggerGroups, Include};
EndPackage[];
-BeginPackage["Thorn`", "CodeGen`", "CalculationFunction`", "MapLookup`", "KrancGroups`"];
+BeginPackage["Thorn`", "CodeGen`", "CalculationFunction`", "MapLookup`", "KrancGroups`", "Helpers`"];
(* These functions are externally visible, and comprise the public
interface to this package. *)
@@ -74,12 +74,6 @@ Begin["`Private`"];
Miscellaneous definitions, could be moved elsewhere
------------------------------------------------------------------------ *)
-(* Create a directory if it does not exist already *)
-ensureDirectory[name_] :=
- If[FileType[name] == None,
- CreateDirectory[name]];
-
-
(* date, user, etc. *)
date[] := ToString[Date[][[3]]] <> "/" <>
ToString[Date[][[2]]] <> "/" <>
@@ -992,8 +986,8 @@ CreateThorn[thorn_] :=
Print["Creating thorns in directory ", thornDirectory];
- ensureDirectory[thornDirectory];
- ensureDirectory[sourceDirectory];
+ EnsureDirectory[thornDirectory];
+ EnsureDirectory[sourceDirectory];
GenerateFile[thornDirectory <> "/interface.ccl", lookup[thorn, Interface]];
GenerateFile[thornDirectory <> "/param.ccl", lookup[thorn, Param]];