HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
VlasovComputeCFL.c File Reference

Contains the function to compute maximum CFL over the domain for the Vlasov equations. 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 *, int, void *)
 
double VlasovComputeCFL (void *s, void *m, double dt, double t)
 

Detailed Description

Contains the function to compute maximum CFL over the domain for the Vlasov equations.

Author
John Loffeld

Definition in file VlasovComputeCFL.c.

Function Documentation

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 }
int ndims_x
Definition: vlasov.h:63
double * e_field
Definition: vlasov.h:81
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
int ghosts
Definition: hypar.h:52
#define _ArrayIndex1D_(N, imax, i, ghost, index)
Definition: vlasov.h:57
#define _ArrayCopy1D_(x, y, size)
double * x
Definition: hypar.h:107
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
double VlasovComputeCFL ( void *  s,
void *  m,
double  dt,
double  t 
)

Computes the maximum CFL number over the domain. Note that the CFL is computed over the local domain on this processor only.

Parameters
sSolver object of type HyPar
mMPI object of type MPIVariables
dtTime step size for which to compute the CFL
tTime

Definition at line 19 of file VlasovComputeCFL.c.

24 {
25  HyPar *solver = (HyPar*) s;
26  Vlasov *params = (Vlasov*) solver->physics;
27 
28  int ndims = solver->ndims;
29  int ghosts = solver->ghosts;
30  int *dim = solver->dim_local;
31  double *u = solver->u;
32 
33  double max_cfl = 0;
34  int done = 0;
35  int index[ndims];
36  _ArraySetValue_(index,ndims,0);
37 
38  while (!done) {
39 
40  for (int dir=0; dir<ndims; dir++) {
41  double dxinv;
42  _GetCoordinate_(dir,index[dir],dim,ghosts,solver->dxinv,dxinv);
43  double eig = VlasovAdvectionCoeff(index, dir, solver);
44  double local_cfl = eig*dt*dxinv;
45  if (local_cfl > max_cfl) max_cfl = local_cfl;
46  }
47 
48  _ArrayIncrementIndex_(ndims,dim,index,done);
49  }
50 
51  return(max_cfl);
52 }
#define _ArraySetValue_(x, size, value)
double * u
Definition: hypar.h:116
#define _ArrayIncrementIndex_(N, imax, i, done)
void * physics
Definition: hypar.h:266
int * dim_local
Definition: hypar.h:37
#define _GetCoordinate_(dir, i, dim, ghosts, x, coord)
Definition: basic.h:31
double VlasovAdvectionCoeff(int *, int, void *)
int ghosts
Definition: hypar.h:52
Definition: vlasov.h:57
double * dxinv
Definition: hypar.h:110
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23