From 7369286bc4ab997558d90a594d13873f9fd75ba4 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Thu, 12 Sep 2013 21:46:59 +0200 Subject: Change method used to determine which variables to set symmetries for 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. --- Tools/CodeGen/CodeGenSymmetries.m | 29 ++++++++++++++++++++++++----- Tools/CodeGen/KrancThorn.m | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Tools/CodeGen/CodeGenSymmetries.m b/Tools/CodeGen/CodeGenSymmetries.m index 31e6834..60e898a 100644 --- a/Tools/CodeGen/CodeGenSymmetries.m +++ b/Tools/CodeGen/CodeGenSymmetries.m @@ -21,7 +21,7 @@ BeginPackage[ "CodeGenSymmetries`", {"Errors`", "Helpers`", "Kranc`", "CodeGenCactus`", "MapLookup`", "CodeGenKranc`", - "CodeGenC`", "CodeGen`"}]; + "CodeGenC`", "CodeGen`", "KrancGroups`"}]; CreateSymmetriesRegistrationSource::usage = ""; @@ -63,18 +63,38 @@ DefFn[ (* 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"], @@ -91,7 +111,6 @@ DefFn[ {}]]}; CodeGenC`SOURCELANGUAGE = lang; - tmp]]; End[]; diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index 21d4df0..b49eca0 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -296,7 +296,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ {Filename -> "RegisterSymmetries.cc", Contents -> CreateSymmetriesRegistrationSource[ thornName, implementation, - allGFs, OptionValue[ReflectionSymmetries], False]}]]; + declaredGroups, groups, allGFs, OptionValue[ReflectionSymmetries], False]}]]; (* ------------------------------------------------------------------------ Startup source file -- cgit v1.2.3