HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
Interp1PrimFirstOrderUpwind.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 
62  double *fI,
63  double *fC,
64  double *u,
65  double *x,
66  int upw,
67  int dir,
68  void *s,
69  void *m,
70  int uflag
71  )
72 {
73  HyPar *solver = (HyPar*) s;
74 
75  int ghosts = solver->ghosts;
76  int ndims = solver->ndims;
77  int nvars = solver->nvars;
78  int *dim = solver->dim_local;
79 
80  /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along
81  dimension "dir" */
82  int indexC[ndims], indexI[ndims], index_outer[ndims], bounds_outer[ndims], bounds_inter[ndims];
83  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
84  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
85  int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer);
86 
87  int i;
88 #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI)
89  for (i=0; i<N_outer; i++) {
90  _ArrayIndexnD_(ndims,i,bounds_outer,index_outer,0);
91  _ArrayCopy1D_(index_outer,indexC,ndims);
92  _ArrayCopy1D_(index_outer,indexI,ndims);
93  for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) {
94  indexC[dir] = (upw > 0 ? indexI[dir]-1 : indexI[dir]);
95  int p; _ArrayIndex1D_(ndims,bounds_inter,indexI,0 ,p);
96  int q; _ArrayIndex1D_(ndims,dim ,indexC,ghosts,q);
97  int v; for (v=0; v<nvars; v++) fI[p*nvars+v] = fC[q*nvars+v];
98  }
99  }
100 
101  return(0);
102 }
int nvars
Definition: hypar.h:29
MPI related function definitions.
Some basic definitions and macros.
#define _ArrayIndexnD_(N, index, imax, i, ghost)
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int * dim_local
Definition: hypar.h:37
int Interp1PrimFirstOrderUpwind(double *fI, double *fC, double *u, double *x, int upw, int dir, void *s, void *m, int uflag)
1st order upwind reconstruction (component-wise) on a uniform grid
int ghosts
Definition: hypar.h:52
Definitions for the functions computing the interpolated value of the primitive at the cell interface...
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.
#define _ArrayProduct1D_(x, size, p)