### Minor improvements to FiniteDifferenceStaggeredStencilDerivation

parent 3d9e0c6d
 ... ... @@ -303,11 +303,12 @@ class FiniteDifferenceStaggeredStencilDerivation: zero_counts[zero_count].append(weights) best = zero_counts[max(zero_counts.keys())] if len(best) > 1: # if there are multiple, pick the one that contains a nonzero center weight center = [tuple(p + pos) for p in points].index((0, 0, 0)) center = [tuple(p + pos) for p in points].index((0, 0, 0)[:dim]) best = [b for b in best if b[center] != 0] if len(best) > 1: raise NotImplementedError("more than one suitable set of weights found, don't know how to proceed") weights = best if len(best) > 1: # if there are still multiple, they are equivalent, so we average weights = sp.Add(*[sp.Matrix(b) for b in best]) / len(best) else: weights = best assert weights points_tuple = tuple([tuple(p + pos) for p in points]) ... ...
 ... ... @@ -332,6 +332,9 @@ "assert FiniteDifferenceStaggeredStencilDerivation(\"T\", 3, (2,)).apply(c3) == c3[0, 0, 1] - c3[0, 0, 0]\n", "assert FiniteDifferenceStaggeredStencilDerivation(\"B\", 3, (2,)).apply(c3) == c3[0, 0, 0] - c3[0, 0, -1]\n", "\n", "assert FiniteDifferenceStaggeredStencilDerivation(\"S\", 2, (0,)).apply(c) == \\\n", " (c[1, 0] + c[1, -1] - c[-1, 0] - c[-1, -1])/4\n", "\n", "assert FiniteDifferenceStaggeredStencilDerivation(\"NE\", 2, (0,)).apply(c) + \\\n", " FiniteDifferenceStaggeredStencilDerivation(\"NE\", 2, (1,)).apply(c) == c[1, 1] - c[0, 0]\n", "assert FiniteDifferenceStaggeredStencilDerivation(\"NE\", 3, (0,)).apply(c3) + \\\n", ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!