HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
FPDoubleWellAdvection.c File Reference
#include <stdlib.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/fpdoublewell.h>
#include <hypar.h>

Go to the source code of this file.

Functions

int FPDoubleWellAdvection (double *f, double *u, int dir, void *s, double t)
 

Function Documentation

◆ FPDoubleWellAdvection()

int FPDoubleWellAdvection ( double *  f,
double *  u,
int  dir,
void *  s,
double  t 
)

Definition at line 7 of file FPDoubleWellAdvection.c.

8 {
9  HyPar *solver = (HyPar*) s;
10  int i, v;
11 
12  int *dim = solver->dim_local;
13  int ghosts = solver->ghosts;
14  int ndims = solver->ndims;
15  int nvars = solver->nvars;
16  int index[ndims], bounds[ndims], offset[ndims];
17 
18  /* set bounds for array index to include ghost points */
19  _ArrayCopy1D_(dim,bounds,ndims);
20  for (i=0; i<ndims; i++) bounds[i] += 2*ghosts;
21 
22  /* set offset such that index is compatible with ghost point arrangement */
23  _ArraySetValue_(offset,ndims,-ghosts);
24 
25  int done = 0; _ArraySetValue_(index,ndims,0);
26  while (!done) {
27  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
28  double x; _GetCoordinate_(0,index[0]-ghosts,dim,ghosts,solver->x,x);
29  for (v = 0; v < nvars; v++) f[nvars*p+v] = drift(x) * u[nvars*p+v];
30  _ArrayIncrementIndex_(ndims,bounds,index,done);
31  }
32 
33  return(0);
34 }
int nvars
Definition: hypar.h:29
double * x
Definition: hypar.h:107
#define drift(x)
Definition: fpdoublewell.h:31
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#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)
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
#define _ArrayCopy1D_(x, y, size)