HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPDoubleWellDiffusion.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <basic.h>
3 #include <arrayfunctions.h>
5 #include <hypar.h>
6 
7 int FPDoubleWellDiffusion(double *f,double *u,int dir,void *s,double t)
8 {
9  HyPar *solver = (HyPar*) s;
10  FPDoubleWell *param = (FPDoubleWell*) solver->physics;
11  int i, v;
12 
13  int *dim = solver->dim_local;
14  int ghosts = solver->ghosts;
15  int ndims = solver->ndims;
16  int nvars = solver->nvars;
17  int index[ndims], bounds[ndims], offset[ndims];
18 
19  /* set bounds for array index to include ghost points */
20  _ArrayCopy1D_(dim,bounds,ndims);
21  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
22 
23  /* set offset such that index is compatible with ghost point arrangement */
24  _ArraySetValue_(offset,ndims,-ghosts);
25 
26  int done = 0; _ArraySetValue_(index,ndims,0);
27  while (!done) {
28  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
29  for (v = 0; v < nvars; v++) f[nvars*p+v] = 0.5*param->q * u[nvars*p+v];
30  _ArrayIncrementIndex_(ndims,bounds,index,done);
31  }
32 
33  return(0);
34 }
int nvars
Definition: hypar.h:29
int FPDoubleWellDiffusion(double *f, double *u, int dir, void *s, double t)
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
Contains structure definition for hypar.
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.