Skip to content

Commit

Permalink
KrancThorn.m: Move option distribution code to its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Sep 13, 2013
1 parent b558b23 commit 508c5fd
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions Tools/CodeGen/KrancThorn.m
Expand Up @@ -82,6 +82,21 @@
splitCalculationsProcessCode[cIn_Code, opts___] :=
ApplyToObjectField[cIn, "Calculations", SplitCalculations]];

DefFn[
distributeOptionsProcessCode[cIn_Code, opts___] :=
Module[
{c = cIn},
c = SetObjectField[
c, "Calculations",
Map[Join[#, {Groups -> GetObjectField[c, "Groups"]}] &,
GetObjectField[c, "Calculations"]]];

c = SetObjectField[
c, "Calculations",
Map[Append[#, Parameters -> AllNumericParameters[GetObjectField[c, "Parameters"]]] &,
GetObjectField[c, "Calculations"]]];
c]];

(* --------------------------------------------------------------------------
Thorn generation (main entry point for non-tensorial thorns)
-------------------------------------------------------------------------- *)
Expand Down Expand Up @@ -225,17 +240,10 @@ Thorn generation (main entry point for non-tensorial thorns)
c = MoLProcessCode[c, opts];

(* ------------------------------------------------------------------------
Add options to calculations
Add selected code options to calculations
------------------------------------------------------------------------ *)

c = SetObjectField[c, "Calculations",
Map[Join[#, {Groups -> GetObjectField[c, "Groups"]}] &,
GetObjectField[c, "Calculations"]]];

c = SetObjectField[
c, "Calculations",
Map[Append[#, Parameters -> AllNumericParameters[GetObjectField[c, "Parameters"]]] &,
GetObjectField[c, "Calculations"]]];
c = distributeOptionsProcessCode[c, opts];

(* ------------------------------------------------------------------------
Split calculations according to SplitVars option
Expand Down

0 comments on commit 508c5fd

Please sign in to comment.