Skip to content

Commit

Permalink
Change method used to determine which variables to set symmetries for…
Browse files Browse the repository at this point in the history
… in CodeGenSymmetries.m

This is for the old symmetry infrastructure, and the logic doesn't make a lot of sense anyway, but we reproduce it for compatibility reasons.  Changes the order of symmetry declarations in RegisterSymmetries.cc.
  • Loading branch information
ianhinder committed Sep 12, 2013
1 parent c1bcd9a commit 7369286
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
29 changes: 24 additions & 5 deletions Tools/CodeGen/CodeGenSymmetries.m
Expand Up @@ -21,7 +21,7 @@
BeginPackage[
"CodeGenSymmetries`",
{"Errors`", "Helpers`", "Kranc`", "CodeGenCactus`", "MapLookup`", "CodeGenKranc`",
"CodeGenC`", "CodeGen`"}];
"CodeGenC`", "CodeGen`", "KrancGroups`"}];

CreateSymmetriesRegistrationSource::usage = "";

Expand Down Expand Up @@ -63,18 +63,38 @@
(* Given a symmetries registration structure as defined above, return a
C CodeGen structure of a source file which will register the symmetries. *)
DefFn[
CreateSymmetriesRegistrationSource[thornName_String, implementationName_String, GFs_List,
CreateSymmetriesRegistrationSource[thornName_String, implementationName_String,
declaredGroups_List, groups_List, GFs_List,
reflectionSymmetries_List, debug:(True|False)] :=
Module[
{spec, j, lang, tmp},
{spec, j, lang, tmp, GFs2, nonRHSGroups},

If[debug, Print["Registering Symmetries for: ", GFs]];

lang = CodeGenC`SOURCELANGUAGE;
CodeGenC`SOURCELANGUAGE = "C";

(* TODO: symmetries should probably be applied to all groups, but
for compatibility, apply them only to the non-RHS groups as
this is what was done before *)
nonRHSGroups = Select[declaredGroups,
(!(lookup[GroupExtras[groupFromName[#, groups]],
MoLRHS,
False] ||
lookup[GroupExtras[groupFromName[#, groups]],
GridType,
"gf"] === "array")) &];

GFs2 = variablesFromGroups[nonRHSGroups, groups];

If[Union[GFs2] =!= Union[GFs],
Print["GFs don't match"];
Print["GFs = ", Union[GFs]];
Print["GFs2 = ", Union[GFs2]];
Quit[1]];

spec = Map[{FullName -> implementationName <> "::" <> ToString@#,
Sym -> calcSymmetry[#, Union@reflectionSymmetries]} &, GFs];
Sym -> calcSymmetry[#, Union@reflectionSymmetries]} &, GFs2];

tmp = {FileHeader["C"],

Expand All @@ -91,7 +111,6 @@
{}]]};

CodeGenC`SOURCELANGUAGE = lang;

tmp]];

End[];
Expand Down
2 changes: 1 addition & 1 deletion Tools/CodeGen/KrancThorn.m
Expand Up @@ -296,7 +296,7 @@ Thorn generation (main entry point for non-tensorial thorns)
{Filename -> "RegisterSymmetries.cc",
Contents -> CreateSymmetriesRegistrationSource[
thornName, implementation,
allGFs, OptionValue[ReflectionSymmetries], False]}]];
declaredGroups, groups, allGFs, OptionValue[ReflectionSymmetries], False]}]];

(* ------------------------------------------------------------------------
Startup source file
Expand Down

0 comments on commit 7369286

Please sign in to comment.