1 #ifndef COSMO_UTILS_MATH_H 2 #define COSMO_UTILS_MATH_H 4 #include "../cosmo_macros.h" 5 #include "../cosmo_types.h" 6 #include "../cosmo_includes.h" 7 #include "../cosmo_globals.h" 36 inline real_t KO_dissipation_Q(idx_t i, idx_t j, idx_t k, arr_t & field, real_t ko_coeff)
41 # if STENCIL_ORDER == 2 43 1.0*field[INDEX(i-2,j,k)] + 1.0*field[INDEX(i,j-2,k)] + 1.0*field[INDEX(i,j,k-2)]
44 - 4.0*field[INDEX(i-1,j,k)] - 4.0*field[INDEX(i,j-1,k)] - 4.0*field[INDEX(i,j,k-1)]
45 + 6.0*field[INDEX(i ,j,k)] + 6.0*field[INDEX(i,j ,k)] + 6.0*field[INDEX(i,j,k )]
46 - 4.0*field[INDEX(i+1,j,k)] - 4.0*field[INDEX(i,j+1,k)] - 4.0*field[INDEX(i,j,k+1)]
47 + 1.0*field[INDEX(i+2,j,k)] + 1.0*field[INDEX(i,j+2,k)] + 1.0*field[INDEX(i,j,k+2)]
49 real_t dissipation = ko_coeff*pow(dx, 3.0)/64.0*stencil;
53 # if STENCIL_ORDER == 8 55 1.0*field[INDEX(i-5,j,k)] + 1.0*field[INDEX(i,j-5,k)] + 1.0*field[INDEX(i,j,k-5)]
56 - 10.0*field[INDEX(i-4,j,k)] - 10.0*field[INDEX(i,j-4,k)] - 10.0*field[INDEX(i,j,k-4)]
57 + 45.0*field[INDEX(i-3,j,k)] + 45.0*field[INDEX(i,j-3,k)] + 45.0*field[INDEX(i,j,k-3)]
58 - 120.0*field[INDEX(i-2,j,k)] - 120.0*field[INDEX(i,j-2,k)] - 120.0*field[INDEX(i,j,k-2)]
59 + 210.0*field[INDEX(i-1,j,k)] + 210.0*field[INDEX(i,j-1,k)] + 210.0*field[INDEX(i,j,k-1)]
60 - 252.0*field[INDEX(i ,j,k)] - 252.0*field[INDEX(i,j ,k)] - 252.0*field[INDEX(i,j,k )]
61 + 210.0*field[INDEX(i+1,j,k)] + 210.0*field[INDEX(i,j+1,k)] + 210.0*field[INDEX(i,j,k+1)]
62 - 120.0*field[INDEX(i+2,j,k)] - 120.0*field[INDEX(i,j+2,k)] - 120.0*field[INDEX(i,j,k+2)]
63 + 45.0*field[INDEX(i+3,j,k)] + 45.0*field[INDEX(i,j+3,k)] + 45.0*field[INDEX(i,j,k+3)]
64 - 10.0*field[INDEX(i+4,j,k)] - 10.0*field[INDEX(i,j+4,k)] - 10.0*field[INDEX(i,j,k+4)]
65 + 1.0*field[INDEX(i+5,j,k)] + 1.0*field[INDEX(i,j+5,k)] + 1.0*field[INDEX(i,j,k+5)]
67 real_t dissipation = -ko_coeff*pow(dx, 9.0)/1024.0*stencil;
74 inline real_t derivative_Odx2(idx_t i, idx_t j, idx_t k,
int d,
80 - 1.0/2.0*field[INDEX(i-1,j,k)]
81 + 1.0/2.0*field[INDEX(i+1,j,k)]
86 - 1.0/2.0*field[INDEX(i,j-1,k)]
87 + 1.0/2.0*field[INDEX(i,j+1,k)]
92 - 1.0/2.0*field[INDEX(i,j,k-1)]
93 + 1.0/2.0*field[INDEX(i,j,k+1)]
102 inline real_t forward_derivative_Odx2(idx_t i, idx_t j, idx_t k,
int d,
108 - 1.0/2.0*field[INDEX(i+2,j,k)]
109 + 2.0*field[INDEX(i+1,j,k)]
110 - 3.0/2.0*field[INDEX(i,j,k)]
115 - 1.0/2.0*field[INDEX(i,j+2,k)]
116 + 2.0*field[INDEX(i,j+1,k)]
117 - 3.0/2.0*field[INDEX(i,j,k)]
122 - 1.0/2.0*field[INDEX(i,j,k+2)]
123 + 2.0*field[INDEX(i,j,k+1)]
124 - 3.0/2.0*field[INDEX(i,j,k)]
135 inline real_t backward_derivative_Odx2(idx_t i, idx_t j, idx_t k,
int d,
141 + 1.0/2.0*field[INDEX(i-2,j,k)]
142 - 2.0*field[INDEX(i-1,j,k)]
143 + 3.0/2.0*field[INDEX(i,j,k)]
148 + 1.0/2.0*field[INDEX(i,j-2,k)]
149 - 2.0*field[INDEX(i,j-1,k)]
150 + 3.0/2.0*field[INDEX(i,j,k)]
155 + 1.0/2.0*field[INDEX(i,j,k-2)]
156 - 2.0*field[INDEX(i,j,k-1)]
157 + 3.0/2.0*field[INDEX(i,j,k)]
166 inline real_t lop_forward_derivative_Odx2(idx_t i, idx_t j, idx_t k,
int d,
172 - 1.0/2.0*field[INDEX(i+2,j,k)]
173 + 2.0*field[INDEX(i+1,j,k)]
174 - 3.0/2.0*field[INDEX(i,j,k)]
179 - 1.0/2.0*field[INDEX(i,j+2,k)]
180 + 2.0*field[INDEX(i,j+1,k)]
181 - 3.0/2.0*field[INDEX(i,j,k)]
186 - 1.0/2.0*field[INDEX(i,j,k+2)]
187 + 2.0*field[INDEX(i,j,k+1)]
188 - 3.0/2.0*field[INDEX(i,j,k)]
199 inline real_t lop_backward_derivative_Odx2(idx_t i, idx_t j, idx_t k,
int d,
205 + 1.0/2.0*field[INDEX(i-2,j,k)]
206 - 2.0*field[INDEX(i-1,j,k)]
207 + 3.0/2.0*field[INDEX(i,j,k)]
212 + 1.0/2.0*field[INDEX(i,j-2,k)]
213 - 2.0*field[INDEX(i,j-1,k)]
214 + 3.0/2.0*field[INDEX(i,j,k)]
219 + 1.0/2.0*field[INDEX(i,j,k-2)]
220 - 2.0*field[INDEX(i,j,k-1)]
221 + 3.0/2.0*field[INDEX(i,j,k)]
231 inline real_t derivative_Odx4(idx_t i, idx_t j, idx_t k,
int d,
237 + 1.0/12.0*field[INDEX(i-2,j,k)]
238 - 2.0/3.0*field[INDEX(i-1,j,k)]
239 + 2.0/3.0*field[INDEX(i+1,j,k)]
240 - 1.0/12.0*field[INDEX(i+2,j,k)]
245 + 1.0/12.0*field[INDEX(i,j-2,k)]
246 - 2.0/3.0*field[INDEX(i,j-1,k)]
247 + 2.0/3.0*field[INDEX(i,j+1,k)]
248 - 1.0/12.0*field[INDEX(i,j+2,k)]
253 + 1.0/12.0*field[INDEX(i,j,k-2)]
254 - 2.0/3.0*field[INDEX(i,j,k-1)]
255 + 2.0/3.0*field[INDEX(i,j,k+1)]
256 - 1.0/12.0*field[INDEX(i,j,k+2)]
265 inline real_t lop_forward_derivative_Odx4(idx_t i, idx_t j, idx_t k,
int d,
271 + 1.0/12.0*field[INDEX(i+3,j,k)]
272 - 1.0/2.0*field[INDEX(i+2,j,k)]
273 + 3.0/2.0*field[INDEX(i+1,j,k)]
274 - 5.0/6.0*field[INDEX(i,j,k)]
275 - 1.0/4.0*field[INDEX(i-1,j,k)]
280 + 1.0/12.0*field[INDEX(i,j+3,k)]
281 - 1.0/2.0*field[INDEX(i,j+2,k)]
282 + 3.0/2.0*field[INDEX(i,j+1,k)]
283 - 5.0/6.0*field[INDEX(i,j,k)]
284 - 1.0/4.0*field[INDEX(i,j-1,k)]
289 + 1.0/12.0*field[INDEX(i,j,k+3)]
290 - 1.0/2.0*field[INDEX(i,j,k+2)]
291 + 3.0/2.0*field[INDEX(i,j,k+1)]
292 - 5.0/6.0*field[INDEX(i,j,k)]
293 - 1.0/4.0*field[INDEX(i,j,k-1)]
302 inline real_t lop_backward_derivative_Odx4(idx_t i, idx_t j, idx_t k,
int d,
308 - 1.0/12.0*field[INDEX(i-3,j,k)]
309 + 1.0/2.0*field[INDEX(i-2,j,k)]
310 - 3.0/2.0*field[INDEX(i-1,j,k)]
311 + 5.0/6.0*field[INDEX(i,j,k)]
312 + 1.0/4.0*field[INDEX(i+1,j,k)]
317 - 1.0/12.0*field[INDEX(i,j-3,k)]
318 + 1.0/2.0*field[INDEX(i,j-2,k)]
319 - 3.0/2.0*field[INDEX(i,j-1,k)]
320 + 5.0/6.0*field[INDEX(i,j,k)]
321 + 1.0/4.0*field[INDEX(i,j+1,k)]
326 - 1.0/12.0*field[INDEX(i,j,k-3)]
327 + 1.0/2.0*field[INDEX(i,j,k-2)]
328 - 3.0/2.0*field[INDEX(i,j,k-1)]
329 + 5.0/6.0*field[INDEX(i,j,k)]
330 + 1.0/4.0*field[INDEX(i,j,k+1)]
339 inline real_t forward_derivative_Odx4(idx_t i, idx_t j, idx_t k,
int d,
345 - 1.0/4.0*field[INDEX(i+4,j,k)]
346 + 4.0/3.0*field[INDEX(i+3,j,k)]
347 - 3.0*field[INDEX(i+2,j,k)]
348 + 4.0*field[INDEX(i+1,j,k)]
349 - 25.0/12.0*field[INDEX(i,j,k)]
354 - 1.0/4.0*field[INDEX(i,j+4,k)]
355 + 4.0/3.0*field[INDEX(i,j+3,k)]
356 - 3.0*field[INDEX(i,j+2,k)]
357 + 4.0*field[INDEX(i,j+1,k)]
358 - 25.0/12.0*field[INDEX(i,j,k)]
363 - 1.0/4.0*field[INDEX(i,j,k+4)]
364 + 4.0/3.0*field[INDEX(i,j,k+3)]
365 - 3.0*field[INDEX(i,j,k+2)]
366 + 4.0*field[INDEX(i,j,k+1)]
367 - 25.0/12.0*field[INDEX(i,j,k)]
376 inline real_t backward_derivative_Odx4(idx_t i, idx_t j, idx_t k,
int d,
382 + 1.0/4.0*field[INDEX(i-4,j,k)]
383 - 4.0/3.0*field[INDEX(i-3,j,k)]
384 + 3.0*field[INDEX(i-2,j,k)]
385 - 4.0*field[INDEX(i-1,j,k)]
386 + 25.0/12.0*field[INDEX(i,j,k)]
391 + 1.0/4.0*field[INDEX(i,j-4,k)]
392 - 4.0/3.0*field[INDEX(i,j-3,k)]
393 + 3.0*field[INDEX(i,j-2,k)]
394 - 4.0*field[INDEX(i,j-1,k)]
395 + 25.0/12.0*field[INDEX(i,j,k)]
400 + 1.0/4.0*field[INDEX(i,j,k-4)]
401 - 4.0/3.0*field[INDEX(i,j,k-3)]
402 + 3.0*field[INDEX(i,j,k-2)]
403 - 4.0*field[INDEX(i,j,k-1)]
404 + 25.0/12.0*field[INDEX(i,j,k)]
412 inline real_t derivative_Odx6(idx_t i, idx_t j, idx_t k,
int d,
418 - 1.0/60.0*field[INDEX(i-3,j,k)]
419 + 3.0/20.0*field[INDEX(i-2,j,k)]
420 - 3.0/4.0*field[INDEX(i-1,j,k)]
421 + 3.0/4.0*field[INDEX(i+1,j,k)]
422 - 3.0/20.0*field[INDEX(i+2,j,k)]
423 + 1.0/60.0*field[INDEX(i+3,j,k)]
428 - 1.0/60.0*field[INDEX(i,j-3,k)]
429 + 3.0/20.0*field[INDEX(i,j-2,k)]
430 - 3.0/4.0*field[INDEX(i,j-1,k)]
431 + 3.0/4.0*field[INDEX(i,j+1,k)]
432 - 3.0/20.0*field[INDEX(i,j+2,k)]
433 + 1.0/60.0*field[INDEX(i,j+3,k)]
438 - 1.0/60.0*field[INDEX(i,j,k-3)]
439 + 3.0/20.0*field[INDEX(i,j,k-2)]
440 - 3.0/4.0*field[INDEX(i,j,k-1)]
441 + 3.0/4.0*field[INDEX(i,j,k+1)]
442 - 3.0/20.0*field[INDEX(i,j,k+2)]
443 + 1.0/60.0*field[INDEX(i,j,k+3)]
453 inline real_t forward_derivative_Odx6(idx_t i, idx_t j, idx_t k,
int d,
459 - 49.0/20.0*field[INDEX(i,j,k)]
460 + 6.0*field[INDEX(i+1,j,k)]
461 - 15.0/2.0*field[INDEX(i+2,j,k)]
462 + 20.0/3.0*field[INDEX(i+3,j,k)]
463 - 15.0/4.0*field[INDEX(i+4,j,k)]
464 + 6.0/5.0*field[INDEX(i+5,j,k)]
465 - 1.0/6.0*field[INDEX(i+6,j,k)]
470 - 49.0/20.0*field[INDEX(i,j,k)]
471 + 6.0*field[INDEX(i,j+1,k)]
472 - 15.0/2.0*field[INDEX(i,j+2,k)]
473 + 20.0/3.0*field[INDEX(i,j+3,k)]
474 - 15.0/4.0*field[INDEX(i,j+4,k)]
475 + 6.0/5.0*field[INDEX(i,j+5,k)]
476 - 1.0/6.0*field[INDEX(i,j+6,k)]
481 - 49.0/20.0*field[INDEX(i,j,k)]
482 + 6.0*field[INDEX(i,j,k+1)]
483 - 15.0/2.0*field[INDEX(i,j,k+2)]
484 + 20.0/3.0*field[INDEX(i,j,k+3)]
485 - 15.0/4.0*field[INDEX(i,j,k+4)]
486 + 6.0/5.0*field[INDEX(i,j,k+5)]
487 - 1.0/6.0*field[INDEX(i,j,k+6)]
496 inline real_t backward_derivative_Odx6(idx_t i, idx_t j, idx_t k,
int d,
502 + 49.0/20.0*field[INDEX(i,j,k)]
503 - 6.0*field[INDEX(i-1,j,k)]
504 + 15.0/2.0*field[INDEX(i-2,j,k)]
505 - 20.0/3.0*field[INDEX(i-3,j,k)]
506 + 15.0/4.0*field[INDEX(i-4,j,k)]
507 - 6.0/5.0*field[INDEX(i-5,j,k)]
508 + 1.0/6.0*field[INDEX(i-6,j,k)]
513 + 49.0/20.0*field[INDEX(i,j,k)]
514 - 6.0*field[INDEX(i,j-1,k)]
515 + 15.0/2.0*field[INDEX(i,j-2,k)]
516 - 20.0/3.0*field[INDEX(i,j-3,k)]
517 + 15.0/4.0*field[INDEX(i,j-4,k)]
518 - 6.0/5.0*field[INDEX(i,j-5,k)]
519 + 1.0/6.0*field[INDEX(i,j-6,k)]
524 + 49.0/20.0*field[INDEX(i,j,k)]
525 - 6.0*field[INDEX(i,j,k-1)]
526 + 15.0/2.0*field[INDEX(i,j,k-2)]
527 - 20.0/3.0*field[INDEX(i,j,k-3)]
528 + 15.0/4.0*field[INDEX(i,j,k-4)]
529 - 6.0/5.0*field[INDEX(i,j,k-5)]
530 + 1.0/6.0*field[INDEX(i,j,k-6)]
539 inline real_t lop_forward_derivative_Odx6(idx_t i, idx_t j, idx_t k,
int d,
545 inline real_t lop_backward_derivative_Odx6(idx_t i, idx_t j, idx_t k,
int d,
554 inline real_t derivative_Odx8(idx_t i, idx_t j, idx_t k,
int d,
560 ( 1.0/280.0*field[INDEX(i-4,j,k)] - 1.0/280.0*field[INDEX(i+4,j,k)] )
561 - ( 4.0/105.0*field[INDEX(i-3,j,k)] - 4.0/105.0*field[INDEX(i+3,j,k)] )
562 + ( 1.0/5.0*field[INDEX(i-2,j,k)] - 1.0/5.0*field[INDEX(i+2,j,k)] )
563 - ( 4.0/5.0*field[INDEX(i-1,j,k)] - 4.0/5.0*field[INDEX(i+1,j,k)] )
568 ( 1.0/280.0*field[INDEX(i,j-4,k)] - 1.0/280.0*field[INDEX(i,j+4,k)] )
569 - ( 4.0/105.0*field[INDEX(i,j-3,k)] - 4.0/105.0*field[INDEX(i,j+3,k)] )
570 + ( 1.0/5.0*field[INDEX(i,j-2,k)] - 1.0/5.0*field[INDEX(i,j+2,k)] )
571 - ( 4.0/5.0*field[INDEX(i,j-1,k)] - 4.0/5.0*field[INDEX(i,j+1,k)] )
576 ( 1.0/280.0*field[INDEX(i,j,k-4)] - 1.0/280.0*field[INDEX(i,j,k+4)] )
577 - ( 4.0/105.0*field[INDEX(i,j,k-3)] - 4.0/105.0*field[INDEX(i,j,k+3)] )
578 + ( 1.0/5.0*field[INDEX(i,j,k-2)] - 1.0/5.0*field[INDEX(i,j,k+2)] )
579 - ( 4.0/5.0*field[INDEX(i,j,k-1)] - 4.0/5.0*field[INDEX(i,j,k+1)] )
588 inline real_t forward_derivative_Odx8(idx_t i, idx_t j, idx_t k,
int d,
594 - 761.0/280.0*field[INDEX(i,j,k)] + 8.0*field[INDEX(i+1,j,k)]
595 - 14.0*field[INDEX(i+2,j,k)] + 56.0/3.0*field[INDEX(i+3,j,k)]
596 - 35.0/2.0*field[INDEX(i+4,j,k)] + 56.0/5.0*field[INDEX(i+5,j,k)]
597 - 14.0/3.0*field[INDEX(i+6,j,k)] + 8.0/7.0*field[INDEX(i+7,j,k)]
598 - 1.0/8.0*field[INDEX(i+8,j,k)]
603 - 761.0/280.0*field[INDEX(i,j,k)] + 8.0*field[INDEX(i,j+1,k)]
604 - 14.0*field[INDEX(i,j+2,k)] + 56.0/3.0*field[INDEX(i,j+3,k)]
605 - 35.0/2.0*field[INDEX(i,j+4,k)] + 56.0/5.0*field[INDEX(i,j+5,k)]
606 - 14.0/3.0*field[INDEX(i,j+6,k)] + 8.0/7.0*field[INDEX(i,j+7,k)]
607 - 1.0/8.0*field[INDEX(i,j+8,k)]
612 - 761.0/280.0*field[INDEX(i,j,k)] + 8.0*field[INDEX(i,j,k+1)]
613 - 14.0*field[INDEX(i,j,k+2)] + 56.0/3.0*field[INDEX(i,j,k+3)]
614 - 35.0/2.0*field[INDEX(i,j,k+4)] + 56.0/5.0*field[INDEX(i,j,k+5)]
615 - 14.0/3.0*field[INDEX(i,j,k+6)] + 8.0/7.0*field[INDEX(i,j,k+7)]
616 - 1.0/8.0*field[INDEX(i,j,k+8)]
625 inline real_t backward_derivative_Odx8(idx_t i, idx_t j, idx_t k,
int d,
631 + 761.0/280.0*field[INDEX(i,j,k)] - 8.0*field[INDEX(i-1,j,k)]
632 + 14.0*field[INDEX(i-2,j,k)] - 56.0/3.0*field[INDEX(i-3,j,k)]
633 + 35.0/2.0*field[INDEX(i-4,j,k)] - 56.0/5.0*field[INDEX(i-5,j,k)]
634 + 14.0/3.0*field[INDEX(i-6,j,k)] - 8.0/7.0*field[INDEX(i-7,j,k)]
635 + 1.0/8.0*field[INDEX(i-8,j,k)]
640 + 761.0/280.0*field[INDEX(i,j,k)] - 8.0*field[INDEX(i,j-1,k)]
641 + 14.0*field[INDEX(i,j-2,k)] - 56.0/3.0*field[INDEX(i,j-3,k)]
642 + 35.0/2.0*field[INDEX(i,j-4,k)] - 56.0/5.0*field[INDEX(i,j-5,k)]
643 + 14.0/3.0*field[INDEX(i,j-6,k)] - 8.0/7.0*field[INDEX(i,j-7,k)]
644 + 1.0/8.0*field[INDEX(i,j-8,k)]
649 + 761.0/280.0*field[INDEX(i,j,k)] - 8.0*field[INDEX(i,j,k-1)]
650 + 14.0*field[INDEX(i,j,k-2)] - 56.0/3.0*field[INDEX(i,j,k-3)]
651 + 35.0/2.0*field[INDEX(i,j,k-4)] - 56.0/5.0*field[INDEX(i,j,k-5)]
652 + 14.0/3.0*field[INDEX(i,j,k-6)] - 8.0/7.0*field[INDEX(i,j,k-7)]
653 + 1.0/8.0*field[INDEX(i,j,k-8)]
661 inline real_t lop_forward_derivative_Odx8(idx_t i, idx_t j, idx_t k,
int d,
668 inline real_t lop_backward_derivative_Odx8(idx_t i, idx_t j, idx_t k,
int d,
676 inline real_t mixed_derivative_stencil_Odx2(idx_t i, idx_t j, idx_t k,
int d1,
int d2, arr_t & field)
678 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
680 - field[INDEX(i+1,j-1,k)] + field[INDEX(i+1,j+1,k)]
681 + field[INDEX(i-1,j-1,k)] - field[INDEX(i-1,j+1,k)]
685 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
687 - field[INDEX(i+1,j,k-1)] + field[INDEX(i+1,j,k+1)]
688 + field[INDEX(i-1,j,k-1)] - field[INDEX(i-1,j,k+1)]
692 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
694 - field[INDEX(i,j+1,k-1)] + field[INDEX(i,j+1,k+1)]
695 + field[INDEX(i,j-1,k-1)] - field[INDEX(i,j-1,k+1)]
703 inline real_t mixed_derivative_stencil_Odx4(idx_t i, idx_t j, idx_t k,
int d1,
int d2, arr_t & field)
705 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
708 - field[INDEX(i+1,j-1,k)] + field[INDEX(i+1,j+1,k)]
709 + field[INDEX(i-1,j-1,k)] - field[INDEX(i-1,j+1,k)]
711 - field[INDEX(i+2,j-2,k)] + field[INDEX(i+2,j+2,k)]
712 + field[INDEX(i-2,j-2,k)] - field[INDEX(i-2,j+2,k)]
717 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
720 - field[INDEX(i+1,j,k-1)] + field[INDEX(i+1,j,k+1)]
721 + field[INDEX(i-1,j,k-1)] - field[INDEX(i-1,j,k+1)]
723 - field[INDEX(i+2,j,k-2)] + field[INDEX(i+2,j,k+2)]
724 + field[INDEX(i-2,j,k-2)] - field[INDEX(i-2,j,k+2)]
729 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
732 - field[INDEX(i,j+1,k-1)] + field[INDEX(i,j+1,k+1)]
733 + field[INDEX(i,j-1,k-1)] - field[INDEX(i,j-1,k+1)]
735 - field[INDEX(i,j+2,k-2)] + field[INDEX(i,j+2,k+2)]
736 + field[INDEX(i,j-2,k-2)] - field[INDEX(i,j-2,k+2)]
745 inline real_t mixed_derivative_stencil_Odx6(idx_t i, idx_t j, idx_t k,
int d1,
int d2, arr_t & field)
747 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
750 - field[INDEX(i+1,j-1,k)] + field[INDEX(i+1,j+1,k)]
751 + field[INDEX(i-1,j-1,k)] - field[INDEX(i-1,j+1,k)]
753 - field[INDEX(i+2,j-2,k)] + field[INDEX(i+2,j+2,k)]
754 + field[INDEX(i-2,j-2,k)] - field[INDEX(i-2,j+2,k)]
756 - field[INDEX(i+3,j-3,k)] + field[INDEX(i+3,j+3,k)]
757 + field[INDEX(i-3,j-3,k)] - field[INDEX(i-3,j+3,k)]
762 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
765 - field[INDEX(i+1,j,k-1)] + field[INDEX(i+1,j,k+1)]
766 + field[INDEX(i-1,j,k-1)] - field[INDEX(i-1,j,k+1)]
768 - field[INDEX(i+2,j,k-2)] + field[INDEX(i+2,j,k+2)]
769 + field[INDEX(i-2,j,k-2)] - field[INDEX(i-2,j,k+2)]
771 - field[INDEX(i+3,j,k-3)] + field[INDEX(i+3,j,k+3)]
772 + field[INDEX(i-3,j,k-3)] - field[INDEX(i-3,j,k+3)]
777 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
780 - field[INDEX(i,j+1,k-1)] + field[INDEX(i,j+1,k+1)]
781 + field[INDEX(i,j-1,k-1)] - field[INDEX(i,j-1,k+1)]
783 - field[INDEX(i,j+2,k-2)] + field[INDEX(i,j+2,k+2)]
784 + field[INDEX(i,j-2,k-2)] - field[INDEX(i,j-2,k+2)]
786 - field[INDEX(i,j+3,k-3)] + field[INDEX(i,j+3,k+3)]
787 + field[INDEX(i,j-3,k-3)] - field[INDEX(i,j-3,k+3)]
796 inline real_t mixed_derivative_stencil_Odx8(idx_t i, idx_t j, idx_t k,
int d1,
797 int d2, arr_t & field)
799 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
802 - field[INDEX(i+1,j-1,k)] + field[INDEX(i+1,j+1,k)]
803 + field[INDEX(i-1,j-1,k)] - field[INDEX(i-1,j+1,k)]
805 - field[INDEX(i+2,j-2,k)] + field[INDEX(i+2,j+2,k)]
806 + field[INDEX(i-2,j-2,k)] - field[INDEX(i-2,j+2,k)]
808 - field[INDEX(i+3,j-3,k)] + field[INDEX(i+3,j+3,k)]
809 + field[INDEX(i-3,j-3,k)] - field[INDEX(i-3,j+3,k)]
811 - field[INDEX(i+4,j-4,k)] + field[INDEX(i+4,j+4,k)]
812 + field[INDEX(i-4,j-4,k)] - field[INDEX(i-4,j+4,k)]
817 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
820 - field[INDEX(i+1,j,k-1)] + field[INDEX(i+1,j,k+1)]
821 + field[INDEX(i-1,j,k-1)] - field[INDEX(i-1,j,k+1)]
823 - field[INDEX(i+2,j,k-2)] + field[INDEX(i+2,j,k+2)]
824 + field[INDEX(i-2,j,k-2)] - field[INDEX(i-2,j,k+2)]
826 - field[INDEX(i+3,j,k-3)] + field[INDEX(i+3,j,k+3)]
827 + field[INDEX(i-3,j,k-3)] - field[INDEX(i-3,j,k+3)]
829 - field[INDEX(i+4,j,k-4)] + field[INDEX(i+4,j,k+4)]
830 + field[INDEX(i-4,j,k-4)] - field[INDEX(i-4,j,k+4)]
835 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
838 - field[INDEX(i,j+1,k-1)] + field[INDEX(i,j+1,k+1)]
839 + field[INDEX(i,j-1,k-1)] - field[INDEX(i,j-1,k+1)]
841 - field[INDEX(i,j+2,k-2)] + field[INDEX(i,j+2,k+2)]
842 + field[INDEX(i,j-2,k-2)] - field[INDEX(i,j-2,k+2)]
844 - field[INDEX(i,j+3,k-3)] + field[INDEX(i,j+3,k+3)]
845 + field[INDEX(i,j-3,k-3)] - field[INDEX(i,j-3,k+3)]
847 - field[INDEX(i,j+4,k-4)] + field[INDEX(i,j+4,k+4)]
848 + field[INDEX(i,j-4,k-4)] - field[INDEX(i,j-4,k+4)]
857 inline real_t double_derivative_stencil_Odx2(idx_t i, idx_t j, idx_t k,
int d,
863 field[INDEX(i-1,j,k)]
864 - 2.0*field[INDEX(i-0,j,k)]
865 + field[INDEX(i+1,j,k)]
870 field[INDEX(i,j-1,k)]
871 - 2.0*field[INDEX(i,j-0,k)]
872 + field[INDEX(i,j+1,k)]
877 field[INDEX(i,j,k-1)]
878 - 2.0*field[INDEX(i,j,k-0)]
879 + field[INDEX(i,j,k+1)]
888 inline real_t forward_double_derivative_stencil_Odx2(idx_t i, idx_t j, idx_t k,
int d,
894 2.0*field[INDEX(i,j,k)]
895 - 5.0*field[INDEX(i+1,j,k)]
896 + 4.0*field[INDEX(i+2,j,k)]
897 - 1.0*field[INDEX(i+3,j,k)]
902 2.0*field[INDEX(i,j,k)]
903 - 5.0*field[INDEX(i,j+1,k)]
904 + 4.0*field[INDEX(i,j+2,k)]
905 - 1.0*field[INDEX(i,j+3,k)]
910 2.0*field[INDEX(i,j,k)]
911 - 5.0*field[INDEX(i,j,k+1)]
912 + 4.0*field[INDEX(i,j,k+2)]
913 - 1.0*field[INDEX(i,j,k+3)]
923 inline real_t backward_double_derivative_stencil_Odx2(idx_t i, idx_t j, idx_t k,
int d,
929 2.0*field[INDEX(i,j,k)]
930 - 5.0*field[INDEX(i-1,j,k)]
931 + 4.0*field[INDEX(i-2,j,k)]
932 - 1.0*field[INDEX(i-3,j,k)]
937 2.0*field[INDEX(i,j,k)]
938 - 5.0*field[INDEX(i,j-1,k)]
939 + 4.0*field[INDEX(i,j-2,k)]
940 - 1.0*field[INDEX(i,j-3,k)]
945 2.0*field[INDEX(i,j,k)]
946 - 5.0*field[INDEX(i,j,k-1)]
947 + 4.0*field[INDEX(i,j,k-2)]
948 - 1.0*field[INDEX(i,j,k-3)]
958 inline real_t double_derivative_stencil_Odx4(idx_t i, idx_t j, idx_t k,
int d,
964 - 1.0/12.0*field[INDEX(i-2,j,k)]
965 + 4.0/3.0*field[INDEX(i-1,j,k)]
966 - 5.0/2.0*field[INDEX(i-0,j,k)]
967 + 4.0/3.0*field[INDEX(i+1,j,k)]
968 - 1.0/12.0*field[INDEX(i+2,j,k)]
973 - 1.0/12.0*field[INDEX(i,j-2,k)]
974 + 4.0/3.0*field[INDEX(i,j-1,k)]
975 - 5.0/2.0*field[INDEX(i,j-0,k)]
976 + 4.0/3.0*field[INDEX(i,j+1,k)]
977 - 1.0/12.0*field[INDEX(i,j+2,k)]
982 - 1.0/12.0*field[INDEX(i,j,k-2)]
983 + 4.0/3.0*field[INDEX(i,j,k-1)]
984 - 5.0/2.0*field[INDEX(i,j,k-0)]
985 + 4.0/3.0*field[INDEX(i,j,k+1)]
986 - 1.0/12.0*field[INDEX(i,j,k+2)]
995 inline real_t double_derivative_stencil_Odx6(idx_t i, idx_t j, idx_t k,
int d,
1001 1.0/90.0*field[INDEX(i-3,j,k)]
1002 - 3.0/20.0*field[INDEX(i-2,j,k)]
1003 + 3.0/2.0*field[INDEX(i-1,j,k)]
1004 - 49.0/18.0*field[INDEX(i-0,j,k)]
1005 + 3.0/2.0*field[INDEX(i+1,j,k)]
1006 - 3.0/20.0*field[INDEX(i+2,j,k)]
1007 + 1.0/90.0*field[INDEX(i+3,j,k)]
1012 1.0/90.0*field[INDEX(i,j-3,k)]
1013 - 3.0/20.0*field[INDEX(i,j-2,k)]
1014 + 3.0/2.0*field[INDEX(i,j-1,k)]
1015 - 49.0/18.0*field[INDEX(i,j-0,k)]
1016 + 3.0/2.0*field[INDEX(i,j+1,k)]
1017 - 3.0/20.0*field[INDEX(i,j+2,k)]
1018 + 1.0/90.0*field[INDEX(i,j+3,k)]
1023 1.0/90.0*field[INDEX(i,j,k-3)]
1024 - 3.0/20.0*field[INDEX(i,j,k-2)]
1025 + 3.0/2.0*field[INDEX(i,j,k-1)]
1026 - 49.0/18.0*field[INDEX(i,j,k-0)]
1027 + 3.0/2.0*field[INDEX(i,j,k+1)]
1028 - 3.0/20.0*field[INDEX(i,j,k+2)]
1029 + 1.0/90.0*field[INDEX(i,j,k+3)]
1038 inline real_t double_derivative_stencil_Odx8(idx_t i, idx_t j, idx_t k,
int d,
1044 - 1.0/560.0*field[INDEX(i-4,j,k)]
1045 + 8.0/315.0*field[INDEX(i-3,j,k)]
1046 - 1.0/5.0*field[INDEX(i-2,j,k)]
1047 + 8.0/5.0*field[INDEX(i-1,j,k)]
1048 - 205.0/72.0*field[INDEX(i-0,j,k)]
1049 + 8.0/5.0*field[INDEX(i+1,j,k)]
1050 - 1.0/5.0*field[INDEX(i+2,j,k)]
1051 + 8.0/315.0*field[INDEX(i+3,j,k)]
1052 - 1.0/560.0*field[INDEX(i+4,j,k)]
1057 - 1.0/560.0*field[INDEX(i,j-4,k)]
1058 + 8.0/315.0*field[INDEX(i,j-3,k)]
1059 - 1.0/5.0*field[INDEX(i,j-2,k)]
1060 + 8.0/5.0*field[INDEX(i,j-1,k)]
1061 - 205.0/72.0*field[INDEX(i,j-0,k)]
1062 + 8.0/5.0*field[INDEX(i,j+1,k)]
1063 - 1.0/5.0*field[INDEX(i,j+2,k)]
1064 + 8.0/315.0*field[INDEX(i,j+3,k)]
1065 - 1.0/560.0*field[INDEX(i,j+4,k)]
1070 - 1.0/560.0*field[INDEX(i,j,k-4)]
1071 + 8.0/315.0*field[INDEX(i,j,k-3)]
1072 - 1.0/5.0*field[INDEX(i,j,k-2)]
1073 + 8.0/5.0*field[INDEX(i,j,k-1)]
1074 - 205.0/72.0*field[INDEX(i,j,k-0)]
1075 + 8.0/5.0*field[INDEX(i,j,k+1)]
1076 - 1.0/5.0*field[INDEX(i,j,k+2)]
1077 + 8.0/315.0*field[INDEX(i,j,k+3)]
1078 - 1.0/560.0*field[INDEX(i,j,k+4)]
1087 inline real_t forward_dissipation_stencil_Odx2(idx_t i, idx_t j, idx_t k,
int d,
1093 forward_double_derivative_stencil_Odx2(i,j,k,d,field);
1097 forward_double_derivative_stencil_Odx2(i,j,k,d,field);
1101 forward_double_derivative_stencil_Odx2(i,j,k,d,field);
1110 inline real_t backward_dissipation_stencil_Odx2(idx_t i, idx_t j, idx_t k,
int d,
1116 backward_double_derivative_stencil_Odx2(i,j,k,d,field);
1120 backward_double_derivative_stencil_Odx2(i,j,k,d,field);
1124 backward_double_derivative_stencil_Odx2(i,j,k,d,field);
1132 inline real_t forward_dissipation_stencil_Odx4(idx_t i, idx_t j, idx_t k,
int d,
1140 inline real_t backward_dissipation_stencil_Odx4(idx_t i, idx_t j, idx_t k,
int d,
1148 inline real_t forward_dissipation_stencil_Odx6(idx_t i, idx_t j, idx_t k,
int d,
1156 inline real_t backward_dissipation_stencil_Odx6(idx_t i, idx_t j, idx_t k,
int d,
1164 inline real_t forward_dissipation_stencil_Odx8(idx_t i, idx_t j, idx_t k,
int d,
1172 inline real_t backward_dissipation_stencil_Odx8(idx_t i, idx_t j, idx_t k,
int d,
1180 inline real_t forward_dissipation(idx_t i, idx_t j, idx_t k,
int d,
1183 return STENCIL_ORDER_FUNCTION(forward_dissipation_stencil_Odx)(i, j, k, d, field);
1187 inline real_t backward_dissipation(idx_t i, idx_t j, idx_t k,
int d,
1190 return STENCIL_ORDER_FUNCTION(backward_dissipation_stencil_Odx)(i, j, k, d, field);
1205 inline real_t derivative(idx_t i, idx_t j, idx_t k,
int d,
1210 if(d == 2)
return 0;
1214 if(d == 3)
return 0;
1217 return STENCIL_ORDER_FUNCTION(derivative_Odx)(i, j, k, d, field);
1220 inline real_t lop_forward_derivative(idx_t i, idx_t j, idx_t k,
int d,
1223 return STENCIL_ORDER_FUNCTION(lop_forward_derivative_Odx)(i, j, k, d, field)
1224 + STENCIL_ORDER_FUNCTION(forward_dissipation_stencil_Odx)(i, j, k, d, field);
1227 inline real_t lop_backward_derivative(idx_t i, idx_t j, idx_t k,
int d,
1230 return STENCIL_ORDER_FUNCTION(lop_backward_derivative_Odx)(i, j, k, d, field)
1231 + STENCIL_ORDER_FUNCTION(backward_dissipation_stencil_Odx)(i, j, k, d, field);
1233 inline real_t forward_derivative(idx_t i, idx_t j, idx_t k,
int d,
1236 return STENCIL_ORDER_FUNCTION(forward_derivative_Odx)(i, j, k, d, field)
1237 + STENCIL_ORDER_FUNCTION(forward_dissipation_stencil_Odx)(i, j, k, d, field);
1240 inline real_t backward_derivative(idx_t i, idx_t j, idx_t k,
int d,
1243 return STENCIL_ORDER_FUNCTION(backward_derivative_Odx)(i, j, k, d, field)
1244 + STENCIL_ORDER_FUNCTION(backward_dissipation_stencil_Odx)(i, j, k, d, field);
1247 inline real_t upwind_derivative(idx_t i, idx_t j, idx_t k,
int d,
1248 arr_t & field, real_t c)
1250 if( c > 0)
return c * lop_forward_derivative(i,j,k,d,field);
1251 else return c * lop_backward_derivative(i,j,k,d,field);
1267 inline real_t mixed_derivative_stencil(idx_t i, idx_t j, idx_t k,
int d1,
int d2, arr_t & field)
1271 if(d1 == 2 || d2 == 2)
return 0;
1275 if(d1 == 3 || d2 == 3)
return 0;
1278 return STENCIL_ORDER_FUNCTION(mixed_derivative_stencil_Odx)(i, j, k, d1, d2, field);
1292 inline real_t double_derivative_stencil(idx_t i, idx_t j, idx_t k,
int d,
1297 if(d == 2)
return 0;
1301 if(d == 3)
return 0;
1304 return STENCIL_ORDER_FUNCTION(double_derivative_stencil_Odx)(i, j, k, d, field);
1319 inline real_t double_derivative(idx_t i, idx_t j, idx_t k,
int d1,
int d2,
1323 return double_derivative_stencil(i, j, k, d1, field);
1325 return mixed_derivative_stencil(i, j, k, d1, d2, field);
1344 inline real_t laplacian(idx_t i, idx_t j, idx_t k, arr_t & field)
1347 double_derivative(i, j, k, 1, 1, field)
1348 + double_derivative(i, j, k, 2, 2, field)
1349 + double_derivative(i, j, k, 3, 3, field)
1359 inline real_t average(arr_t & field)
1363 idx_t i=0, j=0, k=0;
1365 #pragma omp parallel for default(shared) private(i, j, k) reduction(+:sum) 1368 sum += field[NP_INDEX(i,j,k)];
1382 inline real_t volume_average(arr_t & DIFFphi, real_t phi_FRW)
1385 idx_t i=0, j=0, k=0;
1387 #pragma omp parallel for default(shared) private(i, j, k) reduction(+:sum) 1390 sum += exp(6.0*(DIFFphi[NP_INDEX(i,j,k)] + phi_FRW));
1403 inline real_t conformal_average(arr_t & field, arr_t & DIFFphi, real_t phi_FRW)
1406 idx_t i=0, j=0, k=0;
1408 #pragma omp parallel for default(shared) private(i, j, k) reduction(+:sum) 1411 sum += exp(6.0*(DIFFphi[NP_INDEX(i,j,k)] + phi_FRW))*field[NP_INDEX(i,j,k)];
1413 real_t vol = volume_average(DIFFphi, phi_FRW);
1414 return sum/POINTS/vol;
1424 inline real_t standard_deviation(arr_t & field, real_t avg)
1427 idx_t i=0, j=0, k=0;
1429 #pragma omp parallel for default(shared) private(i, j, k) reduction(+:sum) 1432 sum += pw2(avg - field[NP_INDEX(i,j,k)]);
1434 return sqrt(sum/(POINTS-1));
1443 inline real_t standard_deviation(arr_t & field)
1445 real_t avg = average(field);
1446 return standard_deviation(field, avg);
1458 inline real_t conformal_standard_deviation(arr_t & field, arr_t & DIFFphi, real_t phi_FRW, real_t avg)
1461 idx_t i=0, j=0, k=0;
1463 #pragma omp parallel for default(shared) private(i, j, k) reduction(+:sum) 1466 sum += exp(6.0*(DIFFphi[NP_INDEX(i,j,k)] + phi_FRW))*pw2(avg - field[NP_INDEX(i,j,k)]);
1468 real_t vol = volume_average(DIFFphi, phi_FRW);
1469 return sqrt(sum/(POINTS-1)/vol);
1480 inline real_t conformal_standard_deviation(arr_t & field, arr_t & DIFFphi, real_t phi_FRW)
1482 real_t avg = conformal_average(field, DIFFphi, phi_FRW);
1483 return conformal_standard_deviation(field, DIFFphi, phi_FRW, avg);
1489 inline real_t max(arr_t & field)
1491 idx_t i=0, j=0, k=0;
1492 real_t max_val = field[0];
1493 #pragma omp parallel for default(shared) private(i, j, k) reduction(max:max_val) 1496 if(field[INDEX(i,j,k)] > max_val) {
1497 max_val = field[INDEX(i,j,k)];
1506 inline real_t min(arr_t & field)
1508 idx_t i=0, j=0, k=0;
1509 real_t min_val = field[0];
1510 #pragma omp parallel for default(shared) private(i, j, k) reduction(min:min_val) 1513 if(field[INDEX(i,j,k)] < min_val) {
1514 min_val = field[INDEX(i,j,k)];
1524 inline idx_t numNaNs(arr_t & field)
1526 idx_t i=0, j=0, k=0;
1529 #pragma omp parallel for default(shared) private(i, j, k) reduction(+:NaNs) 1532 real_t val = field[NP_INDEX(i,j,k)];
1533 union {
float val; uint32_t x; } u = { (float) val };
1534 if((u.x << 1) > 0xff000000u)
1544 inline idx_t idx_t_mod(idx_t n, idx_t d)
1552 inline real_t real_t_mod(real_t n, real_t d)
1555 return n - d*std::floor(n/d);
1564 inline real_t derivative_Odx2(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
1566 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1570 - 1.0/2.0*field[H_INDEX(i-1,j,k,nx,ny,nz)]
1571 + 1.0/2.0*field[H_INDEX(i+1,j,k,nx,ny,nz)]
1576 - 1.0/2.0*field[H_INDEX(i,j-1,k,nx,ny,nz)]
1577 + 1.0/2.0*field[H_INDEX(i,j+1,k,nx,ny,nz)]
1582 - 1.0/2.0*field[H_INDEX(i,j,k-1,nx,ny,nz)]
1583 + 1.0/2.0*field[H_INDEX(i,j,k+1,nx,ny,nz)]
1592 inline real_t derivative_Odx4(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
1594 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1598 + 1.0/12.0*field[H_INDEX(i-2,j,k,nx,ny,nz)]
1599 - 2.0/3.0*field[H_INDEX(i-1,j,k,nx,ny,nz)]
1600 + 2.0/3.0*field[H_INDEX(i+1,j,k,nx,ny,nz)]
1601 - 1.0/12.0*field[H_INDEX(i+2,j,k,nx,ny,nz)]
1606 + 1.0/12.0*field[H_INDEX(i,j-2,k,nx,ny,nz)]
1607 - 2.0/3.0*field[H_INDEX(i,j-1,k,nx,ny,nz)]
1608 + 2.0/3.0*field[H_INDEX(i,j+1,k,nx,ny,nz)]
1609 - 1.0/12.0*field[H_INDEX(i,j+2,k,nx,ny,nz)]
1614 + 1.0/12.0*field[H_INDEX(i,j,k-2,nx,ny,nz)]
1615 - 2.0/3.0*field[H_INDEX(i,j,k-1,nx,ny,nz)]
1616 + 2.0/3.0*field[H_INDEX(i,j,k+1,nx,ny,nz)]
1617 - 1.0/12.0*field[H_INDEX(i,j,k+2,nx,ny,nz)]
1626 inline real_t derivative_Odx6(idx_t i, idx_t j, idx_t k,idx_t nx, idx_t ny, idx_t nz,
int d,
1629 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1633 - 1.0/60.0*field[H_INDEX(i-3,j,k,nx,ny,nz)]
1634 + 3.0/20.0*field[H_INDEX(i-2,j,k,nx,ny,nz)]
1635 - 3.0/4.0*field[H_INDEX(i-1,j,k,nx,ny,nz)]
1636 + 3.0/4.0*field[H_INDEX(i+1,j,k,nx,ny,nz)]
1637 - 3.0/20.0*field[H_INDEX(i+2,j,k,nx,ny,nz)]
1638 + 1.0/60.0*field[H_INDEX(i+3,j,k,nx,ny,nz)]
1643 - 1.0/60.0*field[H_INDEX(i,j-3,k,nx,ny,nz)]
1644 + 3.0/20.0*field[H_INDEX(i,j-2,k,nx,ny,nz)]
1645 - 3.0/4.0*field[H_INDEX(i,j-1,k,nx,ny,nz)]
1646 + 3.0/4.0*field[H_INDEX(i,j+1,k,nx,ny,nz)]
1647 - 3.0/20.0*field[H_INDEX(i,j+2,k,nx,ny,nz)]
1648 + 1.0/60.0*field[H_INDEX(i,j+3,k,nx,ny,nz)]
1653 - 1.0/60.0*field[H_INDEX(i,j,k-3,nx,ny,nz)]
1654 + 3.0/20.0*field[H_INDEX(i,j,k-2,nx,ny,nz)]
1655 - 3.0/4.0*field[H_INDEX(i,j,k-1,nx,ny,nz)]
1656 + 3.0/4.0*field[H_INDEX(i,j,k+1,nx,ny,nz)]
1657 - 3.0/20.0*field[H_INDEX(i,j,k+2,nx,ny,nz)]
1658 + 1.0/60.0*field[H_INDEX(i,j,k+3,nx,ny,nz)]
1667 inline real_t derivative_Odx8(idx_t i, idx_t j, idx_t k,idx_t nx, idx_t ny, idx_t nz,
int d,arr_t & field)
1669 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1673 ( 1.0/280.0*field[H_INDEX(i-4,j,k,nx,ny,nz)] - 1.0/280.0*field[H_INDEX(i+4,j,k,nx,ny,nz)] )
1674 - ( 4.0/105.0*field[H_INDEX(i-3,j,k,nx,ny,nz)] - 4.0/105.0*field[H_INDEX(i+3,j,k,nx,ny,nz)] )
1675 + ( 1.0/5.0*field[H_INDEX(i-2,j,k,nx,ny,nz)] - 1.0/5.0*field[H_INDEX(i+2,j,k,nx,ny,nz)] )
1676 - ( 4.0/5.0*field[H_INDEX(i-1,j,k,nx,ny,nz)] - 4.0/5.0*field[H_INDEX(i+1,j,k,nx,ny,nz)] )
1681 ( 1.0/280.0*field[H_INDEX(i,j-4,k,nx,ny,nz)] - 1.0/280.0*field[H_INDEX(i,j+4,k,nx,ny,nz)] )
1682 - ( 4.0/105.0*field[H_INDEX(i,j-3,k,nx,ny,nz)] - 4.0/105.0*field[H_INDEX(i,j+3,k,nx,ny,nz)] )
1683 + ( 1.0/5.0*field[H_INDEX(i,j-2,k,nx,ny,nz)] - 1.0/5.0*field[H_INDEX(i,j+2,k,nx,ny,nz)] )
1684 - ( 4.0/5.0*field[H_INDEX(i,j-1,k,nx,ny,nz)] - 4.0/5.0*field[H_INDEX(i,j+1,k,nx,ny,nz)] )
1689 ( 1.0/280.0*field[H_INDEX(i,j,k-4,nx,ny,nz)] - 1.0/280.0*field[H_INDEX(i,j,k+4,nx,ny,nz)] )
1690 - ( 4.0/105.0*field[H_INDEX(i,j,k-3,nx,ny,nz)] - 4.0/105.0*field[H_INDEX(i,j,k+3,nx,ny,nz)] )
1691 + ( 1.0/5.0*field[H_INDEX(i,j,k-2,nx,ny,nz)] - 1.0/5.0*field[H_INDEX(i,j,k+2,nx,ny,nz)] )
1692 - ( 4.0/5.0*field[H_INDEX(i,j,k-1,nx,ny,nz)] - 4.0/5.0*field[H_INDEX(i,j,k+1,nx,ny,nz)] )
1701 inline real_t mixed_derivative_stencil_Odx2(idx_t i, idx_t j, idx_t k,idx_t nx, idx_t ny, idx_t nz,
int d1,
int d2, arr_t & field)
1703 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1704 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
1706 - field[H_INDEX(i+1,j-1,k,nx,ny,nz)] + field[H_INDEX(i+1,j+1,k,nx,ny,nz)]
1707 + field[H_INDEX(i-1,j-1,k,nx,ny,nz)] - field[H_INDEX(i-1,j+1,k,nx,ny,nz)]
1711 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
1713 - field[H_INDEX(i+1,j,k-1,nx,ny,nz)] + field[H_INDEX(i+1,j,k+1,nx,ny,nz)]
1714 + field[H_INDEX(i-1,j,k-1,nx,ny,nz)] - field[H_INDEX(i-1,j,k+1,nx,ny,nz)]
1718 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
1720 - field[H_INDEX(i,j+1,k-1,nx,ny,nz)] + field[H_INDEX(i,j+1,k+1,nx,ny,nz)]
1721 + field[H_INDEX(i,j-1,k-1,nx,ny,nz)] - field[H_INDEX(i,j-1,k+1,nx,ny,nz)]
1729 inline real_t mixed_derivative_stencil_Odx4(idx_t i, idx_t j, idx_t k,idx_t nx, idx_t ny, idx_t nz,
int d1,
int d2, arr_t & field)
1731 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1732 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
1735 - field[H_INDEX(i+1,j-1,k,nx,ny,nz)] + field[H_INDEX(i+1,j+1,k,nx,ny,nz)]
1736 + field[H_INDEX(i-1,j-1,k,nx,ny,nz)] - field[H_INDEX(i-1,j+1,k,nx,ny,nz)]
1738 - field[H_INDEX(i+2,j-2,k,nx,ny,nz)] + field[H_INDEX(i+2,j+2,k,nx,ny,nz)]
1739 + field[H_INDEX(i-2,j-2,k,nx,ny,nz)] - field[H_INDEX(i-2,j+2,k,nx,ny,nz)]
1744 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
1747 - field[H_INDEX(i+1,j,k-1,nx,ny,nz)] + field[H_INDEX(i+1,j,k+1,nx,ny,nz)]
1748 + field[H_INDEX(i-1,j,k-1,nx,ny,nz)] - field[H_INDEX(i-1,j,k+1,nx,ny,nz)]
1750 - field[H_INDEX(i+2,j,k-2,nx,ny,nz)] + field[H_INDEX(i+2,j,k+2,nx,ny,nz)]
1751 + field[H_INDEX(i-2,j,k-2,nx,ny,nz)] - field[H_INDEX(i-2,j,k+2,nx,ny,nz)]
1756 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
1759 - field[H_INDEX(i,j+1,k-1,nx,ny,nz)] + field[H_INDEX(i,j+1,k+1,nx,ny,nz)]
1760 + field[H_INDEX(i,j-1,k-1,nx,ny,nz)] - field[H_INDEX(i,j-1,k+1,nx,ny,nz)]
1762 - field[H_INDEX(i,j+2,k-2,nx,ny,nz)] + field[H_INDEX(i,j+2,k+2,nx,ny,nz)]
1763 + field[H_INDEX(i,j-2,k-2,nx,ny,nz)] - field[H_INDEX(i,j-2,k+2,nx,ny,nz)]
1772 inline real_t mixed_derivative_stencil_Odx6(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d1,
int d2, arr_t & field)
1774 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1775 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
1778 - field[H_INDEX(i+1,j-1,k,nx,ny,nz)] + field[H_INDEX(i+1,j+1,k,nx,ny,nz)]
1779 + field[H_INDEX(i-1,j-1,k,nx,ny,nz)] - field[H_INDEX(i-1,j+1,k,nx,ny,nz)]
1781 - field[H_INDEX(i+2,j-2,k,nx,ny,nz)] + field[H_INDEX(i+2,j+2,k,nx,ny,nz)]
1782 + field[H_INDEX(i-2,j-2,k,nx,ny,nz)] - field[H_INDEX(i-2,j+2,k,nx,ny,nz)]
1784 - field[H_INDEX(i+3,j-3,k,nx,ny,nz)] + field[H_INDEX(i+3,j+3,k,nx,ny,nz)]
1785 + field[H_INDEX(i-3,j-3,k,nx,ny,nz)] - field[H_INDEX(i-3,j+3,k,nx,ny,nz)]
1790 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
1793 - field[H_INDEX(i+1,j,k-1,nx,ny,nz)] + field[H_INDEX(i+1,j,k+1,nx,ny,nz)]
1794 + field[H_INDEX(i-1,j,k-1,nx,ny,nz)] - field[H_INDEX(i-1,j,k+1,nx,ny,nz)]
1796 - field[H_INDEX(i+2,j,k-2,nx,ny,nz)] + field[H_INDEX(i+2,j,k+2,nx,ny,nz)]
1797 + field[H_INDEX(i-2,j,k-2,nx,ny,nz)] - field[H_INDEX(i-2,j,k+2,nx,ny,nz)]
1799 - field[H_INDEX(i+3,j,k-3,nx,ny,nz)] + field[H_INDEX(i+3,j,k+3,nx,ny,nz)]
1800 + field[H_INDEX(i-3,j,k-3,nx,ny,nz)] - field[H_INDEX(i-3,j,k+3,nx,ny,nz)]
1805 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
1808 - field[H_INDEX(i,j+1,k-1,nx,ny,nz)] + field[H_INDEX(i,j+1,k+1,nx,ny,nz)]
1809 + field[H_INDEX(i,j-1,k-1,nx,ny,nz)] - field[H_INDEX(i,j-1,k+1,nx,ny,nz)]
1811 - field[H_INDEX(i,j+2,k-2,nx,ny,nz)] + field[H_INDEX(i,j+2,k+2,nx,ny,nz)]
1812 + field[H_INDEX(i,j-2,k-2,nx,ny,nz)] - field[H_INDEX(i,j-2,k+2,nx,ny,nz)]
1814 - field[H_INDEX(i,j+3,k-3,nx,ny,nz)] + field[H_INDEX(i,j+3,k+3,nx,ny,nz)]
1815 + field[H_INDEX(i,j-3,k-3,nx,ny,nz)] - field[H_INDEX(i,j-3,k+3,nx,ny,nz)]
1824 inline real_t mixed_derivative_stencil_Odx8(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d1,
int d2, arr_t & field)
1826 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1827 if( (d1 == 1 && d2 == 2) || (d1 == 2 && d2 == 1) ) {
1830 - field[H_INDEX(i+1,j-1,k,nx,ny,nz)] + field[H_INDEX(i+1,j+1,k,nx,ny,nz)]
1831 + field[H_INDEX(i-1,j-1,k,nx,ny,nz)] - field[H_INDEX(i-1,j+1,k,nx,ny,nz)]
1833 - field[H_INDEX(i+2,j-2,k,nx,ny,nz)] + field[H_INDEX(i+2,j+2,k,nx,ny,nz)]
1834 + field[H_INDEX(i-2,j-2,k,nx,ny,nz)] - field[H_INDEX(i-2,j+2,k,nx,ny,nz)]
1836 - field[H_INDEX(i+3,j-3,k,nx,ny,nz)] + field[H_INDEX(i+3,j+3,k,nx,ny,nz)]
1837 + field[H_INDEX(i-3,j-3,k,nx,ny,nz)] - field[H_INDEX(i-3,j+3,k,nx,ny,nz)]
1839 - field[H_INDEX(i+4,j-4,k,nx,ny,nz)] + field[H_INDEX(i+4,j+4,k,nx,ny,nz)]
1840 + field[H_INDEX(i-4,j-4,k,nx,ny,nz)] - field[H_INDEX(i-4,j+4,k,nx,ny,nz)]
1845 if( (d1 == 1 && d2 == 3) || (d1 == 3 && d2 == 1) ) {
1848 - field[H_INDEX(i+1,j,k-1,nx,ny,nz)] + field[H_INDEX(i+1,j,k+1,nx,ny,nz)]
1849 + field[H_INDEX(i-1,j,k-1,nx,ny,nz)] - field[H_INDEX(i-1,j,k+1,nx,ny,nz)]
1851 - field[H_INDEX(i+2,j,k-2,nx,ny,nz)] + field[H_INDEX(i+2,j,k+2,nx,ny,nz)]
1852 + field[H_INDEX(i-2,j,k-2,nx,ny,nz)] - field[H_INDEX(i-2,j,k+2,nx,ny,nz)]
1854 - field[H_INDEX(i+3,j,k-3,nx,ny,nz)] + field[H_INDEX(i+3,j,k+3,nx,ny,nz)]
1855 + field[H_INDEX(i-3,j,k-3,nx,ny,nz)] - field[H_INDEX(i-3,j,k+3,nx,ny,nz)]
1857 - field[H_INDEX(i+4,j,k-4,nx,ny,nz)] + field[H_INDEX(i+4,j,k+4,nx,ny,nz)]
1858 + field[H_INDEX(i-4,j,k-4,nx,ny,nz)] - field[H_INDEX(i-4,j,k+4,nx,ny,nz)]
1863 if( (d1 == 3 && d2 == 2) || (d1 == 2 && d2 == 3) ) {
1866 - field[H_INDEX(i,j+1,k-1,nx,ny,nz)] + field[H_INDEX(i,j+1,k+1,nx,ny,nz)]
1867 + field[H_INDEX(i,j-1,k-1,nx,ny,nz)] - field[H_INDEX(i,j-1,k+1,nx,ny,nz)]
1869 - field[H_INDEX(i,j+2,k-2,nx,ny,nz)] + field[H_INDEX(i,j+2,k+2,nx,ny,nz)]
1870 + field[H_INDEX(i,j-2,k-2,nx,ny,nz)] - field[H_INDEX(i,j-2,k+2,nx,ny,nz)]
1872 - field[H_INDEX(i,j+3,k-3,nx,ny,nz)] + field[H_INDEX(i,j+3,k+3,nx,ny,nz)]
1873 + field[H_INDEX(i,j-3,k-3,nx,ny,nz)] - field[H_INDEX(i,j-3,k+3,nx,ny,nz)]
1875 - field[H_INDEX(i,j+4,k-4,nx,ny,nz)] + field[H_INDEX(i,j+4,k+4,nx,ny,nz)]
1876 + field[H_INDEX(i,j-4,k-4,nx,ny,nz)] - field[H_INDEX(i,j-4,k+4,nx,ny,nz)]
1885 inline real_t double_derivative_stencil_Odx2(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
1887 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1891 field[H_INDEX(i-1,j,k,nx,ny,nz)]
1892 - 2.0*field[H_INDEX(i-0,j,k,nx,ny,nz)]
1893 + field[H_INDEX(i+1,j,k,nx,ny,nz)]
1898 field[H_INDEX(i,j-1,k,nx,ny,nz)]
1899 - 2.0*field[H_INDEX(i,j-0,k,nx,ny,nz)]
1900 + field[H_INDEX(i,j+1,k,nx,ny,nz)]
1905 field[H_INDEX(i,j,k-1,nx,ny,nz)]
1906 - 2.0*field[H_INDEX(i,j,k-0,nx,ny,nz)]
1907 + field[H_INDEX(i,j,k+1,nx,ny,nz)]
1916 inline real_t double_derivative_stencil_Odx4(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
1918 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1922 - 1.0/12.0*field[H_INDEX(i-2,j,k,nx,ny,nz)]
1923 + 4.0/3.0*field[H_INDEX(i-1,j,k,nx,ny,nz)]
1924 - 5.0/2.0*field[H_INDEX(i-0,j,k,nx,ny,nz)]
1925 + 4.0/3.0*field[H_INDEX(i+1,j,k,nx,ny,nz)]
1926 - 1.0/12.0*field[H_INDEX(i+2,j,k,nx,ny,nz)]
1931 - 1.0/12.0*field[H_INDEX(i,j-2,k,nx,ny,nz)]
1932 + 4.0/3.0*field[H_INDEX(i,j-1,k,nx,ny,nz)]
1933 - 5.0/2.0*field[H_INDEX(i,j-0,k,nx,ny,nz)]
1934 + 4.0/3.0*field[H_INDEX(i,j+1,k,nx,ny,nz)]
1935 - 1.0/12.0*field[H_INDEX(i,j+2,k,nx,ny,nz)]
1940 - 1.0/12.0*field[H_INDEX(i,j,k-2,nx,ny,nz)]
1941 + 4.0/3.0*field[H_INDEX(i,j,k-1,nx,ny,nz)]
1942 - 5.0/2.0*field[H_INDEX(i,j,k-0,nx,ny,nz)]
1943 + 4.0/3.0*field[H_INDEX(i,j,k+1,nx,ny,nz)]
1944 - 1.0/12.0*field[H_INDEX(i,j,k+2,nx,ny,nz)]
1953 inline real_t double_derivative_stencil_Odx6(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
1955 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
1959 1.0/90.0*field[H_INDEX(i-3,j,k,nx,ny,nz)]
1960 - 3.0/20.0*field[H_INDEX(i-2,j,k,nx,ny,nz)]
1961 + 3.0/2.0*field[H_INDEX(i-1,j,k,nx,ny,nz)]
1962 - 49.0/18.0*field[H_INDEX(i-0,j,k,nx,ny,nz)]
1963 + 3.0/2.0*field[H_INDEX(i+1,j,k,nx,ny,nz)]
1964 - 3.0/20.0*field[H_INDEX(i+2,j,k,nx,ny,nz)]
1965 + 1.0/90.0*field[H_INDEX(i+3,j,k,nx,ny,nz)]
1970 1.0/90.0*field[H_INDEX(i,j-3,k,nx,ny,nz)]
1971 - 3.0/20.0*field[H_INDEX(i,j-2,k,nx,ny,nz)]
1972 + 3.0/2.0*field[H_INDEX(i,j-1,k,nx,ny,nz)]
1973 - 49.0/18.0*field[H_INDEX(i,j-0,k,nx,ny,nz)]
1974 + 3.0/2.0*field[H_INDEX(i,j+1,k,nx,ny,nz)]
1975 - 3.0/20.0*field[H_INDEX(i,j+2,k,nx,ny,nz)]
1976 + 1.0/90.0*field[H_INDEX(i,j+3,k,nx,ny,nz)]
1981 1.0/90.0*field[H_INDEX(i,j,k-3,nx,ny,nz)]
1982 - 3.0/20.0*field[H_INDEX(i,j,k-2,nx,ny,nz)]
1983 + 3.0/2.0*field[H_INDEX(i,j,k-1,nx,ny,nz)]
1984 - 49.0/18.0*field[H_INDEX(i,j,k-0,nx,ny,nz)]
1985 + 3.0/2.0*field[H_INDEX(i,j,k+1,nx,ny,nz)]
1986 - 3.0/20.0*field[H_INDEX(i,j,k+2,nx,ny,nz)]
1987 + 1.0/90.0*field[H_INDEX(i,j,k+3,nx,ny,nz)]
1996 inline real_t double_derivative_stencil_Odx8(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
1998 real_t dx = H_LEN_FRAC / nx, dy = H_LEN_FRAC / ny, dz = H_LEN_FRAC / nz;
2002 - 1.0/560.0*field[H_INDEX(i-4,j,k,nx,ny,nz)]
2003 + 8.0/315.0*field[H_INDEX(i-3,j,k,nx,ny,nz)]
2004 - 1.0/5.0*field[H_INDEX(i-2,j,k,nx,ny,nz)]
2005 + 8.0/5.0*field[H_INDEX(i-1,j,k,nx,ny,nz)]
2006 - 205.0/72.0*field[H_INDEX(i-0,j,k,nx,ny,nz)]
2007 + 8.0/5.0*field[H_INDEX(i+1,j,k,nx,ny,nz)]
2008 - 1.0/5.0*field[H_INDEX(i+2,j,k,nx,ny,nz)]
2009 + 8.0/315.0*field[H_INDEX(i+3,j,k,nx,ny,nz)]
2010 - 1.0/560.0*field[H_INDEX(i+4,j,k,nx,ny,nz)]
2015 - 1.0/560.0*field[H_INDEX(i,j-4,k,nx,ny,nz)]
2016 + 8.0/315.0*field[H_INDEX(i,j-3,k,nx,ny,nz)]
2017 - 1.0/5.0*field[H_INDEX(i,j-2,k,nx,ny,nz)]
2018 + 8.0/5.0*field[H_INDEX(i,j-1,k,nx,ny,nz)]
2019 - 205.0/72.0*field[H_INDEX(i,j-0,k,nx,ny,nz)]
2020 + 8.0/5.0*field[H_INDEX(i,j+1,k,nx,ny,nz)]
2021 - 1.0/5.0*field[H_INDEX(i,j+2,k,nx,ny,nz)]
2022 + 8.0/315.0*field[H_INDEX(i,j+3,k,nx,ny,nz)]
2023 - 1.0/560.0*field[H_INDEX(i,j+4,k,nx,ny,nz)]
2028 - 1.0/560.0*field[H_INDEX(i,j,k-4,nx,ny,nz)]
2029 + 8.0/315.0*field[H_INDEX(i,j,k-3,nx,ny,nz)]
2030 - 1.0/5.0*field[H_INDEX(i,j,k-2,nx,ny,nz)]
2031 + 8.0/5.0*field[H_INDEX(i,j,k-1,nx,ny,nz)]
2032 - 205.0/72.0*field[H_INDEX(i,j,k-0,nx,ny,nz)]
2033 + 8.0/5.0*field[H_INDEX(i,j,k+1,nx,ny,nz)]
2034 - 1.0/5.0*field[H_INDEX(i,j,k+2,nx,ny,nz)]
2035 + 8.0/315.0*field[H_INDEX(i,j,k+3,nx,ny,nz)]
2036 - 1.0/560.0*field[H_INDEX(i,j,k+4,nx,ny,nz)]
2059 inline real_t derivative(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d,
2062 return STENCIL_ORDER_FUNCTION(derivative_Odx)(i, j, k, nx, ny, nz, d, field);
2080 inline real_t mixed_derivative_stencil(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d1,
int d2, arr_t & field)
2082 return STENCIL_ORDER_FUNCTION(mixed_derivative_stencil_Odx)(i, j, k, nx, ny, nz, d1, d2, field);
2099 inline real_t double_derivative_stencil(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d, arr_t & field)
2101 return STENCIL_ORDER_FUNCTION(double_derivative_stencil_Odx)(i, j, k, nx, ny, nz, d, field);
2119 inline real_t double_derivative(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz,
int d1,
int d2, arr_t & field)
2122 return double_derivative_stencil(i, j, k, nx, ny, nz, d1, field);
2124 return mixed_derivative_stencil(i, j, k, nx, ny, nz, d1, d2, field);
2146 inline real_t laplacian(idx_t i, idx_t j, idx_t k, idx_t nx, idx_t ny, idx_t nz, arr_t & field)
2149 double_derivative(i, j, k, nx, ny, nz, 1, 1, field)
2150 + double_derivative(i, j, k, nx, ny, nz, 2, 2, field)
2151 + double_derivative(i, j, k, nx, ny, nz, 3, 3, field)
2155 inline real_t interp(real_t i, real_t j, real_t k, idx_t nx, idx_t ny,
2156 idx_t nz, arr_t & field)
2158 real_t C000 = field[INDEX( (idx_t) i, (idx_t) j, (idx_t) k )];
2159 real_t C001 = field[INDEX( (idx_t) i, (idx_t) j, (idx_t) k + 1 )];
2160 real_t C010 = field[INDEX( (idx_t) i, (idx_t) j + 1, (idx_t) k )];
2161 real_t C011 = field[INDEX( (idx_t) i, (idx_t) j + 1, (idx_t) k + 1 )];
2162 real_t C100 = field[INDEX( (idx_t) i + 1, (idx_t) j, (idx_t) k )];
2163 real_t C101 = field[INDEX( (idx_t) i + 1, (idx_t) j, (idx_t) k + 1 )];
2164 real_t C110 = field[INDEX( (idx_t) i + 1, (idx_t) j + 1, (idx_t) k )];
2165 real_t C111 = field[INDEX( (idx_t) i + 1, (idx_t) j + 1, (idx_t) k + 1 )];
2167 real_t i_frac = real_t_mod( i, 1.0 );
2168 real_t j_frac = real_t_mod( j, 1.0 );
2169 real_t k_frac = real_t_mod( k, 1.0 );
2171 real_t C00 = C000*(1.0 - i_frac) + C100*i_frac;
2172 real_t C01 = C001*(1.0 - i_frac) + C101*i_frac;
2173 real_t C10 = C010*(1.0 - i_frac) + C110*i_frac;
2174 real_t C11 = C011*(1.0 - i_frac) + C111*i_frac;
2176 real_t C0 = C00*(1.0 - j_frac) + C10*j_frac;
2177 real_t C1 = C01*(1.0 - j_frac) + C11*j_frac;
2180 return C0*(1.0 - k_frac) + C1*k_frac;