|
3 | 3 |
|
4 | 4 | from conftest import assert_structure, get_params, get_arrays, check_array |
5 | 5 | from devito import (Buffer, Eq, Function, TimeFunction, Grid, Operator, |
6 | | - cos, sin) |
| 6 | + Coefficient, Substitutions, cos, sin) |
7 | 7 | from devito.finite_differences import Weights |
8 | 8 | from devito.arch.compiler import OneapiCompiler |
9 | 9 | from devito.ir import Expression, FindNodes, FindSymbols |
@@ -76,6 +76,35 @@ def test_multiple_cross_derivs(self, coeffs, expected): |
76 | 76 | weights = {f for f in functions if isinstance(f, Weights)} |
77 | 77 | assert len(weights) == expected |
78 | 78 |
|
| 79 | + @pytest.mark.parametrize('order', [1, 2]) |
| 80 | + @pytest.mark.parametrize('nweight', [None, +4, -4]) |
| 81 | + def test_legacy_api(self, order, nweight): |
| 82 | + grid = Grid(shape=(51, 51, 51)) |
| 83 | + x, y, z = grid.dimensions |
| 84 | + |
| 85 | + nweight = 0 if nweight is None else nweight |
| 86 | + so = 8 |
| 87 | + |
| 88 | + u = TimeFunction(name='u', grid=grid, space_order=so, |
| 89 | + coefficients='symbolic') |
| 90 | + |
| 91 | + w0 = np.arange(so + 1 + nweight) + 1 |
| 92 | + wstr = '{' + ', '.join([f"{w:1.1f}F" for w in w0]) + '}' |
| 93 | + wdef = f'[{so + 1 + nweight}] __attribute__ ((aligned (64)))' |
| 94 | + |
| 95 | + coeffs_x_p1 = Coefficient(order, u, x, w0) |
| 96 | + |
| 97 | + coeffs = Substitutions(coeffs_x_p1) |
| 98 | + |
| 99 | + eqn = Eq(u, u.dx.dy + u.dx2 + .37, coefficients=coeffs) |
| 100 | + |
| 101 | + if nweight > 0: |
| 102 | + with pytest.raises(ValueError): |
| 103 | + op = Operator(eqn, opt=('advanced', {'expand': False})) |
| 104 | + else: |
| 105 | + op = Operator(eqn, opt=('advanced', {'expand': False})) |
| 106 | + assert f'{wdef} = {wstr}' in str(op) |
| 107 | + |
79 | 108 |
|
80 | 109 | class Test1Pass: |
81 | 110 |
|
|
0 commit comments