wiki:ComputationalStencils

Version 2 (modified by trac, 12 years ago) ( diff )

Stencils

During the update of a given cell, various intermediate quantities need to be calculated such as gradients, eigenvectors, interface states, fluxes, emfs etc… In order for the sweep method to work, information about how each stencil piece relies on other stencil pieces needs to be explicitly stated. These relationships essentially contain a handle to the dependent stencil piece, a handle to the dependee stencil piece, and a range that is a 3x2 integer array that expresses the spatial dependence. For example, a cell update (q3) requires x-fluxes (f2x) at the left cell edge and the right cell edge. Since left and right face indices for cell i are i and i+1 this dependency would be stored as

  • q3 → f2x
0 1
0 0

Then let's assume for the moment that we have an array that represents where we need to update q3

9
8 TT
7 TTT
6 TTTT TT
5 TTT TT
4 TT TTT
3 TT TTT
2 TT TTT
1 TT TTT
1 2 3 4 5 6 7 8 9

We then need to mark an array that represents where we need to calculate f2x

9
8 TTT
7 TTTT
6 TTTTT TTT
5 TTTT TTT
4 TTT TTTT
3 TTT TTTT
2 TTT TTTT
1 TTT TTTT
1 2 3 4 5 6 7 8 9

If we store the q3 array as a list of boxes

  • [(1,1)-(2,8)]
  • [(3,5)-(3,7)]
  • [(4,6)-(4,6)]
  • [(6,1)-(8,4)]
  • [(7,5)-(8,6)]

Then the f2x array is just the union of the above boxlist but adding [(0,0)-(1,0)] to each

  • [(1,1)-(3,8)]
  • [(3,5)-(4,7)]
  • [(4,6)-(5,6)]
  • [(6,1)-(9,4)]
  • [(7,5)-(9,6)]

Of course now the points [(4,5)-(5,7)] and [(5,6)-(5,6)] are covered by more then one box so we would like to subtract these repeated indices - Or when we are stretching each box, we need to check that we don't add points repeatedly.

  • [(1,1)-(3,8)]
  • [(5,5)-(5,7)]
  • [(5,6)-(5,6)]
  • [(6,1)-(9,4)]
  • [(7,5)-(9,6)]

If we don't remove the repeated boxes, then when we query for regions that need updating - we will end up duplicating our efforts (our worse)…

Often we will need to work backwards from the final updates q3 that we need, to the fluxes, to the interface states, to the derivatives, and finally to the initial fluid state q by doing something similar to above 'StretchArrayAdd' or what is equivalently a series of OR operations.

Sometimes we will need to work fowards from the initial fluid states that we have available q to what derivatives we can calculate, to what interface states we can calculate, to what fluxes we can calculate, to what final updates q3 we can perform. This involves looking at the dependencies the other way and involves a series of AND operations.

Note: See TracWiki for help on using the wiki.