Functions
Boxes
MeshSteward.initbox
— Functioninitbox(x::AbstractVector{T}) where {T}
Create a bounding box and initialize with a single point.
MeshSteward.updatebox!
— Functionupdatebox!(box::AbstractVector{T}, x::AbstractVector{T}) where {T}
Update a box with another location, or create a new box.
If the box
does not have the correct dimensions, it is correctly sized.
box
= bounding box for 1-D box=[minx,maxx]
, or for 2-D box=[minx,maxx,miny,maxy]
, or for 3-D box=[minx,maxx,miny,maxy,minz,maxz]
x
= vector defining a point. The box
is expanded to include the supplied location x
.
MeshSteward.boundingbox
— Functionboundingbox(x::AbstractArray{T}) where {T}
Compute the bounding box of the points in x
.
x
= holds points, one per row.
Returns box
= bounding box for 1-D box=[minx,maxx]
, or for 2-D box=[minx,maxx,miny,maxy]
, or for 3-D box=[minx,maxx,miny,maxy,minz,maxz]
MeshSteward.inflatebox!
— Functioninflatebox!(box::AbstractVector{T}, inflatevalue::T) where {T}
Inflate the box by the value supplied.
MeshSteward.inbox
— Functioninbox(box::AbstractVector{T}, x::AbstractVector{T}) where {T}
Is the given location inside the box?
box
= vector entries arranged as minx,maxx,miny,maxy,minz,maxz.
Note: point on the boundary of the box is counted as being inside.
MeshSteward.boxesoverlap
— Functionboxesoverlap(box1::AbstractVector{T}, box2::AbstractVector{T}) where {T}
Do the given boxes overlap?
MeshSteward.intersectboxes
— Functionintersectboxes(box1::AbstractVector{T}, box2::AbstractVector{T}) where {T}
Compute the intersection of two boxes.
The function returns an empty box (length(b) == 0) if the intersection is empty; otherwise a box is returned.
Searching vertices and elements
MeshSteward.vselect
— Functionvselect(v::VT; kwargs...) where {VT}
Select locations (vertices) based on some criterion.
VT
is an abstract array that returns the coordinates of a vertex given its number.
Selection criteria
box
nLx = vselect(v, box = [0.0 Lx 0.0 0.0 0.0 0.0], inflate = Lx/1.0e5)
The keyword 'inflate' may be used to increase or decrease the extent of the box (or the distance) to make sure some nodes which would be on the boundary are either excluded or included.
distance
list = vselect(v, distance=1.0+0.1/2^nref, from=[0. 0.], inflate=tolerance);
plane
candidates = vselect(v, plane = [0.0 0.0 1.0 0.0], thickness = h/1000)
The keyword plane
defines the plane by its normal (the first two or three numbers) and its distance from the origin (the last number). Nodes are selected they lie on the plane, or near the plane within the distance thickness
from the plane. The normal is assumed to be of unit length, if it isn't provided as such, it will be normalized internally.
nearestto
Find the node nearest to the location given.
nh = vselect(v, nearestto = [R+Ro/2, 0.0, 0.0])
Returns
The list of vertices that match the search criterion.
vselect(m::Mesh; kwargs...)
Select vertices. Return as an incidence relation.
Refer to vselect
that works with the geometry attribute.
MeshSteward.eselect
— Functioneselect(ir::IncRel; kwargs...)
Select finite elements.
Arguments
ir
= incidence relation representing finite element set(d, 0)
. The "elements" are the shapes on the left of the incidence relation.kwargs
= keyword arguments to specify the selection criteria
Selection criteria
facing
Select all "boundary" elements that "face" a certain direction.
exteriorbfl = eselect(ir, facing=true, direction=x -> [1.0, 1.0, 0.0]);
or
exteriorbfl = eselect(ir, facing=true, direction=xyz -> xyz/norm(xyz), dotmin = 0.99);
where xyz
is the location of the centroid of a boundary element. Here the finite element is considered "facing" in the given direction if the dot product of its normal and the direction vector is greater than dotmin
. The default value for dotmin
is 0.01 (this corresponds to almost 90 degrees between the normal to the finite element and the given direction).
This selection method makes sense only for elements that are surface-like (i. e. for boundary meshes).
label
Select elements based on their label.
rl1 = eselect(ir, label=1)
box, distance
Select elements based on some criteria that their nodes satisfy. See the function vselect()
.
Example: Select all elements whose nodes are closer than R+inflate
from the point from
.
linner = eselect(ir, distance = R, from = [0.0 0.0 0.0], inflate = tolerance)
Example:
exteriorbfl = eselect(ir, box=[1.0, 1.0, 0.0, pi/2, 0.0, Th], inflate=tolerance)
where Th
is a variable.
Optional keyword arguments
Should we consider the element only if all its nodes are in?
allin
= Boolean: if true, then all nodes of an element must satisfy the criterion; otherwise one is enough.
Output
felist
= list of finite elements (shapes) from the from the collection on the left of the incidence relation that satisfy the criteria
Import of meshes
MeshSteward.import_MESH
— Functionimport_MESH(meshfile)
Import vertices and shapes in the MESH format.
Output
Data dictionary, with keys
- "
vertices
" (vertices), - "
shapes
" (array of shape collections).
MeshSteward.import_NASTRAN
— Functionimport_NASTRAN(filename)
Import tetrahedral (4- and 10-node) NASTRAN mesh (.nas file).
Limitations:
- only the GRID and CTETRA sections are read.
- Only 4-node and 10-node tetrahedra are handled.
- The file should be free-form (data separated by commas).
Some fixed-format files can also be processed (large-field, but not small-field).
Output
Data dictionary, with keys
- "
vertices
" (vertices), - "
shapes
" (array of shape collections).
MeshSteward.import_ABAQUS
— Functionimport_ABAQUS(filename)
Import tetrahedral (4- and 10-node) or hexahedral (8- and 20-node) Abaqus mesh (.inp file).
Limitations:
- Only the
*NODE
and*ELEMENT
sections are read - Only 4-node and 10-node tetrahedra, 8-node or 20-node hexahedra, 3-node triangles are handled.
Output
Data dictionary, with keys
- "
fens
" (finite element nodes), - "
fesets
" (array of finite element sets).
Export of meshes
MeshSteward.vtkwrite
— Functionvtkwrite(filename, connectivity)
Write VTK file with the mesh.
connectivity
= incidence relation of the typed -> 0
. It must have a "geom" attribute for access to the locations of all the vertices that the connectivity incidence relation references.data
= array of named tuples. Names of attributes of either the left or the right shape collection of theconnectivity
incidence relation. Property names::name
required, name of the attribute.:allxyz
optional, pad the attribute to be a three-dimensional quantity (in the global Cartesian coordinate system).
MeshSteward.export_MESH
— Functionexport_MESH(meshfile, mesh)
Import vertices and shapes in the MESH format.
Output
Data dictionary, with keys
- "
vertices
" (vertices), - "
shapes
" (array of shape collections).
Management of meshes
MeshSteward.load
— Functionload(m::Mesh, filename::String)
Load a mesh (incidence relation) from a MESH file.
No check is performed that the loaded incidence relation is compatible with the existing incidence relations in the mesh.
MeshSteward.save
— Functionsave(m::Mesh, filename::String)
Save a mesh base incidence relation to a MESH file.
MeshSteward.increl
— Functionincrel(m::Mesh, irc::Tuple{Int64, Int64})
Retrieve the named incidence relation based on the code.
Any tag is matched.
increl(m::Mesh, fullirc::Tuple{Tuple{Int64, Int64}, String})
Retrieve the named incidence relation based on the full key (code + tag).
MeshSteward.attach!
— Functionattach!(m::Mesh, increl::IncRel)
Attach the incidence relation under its code and empty tag.
The code of the incidence relation combined with an empty tag (""
) is the key under which this relation is stored in the mesh.
attach!(m::Mesh, increl::IncRel, tag::String)
Attach the incidence relation under its code and given tag.
The code of the incidence relation combined with the tag is the key under which this relation is stored in the mesh.
MeshSteward.basecode
— Functionbasecode(m::Mesh)
Compute the code of the base relation.
The base incidence relation is (d, 0)
that represents the elements of the interior of the domain.
MeshSteward.nspacedims
— Functionnspacedims(m::Mesh)
Furnish the dimension of the space in which the mesh lives.
Base.summary
— FunctionBase.summary(m::Mesh)
Form a brief summary of the mesh.
Base.summary(io::IO, m::Mesh)
Form a brief summary of the mesh.
MeshSteward.boundary
— Functionboundary(m::Mesh)
Compute the boundary of the mesh.
The incidents relation is stored in the mesh with the tag "boundary".
MeshSteward.vertices
— Functionvertices(m::Mesh)
Compute the (0, 0)
incidence relation for the vertices of the base incidence relation.
MeshSteward.submesh
— Functionsubmesh(m::Mesh, list)
Extract a submesh constructed of a subset of the base relation.
MeshSteward.label
— Functionlabel(m::Mesh, irc, list, lab)
Label shapes in list
with the label lab
.
Label the shapes on the shapecoll
of the incidence relation. shapecoll
must be either :left
or :right
.
Index
Base.summary
MeshSteward.attach!
MeshSteward.basecode
MeshSteward.boundary
MeshSteward.boundingbox
MeshSteward.boxesoverlap
MeshSteward.eselect
MeshSteward.export_MESH
MeshSteward.import_ABAQUS
MeshSteward.import_MESH
MeshSteward.import_NASTRAN
MeshSteward.inbox
MeshSteward.increl
MeshSteward.inflatebox!
MeshSteward.initbox
MeshSteward.intersectboxes
MeshSteward.label
MeshSteward.load
MeshSteward.nspacedims
MeshSteward.save
MeshSteward.submesh
MeshSteward.updatebox!
MeshSteward.vertices
MeshSteward.vselect
MeshSteward.vtkwrite