HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NonLinearInterpolation.c
Go to the documentation of this file.
1 
6 #include <stdlib.h>
7 #include <basic.h>
8 #include <arrayfunctions.h>
9 #include <mpivars.h>
10 #include <hypar.h>
11 
29  double *u,
30  void *s,
31  void *m,
32  double t,
36  int (*FluxFunction)(double*,double*,int,void*,double)
37  )
38 {
39  HyPar *solver = (HyPar*) s;
40  MPIVariables *mpi = (MPIVariables*) m;
41  double *FluxC = solver->fluxC; /* cell centered flux */
43 
44  int flag = (FluxFunction && solver->flag_nonlinearinterp && solver->SetInterpLimiterVar);
45  if (flag) {;
46  int ndims = solver->ndims;
47  int nvars = solver->nvars;
48  int ghosts = solver->ghosts;
49  int *dim = solver->dim_local;
50  double *x = solver->x;
51 
52  int size = 1, d;
53  for (d=0; d<ndims; d++) size *= (dim[d] + 2*ghosts);
54 
55  /* apply boundary conditions and exchange data over MPI interfaces */
56  IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); CHECKERR(ierr);
57  IERR solver->ApplyIBConditions(solver,mpi,u,t); CHECKERR(ierr);
58  IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); CHECKERR(ierr);
59 
60  int offset = 0;
61  for (d = 0; d < ndims; d++) {
62  /* evaluate cell-centered flux */
63  IERR FluxFunction(FluxC,u,d,solver,t); CHECKERR(ierr);
64  /* calculate non-linear interpolation coefficients */
65  IERR solver->SetInterpLimiterVar(FluxC,u,x+offset,d,solver,mpi);CHECKERR(ierr);
66  offset += dim[d] + 2*ghosts;
67  }
68  }
69 
70  return(0);
71 }
72 
int NonLinearInterpolation(double *u, void *s, void *m, double t, int(*FluxFunction)(double *, double *, int, void *, double))
int * dim_local
Definition: hypar.h:37
MPI related function definitions.
int ghosts
Definition: hypar.h:52
int(* SetInterpLimiterVar)(double *, double *, double *, int, void *, void *)
Definition: hypar.h:234
double * fluxC
Definition: hypar.h:128
int nvars
Definition: hypar.h:29
#define CHECKERR(ierr)
Definition: basic.h:18
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.
int(* ApplyBoundaryConditions)(void *, void *, double *, double *, double)
Definition: hypar.h:214
#define IERR
Definition: basic.h:16
int MPIExchangeBoundariesnD(int, int, int *, int, void *, double *)
Structure of MPI-related variables.
double * x
Definition: hypar.h:107
int(* ApplyIBConditions)(void *, void *, double *, double)
Definition: hypar.h:217
int flag_nonlinearinterp
Definition: hypar.h:411
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _DECLARE_IERR_
Definition: basic.h:17