Repository navigation
Commit 6573324
committed
api: Add Derivative halo=0 for SubDomain-restricted derivatives and adjoints
`expr.dx(halo=0)` treats `expr` as zero outside the SubDomain of its
equation, and `.T` keeps the flag. Hence `Inc(q_bar, out_bar.dx(halo=0).T,
subdomain=S)` is the adjoint of `Eq(out, q.dx, subdomain=S)`, i.e. D^T R^T with
R the restriction to S, without a user-side zero-padded work field. Equations
without `halo=0` derivatives, or without a SubDomain, are evaluated as before.
- An equation evaluates its rhs with `_eval_at(lhs, subdomain=S)`. A `halo=0`
derivative records S, and multiplies each stencil tap by a branch-free
integer MIN/MAX indicator of the grid point it reads being in S
(SubDomain.indicator), which invariant hoisting computes once. Along the
Dimensions it does not differentiate, it restricts its argument to S at the
evaluation point. In a sum with such derivatives, the other terms are
restricted to S at the evaluation point (SubDomain.restrict); factors are
not.
- The evaluated derivative records its stencil radius (halo_radius), and the
equation iterates over S grown by the largest one (SubDomain.grow, a
SubDomain with a parent). Tensor equations aggregate their components.
- It works for expanded, unexpanded and staggered derivatives. Derivatives of
`halo=0` derivatives, MultiSubDomains and methods other than FD raise
NotImplementedError.
Tests: dot tests of `Eq(out, g.dx, subdomain=S)` against
`Inc(g_bar, out_bar.dx(halo=0).T, subdomain=S)` for left/right/middle
SubDomains, first and second derivatives, orders 2/4/8, Eq and Inc, 2D and
unexpanded forms, in 1D and 3D; staggered dot tests against
`-out_bar.dx(halo=0)`, as in elastic adjoints, including a staggered vector
equation; sums, factors and vector equations; SubDomain growth; a forward
check; and a one-face CPML operator.1 parent c5d3325 commit 6573324
8 files changed
Lines changed: 669 additions & 39 deletions
File tree
- devito
- finite_differences
- types
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
180 | 192 | | |
181 | 193 | | |
182 | 194 | | |
| |||
325 | 337 | | |
326 | 338 | | |
327 | 339 | | |
| 340 | + | |
| 341 | + | |
328 | 342 | | |
329 | 343 | | |
330 | 344 | | |
| |||
457 | 471 | | |
458 | 472 | | |
459 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
460 | 494 | | |
461 | 495 | | |
462 | 496 | | |
| |||
481 | 515 | | |
482 | 516 | | |
483 | 517 | | |
484 | | - | |
| 518 | + | |
485 | 519 | | |
486 | 520 | | |
487 | 521 | | |
488 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
489 | 526 | | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
504 | 533 | | |
505 | 534 | | |
506 | 535 | | |
| |||
519 | 548 | | |
520 | 549 | | |
521 | 550 | | |
522 | | - | |
| 551 | + | |
523 | 552 | | |
524 | 553 | | |
525 | 554 | | |
| |||
534 | 563 | | |
535 | 564 | | |
536 | 565 | | |
537 | | - | |
| 566 | + | |
| 567 | + | |
538 | 568 | | |
539 | 569 | | |
540 | 570 | | |
| |||
549 | 579 | | |
550 | 580 | | |
551 | 581 | | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
552 | 601 | | |
553 | 602 | | |
554 | 603 | | |
| |||
581 | 630 | | |
582 | 631 | | |
583 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
584 | 640 | | |
585 | 641 | | |
586 | 642 | | |
| |||
598 | 654 | | |
599 | 655 | | |
600 | 656 | | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
601 | 666 | | |
602 | 667 | | |
603 | 668 | | |
| |||
607 | 672 | | |
608 | 673 | | |
609 | 674 | | |
610 | | - | |
| 675 | + | |
| 676 | + | |
611 | 677 | | |
612 | 678 | | |
613 | 679 | | |
614 | 680 | | |
615 | 681 | | |
616 | | - | |
| 682 | + | |
| 683 | + | |
617 | 684 | | |
618 | 685 | | |
619 | 686 | | |
620 | 687 | | |
621 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
622 | 695 | | |
623 | 696 | | |
624 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
194 | 212 | | |
195 | 213 | | |
196 | 214 | | |
| |||
540 | 558 | | |
541 | 559 | | |
542 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
543 | 573 | | |
544 | 574 | | |
545 | 575 | | |
| |||
640 | 670 | | |
641 | 671 | | |
642 | 672 | | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
643 | 686 | | |
644 | 687 | | |
645 | 688 | | |
| |||
1276 | 1319 | | |
1277 | 1320 | | |
1278 | 1321 | | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1279 | 1330 | | |
1280 | 1331 | | |
1281 | 1332 | | |
| |||
1291 | 1342 | | |
1292 | 1343 | | |
1293 | 1344 | | |
1294 | | - | |
| 1345 | + | |
1295 | 1346 | | |
1296 | | - | |
| 1347 | + | |
1297 | 1348 | | |
1298 | 1349 | | |
1299 | 1350 | | |
| |||
1309 | 1360 | | |
1310 | 1361 | | |
1311 | 1362 | | |
| 1363 | + | |
| 1364 | + | |
1312 | 1365 | | |
1313 | 1366 | | |
1314 | 1367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
154 | 159 | | |
155 | 160 | | |
156 | 161 | | |
| |||
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
174 | | - | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| |||
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
183 | | - | |
| 188 | + | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
| |||
222 | 227 | | |
223 | 228 | | |
224 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
225 | 236 | | |
226 | 237 | | |
227 | 238 | | |
228 | 239 | | |
229 | 240 | | |
230 | 241 | | |
231 | 242 | | |
| 243 | + | |
| 244 | + | |
232 | 245 | | |
233 | 246 | | |
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
239 | | - | |
| 252 | + | |
| 253 | + | |
240 | 254 | | |
241 | 255 | | |
242 | 256 | | |
243 | 257 | | |
244 | 258 | | |
245 | 259 | | |
| 260 | + | |
| 261 | + | |
246 | 262 | | |
247 | 263 | | |
248 | 264 | | |
249 | 265 | | |
250 | 266 | | |
251 | 267 | | |
252 | 268 | | |
253 | | - | |
| 269 | + | |
254 | 270 | | |
255 | 271 | | |
0 commit comments