Helper - Functions
Index
PeriLab.Solver_control.Helpers.check_inf_or_nan
PeriLab.Solver_control.Helpers.compute_free_surface_nodes
PeriLab.Solver_control.Helpers.create_centroid_and_search_radius
PeriLab.Solver_control.Helpers.find_files_with_ending
PeriLab.Solver_control.Helpers.find_indices
PeriLab.Solver_control.Helpers.find_inverse_bond_id
PeriLab.Solver_control.Helpers.get_active_update_nodes
PeriLab.Solver_control.Helpers.get_block_nodes
PeriLab.Solver_control.Helpers.get_fourth_order
PeriLab.Solver_control.Helpers.get_hexagon
PeriLab.Solver_control.Helpers.get_ring
PeriLab.Solver_control.Helpers.invert
PeriLab.Solver_control.Helpers.matrix_style
PeriLab.Solver_control.Helpers.matrix_to_vector
PeriLab.Solver_control.Helpers.progress_bar
PeriLab.Solver_control.Helpers.qdim
PeriLab.Solver_control.Helpers.rotate
PeriLab.Solver_control.Helpers.rotate_second_order_tensor
Helpers
PeriLab.Solver_control.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_control.Helpers.compute_free_surface_nodes
— Methodcompute_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.Solver_control.Helpers.create_centroid_and_search_radius
— Methodcreate_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.,2
for 2D and3
for 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.Solver_control.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_control.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_control.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_control.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_control.Helpers.get_block_nodes
— Methodget_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.Solver_control.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_control.Helpers.get_hexagon
— Methodget_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.Solver_control.Helpers.get_ring
— Methodget_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.Solver_control.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_control.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_control.Helpers.matrix_to_vector
— Method matrix_to_vector(mat::Union{Matrix{Float64},Matrix{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.Solver_control.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_control.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_control.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_control.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.