HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
NonLinearInterpolation.c File Reference

Compute the coefficients of a non-linear interpolation method (such as WENO, CRWENO) More...

#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int NonLinearInterpolation (double *u, void *s, void *m, double t, int(*FluxFunction)(double *, double *, int, void *, double))
 

Detailed Description

Compute the coefficients of a non-linear interpolation method (such as WENO, CRWENO)

Author
Debojyoti Ghosh

Definition in file NonLinearInterpolation.c.

Function Documentation

◆ NonLinearInterpolation()

int NonLinearInterpolation ( double *  u,
void *  s,
void *  m,
double  t,
int(*)(double *, double *, int, void *, double)  FluxFunction 
)

Compute the interpolation coefficients of a nonlinear interpolation method, based on the smoothness of the flux function of the solution passed as an argument. This function is provided separately so that these coefficients can be pre-computed and stored for future use.

In the implementation of non-linear methods (such as WENO5), the calculation of the non-linear coefficients, and the actual evaluation of the interpolant are separated into different functions. This provides flexibility on when the nonlinear coefficients are evaluated. Some scenarios are as follows:

  • For explicit time integration, it will be computed every time the hyperbolic flux term is being computed.
  • For implicit time integration, consistency or linearization may require that the coefficients be computed and "frozen" at the beginning of each stage. Thus, this function can be called at the beginning of each time integration stage, while HyperbolicFunction() is called with the argument LimFlag = 0.
Parameters
uSolution array
sSolver object of type HyPar
mMPI object of type MPIVariables
tCurrent solution time
FluxFunctionThe flux function \({\bf f}_d\left({\bf u}\right)\), whose properties (typically smoothness) is used to evaluate the nonlinear coefficients

Definition at line 28 of file NonLinearInterpolation.c.

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 }
int nvars
Definition: hypar.h:29
#define IERR
Definition: basic.h:16
#define CHECKERR(ierr)
Definition: basic.h:18
int MPIExchangeBoundariesnD(int, int, int *, int, void *, double *)
int(* ApplyBoundaryConditions)(void *, void *, double *, double *, double)
Definition: hypar.h:214
int(* ApplyIBConditions)(void *, void *, double *, double)
Definition: hypar.h:217
double * x
Definition: hypar.h:107
int ndims
Definition: hypar.h:26
int(* SetInterpLimiterVar)(double *, double *, double *, int, void *, void *)
Definition: hypar.h:234
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int * dim_local
Definition: hypar.h:37
int flag_nonlinearinterp
Definition: hypar.h:411
int ghosts
Definition: hypar.h:52
Structure of MPI-related variables.
#define _DECLARE_IERR_
Definition: basic.h:17
double * fluxC
Definition: hypar.h:128