Functions

Boxes

MeshSteward.initboxFunction
initbox(x::AbstractVector{T}) where {T}

Create a bounding box and initialize with a single point.

source
MeshSteward.updatebox!Function
updatebox!(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.

source
MeshSteward.boundingboxFunction
boundingbox(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]

source
MeshSteward.inboxFunction
inbox(box::AbstractVector{T}, x::AbstractVector{T}) where {T}

Is the given location inside the box?

Note: point on the boundary of the box is counted as being inside.

source
MeshSteward.intersectboxesFunction
intersectboxes(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.

source

Searching vertices and elements

MeshSteward.vselectFunction
vselect(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.

source
vselect(m::Mesh; kwargs...)

Select vertices. Return as an incidence relation.

Refer to vselect that works with the geometry attribute.

source
MeshSteward.eselectFunction
eselect(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
source

Import of meshes

MeshSteward.import_MESHFunction
import_MESH(meshfile)

Import vertices and shapes in the MESH format.

Output

Data dictionary, with keys

  • "vertices" (vertices),
  • "shapes" (array of shape collections).
source
MeshSteward.import_NASTRANFunction
import_NASTRAN(filename)

Import tetrahedral (4- and 10-node) NASTRAN mesh (.nas file).

Limitations:

  1. only the GRID and CTETRA sections are read.
  2. Only 4-node and 10-node tetrahedra are handled.
  3. 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).
source
MeshSteward.import_ABAQUSFunction
import_ABAQUS(filename)

Import tetrahedral (4- and 10-node) or hexahedral (8- and 20-node) Abaqus mesh (.inp file).

Limitations:

  1. Only the *NODE and *ELEMENT sections are read
  2. 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).
source

Export of meshes

MeshSteward.vtkwriteFunction
vtkwrite(filename, connectivity)

Write VTK file with the mesh.

  • connectivity = incidence relation of the type d -> 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 the connectivity 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).
source
MeshSteward.export_MESHFunction
export_MESH(meshfile, mesh)

Import vertices and shapes in the MESH format.

Output

Data dictionary, with keys

  • "vertices" (vertices),
  • "shapes" (array of shape collections).
source

Management of meshes

MeshSteward.loadFunction
load(m::Mesh, filename::String)

Load a mesh (incidence relation) from a MESH file.

Note

No check is performed that the loaded incidence relation is compatible with the existing incidence relations in the mesh.

source
MeshSteward.saveFunction
save(m::Mesh, filename::String)

Save a mesh base incidence relation to a MESH file.

source
MeshSteward.increlFunction
increl(m::Mesh, irc::Tuple{Int64, Int64})

Retrieve the named incidence relation based on the code.

Any tag is matched.

source
increl(m::Mesh, fullirc::Tuple{Tuple{Int64, Int64}, String})

Retrieve the named incidence relation based on the full key (code + tag).

source
MeshSteward.attach!Function
attach!(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.

source
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.

source
MeshSteward.basecodeFunction
basecode(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.

source
Base.summaryFunction
Base.summary(m::Mesh)

Form a brief summary of the mesh.

source
Base.summary(io::IO, m::Mesh)

Form a brief summary of the mesh.

source
MeshSteward.boundaryFunction
boundary(m::Mesh)

Compute the boundary of the mesh.

The incidents relation is stored in the mesh with the tag "boundary".

source
MeshSteward.verticesFunction
vertices(m::Mesh)

Compute the (0, 0) incidence relation for the vertices of the base incidence relation.

source
MeshSteward.labelFunction
label(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.

source

Index