HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Interp1PrimSecondOrderCentral.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_ 1
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], indexR[ndims], indexI[ndims], index_outer[ndims], bounds_outer[ndims], bounds_inter[ndims];
84  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
85  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
86  int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer);
87 
88  int i;
89 #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexL,indexR,indexI)
90  for (i=0; i<N_outer; i++) {
91  _ArrayIndexnD_(ndims,i,bounds_outer,index_outer,0);
92  _ArrayCopy1D_(index_outer,indexL,ndims);
93  _ArrayCopy1D_(index_outer,indexR,ndims);
94  _ArrayCopy1D_(index_outer,indexI,ndims);
95  for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) {
96  indexL[dir] = indexI[dir]-1;
97  indexR[dir] = indexI[dir];
98  int p; _ArrayIndex1D_(ndims,bounds_inter,indexI,0 ,p);
99  int qL; _ArrayIndex1D_(ndims,dim ,indexL,ghosts,qL);
100  int qR; _ArrayIndex1D_(ndims,dim ,indexR,ghosts,qR);
101  int v; for (v=0; v<nvars; v++) fI[p*nvars+v] = 0.5*(fC[qL*nvars+v]+fC[qR*nvars+v]);
102  }
103  }
104 
105  return(0);
106 }
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)
#define _ArrayCopy1D_(x, y, size)
int nvars
Definition: hypar.h:29
int Interp1PrimSecondOrderCentral(double *, double *, double *, double *, int, int, void *, void *, int)
2nd order central reconstruction (component-wise) on a uniform grid
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