Elements and Meshes

Discretization objects, containing both the meshing and the solution space approximation.

That is inside this object is both the \(h\) and \(p\) discretization. These are in this code orginized together as no local \(p\) refinement is expeced. There is a base class, Mesh, specifying the interface to the main kernel and solver, and there are the following interited classes specifying:

  1. Mesh1D for a 1D mesh of different approximation orders \(p\).

  2. Mesh2Dtri for a 2D mesh of triangles.

  3. Mesh2Dqua for a 2D mesh of quadralatirals.

And although these have the name ‘mesh’ they do describe the elements as well.

Bram Lagerweij COHMAS Mechanical Engineering KAUST 2021

Base Mesh

class element.Mesh

Specify a base mesh object, and it’s behaviour.

This base class is not an actual usefull mesh but provides the basics outline that should be in all other mesh classes. All other meshes should be childeren from this base class. But inheritance works badly with the just in time compilation of numba. Hence all function have to be redefined in the child classes, while the class requires the @nb.jitclass(spec) decorator.

num_ele

Number of elements in the entire mesh.

Type

int

num_dofe

Number of degrees of freedom per element.

Type

int

num_dofs

Number of degrees of freedom in the problem, this property depends on the element type and the mesh.

Type

int

num_q

Number of quadrature point in integration approximations.

Type

int

nodes

For each node in each element the coordinates.

Type

array_like(float), shape(n+1, order+1)

connectivity

Elements to node connectivity array.

Type

array_like(int), shape(n+1, order+1)

dshape(xi)

Shape functions derivatives at locations \(\xi\) in element coordinates system.

Parameters

xi (array_like(float)) – Locations \(\xi\) where the shape functions are evaluated.

Returns

dphi_xq – Shape functions derivatives \(\phi_i\) at locations \(\xi\).

Return type

array_like(float)

get_element(ele, rhs=None)

Get the element properties of element ele.

Parameters
  • ele (int) – Number of the element of which the properties should be obtained.

  • rhs (callable(float)) – The righthandside function of the pde in terms of global coordinates.

Returns

  • dofe (array_like(int), shape(num_dofe)) – The degrees of freedom that belong to this element.

  • phi_xq (array_like(float), shape((dofs, num_q))) – For each shape function the value at the quadrature points.

  • invJ_dphi_xq (array_like(float), shape((dofs, num_q))) – For each shape function its derivative value at the quadrature points times the inverse Jacobian.

  • f_xq (array_like(float), shape(num_q)) – The value of the right hand side equation evaluated at the quadrature points.

  • wq_detJ (array_like(float), shape((dofs, num_q))) – For the local determinant times quadrature weight at each of the quadrature points.

jacobian(ele, xi)

The jacobian and mapping for the local to global coordinates system (\(\xi\) to \(x\)).

Parameters
  • ele (int) – Element for which the jacobian has to be calculated.

  • xi (array_like(float)) – Location where the jacobians should be measured.

Returns

  • jac (array_like(float)) – The Jacobian at \(\xi\).

  • invJ (array_like(float)) – The inverse Jacobian at \(\xi\).

  • detJ (array_like(float)) – The derivative of the Jacobian at \(\xi\).

shape(xi)

Shape functions at locations \(\xi\) in element coordinates system.

Parameters

xi (array_like(float)) – Locations \(\xi\) where the shape functions are evaluated.

Returns

phi_xq – Shape functions \(\phi_i\) at locations \(\xi\).

Return type

array_like(float)

x_to_xi(ele, x)

Converting global into local coordinates \(x \rightarrow \xi\).

Parameters
  • ele (int) – Element in which the transformation has to take place.

  • x (array_like(float)) – Global coordinates, these must be within the element.

Returns

xi – The local, element, coordinates.

Return type

array_like(float)

xi_to_x(ele, xi)

Converting local coordinates into global ones \(\xi \rightarrow x\).

Parameters
  • ele (int) – Element in which the transformation has to take place.

  • xi (array_like(float)) – Local coordinates within the element.

Returns

x – The global coordinates.

Return type

array_like(float)

Implemented Meshes

class element.Mesh1D(x_start, x_end, num_ele, order, num_q, periodic=False)

Specify a 1D mesh object, and it’s behaviour.

This is a 1D mesh object with Lagransian basis functions.

Parameters
  • x_start (float) – Start coordinate of the domain.

  • x_end (float) – End coordinate of the domain.

  • num_ele (int) – Number of elements in the mesh.

  • order (int) – Polynomial order of the Lagransian basis functions.

  • num_q (int) – Number of quadrature points per element.

  • periodic (bool, optional) – Whether the domain is periodic, default is False.

num_ele

Number of elements in the entire mesh.

Type

int

order

Order of the polynomaial approximation.

Type

int

num_dofe

Number of degrees of freedom per element.

Type

int

num_dofs

Number of degrees of freedom in the problem, this property depends on the element type and the mesh.

Type

int

num_q

Number of quadrature point in integration approximations.

Type

int

nodes

For each node in each element the coordinates.

Type

array_like(float), shape(n+1, order+1)

connectivity

Elements to node connectivity array.

Type

array_like(int), shape(n+1, order+1)

get_element(ele, rhs=None)

Get the element properties of element ele.

Parameters
  • ele (int) – Number of the element of which the properties should be obtained.

  • rhs (callable(float), optional) – The righthandside function of the pde in terms of global coordinates.

Returns

  • dofe (array_like(int), shape(num_dofe)) – The degrees of freedom that belong to this element.

  • phi_xq (array_like(float), shape((dofs, num_q))) – For each shape function the value at the quadrature points.

  • invJ_dphi_xq (array_like(float), shape((dofs, num_q))) – For each shape function its derivative value at the quadrature points times the inverse Jacobian.

  • f_xq (array_like(float), shape(num_q)) – The value of the right hand side equation evaluated at the quadrature points.

  • wq_detJ (array_like(float), shape((dofs, num_q))) – For the local determinant times quadrature weight at each of the quadrature points.

x_to_xi(ele, x)

Converting local coordinates into global ones \(x \rightarrow \xi\).

Parameters
  • ele (int) – Element in which the transformation has to take place.

  • x (array_like(float)) – Global coordinates, these must be within the element.

Returns

xi – The local, element, coordinates.

Return type

array_like(float)

xi_to_x(ele, xi)

Converting local coordinates into global ones \(\xi \rightarrow x\).

Parameters
  • ele (int) – Element in which the transformation has to take place.

  • xi (array_like(float)) – Local coordinates within the element.

Returns

x – The global coordinates.

Return type

array_like(float)

jacobian(ele)

The jacobian and mapping for the local to global coordinates system (\(\xi\) to \(x\)).

Because the jacobian is a constant for 1D meshes, the objectes that are returned are constant floats instead of arrays.

Parameters

ele (int) – Element for which the jacobian has to be calculated.

Returns

  • jac (float) – The Jacobian at \(\xi\).

  • invJ (float) – The inverse Jacobian at \(\xi\).

  • detJ (float) – The derivative of the Jacobian at \(\xi\).

shape(xi)

Shape functions at locations \(\xi\) in element coordinates system.

Parameters

xi (array_like(float)) – Locations \(\xi\) where the shape functions are evaluated.

Returns

phi_xq – Shape functions \(\phi_i\) at locations \(\xi\).

Return type

array_like(float)

dshape(xi)

Shape functions derivatives at locations \(\xi\) in element coordinates system.

Parameters

xi (array_like(float)) – Locations \(\xi\) where the shape functions are evaluated.

Returns

dphi_xq – Shape functions derivatives \(\phi_i\) at locations \(\xi\).

Return type

array_like(float)