HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
ParabolicFunctionNC1.5Stage.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 
36  double *par,
37  double *u,
38  void *s,
39  void *m,
40  double t
41  )
42 {
43  HyPar *solver = (HyPar*) s;
44  MPIVariables *mpi = (MPIVariables*) m;
45  double *Func = solver->fluxC;
46  double *Deriv1 = solver->Deriv1;
47  double *Deriv2 = solver->Deriv2;
48  int d, d1, d2, v, p, done;
49  double dxinv1, dxinv2;
51 
52  int ndims = solver->ndims;
53  int nvars = solver->nvars;
54  int ghosts = solver->ghosts;
55  int *dim = solver->dim_local;
56  double *dxinv = solver->dxinv;
57  int size = solver->npoints_local_wghosts;
58 
59  if (!solver->HFunction) return(0); /* zero parabolic terms */
60  solver->count_par++;
61 
62  int index[ndims];
63  _ArraySetValue_(par,size*nvars,0.0);
64 
65  for (d1 = 0; d1 < ndims; d1++) {
66  for (d2 = 0; d2 < ndims; d2++) {
67 
68  /* calculate the diffusion function */
69  IERR solver->HFunction(Func,u,d1,d2,solver,t); CHECKERR(ierr);
70  if (d1 == d2) {
71  /* second derivative with respect to the same independent variable */
72  IERR solver->SecondDerivativePar(Deriv2,Func,d1,solver,mpi); CHECKERR(ierr);
73  } else {
74  /* cross derivative */
75  IERR solver->FirstDerivativePar(Deriv1,Func ,d1, 1,solver,mpi); CHECKERR(ierr);
76  IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,Deriv1); CHECKERR(ierr);
77  IERR solver->FirstDerivativePar(Deriv2,Deriv1,d2,-1,solver,mpi); CHECKERR(ierr);
78  }
79 
80  /* calculate the final term - second derivative of the diffusion function */
81  done = 0; _ArraySetValue_(index,ndims,0);
82  while (!done) {
83  _ArrayIndex1D_(ndims,dim,index,ghosts,p);
84  _GetCoordinate_(d1,index[d1],dim,ghosts,dxinv,dxinv1);
85  _GetCoordinate_(d2,index[d2],dim,ghosts,dxinv,dxinv2);
86  for (v=0; v<nvars; v++) par[nvars*p+v] += (dxinv1*dxinv2 * Deriv2[nvars*p+v]);
87  _ArrayIncrementIndex_(ndims,dim,index,done);
88  }
89 
90  }
91  }
92 
93  if (solver->flag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars);
94  return(0);
95 }
double * Deriv2
Definition: hypar.h:151
int nvars
Definition: hypar.h:29
int(* SecondDerivativePar)(double *, double *, int, void *, void *)
Definition: hypar.h:247
#define IERR
Definition: basic.h:16
MPI related function definitions.
#define CHECKERR(ierr)
Definition: basic.h:18
int MPIExchangeBoundariesnD(int, int, int *, int, void *, double *)
int(* HFunction)(double *, double *, int, int, void *, double)
Definition: hypar.h:313
Some basic definitions and macros.
int flag_ib
Definition: hypar.h:441
double * iblank
Definition: hypar.h:436
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
double * Deriv1
Definition: hypar.h:151
int count_par
Definition: hypar.h:418
Contains structure definition for hypar.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
int(* FirstDerivativePar)(double *, double *, int, int, void *, void *)
Definition: hypar.h:243
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
int ParabolicFunctionNC1_5Stage(double *par, double *u, void *s, void *m, double t)
Structure of MPI-related variables.
#define _ArrayBlockMultiply_(x, a, n, bs)
int npoints_local_wghosts
Definition: hypar.h:42
#define _DECLARE_IERR_
Definition: basic.h:17
Contains macros and function definitions for common array operations.
double * fluxC
Definition: hypar.h:128
double * dxinv
Definition: hypar.h:110