diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-12-06 17:12:31 +0100 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2010-12-06 20:36:42 +0100 |
commit | 3b7c2193b41cebf8ebb8ba3586928ace23ee720c (patch) | |
tree | 149dce1a0b3572a20773c232fee909bde74b5a71 | |
parent | a41bfbe853bf083bdc27f46a88e2a09252d0925d (diff) | |
parent | 8fe31b346679148fcea5d47d3508fcd2c7c8d75c (diff) |
Merge master into vector
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c | 19 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h | 3 | ||||
-rw-r--r-- | Examples/Wave.m | 10 | ||||
-rw-r--r-- | Tools/CodeGen/CactusBoundary.m | 8 | ||||
-rw-r--r-- | Tools/CodeGen/CalculationFunction.m | 24 | ||||
-rw-r--r-- | Tools/CodeGen/KrancThorn.m | 3 | ||||
-rw-r--r-- | Tools/CodeGen/TensorTools.m | 13 | ||||
-rw-r--r-- | Tools/CodeGen/Thorn.m | 2 |
8 files changed, 65 insertions, 17 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c index ba83b89..9084f65 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c @@ -503,3 +503,22 @@ void GenericFD_PenaltyPrim2Char(cGH const * restrict const cctkGH, int const dir return; } + +void GenericFD_AssertGroupStorage(cGH const * restrict const cctkGH, const char *calc, + int ngroups, const char *group_names[ngroups]) +{ + for (int i = 0; i < ngroups; i++) + { + int result = CCTK_QueryGroupStorage(cctkGH, group_names[i]); + if (result == 0) + { + CCTK_VWarn(CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error in %s: Group \"%s\" does not have storage", calc, group_names[i]); + } + else if (result < 0) + { + CCTK_VWarn(CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error in %s: Invalid group name \"%s\"", calc, group_names[i]); + } + } +} diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h index 7d8a13d..d9ead13 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h @@ -708,6 +708,9 @@ void GenericFD_GetBoundaryInfo(cGH const * restrict cctkGH, int * restrict is_physbnd, int * restrict is_ipbnd); +void GenericFD_AssertGroupStorage(cGH const * restrict const cctkGH, const char *calc, + int ngroups, const char *group_names[]); + #if 0 /* Finite differencing near boundaries */ diff --git a/Examples/Wave.m b/Examples/Wave.m index 0c19475..94dbbda 100644 --- a/Examples/Wave.m +++ b/Examples/Wave.m @@ -36,10 +36,10 @@ zerodims = {}; PD = PDstandard2nd; PDnorm = PDplus; -evolvedGroup = {"evolved", {phi, pi}}; -normGroup = {"norms", {VL2, VDP, EL2}}; -exactGroup = {"exact", {phiExact, piExact}}; -errorGroup = {"errors", {phiError, piError}}; +evolvedGroup = {"evolved", {phi, pi}, Timelevels -> 3}; +normGroup = {"norms", {VL2, VDP, EL2}, Timelevels -> 3}; +exactGroup = {"exact", {phiExact, piExact}, Timelevels -> 3}; +errorGroup = {"errors", {phiError, piError}, Timelevels -> 3}; groups = {evolvedGroup, normGroup, exactGroup, errorGroup}; @@ -105,7 +105,7 @@ importerCalc = evolveEquations = { dot[phi] -> pi, - dot[pi] -> PD[phi,li,ui] + dot[pi] -> PD[phi,li,lj] Euc[ui,uj] } evolveCalc = diff --git a/Tools/CodeGen/CactusBoundary.m b/Tools/CodeGen/CactusBoundary.m index ceb640d..3f3a110 100644 --- a/Tools/CodeGen/CactusBoundary.m +++ b/Tools/CodeGen/CactusBoundary.m @@ -95,10 +95,10 @@ GetScheduledFunctions[thornName_, evolvedGroups_] := } }; -createBoundTypeParam[groupOrGF_] := { +createBoundTypeParam[groupOrGF_, def_] := { Name -> ToString@groupOrGF <> "_bound", Type -> "KEYWORD", - Default -> "skip", + Default -> def, Description -> "Boundary condition to implement", Visibility -> "private", AllowedValues -> { @@ -143,8 +143,8 @@ createBoundScalarParam[groupOrGF_] := { }; GetParameters[evolvedGFs_, evolvedGroups_] := - Join[Map[createBoundTypeParam, evolvedGFs], - Map[createBoundTypeParam, Map[unqualifiedGroupName,evolvedGroups]], + Join[Map[createBoundTypeParam[#,"skip"] &, evolvedGFs], + Map[createBoundTypeParam[#,"none"] &, Map[unqualifiedGroupName,evolvedGroups]], Map[createBoundSpeedParam, evolvedGFs], Map[createBoundSpeedParam, Map[unqualifiedGroupName,evolvedGroups]], diff --git a/Tools/CodeGen/CalculationFunction.m b/Tools/CodeGen/CalculationFunction.m index df79553..f65e539 100644 --- a/Tools/CodeGen/CalculationFunction.m +++ b/Tools/CodeGen/CalculationFunction.m @@ -157,6 +157,26 @@ removeUnusedShorthands[calc_] := removeUnusedShorthands[newCalc], newCalc]]; +(* Return all the groups that are used in a given calculation *) +groupsInCalculation[calc_, imp_] := + Module[{groups,gfs,eqs,gfsUsed, groupNames}, + groups = lookup[calc, Groups]; + gfs = allGroupVariables[groups]; + eqs = lookup[calc, Equations]; + gfsUsed = Union[Cases[eqs, _ ? (MemberQ[gfs,#] &), Infinity]]; + groupNames = containingGroups[gfsUsed, groups]; + Map[qualifyGroupName[#, imp] &, groupNames]]; + +CheckGroupStorage[groupNames_, calcName_] := + Module[{ignoreGroups, groupsNames2}, + ignoreGroups = {"TmunuBase::stress_energy_scalar", "TmunuBase::stress_energy_vector", + "TmunuBase::stress_energy_tensor"}; + groupNames2 = Select[groupNames, !MemberQ[ignoreGroups, #] &]; + {"\nconst char *groups[] = {", + Riffle[Map[Quote,groupNames2], ","], + "};\n", + "GenericFD_AssertGroupStorage(cctkGH, ", Quote[calcName],", ", Length[groupNames2], ", groups);\n"}]; + (* -------------------------------------------------------------------------- Variables -------------------------------------------------------------------------- *) @@ -324,7 +344,7 @@ pdCanonicalOrdering[name_[inds___] -> x_] := Options[CreateCalculationFunction] = ThornOptions; -CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] := +CreateCalculationFunction[calc_, debug_, useCSE_, imp_, opts:OptionsPattern[]] := Module[{gfs, allSymbols, knownSymbols, shorts, eqs, parameters, parameterRules, functionName, dsUsed, groups, pddefs, cleancalc, eqLoop, where, @@ -417,6 +437,8 @@ CreateCalculationFunction[calc_, debug_, useCSE_, opts:OptionsPattern[]] := ConditionalOnParameterTextual["cctk_iteration % " <> functionName <> "_calc_every != " <> functionName <> "_calc_offset", "return;\n"], + CheckGroupStorage[groupsInCalculation[cleancalc, imp], functionName], + If[haveCondTextuals, Map[ConditionalOnParameterTextual["!(" <> # <> ")", "return;\n"] &,condTextuals], {}], CommentedBlock["Include user-supplied include files", diff --git a/Tools/CodeGen/KrancThorn.m b/Tools/CodeGen/KrancThorn.m index 7527f5e..28bf6e1 100644 --- a/Tools/CodeGen/KrancThorn.m +++ b/Tools/CodeGen/KrancThorn.m @@ -126,6 +126,9 @@ CreateKrancThorn[groupsOrig_, parentDirectory_, thornName_, opts:OptionsPattern[ useCSE = OptionValue[UseCSE]; coordGroup = {"grid::coordinates", {Kranc`x,Kranc`y,Kranc`z,Kranc`r}}; + + CheckGroups[groupsOrig]; + groups = Join[groupsOrig, {coordGroup}]; includeFiles = Join[includeFiles, {"GenericFD.h", "Symmetry.h", "sbp_calc_coeffs.h"}]; diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m index c6f4cfd..350b619 100644 --- a/Tools/CodeGen/TensorTools.m +++ b/Tools/CodeGen/TensorTools.m @@ -217,10 +217,10 @@ IndexIsLower[TensorIndex[_, "u"]] := False; -------------------------------------------------------------------------- *) Format[TensorIndex[label_, "u"], OutputForm] := - Superscript[null,label]; + "u"<>ToString[label]; Format[TensorIndex[label_, "l"], OutputForm] := - Subscript[null,label]; + "l"<>ToString[label]; Format[TensorIndex[label_, "u"], StandardForm] := Superscript[null,label]; @@ -265,7 +265,7 @@ DefineTensor[T_] := HoldForm[T[is]];*) T[is:((TensorIndex[_,_] | _Integer) ..)] := Tensor[T, is]; - TensorAttributes[T] = {TensorWeight -> 1, Symmetries -> {}}; + TensorAttributes[T] = {TensorWeight -> 0, Symmetries -> {}}; T]; (* -------------------------------------------------------------------------- @@ -1235,10 +1235,11 @@ CheckTensors[x_, y_] := ]; CheckTensors[t:Tensor[k_, is__]] := - Module[{}, + Module[{is2}, (* Print["CheckTensors: Tensor: ", t];*) - If[!(Union[{is}] === Sort[{is}]), - ThrowError["Tensor has repeated indices: ", t, {is}]]; + is2 = Select[{is}, !NumericQ[#]&]; + If[!(Union[is2] === Sort[is2]), + ThrowError["Tensor has repeated indices: ", t, is2]]; True]; CheckTensors[t:f_[TensorIndex[__]..]] := diff --git a/Tools/CodeGen/Thorn.m b/Tools/CodeGen/Thorn.m index 08ba38f..f09a669 100644 --- a/Tools/CodeGen/Thorn.m +++ b/Tools/CodeGen/Thorn.m @@ -521,7 +521,7 @@ CreateSetterSource[calcs_, debug_, useCSE_, include_, imp_, CalculationBoundariesFunction[First[calcs], imp], - Map[CreateCalculationFunction[# , debug, useCSE, opts] &, + Map[CreateCalculationFunction[# , debug, useCSE, imp, opts] &, calcs]}]; |