Helper - Functions
Index
PeriLab.Solver.Helpers.check_inf_or_nan
PeriLab.Solver.Helpers.find_files_with_ending
PeriLab.Solver.Helpers.find_indices
PeriLab.Solver.Helpers.find_inverse_bond_id
PeriLab.Solver.Helpers.get_active_update_nodes
PeriLab.Solver.Helpers.get_fourth_order
PeriLab.Solver.Helpers.invert
PeriLab.Solver.Helpers.matrix_style
PeriLab.Solver.Helpers.progress_bar
PeriLab.Solver.Helpers.qdim
PeriLab.Solver.Helpers.rotate
PeriLab.Solver.Helpers.rotate_second_order_tensor
Helpers
PeriLab.Solver.Helpers.check_inf_or_nan
— Methodcheck_inf_or_nan(array, msg)
Checks if the sum of the array is finite. If not, an error is raised.
Arguments
array
: The array to check.msg
: The error message to raise.
Returns
Bool
:true
if the sum of the array is finite,false
otherwise.
PeriLab.Solver.Helpers.find_files_with_ending
— Methodfind_files_with_ending(folder_path::AbstractString, file_ending::AbstractString)
Returns a list of files in folder_path
that end with file_ending
.
Arguments
folder_path::AbstractString
: The path to the folder.file_ending::AbstractString
: The ending of the files.
Returns
file_list::Vector{String}
: The list of files that end withfile_ending
.
PeriLab.Solver.Helpers.find_indices
— Methodfind_indices(vector, what)
Returns the indices of vector
that are equal to what
.
Arguments
vector::Vector
: The vector to search in.what
: The value to search for.
Returns
indices::Vector
: The indices ofvector
that are equal towhat
.
PeriLab.Solver.Helpers.find_inverse_bond_id
— Methodfind_inverse_bond_id(nlist::Vector{Vector{Int64}})
Finds the inverse of the bond id in the nlist.
Arguments
nlist::Vector{Vector{Int64}}
: The nlist to find the inverse of.
Returns
inverse_nlist::Vector{Dict{Int64,Int64}}
: The inverse nlist.
PeriLab.Solver.Helpers.get_active_update_nodes
— Methodget_active_update_nodes(active::Vector{Bool}, update_list::Vector{Bool}, nodes::Vector{Int64}, index::Vector{Int64})
Returns the active nodes and the update nodes.
Arguments
active::Vector{Bool}
: The active vector.update_list::Vector{Bool}
: The update vector.nodes::Vector{Int64}
: The vector of nodes.index::Vector{Int64}
: Pre allocated Vector.
Returns
update_nodes::Vector{Int64}
: The nodes ofupdate
that are true.
PeriLab.Solver.Helpers.get_fourth_order
— Methodget_fourth_order(CVoigt, dof)
Constructs a symmetric fourth-order tensor from a Voigt notation vector. It uses Tensors.jl package.
This function takes a Voigt notation vector CVoigt
and the degree of freedom dof
to create a symmetric fourth-order tensor. The CVoigt
vector contains components that represent the tensor in Voigt notation, and dof
specifies the dimension of the tensor.
Arguments
CVoigt::Matrix{Float64}
: A vector containing components of the tensor in Voigt notation.dof::Int64
: The dimension of the resulting symmetric fourth-order tensor.
Returns
SymmetricFourthOrderTensor{dof}
: A symmetric fourth-order tensor of dimensiondof
.
Example
```julia CVoigt = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] dof = 3 result = getfourthorder(CVoigt, dof)
PeriLab.Solver.Helpers.invert
— Functioninvert(A::Union{Matrix{Float64},Matrix{Int64}}, error_message::String="Matrix is singular")
Invert a n x n matrix. Throws an error if A is singular.
Arguments
- A::Union{Matrix{Float64},Matrix{Int64}}: A n x n matrix.
- error_message::String="Matrix is singular": The error message returned if A is singular.
Returns
- inverted matrix or nothing if not inverable.
PeriLab.Solver.Helpers.matrix_style
— Methodmatrix_style(A)
Include a scalar or an array and reshape it to style needed for LinearAlgebra package
Arguments
A
: The array or scalar to reshape
Returns
Array
: The reshaped array
PeriLab.Solver.Helpers.progress_bar
— Methodprogress_bar(rank::Int64, nsteps::Int64, silent::Bool)
Create a progress bar if the rank is 0. The progress bar ranges from 1 to nsteps + 1.
Arguments
- rank::Int64: An integer to determine if the progress bar should be created.
- nsteps::Int64: The total number of steps in the progress bar.
- silent::Bool: de/activates the progress bar
Returns
- ProgressBar or UnitRange: If rank is 0, a ProgressBar object is returned. Otherwise, a range from 1 to nsteps + 1 is returned.
PeriLab.Solver.Helpers.qdim
— Methodqdim(order::Int64, dof::Int64)
Calculate the number of terms in a polynomial expansion up to a specified accuracy order. Simplied first complex loop in Peridigm correspondence::computeLagrangianGradientWeights. In the unit test this values where tested.
Arguments
order::Int64
: The accuracy order of the polynomial expansion.
Returns
Int64
: The total number of terms in the polynomial expansion.
Description
This function calculates the number of terms in a polynomial expansion up to the specified accuracy order using an analytical formula derived from combinatorial considerations. The function iterates over each order from 1 to the specified order
and calculates the sum of binomial coefficients according to the formula: qdim(order) = Σ(i=1 to order) [(i+2)! / (2! * i!)]
PeriLab.Solver.Helpers.rotate
— Methodrotate(nodes::Union{SubArray,Vector{Int64}}, dof::Int64, matrix::Union{SubArray,Array{Float64,3}}, angles::SubArray, back::Bool)
Rotates the matrix.
Arguments
nodes::Union{SubArray,Vector{Int64}}
: List of block nodes.matrix::Union{SubArray,Array{Float64,3}}
: Matrix.rot::SubArray
: Rotation tensor.back::Bool
: Back.
Returns
matrix::SubArray
: Matrix.
PeriLab.Solver.Helpers.rotate_second_order_tensor
— Methodrotate_second_order_tensor(angles::Union{Vector{Float64},Vector{Int64}}, tensor::Matrix{Float64}, dof::Int64, back::Bool)
Rotates the second order tensor.
Arguments
angles::Union{Vector{Float64},Vector{Int64}}
: Angles.tensor::Matrix{Float64}
: Second order tensor.dof::Int64
: Degree of freedom.back::Bool
: Back.
Returns
tensor::Matrix{Float64}
: Second order tensor.