diff options
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/param.ccl | 5 | ||||
-rw-r--r-- | Tools/CodeGen/Interface.m | 11 | ||||
-rw-r--r-- | Tools/CodeGen/Jacobian.m | 13 | ||||
-rw-r--r-- | Tools/CodeGen/Thorn.m | 3 |
4 files changed, 24 insertions, 8 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/param.ccl b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/param.ccl index 85de1f9..8e410f7 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/param.ccl +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/param.ccl @@ -42,3 +42,8 @@ CCTK_STRING jacobian_derivative_group "Name of group containing Jacobian derivat { "" :: "String of the form <implementation>::<groupname>" } "" + +CCTK_INT jacobian_identity_map "Map number on which the Jacobian should not be applied" +{ + -1:* :: "Any integer" +} -1 diff --git a/Tools/CodeGen/Interface.m b/Tools/CodeGen/Interface.m index c0a15e1..5f8f613 100644 --- a/Tools/CodeGen/Interface.m +++ b/Tools/CodeGen/Interface.m @@ -73,7 +73,7 @@ CreateKrancInterface[nonevolvedGroups_, evolvedGroups_, rhsGroups_, groups_, Module[{registerEvolved, (*registerConstrained,*) nonevolvedGroupStructures, evolvedGroupStructures, rhsGroupStructures, - groupStructures, interface}, + groupStructures, interface, getMap}, VerifyGroupNames[nonevolvedGroups]; VerifyGroupNames[evolvedGroups]; VerifyGroupNames[rhsGroups]; @@ -105,6 +105,13 @@ CreateKrancInterface[nonevolvedGroups_, evolvedGroups_, rhsGroups_, groups_, ArgString -> "CCTK_POINTER_TO_CONST IN cctkGH, CCTK_INT IN dir, CCTK_INT IN nsize, CCTK_INT OUT ARRAY imin, CCTK_INT OUT ARRAY imax, CCTK_REAL OUT ARRAY q, CCTK_INT IN table_handle" }; + getMap = + { + Name -> "MultiPatch_GetMap", + Type -> "CCTK_INT", + ArgString -> "CCTK_POINTER_TO_CONST IN cctkGH" + }; + (* For each group declared in this thorn, we need an entry in the interface file. Each evolved group needs an associated rhs @@ -131,7 +138,7 @@ CreateKrancInterface[nonevolvedGroups_, evolvedGroups_, rhsGroups_, groups_, If[OptionValue[UseVectors], {"vectors.h"}, {}]], groupStructures, UsesFunctions -> - Join[{registerEvolved, (*registerConstrained,*) diffCoeff}, + Join[{registerEvolved, (*registerConstrained,*) diffCoeff, getMap}, CactusBoundary`GetUsedFunctions[]]]; Return[interface]]; diff --git a/Tools/CodeGen/Jacobian.m b/Tools/CodeGen/Jacobian.m index 59a57f9..8ebd243 100644 --- a/Tools/CodeGen/Jacobian.m +++ b/Tools/CodeGen/Jacobian.m @@ -38,7 +38,7 @@ JacobianQ[opts:OptionsPattern[]] := jacobianShorthand[d:(deriv_[var_, i_])] := Module[{}, derivToJacDeriv[d] -> - Sum[Symbol["J"<>ToString[j]<>ToString[i]] deriv[var, j], {j, 1 3}] + IfThen["use_jacobian", Sum[Symbol["J"<>ToString[j]<>ToString[i]] deriv[var, j], {j, 1 3}], deriv[var, i]] ]; (* Assign a shorthand containing the Jacobian multiplied by the passed @@ -47,8 +47,9 @@ jacobianShorthand[d:(deriv_[var_, i_,j_])] := Module[{ip,jp}, {ip,jp} = Sort[{i,j}]; (* dJ is symmetric in the last two indices *) derivToJacDeriv[d] -> - Sum[Symbol["dJ"<>ToString[a]<>ToString[ip]<>ToString[jp]] deriv[var, a], {a, 1 3}] + - Sum[Symbol["J"<>ToString[a]<>ToString[i]] Symbol["J"<>ToString[b]<>ToString[j]] deriv[var, a, b], {a, 1 3}, {b, 1, 3}] + IfThen["use_jacobian", Sum[Symbol["dJ"<>ToString[a]<>ToString[ip]<>ToString[jp]] deriv[var, a], {a, 1 3}] + + Sum[Symbol["J"<>ToString[a]<>ToString[i]] Symbol["J"<>ToString[b]<>ToString[j]] deriv[var, a, b], {a, 1 3}, {b, 1, 3}], + deriv[var, i, j]] ]; (* Convert a 1st derivative to a Jacobian-multiplied derivative *) @@ -81,7 +82,8 @@ InsertJacobian[calc_List, opts:OptionsPattern[]] := derivatives groups *) CreateJacobianVariables[] := CommentedBlock["Jacobian variable pointers", - {"if (strlen(jacobian_group) == 0 || strlen(jacobian_derivative_group) == 0)\n", + {"bool use_jacobian = (!CCTK_IsFunctionAliased(\"MultiPatch_GetMap\") || MultiPatch_GetMap(cctkGH) != jacobian_identity_map)\n && strlen(jacobian_group) > 0;\n", + "if (use_jacobian && strlen(jacobian_derivative_group) == 0)\n", "{\n", " CCTK_WARN (1, \"GenericFD::jacobian_group and GenericFD::jacobian_derivative_group must both be set to valid group names\");\n", "}\n\n", @@ -106,7 +108,8 @@ JacobianSymbols[] := (* Parameters to inherit from GenericFD *) JacobianGenericFDParameters[] := {{Name -> "jacobian_group", Type -> "CCTK_STRING"}, - {Name -> "jacobian_derivative_group", Type -> "CCTK_STRING"}}; + {Name -> "jacobian_derivative_group", Type -> "CCTK_STRING"}, + {Name -> "jacobian_identity_map", Type -> "CCTK_INT"}}; (* The symbols which are used for the Jacobian variables in the generated source code. These do not have to coincide with the diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index a454f87..22b9f77 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -509,7 +509,8 @@ CreateSetterSource[calcs_, debug_, include_, imp_, {IncludeSystemFile["assert.h"], IncludeSystemFile["math.h"], IncludeSystemFile["stdio.h"], - IncludeSystemFile["stdlib.h"]}, + IncludeSystemFile["stdlib.h"], + IncludeSystemFile["string.h"]}, {"\n"} ], |