HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Initialize the linear advection-diffusion-reaction module. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <bandedmatrix.h>
#include <physicalmodels/linearadr.h>
#include <mpivars.h>
#include <hypar.h>
Go to the source code of this file.
Functions | |
int | LinearADRAdvectionField (void *, void *, int, int, int *) |
double | LinearADRComputeCFL (void *, void *, double, double) |
double | LinearADRComputeDiffNumber (void *, void *, double, double) |
int | LinearADRAdvection (double *, double *, int, void *, double) |
int | LinearADRDiffusionG (double *, double *, int, void *, double) |
int | LinearADRDiffusionH (double *, double *, int, int, void *, double) |
int | LinearADRReaction () |
int | LinearADRUpwind (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | LinearADRCenteredFlux (double *, double *, double *, double *, double *, double *, int, void *, double) |
int | LinearADRWriteAdvField (void *, void *, double) |
int | LinearADRAdvectionJacobian (double *, double *, void *, int, int, int) |
int | LinearADRDiffusionJacobian (double *, double *, void *, int, int) |
int | LinearADRInitialize (void *s, void *m) |
Initialize the linear advection-diffusion-reaction module.
Definition in file LinearADRInitialize.c.
int LinearADRAdvectionField | ( | void * | s, |
void * | m, | ||
int | idx, | ||
int | nsims, | ||
int * | dim_adv | ||
) |
Set the advection field over the domain - reads the spatially-varying advection data from a file, if available. The array to store the field must already be allocated.
For a single simulation, it reads in the data from a file. The data must have the same grid dimensions as the solution.
For an ensemble simulation, it reads in the advection field from the file corresponding to the idx (index of this simulation). The data in this file must have the same grid dimensions as the domain it is being read in for.
For a sparse grids simulation, it reads in the advection field from the file with data that has the grid dimensions as the full grid. The field on the current grid is obtained by interpolation.
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
idx | Index of this simulation |
nsims | Total number of simulations |
dim_adv | Grid dimensions of the advection field stored in file |
Definition at line 33 of file LinearADRAdvectionField.c.
double LinearADRComputeCFL | ( | 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 15 of file LinearADRComputeCFL.c.
double LinearADRComputeDiffNumber | ( | void * | s, |
void * | m, | ||
double | dt, | ||
double | t | ||
) |
Computes the maximum diffusion number over the domain. Note that the diffusion number 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 14 of file LinearADRComputeDiffNumber.c.
int LinearADRAdvection | ( | double * | f, |
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Evaluate the advection term in the linear advection-diffusion-reaction model:
Compute
\begin{equation} a_d u \end{equation}
given \(u\) and \(d\) in the hyperbolic term
\begin{equation} \sum_d \frac {\partial} {\partial x_d} \left( a_d u \right) \end{equation}
f | Array to hold the computed flux (same size and layout as u) |
u | Array containing the solution |
dir | Spatial dimension \(d\) |
s | Solver object of type HyPar |
t | Current time |
Definition at line 37 of file LinearADRAdvection.c.
int LinearADRDiffusionG | ( | double * | f, |
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Evaluate the diffusion term in the linear advection-diffusion-reaction model for a "pure Laplacian" type operator (no cross derivatives):
Compute
\begin{equation} \nu_d u \end{equation}
given \(u\) and \(d\) in the parabolic term
\begin{equation} \sum_d \frac {\partial^2} {\partial x_d^2} \left( \nu_d u \right) \end{equation}
f | Array to hold the computed diffusion term (same size and layout as u) |
u | Array containing the solution |
dir | Spatial dimension (unused since this is a 1D system) |
s | Solver object of type HyPar |
t | Current time |
Definition at line 26 of file LinearADRDiffusion.c.
int LinearADRDiffusionH | ( | double * | f, |
double * | u, | ||
int | dir1, | ||
int | dir2, | ||
void * | s, | ||
double | t | ||
) |
Evaluate the diffusion term in the linear advection-diffusion-reaction model for a parabolic operator with no cross derivatives:
Compute
\begin{equation} \nu_d u \end{equation}
given \(u\) and \(d_1,d_2\) in the parabolic term
\begin{equation} \sum_{d_1}\sum_{d_2} \frac {\partial^2} {\partial x_{d_1} \partial x_{d_2}} \left( \nu_d u \right) \end{equation}
Note: it's not correctly implemented. Will implement when necessary.
f | Array to hold the computed diffusion term (same size and layout as u) |
u | Array containing the solution |
dir1 | First spatial dimension of the double derivative \(d_1\) |
dir2 | Second spatial dimension of the double derivative \(d_2\) |
s | Solver object of type HyPar |
t | Current time |
Definition at line 74 of file LinearADRDiffusion.c.
int LinearADRReaction | ( | ) |
int LinearADRUpwind | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Upwinding scheme for linear advection
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 |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 16 of file LinearADRUpwind.c.
int LinearADRCenteredFlux | ( | double * | fI, |
double * | fL, | ||
double * | fR, | ||
double * | uL, | ||
double * | uR, | ||
double * | u, | ||
int | dir, | ||
void * | s, | ||
double | t | ||
) |
Centered scheme for linear advection
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 |
s | Solver object of type HyPar |
t | Current solution time |
Definition at line 103 of file LinearADRUpwind.c.
int LinearADRWriteAdvField | ( | void * | s, |
void * | m, | ||
double | a_t | ||
) |
Write out the advection field to file
s | Solver object of type HyPar |
m | MPI object of type MPIVariables |
a_t | Current simulation time |
Definition at line 18 of file LinearADRWriteAdvField.c.
int LinearADRAdvectionJacobian | ( | double * | Jac, |
double * | u, | ||
void * | p, | ||
int | dir, | ||
int | nvars, | ||
int | upw | ||
) |
Function to compute the flux Jacobian for the hyperbolic (advection) part of the linear-advection-diffusion-reaction model.
Jac | Jacobian matrix of size 1 (nvar = 1) |
u | solution at a grid point |
p | object containing physics-related parameters |
dir | dimension (x/y/z) |
nvars | number of 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 11 of file LinearADRJacobian.c.
int LinearADRDiffusionJacobian | ( | double * | Jac, |
double * | u, | ||
void * | p, | ||
int | dir, | ||
int | nvars | ||
) |
Function to compute the Jacobian for the parabolic (diffusion) part of the linear-advection-diffusion-reaction model.
Jac | Jacobian matrix of size 1 (nvar = 1) |
u | solution at a grid point |
p | object containing physics-related parameters |
dir | dimension (x/y/z) |
nvars | number of components |
Definition at line 36 of file LinearADRJacobian.c.
int LinearADRInitialize | ( | void * | s, |
void * | m | ||
) |
Initialize the linear advection-diffusion-reaction physics module - allocate and set physics-related parameters, read physics-related inputs from file, 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 |
---|---|---|---|
advection_filename | char[] | LinearADR::adv_filename | "none" |
advection | double[] | LinearADR::a | 0 |
diffusion | double[] | LinearADR::d | 0 |
centered_flux | char[] | LinearADR::centered_flux | "no" |
Note:
s | Solver object of type HyPar |
m | Object of type MPIVariables containing MPI-related info |
Definition at line 59 of file LinearADRInitialize.c.