Mesh generation

Node

Node struct

Amaru.NodeType
Node

A type that represents a finite element node.

Fields

  • id::Int64

: identification number

  • coord::Amaru.Vec3

: coordinates vector

  • tag::String

: string tag used to group nodes

  • dofs::Vector{Dof}

: array of degrees of freedom

  • dofdict::OrderedCollections.OrderedDict{Symbol, Dof}

: dictionary of degrees of freedom

Node constructors

Amaru.NodeMethod
Node() -> Node

Constructs an uninitiallised Node.

Amaru.NodeMethod
Node(x::Real) -> Node
Node(x::Real, y::Real) -> Node
Node(x::Real, y::Real, z::Real; tag, id) -> Node

Constructs an Node with coordinates x, y and z. A tag string can be provided optionally.

Examples

julia> using Amaru;
julia> Node(1.0, 2.0, 3.0, tag="vertex")
Node
  id: -1
  coord: [1.0, 2.0, 3.0]
  tag: "vertex"
  dofs: 0-element Vector{Dof}
  dofdict: OrderedDict{Symbol, Dof} with 0 entries
Amaru.NodeMethod
Node(X::AbstractArray; tag, id) -> Any

Constructs an Node with coordinates privided in the X vector. A tag string can be provided optionally.

Examples

julia> using Amaru;
julia> Node([1.0, 2.0, 3.0], tag="vertex")
Node
  id: -1
  coord: [1.0, 2.0, 3.0]
  tag: "vertex"
  dofs: 0-element Vector{Dof}
  dofdict: OrderedDict{Symbol, Dof} with 0 entries

Node functions

Base.copyMethod
copy(node::Node) -> Node

Creates a copy of node.

Amaru.tag!Method
tag!(object::Node, tag::String)

Tag a Node object by setting the tag string.

Amaru.tag!Method
tag!(objects, tag)

Tag all Node objects in an array using the tag string.

Amaru.add_dofFunction
add_dof(node::Node, name::Symbol, natname::Symbol)

Adds to node a new degree of freedom called name with associated natural variable natname.

Cell

Cell struct

Amaru.CellType
Cell

A type that represents a mesh cell. It can be a 1D, 2D or 3D.

Fields

  • id

: identification number

  • shape

: geometric shape

  • nodes

: array of nodes

  • tag

: string tag used to group cells

  • quality

: cell quality in the range from 0 to 1

  • embedded

: defines if it is an embedded cell

  • crossed

: defines if it is a crossed cell

  • owner

: owner cell if the cell is a face or edge

  • linked_elems

: array of coupled cells

Cell constructors

Amaru.CellMethod
Cell(shape, nodes; tag, owner, id)

Constructs a Cell given a shape and an array of nodes. A tag string can be provided optionally. If the cell is a face or an edge, the owner element cell can be provided.

Examples

julia> using Amaru;
julia> nodes = [ Node(0,0), Node(1,0), Node(1,1) ];
julia> Cell(TRI3, nodes, tag="triangle");
Cell
  id: -1
  shape: CellShape  name="TRI3"
  nodes: 3-element Vector{Node}:
      1: Node  id=-1
      2: Node  id=-1
      3: Node  id=-1
  tag: "triangle"
  quality: 0.0
  embedded: false
  crossed: false
  owner: nothing
  linked_elems: 0-element Vector{Amaru.AbstractCell}

Cell functions

Base.copyMethod
copy(cell::Cell) -> Cell

Creates a copy of cell.

Amaru.tag!Method
tag!(object::Cell, tag::String)

Tag a Cell object by setting the tag string.

Amaru.tag!Method
tag!(objects, tag)

Tag all Cell objects in an array using the tag string.

Blocks

Block struct

Amaru.BlockType
Block

A type that represents a segment, area or volume and is used to aid the generation of structured meshes by subdivision.

Fields

  • nodes

: array of vertices

  • shape

: block shape

  • cellshape

: shape for the resulting cells

  • nx

: number of divisions in the $x$ direction

  • ny

: number of divisions in the $y$ direction

  • nz

: number of divisions in the $z$ direction

  • rx

: growing rate in the $x$ direction

  • ry

: growing rate in the $y$ direction

  • rz

: growing rate in the $z$ direction

  • tag

: string tag to group blocks

Block constructors

Amaru.BlockMethod
Block(
    coords::Array;
    nx,
    ny,
    nz,
    n,
    rx,
    ry,
    rz,
    r,
    cellshape,
    tag,
    shape
) -> Block

Creates a 1D, 2D, 3D or surface Block using a coordinates matrix coords for the vertices and sets the number of divisions (nx, ny, nz) in the $x$, $y$ and $z$ directions of a local system. The ratios rx, ry and rz set the resulting cells growing rates in the corresponding directions. At the mesh generation stage, the shape of cells will be set according to cellshape (e.g. LIN2, TRI3, QUAD8, HEX8, WED15, etc.). If cellshape is not provided, the cells shape will be set to the lowest degree shape available. A tag string can be provided optionally. This tag will be inherinted by the cells generated from the block.

Block functions

Base.copyMethod
copy(block::Block) -> Block

Creates a copy of block.

Amaru.tag!Method
tag!(object::Block, tag::String)

Tag a Block object by setting the tag string.

Amaru.tag!Method
tag!(objects, tag)

Tag all Block objects in an array using the tag string.

Amaru.arrayMethod
array(block; nx, ny, nz, dx, dy, dz)

Creates a rectangular array of blocks of size nx×ny×nz using copies of block spaced at dx, dy and dz. The original bĺock is considered as part of the result.

Examples

```julia julia> block = Block([ 0 0; 1 1 ], nx=3, ny=3);

julia> blocks = array(block, nx=2, ny=2, dx=1, dy=1);

julia> length(blocks) 4 ```

Amaru.mirrorMethod
mirror(
    block::Amaru.AbstractBlock;
    axis,
    base
) -> Union{Block, BlockInset}

Creates a new Block by mirroring block according to a plane defined by a normal axis and base point.

Examples

julia> block1 = Block([ 0 0; 2 1; 1 1; 0 1], nx=2, ny=2);
julia> block2 = mirror(block1, axis=[1,1], base=[2,1])
Block
  nodes: 4-element Vector{Node}:
    1: Node  id=1
    2: Node  id=2
    3: Node  id=3
    4: Node  id=4
  shape: CellShape  name="QUAD4"
  cellshape: CellShape  name="QUAD4"
  nx: 2
  ny: 2
  nz: 1
  rx: 1.0
  ry: 1.0
  rz: 1.0
  tag: ""
Amaru.polarMethod
polar(block; base, axis, angle, n)
Creates a `polar` array using copies of `block` by rotating it
around `axis` along an `angle` domain. `n` representes 
the number of cells in the polar direction.

# Examples

```julia
julia> block = Block([ 0 0; 1 0; 0.707 0.707; 0 1; 0.5 0; 0.924 0.383; 0.382 0.924; 0.354 0.354 ], nx=3, ny=3);

julia> blocks = polar(block, base=[ 0, 0 ,0 ], axis=[ 0, 0, 1 ], angle=360, n=4);

julia> length(blocks)
4
```
LinearAlgebra.rotate!Method
rotate!(
    bl::Amaru.AbstractBlock;
    base,
    axis,
    angle
) -> Amaru.AbstractBlock

Rotates block an angle (default 90 degrees) around an axis that passes by a base point.

Examples

julia> block = Block([ 0 0; 1 1 ], nx=2, ny=2);

julia> getcoords(block)
4×3 Matrix{Float64}:
 0.0  0.0  0.0
 1.0  0.0  0.0
 1.0  1.0  0.0
 0.0  1.0  0.0

julia> rotate!(block, base=[ 0, 0, 0 ], axis=[ 0, 0, 1], angle=45);

julia> getcoords(block)
4×3 Matrix{Float64}:
 0.0       0.0       0.0
 0.707107  0.707107  0.0
 0.0       1.41421   0.0
 0.0       0.707107  0.0
Amaru.scale!Method
scale!(block; factor, base, axis)

Scales a block from the point base using the given factor. If axis is provided, the scaling is performent only in the axis direction.

Examples

julia> block = Block([ 0 0; 1 1 ], nx=2, ny=2);

julia> getcoords(block)
4×3 Matrix{Float64}:
 0.0  0.0  0.0
 1.0  0.0  0.0
 1.0  1.0  0.0
 0.0  1.0  0.0

julia> scale!(block, factor=0.5, base=[ 0, 0 ], axis=[ 1, 0 ]);

julia> getcoords(block)
4×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.5  0.0  0.0
 0.5  0.0  0.0
 0.0  0.0  0.0
Amaru.extrudeMethod
extrude(block::Block; axis, length, n, quiet) -> Block

Gets a 3D Block by extruding a 2D block in the direction given by axis and a distance length. It also sets the number of divisions n in the extruded direction.

Examples

julia> block2d = Block([ 0 0; 1 1 ], nx=3, ny=4, cellshape=QUAD8);
julia> block3d = extrude(block2d, axis=[0,0,1], length=1, n=5)
Block
  nodes: 8-element Vector{Node}:
    1: Node  id=1
    2: Node  id=2
    3: Node  id=3
    4: Node  id=4
    5: Node  id=5
    6: Node  id=6
    7: Node  id=7
    8: Node  id=8
  shape: CellShape  name="HEX8"
  cellshape: CellShape  name="HEX20"
  nx: 3
  ny: 4
  nz: 5
  rx: 1.0
  ry: 1.0
  rz: 1.0
  tag: ""

Mesh

Mesh struct

Amaru.MeshType
Mesh

A type that represents a finite element mesh. It contains geometric fields as: nodes, elems, faces, edges, ndim, quality, etc.

Fields

  • ndim

: mesh dimensions

  • nodes

: array of nodes

  • elems

: array of elements (cells)

  • faces

: array of faces (cells)

  • edges

: array of edges (cells)

  • node_data

: nodal data dictionary

  • elem_data

: element data dictionary

  • _pointdict

  • _elempartition

Mesh constructors

Amaru.MeshMethod
Mesh(coordinates, conns)
Mesh(coordinates, conns, cellshapes; tag, quiet)

Creates a Mesh from a nodal coordinates matrix, an array of connectivities and a list of cellshapes. If cellshapes are not provided, they are computed based on the geometry. A tag string for all generated cells can be provided optionally.

Examples

julia> using Amaru;
julia> C = [ 0 0; 1 0; 1 1; 0 1 ];
julia> L = [ [ 1, 2, 3 ], [ 1, 3, 4 ] ];
julia> S = [ TRI3, TRI3 ];
julia> Mesh(C, L, S, tag="triangle")

Mesh
  ndim: 2
  nodes: 4-element Vector{Node}:
    1: Node  id=1
    2: Node  id=2
    3: Node  id=3
    4: Node  id=4
  elems: 2-element Vector{Cell}:
    1: Cell  id=1  tag="triangle"
    2: Cell  id=2  tag="triangle"
  faces: 4-element Vector{Cell}:
    1: Cell  id=-1  tag="triangle"
    2: Cell  id=-1  tag="triangle"
    3: Cell  id=-1  tag="triangle"
    4: Cell  id=-1  tag="triangle"
  edges: 4-element Vector{Cell}:
    1: Cell  id=-1  tag="triangle"
    2: Cell  id=-1  tag="triangle"
    3: Cell  id=-1  tag="triangle"
    4: Cell  id=-1  tag="triangle"
  node_data: OrderedDict{String, Array} with 1 entry
    "node-id" => [1, 2, 3, 4]
  elem_data: OrderedDict{String, Array} with 3 entries
    "quality" => [0.8915188114208271, 0.8915188114208271]
    "elem-id" => [1, 2]
    "cell-type" => [5, 5]
Amaru.MeshMethod
Mesh(items; genfacets, genedges, reorder, quiet)

Generates a Mesh based from a set of items that can be Block or Mesh objects, or a combination of both. If reorder is true (default), the nodes are ordered using the Cuthill–McKee algorithm. The mesh generation steps are printed in stdout. The printed output can be set to verbose or silent.

Examples

julia> using Amaru;
julia> B1 = Block([0 0; 1 1], nx=2, ny=2);
julia> B2 = Block([1 0; 2 1], nx=3, ny=2);
julia> Mesh(B1, B2)
Mesh
  ndim: 2
  nodes: 18-element Vector{Node}:
    1: Node  id=1
    2: Node  id=2
    3: Node  id=3
    4: Node  id=4
    ⋮
    15: Node  id=15
    16: Node  id=16
    17: Node  id=17
    18: Node  id=18
  elems: 10-element Vector{Cell}:
    1: Cell  id=1
    2: Cell  id=2
    3: Cell  id=3
    4: Cell  id=4
    ⋮
    7: Cell  id=7
    8: Cell  id=8
    9: Cell  id=9
    10: Cell  id=10
  faces: 14-element Vector{Cell}:
    1: Cell  id=-1
    2: Cell  id=-1
    3: Cell  id=-1
    4: Cell  id=-1
    ⋮
    11: Cell  id=-1
    12: Cell  id=-1
    13: Cell  id=-1
    14: Cell  id=-1
  edges: 14-element Vector{Cell}:
    1: Cell  id=-1
    2: Cell  id=-1
    3: Cell  id=-1
    4: Cell  id=-1
    ⋮
    11: Cell  id=-1
    12: Cell  id=-1
    13: Cell  id=-1
    14: Cell  id=-1
  node_data: OrderedDict{String, Array} with 1 entry
    "node-id" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
  elem_data: OrderedDict{String, Array} with 3 entries
    "quality" => 10-element Vector{Float64}
    "elem-id" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    "cell-type" => [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]

Mesh functions