Misccellaneous

Miscellaneous

UtilsModule.

Module Utils: This module holds miscellaneous functions used throughout the code

source
Utils.TimingsType.

Utils.Timings

This type accumulates the time spent in each part of the code.

source

###Utils.absvalue_deriv

Computes the derivative of the absolute value of a variable w.r.t itself

Inputs

  • val : The variable whose derivative needs to be computed e.r.t itself

source

Permute the columns of A according to permvec. See applyPermRow for the definition of a permvec. Note that for column permutation the interpretation is that destination column permvec[i] comes from source column i. This is consistent with the notion that post-multiplying by a permutation matrix (obtained from permMatrix) is a column permutation, i.e B = A*P

Aliasing: no aliasing allowed

source

Like applyPermColumn, but the result is returned in A. Both A and B are overwritten

Aliasing: no aliasing allowed

source
Utils.applyPermRowMethod.

Permute the rows of A according to the permvec, storing the result in B The permvec contains the source indices for each entry in B, ie. B[i] comes from A[permvec[i]]. This is consistent with the mathematical definition of a permutation that pre-multiplication by a permutation matrix (obtained from permMatrix) is a row permutation, ie. B = P*A

Aliasing: no aliasing allowed

source

Like applyPermRow, but the result is returned in A. Both A and B are overwritten.

Aliasing: no aliasing allowed

source
Utils.array1DTo3DMethod.

Utils.array1DTo3D

This takes eqn.q_vec (the initial state), and disassembles it into eqn.q, the 3 dimensional array. This function uses mesh.dofs to speed the process.

This function also calls writeQ to do any requested output.

Inputs: mesh sbp eqn opts

This is a mid level function, and does the right thing regardless of equation dimension.

The DG method for array1DTo3D assumes that q and q_vec refer to the same memory address, and therefore does no explicit writing/copying.

Aliasing restrictions: none

source
Utils.array3DTo1DMethod.

Utils.array3DTo1D

This function takes the 3D array of variables in arr and reassembles it into the vector res_vec. Note that This is a reduction operation and zeros res_vec before performing the operation, unless zero_resvec is set to false

This is a mid level function, and does the right thing regardless of equation dimension

source
Utils.calcBCNormalMethod.

Calculate the scaled normal vector in parametric coordinates from the face normal and scaled mapping jacobian. nrm2 is overwritten with the result.

source

This function computes the Euclidian norm of a vector where each MPI process owns part of the vector

Inputs: comm: an MPI communicator vec: the local part of the vector

Outputs: val: the Euclidian norm of the entire vector

Note that unlike calcNorm, the time spent in the Allreduce is not logged for this function.

source

This function calculate the SBP approximation to the L2 inner product of two vectors of length mesh.numDof.

L2_product = u^T H conj(v)

Note that this function does not take a square root like calcNorm does.

Inputs

  • eqn: AbstractSolutionData

  • u: first vector, of length mesh.numDof

  • v: second vector, of length mesh.numDof. If complex, this vector gets conjugated

Outputs

  • val: the value of the inner product

Keyword Arguments

  • globalnrm: if true, computes the norm of the entire (parallel) vector, if false, computes the norm of only the local part

source
Utils.calcMeshHMethod.

Utils.calcMeshH

This function calculates the average distance between nodes over the entire mesh. This function allocates a bunch of temporary memory, so don't call it too often. This is, strictly speaking, not quite accurate in parallel because the divison by length happens before the allreduce.

Inputs: mesh eqn opts

source
Utils.calcNormMethod.

Utils.calcNorm

This function calculates the norm of a vector (of length numDof) using the SBP norm.

Inputs:
  eqn:  an AbstractSolutionData
  res_vec:  vector to calculate the norm of

Keyword arguments:
  strongres: if res_vec is the residual of the weak form, then
             strongres=true computes (efficiently) the norm of the strong
             form residual.  Default false
  globalnrm: compute the norm over all processes or not. Default true

Returns:
  val:  norm of solution using SBP norm (Float64)

There are no restrctions on the datatype of res_vec (ie. it can be complex)

Aliasing restrictions: none
source
Utils.fastscale!Method.

This function scales an array by a constant, and should be faster than scale! because it is branch free

source
Utils.fastzero!Method.

This function zeros out an array, and should be faster than fill! (branch free)

Inputs/Outputs: x: an array

source
Utils.freeMethod.

Generic function to free any memory belonging to other libraries

source
Utils.inversePermMethod.

Compute the permutation vector that corresponds to the inverse permutation

Inputs: permvec: the original permutation vector

Inputs/Outputs: invperm: the inverse permutation vector

Aliasing: no aliasing allowed

source
Utils.permMatrix!Method.

Create a permutation matrix from a permutation vector. Only select entries of A are overwritten.

source
Utils.permMatrixMethod.

Create a permutation matrix from a permutation vector. The element type of the returned matrix is Int.

source

Set the complex part of the solution to zero, including eqn.q, eqn.q_vec, and the send and receive buffers in eqn.shared_data

Inputs

  • mesh

  • sbp

  • eqn

  • opts

source
Utils.writeQMethod.

Utils.writeQ

This function writes the real part of the solution variables eqn.q to a space delimited file called q.dat, controlled by the input options 'writeq', of type bool

This is a high level function.

source

Utils.write_timings

Write the values in a Timings object to a file. Also writes the names of fields to a separate file.

Inputs: t: a Timings object fname: the file name, without extension

The values are written to the file fname.dat, and the names are written to fname_names.dat

source
Utils.@verbose1Macro.

Utils.verbose1

This macro introduces an if statement that causes the expression to be executed only if the variable verbose is greater than or equal to 1. verbose must exist in the scope of the caller

source
Utils.@verbose2Macro.

Utils.verbose2

This macro introduces an if statement that causes the expression to be executed only if the variable verbose is greater than or equal to 2. verbose must exist in the scope of the caller

source
Utils.@verbose3Macro.

Utils.verbose3

This macro introduces an if statement that causes the expression to be executed only if the variable verbose is greater than or equal to 3. verbose must exist in the scope of the caller

source
Utils.@verbose4Macro.

Utils.verbose4

This macro introduces an if statement that causes the expression to be executed only if the variable verbose is greater than or equal to 4. verbose must exist in the scope of the caller

source
Utils.@verbose5Macro.

Utils.verbose5

This macro introduces an if statement that causes the expression to be executed only if the variable verbose is greater than or equal to 5. verbose must exist in the scope of the caller

source