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

Go to the source code of this file.

Functions

double FPDoubleWellComputeCFL (void *s, void *m, double dt, double t)
 

Function Documentation

◆ FPDoubleWellComputeCFL()

double FPDoubleWellComputeCFL ( void *  s,
void *  m,
double  dt,
double  t 
)

Definition at line 7 of file FPDoubleWellComputeCFL.c.

8 {
9  HyPar *solver = (HyPar*) s;
10  int d, i, v;
11 
12  int ndims = solver->ndims;
13  int nvars = solver->nvars;
14  int ghosts = solver->ghosts;
15  int *dim = solver->dim_local;
16  double *dxinv = solver->dxinv;
17 
18  int offset = 0;
19  double max_cfl = 0;
20  for (d = 0; d < ndims; d++) {
21  for (i = 0; i < dim[d]; i++) {
22  for (v = 0; v < nvars; v++) {
23  double x; _GetCoordinate_(0,i,dim,ghosts,solver->x,x);
24  double local_cfl = absolute(drift(x)) * dt
25  * dxinv[offset+ghosts+i];
26  if (local_cfl > max_cfl) max_cfl = local_cfl;
27  }
28  }
29  offset += dim[d] + 2*ghosts;
30  }
31 
32  return(max_cfl);
33 }
#define absolute(a)
Definition: math_ops.h:32
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
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
double * dxinv
Definition: hypar.h:110