HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Interp2PrimSecondOrder.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 #undef _MINIMUM_GHOSTS_
15 
19 #define _MINIMUM_GHOSTS_ 1
20 
57  double *fI,
58  double *fC,
59  int dir,
60  void *s,
61  void *m
62  )
63 {
64  HyPar *solver = (HyPar*) s;
65 
66  int ghosts = solver->ghosts;
67  int ndims = solver->ndims;
68  int nvars = solver->nvars;
69  int *dim = solver->dim_local;
70 
71  /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along
72  dimension "dir" */
73  int indexC[ndims], indexI[ndims], index_outer[ndims], bounds_outer[ndims], bounds_inter[ndims];
74  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
75  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
76 
77  int done = 0; _ArraySetValue_(index_outer,ndims,0);
78  while (!done) {
79  _ArrayCopy1D_(index_outer,indexC,ndims);
80  _ArrayCopy1D_(index_outer,indexI,ndims);
81  for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) {
82  int p, qL, qR;
83  _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p);
84  indexC[dir] = indexI[dir]-1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qL);
85  indexC[dir] = indexI[dir] ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR);
86  int v; for (v=0; v<nvars; v++) fI[p*nvars+v] = (fC[qR*nvars+v] - fC[qL*nvars+v]);
87  }
88  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
89  }
90 
91  return(0);
92 }
#define _ArraySetValue_(x, size, value)
Definitions for the functions computing the interpolated value of the primitive at the cell interface...
#define _ArrayIncrementIndex_(N, imax, i, done)
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
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.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int Interp2PrimSecondOrder(double *, double *, int, void *, void *)
2nd order component-wise interpolation of the 2nd primitive on a uniform grid