Miscellaneous
Utils
— Module.Module Utils: This module holds miscellaneous functions used throughout the code
Utils.Timings
— Type.Utils.Timings
This type accumulates the time spent in each part of the code.
Utils.absvalue_deriv
— Method.###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
Utils.applyPermColumn
— Method.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
Utils.applyPermColumnInplace
— Method.Like applyPermColumn, but the result is returned in A. Both A and B are overwritten
Aliasing: no aliasing allowed
Utils.applyPermRow
— Method.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
Utils.applyPermRowInplace
— Method.Like applyPermRow, but the result is returned in A. Both A and B are overwritten.
Aliasing: no aliasing allowed
Utils.array1DTo3D
— Method.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
Utils.array3DTo1D
— Method.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
Utils.calcBCNormal
— Method.Calculate the scaled normal vector in parametric coordinates from the face normal and scaled mapping jacobian. nrm2
is overwritten with the result.
Utils.calcEuclidianNorm
— Method.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.
Utils.calcL2InnerProduct
— Method.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
Utils.calcMeshH
— Method.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
Utils.calcNorm
— Method.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
Utils.fastscale!
— Method.This function scales an array by a constant, and should be faster than scale! because it is branch free
Utils.fastzero!
— Method.This function zeros out an array, and should be faster than fill! (branch free)
Inputs/Outputs: x: an array
Utils.free
— Method.Generic function to free any memory belonging to other libraries
Utils.inversePerm
— Method.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
Utils.permMatrix!
— Method.Create a permutation matrix from a permutation vector. Only select entries of A are overwritten.
Utils.permMatrix
— Method.Create a permutation matrix from a permutation vector. The element type of the returned matrix is Int.
Utils.removeComplex
— Method.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
Utils.writeQ
— Method.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.
Utils.write_timings
— Method.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
Utils.@verbose1
— Macro.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
Utils.@verbose2
— Macro.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
Utils.@verbose3
— Macro.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
Utils.@verbose4
— Macro.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
Utils.@verbose5
— Macro.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