API Reference

Core functions

smearFEM.basis_functionFunction
basis_function(ξ,η=nothing,ζ=nothing,FunctionClass = "Q1")

Define the basis functions and the gradients for a master element

Arguments:

  • ξ::Float64: ξ coordinate of the point where the basis function is evaluated
  • η::Float64: η coordinate of the point where the basis function is evaluated
  • ζ::Float64: ζ coordinate of the point where the basis function is evaluated
  • FunctionClass::String: type of basis functions to be considered (Q1:quadratic or Q2:Lagrange)

Returns:

  • N::Vector{Float64}{,ndof}: basis functions
  • Delta_N::Matrix{Float64}{ndof,ndim}: gradient of the basis functions
source
smearFEM.gaussian_quadratureMethod
smearFEM.gaussian_quadrature(a,b,nGaussPoints)

Compute the nodes and weights for the Gaussian quadrature of order 2

Arguments:

  • a,b::Integer : the limits of the integration interval
  • nGaussPoints::Integer : number of Gauss points to be considered (2 or 3)

Returns:

  • ξ::Vector{Float64}{,nGaussPoints}: nodes.
  • w::Vector{Float64}{,nGaussPoints}: weights
source

Meshes

smearFEM.inflate_cylinderMethod
inflate_cylinder(NodeList, x0, x1, y0, y1)

Inflate the sphere to a cylinder of unit radius and height

Arguments:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • 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

Returns:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
source
smearFEM.meshgrid_cubeMethod
meshgrid_cube(x0,x1,y0,y1,z0,z1,ne,ndim;FunctionClass="Q1")

Set up the mesh grid for a 3D cube

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

Returns:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • IEN::Matrix{Int64}{ne^ndim,2^ndim} : array of elements
  • ID::Matrix{Int64}{nNodes,ndim} : array of node IDs
  • IEN_top::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)} : array of elements on the top surface
  • IEN_btm::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)} : array of elements on the bottom surface
  • BorderNodes::Vector{Int64} : array of nodes on the boundaries
  • BottomBorderNodes::Vector{Int64} : array of nodes on the bottom boundary
  • TopBorderNodes::Vector{Int64} : array of nodes on the top boundary
source
smearFEM.meshgrid_lineMethod
meshgrid_line(x0,x1,ne,FunctionClass="Q1")

Set up the mesh grid for a 1D line

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
  • ne::Int : number of elements
  • FunctionClass::String : type of basis function (Q1 or Q2)

Returns:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • IEN::Matrix{Int64}{ne^ndim,2^ndim} : array of elements
source
smearFEM.meshgrid_ringMethod
meshgrid_ring(r1,r2, theta1, theta2, ne)

Set up the mesh grid for a 2D annulus ring

Arguments:

  • r1::Float64 : inner radius
  • r2::Float64 : outer radius
  • theta1::Float64 : start angle
  • theta2::Float64 : end angle
  • ne::Int : number of elements

Returns:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • IEN::Matrix{Int64}{ne^ndim,2^ndim} : connectivity matrix
source
smearFEM.meshgrid_squareMethod
meshgrid_square(x0,x1,y0,y1,ne,ndim;FunctionClass="Q1")

Set up the mesh grid for a 2D square

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
  • ne::Int : number of elements
  • ndim::Int : number of dimensions
  • FunctionClass::String : type of basis function

Returns:

  • NodeList::Matrix{Float64}{nNodes,ndim} : array of nodes
  • IEN::Matrix{Int64}{ne^ndim,2^ndim} : array of elements
  • ID::Matrix{Int64}{nNodes,ndim} : array of node IDs
  • IEN_top::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)} : array of elements on the top surface
  • IEN_btm::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)} : array of elements on the bottom surface
  • BorderNodes::Vector{Int64} : array of nodes on the boundaries
  • BottomBorderNodes::Vector{Int64} : array of nodes on the bottom boundary
  • TopBorderNodes::Vector{Int64} : array of nodes on the top boundary
source

Post processing functions

smearFEM.back_projectMethod
back_project(NodeList, CameraMatrix)

Project the 3D mesh to 2D image plane

Arguments:

  • NodeList::Matrix{Float64}{3,nbNodes}: 3D mesh grid
  • CameraMatrix::Matrix{Float64}{3,3}: Camera matrix

Returns:

  • NodeList2D::Matrix{Float64}{2,nbNodes}: 2D coordinates of the nodes
source
smearFEM.extract_bordersFunction
Extract_borders(NodeList, CameraMatrix, BorderNodesList, state, ne = nothing)

Project the 3D mesh to 2D image plane and extract the border nodes (left and right)

Arguments:

  • NodeList::Matrix{Float64}{ndim,nNodes} : coordinates of the nodes
  • CameraMatrix::Matrix{Float64}{3,3} : Camera matrix
  • BorderNodesList::Vector{Vector{Any}{4,N}: : List of border nodes
  • state::String : State of the function (init:During the initialization of the mesh or update: when the mesh is updated)
  • ne::Integer: Number of elements in each direction

Returns:

  • NodeList::Matrix{Float64}{ndim,nbNodes}: 2D coordinates of the border nodes
  • BorderNodes::Vector{Int}: Indexes of the border nodes
source
smearFEM.filter_pointsMethod
filter_points(border, centerx)

Select the nodes on the right side of the centerline and sort them

Arguments:

  • border::Matrix{Float64}{2,nbNodes}: 2D coordinates of the border nodes
  • centerx::Float64: x-coordinate of the centerline

Returns:

  • newBorderxSrt::Vector{Float64}: x coordinates of the sorted border nodes
  • newBorderySrt::Vector{Float64}: y coordinates of the sorted border nodes
source
smearFEM.fit_curveMethod
fit_curve(; border, borderx, bordery)

Fit a curve to the border nodes of the 2D mesh

Arguments:

  • border::Matrix{Float64}{2,nbNodes}: 2D coordinates of the border nodes
  • borderx::Vector{Float64}: x coordinates of the border nodes
  • bordery::Vector{Float64}: y coordinates of the border nodes

Returns:

  • pi::Vector{Float64}: x coordinates of the fitted curve
  • qi::Vector{Float64}: y coordinates of the fitted curve
source
smearFEM.fit_curve_2DMethod
fit_curve_2D(x,y, n)

Fit a curve to the border nodes of the 2D mesh

Arguments:

  • x::Vector{Float64}: x coordinates
  • y::Vector{Float64}: y coordinates
  • n::Integer: number of sampled points

Returns:

  • points::Vector{Float64}: vector of n sampled points
source
smearFEM.noramlizeMethod
noramlize(q, IEN)

Function normalize the solution vector for plotting

Arguments:

  • q: solution vector
  • IEN::Matrix{Float64}{nElem, nNodes}: IEN array

Returns:

  • qList: normalized list of solutions
source
smearFEM.rearrangeFunction
rearrange(q, ne, ndim, IEN, FunctionClass)

Rearrange the solution vector from the lagrangian basis functions for to bilinear basis function for plotting and visualization in paraview

Arguments:

  • q::Vector{Float64}: solution vector
  • ne::Integer: number of elements in each direction
  • ndim::Integer: number of dimensions
  • IEN::Matrix{Float64}{nElem, nNodes}: Connectivity matrix
  • FunctionClass::String: type of basis function

Returns:

  • q_new::Vector{Float64}: rearranged solution vector
  • IEN_new::Matrix{Int64}: rearranged connectivity matrix
source
smearFEM.truncate_colormapFunction
truncate_colormap(minval=0.0, maxval=1.0, n=100)

Function to truncate a colormap

Arguments:

  • minval::Integer: minimum value of the colormap
  • maxval::Integer: maximum value of the colormap
  • n::Integer: number of colors

Returns:

  • new_cmap: truncated colormap
source

Visualizations

smearFEM.PlotGridMethod
PlotGrid(IEN, NodeList)

Function to plot the grid

Arguments:

  • IEN::Matrix{Float64}{nElem, nNodes}: IEN array.
  • NodeList::Matrix{Float64}{nNodes, ndim}: array of nodes.
source
smearFEM.animate2DMethod
animate2D(;BorderNodes2D=nothing, fields2D=nothing, p=nothing, q=nothing)

Function to animate the 2D fields as a gif

Arguments:

  • BorderNodes2D::Vector{Vector{Float64}}: 2D coordinates of the border nodes of the mesh
  • fields2D::Vector{Vector{Float64}}: 2D projection of the solution vector
  • p::Vector{Float64}: x coordinates of the extracted convex hull
  • q::Vector{Float64}: y coordinates of the extracted convex hull
source
smearFEM.animate3DMethod
animate3D(fields)

Function to animate the 3D fields as a gif

Arguments:

  • fields::Vector{Vector{Float64}}: solution vector
source
smearFEM.animate_fieldsMethod
animate_fields(;filepath=nothing, fields=nothing , IEN=nothing, BorderNodes2D=nothing, fields2D=nothing, p=nothing, q=nothing)

Function to animate the fields as a gif

Arguments:

  • fields::Vector{Vector{Float64}}: solution vector
  • fields2D::Vector{Vector{Float64}}: 2D projection of the solution vector
  • BorderNodes2D::Vector{Vector{Float64}}: 2D coordinates of the border nodes of the mesh
  • IEN::Matrix{Float64}{nElem, nNodes}: IEN array
  • p::Vector{Float64}: x coordinates of the extracted convex hull
  • q::Vector{Float64}: y coordinates of the extracted convex hull
source
smearFEM.plot_meshMethod
plot_meshgrid(NodeList, IEN)

Function to plot the mesh

Arguments:

  • NodeList::Matrix{Float64}{nNodes,ndim}: array of nodes.
  • IEN::Matrix{nElem,nNodes}: IEN array.
source

io

smearFEM.writeCSVMethod
writeCSV(fileName, borders)

Function to write the border data to a CSV file.

Arguments:

  • fileName::String: name of the file.
  • borders::Vector{Matrix{Float64}}: vector of border data.
source
smearFEM.write_sceneMethod
write_scene(fileName, NodeList, IEN, ne, ndim, fields)

Function to write the solution to a VTK file

Arguments:

  • fileName::String: name of the VTK file.
  • NodeList::Matrix{Float64}{nNodes, ndim}: array of nodes.
  • IEN::Matrix{nElem, nNodes}: IEN array
  • ne::Integer: number of elements in each direction.
  • ndim::Integer: number of dimensions
  • fields::Vector{Vector{Float64}}: vector of solution fields.
source
smearFEM.write_vtkMethod
write_vtk(fileName, fieldName, NodeList, IEN, ne, ndim, q)

Function to write the solution to a VTK file

Arguments:

  • fileName::String: name of the VTK file.
  • NodeList::Matrix[nNodes, ndim]: array of nodes.
  • IEN::Matrix{Float64}{nElem, nNodes}: IEN array.
  • ne::Integer: number of elements in each direction.
  • ndim::Integer: number of dimensions.
  • q::Vector{Float64}: vector of solution fields.
source