aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2012-01-27 23:10:09 -0600
committerIan Hinder <ian.hinder@aei.mpg.de>2012-01-27 23:10:09 -0600
commit4281f314a0ba6d290c8e47f11bfa7fc3b31cafad (patch)
treea11caf73978fa005d00f127007c0fb531e5c8ea3 /Tools/CodeGen
parenta3693e49061e53960334fbf7f0cd476be290fe2a (diff)
KrancTensor.m: Provide a new interface to CreateThorn
This new internal interface derives various things automatically that the user was previously required to provide, for example the groups structure. It also provides centered finite differencing at 2nd and 4th order (this can be increased) for the derivative PD with the order controlled by the new parameter fdOrder.
Diffstat (limited to 'Tools/CodeGen')
-rw-r--r--Tools/CodeGen/KrancTensor.m34
1 files changed, 33 insertions, 1 deletions
diff --git a/Tools/CodeGen/KrancTensor.m b/Tools/CodeGen/KrancTensor.m
index d0157c9..13c40bf 100644
--- a/Tools/CodeGen/KrancTensor.m
+++ b/Tools/CodeGen/KrancTensor.m
@@ -26,9 +26,12 @@
$KrancTensorPackage = "TensorToolsKranc`";
-BeginPackage["KrancTensor`", {"Errors`", "KrancThorn`", "MapLookup`", "KrancGroups`", "Kranc`", $KrancTensorPackage, "ConservationCalculation`", "TensorTools`"}];
+BeginPackage["KrancTensor`", {"Errors`", "KrancThorn`", "MapLookup`", "KrancGroups`",
+ "Kranc`", $KrancTensorPackage, "ConservationCalculation`",
+ "TensorTools`", "KrancGroups`", "Differencing`"}];
CreateKrancThornTT::usage = "Construct a Kranc thorn using tensor expressions.";
+CreateKrancThornTT2::usage = "Construct a Kranc thorn using tensor expressions.";
(* FIXME: Move CreateGroupFromTensor here *)
@@ -102,5 +105,34 @@ makeGroupExplicit[g_] :=
newGroup = SetGroupVariables[g, newVariables];
newGroup];
+Options[CreateKrancThornTT2] = ThornOptions;
+
+DefFn[CreateKrancThornTT2[thornName_String, opts:OptionsPattern[]] :=
+ Module[
+ {groups, pderivs, opts2, fdOrder = Global`fdOrder, PDstandard = Global`PDstandard},
+ groups = Map[CreateGroupFromTensor, OptionValue[Variables]];
+
+ pderivs =
+ Join[OptionValue[PartialDerivatives],
+ {
+ PDstandard[i_] ->
+ StandardCenteredDifferenceOperator[1,fdOrder/2,i],
+ PDstandard[i_, i_] ->
+ StandardCenteredDifferenceOperator[2,fdOrder/2,i],
+ PDstandard[i_, j_] ->
+ StandardCenteredDifferenceOperator[1,fdOrder/2,i] StandardCenteredDifferenceOperator[1,fdOrder/2,j]
+ }];
+
+ opts2 = mapReplaceAdd[{opts}, PartialDerivatives, pderivs];
+
+ opts2 = mapReplaceAdd[opts2, IntParameters, Join[lookup[opts2,IntParameters,{}],
+ {{Name -> fdOrder, Default -> 2, AllowedValues -> {2, 4}}}]];
+
+ opts2 = opts2 /. PD -> PDstandard;
+
+ CreateKrancThornTT[groups,OptionValue[ParentDirectory],thornName,
+ DeclaredGroups -> Map[groupName, groups],
+ Sequence@@opts2]]];
+
End[];
EndPackage[];