HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Interp1PrimFourthOrderCentral.c
Go to the documentation of this file.
1 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <basic.h>
9 #include <arrayfunctions.h>
10 #include <interpolation.h>
11 #include <mpivars.h>
12 #include <hypar.h>
13 
14 #ifdef with_omp
15 #include <omp.h>
16 #endif
17 
18 #undef _MINIMUM_GHOSTS_
19 
23 #define _MINIMUM_GHOSTS_ 2
24 
63  double *fI,
64  double *fC,
65  double *u,
66  double *x,
67  int upw,
68  int dir,
69  void *s,
70  void *m,
71  int uflag
72  )
73 {
74  HyPar *solver = (HyPar*) s;
75 
76  int ghosts = solver->ghosts;
77  int ndims = solver->ndims;
78  int nvars = solver->nvars;
79  int *dim = solver->dim_local;
80 
81  /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along
82  dimension "dir" */
83  int indexL[ndims],
84  indexR[ndims],
85  indexLL[ndims],
86  indexRR[ndims],
87  indexI[ndims],
88  index_outer[ndims],
89  bounds_outer[ndims],
90  bounds_inter[ndims];
91 
92  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
93  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
94  int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer);
95 
96  static const double c1 = 7.0 / 12.0;
97  static const double c2 = -1.0 / 12.0;
98 
99  int i;
100 #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexL,indexR,indexI)
101  for (i=0; i<N_outer; i++) {
102  _ArrayIndexnD_(ndims,i,bounds_outer,index_outer,0);
103  _ArrayCopy1D_(index_outer,indexL,ndims);
104  _ArrayCopy1D_(index_outer,indexLL,ndims);
105  _ArrayCopy1D_(index_outer,indexR,ndims);
106  _ArrayCopy1D_(index_outer,indexRR,ndims);
107  _ArrayCopy1D_(index_outer,indexI,ndims);
108  for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) {
109  indexLL[dir] = indexI[dir]-2;
110  indexL[dir] = indexI[dir]-1;
111  indexR[dir] = indexI[dir];
112  indexRR[dir] = indexI[dir]+1;
113 
114  int p; _ArrayIndex1D_(ndims,bounds_inter,indexI ,0 ,p);
115  int qLL; _ArrayIndex1D_(ndims,dim ,indexLL,ghosts,qLL);
116  int qL; _ArrayIndex1D_(ndims,dim ,indexL ,ghosts,qL );
117  int qR; _ArrayIndex1D_(ndims,dim ,indexR ,ghosts,qR );
118  int qRR; _ArrayIndex1D_(ndims,dim ,indexRR,ghosts,qRR);
119 
120  int v; for (v=0; v<nvars; v++) {
121  fI[p*nvars+v] = c2 * fC[qLL*nvars+v]
122  + c1 * fC[qL *nvars+v]
123  + c1 * fC[qR *nvars+v]
124  + c2 * fC[qRR*nvars+v];
125  }
126  }
127  }
128 
129  return(0);
130 }
Definitions for the functions computing the interpolated value of the primitive at the cell interface...
#define _ArrayIndexnD_(N, index, imax, i, ghost)
int * dim_local
Definition: hypar.h:37
MPI related function definitions.
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int Interp1PrimFourthOrderCentral(double *, double *, double *, double *, int, int, void *, void *, int)
4th order central reconstruction (component-wise) on a uniform grid
#define _ArrayCopy1D_(x, y, size)
int nvars
Definition: hypar.h:29
Contains structure definition for hypar.
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
#define _ArrayProduct1D_(x, size, p)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23