From 5f2e80404eae61e51a2b30f8a8468238b5ee66aa Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Fri, 13 Sep 2013 17:08:55 +0200 Subject: KrancThorn.m: Move coordinates code processing to a separate function --- Tools/CodeGen/KrancThorn.m | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index de89f28..bbc71b9 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -55,6 +55,20 @@ DefFn[ Append[#, GridType -> "array"], #] &, groups]]; +DefFn[ + coordinatesProcessCode[cIn_Code, opts___] := + Module[ + {c = cIn}, + (* TODO: this should just be an Append. The order of the groups + should not matter. We could also check that the input groups + do not contain the coordinates. *) + + c = SetObjectField[c, "Groups", + Union[GetObjectField[c, "Groups"], + {{"grid::coordinates", {Kranc`x,Kranc`y,Kranc`z,Kranc`r}}}, + SameTest->(ToLowerCase[#1]==ToLowerCase[#2]&)]]; + c]]; + (* -------------------------------------------------------------------------- Thorn generation (main entry point for non-tensorial thorns) -------------------------------------------------------------------------- *) @@ -133,14 +147,7 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ CheckGroups[GetObjectField[c, "Groups"]]; - (* TODO: this should just be an Append. The order of the groups - should not matter. We could also check that the input groups - do not contain the coordinates. *) - - c = SetObjectField[c, "Groups", - Union[GetObjectField[c, "Groups"], - {{"grid::coordinates", {Kranc`x,Kranc`y,Kranc`z,Kranc`r}}}, - SameTest->(ToLowerCase[#1]==ToLowerCase[#2]&)]]; + c = coordinatesProcessCode[c, opts]; (* ------------------------------------------------------------------------ Separate derivatives -- cgit v1.2.3