From 5fe746013b88df716c1df5cc9d64892a2c09e664 Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Thu, 12 Sep 2013 15:59:28 +0200 Subject: KrancThorn.m: Rearrange code and comments slightly --- Tools/CodeGen/KrancThorn.m | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index 68fc336..34b6e90 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -77,35 +77,44 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ InfoMessage[Terse, "Processing arguments to CreateKrancThorn"]; (* ------------------------------------------------------------------------ - Read named arguments + Read named arguments and apply nontrivial defaults ------------------------------------------------------------------------ *) cktCheckNamedArgs[{opts}]; calcs = OptionValue[Calculations]; - - calcs = Map[mapReplaceAdd[#, Shorthands, Join[lookup[#,Shorthands,{}],OptionValue[Shorthands]]] &, calcs]; - declaredGroups = OptionValue[DeclaredGroups]; odeGroups = OptionValue[ODEGroups]; - implementation = - If[OptionValue[Implementation] =!= None, - OptionValue[Implementation], - thornName]; - - calcs = Map[Append[#, Implementation -> implementation] &, calcs]; - + implementation = If[OptionValue[Implementation] =!= None, + OptionValue[Implementation], + thornName]; inheritedImplementations = OptionValue[InheritedImplementations]; includeFiles = OptionValue[IncludeFiles]; evolutionTimelevels = OptionValue[EvolutionTimelevels]; (* Redundant *) defaultEvolutionTimelevels = lookupDefault[{opts}, DefaultEvolutionTimelevels, evolutionTimelevels]; + partialDerivs = OptionValue[PartialDerivatives]; - parameters = ParameterDatabase[opts]; + (* ------------------------------------------------------------------------ + Add conservation differencing operators to partialDerivs + ------------------------------------------------------------------------ *) - partialDerivs = OptionValue[PartialDerivatives]; If[OptionValue[ConservationCalculations] =!= {}, partialDerivs = Join[partialDerivs, ConservationDifferencingOperators[]]]; + (* ------------------------------------------------------------------------ + Construct parameter database from named arguments + ------------------------------------------------------------------------ *) + + parameters = ParameterDatabase[opts]; + + (* ------------------------------------------------------------------------ + Add thorn-global options to calculations + ------------------------------------------------------------------------ *) + + calcs = Map[mapReplaceAdd[#, Shorthands, Join[lookup[#,Shorthands,{}],OptionValue[Shorthands]]] &, calcs]; + calcs = Map[Append[#, Implementation -> implementation] &, calcs]; + calcs = Map[Append[#, PartialDerivatives -> partialDerivs] &, calcs]; + (* ------------------------------------------------------------------------ CaKernel ------------------------------------------------------------------------ *) @@ -118,8 +127,6 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ If[!And@@Map[ListQ, calcs], Print[Short[calcs//InputForm]]; ThrowError["Result of WithHostCalculations is not a list of lists"]]; - calcs = Map[Append[#, PartialDerivatives -> partialDerivs] &, calcs]; - If[OptionValue[UseCaKernel], includeFiles = Append[includeFiles, "CaCUDALib_driver_support.h"]]; -- cgit v1.2.3