Skip to content

Commit

Permalink
Chemora: Correctly compute STENCIL and EXTERIOR attributes for EDL code.
Browse files Browse the repository at this point in the history
Patch by Steve Brandt.
  • Loading branch information
dmkoppelman committed Mar 9, 2016
1 parent 98c3c93 commit 09cece5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Tools/CodeGen/Calculation.m
Expand Up @@ -134,13 +134,21 @@
Error["Internal error: Invalid stencil size"]];
MatchQ[stencilSize, {0,0,0}]]];

CombineStencils[{i1_,j1_,k1_},I3D[i2_,j2_,k2_]] :=
{Max[i1,Abs[i2]],Max[j1,Abs[j2]],Max[k1,Abs[k2]]};
CombineStencils[arg1_,{}] := arg1;
CombineStencils[arg1_,{arg2_,arg3___}] :=
CombineStencils[CombineStencils[arg1,arg2],{arg3}];

DefFn[
CalculationStencilSize[calc_List] :=
Module[
{pddefs, eqs, stencilSize},
{pddefs, eqs, stencilSize, explicit, name, i, j, k},

pddefs = lookup[calc, PartialDerivatives, {}];
eqs = lookup[calc, Equations];
explicit = {};
calc /. I3D[name_,i_?NumberQ,j_?NumberQ,k_?NumberQ] :> (AppendTo[explicit,I3D[i,j,k]];I3D[name,i,j,k]);

stencilSize = StencilSize[pddefs, eqs, "not needed", {} (*ZeroDimensions*),
lookupDefault[calc, IntParameters, {}]];
Expand All @@ -150,6 +158,7 @@
If[!VectorQ[stencilSize],
stencilSize = MapThread[Max,Map[Last,stencilSize[[2]]]]];
(* TODO: decide what to do about stencil sizes that depend on runtime parameters *)
stencilSize = CombineStencils[stencilSize,explicit];
stencilSize]];

DefFn[
Expand Down

0 comments on commit 09cece5

Please sign in to comment.