HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Initialize the 1D Euler equations module. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <physicalmodels/euler1d.h>
#include <mpivars.h>
#include <hypar.h>
Go to the source code of this file.
Functions | |
double | Euler1DComputeCFL (void *, void *, double, double) |
int | Euler1DFlux (double *, double *, int, void *, double) |
int | Euler1DStiffFlux (double *, double *, int, void *, double) |
int | Euler1DSource (double *, double *, void *, void *, double) |
int | Euler1DUpwindRoe (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwinddFRoe (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwindRF (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwinddFRF (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwindLLF (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwinddFLLF (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwindSWFS (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DUpwindRusanov (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | Euler1DJacobian (double *, double *, void *, int, int, int) |
int | Euler1DStiffJacobian (double *, double *, void *, int, int, int) |
int | Euler1DRoeAverage (double *, double *, double *, void *) |
int | Euler1DLeftEigenvectors (double *, double *, void *, int) |
int | Euler1DRightEigenvectors (double *, double *, void *, int) |
int | Euler1DGravityField (void *, void *) |
int | Euler1DSourceUpwindLLF (double *, double *, double *, double *, int, void *, double) |
int | Euler1DSourceUpwindRoe (double *, double *, double *, double *, int, void *, double) |
int | Euler1DModifiedSolution (double *, double *, int, void *, void *, double) |
int | Euler1DPreStep (double *, void *, void *, double) |
int | Euler1DInitialize (void *s, void *m) |
Initialize the 1D Euler equations module.
Definition in file Euler1DInitialize.c.
double Euler1DComputeCFL | ( | 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.
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
dt | Time step size for which to compute the CFL |
t | Time |
Definition at line 17 of file Euler1DComputeCFL.c.
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}
f | Array to hold the computed flux (same size and layout as u) |
u | Array containing the conserved solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current time |
Definition at line 16 of file Euler1DFlux.c.
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.
Reference:
f | Array to hold the computed flux (same size and layout as u) |
u | Array containing the conserved solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current time |
Definition at line 64 of file Euler1DFlux.c.
int Euler1DSource | ( | double * | source, |
double * | u, | ||
void * | s, | ||
void * | m, | ||
double | t | ||
) |
Compute the gravitational source terms for the 1D Euler equations. The source term is computed according to the balanced formulation introduced in the reference below. The source term is reformulated and "discretized" in a similar fashion as the hyperbolic flux to ensure that the hydrostatic balance is maintained to machine precision.
source | Computed source terms (array size & layout same as u) |
u | Solution (conserved variables) |
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
t | Current solution time |
Definition at line 23 of file Euler1DSource.c.
int Euler1DUpwindRoe | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Roe's upwinding scheme.
\begin{equation} {\bf f}_{j+1/2} = \frac{1}{2}\left[ {\bf f}_{j+1/2}^L + {\bf f}_{j+1/2}^R - \left| A\left({\bf u}_{j+1/2}^L,{\bf u}_{j+1/2}^R\right) \right| \left( {\bf u}_{j+1/2}^R - {\bf u}_{j+1/2}^L \right)\right] \end{equation}
This upwinding scheme is modified for the balanced discretization of the 1D Euler equations when there is a non-zero gravitational force. See the reference below. For flows without any gravitational forces, it reduces to its original form.
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 30 of file Euler1DUpwind.c.
int Euler1DUpwinddFRoe | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
The Roe upwinding scheme (Euler1DUpwindRoe) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see Euler1DStiffFlux, _Euler1DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used.
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 453 of file Euler1DUpwind.c.
int Euler1DUpwindRF | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Characteristic-based Roe-fixed upwinding scheme.
\begin{align} \alpha_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,L}, \\ \alpha_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,R}, \\ v_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,L}, \\ v_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,R}, \\ \alpha_{j+1/2}^k &= \left\{ \begin{array}{cc} \alpha_{j+1/2}^{k,L} & {\rm if}\ \lambda_{j,j+1/2,j+1} > 0 \\ \alpha_{j+1/2}^{k,R} & {\rm if}\ \lambda_{j,j+1/2,j+1} < 0 \\ \frac{1}{2}\left[ \alpha_{j+1/2}^{k,L} + \alpha_{j+1/2}^{k,R} - \left(\max_{\left[j,j+1\right]} \lambda\right) \left( v_{j+1/2}^{k,R} - v_{j+1/2}^{k,L} \right) \right] & {\rm otherwise} \end{array}\right., \\ {\bf f}_{j+1/2} &= \sum_{k=1}^3 \alpha_{j+1/2}^k {\bf r}_{j+1/2}^k \end{align}
where \({\bf l}\), \({\bf r}\), and \(\lambda\) are the left-eigenvectors, right-eigenvectors and eigenvalues. The subscripts denote the grid locations.
Note that this upwinding scheme cannot be used for solving flows with non-zero gravitational forces.
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 115 of file Euler1DUpwind.c.
int Euler1DUpwinddFRF | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
The characteristic-based Roe-fixed upwinding scheme (Euler1DUpwindRF) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see Euler1DStiffFlux, _Euler1DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used.
Reference:
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 534 of file Euler1DUpwind.c.
int Euler1DUpwindLLF | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Characteristic-based local Lax-Friedrich upwinding scheme.
\begin{align} \alpha_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,L}, \\ \alpha_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf f}_{j+1/2}^{k,R}, \\ v_{j+1/2}^{k,L} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,L}, \\ v_{j+1/2}^{k,R} &= \sum_{k=1}^3 {\bf l}_{j+1/2}^k \cdot {\bf u}_{j+1/2}^{k,R}, \\ \alpha_{j+1/2}^k &= \frac{1}{2}\left[ \alpha_{j+1/2}^{k,L} + \alpha_{j+1/2}^{k,R} - \left(\max_{\left[j,j+1\right]} \lambda\right) \left( v_{j+1/2}^{k,R} - v_{j+1/2}^{k,L} \right) \right], \\ {\bf f}_{j+1/2} &= \sum_{k=1}^3 \alpha_{j+1/2}^k {\bf r}_{j+1/2}^k \end{align}
where \({\bf l}\), \({\bf r}\), and \(\lambda\) are the left-eigenvectors, right-eigenvectors and eigenvalues. The subscripts denote the grid locations.
This upwinding scheme is modified for the balanced discretization of the 1D Euler equations when there is a non-zero gravitational force. See the reference below. For flows without any gravitational forces, it reduces to its original form.
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 212 of file Euler1DUpwind.c.
int Euler1DUpwinddFLLF | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
The characteristic-based local Lax-Friedrich upwinding scheme (Euler1DUpwindLLF) for the partitioned hyperbolic flux that comprises of the acoustic waves only (see Euler1DStiffFlux, _Euler1DSetStiffFlux_). Thus, only the characteristic fields / eigen-modes corresponding to \( u\pm a\) are used.
Reference:
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 623 of file Euler1DUpwind.c.
int Euler1DUpwindSWFS | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Steger-Warming Flux-Splitting scheme
Note that this method cannot be used for flows with non-zero gravitational forces.
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 293 of file Euler1DUpwind.c.
int Euler1DUpwindRusanov | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Rusanov's upwinding scheme.
\begin{equation} {\bf f}_{j+1/2} = \frac{1}{2}\left[ {\bf f}_{j+1/2}^L + {\bf f}_{j+1/2}^R - \max_{j,j+1} \nu_j \left( {\bf u}_{j+1/2}^R - {\bf u}_{j+1/2}^L \right)\right] \end{equation}
where \(\nu = c + \left|u\right|\).
fI | Computed upwind interface flux |
fL | Left-biased reconstructed interface flux |
fR | Right-biased reconstructed interface flux |
uL | Left-biased reconstructed interface solution |
uR | Right-biased reconstructed interface solution |
u | Cell-centered solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 376 of file Euler1DUpwind.c.
int Euler1DJacobian | ( | double * | Jac, |
double * | u, | ||
void * | p, | ||
int | dir, | ||
int | nvars, | ||
int | upw | ||
) |
Function to compute the flux Jacobian of the 1D Euler equations, given the solution at a grid point. The Jacobian is square matrix of size nvar=3, and is returned as a 1D array (double) of 9 elements in row-major format.
Jac | Jacobian matrix: 1D array of size nvar^2 = 9 |
u | solution at a grid point (array of size nvar = 3) |
p | object containing the physics-related parameters |
dir | dimension (x/y/z) (not used, since this is 1D system) |
nvars | number of vector components |
upw | 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux |
Definition at line 14 of file Euler1DJacobian.c.
int Euler1DStiffJacobian | ( | double * | Jac, |
double * | u, | ||
void * | p, | ||
int | dir, | ||
int | nvars, | ||
int | upw | ||
) |
Function to compute the Jacobian of the fast flux (representing the acoustic waves) of the 1D Euler equations, given the solution at a grid point (see _Euler1DSetStiffFlux_, _Euler1DSetStiffJac_). The Jacobian is square matrix of size nvar=3, and is returned as a 1D array (double) of 9 elements in row-major format.
Jac | Jacobian matrix: 1D array of size nvar^2 = 9 |
u | solution at a grid point (array of size nvar = 3) |
p | object containing the physics-related parameters |
dir | dimension (x/y/z) (not used, since this is 1D system) |
nvars | number of vector components |
upw | 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux |
Definition at line 48 of file Euler1DJacobian.c.
int Euler1DRoeAverage | ( | double * | uavg, |
double * | uL, | ||
double * | uR, | ||
void * | p | ||
) |
Compute the Roe-averaged state for the 1D Euler equations. This function just calls the macro _Euler1DRoeAverage_ and is not used by any functions within the 1D Euler module. However, it's necessary to define it and provide it to the the solver object (HyPar) so that it can then send it to interpolation functions for a characteristic-based reconstruction.
uavg | The computed Roe-averaged state |
uL | Left state (conserved variables) |
uR | Right state (conserved variables) |
p | Object of type Euler1D with physics-related variables |
Definition at line 16 of file Euler1DFunctions.c.
int Euler1DLeftEigenvectors | ( | double * | u, |
double * | L, | ||
void * | p, | ||
int | dir | ||
) |
Compute the left eigenvections for the 1D Euler equations. This function just calls the macro _Euler1DLeftEigenvectors_ and is not used by any functions within the 1D Euler module. However, it's necessary to define it and provide it to the the solver object (HyPar) so that it can then send it to interpolation functions for a characteristic-based reconstruction.
u | Conserved solution at a grid point |
L | Array of size nvar^2 = 3^2 to save the matrix of left eigenvectors in (row-major format). |
p | Object of type Euler1D with physics-related variables |
dir | Spatial dimension (not used, since this is a 1D system) |
Definition at line 19 of file Euler1DEigen.c.
int Euler1DRightEigenvectors | ( | double * | u, |
double * | R, | ||
void * | p, | ||
int | dir | ||
) |
Compute the right eigenvections for the 1D Euler equations. This function just calls the macro _Euler1DRightEigenvectors_ and is not used by any functions within the 1D Euler module. However, it's necessary to define it and provide it to the the solver object (HyPar) so that it can then send it to interpolation functions for a characteristic-based reconstruction.
u | Conserved solution at a grid point |
R | Array of size nvar^2 = 3^2 to save the matrix of right eigenvectors in (row-major format). |
p | Object of type Euler1D with physics-related variables |
dir | Spatial dimension (not used, since this is a 1D system) |
Definition at line 38 of file Euler1DEigen.c.
int Euler1DGravityField | ( | void * | s, |
void * | m | ||
) |
Compute the gravitational field over the domain. See
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
Definition at line 23 of file Euler1DGravityField.c.
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.
fI | Computed interface source term ("upwinded") |
fL | Left-biased interface source term |
fR | Right-biased interface source term |
u | Solution (conserved variables) |
dir | Spatial dimension (unused since this is a 1D case) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 21 of file Euler1DSourceUpwind.c.
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.
fI | Computed interface source term ("upwinded") |
fL | Left-biased interface source term |
fR | Right-biased interface source term |
u | Solution (conserved variables) |
dir | Spatial dimension (unused since this is a 1D case) |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 64 of file Euler1DSourceUpwind.c.
int Euler1DModifiedSolution | ( | double * | uC, |
double * | u, | ||
int | d, | ||
void * | s, | ||
void * | m, | ||
double | waqt | ||
) |
Compute the modified solution for the upwinding step in a balanced conservative finite-difference algorithm for the 1D Euler equations with gravitational sources. If no gravitational forces exist, the modified solution is identical to the solution.
Refer to
uC | The modified solution (same array size and layout as u) |
u | The solution (conserved variables) |
d | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
waqt | Current solution time |
Definition at line 23 of file Euler1DModifiedSolution.c.
int Euler1DPreStep | ( | double * | u, |
void * | s, | ||
void * | m, | ||
double | waqt | ||
) |
1D Euler-specific function called at the beginning of each time-step: For a simulation that splits the hyperbolic flux into its acoustic and entropy components for implicit- explicit time-integration, this function computes the fast Jacobian at the beginning of a time step for the linearized formulation.
u | Solution (conserved variables) |
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
waqt | Current solution time |
Definition at line 16 of file Euler1DPreStep.c.
int Euler1DInitialize | ( | void * | s, |
void * | m | ||
) |
Function to initialize the 1D inviscid Euler equations (Euler1D) module: Sets the default parameters, read in and set physics-related parameters, and set the physics-related function pointers in HyPar.
This file reads the file "physics.inp" that must have the following format:
begin <keyword> <value> <keyword> <value> <keyword> <value> ... <keyword> <value> end
where the list of keywords are:
Keyword name | Type | Variable | Default value -------— |
---|---|---|---|
gamma | double | Euler1D::gamma | 1.4 |
gravity | double | Euler1D::grav | 0.0 |
grav_type | int | Euler1D::grav_type | 0 |
upwinding | char[] | Euler1D::upw_choice | "roe" (_ROE_) |
Note: "physics.inp" is optional; if absent, default values will be used.
s | Solver object of type HyPar |
m | Object of type MPIVariables containing MPI-related info |
Definition at line 71 of file Euler1DInitialize.c.