HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
VlasovAdvection.c
Go to the documentation of this file.
1 
6 #include <math.h>
7 #include <basic.h>
8 #include <arrayfunctions.h>
10 #include <mpivars.h>
11 #include <hypar.h>
12 
13 double VlasovAdvectionCoeff(int*, int, void*);
14 
22 int VlasovAdvection( double *f,
23  double *u,
24  int dir,
25  void *s,
26  double t
27  )
28 {
29 
30  HyPar *solver = (HyPar*) s;
31  Vlasov *param = (Vlasov*) solver->physics;
32 
33  int* dim = solver->dim_local;
34  int ghosts = solver->ghosts;
35  int ndims = solver->ndims;
36 
37  // set bounds for array index to include ghost points
38  int bounds[ndims];
39  _ArrayCopy1D_(dim,bounds,ndims);
40  for (int i=0; i<ndims; i++) bounds[i] += 2*ghosts;
41 
42  // set offset such that index is compatible with ghost point arrangement
43  int offset[ndims];
44  _ArraySetValue_(offset,ndims,-ghosts);
45 
46  int done = 0;
47  int index_wog[ndims];
48  int index[ndims]; _ArraySetValue_(index,ndims,0);
49  while (!done) {
50 
51  _ArrayCopy1D_(index, index_wog, ndims);
52  for (int i = 0; i < ndims; i++) index_wog[i] -= ghosts;
53  double adv_coeff = VlasovAdvectionCoeff(index_wog, dir, solver);
54 
55  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
56  f[p] = adv_coeff * u[p];
57  _ArrayIncrementIndex_(ndims,bounds,index,done);
58 
59  }
60 
61  return 0;
62 }
Definition: vlasov.h:57
MPI related function definitions.
int VlasovAdvection(double *f, double *u, int dir, void *s, double t)
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Vlasov Equation.
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.
double VlasovAdvectionCoeff(int *, int, void *)