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

Contains the functions to compute the hyperbolic flux for the 1D Euler equations over the domain. More...

#include <stdlib.h>
#include <arrayfunctions.h>
#include <physicalmodels/euler1d.h>
#include <hypar.h>

Go to the source code of this file.

Functions

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

Detailed Description

Contains the functions to compute the hyperbolic flux for the 1D Euler equations over the domain.

Author
Debojyoti Ghosh

Definition in file Euler1DFlux.c.

Function Documentation

◆ Euler1DFlux()

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

Compute the hyperbolic flux over the local domain.

\begin{equation} {\bf F}\left({\bf u}\right) = \left[\begin{array}{c} \rho u \\ \rho u^2 + p \\ (e+p) u \end{array}\right] \end{equation}

Parameters
fArray to hold the computed flux (same size and layout as u)
uArray containing the conserved solution
dirSpatial dimension (unused since this is a 1D system)
sSolver object of type HyPar
tCurrent time

Definition at line 16 of file Euler1DFlux.c.

23 {
24  HyPar *solver = (HyPar*) s;
25  Euler1D *param = (Euler1D*) solver->physics;
26  int *dim = solver->dim_local;
27  int ghosts = solver->ghosts;
28  static const int ndims = _MODEL_NDIMS_;
29  static const int nvars = _MODEL_NVARS_;
30  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
31 
32  /* set bounds for array index to include ghost points */
33  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
34  /* set offset such that index is compatible with ghost point arrangement */
35  _ArraySetValue_(offset,ndims,-ghosts);
36 
37  int done = 0; _ArraySetValue_(index,ndims,0);
38  while (!done) {
39  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
40  double rho, v, e, P;
41  _Euler1DGetFlowVar_((u+nvars*p),rho,v,e,P,param);
42  _Euler1DSetFlux_((f+nvars*p),rho,v,e,P);
43  _ArrayIncrementIndex_(ndims,bounds,index,done);
44  }
45 
46  return(0);
47 }
Structure containing variables and parameters specific to the 1D Euler equations. This structure cont...
Definition: euler1d.h:273
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#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
#define _Euler1DSetFlux_(f, rho, v, e, P)
Definition: euler1d.h:94
int ghosts
Definition: hypar.h:52
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _Euler1DGetFlowVar_(u, rho, v, e, P, p)
Definition: euler1d.h:81

◆ Euler1DStiffFlux()

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

Compute the stiff component of the hyperbolic flux over the local domain.

\begin{equation} {\bf F}_F\left({\bf u}\right) = A_f\left({\bf u}\right){\bf u} \end{equation}

where \(A_f\left({\bf u}\right) \) is the fast Jacobian representing the acoustic waves only. A linearized formulation is used where the fast Jacobian \(A_f\) is computed for the solution at the beginning of each time step in Euler1DPreStep.

See also
_Euler1DSetStiffFlux_, _Euler1DSetLinearizedStiffFlux_, _Euler1DSetStiffJac_

Reference:

  • Ghosh, D., Constantinescu, E. M., Semi-Implicit Time Integration of Atmospheric Flows with Characteristic-Based Flux Partitioning, SIAM Journal on Scientific Computing, 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369
Parameters
fArray to hold the computed flux (same size and layout as u)
uArray containing the conserved solution
dirSpatial dimension (unused since this is a 1D system)
sSolver object of type HyPar
tCurrent time

Definition at line 64 of file Euler1DFlux.c.

71 {
72  HyPar *solver = (HyPar*) s;
73  Euler1D *param = (Euler1D*) solver->physics;
74  int *dim = solver->dim_local;
75  int ghosts = solver->ghosts;
76  static const int ndims = _MODEL_NDIMS_;
77  static const int nvars = _MODEL_NVARS_;
78  static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_];
79 
80  /* set bounds for array index to include ghost points */
81  _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims);
82  /* set offset such that index is compatible with ghost point arrangement */
83  _ArraySetValue_(offset,ndims,-ghosts);
84 
85  int done = 0; _ArraySetValue_(index,ndims,0);
86  while (!done) {
87  int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p);
88  _Euler1DSetLinearizedStiffFlux_((f+nvars*p),(u+nvars*p),(param->fast_jac+nvars*nvars*p));
89  _ArrayIncrementIndex_(ndims,bounds,index,done);
90  }
91 
92  return(0);
93 }
Structure containing variables and parameters specific to the 1D Euler equations. This structure cont...
Definition: euler1d.h:273
#define _Euler1DSetLinearizedStiffFlux_(f, u, J)
Definition: euler1d.h:134
double * fast_jac
Definition: euler1d.h:289
#define _ArrayAddCopy1D_(x, a, y, size)
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _MODEL_NDIMS_
Definition: euler1d.h:56
#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 _MODEL_NVARS_
Definition: euler1d.h:58