HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
LinearADRJacobian.c
Go to the documentation of this file.
1 
6 #include <mathfunctions.h>
8 
11 int LinearADRAdvectionJacobian( double* Jac,
12  double* u,
13  void* p,
14  int dir,
15  int nvars,
16  int upw )
19 {
20  LinearADR *param = (LinearADR*) p;
21 
22  if (param->a) {
23  *Jac = (1-absolute(upw))*absolute(param->a[dir])
24  + absolute(upw) * (1+upw) * max(0,param->a[dir]) * 0.5
25  - absolute(upw) * (1-upw) * min(0,param->a[dir]) * 0.5 ;
26  } else {
27  /* no advection term */
28  *Jac = 0.0;
29  }
30 
31  return 0;
32 }
33 
36 int LinearADRDiffusionJacobian( double* Jac,
37  double* u,
38  void* p,
39  int dir,
40  int nvars )
41 {
42  LinearADR *param = (LinearADR*) p;
43 
44  int v;
45  for (v = 0; v < nvars; v++) {
46  Jac[nvars*v+v] = -param->d[nvars*dir+v];
47  }
48 
49  return 0;
50 }
#define absolute(a)
Definition: math_ops.h:32
Contains function definitions for common mathematical functions.
#define min(a, b)
Definition: math_ops.h:14
Structure containing variables and parameters specific to the linear advection-diffusion-reaction mod...
Definition: linearadr.h:37
double * a
Definition: linearadr.h:50
Linear Advection-Diffusion-Reaction model.
int LinearADRAdvectionJacobian(double *Jac, double *u, void *p, int dir, int nvars, int upw)
#define max(a, b)
Definition: math_ops.h:18
double * d
Definition: linearadr.h:53
int LinearADRDiffusionJacobian(double *Jac, double *u, void *p, int dir, int nvars)