General Helpers
General utility functions that are used throughout Mantis.
All docstrings from Mantis.GeneralHelpers
Mantis.GeneralHelpers.export_path Method
export_path(output_directory_tree::Vector{String}, filename::String)Create a directory (if needed) and return the path to the output file.
Arguments
output_directory_tree::Vector{String}: A vector of strings representing the directory tree.filename::String: The name of the output file.
Example
output_file = export_path(["examples", "data", "output"], "output.vtk") # "examples/data/output/output.vtk"Mantis.GeneralHelpers.get_derivative_idx Function
get_derivative_idx(der_key::Vector{Int})Convert the given derivative key to a linear index corresponding to its storage location.
If local_basis corresponds to basis evaluations for some manifold_dim-variate function space, then its k-th derivatives will all be stored in the location local_basis[k+1]. Moreover, the k-th derivative corresponding to the key [i₁,i₂,...,iₙ] in the location local_basis[k+1][m] where:
m = 1wheniⱼ = 0for allj, i.e., for basis function values;m = 1+rwheniⱼ = 0for alljexcept forj = randiⱼ = 1, i.e., for the first derivative w.r.t. thej-th canonical coordinate;in all other cases (i.e., when
k>1), the value ofmis equal tolif[i₁,i₂,...,iₙ]is thel-th key returned by the functioninteger_sums(k, manifold_dim).
As an example, consider the first derivative with respect to x₁ (∂/∂x₁) in 2D, which has key [1, 0]. In 3D, this same derivative has key [1, 0, 0]. In 3D, the derivative ∂³/∂x₁²∂x₂ thus has key [2, 1, 0].
Arguments
der_key::Vector{Int}: A key for the desired derivative order.
Returns
::Int: The linear index corresponding to the derivative's storage location in basis evaluations.
Mantis.GeneralHelpers.integer_sums Function
integer_sums(sum_indices::Int, num_indices::Int)Generates all possible combinations of non-negative integers that sum up to a given value, where each combination has a specified number of elements.
Arguments
sum_indices::Int: The target sum of the integers in each combination.num_indices::Int: The number of integers in each combination.
Returns
::Vector{Vector{Int}}: Each inner vector represents a combination of integers that sum up tosum_indices. If no valid combinations exist, the vectors are empty.