HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
VlasovAdvectionCoeff.c File Reference

Returns the advection coefficient at a given grid index. More...

#include <float.h>
#include <math.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/vlasov.h>
#include <mpivars.h>
#include <hypar.h>

Go to the source code of this file.

Functions

double VlasovAdvectionCoeff (int *idx, int dir, void *s)
 

Detailed Description

Returns the advection coefficient at a given grid index.

Author
John Loffeld

Definition in file VlasovAdvectionCoeff.c.

Function Documentation

◆ VlasovAdvectionCoeff()

double VlasovAdvectionCoeff ( int *  idx,
int  dir,
void *  s 
)

Returns the advection coefficient at a given grid index \(c\), where

\begin{equation} c = v_i, \end{equation}

if dir < Vlasov::ndims_x ( \(i = {\rm dir}\)), and

\begin{equation} c = E_i, \end{equation}

the electric field if dir >= Vlasov::ndims_x ( \(i = \) dir-Vlasov::ndims_x).

Note: this function assumes that the electric field has already been set.

Parameters
idxgrid index
dirSpatial dimension
sSolver object of type HyPar

Definition at line 28 of file VlasovAdvectionCoeff.c.

32 {
33 
34  HyPar *solver = (HyPar*) s;
35  Vlasov *param = (Vlasov*) solver->physics;
36 
37  int* dim = solver->dim_local;
38  int ghosts = solver->ghosts;
39 
40  double retval = DBL_MAX;
41 
42  if (dir < param->ndims_x) {
43 
44  int veldim = dir + param->ndims_x;
45  _GetCoordinate_(veldim,idx[veldim],dim,ghosts,solver->x,retval);
46 
47  } else {
48 
49  int ndims_x = param->ndims_x;
50  int dim_x[ndims_x]; _ArrayCopy1D_(dim, dim_x, ndims_x);
51 
52  int idx_x[ndims_x];
53  _ArrayCopy1D_(idx, idx_x, ndims_x);
54  int p; _ArrayIndex1D_(ndims_x, dim_x, idx_x, ghosts, p);
55  retval = param->e_field[ndims_x*p+(dir-ndims_x)];
56 
57  }
58 
59  return retval;
60 
61 }
Definition: vlasov.h:57
double * x
Definition: hypar.h:107
double * e_field
Definition: vlasov.h:81
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1D_(N, imax, i, ghost, index)
int * dim_local
Definition: hypar.h:37
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
void * physics
Definition: hypar.h:266
int ghosts
Definition: hypar.h:52
#define _ArrayCopy1D_(x, y, size)
int ndims_x
Definition: vlasov.h:63