HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
ParabolicFunctionNC1Stage.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 
32  double *par,
33  double *u,
34  void *s,
35  void *m,
36  double t
37  )
38 {
39  HyPar *solver = (HyPar*) s;
40  MPIVariables *mpi = (MPIVariables*) m;
41  double *Func = solver->fluxC;
42  double *Deriv2 = solver->Deriv2;
43  int d, v, i, done;
45 
46  int ndims = solver->ndims;
47  int nvars = solver->nvars;
48  int ghosts = solver->ghosts;
49  int *dim = solver->dim_local;
50  double *dxinv = solver->dxinv;
51  int size = solver->npoints_local_wghosts;
52 
53  if (!solver->GFunction) return(0); /* zero parabolic terms */
54  solver->count_par++;
55 
56  int index[ndims];
57  _ArraySetValue_(par,size*nvars,0.0);
58 
59  int offset = 0;
60  for (d = 0; d < ndims; d++) {
61  int size_deriv = 1; for (i=0; i<ndims; i++) size_deriv *= dim[i];
62 
63  /* calculate the diffusion function */
64  IERR solver->GFunction(Func,u,d,solver,t); CHECKERR(ierr);
65  IERR solver->SecondDerivativePar(Deriv2,Func,d,solver,mpi); CHECKERR(ierr);
66 
67  /* calculate the final term - second derivative of the diffusion function */
68  done = 0; _ArraySetValue_(index,ndims,0);
69  int p;
70  while (!done) {
71  _ArrayIndex1D_(ndims,dim,index,ghosts,p);
72  for (v=0; v<nvars; v++)
73  par[nvars*p+v] += ( dxinv[offset+ghosts+index[d]]*dxinv[offset+ghosts+index[d]]
74  * Deriv2[nvars*p+v] );
75  _ArrayIncrementIndex_(ndims,dim,index,done);
76  }
77 
78  offset += dim[d] + 2*ghosts;
79  }
80 
81  if (solver->flag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars);
82  return(0);
83 }
double * Deriv2
Definition: hypar.h:151
int(* GFunction)(double *, double *, int, void *, double)
Definition: hypar.h:310
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
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
int count_par
Definition: hypar.h:418
Contains structure definition for hypar.
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int ParabolicFunctionNC1Stage(double *par, double *u, void *s, void *m, double t)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
int ghosts
Definition: hypar.h:52
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