Skip to content

Commit

Permalink
Allow disabling UseJacobian for specific calculations
Browse files Browse the repository at this point in the history
Add UseJacobian as possible flag for calculations, which then
overrides the thorn's UseJacobian setting.
  • Loading branch information
eschnett committed Jun 2, 2012
1 parent 88420fd commit 2cc55d1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Tools/CodeGen/CalculationFunction.m
Expand Up @@ -147,6 +147,7 @@ indentation after each line break (this will push the line length
CollectList, AllowedSymbols, ApplyBCs, Conditional, CachedVariables, SplitBy,
SeparatedDerivatives, SeparatedDerivatives2,
LocalGroups, NoSimplify, UseDGFE, SimpleCode, UseCaKernel,
UseJacobian,
ScheduleGroups, TriggerGroups};

usedKeys = Map[First, calc];
Expand Down Expand Up @@ -394,9 +395,11 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be
shorts, eqs, parameters, parameterRules, odeGroups,
functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where,
addToStencilWidth, pDefs, haveCondTextuals, condTextuals, calc,
kernelCall, DGFEDefs, DGFEInit, DGFECall, debug, imp, gridName, stencilSize},
kernelCall, DGFEDefs, DGFEInit, DGFECall, debug, useJacobian,
imp, gridName, stencilSize},

debug = OptionValue[Debug];
useJacobian = OptionValue[UseJacobian] && lookupDefault[calcp, UseJacobian, True];
imp = lookup[calcp, Implementation];
gridName = lookup[calcp, GFAccessFunction];

Expand All @@ -407,7 +410,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be

InfoMessage[InfoFull, "Calculation sets "<>ToString[Map[First,lookup[calcp, Equations]]]];

calc = If[OptionValue[UseJacobian], InsertJacobian[calcp, opts], calcp];
calc = If[useJacobian, InsertJacobian[calcp, opts], calcp];

cleancalc = removeUnusedShorthands[calc];
If[OptionValue[CSE],
Expand All @@ -419,7 +422,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be
parameters = lookupDefault[cleancalc, Parameters, {}];
groups = lookup[cleancalc, Groups];
odeGroups = lookupDefault[cleancalc, ODEGroups, {}];
If[OptionValue[UseJacobian], groups = Join[groups, JacobianGroups[]]];
If[useJacobian, groups = Join[groups, JacobianGroups[]]];
pddefs = lookupDefault[cleancalc, PartialDerivatives, {}];
where = lookupDefault[cleancalc, Where, Everywhere];
addToStencilWidth = lookupDefault[cleancalc, AddToStencilWidth, 0];
Expand Down Expand Up @@ -486,7 +489,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be
knownSymbols = Join[lookupDefault[cleancalc, AllowedSymbols, {}], gfs, shorts, parameters,
{dx,dy,dz,dt,idx,idy,idz,t, Pi, E, Symbol["i"], Symbol["j"], Symbol["k"], normal1, normal2,
normal3, tangentA1, tangentA2, tangentA3, tangentB1, tangentB2, tangentB3},
If[OptionValue[UseJacobian], JacobianSymbols[], {}]];
If[useJacobian, JacobianSymbols[], {}]];

unknownSymbols = Complement[allSymbols, knownSymbols];

Expand Down Expand Up @@ -718,7 +721,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be

definePreDefinitions[pDefs],

If[OptionValue[UseJacobian], CreateJacobianVariables[], {}],
If[useJacobian, CreateJacobianVariables[], {}],

If[Cases[{pddefs}, SBPDerivative[_], Infinity] != {},
CommentedBlock["Compute Summation By Parts derivatives",
Expand Down Expand Up @@ -807,10 +810,13 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be
gfsInBoth, gfsDifferentiated,
gfsDifferentiatedAndOnLHS, declare, eqsReplaced,
arraysInRHS, arraysInLHS, arraysOnlyInRHS, odeVars,
generateEquationCode, groupedIfs, IfThenGroup, noSimplify,gridName},
generateEquationCode, groupedIfs, IfThenGroup, noSimplify,
gridName, useJacobian},

InfoMessage[InfoFull, "Equation loop"];

useJacobian = OptionValue[UseJacobian] && lookupDefault[cleancalc, UseJacobian, True];

gridName = Function[x,FlattenBlock[lookup[cleancalc, GFAccessFunction][x]]];

rhss = Map[#[[2]] &, eqs];
Expand Down Expand Up @@ -973,7 +979,7 @@ it is only possible to do this outside all if(){} statements. *)
(* DeclareDerivatives[defsWithoutShorts, eqsOrdered], *)

CommentedBlock["Assign local copies of grid functions",
assignLocalGridFunctions[gfsInRHS, OptionValue[UseVectors], OptionValue[UseJacobian]]],
assignLocalGridFunctions[gfsInRHS, OptionValue[UseVectors], useJacobian]],

CommentedBlock["Include user supplied include files",
Map[IncludeFile, incs]],
Expand Down

0 comments on commit 2cc55d1

Please sign in to comment.