Helper - Functions
Index
PeriLab.Helpers.check_inf_or_nanPeriLab.Helpers.compute_free_surface_nodesPeriLab.Helpers.create_centroid_and_search_radiusPeriLab.Helpers.find_files_with_endingPeriLab.Helpers.find_indicesPeriLab.Helpers.find_inverse_bond_idPeriLab.Helpers.get_active_update_nodesPeriLab.Helpers.get_block_nodesPeriLab.Helpers.get_fourth_orderPeriLab.Helpers.get_hexagonPeriLab.Helpers.get_ringPeriLab.Helpers.invertPeriLab.Helpers.matrix_stylePeriLab.Helpers.matrix_to_vectorPeriLab.Helpers.matrix_to_vectorPeriLab.Helpers.progress_bar_stable_typePeriLab.Helpers.qdimPeriLab.Helpers.rotatePeriLab.Helpers.rotate_second_order_tensorPeriLab.Helpers.vector_to_matrixPeriLab.Helpers.voigt_to_matrix
Helpers
PeriLab.Helpers.check_inf_or_nan — Method
check_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:trueif the sum of the array is finite,falseotherwise.
PeriLab.Helpers.compute_free_surface_nodes — Method
compute_surface_nodes_and_connections(points::Union{Matrix{Float64},Matrix{Int64}},
poly, free_surfaces::Vector{Int64})Computes the points which are connected free surfaces (()). This function is used for contact search purposes. The free surface nodes are used to compute the nearest neighbors. The connections and underlying points are needed for the contact algorithm. They are a subset of the surface points to create the polyhedron and the only ones which can be in contact.
Arguments
points::Union{Matrix{Float64},Matrix{Int64}}: Points which form the polyhedron.poly: Polyhedron object.free_surfaces::Vector{Int64}: List of the free surfaces of the polyhedron.
Returns
connections: Tthe connections to the free surfaces. There can be more surface points than connections.
PeriLab.Helpers.create_centroid_and_search_radius — Method
create_centroid_and_search_radius(coor::Union{Matrix{Float64},Matrix{Int64}},
el_topology::Matrix{Int64},
dof::Int64,
fu)Computes the centroid and Contact Radius for each element in a given mesh.
Arguments
coor::Union{Matrix{Float64}, Matrix{Int64}}: A matrix of size(N x dof), where each row represents the coordinates of a point in the space.el_topology::Matrix{Int64}: A matrix of size(M x num_nodes), where each row contains the indices of points that define an element.dof::Int64: The number of spatial dimensions (degrees of freedom), e.g.,2for 2D and3for 3D.fu: A function of four point 2D surface or eight point 3D volume.
Returns
el_centroid::Matrix{Float64}: A matrix of size(M × dof), where each row represents the centroid of an element.search_radius::Vector{Float64}: A vector of sizeM, where each entry is the maximum distance from the element centroid to any of its nodes.
PeriLab.Helpers.find_files_with_ending — Method
find_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.Helpers.find_indices — Method
find_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 ofvectorthat are equal towhat.
PeriLab.Helpers.find_inverse_bond_id — Method
find_inverse_bond_id(nlist::BondScalarState{Int64})Finds the inverse of the bond id in the nlist.
Arguments
nlist::BondScalarState{Int64}: The nlist to find the inverse of.
Returns
inverse_nlist::Vector{Dict{Int64,Int64}}: The inverse nlist.
PeriLab.Helpers.get_active_update_nodes — Method
get_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 ofupdatethat are true.
PeriLab.Helpers.get_block_nodes — Method
get_block_nodes(block_ids, nnodes)Returns a dictionary mapping block IDs to collections of nodes.
Arguments
block_ids::Vector{Int64}: A vector of block IDsnnodes::Int64: The number of nodes
Returns
block_nodes::Dict{Int64,Vector{Int64}}: A dictionary mapping block IDs to collections of nodes
PeriLab.Helpers.get_fourth_order — Method
get_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
Array{Float64,4}: A symmetric fourth-order tensor of dimensiondof.
Example
CVoigt = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
dof = 3
result = get_fourth_order(CVoigt, dof)PeriLab.Helpers.get_hexagon — Method
get_hexagon(coor::Union{Matrix{Float64},Matrix{Int64}}, topo::Vector{Int64})Description
This function gives the hexahedron model back to compute centroids of this surface and check if a point lies inside. The el_topology has to be transformed from PeriLab notation, to avoid overlapping.
Arguments
coor::Union{Matrix{Float64},Matrix{Int64}}: Coordinates.topo::Vector{Int64}: el_topology of an element.
Returns
Hexahedron: eight point hexahedron.
PeriLab.Helpers.get_ring — Method
get_ring(coor::Union{Matrix{Float64},Matrix{Int64}}, topo::Vector{Int64})Description
This function gives the ring model back to compute centroids of this surface and check if a point lies inside. The el_topology has to be transformed from PeriLab notation, to avoid overlapping.
Arguments
coor::Union{Matrix{Float64},Matrix{Int64}}: Coordinates.topo::Vector{Int64}: el_topology of an element.
Returns
Ring: four point closed surface.
PeriLab.Helpers.invert — Function
invert(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.Helpers.matrix_style — Method
matrix_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.Helpers.matrix_to_vector — Method
matrix_to_vector(matrix::AbstractMatrix{Float64})Convert a 3x3 matrix to a 6x1 vector
Arguments
matrix::Matrix{Float64}: The matrix.
Returns
vector::SVector{Float64}: The Vorigt vector.
PeriLab.Helpers.matrix_to_vector — Method
matrix_to_vector(mat::Matrix{T}) where {T<:Union{Float64,Int64}}Transforming a matrix representation in a Vector{Vector} representation.
Arguments
mat::Union{Matrix{Float64},Matrix{Int64}}: Points which form the polyhedron.
Returns
- ``: transformed data
PeriLab.Helpers.progress_bar_stable_type — Method
progress_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.Helpers.qdim — Method
qdim(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.Helpers.rotate — Method
rotate(nodes::AbstractVector{Int64}, dof::Int64, matrix::AbstractArray{Float64,3}, angles::SubArray, back::Bool)Rotates the matrix.
Arguments
nodes::AbstractVector{Int64}: List of block nodes.matrix::AbstractArray{Float64,3}: Matrix.rot::SubArray: Rotation tensor.back::Bool: Back.
Returns
matrix::SubArray: Matrix.
PeriLab.Helpers.rotate_second_order_tensor — Method
rotate_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.
PeriLab.Helpers.vector_to_matrix — Method
vector_to_matrix(matrix)Convert a 6x1 vector to a 3x3 matrix
Arguments
vector::Vector{Float64}: The vector.
Returns
matrix::Matrix{Float64}: The matrix.
PeriLab.Helpers.voigt_to_matrix — Method
voigt_to_matrix(voigt::Union{Vector{Float64},Vector{Int64}})Convert a Voigt notation (6x1 or 3x1 vector) to a 2x2 or 3x3 matrix
Arguments
voigt::Vector{Float64}: The Voigt notation.
Returns
matrix::Matrix{Float64}: The matrix.