IO - Functions

Index

IO

PeriLab.IO._init_overlap_map_Method
_init_overlap_map_(size)

Initialize the overlap map.

Arguments

  • size::Int64: The number of ranks.

Returns

  • overlap_map::Dict{Int64,Dict{Int64,Dict{String,Vector{Int64}}}}: The overlap map.
source
PeriLab.IO.arcMethod
arc(cmds, dataobject, clockwise::Bool)

G02/G03 arc interpolation with extrusion. Computes points along a circular arc defined by the destination (X, Y) and either the I, J offset of the arc center or the R radius. Follows the same no-E-axis convention as linear.

source
PeriLab.IO.area_of_polygonMethod
area_of_polygon(vertices)

Calculate the area of a polygon.

Arguments

  • vertices: The vertices of the polygon.

Returns

  • area: The area of the polygon.
source
PeriLab.IO.bond_component_sizeMethod
bond_component_size(datafield)

Returns the size of a single bond value, i.e. () for a scalar bond field, (dof,) for a vector one such as Deformed Bond Geometry, and (i_dof, j_dof) for a tensor one.

Handles both the nested layout PeriLab uses for bond fields (field[node][neighbor][...]) and a flat one (field[node][neighbor, ...]). Nodes without neighbours are skipped, so a boundary node cannot make a vector field look scalar.

Arguments

  • datafield: The bond field, indexed by node

Returns

  • ::Tuple: The component size
source
PeriLab.IO.bond_element_id_offsetMethod
bond_element_id_offset(element_ids, n_bond_elements)

Returns the offset after which this rank numbers its bond elements: bond element ids start after all node elements and are then handed out rank by rank.

rank 0:  base + 1                          ... base + n_0
rank 1:  base + n_0 + 1                    ... base + n_0 + n_1
rank 2:  base + n_0 + n_1 + 1              ... base + n_0 + n_1 + n_2

base is the total number of nodes over all ranks, so the bond ids start behind the node elements. n_r is the bond count of rank r, obtained from an Allgather, so every rank can compute the sum of all lower ranks itself.

Points and FE elements take their global ids from loc_to_glob, because there is exactly one element per node. A node owns many bonds, so that map cannot be reused.

A directed bond i -> j is written only by the rank owning node i, so nothing has to be merged; the ranges only have to be disjoint.

Collective

Calls MPI.Allreduce and MPI.Allgather, so every rank has to reach this function, including ranks that hold no bonds at all.

Arguments

  • element_ids::AbstractVector: Element ids already assigned on this rank, used as the base in the serial case and for the FE part
  • n_bond_elements::Int64: Number of bond elements on this rank

Returns

  • ::Int64: Offset for the first bond element id of this rank
source
PeriLab.IO.calculate_blockMethod
calculate_block( field_key::String, dof::Int64, calculation_type::String, block::Int64)

Calculate the global value of a field for a given block.

Arguments

  • field_key::String: Field key.
  • dof::Union{Int64,Vector{Int64}}: Degree of freedom
  • calculation_type::String: Calculation type.
  • block::Int64: Block number.

Returns

  • value::Float64: Global value.
  • nnodes::Int64: Number of nodes.
source
PeriLab.IO.calculate_nodelistMethod
calculate_nodelist(field_key::String, dof::Union{Int64,Vector{Int64}}, calculation_type::String, local_nodes::Vector{Int64})

Calculate the global value of a field for a given set of nodes.

Arguments

  • field_key::String: Field key.
  • dof::Union{Int64,Vector{Int64}}: Degree of freedom
  • calculation_type::String: Calculation type.
  • local_nodes::Vector{Int64}: Node set.

Returns

  • value::Vector: Global value.
  • nnodes::Int64: Number of nodes.
source
PeriLab.IO.calculate_volumeMethod
calculate_volume(element_type::String, vertices::Vector{Vector{Float64}})

Calculate the volume of a element.

Arguments

  • element_type: The element type of the element.
  • vertices: The vertices of the element.

Returns

  • volume: The volume of the element.
source
PeriLab.IO.check_block_selectionMethod
check_block_selection(blocks, n_blocks)

Verifies that every index of a "Bond Blocks" selection refers to an existing block.

resolve_block_selection only parses; it has no idea which blocks exist. Without this check an out-of-range index is silently skipped by the export loop, and the user gets fewer bond blocks than asked for with no hint why.

Arguments

  • blocks::Union{Nothing,AbstractVector{Int64}}: The parsed selection, nothing for all blocks
  • n_blocks::Int64: Number of existing material blocks

Returns

  • blocks: The unchanged input, so the call can be chained
source
PeriLab.IO.check_for_duplicate_in_dataframeMethod
check_for_duplicate_in_dataframe(mesh::DataFrame)

check duplicated entries and throws an error if one is there. If not everything is ok.

Arguments

  • mesh::DataFrame: The input mesh data represented as a DataFrame.
source
PeriLab.IO.check_mesh_elementsMethod
check_mesh_elements(mesh, dof)

Process and analyze mesh data to create an dictionary containing information about mesh elements for further processing.

Arguments

  • mesh::DataFrame: The input mesh data represented as a DataFrame.
  • dof::Int64: The degrees of freedom (DOF) for the mesh elements.

Returns

A dictionary containing information about mesh elements, which can be used for further processing or uploading.

Example

`julia meshdata = DataFrame(x1 = [1.0, 2.0, 3.0], x2 = [4.0, 5.0, 6.0], volume = [10.0, 20.0, 30.0]) dof = 3 result = checkmeshelements(meshdata, dof)

source
PeriLab.IO.check_types_in_dataframeMethod
check_types_in_dataframe(mesh::DataFrame)

check if block_id in mesh contains only int.

Arguments

  • mesh::DataFrame: The input mesh data represented as a DataFrame.
source
PeriLab.IO.clearNP1Method
clearNP1(name::String)

Clears the NP1 from the name

Arguments

  • name::String: The name

Returns

  • name::String: The cleared name
source
PeriLab.IO.close_result_filesMethod
close_result_files(result_files::Vector{Dict}, outputs::Dict{Int64,Dict{}})

Closes the result files if the flush_file flag is not set

Arguments

  • result_files::Vector{Dict}: The result files
  • outputs::Dict{Int64,Dict{}}: The output settings
source
PeriLab.IO.close_result_filesMethod
close_result_files(result_files::Vector{Dict})

Closes the result files

Arguments

  • result_files::Vector{Dict}: The result files

Returns

  • true: File is closed
  • false: File was already closed
source
PeriLab.IO.compute_bond_connectivityMethod
compute_bond_connectivity(block_Id, n_blocks, nlist; blocks = nothing)

Builds the BAR2 connectivity for the bond export once, so that the element count used at initialisation, the connectivity written into the file, and the result values written per time step all follow the same ordering.

Bonds are directed, which is what the peridynamic data structure actually holds: nlist[i] containing j does not imply that nlist[j] contains i, and even when both exist they carry separate state (bond damage, bond forces and so on differ per direction). Each entry of each neighbourhood list therefore becomes its own BAR2 element, owned by the block of node i. Two elements on the same node pair are legal in exodusII; they simply overlap geometrically.

Bonds are owned by the block of node i, and only nodes this rank owns are iterated, so every directed bond exists exactly once across all ranks.

The partner j may be a responder node. Those bonds are written too, which is why the file has to contain the responder nodes as well; see init_write_results, where num_nodes counts them and num_owned_nodes does not.

A selected block with no local bonds is kept with zero elements. Which blocks are selected is the same on every rank, whether they hold bonds locally is not, and epu needs the same block structure in every per-rank file.

Arguments

  • block_Id::AbstractVector{Int64}: Block id per owned node
  • n_blocks::Int64: Number of material blocks
  • nlist::AbstractVector: Neighbourhood list
  • blocks: Optional subset of block indices to export bonds for

Returns

  • bond_blocks::OrderedDict{Int64,BondBlock}: Block index -> bond block
source
PeriLab.IO.create_and_distribute_bond_normMethod
create_and_distribute_bond_norm(comm::MPI.Comm, nlist_filtered_ids::BondScalarState{Int64}, distribution::Vector{Int64}, bond_norm::Vector{Float64}, dof::Int64)

Create and distribute the bond norm

Arguments

  • comm::MPI.Comm: MPI communicator
  • nlist_filtered_ids::BondScalarState{Int64}: The filtered neighborhood list
  • distribution::Vector{Int64}: The distribution
  • bond_norm::Vector{Float64}: The bond norm
  • dof::Int64: The degree of freedom
source
PeriLab.IO.create_distributionMethod
create_distribution(nnodes::Int64, size::Int64)

Calculate the initial size of each chunk for a nearly equal number of nodes vs. cores this algorithm might lead to the problem, that the last core is not equally loaded

Arguments

  • nnodes::Int64: The number of nodes.
  • size::Int64: The number of cores.

Returns

  • distribution::Array{Int64,1}: The distribution of the nodes.
  • point_to_core::Array{Int64,1}: The number of nodes in each rank.
source
PeriLab.IO.create_distribution_neighbor_basedMethod
create_distribution_neighbor_based(nnodes::Int64,nlist::BondScalarState{Int64}, size::Int64)

Calculate the initial size of each chunk for a nearly equal number of nodes vs. cores this algorithm might lead to the problem, that the last core is not equally loaded

Arguments

  • nnodes::Int64: The number of nodes.
  • nlist::BondScalarState{Int64}: The neighborhood list.
  • size::Int64: The number of cores.

Returns

  • distribution::Array{Int64,1}: The distribution of the nodes.
  • point_to_core::Array{Int64,1}: The number of nodes in each rank.
source
PeriLab.IO.create_distribution_node_basedMethod
create_distribution_node_based(nnodes::Int64,nlist::BondScalarState{Int64}, size::Int64)

Calculate the initial size of each chunk for a nearly equal number of nodes vs. cores this algorithm might lead to the problem, that the last core is not equally loaded

Arguments

  • nnodes::Int64: The number of nodes.
  • nlist::BondScalarState{Int64}: The neighborhood list.
  • size::Int64: The number of cores.

Returns

  • distribution::Array{Int64,1}: The distribution of the nodes.
  • point_to_core::Array{Int64,1}: The number of nodes in each rank.
source
PeriLab.IO.create_neighborhoodlistMethod
create_neighborhoodlist(mesh::DataFrame, params::Dict, dof::Int64)

Create the neighborhood list of the mesh elements.

Arguments

  • mesh::DataFrame: The input mesh data represented as a DataFrame.
  • params::Dict: The input parameters.
  • dof::Int64: The degrees of freedom (DOF) for the mesh elements.

Returns

  • nlist::Array{Array{Int64,1},1}: The neighborhood list of the mesh elements.
source
PeriLab.IO.create_overlap_mapMethod
create_overlap_map(distribution, ptc, size)

Create the overlap map.

Arguments

  • distribution::Array{Int64,1}: The distribution of the nodes.
  • ptc::Array{Int64,1}: The number of nodes in each rank.
  • size::Int64: The number of ranks.

Returns

  • overlap_map::Dict{Int64,Dict{Int64,Dict{String,Vector{Int64}}}}: The overlap map.
source
PeriLab.IO.create_result_fileFunction
create_result_file(filename, num_nodes, num_dim, num_elem_blks, num_node_sets,
                   num_elements = 0, FEtopology = nothing)

Creates an exodus file for the results.

Important

num_elem_blks must be the total number of element blocks that will later be written, i.e. the number of material blocks plus the number of bond blocks. Use bond_export_sizes to obtain the latter. exodusII fixes this count at initialisation; writing a different number of blocks makes ex_put_block fail, and in an MPI run it makes the per-rank files inconsistent so that epu cannot merge them.

Arguments

  • filename::AbstractString: The name of the file to create
  • num_nodes::Int64: The number of nodes
  • num_dim::Int64: The number of dimensions
  • num_elem_blks::Int64: Total number of element blocks (material + bond blocks)
  • num_node_sets::Int64: The number of node sets
  • num_elements::Int64: Number of additional elements (FE elements + bond elements)
  • FEtopology::Union{Nothing,Matrix{Int64}}: FE topology, if a FE part is present

Keywords

  • num_owned_nodes::Int64: Master nodes of this rank, one SPHERE element each. Defaults to num_nodes, which is right whenever the file holds no responder nodes.

Returns

  • result_file::Dict{String,Any}: A dictionary containing the filename and the exodus file
source
PeriLab.IO.create_result_fileMethod
create_result_file(filename::String, outputs::Dict)

Creates a csv file for the results

Arguments

  • filename::String: The name of the file to create
  • outputs::Dict: The outputs dictionary

Returns

  • Dict: The result file
source
PeriLab.IO.csv_readerMethod
csv_reader(filename::String)

Read csv and return it as a DataFrame.

Arguments

  • filename::String: The path to the mesh file.

Returns

  • csvData::DataFrame: The csv data a DataFrame.
source
PeriLab.IO.define_nsetsMethod
define_nsets(nsets::Dict{String,Vector{Int64}})

Defines the node sets

Arguments

  • nsets::Dict{String,Vector{Int64}}: Node sets read from files
source
PeriLab.IO.distribute_neighborhoodlist_to_coresMethod
distribute_neighborhoodlist_to_cores(comm::MPI.Comm, nlist, distribution)

Distributes the neighborhood list to the cores.

Arguments

  • comm::MPI.Comm: MPI communicator
  • nlist: neighborhood list
  • distribution Array{Int64}: global nodes distribution at cores
source
PeriLab.IO.distribution_to_coresMethod
distribution_to_cores(comm::MPI.Comm, mesh, distribution, dof::Int64)

Distributes the mesh data to the cores

Arguments

  • comm::MPI.Comm: MPI communicator
  • mesh: Mesh
  • distribution Array{Int64}: global nodes distribution at cores
  • dof::Int64: Degree of freedom
source
PeriLab.IO.element_block_sizesMethod
element_block_sizes(block_Id, n_blocks, bond_blocks)

Returns the number of elements per exodus block id, for both the material (SPHERE) blocks and the bond (BAR2) blocks.

Exodus.jl exposes no truth table API, so an element variable has to be written for every element block, not only for the bond blocks. This mapping supplies the lengths of the zero vectors used for the material blocks. Blocks with no local nodes are kept with a count of zero, because they exist in the file as well.

Arguments

  • block_Id::AbstractVector{Int64}: Block id per node
  • n_blocks::Int64: Number of material blocks
  • bond_blocks::AbstractDict{Int64,BondBlock}: The bond blocks

Returns

  • sizes::OrderedDict{Int64,Int64}: exodus block id -> number of elements
source
PeriLab.IO.element_distributionMethod
element_distribution(topology::Vector{Vector{Int64}}, ptc::Vector{Int64}, size::Int64)

Create the distribution of the finite elements. Is needed to avoid multiple element calls. Each element should run only one time at the cores.

Arguments

  • topology::Vector{Vector{Int64}}: The topology list of the mesh elements.
  • nlist::BondScalarState{Int64}: The neighborhood list of the mesh elements.
  • size::Int64: The number of ranks.

Returns

  • distribution::Vector{Vector{Int64}}: The distribution of the nodes.
  • etc::Vector{Int64}: The number of nodes in each rank.
source
PeriLab.IO.exodus_num_nodesMethod
exodus_num_nodes(exo::ExodusDatabase)

Number of nodes the database was initialised with.

Exodus.jl carries the initialisation as type parameters, Initialization{num_dim, num_nodes, num_elems, num_elem_blks, num_node_sets, num_side_sets} — the same order create_result_file builds it in. There is no exported accessor, so the parameter is read off the type.

Arguments

  • exo::ExodusDatabase: The exodus file

Returns

  • ::Int64: Node count of the file
source
PeriLab.IO.extrude_surface_meshMethod
extrude_surface_mesh(mesh::DataFrame)

extrude the mesh at the surface of the block

Arguments

  • mesh::DataFrame: The input mesh data represented as a DataFrame.
  • params::Dict: The input parameters.
source
PeriLab.IO.find_global_core_value!Method
find_global_core_value!(global_value::Union{Int64,Float64}, calculation_type::String, nnodes::Int64)

Find global core value.

Arguments

  • global_value::Union{Int64,Float64}: The global value
  • calculation_type::String: The calculation type
  • nnodes::Int64: The number of nodes

Returns

  • global_value::Union{Int64,Float64}: The global value
source
PeriLab.IO.gather_bond_valuesMethod
gather_bond_values(field, bond_block, dof)

Extracts the values of one bond variable in exactly the order of the bond connectivity.

Two storage layouts are supported, decided once per field from a sample entry:

  • nested (Vector{Vector{...}}, what PeriLab uses for BondScalarState and BondVectorState): field[node][neighbor] is the value itself for a scalar field and a Vector for a vector field such as Deformed Bond Geometry.
  • flat (an Array{T,3} per node, BondTensorState): field[node][neighbor, i, j].

Arguments

  • field: The bond field
  • bond_block::BondBlock: The bond block
  • dof: nothing for scalars, an Integer for vectors, a 2-element collection for tensors

Returns

  • values::Vector{Float64}: One value per bond
source
PeriLab.IO.get_block_nodesMethod
get_block_nodes(block_Id::AbstractVector{Int64}, block::Int64)

Returns the nodes of a block as a 1 x n matrix, which is the layout exodusII expects for a SPHERE block (one node per element).

Arguments

  • block_Id::AbstractVector{Int64}: The block Id
  • block::Int64: The block

Returns

  • nodes::Matrix{Int64}: The nodes of the block, shaped 1 x n
source
PeriLab.IO.get_file_sizeMethod
get_file_size(result_files::Vector{Dict})

Gets the file size of the result files

Arguments

  • result_files: The result files

Returns

  • total_file_size: The total file size
source
PeriLab.IO.get_global_valuesMethod
get_global_values(output::Dict,)

Get global values.

Arguments

  • output::Dict: The output

Returns

  • global_values::Vector: The global values
source
PeriLab.IO.get_local_element_topologyMethod
get_local_element_topology(topology::Vector{Vector{Int64}}, distribution::Vector{Int64})

Get the local element topology

Arguments

  • topology::Vector{Vector{Int64}}: The topology
  • distribution::Vector{Int64}: The distribution
source
PeriLab.IO.get_local_neighborsMethod
get_local_neighbors(mapping, nlist_core)

Gets the local neighborhood list from the global neighborhood list

Arguments

  • mapping: mapping function
  • nlist_core: global neighborhood list

Returns

  • nlist_core: local neighborhood list
source
PeriLab.IO.get_local_overlap_mapMethod
get_local_overlap_map()

Changes entries in the overlap map from the global numbering to the local computer core one.

Arguments

  • overlap_map::Dict{Int64, Dict{Int64, String}}: overlap map with global nodes.
  • distribution::Vector{Vector{Int64}}: global nodes distribution at cores, needed for the gobal to local mapping
  • ranks Array{Int64} : number of used computer cores

Returns

  • overlap_map::Dict{Int64, Dict{Int64, String}}: returns overlap map with local nodes.

Example:

get_local_overlap_map(overlap_map, distribution, ranks)  # returns local nodes
source
PeriLab.IO.get_mpi_rank_stringMethod
get_mpi_rank_string(rank::Int64, max_rank::Int64)

Get MPI rank string.

Arguments

  • value::Int64: The rank
  • max_rank::Int64: The max rank

Returns

  • result::String: The result
source
PeriLab.IO.get_number_of_neighbornodesMethod
get_number_of_neighbornodes(nlist::BondScalarState{Int64})

Get the number of neighbors for each node.

Arguments

  • nlist::BondScalarState{Int64}: The neighborhood list of the mesh elements.

Returns

  • length_nlist::Vector{Int64}: The number of neighbors for each node.
source
PeriLab.IO.get_paraview_coordinatesMethod
get_paraview_coordinates(dof::Int64, refDof::Int64)

Returns the paraview specific dof

Arguments

  • dof::Int64: The degrees of freedom
  • refDof::Int64: The reference degrees of freedom

Returns

  • paraview_specifics::String: The paraview specific dof
source
PeriLab.IO.get_results_mappingMethod
get_results_mapping(params::Dict, path::String)

Gets the results mapping

Arguments

  • params::Dict: The parameters
  • path::String: The path

Returns

  • output_mapping::Dict{Int64,Dict{}}: The results mapping
source
PeriLab.IO.global_value_avgMethod
global_value_avg(field::Union{NodeScalarField{Float64},NodeVectorField{Float64}}, dof::Union{Int64,Vector{Int64}}, nodes::AbstractVector{Int64})

Calculate the global average of a field for given nodes.

Arguments

  • field::Union{NodeScalarField{Float64},NodeVectorField{Float64}}: Field.
  • dof::Union{Int64,Vector{Int64}}: Degree of freedom
  • nodes::AbstractVector{Int64}: Nodes.

Returns

  • returnValue::Vector: Global value.
source
PeriLab.IO.global_value_maxMethod
global_value_max(field::Union{NodeScalarField{Float64},NodeVectorField{Float64}}, dof::Union{Int64,Vector{Int64}}, nodes::AbstractVector{Int64})

Calculate the global maximum of a field for given nodes.

Arguments

  • field::Union{NodeScalarField{Float64},NodeVectorField{Float64}}: Field.
  • dof::Union{Int64,Vector{Int64}}: Degree of freedom
  • nodes::AbstractVector{Int64}: Nodes.

Returns

  • returnValue::Vector: Global value.
source
PeriLab.IO.global_value_minMethod
global_value_min(field::Union{NodeScalarField{Float64},NodeVectorField{Float64}}, dof::Union{Int64,Vector{Int64}}, nodes::AbstractVector{Int64})

Calculate the global minimum of a field for given nodes.

Arguments

  • field::Union{NodeScalarField{Float64},NodeVectorField{Float64}}: Field.
  • dof::Union{Int64,Vector{Int64}}: Degree of freedom
  • nodes::AbstractVector{Int64}: Nodes.

Returns

  • returnValue::Vector: Global value.
source
PeriLab.IO.global_value_sumMethod
global_value_sum(field::Union{NodeScalarField{Float64},NodeVectorField{Float64},NodeTensorField{Float64}}, dof::Union{Int64,Vector{Int64}}, nodes::AbstractVector{Int64})

Calculate the global sum of a field for given nodes.

Arguments

  • field::Union{NodeScalarField{Float64},NodeVectorField{Float64},NodeTensorField{Float64}}: Field.
  • dof::Union{Int64,Vector{Int64}: Degree of freedom
  • nodes::AbstractVector{Int64}: Nodes.

Returns

  • returnValue::Vector: Global value.
source
PeriLab.IO.hex8_volumeMethod

hex8volume(hexvertices)

Calculate the volume of a hex.

Arguments

  • hex_vertices: The vertices of the wedge.

Returns

  • volume: The volume of the wedge.
source
PeriLab.IO.hex8_volumeMethod

hex8volume(hexvertices)

Calculate the volume of a hex.

Arguments

  • hex_vertices: The vertices of the wedge.

Returns

  • volume: The volume of the wedge.
source
PeriLab.IO.init_bond_information_exportMethod
init_bond_information_export(block_Id, n_blocks, nlist, parameter)

Convenience wrapper: evaluates the "Bond Export" parameter and returns the bond blocks together with the sizes required at initialisation.

Arguments

  • block_Id::AbstractVector{Int64}: Block id per node
  • n_blocks::Int64: Number of material blocks
  • nlist::AbstractVector: Neighbourhood list
  • parameter::Dict: Output parameter block, may contain "Bond Export" and "Bond Blocks" (whitespace separated indices, e.g. 1 3). Without "Bond Blocks" every block is exported.

Returns

  • bond_blocks::OrderedDict{Int64,BondBlock}: Bond blocks (empty if disabled)
  • n_bond_elements::Int64: Total number of BAR2 elements
  • n_bond_blocks::Int64: Number of additional element blocks
source
PeriLab.IO.init_dataMethod
init_data(params::Dict, path::String, comm::MPI.Comm)

Initializes the data for the mesh.

Arguments

  • params::Dict: The parameters for the simulation.
  • path::String: The path to the mesh file.
  • comm::MPI.Comm: The MPI communicator.

Returns

  • params::Dict: The parameters for the simulation.
source
PeriLab.IO.init_results_in_exodusFunction
init_results_in_exodus(exo, dof, output, coords, block_Id, all_block_name_list,
                       nsets, global_ids, PERILAB_VERSION, qa_vector,
                       fem_block = nothing, topology = nothing,
                       elem_global_ids = nothing;
                       bond_blocks = ..., bond_output_names = String[],
                       bond_id_offset = -1)

Initializes the results in exodus.

Works with and without bond export: leaving both keywords out writes a plain nodal result file, exactly as before the bond export existed. The FE arguments keep their old positional places.

Arguments

  • exo::ExodusDatabase: The exodus database
  • dof: Degrees of freedom
  • output::Dict: The output definition
  • coords::Union{Matrix{Int64},Matrix{Float64}}: The coordinates
  • block_Id::Vector{Int64}: The block Id per node
  • all_block_name_list::Vector{String}: The block names
  • nsets::Dict{String,Vector{Int64}}: The node sets
  • global_ids::Vector{Int64}: The global ids
  • PERILAB_VERSION::String: PeriLab version string
  • qa_vector::Vector{String}: Additional QA records (at most 2 are stored)
  • fem_block::Union{Nothing,Vector{Bool}}: Per-node flag marking FE nodes
  • topology::Union{Nothing,Matrix{Int64}}: FE topology
  • elem_global_ids::Union{Nothing,Vector{Int64}}: Global element ids for the FE part

Keywords

  • bond_blocks: Bond blocks, see compute_bond_connectivity. Empty means no bond export.
  • bond_output_names::Vector{String}: Names of the bond variables, written as element variables
  • bond_id_offset::Int64: First bond element id minus one, from bond_element_id_offset. Negative means single rank, then the local maximum is used.

Returns

  • exo::ExodusDatabase: The exodus file
source
PeriLab.IO.init_write_resultsMethod
init_write_results(params::Dict, output_dir::String, path::String, PERILAB_VERSION::String, qa_vector::Vector{String})

Initialize write results.

Arguments

  • params::Dict: The parameters
  • output_dir::String: The output directory.
  • path::String: The path
  • PERILAB_VERSION::String: The PeriLab version
  • qa_vector::Vector{String}: Additional QA records

Returns

  • result_files::Array: The result files
  • outputs::Dict: The outputs
source
PeriLab.IO.initialize_dataMethod
initialize_data(filename::String, filedirectory::String, comm::MPI.Comm)

Initialize data.

Arguments

  • filename::String: The name of the input file.
  • filedirectory::String: The directory of the input file.
  • comm::MPI.Comm: The MPI communicator

Returns

  • data::Dict: The data
source
PeriLab.IO.is_bond_field_typeMethod
is_bond_field_type(field_type)

Returns whether a field type produced by Data_Manager.get_field_type describes a bond field.

Note

This and gather_bond_values in exodus_export.jl are the only two places that encode how a bond field looks. Adjust both together if the naming or the storage layout of bond fields changes.

Arguments

  • field_type: The field type

Returns

  • ::Bool: true for bond fields
source
PeriLab.IO.linearMethod
linear(cmds, dataobject)

Example extrusion callback for G1 which calculates total length of filament extruded.

The extruded filament length is obtained by watching the E axis movement in the g-code file. If no E axis is present anywhere in the file, G1 moves are treated as material deposition/cutting moves by convention (only G0 is a pure travel move).

source
PeriLab.IO.load_and_evaluate_meshMethod
load_and_evaluate_mesh(params::Dict, path::String, ranksize::Int64)

Load and evaluate the mesh data.

Arguments

  • params::Dict: The input parameters.
  • path::String: The path to the mesh file.
  • ranksize::Int64: The number of ranks.

Returns

  • distribution::Array{Int64,1}: The distribution of the mesh elements.
  • mesh::DataFrame: The mesh data as a DataFrame.
  • ntype::Dict: The type of the mesh elements.
  • overlap_map::Array{Array{Int64,1},1}: The overlap map of the mesh elements.
  • nlist::Array{Array{Int64,1},1}: The neighborhood list of the mesh elements.
  • dof::Int64: The degrees of freedom (DOF) for the mesh elements.
  • nsets::Dict: The node sets
  • topology::Int64::Array{Int64,nelement:nodes}`: The topology of elements.
  • el_distribution::Array{Int64,1}: The distribution of the finite elements.
source
PeriLab.IO.local_nodes_from_dictMethod
local_nodes_from_dict(create_global_to_local_mapping::Dict{Int,Int}, global_nodes::Vector{Int64})

Changes entries in the overlap map from the global numbering to the local computer core one.

Arguments

  • create_global_to_local_mapping::Dict{Int,Int}: global to local mapping
  • global_nodes::Vector{Int64}: global nodes

Returns

  • overlap_map::Dict{Int64, Dict{Int64, String}}: returns overlap map with local nodes.
source
PeriLab.IO.merge_exodus_fileMethod
merge_exodus_file(file_name::AbstractString)

Merges the exodus file

Arguments

  • file_name::AbstractString: The name of the file to merge

Returns

  • exo::ExodusDatabase: The exodus file
source
PeriLab.IO.merge_exodus_filesMethod
merge_exodus_files(result_files::Vector{Any}, output_dir::String)

Merges exodus output files

Arguments

  • result_files::Vector{Any}: The result files
  • output_dir::String: The file directory
source
PeriLab.IO.movementMethod
movement(cmds, dataobject)

Example movement callback for G0 and G1 which calculates the total distance moved in all axes.

It is calculated by watching the X, Y and Z axes movement.

source
PeriLab.IO.neighborsMethod
neighbors(mesh, params::Dict, coor)

Compute the neighbor list for each node in a mesh based on their proximity using a BallTree data structure.

Arguments

  • mesh: A mesh data structure containing the coordinates and other information.
  • params: paramss needed for computing the neighbor list.
  • coor: A vector of coordinate names along which to compute the neighbor list.

Returns

An array of neighbor lists, where each element represents the neighbors of a node in the mesh.

source
PeriLab.IO.node_distributionFunction
node_distribution(nlist::BondScalarState{Int64}, size::Int64)

Create the distribution of the nodes.

Arguments

  • nlist::BondScalarState{Int64}: The neighborhood list of the mesh elements.
  • size::Int64: The number of ranks.
  • distribution_type::String: The distribution type.

Returns

  • distribution::Vector{Vector{Int64}}: The distribution of the nodes.
  • ptc::Vector{Int64}: Defines at which core / rank each node lies.
  • ntype::Dict: The type of the nodes.
source
PeriLab.IO.paraview_specificsMethod
paraview_specifics(dof::Int64)

Returns the paraview specific dof

Arguments

  • dof::Int64: The degrees of freedom

Returns

  • paraview_specifics::String: The paraview specific dof
source
PeriLab.IO.parseLineFunction
parseLine(line::String, returnPair::Bool = true)::Array{Union{String,Pair{String,String}},1}

Parse a single line of g-code and return an array of Pair{String,String} or an array of String containing the parsed commands.

The first command usually defines what to do (ie. G01 - linear interpolation) and following commands are the arguments (ie. X 14.312);

Examples

julia> parseLine("G10 X5.Y3. E6.")
4-element Array{Union{Pair{String,String}, String},1}:
 "G" => "10"
 "X" => "5."
 "Y" => "3."
 "E" => "6."

Return array of strings

julia> parseLine("G10 X5.Y3. E6.", false)
4-element Array{Union{Pair{String,String}, String},1}:
 "G10"
 "X5."
 "Y3."
 "E6."
source
PeriLab.IO.read_external_topologyMethod
read_external_topology(filename::String)

Read external topoloy data from a file and return it as a DataFrame.

Arguments

  • filename::String: The path to the mesh file.

Returns

  • external_topology::DataFrame: The external topology data as a DataFrame.
source
PeriLab.IO.read_inputMethod
read_input(filename::String)

Reads the input deck from a yaml file

Arguments

  • filename::String: The name of the yaml file

Returns

  • params::Dict{String,Any}: The parameters read from the yaml file
source
PeriLab.IO.read_input_fileMethod
read_input_file(filename::String)

Reads the input deck from a yaml file

Arguments

  • filename::String: The name of the yaml file

Returns

  • Dict{String,Any}: The validated parameters read from the yaml file.
source
PeriLab.IO.read_meshMethod
read_mesh(filename::String, params::Dict)

Read mesh data from a file and return it as a DataFrame.

Arguments

  • filename::String: The path to the mesh file.
  • params::Dict: The input parameters.

Returns

  • mesh::DataFrame: The mesh data as a DataFrame.
source
PeriLab.IO.resolve_block_selectionMethod
resolve_block_selection(blocks)

Normalises the "Bond Blocks" entry into a list of block indices.

The entry is written as a plain, whitespace separated list of indices in the input deck, e.g. Bond Blocks: 1 3. A single index and an already parsed collection of integers are accepted as well. nothing or an empty entry means "all blocks".

Arguments

  • blocks: The selection taken from the output parameters

Returns

  • Union{Nothing,Vector{Int64}}: Block indices, or nothing for "all blocks"
source
PeriLab.IO.set_anglesMethod
set_angles(params::Dict, block_nodes::Dict)

Sets the density of the nodes in the dictionary.

Arguments

  • params::Dict: The parameters
  • block_nodes::Dict: A dictionary mapping block IDs to collections of nodes
source
PeriLab.IO.set_dofMethod
set_dof(mesh::DataFrame)

Set the degrees of freedom (DOF) for the mesh elements.

Arguments

  • mesh::DataFrame: The input mesh data represented as a DataFrame.

Returns

  • dof::Int64: The degrees of freedom (DOF) for the mesh elements.
source
PeriLab.IO.set_output_frequencyMethod
set_output_frequency(params::Dict, nsteps::Int64, step_id::Int64)

Sets the output frequency.

Arguments

  • params::Dict: The parameters
  • nsteps::Int64: The number of steps
  • step_id::Int64: The step id
source
PeriLab.IO.show_block_summaryMethod
show_block_summary(solver_options::Dict, params::Dict, log_file::String, silent::Bool, comm::MPI.Comm)

Show block summary.

Arguments

  • solver_options::Dict: The solver options
  • params::Dict: The params
  • log_file::String: The log file
  • silent::Bool: The silent flag
  • comm::MPI.Comm: The Comm_rank
source
PeriLab.IO.show_mpi_summaryMethod
show_mpi_summary(log_file::String, silent::Bool, comm::MPI.Comm)

Show MPI summary.

Arguments

  • log_file::String: The log file
  • silent::Bool: The silent flag
  • comm::MPI.Comm: The comm
source
PeriLab.IO.split_output_fieldsMethod
split_output_fields(fields::Dict)

Splits an output field definition into its nodal, bond and global parts.

Arguments

  • fields::Dict: The "Fields" entry of an output definition

Returns

  • nodal::Dict, bond::Dict, global_::Dict
source
PeriLab.IO.stripCommentsMethod
stripComments(line::String)::String

Return a copy of string line with stripped comments inside parentheses and all characters after a semicolon.

This function also removes whitespace as it it not needed for further parsing.

Examples

julia> stripComments("G92 (G10(aaa)))) ((comment)G) Z0.2 ; this is a comment")
"G92Z0.2"
source
PeriLab.IO.tetrahedron_volumeMethod
tetrahedron_volume(tet_vertices)

Calculate the volume of a tetrahedron.

Arguments

  • tet_vertices: The vertices of the tetrahedron.

Returns

  • volume: The volume of the tetrahedron.
source
PeriLab.IO.tetrahedron_volumeMethod
tetrahedron_volume(tet_vertices)

Calculate the volume of a tetrahedron.

Arguments

  • tet_vertices: The vertices of the tetrahedron.

Returns

  • volume: The volume of the tetrahedron.
source
PeriLab.IO.wedge6_volumeMethod
wedge6_volume(wedge_vertices)

Calculate the volume of a wedge.

Arguments

  • wedge_vertices: The vertices of the wedge.

Returns

  • volume: The volume of the wedge.
source
PeriLab.IO.write_bond_results_in_exodusMethod
write_bond_results_in_exodus(exo, step, output, bond_blocks, block_Id, n_blocks)

Writes the bond results in the exodus file, as element variables on the BAR2 blocks.

A bond can carry the same variable types as a point (scalar, vector, tensor); the component selection in output therefore follows the same "dof" / "i_dof" + "j_dof" convention as the nodal output. The values are gathered in the order of the bond connectivity, so bond k of a block always refers to the same element that was written at initialisation.

Because Exodus.jl offers no truth table, the same variable is also written to the material blocks — as zeros.

Arguments

  • exo::ExodusDatabase: The exodus file
  • step::Int64: The step
  • output::Dict: The bond output definitions
  • bond_blocks::AbstractDict{Int64,BondBlock}: The bond blocks
  • block_Id::AbstractVector{Int64}: Block id per node
  • n_blocks::Int64: Number of material blocks

Returns

  • exo::ExodusDatabase: The exodus file
source
PeriLab.IO.write_global_results_in_csvMethod
write_global_results_in_csv(csv_file::IOStream, time::Float64, global_values)

Writes the global results to the csv file

Arguments

  • csv_file::IOStream: The csv file
  • global_values: The global values
source
PeriLab.IO.write_global_results_in_exodusMethod
write_global_results_in_exodus(exo::ExodusDatabase, step::Int64, global_values)

Writes the global results in the exodus file

Arguments

  • exo::ExodusDatabase: The exodus file
  • step::Int64: The step
  • global_values: The global values

Returns

  • exo::ExodusDatabase: The exodus file
source
PeriLab.IO.write_nodal_results_in_exodusMethod
write_nodal_results_in_exodus(exo::ExodusDatabase, step::Int64, output::Dict)

Writes the nodal results in the exodus file

Arguments

  • exo::ExodusDatabase: The exodus file
  • step::Int64: The step
  • output::Dict: The output

Returns

  • exo::ExodusDatabase: The exodus file
source
PeriLab.IO.write_pd_mesh_arcMethod
write_pd_mesh_arc(dataobject, sx, sy, sz, ex, ey, ez)

Variant of write_pd_mesh for arc segments. Uses the provided start/end points instead of reading them from dataobject.

source
PeriLab.IO.write_resultsMethod
write_results(result_files::Vector{Any}, time::Float64, max_damage::Float64, outputs::Dict)

Write results.

Arguments

  • result_files::Vector{Any}: The result files
  • time::Float64: The time
  • max_damage::Float64: The maximum damage
  • outputs::Dict: The outputs

Returns

  • result_files::Vector{Any}: The result files
source
PeriLab.IO.write_step_and_timeMethod
write_step_and_time(exo::ExodusDatabase, step::Int64, time::Float64)

Writes the step and time in the exodus file

Arguments

  • exo::ExodusDatabase: The exodus file
  • step::Int64: The step
  • time::Float64: The time

Returns

  • exo::ExodusDatabase: The exodus file
source
PeriLab.IO.BondBlockType
BondBlock

Holds everything needed to write one bond block, built once in compute_bond_connectivity.

The three fields are aligned column by column: bond k runs from nodes[k] to the second entry of conn[:, k], and corresponds to entry neighbor_index[k] of the owning node's neighbourhood list. Keeping the neighbour index around is what makes the result output reproduce exactly the order used for the connectivity — otherwise bond values and bond elements silently drift apart.

Bonds are directed, so the same node pair may appear twice, once per direction, each with its own values. The owning node is always conn[1, k].

Fields

  • conn::Matrix{Int64}: 2 x n_bonds BAR2 connectivity
  • nodes::Vector{Int64}: owning node of each bond
  • neighbor_index::Vector{Int64}: position of the bond inside nlist[node]
source

Parameter_Handling

PeriLab.Parameter_Handling._get_valuesFunction
_get_values(params::Dict, block_id::Int64, valueName::String, defaultValue::Union{Float64,Bool,Nothing})

Get the value of a block.

Arguments

  • params::Dict: The parameters
  • block_id::Int64: The ID of the block
  • valueName::String: The name of the value
  • defaultValue::Union{Float64,Bool,Nothing: The default value

Returns

  • value::Float64: The value of the block
source
PeriLab.Parameter_Handling.get_anglesMethod
get_angles(params::Dict, block_id::Int64, dof::Int64)

Get the horizon of a block.

Arguments

  • params::Dict: The parameters
  • block_id::Int64: The ID of the block
  • dof::Int64: The dof

Returns

  • angles::Float64: The angles of the block
source
PeriLab.Parameter_Handling.get_block_names_and_idsMethod
get_block_names_and_ids(params::Dict, block_ids::Vector{Int64})

Get the names of the blocks.

Arguments

  • params::Dict: The parameters dictionary.
  • block_ids::Vector{Int64}: The IDs of the blocks

Returns

  • block_names::Vector{String}: The names of the blocks.
source
PeriLab.Parameter_Handling.get_bond_filtersMethod
get_bond_filters(params::Dict)

Returns the bond filters from the parameters

Arguments

  • params::Dict: The parameters

Returns

  • check::Bool: Whether the bond filters are defined
  • bfList::Dict{String,Dict{String,Any}}: The bond filters
source
PeriLab.Parameter_Handling.get_computesMethod
get_computes(params::Dict, variables::Vector{String})

Get the computes.

Arguments

  • params::Dict: The parameters dictionary.
  • variables::Vector{String}: The variables.

Returns

  • computes::Dict{String,Dict{Any,Any}}: The computes.
source
PeriLab.Parameter_Handling.get_densityMethod
get_density(params::Dict, block_id::Int64)

Get the density of a block.

Arguments

  • params::Dict: The parameters
  • block_id::Int64: The ID of the block

Returns

  • density::Float64: The density of the block
source
PeriLab.Parameter_Handling.get_external_topology_nameMethod
get_external_topology_name(params::Dict, path)

Returns the name of the mesh file from the parameters

Arguments

  • params::Dict: The parameters
  • path::String: Path of the working folder

Returns

  • String: The name of the finite element topology file
source
PeriLab.Parameter_Handling.get_fem_blockMethod
get_fem_block(params::Dict, block_id::Int64)

Get the fem_block of a block.

Arguments

  • params::Dict: The parameters
  • block_id::Int64: The ID of the block

Returns

  • fem_block::Float64: The fem_block of the block
source
PeriLab.Parameter_Handling.get_headerMethod
get_header(filename::Union{String,AbstractString})

Returns the header line and the header.

Arguments

  • filename::Union{String,AbstractString}: The filename of the file.

Returns

  • header_line::Int: The header line.
  • header::Vector{String}: The header.
source
PeriLab.Parameter_Handling.get_heat_capacityMethod
get_heat_capacity(params::Dict, block_id::Int64)

Get the heat capacity of a block.

Arguments

  • params::Dict: The parameters
  • block_id::Int64: The ID of the block

Returns

  • heat_capacity::Float64: The heat capacity of the block
source
PeriLab.Parameter_Handling.get_horizonMethod
get_horizon(params::Dict, block_id::Int64)

Get the horizon of a block.

Arguments

  • params::Dict: The parameters
  • block_id::Int64: The ID of the block

Returns

  • horizon::Float64: The horizon of the block
source
PeriLab.Parameter_Handling.get_model_parameterFunction
get_model_parameter(params, model, id)

Retrieve a model parameter from a dictionary of parameters.

This function retrieves a specific model parameter from a dictionary of parameters based on the provided model and identifier (id).

Arguments

  • params::Dict: A dictionary containing various parameters.

  • model::String: The model type for which the parameter is sought.

  • id::String: The identifier (name) of the specific model parameter.

Returns

  • parameter::Any: The retrieved model parameter, or nothing if the parameter is not found.

Errors

  • If the specified model is defined in blocks but no model definition block exists, an error message is logged, and the function returns nothing.

  • If the model with the given identifier is defined in blocks but missing in the model's definition, an error message is logged, and the function returns nothing.

Example

params = Dict(
    "Models" => Dict(
        "Models" => Dict(
            "ModelA" => 42,
            "ModelB" => 24
        )
    )
)

model = "Models"
id = "ModelA"

result = get_model_parameter(params, model, id)
if result !== nothing
    println("Parameter id: result")
else
    println("Parameter not found.")
end
source
PeriLab.Parameter_Handling.get_node_setsMethod
get_node_sets(params::Dict, path::String)

Returns the node sets from the parameters

Arguments

  • params::Dict: The parameters
  • path::String: The path to the mesh file

Returns

  • nsets::Dict{String,Any}: The node sets
source
PeriLab.Parameter_Handling.get_output_fieldnamesMethod
get_output_fieldnames(outputs::Dict, variables::Vector{String}, computes::Vector{String}, output_type::String)

Gets the output fieldnames.

Arguments

  • outputs::Dict: The outputs
  • variables::Vector{String}: The variables
  • computes::Vector{String}: The computes
  • output_type::String: The output type

Returns

  • output_fieldnames::Vector{String}: The output fieldnames
source
PeriLab.Parameter_Handling.get_output_filenamesMethod
get_output_filenames(params::Dict, output_dir::String)

Gets the output filenames.

Arguments

  • params::Dict: The parameters
  • output_dir::String: The file directory

Returns

  • filenames::Vector{String}: The filenames
source
PeriLab.Parameter_Handling.get_output_variablesMethod
get_output_variables(output::String, variables::Vector{String})

Get the output variable.

Arguments

  • output::String: The output variable.
  • variables::Vector{String}: The variables.

Returns

  • output::String: The output variable.
source
PeriLab.Parameter_Handling.get_outputsMethod
get_outputs(params::Dict, variables::Vector{String}, compute_names::Vector{String})

Gets the outputs.

Arguments

  • params::Dict: The parameters
  • variables::Vector{String}: The variables
  • compute_names::Vector{String}: The compute names

Returns

  • outputs::Dict: The outputs
source
PeriLab.Parameter_Handling.validate_structure_recursiveFunction
validate_structure_recursive(expected::Dict, actual::Dict, validate::Bool, checked_keys::Array, path::String="")

Validates the parameters against the expected structure

Arguments

  • expected::Dict: The expected structure
  • actual::Dict: The actual structure
  • validate::Bool: The validation results
  • checked_keys::Array: The keys that have been checked
  • path::String: The current path

Returns

  • validate::Bool: The validation result
  • checked_keys::Array: The keys that have been checked
source
PeriLab.Parameter_Handling.validate_yamlMethod
validate_yaml(params::Dict)

Validates the parameters against the expected structure

Arguments

  • params::Dict: The parameters dictionary.

Returns

  • params::Dict: The parameters dictionary.
source