Data Structures | Functions
SPE Namespace Reference

Namespace containing all functions and data classes for this solver. More...

Data Structures

struct  Mat_4terms
 structure for 4 mats to have u_term, v_term, w_term, P_term Mat More...
 
class  SPE
 Class to contain various variables for SPE solution. More...
 

Functions

PetscInt Ax_b (const PetscScalar *const *Ain, Vec &x, const PetscScalar bin[], const PetscInt &n)
 Solves \(x\) in \(Ax=b\) linalg problem using PETSc in parallel Useful for solving small systems of equations, such as finite difference coefficients for given stencils. More...
 
PetscInt Ax_b (const Mat &A, Vec &x, const Vec &b, const PetscInt &n)
 Solves \(x\) in \(Ax=b\) linalg problem using PETSc in parallel. More...
 
PetscInt Ax_kBx (const Mat &A, const Mat &B, PetscScalar &kr, PetscScalar &ki, Vec &xr, Vec &xi, PetscScalar target=0.54213+0.082968 *PETSC_i, PetscInt nev=1, EPSWhich which=EPS_TARGET_MAGNITUDE)
 Solves \(x\) in \(Ax=kBx\) eigenvalue problem using SLEPc in parallel. More...
 
int base_flow (SPE &data)
 set plane channel or blasius boundary layer flow velocity variables \(U, U_x, U_y,\) and etc Note: type_base_flow has an integer flag that corresponds with the following flow types More...
 
int _bblf (const PetscScalar input[3], PetscScalar output[3])
 Blasius boundary layer function to integrate. Similarity Blasius ODE broken into three coupled equations

\[ \begin{aligned} f'' &= \int -ff'' d\eta\\ f' &= \int f'' d\eta\\ f &= \int f' d\eta\\ \end{aligned} \]

. More...

 
int base_flow_dim (SPE &data)
 Use this after base_flow(data) call to set the ny matrices to size dim. So U is set into U_dim. More...
 
int calc_Closure (PetscScalar &I, SPE &data, Vec &q, Vec &qp1)
 calculate the closure equation \( \int_{\Omega} \hat{\textbf{q}}^\dagger \hat{\textbf{q}}_x d\Omega \) and output the result More...
 
int calc_L2 (PetscReal &error, Vec &x1, Vec &x2, PetscInt n, NormType type=NORM_2)
 calculate the \( L_2 \) norm of the difference between \(x_1\) and \(x_2\) vectors and return More...
 
int calc_L2 (PetscReal &error, Mat &x1, Mat &x2, PetscInt n, NormType type=NORM_2)
 calculate the \( L_2 \) norm of the difference between \(x_1\) and \(x_2\) matrix diagonals and return More...
 
int calc_LST (SPE &data, PetscScalar target_alpha, PetscScalar &alpha, Vec &qp1_OSS, Vec &qp1)
 calculate the Local Stability Theory (LST) Orr-Sommerfeld Squire equations in primitive variables at this x-location and store the alpha and qp1 of the target spatial values. More...
 
int Create_grid (SPE &data, PetscScalar deltay=0.)
 create y and z grid and stretch in y direction using stretching if deltay is nonzero More...
 
unsigned factorial (unsigned n)
 calculate the factorial of an integer More...
 
PetscInt get_D_Coeffs (const PetscScalar s[], const PetscInt &n, Vec &output, const PetscInt &d=2)
 Solve arbitrary stencil points s of length N with order of derivatives d<N can be obtained from equation on MIT website http://web.media.mit.edu/~crtaylor/calculator.html where the accuracy is determined as the usual form O(h^(N-d)) More...
 
int Init_Mat (Mat &A, const PetscInt &n)
 Initialize a Matrix A to be of size nxn. More...
 
int Init_Mat (Mat &A, const PetscInt &m, const PetscInt &n)
 Initialize a Matrix A to be of size mxn. More...
 
int Init_Vec (Vec &x, const PetscInt &n)
 Initialize a vector x to be of size n. More...
 
PetscInt map_D (Mat &output, SPE &data, const PetscInt &n, Vec &yVec, const PetscInt &order=2, const PetscInt &d=2, const PetscBool &periodic=PETSC_FALSE, const PetscBool &staggered=PETSC_FALSE, const PetscBool &reduce_wall_order=PETSC_TRUE)
 map D matrix operator for specified order and derivative, for a non-uniform mesh More...
 
PetscErrorCode printScalar (const PetscScalar x[], const PetscInt n=1, char const name[]="x", const PetscViewer viewer=PETSC_VIEWER_STDOUT_WORLD)
 Print PetscScalar variable to screen. More...
 
PetscErrorCode printReal (const PetscReal x[], const PetscInt n=1, char const name[]="x", const PetscViewer viewer=PETSC_VIEWER_STDOUT_WORLD)
 Print PetscReal variable to screen. More...
 
PetscErrorCode printVec (const Vec &x, const PetscInt n, char const name[]="x")
 Print Vec from PETSc type variable to screen. More...
 
PetscErrorCode printInt (const PetscInt x[], const PetscInt n=1, char const name[]="x")
 Print PetscInt variable to screen. More...
 
void printVecView (const Vec &x, char const name[]="x viewer", const PetscViewerFormat format=PETSC_VIEWER_DEFAULT)
 view PetscVec variable to screen Open an X-window viewer. Note that we specify the same communicator for the viewer as we used for the distributed vector (PETSC_COMM_WORLD). More...
 
PetscInt printMatView (const Mat &A, char const name[]="A viewer", const PetscViewerFormat format=PETSC_VIEWER_DEFAULT)
 view Petsc Mat variable to screen Open an X-window viewer. Note that we specify the same communicator for the viewer as we used for the distributed vector (PETSC_COMM_WORLD). More...
 
PetscInt printMatASCII (const Mat &A, char const name[]="printMatASCII.txt", const PetscViewerFormat format=PETSC_VIEWER_DEFAULT)
 view Petsc Mat variable to ASCII file More...
 
PetscInt printMatASCII (const Mat &A, std::string name, const PetscViewerFormat format=PETSC_VIEWER_DEFAULT)
 view Petsc Mat variable to ASCII file More...
 
void printMatGetDiagonalASCII (const Mat &A, char const name[]="printMatGetDiagonalASCII.txt", const PetscViewerFormat format=PETSC_VIEWER_ASCII_MATLAB)
 print diagonal of Petsc Mat variable to ASCII file More...
 
void printVecASCII (const Vec &b, char const name[]="printVecASCII.txt", const PetscViewerFormat format=PETSC_VIEWER_ASCII_MATLAB)
 view Petsc Vec variable to ASCII file More...
 
PetscErrorCode printClosureIter (SPE &data)
 print iteration residuals to screen from update_Closure iterations More...
 
PetscErrorCode printNonlinearIter (SPE &data)
 print iteration residuals to screen from update_Nonlinear iterations More...
 
void printHeaderIter ()
 print iteration residuals header to screen More...
 
PetscErrorCode printBaseNonlinearIter (SPE &data, PetscReal basenonlinear_error, PetscInt basenonlinear_iter)
 print iteration residuals to screen from baseflow nonlinear iterations More...
 
int Read_input_file (SPE &data, char const buff[]="input_file.json")
 Read an input file written in json format. More...
 
int set_input_value (Json::Value &val, const char buff[], PetscInt &v)
 take Json data and save it to value if it exists More...
 
int set_input_value (Json::Value &val, const char buff[], PetscReal &v)
 take Json data and save it to value if it exists More...
 
int set_input_value (Json::Value &val, const char buff[], PetscScalar &v)
 take Json data and save it to value if it exists More...
 
int set_input_value (Json::Value &val, const char buff[], PetscBool &v)
 take Json data and save it to value if it exists More...
 
int set_input_value (Json::Value &val, const char buff[], char *v)
 take Json data and save it to value if it exists More...
 
int set_input_value (Json::Value &val, const char buff[], std::string &v)
 take Json data and save it to value if it exists More...
 
int Read_q (SPE &data, std::string &buff)
 Read q from a tofile output from python. More...
 
int Read_q (Vec &output, const int n, std::string &buff)
 Read q from a tofile output from python. More...
 
int Read_q (PetscScalar output[], const int n, std::string &buff)
 Read y from a tofile output from python. More...
 
int Read_q (PetscScalar &output, std::string &buff)
 Read complex scalar from a tofile output from python. More...
 
PetscErrorCode Read_MatLabVec (Vec &output, std::string &buff)
 Read complex scalar vector from a matlab file (be sure this uses the PetscBinaryWrite() MatLab function) More...
 
PetscErrorCode Read_MatLabMat (Mat &output, std::string &buff)
 Read complex scalar matrix from a matlab file (be sure this uses the PetscBinaryWrite() MatLab function) More...
 
PetscErrorCode Read_MatLab (SPE &data, std::string &buff)
 Read input matrix and vectors input data from a matlab files (be sure this uses the PetscBinaryWrite() MatLab function) Reads and sets y, yVec, z, zVec, q, qp1, alpha, Deltay, and Deltaz quantities in the SPE class. More...
 
PetscInt set_A_and_B_OSS_zi (SPE &data, const PetscInt &zi=0)
 set A and B matrix for Orr-Sommerfeld equations for zi plane Note that the wavelike ansatz is \(u=\hat{u}(y,z) \exp (i (-\omega t + \alpha x))\)

\[ \begin{aligned} (-i \omega - \frac{1}{Re}(\partial_y^2 + \partial_z^2))\hat{u} + U' \hat{v} &= \alpha (-i \hat{P} - \frac{i}{Re}(\partial_y \hat{v} + \partial_z \hat{w}) - iU \hat{u})\\ (-i \omega - \frac{1}{Re}(\partial_y^2 + \partial_z^2))\hat{v} + \partial_y \hat{P} &= \alpha (- \frac{1}{Re}(\alpha \hat{v}) - iU \hat{v})\\ (\alpha \hat{v}) &= \alpha \cdot \hat{v}\\ (-i \omega - \frac{1}{Re}(\partial_y^2 + \partial_z^2))\hat{w} + \partial_z \hat{P} &= \alpha (- \frac{1}{Re}(\alpha \hat{w}) - iU \hat{w})\\ (\alpha \hat{w}) &= \alpha \cdot \hat{w}\\ \partial_y \hat{v} + \partial_z \hat{w} &= \alpha (-i \hat{u})\\ \end{aligned}\]

Where we have

\[ \begin{aligned} \mathbf{z}_i= \begin{bmatrix} \hat{u}\\ \alpha \hat{v}\\ \hat{v}\\ \alpha \hat{w}\\ \hat{w}\\ \hat{P} \end{bmatrix}_{z=z(i)} \textrm{ and } & \mathbf{q} = \begin{bmatrix} \mathbf{z}_1\\ \mathbf{z}_2\\ \vdots \\ \mathbf{z}_{nz - 1}\\ \mathbf{z}_{nz}\\ \end{bmatrix}\\ \end{aligned}\]

To solve the spatial eigenvalue problem \(\mathbf{\mathcal{A}q} = \alpha \mathbf{\mathcal{B}q}\) More...

 
PetscInt set_A_and_Ds (SPE &data, PetscScalar &alpha)
 set A and B matrix for SPE equations More...
 
PetscInt set_A_and_Ds (SPE &data)
 set A and B matrix for SPE equations, this is called from set_A_and_Ds(data,alplha) function This is used to set the full 3D operators (y,z, and t) More...
 
PetscInt set_A_and_Ds_nonlinear (SPE &data)
 set A and D matrix linear terms for SPE equations for nonlinear terms More...
 
PetscInt set_A_and_Ds_zi (SPE &data, PetscScalar &alpha, const PetscInt &zi=0)
 set A and B matrix linear terms for SPE equations for zi plane (also sets the permutation matrices to extract u from q, etc. More...
 
PetscInt set_b (const Mat &B, const Vec &qn, Vec &b)
 set b vector from B and q as b=B*q More...
 
PetscInt set_BCs (Mat &A, Vec &b, const PetscInt &ny, const PetscInt &nz)
 sets Boundary Condition equations in Matrix A and vector b in Ax=b linear system for solving the SPE equations More...
 
PetscInt set_BCs (SPE &data)
 sets Boundary Condition equations in Matrix A and Matrix B in A+ B*dqdx=0 linear system for solving the SPE equations More...
 
PetscInt set_Crank_Nicolson_Advance (SPE &data, Vec &q, PetscScalar &alpha)
 set up Crank-Nicolson advancing matrices A x = b system by creating matrices and setting BCs More...
 
PetscInt set_D (const PetscScalar y[], const PetscScalar yP[], const PetscInt &n, Mat &output, SPE &data, const PetscInt &order=2, const PetscInt &d=2, const PetscBool &periodic=PETSC_FALSE, const PetscBool &staggered=PETSC_FALSE, const PetscBool &reduce_wall_order=PETSC_TRUE, const PetscBool &uniform=PETSC_TRUE)
 set D matrix operator for specified order and derivative More...
 
PetscInt set_D_fourier (const PetscInt N, const PetscScalar &T, Mat &output, const PetscInt &d=1)
 set D matrix operator for specified derivative using fouier collocated points More...
 
PetscInt set_D (SPE &data)
 set D matrices and operators for use in OSS and SPE More...
 
PetscInt set_Euler_Advance (SPE &data, Vec &q, PetscScalar &alpha)
 set up Euler advancing matrices A x = b system by creating matrices and setting BCs More...
 
PetscInt set_Mat (const PetscScalar *const *Ain, const PetscInt &n, Mat &A, const InsertMode &addv=ADD_VALUES)
 set a matrix from PetscScalar 2D matrix to PETSc Mat type in parallel More...
 
PetscInt set_Mat (const PetscScalar &diag, const PetscInt &n, Mat &A, const PetscInt &k=0, const PetscBool &parallel=PETSC_TRUE, const InsertMode &addv=ADD_VALUES)
 set a diagonal of a matrix from scalar More...
 
PetscInt set_Mat (Mat &A)
 Assemble matrix. More...
 
PetscInt set_Mat (const PetscScalar &value, const PetscInt &row, const PetscInt &col, Mat &A, const PetscBool &parallel=PETSC_TRUE, const InsertMode &addv=ADD_VALUES)
 set a single value in matrix at row,col More...
 
PetscInt set_Mat (const PetscScalar &a, const Mat &Asub, const PetscInt &nsub, Mat &A, const PetscInt &n, const PetscInt &rowoffset=0, const PetscInt &coloffset=0, const InsertMode &addv=ADD_VALUES)
 set a submatrix Asub in a matrix A More...
 
PetscInt set_Mat (const PetscScalar *Ain, const PetscInt &row, const PetscInt &ncols, const PetscInt cols[], Mat &A, const InsertMode &addv=ADD_VALUES)
 set a row of PetscScalar to a matrix to PETSc Mat More...
 
PetscInt set_Mat (const PetscScalar &a, const Mat &Dz, const PetscInt &nz, const PetscInt &ny, const PetscInt &zi, Mat &A, const PetscInt &n, const PetscInt &nvars=4, const PetscInt &rowoffset=0, const PetscInt &coloffset=0, const InsertMode &addv=ADD_VALUES)
 set a Dz submatrix into A More...
 
PetscInt set_MatDiagonalScale (const Mat &diag_to_scale, const Mat &Asub, const PetscInt &nsub, Mat &A, const PetscInt &n, const PetscInt &rowoffset=0, const PetscInt &coloffset=0, const InsertMode &addv=ADD_VALUES)
 set a scaled matrix, (rows are scaled by matrix, using A=LA and MatDiagonalScale) More...
 
PetscInt set_Mat_broadcast_from_colVec (Vec &x, PetscInt &n, Mat &A)
 set a matrix from a column vector (broadcast the column vector to all columns of a matrix Be sure that A is already initialized More...
 
PetscInt set_Mat_from_Vec (Vec &x, PetscInt &ny, PetscInt &nz, PetscInt &rowoffset, Mat &A, const InsertMode &addv=ADD_VALUES)
 set a matrix A (large ny*nz*4) from a vector (ny*nz) (used in the diagonals) at a certain rowoffset (between 0-ny*3). Be sure that A is already initialized More...
 
PetscInt set_Mat_kron (const Mat &A, const Mat &B, Mat &C)
 Kronecker tensor product of two matrices A and B to make C If A is m by n, and B is p by q, then C will be m*p by n*q matrix formed by taking all possible products between the elements of A and the matrix B. See wikipedia for more information here. More...
 
PetscInt set_Mat_aPDdim_to_A (PetscScalar a, Mat &P, Mat &D, Mat &A)
 
PetscInt set_P (SPE &data)
 set permutation matrices and operators for use in OSS and SPE More...
 
PetscInt set_Vec (const PetscScalar *bin, const PetscInt &n, Vec &b, const PetscBool &parallel=PETSC_TRUE)
 set a vector from PetscScalar 1D vector to PETSc Vec type in parallel More...
 
PetscInt set_Vec (Vec &b)
 Assemble b vector. More...
 
PetscInt set_Vec (const PetscScalar &bin, const PetscInt &n, Vec &b)
 set a vector from PetscScalar to PETSc Vec in location n More...
 
PetscInt set_Vec (const Vec &inVec, const PetscInt &low, const PetscInt &hi, Vec &b)
 set a subvector from larger vector from low to hi indices More...
 
PetscInt set_Vec_linspace (PetscScalar a, const PetscScalar b, const PetscInt n, PetscScalar y[])
 set values of y, use linspace similar to matlab, creates on every processor More...
 
int trapz (const Vec &q, PetscScalar &I, SPE &data)
 trapezoidal rule on Vec with ny,nz values More...
 
PetscErrorCode trapz_4nynznt (const Vec &q, PetscScalar &I, SPE &data)
 trapezoidal rule on Vec with 4,ny,nz,nt values More...
 
int update_Closure (SPE &data, Vec &q, Vec &qp1, PetscScalar &alpha, const PetscInt &maxiter=50)
 calculate the closure equation \( \int_\Omega \hat{\textbf{q}}^\dagger \hat{\textbf{q}}_x dy \) and output the result This is part of the solution procedure shown in the bottom half of this diagram More...
 
int update_Nonlinear (SPE &data, Vec &q, Vec &qp1, PetscScalar &alpha_old, PetscScalar &alpha, PetscScalar &Ialpha_old, PetscScalar &Ialpha, const PetscInt &maxiter=50)
 advance the Nonlinear SPE system one x step More...
 

Detailed Description

Namespace containing all functions and data classes for this solver.

Function Documentation

int SPE::_bblf ( const PetscScalar  input[3],
PetscScalar  output[3] 
)

Blasius boundary layer function to integrate. Similarity Blasius ODE broken into three coupled equations

\[ \begin{aligned} f'' &= \int -ff'' d\eta\\ f' &= \int f'' d\eta\\ f &= \int f' d\eta\\ \end{aligned} \]

.

Parameters
[in]input\([f'', f', f]^T\) state at \( \eta_i \)
[out]output\([f'', f', f]^T\) state at \(\eta_{i+1} \)
PetscInt SPE::Ax_b ( const PetscScalar *const *  Ain,
Vec &  x,
const PetscScalar  bin[],
const PetscInt &  n 
)

Solves \(x\) in \(Ax=b\) linalg problem using PETSc in parallel Useful for solving small systems of equations, such as finite difference coefficients for given stencils.

Returns
0 if successful
Parameters
[in]Aininput of 2D \(A\) matrix in \(Ax=b\) (must be dynamic pointer to pointer)
[in,out]xvector of \(x\) in \(Ax=b\) (already initialized)
[in]binvector of \(b\) in \(Ax=b\)
[in]nn size of vectors or nxn matrix \(A\)
PetscInt SPE::Ax_b ( const Mat &  A,
Vec &  x,
const Vec &  b,
const PetscInt &  n 
)

Solves \(x\) in \(Ax=b\) linalg problem using PETSc in parallel.

Returns
0 if successful
Parameters
[in]Ainput of A matrix in \(Ax=b\)
[in,out]xvector of \(x\) in \(Ax=b\) (already initialized)
[in]bvector of \(b\) in \(Ax=b\)
[in]nn size of vectors or nxn matrix \(A\)
PetscInt SPE::Ax_kBx ( const Mat &  A,
const Mat &  B,
PetscScalar &  kr,
PetscScalar &  ki,
Vec &  xr,
Vec &  xi,
PetscScalar  target = 0.54213+0.082968*PETSC_i,
PetscInt  nev = 1,
EPSWhich  which = EPS_TARGET_MAGNITUDE 
)

Solves \(x\) in \(Ax=kBx\) eigenvalue problem using SLEPc in parallel.

Returns
0 if successful
Parameters
[in]Ainput of A matrix in \(Ax=kBx\)
[in]Binput of B matrix in \(Ax=kBx\)
[out]krreal part of eigenvalue
[out]kiimag part of eigenvalue
[out]xrvector of \(x\) in \(Ax=kBx\) (already initialized)
[out]xivector of \(x\) in \(Ax=kBx\) (already initialized)
[in]targettarget eigenvalue to solve around using the which parameter
[in]nevnumber of eigenvalues to compute
[in]whichportion of spectrum to be sought
int SPE::base_flow ( SPE data)

set plane channel or blasius boundary layer flow velocity variables \(U, U_x, U_y,\) and etc Note: type_base_flow has an integer flag that corresponds with the following flow types

  • 1 - Poisuille channel flow
  • 2 - Blasius Flat-Plate
  • 3 - SPE Boundary Layer equations with nonlinear forcing terms for Mean Flow Distortion
  • 4 - Read U,V,P from DNS data set located in the file sets of read_matlab_filename + "_Base_Flow/Base_Flow_istep_%i.dat"
  • 5 - SPE Boundary Layer equations with nonlinear forcing terms for Mean Flow Distortion for semi-staggered grid use this once to set the vectors with the velocity of plane channel flow (max u=1)
    Returns
    0 if successful
Parameters
[in,out]datadata from class passed in and out
int SPE::base_flow_dim ( SPE data)

Use this after base_flow(data) call to set the ny matrices to size dim. So U is set into U_dim.

Returns
0 if successful
Parameters
[in,out]datadata from class passed in and out
int SPE::calc_Closure ( PetscScalar &  I,
SPE data,
Vec &  q,
Vec &  qp1 
)

calculate the closure equation \( \int_{\Omega} \hat{\textbf{q}}^\dagger \hat{\textbf{q}}_x d\Omega \) and output the result

Returns
0 if successful
Parameters
[out]Ioutput integral value
[in,out]datadata class to store values
[in]qq at last marching step
[in]qp1q at current marching step
int SPE::calc_L2 ( PetscReal &  error,
Vec &  x1,
Vec &  x2,
PetscInt  n,
NormType  type = NORM_2 
)

calculate the \( L_2 \) norm of the difference between \(x_1\) and \(x_2\) vectors and return

Returns
0 if successful
Parameters
[out]error\(L_2\) norm of the difference between \(x_1\) and \(x_2\) vectors
[in]x1\(x_1\) vector
[in]x2\(x_2\) vector
[in]nsize of vectors
[in]typetype of norm (default NORM_2 \(\sqrt{\sum |x_1-x_2|^2}\)
int SPE::calc_L2 ( PetscReal &  error,
Mat &  x1,
Mat &  x2,
PetscInt  n,
NormType  type = NORM_2 
)

calculate the \( L_2 \) norm of the difference between \(x_1\) and \(x_2\) matrix diagonals and return

Returns
0 if successful
Parameters
[out]error\(L_2\) norm of the difference between \(x_1\) and \(x_2\) vectors
[in]x1\(x_1\) diagonal matrix
[in]x2\(x_2\) diagonal matrix
[in]nsize of vectors
[in]typetype of norm (default NORM_2 \(\sqrt{\sum |x_1-x_2|^2}\)
int SPE::calc_LST ( SPE data,
PetscScalar  target_alpha,
PetscScalar &  alpha,
Vec &  qp1_OSS,
Vec &  qp1 
)

calculate the Local Stability Theory (LST) Orr-Sommerfeld Squire equations in primitive variables at this x-location and store the alpha and qp1 of the target spatial values.

See also
set_A_and_B_OSS_zi.hpp
Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]target_alphatarget alpha guess
[out]alphaalpha from OSS solver
[out]qp1_OSSeigenvector of size data.dimOSS
[out]qp1eigenvector of size data.dim
int SPE::Create_grid ( SPE data,
PetscScalar  deltay = 0. 
)

create y and z grid and stretch in y direction using stretching if deltay is nonzero

Returns
0 if successful
Parameters
[in,out]datadata class to hold data
[in]deltaystretching in y direction using hyperbolic stretching function
unsigned SPE::factorial ( unsigned  n)

calculate the factorial of an integer

Returns
n!
Parameters
[out]ninput integer to perform factorial on
PetscInt SPE::get_D_Coeffs ( const PetscScalar  s[],
const PetscInt &  n,
Vec &  output,
const PetscInt &  d = 2 
)

Solve arbitrary stencil points s of length N with order of derivatives d<N can be obtained from equation on MIT website http://web.media.mit.edu/~crtaylor/calculator.html where the accuracy is determined as the usual form O(h^(N-d))

ierr from Ax=b solver

Parameters
[in]sarray of stencil points e.g. [-3,-2,-1,0,1]
[in]nsize of stencil
[out]outputoutput of coefficient values for the given stencil (uninitialized)
[in]dorder of desired derivative (default=2)
int SPE::Init_Mat ( Mat &  A,
const PetscInt &  n 
)

Initialize a Matrix A to be of size nxn.

Returns
0 if successful
Parameters
[out]AA matrix to initialize in MPI (uninitialized)
[in]nnumber of global rows and columns
int SPE::Init_Mat ( Mat &  A,
const PetscInt &  m,
const PetscInt &  n 
)

Initialize a Matrix A to be of size mxn.

Returns
0 if successful
Parameters
[out]AA matrix to initialize in MPI (uninitialized)
[in]mnumber of global rows
[in]nnumber of global columns
int SPE::Init_Vec ( Vec &  x,
const PetscInt &  n 
)

Initialize a vector x to be of size n.

Returns
0 if successful
Parameters
[out]xx vector to initialize in MPI (uninitialized)
[in]nsize of vector
PetscInt SPE::map_D ( Mat &  output,
SPE data,
const PetscInt &  n,
Vec &  yVec,
const PetscInt &  order = 2,
const PetscInt &  d = 2,
const PetscBool &  periodic = PETSC_FALSE,
const PetscBool &  staggered = PETSC_FALSE,
const PetscBool &  reduce_wall_order = PETSC_TRUE 
)

map D matrix operator for specified order and derivative, for a non-uniform mesh

Returns
0 if successful
Parameters
[in,out]outputmatrix(n by n) dth derivative of order O(h^order) assuming uniform xi spacing coming in (initialized), then output a non-uniform derivative w.r.t. y
[in]datadata class to have flags
[in]nlength of y values
[in]yVecy non-uniform data pts of interest
[in]orderorder of accuracy desired (assuming even e.g. 2,4,6,...)
[in]ddth derivative
[in]periodicperiodic boundary
[in]staggeredif setting staggered pressure derivative
[in]reduce_wall_orderreduce the order of accuracy at the wall?
PetscErrorCode SPE::printBaseNonlinearIter ( SPE data,
PetscReal  basenonlinear_error,
PetscInt  basenonlinear_iter 
)

print iteration residuals to screen from baseflow nonlinear iterations

Parameters
[in]datadata class storing iterations and residual values
[in]basenonlinear_errornonlinear error for the baseflow
[in]basenonlinear_iterbase flow nonlinear iteration
PetscErrorCode SPE::printClosureIter ( SPE data)

print iteration residuals to screen from update_Closure iterations

Parameters
[in]datadata class storing iterations and residual values
void SPE::printHeaderIter ( )

print iteration residuals header to screen

PetscErrorCode SPE::printInt ( const PetscInt  x[],
const PetscInt  n = 1,
char const  name[] = "x" 
)

Print PetscInt variable to screen.

Returns
ierr from PetscErrorCode of PetscPrintf
Parameters
[in]xPetscScalar array to print to screen
[in]nsize of scalar array to print
[in]namename of variable to output default to 'x'
PetscInt SPE::printMatASCII ( const Mat &  A,
char const  name[] = "printMatASCII.txt",
const PetscViewerFormat  format = PETSC_VIEWER_DEFAULT 
)

view Petsc Mat variable to ASCII file

  • Helpful runtime option:

-draw_pause <pause> : sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Parameters
[in]APetsc Mat nxn matrix to print to screen
[in]namefilename to write to
[in]formatformat for viewer
PetscInt SPE::printMatASCII ( const Mat &  A,
std::string  name,
const PetscViewerFormat  format = PETSC_VIEWER_DEFAULT 
)

view Petsc Mat variable to ASCII file

  • Helpful runtime option:

-draw_pause <pause> : sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Parameters
[in]APetsc Mat nxn matrix to print to screen
[in]namefilename to write to
[in]formatformat for viewer
void SPE::printMatGetDiagonalASCII ( const Mat &  A,
char const  name[] = "printMatGetDiagonalASCII.txt",
const PetscViewerFormat  format = PETSC_VIEWER_ASCII_MATLAB 
)

print diagonal of Petsc Mat variable to ASCII file

  • Helpful runtime option:

-draw_pause <pause> : sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Parameters
[in]APetsc Mat nxn matrix to print to screen
[in]namefilename to write to
[in]formatformat for viewer
PetscInt SPE::printMatView ( const Mat &  A,
char const  name[] = "A viewer",
const PetscViewerFormat  format = PETSC_VIEWER_DEFAULT 
)

view Petsc Mat variable to screen Open an X-window viewer. Note that we specify the same communicator for the viewer as we used for the distributed vector (PETSC_COMM_WORLD).

  • Helpful runtime option:

-draw_pause <pause> : sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Parameters
[in]APetsc Mat nxn matrix to print to screen
[in]namename of variable to output default to 'A'
[in]formatformat for viewer
PetscErrorCode SPE::printNonlinearIter ( SPE data)

print iteration residuals to screen from update_Nonlinear iterations

Parameters
[in]datadata class storing iterations and residual values
PetscErrorCode SPE::printReal ( const PetscReal  x[],
const PetscInt  n = 1,
char const  name[] = "x",
const PetscViewer  viewer = PETSC_VIEWER_STDOUT_WORLD 
)

Print PetscReal variable to screen.

Returns
ierr from PetscErrorCode of PetscPrintf
Parameters
[in]xPetscReal array to print to screen
[in]nsize of scalar array to print
[in]namename of variable to output default to 'x'
[in]viewerformat for viewer
PetscErrorCode SPE::printScalar ( const PetscScalar  x[],
const PetscInt  n = 1,
char const  name[] = "x",
const PetscViewer  viewer = PETSC_VIEWER_STDOUT_WORLD 
)

Print PetscScalar variable to screen.

Returns
ierr from PetscErrorCode of PetscPrintf
Parameters
[in]xPetscScalar array to print to screen
[in]nsize of scalar array to print
[in]namename of variable to output default to 'x'
[in]viewerformat for viewer
PetscErrorCode SPE::printVec ( const Vec &  x,
const PetscInt  n,
char const  name[] = "x" 
)

Print Vec from PETSc type variable to screen.

Returns
ierr from PetscErrorCode of PetscPrintf
Parameters
[in]xVec array to print to screen
[in]nsize of scalar array to print
[in]namename of variable to output default to 'x'
void SPE::printVecASCII ( const Vec &  b,
char const  name[] = "printVecASCII.txt",
const PetscViewerFormat  format = PETSC_VIEWER_ASCII_MATLAB 
)

view Petsc Vec variable to ASCII file

  • Helpful runtime option:

-draw_pause <pause> : sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Parameters
[in]bPetsc Vec 1xn vector to print to screen
[in]namefilename to write to
[in]formatformat for viewer
void SPE::printVecView ( const Vec &  x,
char const  name[] = "x viewer",
const PetscViewerFormat  format = PETSC_VIEWER_DEFAULT 
)

view PetscVec variable to screen Open an X-window viewer. Note that we specify the same communicator for the viewer as we used for the distributed vector (PETSC_COMM_WORLD).

  • Helpful runtime option:

-draw_pause <pause> : sets time (in seconds) that the program pauses after PetscDrawPause() has been called (0 is default, -1 implies until user input).

Parameters
[in]xPetscScalar array to print to screen
[in]namename of variable to output default to 'x'
[in]formatformat for viewer
int SPE::Read_input_file ( SPE data,
char const  buff[] = "input_file.json" 
)

Read an input file written in json format.

Returns
0 if successful
Parameters
[in,out]datadata class to hold data
[in]bufffilename of binary to read (output of python script
int SPE::Read_MatLab ( SPE data,
std::string &  buff 
)

Read input matrix and vectors input data from a matlab files (be sure this uses the PetscBinaryWrite() MatLab function) Reads and sets y, yVec, z, zVec, q, qp1, alpha, Deltay, and Deltaz quantities in the SPE class.

Returns
ierr
Parameters
[in,out]datadata class to hold data
[in]bufffilename (without endings) of binary matlab files to read (output of matlab script using PetscSpecific binary write functions and fwrite)
PetscErrorCode SPE::Read_MatLabMat ( Mat &  output,
std::string &  buff 
)

Read complex scalar matrix from a matlab file (be sure this uses the PetscBinaryWrite() MatLab function)

Returns
ierr
Parameters
[out]outputcomplex scalar matrix to return after reading file (uninitialized)
[in]bufffilename of binary matlab file to read (output of matlab script using PetscSpecific binary write functions)
PetscErrorCode SPE::Read_MatLabVec ( Vec &  output,
std::string &  buff 
)

Read complex scalar vector from a matlab file (be sure this uses the PetscBinaryWrite() MatLab function)

Returns
ierr
Parameters
[out]outputcomplex scalar vector to return after reading file (uninitialized)
[in]bufffilename of binary matlab file to read (output of matlab script using PetscSpecific binary write functions)
int SPE::Read_q ( SPE data,
std::string &  buff 
)

Read q from a tofile output from python.

Returns
0 if successful
Parameters
[in,out]datadata class to hold data
[in]bufffilename of binary to read (output of python script)
int SPE::Read_q ( Vec &  output,
const int  n,
std::string &  buff 
)

Read q from a tofile output from python.

Returns
0 if successful
Parameters
[in,out]outputvector to return after reading file (already initialized)
[in]nint size of vector
[in]bufffilename of binary to read (output of python script)
int SPE::Read_q ( PetscScalar  output[],
const int  n,
std::string &  buff 
)

Read y from a tofile output from python.

Returns
0 if successful
Parameters
[out]outputvector to return after reading file
[in]nint size of vector
[in]bufffilename of binary to read (output of python script)
int SPE::Read_q ( PetscScalar &  output,
std::string &  buff 
)

Read complex scalar from a tofile output from python.

Returns
0 if successful
Parameters
[out]outputcomplex scalar to return after reading file
[in]bufffilename of binary to read (output of python script)
PetscInt SPE::set_A_and_B_OSS_zi ( SPE data,
const PetscInt &  zi = 0 
)

set A and B matrix for Orr-Sommerfeld equations for zi plane Note that the wavelike ansatz is \(u=\hat{u}(y,z) \exp (i (-\omega t + \alpha x))\)

\[ \begin{aligned} (-i \omega - \frac{1}{Re}(\partial_y^2 + \partial_z^2))\hat{u} + U' \hat{v} &= \alpha (-i \hat{P} - \frac{i}{Re}(\partial_y \hat{v} + \partial_z \hat{w}) - iU \hat{u})\\ (-i \omega - \frac{1}{Re}(\partial_y^2 + \partial_z^2))\hat{v} + \partial_y \hat{P} &= \alpha (- \frac{1}{Re}(\alpha \hat{v}) - iU \hat{v})\\ (\alpha \hat{v}) &= \alpha \cdot \hat{v}\\ (-i \omega - \frac{1}{Re}(\partial_y^2 + \partial_z^2))\hat{w} + \partial_z \hat{P} &= \alpha (- \frac{1}{Re}(\alpha \hat{w}) - iU \hat{w})\\ (\alpha \hat{w}) &= \alpha \cdot \hat{w}\\ \partial_y \hat{v} + \partial_z \hat{w} &= \alpha (-i \hat{u})\\ \end{aligned}\]

Where we have

\[ \begin{aligned} \mathbf{z}_i= \begin{bmatrix} \hat{u}\\ \alpha \hat{v}\\ \hat{v}\\ \alpha \hat{w}\\ \hat{w}\\ \hat{P} \end{bmatrix}_{z=z(i)} \textrm{ and } & \mathbf{q} = \begin{bmatrix} \mathbf{z}_1\\ \mathbf{z}_2\\ \vdots \\ \mathbf{z}_{nz - 1}\\ \mathbf{z}_{nz}\\ \end{bmatrix}\\ \end{aligned}\]

To solve the spatial eigenvalue problem \(\mathbf{\mathcal{A}q} = \alpha \mathbf{\mathcal{B}q}\)

Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]zizi plane of matrix
PetscInt SPE::set_A_and_Ds ( SPE data,
PetscScalar &  alpha 
)

set A and B matrix for SPE equations

Returns
0 if successful
Parameters
[in,out]datadata class containing all matrices, vectors, scalars, and problem size
[in]alpha\( \alpha \) eigenvalue from previous iteration
PetscInt SPE::set_A_and_Ds ( SPE data)

set A and B matrix for SPE equations, this is called from set_A_and_Ds(data,alplha) function This is used to set the full 3D operators (y,z, and t)

Returns
0 if successful
Parameters
[in,out]datadata class containing all matrices, vectors, scalars, and problem size
PetscInt SPE::set_A_and_Ds_nonlinear ( SPE data)

set A and D matrix linear terms for SPE equations for nonlinear terms

Returns
0 if successful
Parameters
[in,out]datadata class to store values
PetscInt SPE::set_A_and_Ds_zi ( SPE data,
PetscScalar &  alpha,
const PetscInt &  zi = 0 
)

set A and B matrix linear terms for SPE equations for zi plane (also sets the permutation matrices to extract u from q, etc.

Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]alphaeigenvalue from previous iteration
[in]zizi plane of matrix
PetscInt SPE::set_b ( const Mat &  B,
const Vec &  qn,
Vec &  b 
)

set b vector from B and q as b=B*q

Returns
0 if successful
Parameters
[in]BB matrix
[in]qnqn vector to multiply
[in,out]bb Vec (already initialized)
PetscInt SPE::set_BCs ( Mat &  A,
Vec &  b,
const PetscInt &  ny,
const PetscInt &  nz 
)

sets Boundary Condition equations in Matrix A and vector b in Ax=b linear system for solving the SPE equations

Returns
0 if successful
Parameters
[in,out]AA matrix (already initialized)
[in,out]bb Vec (already initialized)
[in]nysize of y array
[in]nzsize of z array
PetscInt SPE::set_BCs ( SPE data)

sets Boundary Condition equations in Matrix A and Matrix B in A+ B*dqdx=0 linear system for solving the SPE equations

Returns
0 if successful
Parameters
[in]datadata class for flags
PetscInt SPE::set_Crank_Nicolson_Advance ( SPE data,
Vec &  q,
PetscScalar &  alpha 
)

set up Crank-Nicolson advancing matrices A x = b system by creating matrices and setting BCs

Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]qq at last marching step
[in]alphaeigenvalue from previous step
PetscInt SPE::set_D ( const PetscScalar  y[],
const PetscScalar  yP[],
const PetscInt &  n,
Mat &  output,
SPE data,
const PetscInt &  order = 2,
const PetscInt &  d = 2,
const PetscBool &  periodic = PETSC_FALSE,
const PetscBool &  staggered = PETSC_FALSE,
const PetscBool &  reduce_wall_order = PETSC_TRUE,
const PetscBool &  uniform = PETSC_TRUE 
)

set D matrix operator for specified order and derivative

Returns
0 if successful

if odd derivative

if odd derivative

if odd derivative

if odd derivative

Parameters
[in]yarray of y values
[in]yParray of y values of semi-staggered pressure locations (size ny-1)
[in]nlength of y values
[out]outputmatrix(n by n) dth derivative of order O(h^order) assuming uniform y spacing (uninitialized)
[in]datadata class to have flags
[in]orderorder of accuracy desired (assuming even e.g. 2,4,6,...) (default 2)
[in]ddth derivative (default 2)
[in]periodicperiodic boundary (default false)
[in]staggeredif setting staggered pressure derivative (default false)
[in]reduce_wall_orderreduce the order of accuracy at the wall? (default true)
[in]uniformuniform mesh? (default true)
PetscInt SPE::set_D ( SPE data)

set D matrices and operators for use in OSS and SPE

Returns
0 if successful
Parameters
[in]datadata class to have flags
PetscInt SPE::SPE::set_D_fourier ( const PetscInt  N,
const PetscScalar &  T,
Mat &  output,
const PetscInt &  d = 1 
)

set D matrix operator for specified derivative using fouier collocated points

Returns
0 if successful
Parameters
[in]Nlength of collocated points
[in]Tperiod of y values
[out]outputmatrix(n by n) dth derivative of order O(h^order) assuming uniform y spacing (uninitialized)
[in]ddth derivative (default 1)
PetscInt SPE::set_Euler_Advance ( SPE data,
Vec &  q,
PetscScalar &  alpha 
)

set up Euler advancing matrices A x = b system by creating matrices and setting BCs

Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]qq at last marching step
[in]alphaeigenvalue \( \alpha \) from the previous iteration
int SPE::set_input_value ( Json::Value val,
const char  buff[],
PetscInt &  v 
)

take Json data and save it to value if it exists

Returns
0 if successful
Parameters
valJson file after reading
buffmatching key to check if it exits, if it does, set the value
vvalue to set if key is matching
int SPE::set_input_value ( Json::Value val,
const char  buff[],
PetscReal &  v 
)

take Json data and save it to value if it exists

Returns
0 if successful
Parameters
valJson file after reading
buffmatching key to check if it exits, if it does, set the value
vvalue to set if key is matching
int SPE::set_input_value ( Json::Value val,
const char  buff[],
PetscScalar &  v 
)

take Json data and save it to value if it exists

Returns
0 if successful
Parameters
valJson file after reading
buffmatching key to check if it exits, if it does, set the value
vvalue to set if key is matching
int SPE::set_input_value ( Json::Value val,
const char  buff[],
PetscBool &  v 
)

take Json data and save it to value if it exists

Returns
0 if successful
Parameters
valJson file after reading
buffmatching key to check if it exits, if it does, set the value
vvalue to set if key is matching
int SPE::set_input_value ( Json::Value val,
const char  buff[],
char *  v 
)

take Json data and save it to value if it exists

Returns
0 if successful
Parameters
valJson file after reading
buffmatching key to check if it exits, if it does, set the value
vvalue tos et if key is matching (string)
int SPE::set_input_value ( Json::Value val,
const char  buff[],
std::string &  v 
)

take Json data and save it to value if it exists

Returns
0 if successful
Parameters
valJson file after reading
buffmatching key to check if it exits, if it does, set the value
vvalue tos et if key is matching (string)
PetscInt SPE::set_Mat ( const PetscScalar *const *  Ain,
const PetscInt &  n,
Mat &  A,
const InsertMode &  addv = ADD_VALUES 
)

set a matrix from PetscScalar 2D matrix to PETSc Mat type in parallel

Returns
0 if successful
Parameters
[in]AinMatrix set on all processors as 2D array
[in]nsize of nxn matrix
[out]AMat to SetValues and output in parallel (uninitialized)
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_Mat ( const PetscScalar &  diag,
const PetscInt &  n,
Mat &  A,
const PetscInt &  k = 0,
const PetscBool &  parallel = PETSC_TRUE,
const InsertMode &  addv = ADD_VALUES 
)

set a diagonal of a matrix from scalar

Returns
0 if successful
Parameters
[in]diagscalar value to set as diagonal in matrix
[in]nsize of nxn matrix
[in,out]AMat to SetValues and output in parallel (already initialized)
[in]kdiagonal offset in matrix (k=0 is main diagonal, k>0 is above main diagonal, k<0 is below main diagonal) default is 0
[in]parallelset the matrix using Istart and Iend
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_Mat ( Mat &  A)

Assemble matrix.

Returns
0 if successful
Parameters
[in,out]AMat to assemble (already initialized)
PetscInt SPE::set_Mat ( const PetscScalar &  value,
const PetscInt &  row,
const PetscInt &  col,
Mat &  A,
const PetscBool &  parallel = PETSC_TRUE,
const InsertMode &  addv = ADD_VALUES 
)

set a single value in matrix at row,col

Returns
0 if successful
Parameters
[in]valuevalue to set in Mat A
[in]rowspecified global row in Mat A
[in]colspecified global col in Mat A
[in,out]AMatrix A to set value (already initialized)
[in]paralleldo this in parallel?
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_Mat ( const PetscScalar &  a,
const Mat &  Asub,
const PetscInt &  nsub,
Mat &  A,
const PetscInt &  n,
const PetscInt &  rowoffset = 0,
const PetscInt &  coloffset = 0,
const InsertMode &  addv = ADD_VALUES 
)

set a submatrix Asub in a matrix A

Returns
0 if successful
Parameters
[in]apremultple to Asub
[in]Asubsub matrix to set into mat
[in]nsubnxn size of square sub matrix Asub
[in,out]AMatrix A to set value (already initialized)
[in]nsize of square Matrix A
[in]rowoffsetstart inserting Asub in A starting at rowoffset row
[in]coloffsetstart inserting Asub in A starting at coloffset column
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_Mat ( const PetscScalar *  Ain,
const PetscInt &  row,
const PetscInt &  ncols,
const PetscInt  cols[],
Mat &  A,
const InsertMode &  addv = ADD_VALUES 
)

set a row of PetscScalar to a matrix to PETSc Mat

Returns
0 if successful
Parameters
[in]Ainarray to set in row of matrix
[in]rowrow to set in matrix
[in]ncolsncols of array
[in]colscols to set in matrix
[in,out]AMat to SetValues and output in parallel (already initialized)
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_Mat ( const PetscScalar &  a,
const Mat &  Dz,
const PetscInt &  nz,
const PetscInt &  ny,
const PetscInt &  zi,
Mat &  A,
const PetscInt &  n,
const PetscInt &  nvars = 4,
const PetscInt &  rowoffset = 0,
const PetscInt &  coloffset = 0,
const InsertMode &  addv = ADD_VALUES 
)

set a Dz submatrix into A

Returns
0 if successful
Parameters
[in]apremultple to Dz
[in]Dzsub matrix to set into mat in z direction
[in]nz\(n_z \times n_z \) size of square sub matrix Dz
[in]nylength of \( y \) array
[in]ziwhich \( z \) plane you are looking at
[in,out]AMatrix A to set value (already initialized)
[in]nsize of square Matrix A
[in]nvarsnumber of variables in vector 4 if (u,v,w,P) or 6 if (u, v, av, w, aw, P)
[in]rowoffsetstart inserting Asub in A starting at rowoffset row
[in]coloffsetstart inserting Asub in A starting at coloffset column
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_Mat_aPDdim_to_A ( PetscScalar  a,
Mat &  P,
Mat &  D,
Mat &  A 
)
Returns
0 if successful
Parameters
[in]aScalar to multiply Ddim by
[in]PPermutation matrix to change block diagonal to fit desired input into A
[in]DDerivative matrix (or similar) of size A
[in,out]AMatrix that A += a*P (@ is matrix multiply)
PetscInt SPE::set_Mat_broadcast_from_colVec ( Vec &  x,
PetscInt &  n,
Mat &  A 
)

set a matrix from a column vector (broadcast the column vector to all columns of a matrix Be sure that A is already initialized

Returns
0 if successful
Parameters
[in]xcolumn Vec
[in]nlength of Vec
[out]AMatrix of size nxn
PetscInt SPE::set_Mat_from_Vec ( Vec &  x,
PetscInt &  ny,
PetscInt &  nz,
PetscInt &  rowoffset,
Mat &  A,
const InsertMode &  addv = ADD_VALUES 
)

set a matrix A (large ny*nz*4) from a vector (ny*nz) (used in the diagonals) at a certain rowoffset (between 0-ny*3). Be sure that A is already initialized

Returns
0 if successful
Parameters
[in]xcolumn Vec
[in]nylength of Vec is ny*nz
[in]nzlength of Vec is ny*nz
[in]rowoffsetstart inserting Vec in A starting at rowoffset row
[in,out]AMatrix of size ny*nz*4
[in]addvinsert values or add values to matrix A (default ADD_VALUES)
PetscInt SPE::set_Mat_kron ( const Mat &  A,
const Mat &  B,
Mat &  C 
)

Kronecker tensor product of two matrices A and B to make C If A is m by n, and B is p by q, then C will be m*p by n*q matrix formed by taking all possible products between the elements of A and the matrix B. See wikipedia for more information here.

Returns
0 if successful
Parameters
[in]AFirst matrix \(m \times n\)
[in]BSecond matrix \(p \times q\)
[out]Coutput matrix \(mp \times n*q\)
PetscInt SPE::set_MatDiagonalScale ( const Mat &  diag_to_scale,
const Mat &  Asub,
const PetscInt &  nsub,
Mat &  A,
const PetscInt &  n,
const PetscInt &  rowoffset = 0,
const PetscInt &  coloffset = 0,
const InsertMode &  addv = ADD_VALUES 
)

set a scaled matrix, (rows are scaled by matrix, using A=LA and MatDiagonalScale)

Returns
0 if successful
Parameters
[in]diag_to_scalepremultple to scale the rows of Asub
[in]Asubsub matrix to set into mat
[in]nsubnxn size of square sub matrix Asub
[in,out]AMatrix A to set value (already initialized)
[in]nsize of square Matrix A
[in]rowoffsetstart inserting Asub in A starting at rowoffset row
[in]coloffsetstart inserting Asub in A starting at coloffset column
[in]addvinsert values or add values to matrix A
PetscInt SPE::set_P ( SPE data)

set permutation matrices and operators for use in OSS and SPE

Returns
0 if successful
Parameters
[in]datadata class to have flags
PetscInt SPE::set_Vec ( const PetscScalar *  bin,
const PetscInt &  n,
Vec &  b,
const PetscBool &  parallel = PETSC_TRUE 
)

set a vector from PetscScalar 1D vector to PETSc Vec type in parallel

Returns
0 if successful
Parameters
[in]binarray set on all processors as 1D array
[in]nsize of n array
[in,out]bVec to SetValues and output in parallel (already initialized)
[in]parallelset in parallel
PetscInt SPE::set_Vec ( Vec &  b)

Assemble b vector.

Returns
0 if successful
Parameters
[in,out]barray to assemble on all processors
PetscInt SPE::set_Vec ( const PetscScalar &  bin,
const PetscInt &  n,
Vec &  b 
)

set a vector from PetscScalar to PETSc Vec in location n

Returns
0 if successful
Parameters
[in]binscalar to set into Vec
[in]nlocation to put into Vec
[in,out]bVec to SetValues (already initialized)
PetscInt SPE::set_Vec ( const Vec &  inVec,
const PetscInt &  low,
const PetscInt &  hi,
Vec &  b 
)

set a subvector from larger vector from low to hi indices

Returns
0 if successful
Parameters
[in]inVeclarger vec to copy values from
[in]lowlower bound
[in]hiupper bound
[in,out]bVec to SetValues and output (already initialized)
PetscInt SPE::set_Vec_linspace ( PetscScalar  a,
const PetscScalar  b,
const PetscInt  n,
PetscScalar  y[] 
)

set values of y, use linspace similar to matlab, creates on every processor

Returns
0 if successful
Parameters
[in]alower bound
[in]bupper bound
[in]nupper bound
[out]ylinspace output vector (already initialized to right size)
int SPE::trapz ( const Vec &  q,
PetscScalar &  I,
SPE data 
)

trapezoidal rule on Vec with ny,nz values

Returns
0 if successful
Parameters
[in]qVector to integrate
[out]Ivalue of integration
[out]datadata class to store Trapzy and Trapzz value and flags
PetscErrorCode SPE::trapz_4nynznt ( const Vec &  q,
PetscScalar &  I,
SPE data 
)

trapezoidal rule on Vec with 4,ny,nz,nt values

Returns
0 if successful
Parameters
[in]qVector to integrate
[out]Ivalue of integration
[out]datadata class to store Trapzy and Trapzz value and flags
int SPE::update_Closure ( SPE data,
Vec &  q,
Vec &  qp1,
PetscScalar &  alpha,
const PetscInt &  maxiter = 50 
)

calculate the closure equation \( \int_\Omega \hat{\textbf{q}}^\dagger \hat{\textbf{q}}_x dy \) and output the result This is part of the solution procedure shown in the bottom half of this diagram

SolutionProcedure.png
Solution Procedure
Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]qq at previous marching step
[in,out]qp1current marching step
[in,out]alpha\( \alpha \) value at current marching step
[in]maxitermaximum number of iterations (not implimented)
int SPE::update_Nonlinear ( SPE data,
Vec &  q,
Vec &  qp1,
PetscScalar &  alpha_old,
PetscScalar &  alpha,
PetscScalar &  Ialpha_old,
PetscScalar &  Ialpha,
const PetscInt &  maxiter = 50 
)

advance the Nonlinear SPE system one x step

Returns
0 if successful
Parameters
[in,out]datadata class to store values
[in]qq at previous marching step
[in,out]qp1current marching step
[in,out]alpha_old\( \alpha \) value at previous marching step (will be updated)
[in,out]alpha\( \alpha \) value at current marching step
[in,out]Ialpha_old\( \int_{x_0}^{x_{i+1}} \alpha dx \) value at previous marching step
[in,out]Ialpha\( \int_{x_0}^{x_{i+1}} \alpha dx \) value at current marching step
[in]maxitermaximum number of iterations (not implimented)