aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Tools/CodeGen/CalculationFunction.m12
-rw-r--r--Tools/CodeGen/KrancThorn.m66
2 files changed, 37 insertions, 41 deletions
diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m
index 6f20c35..e7e5e40 100644
--- a/Tools/CodeGen/CalculationFunction.m
+++ b/Tools/CodeGen/CalculationFunction.m
@@ -680,7 +680,7 @@ equationLoop[eqs_,
opts:OptionsPattern[]] :=
Module[{rhss, lhss, gfsInRHS, gfsInLHS, gfsOnlyInRHS, localGFs, localMap, eqs2,
derivSwitch, actualSyncGroups, code, functionName, calcCode,
- syncCode, loopFunction},
+ syncCode, loopFunction, gfsInBoth},
rhss = Map[#[[2]] &, eqs];
lhss = Map[#[[1]] &, eqs];
@@ -696,6 +696,16 @@ equationLoop[eqs_,
gfsInLHS = Union[Cases[lhss, _ ? (MemberQ[gfs,#] &), Infinity]];
gfsOnlyInRHS = Complement[gfsInRHS, gfsInLHS];
+ gfsInBoth = Intersection[gfsInRHS,gfsInLHS];
+
+ If[OptionValue[ProhibitAssignmentToGridFunctionsRead] &&
+ gfsInBoth =!= {},
+ Throw["The calculation " <> ToString@lookup[cleancalc, Name] <>
+ " has the grid functions " <> ToString[gfsInBoth] <>
+ " on both the left hand side and the right hand side. This is" <>
+ " not allowed with the option" <>
+ " ProhibitAssignmentToGridFunctionsRead -> True."]];
+
localGFs = Map[localName, gfs];
localMap = Map[# -> localName[#] &, gfs];
diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m
index aa21242..f47fb49 100644
--- a/Tools/CodeGen/KrancThorn.m
+++ b/Tools/CodeGen/KrancThorn.m
@@ -27,14 +27,30 @@
BeginPackage["sym`"];
-{Calculations, DeclaredGroups, RealParameters, IntParameters, KeywordParameters,
- InheritedRealParameters,InheritedIntParameters,InheritedKeywordParameters,
- ExtendedRealParameters,ExtendedIntParameters,ExtendedKeywordParameters,
- Parameters,
- EvolutionTimelevels, DefaultEvolutionTimelevels,
- UseCSE, ThornOptions,
-
-PartialDerivatives, InheritedImplementations, ConditionalOnKeyword, ConditionalOnKeywords, ReflectionSymmetries, ZeroDimensions, CollectList, Interior, InteriorNoSync, Boundary, BoundaryWithGhosts, Where, PreDefinitions, AllowedSymbols, UseLoopControl};
+ThornOptions =
+ {Calculations -> {},
+ DeclaredGroups -> {},
+ Implementation -> None,
+ InheritedImplementations -> {},
+ EvolutionTimelevels -> 3,
+ DefaultEvolutionTimelevels -> None,
+ RealParameters -> {},
+ IntParameters -> {},
+ KeywordParameters -> {},
+ InheritedRealParameters -> {},
+ InheritedIntParameters -> {},
+ InheritedKeywordParameters -> {},
+ ExtendedRealParameters -> {},
+ ExtendedIntParameters -> {},
+ ExtendedKeywordParameters -> {},
+ PartialDerivatives -> {},
+ ReflectionSymmetries -> {},
+ ZeroDimensions -> {},
+ UseLoopControl -> False,
+ UseCSE -> False,
+ ProhibitAssignmentToGridFunctionsRead -> False};
+
+{ConditionalOnKeyword, ConditionalOnKeywords, CollectList, Interior, InteriorNoSync, Boundary, BoundaryWithGhosts, Where, PreDefinitions, AllowedSymbols, UseLoopControl, Parameters};
EndPackage[];
@@ -82,18 +98,10 @@ VerifyNewCalculation[calc_] :=
cktCheckNamedArgs[l_] :=
-Module[{allowed = {Calculations,
- DeclaredGroups, Implementation, InheritedImplementations,
- EvolutionTimelevels, DefaultEvolutionTimelevels,
- RealParameters, IntParameters, KeywordParameters,
- InheritedRealParameters,InheritedIntParameters,InheritedKeywordParameters,
- ExtendedRealParameters,ExtendedIntParameters,ExtendedKeywordParameters,
- PartialDerivatives, ReflectionSymmetries, ZeroDimensions, UseLoopControl,
- UseCSE},
- used, unrecognized},
+Module[{used, unrecognized},
used = Map[First, l];
- unrecognized = Complement[used, allowed];
+ unrecognized = Complement[used, Map[First, ThornOptions]];
If[Length[unrecognized] > 0,
ThrowError["Unrecognized named arguments: ", unrecognized]]
@@ -102,28 +110,6 @@ Module[{allowed = {Calculations,
replaceDots[x_] :=
x /. (dot[y_] :> Symbol[ToString[y] <> "rhs"]);
-ThornOptions =
- {Calculations -> {},
- DeclaredGroups -> {},
- Implementation -> None,
- InheritedImplementations -> {},
- EvolutionTimelevels -> 3,
- DefaultEvolutionTimelevels -> None,
- RealParameters -> {},
- IntParameters -> {},
- KeywordParameters -> {},
- InheritedRealParameters -> {},
- InheritedIntParameters -> {},
- InheritedKeywordParameters -> {},
- ExtendedRealParameters -> {},
- ExtendedIntParameters -> {},
- ExtendedKeywordParameters -> {},
- PartialDerivatives -> {},
- ReflectionSymmetries -> {},
- ZeroDimensions -> {},
- UseLoopControl -> False,
- UseCSE -> False,
- ProhibitAssignmentToGridfunctionsRead -> False};
Options[CreateKrancThorn] = ThornOptions;