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

Contains functions to compute the "upwind" source term at an interface (for a balanced finite-difference discretization of the 1D Euler equations with gravitational source terms). More...

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

Go to the source code of this file.

Functions

int Euler1DSourceUpwindLLF (double *fI, double *fL, double *fR, double *u, int dir, void *s, double t)
 
int Euler1DSourceUpwindRoe (double *fI, double *fL, double *fR, double *u, int dir, void *s, double t)
 

Detailed Description

Contains functions to compute the "upwind" source term at an interface (for a balanced finite-difference discretization of the 1D Euler equations with gravitational source terms).

Author
Debojyoti Ghosh

Definition in file Euler1DSourceUpwind.c.

Function Documentation

◆ Euler1DSourceUpwindLLF()

int Euler1DSourceUpwindLLF ( double *  fI,
double *  fL,
double *  fR,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the "upwind" source term in the balanced formulation introduced in the reference below. The "upwind" state is just the arithmetic average of the left and right states.

Parameters
fIComputed interface source term ("upwinded")
fLLeft-biased interface source term
fRRight-biased interface source term
uSolution (conserved variables)
dirSpatial dimension (unused since this is a 1D case)
sSolver object of type HyPar
tCurrent solution time

Definition at line 21 of file Euler1DSourceUpwind.c.

30 {
31  HyPar *solver = (HyPar*) s;
32  int done,k;
34 
35  int ndims = solver->ndims;
36  int *dim = solver->dim_local;
37 
38  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
39  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
40  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
41 
42  done = 0; _ArraySetValue_(index_outer,ndims,0);
43  while (!done) {
44  _ArrayCopy1D_(index_outer,index_inter,ndims);
45  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
46  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
47  /* Local Lax-Friedrich upwinding scheme */
48  for (k = 0; k < _MODEL_NVARS_; k++)
49  (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]);
50  }
51  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
52  }
53 
54  return(0);
55 }
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _DECLARE_IERR_
Definition: basic.h:17
#define _ArrayCopy1D_(x, y, size)

◆ Euler1DSourceUpwindRoe()

int Euler1DSourceUpwindRoe ( double *  fI,
double *  fL,
double *  fR,
double *  u,
int  dir,
void *  s,
double  t 
)

Compute the "upwind" source term in the balanced formulation introduced in the reference below. The "upwind" state is just the arithmetic average of the left and right states.

Parameters
fIComputed interface source term ("upwinded")
fLLeft-biased interface source term
fRRight-biased interface source term
uSolution (conserved variables)
dirSpatial dimension (unused since this is a 1D case)
sSolver object of type HyPar
tCurrent solution time

Definition at line 64 of file Euler1DSourceUpwind.c.

73 {
74  HyPar *solver = (HyPar*) s;
75  int done,k;
77 
78  int ndims = solver->ndims;
79  int *dim = solver->dim_local;
80 
81  int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims];
82  _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1;
83  _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1;
84 
85  done = 0; _ArraySetValue_(index_outer,ndims,0);
86  while (!done) {
87  _ArrayCopy1D_(index_outer,index_inter,ndims);
88  for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) {
89  int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p);
90  /* Local Lax-Friedrich upwinding scheme */
91  for (k = 0; k < _MODEL_NVARS_; k++)
92  (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]);
93  }
94  _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done);
95  }
96 
97  return(0);
98 }
int ndims
Definition: hypar.h:26
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArraySetValue_(x, size, value)
int * dim_local
Definition: hypar.h:37
#define _ArrayIncrementIndex_(N, imax, i, done)
#define _MODEL_NVARS_
Definition: euler1d.h:58
#define _DECLARE_IERR_
Definition: basic.h:17
#define _ArrayCopy1D_(x, y, size)