|
8 | 8 | from devito.types import Eq, Function, TimeFunction
|
9 | 9 |
|
10 | 10 |
|
11 |
| -def superstep_generator_iterative(field, stencil, k, nt=0): |
12 |
| - """ |
13 |
| - Generate superstep iteratively: |
14 |
| - Aʲ⁺¹ = A·Aʲ |
15 |
| - """ |
16 |
| - # New fields, for vector formulation both current and previous timestep are needed |
17 |
| - name = field.name |
18 |
| - grid = field.grid |
19 |
| - u = TimeFunction(name=f'{name}_ss', grid=grid, time_order=2, space_order=2*k) |
20 |
| - u_prev = TimeFunction(name=f'{name}_ss_p', grid=grid, time_order=2, space_order=2*k) |
21 |
| - |
22 |
| - superstep_solution_transfer(field, u, u_prev, nt) |
23 |
| - |
24 |
| - # Substitute new fields into stencil |
25 |
| - ss_stencil = stencil.subs({field: u, field.backward: u_prev}, postprocess=False) |
26 |
| - ss_stencil = ss_stencil.expand().expand(add=True, nest=True) |
27 |
| - current = ss_stencil |
28 |
| - |
29 |
| - # Placeholder fields for forming the superstep |
30 |
| - a_tmp = Function(name="a_tmp", grid=grid, space_order=2*k) |
31 |
| - b_tmp = Function(name="b_tmp", grid=grid, space_order=2*k) |
32 |
| - |
33 |
| - if k >= 2: |
34 |
| - for _ in range(k - 2): |
35 |
| - current = current.subs( |
36 |
| - {u: a_tmp, u_prev: b_tmp}, postprocess=False).subs( |
37 |
| - {a_tmp: ss_stencil, b_tmp: u}, postprocess=False |
38 |
| - ) |
39 |
| - current = current.expand().expand(add=True, nest=True) |
40 |
| - else: |
41 |
| - current = u |
42 |
| - |
43 |
| - stencil_next = current.subs( |
44 |
| - {u: a_tmp, u_prev: b_tmp}, postprocess=False).subs( |
45 |
| - {a_tmp: ss_stencil, b_tmp: u}, postprocess=False |
46 |
| - ) |
47 |
| - stencil_next = stencil_next.expand().expand(add=True, nest=True) |
48 |
| - return u, u_prev, Eq(u.forward, stencil_next), Eq(u_prev.forward, current) |
49 |
| - |
50 |
| - |
51 | 11 | def superstep_generator(field, stencil, k, nt=0):
|
52 | 12 | """
|
53 | 13 | Generate superstep using a binary decomposition:
|
|
0 commit comments