|
18 | 18 | from FIAT import polynomial_set, jacobi, quadrature_schemes |
19 | 19 |
|
20 | 20 |
|
21 | | -def index_iterator(shp): |
22 | | - """Constructs a generator iterating over all indices in |
23 | | - shp in generalized column-major order So if shp = (2,2), then we |
24 | | - construct the sequence (0,0),(0,1),(1,0),(1,1)""" |
25 | | - return numpy.ndindex(shp) |
26 | | - |
27 | | - |
28 | 21 | class Functional(object): |
29 | 22 | r"""Abstract class representing a linear functional. |
30 | 23 | All FIAT functionals are discrete in the sense that |
@@ -384,7 +377,7 @@ def __init__(self, ref_el, Q, f_at_qpts, nm=None): |
384 | 377 | self.f_at_qpts = f_at_qpts |
385 | 378 | qpts, qwts = Q.get_points(), Q.get_weights() |
386 | 379 | weights = numpy.transpose(numpy.multiply(f_at_qpts, qwts), (-1,) + tuple(range(len(shp)))) |
387 | | - alphas = list(index_iterator(shp)) |
| 380 | + alphas = list(numpy.ndindex(shp)) |
388 | 381 |
|
389 | 382 | pt_dict = {tuple(pt): [(wt[alpha], alpha) for alpha in alphas] for pt, wt in zip(qpts, weights)} |
390 | 383 | Functional.__init__(self, ref_el, shp, pt_dict, {}, nm or "FrobeniusIntegralMoment") |
@@ -494,7 +487,7 @@ def __init__(self, ref_el, Q, f_at_qpts): |
494 | 487 | weights = numpy.multiply(f_at_qpts, Q.get_weights()).T |
495 | 488 |
|
496 | 489 | alphas = tuple(map(tuple, numpy.eye(sd, dtype=int))) |
497 | | - dpt_dict = {tuple(pt): [(wt[i], alphas[j], (i, j)) for i, j in index_iterator(shp)] |
| 490 | + dpt_dict = {tuple(pt): [(wt[i], alphas[j], (i, j)) for i, j in numpy.ndindex(shp)] |
498 | 491 | for pt, wt in zip(points, weights)} |
499 | 492 |
|
500 | 493 | super().__init__(ref_el, tuple(), {}, dpt_dict, "IntegralMomentOfDivergence") |
@@ -655,7 +648,7 @@ def __init__(self, ref_el, v, w, pt): |
655 | 648 | wvT = numpy.outer(w, v) |
656 | 649 | shp = wvT.shape |
657 | 650 |
|
658 | | - pt_dict = {tuple(pt): [(wvT[idx], idx) for idx in index_iterator(shp)]} |
| 651 | + pt_dict = {tuple(pt): [(wvT[idx], idx) for idx in numpy.ndindex(shp)]} |
659 | 652 |
|
660 | 653 | super().__init__(ref_el, shp, pt_dict, {}, "PointwiseInnerProductEval") |
661 | 654 |
|
|
0 commit comments