TYCHO  1.3.0
 All Data Structures Files Functions Variables Enumerations Enumerator
/home/kapf/tycho_docu/advection.c
Go to the documentation of this file.
1 /*
2  * advection.c
3  *
4  * Author: Wolfgang Kapferer
5  */
6 
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <math.h>
10 
11 #include "variables_global.h"
12 #include "prototypes.h"
13 
18 int advect(int nmin, int nmax, int flag, double *dx, double *vx_1D, double *marker_1D) {
19 
20  int n;
21  double spacing;
22 
23  if (flag == 0) spacing = 2.0 * xmax / (double) x;
24  if (flag == 1) spacing = 2.0 * ymax / (double) y;
25  if (flag == 2) spacing = 2.0 * zmax / (double) z;
26 
27  //Advect the marker field
28  for (n = nmin; n <= nmax; n++) {
29  if (vx_1D[n] > 0.0)
30  marker_1D[n] = marker_1D[n]-(dt * vx_1D[n]*(3 * marker_1D[n] - 4 * marker_1D[n - 1] + marker_1D[n - 2])) / spacing;
31  if (vx_1D[n] < 0.0)
32  marker_1D[n] = marker_1D[n]-(dt * vx_1D[n]*(-1 * marker_1D[n + 2] + 4 * marker_1D[n + 1] - 3 * marker_1D[n])) / spacing;
33  //to prevent negative marker densities
34  if (marker_1D[n] < 0.0) marker_1D[n] = 0.0;
35  }
36 
37  //Now the ghost cell resions are cleared
38  for (n = 1; n <= 6; n++) marker_1D[nmin - n] = 0.0;
39  for (n = 1; n <= 6; n++) marker_1D[nmax + n] = 0.0;
40 
41  return 0;
42 }