HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 }
int npoints_local_wghosts
Definition: hypar.h:42
#define _ArraySetValue_(x, size, value)
int ParabolicFunctionNC1Stage(double *par, double *u, void *s, void *m, double t)
double * iblank
Definition: hypar.h:436
#define _ArrayIncrementIndex_(N, imax, i, done)
double * Deriv2
Definition: hypar.h:151
int flag_ib
Definition: hypar.h:441
int * dim_local
Definition: hypar.h:37
MPI related function definitions.
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int count_par
Definition: hypar.h:418
#define _ArrayBlockMultiply_(x, a, n, bs)
double * fluxC
Definition: hypar.h:128
int nvars
Definition: hypar.h:29
#define CHECKERR(ierr)
Definition: basic.h:18
Contains structure definition for hypar.
double * dxinv
Definition: hypar.h:110
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Contains macros and function definitions for common array operations.
int(* SecondDerivativePar)(double *, double *, int, void *, void *)
Definition: hypar.h:247
#define IERR
Definition: basic.h:16
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
int(* GFunction)(double *, double *, int, void *, double)
Definition: hypar.h:310
#define _DECLARE_IERR_
Definition: basic.h:17