• Nem Talált Eredményt

4.4 Time stepping

4.4.3 Local time stepping

Employing a global timestep that is limited by the smallest allowable timestep in the mesh ( tmin) is rather restrictive, since the highly varied cell size in a typical quadtree mesh gives rise to an equally high inhomogeneity in the CFL number. Instead of resorting to an implicit time integration, a time-accurate local time stepping is introduced to the Hancock scheme so as to overcome the restriction of a global timestep limitation, whereby cells are individually integrated

Figure 23. Example of timestep adaptivity with 2-stage LTS.

in time, at a rate near the optimal CFL = 1. We adopt the synchronised local time stepping (LTS) technique proposed by Kleb et al. (1992), which restricts the actual timesteps to be power-of-two multiples of the global minimum timestep.

Starting from the current time level tn, the integer values mi are calculated individually for all cells so that the local timesteps satisfy the synchronisation requirement ti = 2mi tmin, and the local stability condition ti ti;max. Cells are then advanced by their own ti to the next time level using the predictor and corrector steps of the Hancock scheme. For simplicity and without loss of generality, I illustrate the algorithm with a one-dimensional, inviscid example where the local timesteps taken in three consecutive cells are ti 1 = ti = 2 tmin and ti+1 = tmin, i.e., mi 1 =mi = 1 and mi+1 = 0. Application to the full, 2D system follows logically. The space-time plot in Figure 23 shows the three cells with integer indexes, the cell interfaces with half-indexes and the three time levels indexed n to n+ 2.

In the …rst LTS stage, ‡uxes and source terms are evaluated using the known

‡ow states at the current time leveltn, and all cells are advanced by the local ti in the predictor step by (91)

un+i =uni (2 tmin)

2 xi fi+0:5;in fin0:5;i +sni; (94)

un+i+1 =uni+1 tmin

2 xi+1 fi+1:5;i+1n fi+0:5;i+1n +sni+1; (95) followed by the corrector step (92)

un+2i =uni 2 tmin xi

^fi+0:5n+ ^fin+0:5 +sn+i ; (96) un+1i+1 =uni+1 tmin

xi+1

^fi+1:5n+ ^fi+0:5n+ +sn+i+1: (97) Subscripts and superscripts off andsrefer to the edge index and the time level of the ‡ow state for which they are evaluated, e.g.,fi+0:5;in f1(uni+0:5;i)and^fi+0:5n+

4.4. TIME STEPPING 55

^f1(un+i+0:5;i;un+i+0:5;i+1). Contrary to the globally stepped Hancock scheme, with LTS the ‡uxes are not time-centred at interfaces between a cell that is timestepped and its neighbour that is skipped in the current stage. Instead, only the end time levels of the corrector steps are synchronised. In this case, predictor time levels actually represent an intermediate estimate of the ‡uxes during the whole timestep interval and are denoted by a star, e.g., un+i+1 is written for the predictor level between n and n + 1 instead of un+0:5i+1 . Synchronising the predictor time levels would require the temporal interpolation of both ‡uxes and ‡ow states at a cost of additional computation, bookkeeping and storage. Such an algorithmic e¤ort may be justi…ed for the simulation of highly transient ‡ows.

Now cell i+ 1 is behind the other two cells, so it is advanced in the second LTS stage from the leveltn+1 to tn+2. The Hancock predictor step is

un+1+i+1 = un+1i+1 tmin

xi+1 fi+1:5;i+1n+1 fi+0:5;i+1n+1 +sn+1i+1; (98) un+2i+1 = un+1i+1 tmin

xi+1

^fi+1:5n+1+ ^fi+0:5n+1+ +sn+1+i+1 : (99) The evaluation of the gradient run+1i+1 and ‡ux ^fi+0:5n+1+ involves the ‡ow states un+1,un+1+ in neighbouring celli. These missing values are interpolated linearly between the known time levels as

un+1i = uni +un+2i

2 ; un+1+i =un+1i : (100) Actually, to spare memory the old value uni is overwritten with the interpolated valueun+1i . Furthermore, the interpolation can be skipped altogether in celli 1, because no ‡ux to that cell must be evaluated at the intermediate time tn+1.

The total exchange of u across the interfacei+ 0:5 is ui = tmin

xi 2^fi+0:5n+ (101)

from cell i+ 1 into cell i and

ui+1 = tmin xi

^fi+0:5n+ +^fi+0:5n+1+ (102)

in the reverse direction. In general ui + ui+1 6= 0, so we …nd that the LTS method by Kleb et al. (1992) happens to be non-conservative. The imbalance is caused not by the second-order Hancock scheme but by the unilateral application of the intermediate ‡ux^fi+0:5n+1+ .

To make the method conservative at cell interfaces with a jump in m, the slower cell is adjusted at the end of the …rst LTS stage as

un+2i (un+2i + tmin

xi ^fi+0:5n+1+ ^fi+0:5n+ : (103)

A similar treatment is employed in the moving mesh method of Tan et al. (2004).

To increase the robustness and accuracy at intermediate stages, m is not per-mitted to di¤er by more than one between two neighbours, which is achieved by regularising the distribution of m similarly to the regularisation of the quadtree level, see §3.4.

The bene…t of local time stepping is that only four time integrations and one interpolation are required in the previous example instead of the six integrations when global time stepping is used. The actual acceleration is of course a function of the CFL inhomogeneity and the computational overhead of determining and smoothing the distribution of mi. Nevertheless, it can be said that a speedup factor up to 1.5 can typically be reached, which is a signi…cant, although not fundamental improvement over the global time stepping approach. Moreover, my experience also con…rms that solution accuracy is not impaired, as reported by Crossley et al. (2003), who applied this LTS scheme to the de Saint-Venant equations.

The general algorithm of local time stepping is given next.

Step 1 Before starting the LTS sequence, determine the overall minimum timestep for each cell using (93)

tmin = min( tmax;i): (104) Step 2 Calculate the LTS level of cell i as

mi = log2 tmax;i

tmin ; (105)

where the brackets b c denote the ‡oor function. Once mi are available for all cells, the distribution ofm is smoothed iteratively so thatjmi mjj 1 for all pairs of neighbours i and j.

Step 3 The LTS level of a cell for which interpolation is necessary is

mip;i= min(mj); j 2 fi;neighbours ofig: (106) Step 4 At the start of the sequence, denote the solution time level by n0 and the solution time by tn0. Imposing the maximum LTS level mmax, advance consecutive stages in the LTS sequence with a loop counterk = 0: : :2mmax 1. Consequently, each sequence is composed of2mmax stages.

The procedure for thekth LTS stage is as follows.

4.4. TIME STEPPING 57 Step 5 Three levels of the solution denoted by n1, n2 and n3 are kept simultan-eously in memory. The actual time level corresponding to these varies from cell to cell according tomi:

n1 =n0+ 2mik; n2 =n1+ ; n3 =n1+ 1: (107) Step 6 Copy the solution uni1 (uni3 for cells with mi < m(k)H , where m(k)H is the

smallest positive integer that satis…es

k mod 2m(k)H 6= 0: (108) Step 7 Interpolate the solution in cells which need not be advanced by the Han-cock method, that is, cells for whichmip;i< m(k)H and mi m(k)H . Given the previous LTS stage k(k)prev at which the value was interpolated and the next stage knext(k) at which the solution has already been computed:

k(k)prev(m) = 2m k+ 1

2m ; (109)

knext(k) (m) = 2m k+ 1

2m ; (110)

determine interpolation weights for cell i using

!(k)i = k(k)next(mi) k

k(k)next(mi) k(k)prev(mip;i): (111) The bracketsd ein (110) denote the ceiling function. Overwrite the previous

‡ow state value with the value interpolated to the current LTS stage:

uni1 (!(k)i uni1 h

1 !(k)i i

uni3; (112)

uni2 (uni1: (113)

Step 8 Store ‡ux vectors ^fen2;^gen2 calculated in the previous corrector step into

^feprev;^gpreve for each edgee that belongs to a cell withmi < m(k)H . The stored values will be used to balance the ‡uxes in Step 10.

Step 9 Advance cells withmi < m(k)H by their own timestep tiusing the Hancock scheme. Do this using (91) and (92) with n1, n2 and n3 taking the place of superscriptsn,n+ 0:5 and n+ 1, respectively. Note that the corrector step will overwrite ‡ux vectors^fen2;g^en2 on the edges of the stepped cells.

Step 10 To …nish thekth stage, compensate for unbalanced ‡uxes at the interface of stepped and interpolated cells. Compensation is required between cells i

and j if mi < m(k)H and mj m(k)H , that is, if cell i was stepped and cell j was interpolated. Depending on the direction of edge e separating the two cells, update the interpolated cell with

unj3 (unj3 + tminne;x ye Aj

h

k(k)next(mj) ki

^fen2 ^feprev (114) for vertical edges and with

unj3 (unj3 + tminne;y xe Aj

h

k(k)next(mj) ki

(^gne2 g^preve ) (115) for horizontal edges, where the ‡ux vectors ^feprev;^gpreve have been saved in Step 8.

Increment k and continue the LTS sequence with the next stage in Step 5.