Examples

smearFEM.apply_boundary_conditionsMethod

Apply the Neumann slip boundary conditions to the global stiffness matrix

Arguments:

K: {[ndof,ndof] SparseMatrixCSC{Float64,Int64}} : sparse stiffness matrix ID: {[nNodes,nDof] Matrix{Int}} : matrix that maps the global degrees of freedom to the local degrees of freedom qd: {[ndof] Vector{Float64}} : Dirichlet boundary conditions qn: {[ndof] Vector{Float64}} : Neumann boundary conditions

Returns:

K: {[ndof,ndof] SparseMatrixCSC{Float64,Int64}} : sparse stiffness matrix with the boundary conditions applied F: {[ndof] Vector{Float64}} : force vector

source
smearFEM.assemble_systemMethod
assemble_system(ne, NodeList, IEN, ndim, FunctionClass="Q1", nDof=1, ID=nothing, Young=1, ν=0.3)

Assembles the finite element system. # Returns the global stiffness matrix

Arguments:

  • ne::Interger: number of elements in each direction
  • NodeList::Matrix{Float64}{ndim,nNodes} : coordinates of the nodes
  • IEN::Matrix{Int}{nElements,nLocalNodes} : connectivity matrix
  • ndim::Interger: number of dimensions
  • nDof::Interger: number of degree of freedom per node
  • FunctionClass::String: type of basis functions to be considered (Q1:quadratic or Q2:Lagrange)
  • ID::Matrix{Int}{nNodes,nDof} : matrix that maps the global degrees of freedom to the local degrees of freedom
  • Young::Float64: Young's modulus
  • ν::Float64: Poisson's ratio

Returns:

  • K::SparseMatrixCSC{Float64,Int64}{ndof,ndof} : sparse stiffness matrix
source
smearFEM.get_cMatFunction
get_cMat(type; λ=nothing, μ=nothing, Young=nothing, ν=nothing)

Returns the stiffness matrix for a given type of material

Arguments:

  • type::String: type of constitutive matrix to be considered (lame or standard)
  • λ::Float64: Lame's first parameter
  • μ::Float64: Sheer modulus
  • Young::Float64: Young's modulus
  • ν::Float64: Poisson's ratio

Returns:

  • cMat::Matrix{Float64}: constitutive matrix
source
smearFEM.initialize_mesh_testFunction
function initialize_mesh_test(x0, x1, y0, y1, z0, z1, ne, ndim, FunctionClass, CameraMatrix, filepath=nothing)

Initialize the mesh and write the data to a file

Arguments:

  • x0::Float64 : x-coordinate of the lower left corner of the domain
  • x1::Float64 : x-coordinate of the upper right corner of the domain
  • y0::Float64 : y-coordinate of the lower left corner of the domain
  • y1::Float64 : y-coordinate of the upper right corner of the domain
  • z0::Float64 : z-coordinate of the lower left corner of the domain
  • z1::Float64 : z-coordinate of the upper right corner of the domain
  • ne::Int : number of elements
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function
  • CameraMatrix::Matrix{Float64} : camera matrix
  • filepath::String : path to the file
source
smearFEM.set_fileMethod
set_file(filepath)

Create the directories to store the data

Arguments:

  • filepath::String : path to the file
source
smearFEM.setboundaryCondFunction

Set the Dirichlet boundary conditions for the problem

Arguments:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • ne::Int : number of elements
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function

Returns:

  • q_upper::Vector{Float64} : vector of the Dirichlet boundary conditions (for ndof = 1) / Dirichlet boundary conditions upper surface (for ndof > 1)
  • q_lower::Vector{Float64} : vector of the Neumann boundary conditions (for ndof = 1) / Dirichlet boundary conditions lower surface (for ndof > 1)
  • C_uc::SparseMatrixCSC{Float64,Int64} : onstraint matrix
source
smearFEM.simulateMethod
simulate(x0, x1, y0, y1, z0, z1, ne, Young, ν, ndim, FunctionClass, nDof, β, CameraMatrix, endTime, tSteps, Control, cParam, cMat; writeData=false, filepath=nothing)

Simulate the deformation of a cylindrical under compression

Arguments:

  • x0::Float64 : x-coordinate of the lower left corner of the domain
  • x1::Float64 : x-coordinate of the upper right corner of the domain
  • y0::Float64 : y-coordinate of the lower left corner of the domain
  • y1::Float64 : y-coordinate of the upper right corner of the domain
  • z0::Float64 : z-coordinate of the lower left corner of the domain
  • z1::Float64 : z-coordinate of the upper right corner of the domain
  • ne::Int : number of elements
  • Young::Float64 : Young's modulus
  • ν::Float64 : Poisson's ratio
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function
  • nDof::Int : number of degree of freedom per node
  • β::Float64 : friction parameter
  • CameraMatrix::Matrix{Float64} : camera matrix
  • endTime::Float64 : end time
  • tSteps::Int : number of time steps to be taken
  • Control::String : type of control (force or displacement)
  • cParam::Vector{Float64} : control parameter (force or displacement prescribed at the top surface per time step)
  • cMat::Matrix{Float64} : control matrix
  • writeData::Bool : write the data to a file
  • filepath::String : path to the file
source
smearFEM.testMethod
test(x0, x1, y0, y1, z0, z1, ne, Young, ν, ndim, FunctionClass, nDof, β, CameraMatrix, endTime, tSteps, Control; writeData=false, filepath=nothing, mode = "standard")

Test the simulation

Arguments:

  • x0::Float64 : x-coordinate of the lower left corner of the domain
  • x1::Float64 : x-coordinate of the upper right corner of the domain
  • y0::Float64 : y-coordinate of the lower left corner of the domain
  • y1::Float64 : y-coordinate of the upper right corner of the domain
  • z0::Float64 : z-coordinate of the lower left corner of the domain
  • z1::Float64 : z-coordinate of the upper right corner of the domain
  • ne::Int : number of elements
  • Young::Float64 : Young's modulus
  • ν::Float64 : Poisson's ratio
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function
  • nDof::Int : number of degree of freedom per node
  • β::Float64 : friction parameter
  • CameraMatrix::Matrix{Float64} : camera matrix
  • endTime::Float64 : end time
  • tSteps::Int : number of time steps to be taken
  • Control::String : type of control (force or displacement)
  • writeData::Bool : write the data to a file
  • filepath::String : path to the file
  • mode::String : type of constitutive matrix
source
smearFEM.write_sim_dataMethod
write_sim_data(x0, x1, y0, y1, z0, z1, ne, Young, ν, ndim, FunctionClass, nDof, β, CameraMatrix, endTime, tSteps, Control, filename; mode = "standard")

Initialize the simulation and write the data to a file

Arguments:

  • x0::Float64 : x-coordinate of the lower left corner of the domain
  • x1::Float64 : x-coordinate of the upper right corner of the domain
  • y0::Float64 : y-coordinate of the lower left corner of the domain
  • y1::Float64 : y-coordinate of the upper right corner of the domain
  • z0::Float64 : z-coordinate of the lower left corner of the domain
  • z1::Float64 : z-coordinate of the upper right corner of the domain
  • ne::Int : number of elements
  • Young::Float64 : Young's modulus
  • ν::Float64 : Poisson's ratio
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function
  • nDof::Int : number of degree of freedom per node
  • β::Float64 : friction parameter
  • CameraMatrix::Matrix{Float64} : camera matrix
  • endTime::Float64 : end time
  • tSteps::Int : number of time steps to be taken
  • Control::String : type of control (force or displacement)
  • filename::String : path to the file
source
smearFEM.apply_boundary_conditions_stokesMethod

Apply the Neumann slip boundary conditions to the global stiffness matrix

Arguments:

K: {[ndof,ndof] SparseMatrixCSC{Float64,Int64}} : sparse stiffness matrix ID: {[nNodes,nDof] Matrix{Int}} : matrix that maps the global degrees of freedom to the local degrees of freedom qd: {[ndof] Vector{Float64}} : Dirichlet boundary conditions qn: {[ndof] Vector{Float64}} : Neumann boundary conditions

Returns:

K: {[ndof,ndof] SparseMatrixCSC{Float64,Int64}} : sparse stiffness matrix with the boundary conditions applied F: {[ndof] Vector{Float64}} : force vector

source
smearFEM.assemble_system_AMethod
assemble_system(ne, NodeList, IEN, ndim, FunctionClass="Q1", nDof=1, ID=nothing, Young=1, ν=0.3)

Assembles the finite element system. # Returns the global stiffness matrix

Arguments:

  • ne::Interger: number of elements in each direction
  • NodeList::Matrix{Float64}{ndim,nNodes} : coordinates of the nodes
  • IEN::Matrix{Int}{nElements,nLocalNodes} : connectivity matrix
  • ndim::Interger: number of dimensions
  • nDof::Interger: number of degree of freedom per node
  • FunctionClass::String: type of basis functions to be considered (Q1:quadratic or Q2:Lagrange)
  • ID::Matrix{Int}{nNodes,nDof} : matrix that maps the global degrees of freedom to the local degrees of freedom
  • Young::Float64: Young's modulus
  • ν::Float64: Poisson's ratio

Returns:

  • K::SparseMatrixCSC{Float64,Int64}{ndof,ndof} : sparse stiffness matrix
source
smearFEM.set_boundary_cond_stokesFunction

Set the Dirichlet boundary conditions for the problem

Arguments:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • ne::Int : number of elements
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function

Returns:

  • q_upper::Vector{Float64} : vector of the Dirichlet boundary conditions (for ndof = 1) / Dirichlet boundary conditions upper surface (for ndof > 1)
  • q_lower::Vector{Float64} : vector of the Neumann boundary conditions (for ndof = 1) / Dirichlet boundary conditions lower surface (for ndof > 1)
  • C_uc::SparseMatrixCSC{Float64,Int64} : onstraint matrix
source