API Reference
Core functions
smearFEM.basis_function
— Functionbasis_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 evaluatedFunctionClass::String
: type of basis functions to be considered (Q1:quadratic or Q2:Lagrange)
Returns:
N::Vector{Float64}{,ndof}
: basis functionsDelta_N::Matrix{Float64}{ndof,ndim}
: gradient of the basis functions
smearFEM.gaussian_quadrature
— MethodsmearFEM.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 intervalnGaussPoints::Integer
: number of Gauss points to be considered (2 or 3)
Returns:
ξ::Vector{Float64}{,nGaussPoints}
: nodes.w::Vector{Float64}{,nGaussPoints}
: weights
Meshes
smearFEM.inflate_cylinder
— Methodinflate_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 nodesx0::Float64
: x-coordinate of the lower left corner of the domainx1::Float64
: x-coordinate of the upper right corner of the domainy0::Float64
: y-coordinate of the lower left corner of the domainy1::Float64
: y-coordinate of the upper right corner of the domain
Returns:
NodeList::Matrix{Float64}{nNodes,ndim}
: array of nodes
smearFEM.meshgrid_cube
— Methodmeshgrid_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 domainx1::Float64
: x-coordinate of the upper right corner of the domainy0::Float64
: y-coordinate of the lower left corner of the domainy1::Float64
: y-coordinate of the upper right corner of the domainz0::Float64
: z-coordinate of the lower left corner of the domainz1::Float64
: z-coordinate of the upper right corner of the domainne::Int
: number of elementsndim::Int
: number of dimensionsFunctionClass::String
: type of basis function
Returns:
NodeList::Matrix{Float64}{nNodes,ndim}
: array of nodesIEN::Matrix{Int64}{ne^ndim,2^ndim}
: array of elementsID::Matrix{Int64}{nNodes,ndim}
: array of node IDsIEN_top::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)}
: array of elements on the top surfaceIEN_btm::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)}
: array of elements on the bottom surfaceBorderNodes::Vector{Int64}
: array of nodes on the boundariesBottomBorderNodes::Vector{Int64}
: array of nodes on the bottom boundaryTopBorderNodes::Vector{Int64}
: array of nodes on the top boundary
smearFEM.meshgrid_line
— Methodmeshgrid_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 domainx1::Float64
: x-coordinate of the upper right corner of the domainne::Int
: number of elementsFunctionClass::String
: type of basis function (Q1 or Q2)
Returns:
NodeList::Matrix{Float64}{nNodes,ndim}
: array of nodesIEN::Matrix{Int64}{ne^ndim,2^ndim}
: array of elements
smearFEM.meshgrid_ring
— Methodmeshgrid_ring(r1,r2, theta1, theta2, ne)
Set up the mesh grid for a 2D annulus ring
Arguments:
r1::Float64
: inner radiusr2::Float64
: outer radiustheta1::Float64
: start angletheta2::Float64
: end anglene::Int
: number of elements
Returns:
NodeList::Matrix{Float64}{nNodes,ndim}
: array of nodesIEN::Matrix{Int64}{ne^ndim,2^ndim}
: connectivity matrix
smearFEM.meshgrid_square
— Methodmeshgrid_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 domainx1::Float64
: x-coordinate of the upper right corner of the domainy0::Float64
: y-coordinate of the lower left corner of the domainy1::Float64
: y-coordinate of the upper right corner of the domainne::Int
: number of elementsndim::Int
: number of dimensionsFunctionClass::String
: type of basis function
Returns:
NodeList::Matrix{Float64}{nNodes,ndim}
: array of nodesIEN::Matrix{Int64}{ne^ndim,2^ndim}
: array of elementsID::Matrix{Int64}{nNodes,ndim}
: array of node IDsIEN_top::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)}
: array of elements on the top surfaceIEN_btm::Matrix{Int64}{ne^(ndim-1),2^(ndim-1)}
: array of elements on the bottom surfaceBorderNodes::Vector{Int64}
: array of nodes on the boundariesBottomBorderNodes::Vector{Int64}
: array of nodes on the bottom boundaryTopBorderNodes::Vector{Int64}
: array of nodes on the top boundary
Post processing functions
smearFEM.back_project
— Methodback_project(NodeList, CameraMatrix)
Project the 3D mesh to 2D image plane
Arguments:
NodeList::Matrix{Float64}{3,nbNodes}
: 3D mesh gridCameraMatrix::Matrix{Float64}{3,3}
: Camera matrix
Returns:
NodeList2D::Matrix{Float64}{2,nbNodes}
: 2D coordinates of the nodes
smearFEM.extract_borders
— FunctionExtract_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 nodesCameraMatrix::Matrix{Float64}{3,3}
: Camera matrixBorderNodesList::Vector{Vector{Any}{4,N}
: : List of border nodesstate::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 nodesBorderNodes::Vector{Int}
: Indexes of the border nodes
smearFEM.filter_points
— Methodfilter_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 nodescenterx::Float64
: x-coordinate of the centerline
Returns:
newBorderxSrt::Vector{Float64}
: x coordinates of the sorted border nodesnewBorderySrt::Vector{Float64}
: y coordinates of the sorted border nodes
smearFEM.fit_curve
— Methodfit_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 nodesborderx::Vector{Float64}
: x coordinates of the border nodesbordery::Vector{Float64}
: y coordinates of the border nodes
Returns:
pi::Vector{Float64}
: x coordinates of the fitted curveqi::Vector{Float64}
: y coordinates of the fitted curve
smearFEM.fit_curve_2D
— Methodfit_curve_2D(x,y, n)
Fit a curve to the border nodes of the 2D mesh
Arguments:
x::Vector{Float64}
: x coordinatesy::Vector{Float64}
: y coordinatesn::Integer
: number of sampled points
Returns:
points::Vector{Float64}
: vector of n sampled points
smearFEM.noramlize
— Methodnoramlize(q, IEN)
Function normalize the solution vector for plotting
Arguments:
q
: solution vectorIEN::Matrix{Float64}{nElem, nNodes}
: IEN array
Returns:
qList
: normalized list of solutions
smearFEM.rearrange
— Functionrearrange(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 vectorne::Integer
: number of elements in each directionndim::Integer
: number of dimensionsIEN::Matrix{Float64}{nElem, nNodes}
: Connectivity matrixFunctionClass::String
: type of basis function
Returns:
q_new::Vector{Float64}
: rearranged solution vectorIEN_new::Matrix{Int64}
: rearranged connectivity matrix
smearFEM.truncate_colormap
— Functiontruncate_colormap(minval=0.0, maxval=1.0, n=100)
Function to truncate a colormap
Arguments:
minval::Integer
: minimum value of the colormapmaxval::Integer
: maximum value of the colormapn::Integer
: number of colors
Returns:
new_cmap
: truncated colormap
Visualizations
smearFEM.PlotGrid
— MethodPlotGrid(IEN, NodeList)
Function to plot the grid
Arguments:
IEN::Matrix{Float64}{nElem, nNodes}
: IEN array.NodeList::Matrix{Float64}{nNodes, ndim}
: array of nodes.
smearFEM.animate2D
— Methodanimate2D(;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 meshfields2D::Vector{Vector{Float64}}
: 2D projection of the solution vectorp::Vector{Float64}
: x coordinates of the extracted convex hullq::Vector{Float64}
: y coordinates of the extracted convex hull
smearFEM.animate3D
— Methodanimate3D(fields)
Function to animate the 3D fields as a gif
Arguments:
fields::Vector{Vector{Float64}}
: solution vector
smearFEM.animate_fields
— Methodanimate_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 vectorfields2D::Vector{Vector{Float64}}
: 2D projection of the solution vectorBorderNodes2D::Vector{Vector{Float64}}
: 2D coordinates of the border nodes of the meshIEN::Matrix{Float64}{nElem, nNodes}
: IEN arrayp::Vector{Float64}
: x coordinates of the extracted convex hullq::Vector{Float64}
: y coordinates of the extracted convex hull
smearFEM.plot_mesh
— Methodplot_meshgrid(NodeList, IEN)
Function to plot the mesh
Arguments:
NodeList::Matrix{Float64}{nNodes,ndim}
: array of nodes.IEN::Matrix{nElem,nNodes}
: IEN array.
io
smearFEM.writeCSV
— MethodwriteCSV(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.
smearFEM.write_scene
— Methodwrite_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 arrayne::Integer
: number of elements in each direction.ndim::Integer
: number of dimensionsfields::Vector{Vector{Float64}}
: vector of solution fields.
smearFEM.write_vtk
— Methodwrite_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.