Namespace GooseFEM::Mesh#

namespace Mesh

Generic mesh operations, and simple mesh definitions.

Enums

enum class ElementType

Enumerator for element-types.

Values:

enumerator Unknown

Unknown element-type.

enumerator Quad4

Quadrilateral: 4-noded element in 2-d.

enumerator Hex8

Hexahedron: 8-noded element in 3-d.

enumerator Tri3

Triangle: 3-noded element in 2-d.

Functions

template<class D>
inline std::vector<std::vector<size_t>> nodaltyings(const D &dofs)

List nodal tyings based on DOF-numbers per node.

Parameters

dofs – DOFs per node [nnode, ndim].

Returns

Nodes to which the nodes is connected (sorted) [nnode, …]

template<class S, class T>
inline ElementType defaultElementType(const S &coor, const T &conn)

Extract the element type based on the connectivity.

Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

Returns

ElementType().

inline array_type::tensor<size_t, 2> dofs(size_t nnode, size_t ndim)

List with DOF-numbers in sequential order.

The output is a sequential list of DOF-numbers for each vector-component of each node. For example for 3 nodes in 2 dimensions the output is

\( \begin{bmatrix} 0 & 1 \\ 2 & 3 \\ 4 & 5 \end{bmatrix} \)

Parameters
  • nnode – Number of nodes.

  • ndim – Number of dimensions.

Returns

DOF-numbers.

template<class T>
inline T renumber(const T &dofs)

Renumber to lowest possible index (see GooseFEM::Mesh::Renumber).

Parameters

dofs – DOF-numbers [nnode, ndim].

Returns

Renumbered DOF-numbers.

template<class S, class T>
inline array_type::tensor<size_t, 2> overlapping(const S &coor_a, const T &coor_b, double rtol = 1e-5, double atol = 1e-8)

Find overlapping nodes.

The output has the following structure:

 [
     [nodes_from_mesh_a],
     [nodes_from_mesh_b],
 ]

Parameters
  • coor_a – Nodal coordinates of mesh “a” [nnode, ndim].

  • coor_b – Nodal coordinates of mesh “b” [nnode, ndim].

  • rtol – Relative tolerance for position match.

  • atol – Absolute tolerance for position match.

Returns

Overlapping nodes.

template<class E>
inline array_type::tensor<size_t, 1> coordination(const E &conn)

Number of elements connected to each node.

Parameters

conn – Connectivity [nelem, nne].

Returns

Coordination per node.

template<class E>
inline std::vector<std::vector<size_t>> elem2node(const E &conn, bool sorted = true)

Elements connected to each node.

Parameters
  • conn – Connectivity [nelem, nne].

  • sorted – If true the list of elements for each node is sorted.

Returns

Elements per node [nnode, …].

template<class E, class D>
inline std::vector<std::vector<size_t>> elem2node(const E &conn, const D &dofs, bool sorted = true)

Elements connected to each node.

Parameters
  • conn – Connectivity [nelem, nne].

  • sorted – If true the list of elements for each node is sorted.

  • dofs – DOFs per node, allowing accounting for periodicity [nnode, ndim].

Returns

Elements per node [nnode, …].

template<class D>
inline std::vector<std::vector<size_t>> node2dof(const D &dofs, bool sorted = true)

Nodes connected to each DOF.

Parameters
  • dofs – DOFs per node [nnode, ndim].

  • sorted – If true the list of nodes for each DOF is sorted.

Returns

Nodes per DOF [ndof, …].

template<class C, class E>
inline array_type::tensor<double, 2> edgesize(const C &coor, const E &conn, ElementType type)

Return size of each element edge.

Parameters
  • coor – Nodal coordinates.

  • conn – Connectivity.

  • type – ElementType.

Returns

Edge-sizes per element.

template<class C, class E>
inline array_type::tensor<double, 2> edgesize(const C &coor, const E &conn)

Return size of each element edge.

The element-type is automatically determined, see defaultElementType().

Parameters
  • coor – Nodal coordinates.

  • conn – Connectivity.

Returns

Edge-sizes per element.

template<class C, class E>
inline array_type::tensor<double, 2> centers(const C &coor, const E &conn, ElementType type)

Coordinates of the center of each element.

Parameters
  • coor – Nodal coordinates.

  • conn – Connectivity.

  • type – ElementType.

Returns

Center of each element.

template<class C, class E>
inline array_type::tensor<double, 2> centers(const C &coor, const E &conn)

Coordinates of the center of each element.

The element-type is automatically determined, see defaultElementType().

Parameters
  • coor – Nodal coordinates.

  • conn – Connectivity.

Returns

Center of each element.

template<class T, class C, class E>
inline array_type::tensor<size_t, 1> elemmap2nodemap(const T &elem_map, const C &coor, const E &conn, ElementType type)

Convert an element-map to a node-map.

Parameters
  • elem_map – Element-map such that new_elvar = elvar[elem_map].

  • coor – Nodal coordinates.

  • conn – Connectivity.

  • type – ElementType.

Returns

Node-map such that new_nodevar = nodevar[node_map]

template<class T, class C, class E>
inline array_type::tensor<size_t, 1> elemmap2nodemap(const T &elem_map, const C &coor, const E &conn)

Convert an element-map to a node-map.

The element-type is automatically determined, see defaultElementType().

Parameters
  • elem_map – Element-map such that new_elvar = elvar[elem_map].

  • coor – Nodal coordinates.

  • conn – Connectivity.

Returns

Node-map such that new_nodevar = nodevar[node_map]

template<class C, class E>
inline array_type::tensor<double, 2> nodal_mass(const C &coor, const E &conn, ElementType type)

Compute the mass of each node in the mesh.

If nodes are not part of the connectivity the mass is set to zero, such that the center of gravity is simply::

 average(coor, GooseFEM.Mesh.nodal_mass(coor, conn, type), axis=0);

Template Parameters
Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

  • type – ElementType.

Returns

Center of gravity [ndim].

template<class C, class E>
inline array_type::tensor<double, 2> nodal_mass(const C &coor, const E &conn)

Compute the mass of each node in the mesh.

If nodes are not part of the connectivity the mass is set to zero, such that the center of gravity is simply::

 average(coor, GooseFEM.Mesh.nodal_mass(coor, conn), axis=0);

Template Parameters
Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

Returns

Center of gravity [ndim].

template<class C, class E>
inline array_type::tensor<double, 1> center_of_gravity(const C &coor, const E &conn, ElementType type)

Compute the center of gravity of a mesh.

Template Parameters
Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

  • type – ElementType.

Returns

Center of gravity [ndim].

template<class C, class E>
inline array_type::tensor<double, 1> center_of_gravity(const C &coor, const E &conn)

Compute the center of gravity of a mesh.

Template Parameters
Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

Returns

Center of gravity [ndim].

class ManualStitch
#include <GooseFEM/Mesh.h>

Stitch two mesh objects, specifying overlapping nodes by hand.

Public Functions

template<class CA, class EA, class NA, class CB, class EB, class NB>
inline ManualStitch(const CA &coor_a, const EA &conn_a, const NA &overlapping_nodes_a, const CB &coor_b, const EB &conn_b, const NB &overlapping_nodes_b, bool check_position = true, double rtol = 1e-5, double atol = 1e-8)
Parameters
  • coor_a – Nodal coordinates of mesh “a” [nnode, ndim].

  • conn_a – Connectivity of mesh “a” [nelem, nne].

  • overlapping_nodes_a – Node-numbers of mesh “a” that overlap with mesh “b” [n].

  • coor_b – Nodal coordinates of mesh “b” [nnode, ndim].

  • conn_b – Connectivity of mesh “b” [nelem, nne].

  • overlapping_nodes_b – Node-numbers of mesh “b” that overlap with mesh “a” [n].

  • check_position – If true the nodes are checked for position overlap.

  • rtol – Relative tolerance for check on position overlap.

  • atol – Absolute tolerance for check on position overlap.

inline size_t nmesh() const

Number of sub meshes == 2.

Returns

unsigned int

inline size_t nelem() const

Number of elements.

Returns

unsigned int

inline size_t nnode() const

Number of nodes.

Returns

unsigned int

inline size_t nne() const

Number of nodes-per-element.

Returns

unsigned int

inline size_t ndim() const

Number of dimensions.

Returns

unsigned int

inline const array_type::tensor<double, 2> &coor() const

Nodal coordinates [nnode, ndim].

Returns

coordinates per node

inline const array_type::tensor<size_t, 2> &conn() const

Connectivity [nelem, nne].

Returns

nodes per element

inline array_type::tensor<size_t, 2> dofs() const

DOF numbers for each node (numbered sequentially) [nnode, ndim].

Returns

DOFs per node

inline std::vector<array_type::tensor<size_t, 1>> nodemap() const

Node-map per sub-mesh.

Returns

nodes per mesh

inline std::vector<array_type::tensor<size_t, 1>> elemmap() const

Element-map per sub-mesh.

Returns

elements per mesh

inline array_type::tensor<size_t, 1> nodemap(size_t mesh_index) const
Parameters

mesh_index – Index of the mesh (“a” = 1, “b” = 1).

Returns

Node-map for a given mesh.

inline array_type::tensor<size_t, 1> elemmap(size_t mesh_index) const
Parameters

mesh_index – Index of the mesh (“a” = 1, “b” = 1).

Returns

Element-map for a given mesh.

template<class T>
inline T nodeset(const T &set, size_t mesh_index) const

Convert set of node numbers for an original mesh to the stitched mesh.

Parameters
  • set – List of node numbers.

  • mesh_index – Index of the mesh (“a” = 1, “b” = 1).

Returns

List of node numbers for the stitched mesh.

template<class T>
inline T elemset(const T &set, size_t mesh_index) const

Convert set of element numbers for an original mesh to the stitched mesh.

Parameters
  • set – List of element numbers.

  • mesh_index – Index of the mesh (“a” = 1, “b” = 1).

Returns

List of element numbers for the stitched mesh.

template<class D>
class RegularBase
#include <GooseFEM/Mesh.h>

CRTP base class for regular meshes.

Subclassed by GooseFEM::Mesh::RegularBase2d< FineLayer >, GooseFEM::Mesh::RegularBase2d< Regular >, GooseFEM::Mesh::RegularBase3d< FineLayer >, GooseFEM::Mesh::RegularBase3d< Regular >, GooseFEM::Mesh::RegularBase2d< D >, GooseFEM::Mesh::RegularBase3d< D >

Public Types

using derived_type = D

Underlying type.

Public Functions

inline auto nelem() const

Number of elements.

Returns

unsigned int

inline auto nnode() const

Number of nodes.

Returns

unsigned int

inline auto nne() const

Number of nodes-per-element == 4.

Returns

unsigned int

inline auto ndim() const

Number of dimensions == 2.

Returns

unsigned int

inline auto nelx() const

Number of elements in x-direction == width of the mesh in units of h.

Returns

unsigned int

inline auto nely() const

Number of elements in y-direction == height of the mesh, in units of h,.

Returns

unsigned int

inline auto h() const

Linear edge size of one ‘block’.

Returns

double

inline auto elementType() const

The ElementType().

Returns

element type

inline auto coor() const

Nodal coordinates [nnode, ndim].

Returns

coordinates per node

inline auto conn() const

Connectivity [nelem, nne].

Returns

nodes per element

inline auto dofs() const

DOF numbers for each node (numbered sequentially) [nnode, ndim].

Returns

DOFs per node

inline auto dofsPeriodic() const

DOF-numbers for the case that the periodicity if fully eliminated.

Returns

DOF numbers for each node [nnode, ndim].

inline auto nodesPeriodic() const

Periodic node pairs, in two columns: (independent, dependent).

Returns

[ntyings, ndim].

inline auto nodesOrigin() const

Reference node to use for periodicity, because all corners are tied to it.

Returns

Node number.

template<class D>
class RegularBase2d : public GooseFEM::Mesh::RegularBase<D>
#include <GooseFEM/Mesh.h>

CRTP base class for regular meshes in 2d.

Public Types

using derived_type = D

Underlying type.

Public Functions

inline auto nodesBottomEdge() const

Nodes along the bottom edge (y = 0), in order of increasing x.

Returns

List of node numbers.

inline auto nodesTopEdge() const

Nodes along the top edge (y = nely * h), in order of increasing x.

Returns

List of node numbers.

inline auto nodesLeftEdge() const

Nodes along the left edge (x = 0), in order of increasing y.

Returns

List of node numbers.

inline auto nodesRightEdge() const

Nodes along the right edge (x = nelx * h), in order of increasing y.

Returns

List of node numbers.

inline auto nodesBottomOpenEdge() const

Nodes along the bottom edge (y = 0), without the corners (at x = 0 and x = nelx * h).

Same as: nodesBottomEdge()[1: -1].

Returns

List of node numbers.

inline auto nodesTopOpenEdge() const

Nodes along the top edge (y = nely * h), without the corners (at x = 0 and x = nelx * h).

Same as: nodesTopEdge()[1: -1].

Returns

List of node numbers.

inline auto nodesLeftOpenEdge() const

Nodes along the left edge (x = 0), without the corners (at y = 0 and y = nely * h).

Same as: nodesLeftEdge()[1: -1].

Returns

List of node numbers.

inline auto nodesRightOpenEdge() const

Nodes along the right edge (x = nelx * h), without the corners (at y = 0 and y = nely * h).

Same as: nodesRightEdge()[1: -1].

Returns

List of node numbers.

inline auto nodesBottomLeftCorner() const

The bottom-left corner node (at x = 0, y = 0).

Same as nodesBottomEdge()[0] and nodesLeftEdge()[0].

Returns

Node number.

inline auto nodesBottomRightCorner() const

The bottom-right corner node (at x = nelx * h, y = 0).

Same as nodesBottomEdge()[-1] and nodesRightEdge()[0].

Returns

Node number.

inline auto nodesTopLeftCorner() const

The top-left corner node (at x = 0, y = nely * h).

Same as nodesTopEdge()[0] and nodesRightEdge()[-1].

Returns

Node number.

inline auto nodesTopRightCorner() const

The top-right corner node (at x = nelx * h, y = nely * h).

Same as nodesTopEdge()[-1] and nodesRightEdge()[-1].

Returns

Node number.

inline auto nodesLeftBottomCorner() const

Alias of nodesBottomLeftCorner().

Returns

Node number.

inline auto nodesLeftTopCorner() const

Alias of nodesTopLeftCorner().

Returns

Node number.

inline auto nodesRightBottomCorner() const

Alias of nodesBottomRightCorner().

Returns

Node number.

inline auto nodesRightTopCorner() const

Alias of nodesTopRightCorner().

Returns

Node number.

template<class D>
class RegularBase3d : public GooseFEM::Mesh::RegularBase<D>
#include <GooseFEM/Mesh.h>

CRTP base class for regular meshes in 3d.

Public Types

using derived_type = D

Underlying type.

Public Functions

inline auto nelz() const

Number of elements in y-direction == height of the mesh, in units of h,.

Returns

unsigned int

inline auto nodesBottom() const

Nodes along the bottom face (y = 0).

Returns

List of node numbers.

inline auto nodesTop() const

Nodes along the top face (y = nely * h).

Returns

List of node numbers.

inline auto nodesLeft() const

Nodes along the left face (x = 0).

Returns

List of node numbers.

inline auto nodesRight() const

Nodes along the right face (x = nelx * h).

Returns

List of node numbers.

inline auto nodesFront() const

Nodes along the front face (z = 0).

Returns

List of node numbers.

inline auto nodesBack() const

Nodes along the back face (z = nelz * h).

Returns

List of node numbers.

inline auto nodesFrontBottomEdge() const

Nodes along the edge at the intersection of the front and bottom faces (z = 0 and y = 0).

Returns

List of node numbers.

inline auto nodesFrontTopEdge() const

Nodes along the edge at the intersection of the front and top faces (z = 0 and y = nely * h).

Returns

List of node numbers.

inline auto nodesFrontLeftEdge() const

Nodes along the edge at the intersection of the front and left faces (z = 0 and x = 0).

Returns

List of node numbers.

inline auto nodesFrontRightEdge() const

Nodes along the edge at the intersection of the front and right faces (z = 0 and x = nelx * h).

Returns

List of node numbers.

inline auto nodesBackBottomEdge() const

Nodes along the edge at the intersection of the back and bottom faces (z = nelz * h and y = nely * h).

Returns

List of node numbers.

inline auto nodesBackTopEdge() const

Nodes along the edge at the intersection of the back and top faces (z = nelz * h and x = 0).

Returns

List of node numbers.

inline auto nodesBackLeftEdge() const

Nodes along the edge at the intersection of the back and left faces (z = nelz * h and x = nelx * h).

Returns

List of node numbers.

inline auto nodesBackRightEdge() const

Nodes along the edge at the intersection of the back and right faces (? = nelz * h and ? = ?).

Returns

List of node numbers.

inline auto nodesBottomLeftEdge() const

Nodes along the edge at the intersection of the bottom and left faces (y = 0 and x = 0).

Returns

List of node numbers.

inline auto nodesBottomRightEdge() const

Nodes along the edge at the intersection of the bottom and right faces (y = 0 and x = nelx * h).

Returns

List of node numbers.

inline auto nodesTopLeftEdge() const

Nodes along the edge at the intersection of the top and left faces (y = 0 and x = nelx * h).

Returns

List of node numbers.

inline auto nodesTopRightEdge() const

Nodes along the edge at the intersection of the top and right faces (y = nely * h and x = nelx * h).

Returns

List of node numbers.

inline auto nodesBottomFrontEdge() const

Alias of nodesFrontBottomEdge()

Returns

List of node numbers.

inline auto nodesBottomBackEdge() const

Alias of nodesBackBottomEdge()

Returns

List of node numbers.

inline auto nodesTopFrontEdge() const

Alias of nodesFrontTopEdge()

Returns

List of node numbers.

inline auto nodesTopBackEdge() const

Alias of nodesBackTopEdge()

Returns

List of node numbers.

inline auto nodesLeftBottomEdge() const

Alias of nodesBottomLeftEdge()

Returns

List of node numbers.

inline auto nodesLeftFrontEdge() const

Alias of nodesFrontLeftEdge()

Returns

List of node numbers.

inline auto nodesLeftBackEdge() const

Alias of nodesBackLeftEdge()

Returns

List of node numbers.

inline auto nodesLeftTopEdge() const

Alias of nodesTopLeftEdge()

Returns

List of node numbers.

inline auto nodesRightBottomEdge() const

Alias of nodesBottomRightEdge()

Returns

List of node numbers.

inline auto nodesRightTopEdge() const

Alias of nodesTopRightEdge()

Returns

List of node numbers.

inline auto nodesRightFrontEdge() const

Alias of nodesFrontRightEdge()

Returns

List of node numbers.

inline auto nodesRightBackEdge() const

Alias of nodesBackRightEdge()

Returns

List of node numbers.

inline auto nodesFrontFace() const

Nodes along the front face excluding edges.

Same as different between nodesFront() and [nodesFrontBottomEdge(), nodesFrontTopEdge(), nodesFrontLeftEdge(), nodesFrontRightEdge()]

Returns

list of node numbers.

inline auto nodesBackFace() const

Nodes along the back face excluding edges.

Same as different between nodesBack() and [nodesBackBottomEdge(), nodesBackTopEdge(), nodesBackLeftEdge(), nodesBackRightEdge()]

Returns

list of node numbers.

inline auto nodesLeftFace() const

Nodes along the left face excluding edges.

Same as different between nodesLeft() and [nodesFrontLeftEdge(), nodesBackLeftEdge(), nodesBottomLeftEdge(), nodesTopLeftEdge()]

Returns

list of node numbers.

inline auto nodesRightFace() const

Nodes along the right face excluding edges.

Same as different between nodesRight() and [nodesFrontRightEdge(), nodesBackRightEdge(), nodesBottomRightEdge(), nodesTopRightEdge()]

Returns

list of node numbers.

inline auto nodesBottomFace() const

Nodes along the bottom face excluding edges.

Same as different between nodesBottom() and [nodesBackBottomEdge(), nodesBackTopEdge(), nodesBackLeftEdge(), nodesBackRightEdge()]

Returns

list of node numbers.

inline auto nodesTopFace() const

Nodes along the top face excluding edges.

Same as different between nodesTop() and [nodesFrontBottomEdge(), nodesFrontTopEdge(), nodesFrontLeftEdge(), nodesFrontRightEdge()]

Returns

list of node numbers.

inline auto nodesFrontBottomOpenEdge() const

Same as nodesFrontBottomEdge() but without corners.

Returns

List of node numbers.

inline auto nodesFrontTopOpenEdge() const

Same as nodesFrontTopEdge() but without corners.

Returns

List of node numbers.

inline auto nodesFrontLeftOpenEdge() const

Same as nodesFrontLeftEdge() but without corners.

Returns

List of node numbers.

inline auto nodesFrontRightOpenEdge() const

Same as nodesFrontRightEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBackBottomOpenEdge() const

Same as nodesBackBottomEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBackTopOpenEdge() const

Same as nodesBackTopEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBackLeftOpenEdge() const

Same as nodesBackLeftEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBackRightOpenEdge() const

Same as nodesBackRightEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBottomLeftOpenEdge() const

Same as nodesBottomLeftEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBottomRightOpenEdge() const

Same as nodesBottomRightEdge() but without corners.

Returns

List of node numbers.

inline auto nodesTopLeftOpenEdge() const

Same as nodesTopLeftEdge() but without corners.

Returns

List of node numbers.

inline auto nodesTopRightOpenEdge() const

Same as nodesTopRightEdge() but without corners.

Returns

List of node numbers.

inline auto nodesBottomFrontOpenEdge() const

Alias of nodesFrontBottomOpenEdge().

Returns

List of node numbers.

inline auto nodesBottomBackOpenEdge() const

Alias of nodesBackBottomOpenEdge().

Returns

List of node numbers.

inline auto nodesTopFrontOpenEdge() const

Alias of nodesFrontTopOpenEdge().

Returns

List of node numbers.

inline auto nodesTopBackOpenEdge() const

Alias of nodesBackTopOpenEdge().

Returns

List of node numbers.

inline auto nodesLeftBottomOpenEdge() const

Alias of nodesBottomLeftOpenEdge().

Returns

List of node numbers.

inline auto nodesLeftFrontOpenEdge() const

Alias of nodesFrontLeftOpenEdge().

Returns

List of node numbers.

inline auto nodesLeftBackOpenEdge() const

Alias of nodesBackLeftOpenEdge().

Returns

List of node numbers.

inline auto nodesLeftTopOpenEdge() const

Alias of nodesTopLeftOpenEdge().

Returns

List of node numbers.

inline auto nodesRightBottomOpenEdge() const

Alias of nodesBottomRightOpenEdge().

Returns

List of node numbers.

inline auto nodesRightTopOpenEdge() const

Alias of nodesTopRightOpenEdge().

Returns

List of node numbers.

inline auto nodesRightFrontOpenEdge() const

Alias of nodesFrontRightOpenEdge().

Returns

List of node numbers.

inline auto nodesRightBackOpenEdge() const

Alias of nodesBackRightOpenEdge().

Returns

List of node numbers.

inline auto nodesFrontBottomLeftCorner() const

Front-Bottom-Left corner node.

Returns

Node number.

inline auto nodesFrontBottomRightCorner() const

Front-Bottom-Right corner node.

Returns

Node number.

inline auto nodesFrontTopLeftCorner() const

Front-Top-Left corner node.

Returns

Node number.

inline auto nodesFrontTopRightCorner() const

Front-Top-Right corner node.

Returns

Node number.

inline auto nodesBackBottomLeftCorner() const

Back-Bottom-Left corner node.

Returns

Node number.

inline auto nodesBackBottomRightCorner() const

Back-Bottom-Right corner node.

Returns

Node number.

inline auto nodesBackTopLeftCorner() const

Back-Top-Left corner node.

Returns

Node number.

inline auto nodesBackTopRightCorner() const

Back-Top-Right corner node.

Returns

Node number.

inline auto nodesFrontLeftBottomCorner() const

Alias of nodesFrontBottomLeftCorner().

Returns

Node number.

inline auto nodesBottomFrontLeftCorner() const

Alias of nodesFrontBottomLeftCorner().

Returns

Node number.

inline auto nodesBottomLeftFrontCorner() const

Alias of nodesFrontBottomLeftCorner().

Returns

Node number.

inline auto nodesLeftFrontBottomCorner() const

Alias of nodesFrontBottomLeftCorner().

Returns

Node number.

inline auto nodesLeftBottomFrontCorner() const

Alias of nodesFrontBottomLeftCorner().

Returns

Node number.

inline auto nodesFrontRightBottomCorner() const

Alias of nodesFrontBottomRightCorner().

Returns

Node number.

inline auto nodesBottomFrontRightCorner() const

Alias of nodesFrontBottomRightCorner().

Returns

Node number.

inline auto nodesBottomRightFrontCorner() const

Alias of nodesFrontBottomRightCorner().

Returns

Node number.

inline auto nodesRightFrontBottomCorner() const

Alias of nodesFrontBottomRightCorner().

Returns

Node number.

inline auto nodesRightBottomFrontCorner() const

Alias of nodesFrontBottomRightCorner().

Returns

Node number.

inline auto nodesFrontLeftTopCorner() const

Alias of nodesFrontTopLeftCorner().

Returns

Node number.

inline auto nodesTopFrontLeftCorner() const

Alias of nodesFrontTopLeftCorner().

Returns

Node number.

inline auto nodesTopLeftFrontCorner() const

Alias of nodesFrontTopLeftCorner().

Returns

Node number.

inline auto nodesLeftFrontTopCorner() const

Alias of nodesFrontTopLeftCorner().

Returns

Node number.

inline auto nodesLeftTopFrontCorner() const

Alias of nodesFrontTopLeftCorner().

Returns

Node number.

inline auto nodesFrontRightTopCorner() const

Alias of nodesFrontTopRightCorner().

Returns

Node number.

inline auto nodesTopFrontRightCorner() const

Alias of nodesFrontTopRightCorner().

Returns

Node number.

inline auto nodesTopRightFrontCorner() const

Alias of nodesFrontTopRightCorner().

Returns

Node number.

inline auto nodesRightFrontTopCorner() const

Alias of nodesFrontTopRightCorner().

Returns

Node number.

inline auto nodesRightTopFrontCorner() const

Alias of nodesFrontTopRightCorner().

Returns

Node number.

inline auto nodesBackLeftBottomCorner() const

Alias of nodesBackBottomLeftCorner().

Returns

Node number.

inline auto nodesBottomBackLeftCorner() const

Alias of nodesBackBottomLeftCorner().

Returns

Node number.

inline auto nodesBottomLeftBackCorner() const

Alias of nodesBackBottomLeftCorner().

Returns

Node number.

inline auto nodesLeftBackBottomCorner() const

Alias of nodesBackBottomLeftCorner().

Returns

Node number.

inline auto nodesLeftBottomBackCorner() const

Alias of nodesBackBottomLeftCorner().

Returns

Node number.

inline auto nodesBackRightBottomCorner() const

Alias of nodesBackBottomRightCorner().

Returns

Node number.

inline auto nodesBottomBackRightCorner() const

Alias of nodesBackBottomRightCorner().

Returns

Node number.

inline auto nodesBottomRightBackCorner() const

Alias of nodesBackBottomRightCorner().

Returns

Node number.

inline auto nodesRightBackBottomCorner() const

Alias of nodesBackBottomRightCorner().

Returns

Node number.

inline auto nodesRightBottomBackCorner() const

Alias of nodesBackBottomRightCorner().

Returns

Node number.

inline auto nodesBackLeftTopCorner() const

Alias of nodesBackTopLeftCorner().

Returns

Node number.

inline auto nodesTopBackLeftCorner() const

Alias of nodesBackTopLeftCorner().

Returns

Node number.

inline auto nodesTopLeftBackCorner() const

Alias of nodesBackTopLeftCorner().

Returns

Node number.

inline auto nodesLeftBackTopCorner() const

Alias of nodesBackTopLeftCorner().

Returns

Node number.

inline auto nodesLeftTopBackCorner() const

Alias of nodesBackTopLeftCorner().

Returns

Node number.

inline auto nodesBackRightTopCorner() const

Alias of nodesBackTopRightCorner().

Returns

Node number.

inline auto nodesTopBackRightCorner() const

Alias of nodesBackTopRightCorner().

Returns

Node number.

inline auto nodesTopRightBackCorner() const

Alias of nodesBackTopRightCorner().

Returns

Node number.

inline auto nodesRightBackTopCorner() const

Alias of nodesBackTopRightCorner().

Returns

Node number.

inline auto nodesRightTopBackCorner() const

Alias of nodesBackTopRightCorner().

Returns

Node number.

class Renumber
#include <GooseFEM/Mesh.h>

Renumber indices to lowest possible index.

For example:

\( \begin{bmatrix} 0 & 1 \\ 5 & 4 \end{bmatrix} \)

is renumbered to

\( \begin{bmatrix} 0 & 1 \\ 3 & 2 \end{bmatrix} \)

Or, in pseudo-code, the result of this function is that:

 dofs = renumber(dofs)
 sort(unique(dofs[:])) == range(max(dofs+1))

Note

One can use the wrapper function renumber(). This class gives more advanced features.

Public Functions

template<class T>
inline Renumber(const T &dofs)
Parameters

dofs – DOF-numbers.

template<class T>
inline T apply(const T &list) const

Apply renumbering to other set.

Parameters

list – List of (DOF-)numbers.

Returns

Renumbered list of (DOF-)numbers.

inline const array_type::tensor<size_t, 1> &index() const

Get the list needed to renumber, e.g.:

 dofs_renumbered(i, j) = index(dofs(i, j))

Returns

Renumber-index.

class Reorder
#include <GooseFEM/Mesh.h>

Reorder to lowest possible index, in specific order.

For example for Reorder({iiu, iip}) after reordering:

 iiu = xt::range<size_t>(nnu);
 iip = xt::range<size_t>(nnp) + nnu;

Public Functions

template<class T>
inline Reorder(const std::initializer_list<T> args)
Parameters

args – List of (DOF-)numbers.

template<class T>
inline T apply(const T &list) const

Apply reordering to other set.

Parameters

list – List of (DOF-)numbers.

Returns

Reordered list of (DOF-)numbers.

inline const array_type::tensor<size_t, 1> &index() const

Get the list needed to reorder, e.g.:

 dofs_reordered(i, j) = index(dofs(i, j))

Returns

Reorder-index.

class Stitch
#include <GooseFEM/Mesh.h>

Stitch mesh objects, automatically searching for overlapping nodes.

Subclassed by GooseFEM::Mesh::Vstack

Public Functions

inline Stitch(double rtol = 1e-5, double atol = 1e-8)
Parameters
  • rtol – Relative tolerance for position match.

  • atol – Absolute tolerance for position match.

template<class C, class E>
inline void push_back(const C &coor, const E &conn)

Add mesh to be stitched.

Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

inline size_t nmesh() const

Number of sub meshes.

Returns

unsigned int

inline size_t nelem() const

Number of elements.

Returns

unsigned int

inline size_t nnode() const

Number of nodes.

Returns

unsigned int

inline size_t nne() const

Number of nodes-per-element.

Returns

unsigned int

inline size_t ndim() const

Number of dimensions.

Returns

unsigned int

inline const array_type::tensor<double, 2> &coor() const

Nodal coordinates [nnode, ndim].

Returns

coordinates per node

inline const array_type::tensor<size_t, 2> &conn() const

Connectivity [nelem, nne].

Returns

nodes per element

inline array_type::tensor<size_t, 2> dofs() const

DOF numbers for each node (numbered sequentially) [nnode, ndim].

Returns

DOFs per node

inline std::vector<array_type::tensor<size_t, 1>> nodemap() const

Node-map per sub-mesh.

Returns

nodes per mesh

inline std::vector<array_type::tensor<size_t, 1>> elemmap() const

Element-map per sub-mesh.

Returns

elements per mesh

inline array_type::tensor<size_t, 1> nodemap(size_t mesh_index) const

The node numbers in the stitched mesh that are coming from a specific sub-mesh.

Parameters

mesh_index – Index of the sub-mesh.

Returns

List of node numbers.

inline array_type::tensor<size_t, 1> elemmap(size_t mesh_index) const

The element numbers in the stitched mesh that are coming from a specific sub-mesh.

Parameters

mesh_index – Index of the sub-mesh.

Returns

List of element numbers.

template<class T>
inline T nodeset(const T &set, size_t mesh_index) const

Convert set of node-numbers for a sub-mesh to the stitched mesh.

Parameters
  • set – List of node numbers.

  • mesh_index – Index of the sub-mesh.

Returns

List of node numbers for the stitched mesh.

template<class T>
inline T elemset(const T &set, size_t mesh_index) const

Convert set of element-numbers for a sub-mesh to the stitched mesh.

Parameters
  • set – List of element numbers.

  • mesh_index – Index of the sub-mesh.

Returns

List of element numbers for the stitched mesh.

template<class T>
inline T nodeset(const std::vector<T> &set) const

Combine set of node numbers for an original to the final mesh (removes duplicates).

Parameters

set – List of node numbers per mesh.

Returns

List of node numbers for the stitched mesh.

template<class T>
inline T nodeset(std::initializer_list<T> set) const

Combine set of node numbers for an original to the final mesh (removes duplicates).

Parameters

set – List of node numbers per mesh.

Returns

List of node numbers for the stitched mesh.

template<class T>
inline T elemset(const std::vector<T> &set) const

Combine set of element numbers for an original to the final mesh.

Parameters

set – List of element numbers per mesh.

Returns

List of element numbers for the stitched mesh.

template<class T>
inline T elemset(std::initializer_list<T> set) const

Combine set of element numbers for an original to the final mesh.

Parameters

set – List of element numbers per mesh.

Returns

List of element numbers for the stitched mesh.

class Vstack : public GooseFEM::Mesh::Stitch
#include <GooseFEM/Mesh.h>

Vertically stack meshes.

Public Functions

inline Vstack(bool check_overlap = true, double rtol = 1e-5, double atol = 1e-8)
Parameters
  • check_overlap – Check if nodes are overlapping when adding a mesh.

  • rtol – Relative tolerance for position match.

  • atol – Absolute tolerance for position match.

template<class C, class E, class N>
inline void push_back(const C &coor, const E &conn, const N &nodes_bot, const N &nodes_top)

Add a mesh to the top of the current stack.

Each time the current nodes_bot are stitched with the then highest nodes_top.

Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

  • nodes_bot – Nodes along the bottom edge [n].

  • nodes_top – Nodes along the top edge [n].

namespace Hex8

Simple meshes of 8-noded hexahedral elements in 3d (ElementType::Hex8).

class FineLayer : public GooseFEM::Mesh::RegularBase3d<FineLayer>
#include <GooseFEM/MeshHex8.h>

Mesh with fine middle layer, and coarser elements towards the top and bottom.

Public Functions

inline FineLayer(size_t nelx, size_t nely, size_t nelz, double h = 1.0, size_t nfine = 1)

Constructor.

Parameters
  • nelx – Number of elements (along the middle layer) in horizontal (x) direction.

  • nely – Approximate equivalent number of elements in vertical (y) direction.

  • nelz – Number of elements (along the middle layer) in depth (z) direction.

  • h – Edge size (width == height == depth) of elements along the weak layer.

  • nfine – Extra number of fine layers around the middle layer. By default the element size is kept smaller than the distance to the middle layer.

inline array_type::tensor<size_t, 1> elementsMiddleLayer() const

Elements in the middle (fine) layer.

Returns

List of element numbers (copy, involves computation).

class Regular : public GooseFEM::Mesh::RegularBase3d<Regular>
#include <GooseFEM/MeshHex8.h>

Regular mesh: equi-sized elements.

Public Functions

inline Regular(size_t nelx, size_t nely, size_t nelz, double h = 1.0)

Constructor.

Parameters
  • nelx – Number of elements in horizontal (x) direction.

  • nely – Number of elements in vertical (y) direction.

  • nelz – Number of elements in vertical (z) direction.

  • h – Edge size (width == height == depth).

namespace Quad4

Simple meshes of 4-noded quadrilateral elements in 2d (ElementType::Quad4).

class FineLayer : public GooseFEM::Mesh::RegularBase2d<FineLayer>
#include <GooseFEM/MeshQuad4.h>

Mesh with fine middle layer, and coarser elements towards the top and bottom.

Public Functions

inline FineLayer(size_t nelx, size_t nely, double h = 1.0, size_t nfine = 1)

Constructor.

Parameters
  • nelx – Number of elements (along the middle layer) in horizontal (x) direction.

  • nely – Approximate equivalent number of elements in vertical (y) direction.

  • h – Edge size (width == height) of elements along the weak layer.

  • nfine – Extra number of fine layers around the middle layer. By default the element size is kept smaller than the distance to the middle layer.

template<class C, class E, std::enable_if_t<xt::is_xexpression<C>::value, bool> = true>
inline FineLayer(const C &coor, const E &conn)

Reconstruct class for given coordinates / connectivity.

Template Parameters
Parameters
  • coor – Nodal coordinates [nnode, ndim] with ndim == 2.

  • conn – Connectivity [nne, nne] with nne == 4.

inline const array_type::tensor<size_t, 1> &elemrow_nhx() const

Edge size in x-direction of a block, in units of h, per row of blocks.

Note that a block is equal to an element except in refinement layers where it contains three elements.

Returns

List of size equal to the number of rows of blocks.

inline const array_type::tensor<size_t, 1> &elemrow_nhy() const

Edge size in y-direction of a block, in units of h, per row of blocks.

Note that a block is equal to an element except in refinement layers where it contains three elements.

Returns

List of size equal to the number of rows of blocks.

inline const array_type::tensor<int, 1> &elemrow_type() const

Per row of blocks: -1: normal layer 0: transition layer to match coarse and finer element on the previous/next row.

Returns

List of size equal to the number of rows of blocks.

inline const array_type::tensor<size_t, 1> &elemrow_nelem() const

Number of elements per row of blocks.

Note that a block is equal to an element except in refinement layers where it contains three elements.

Returns

List of size equal to the number of rows of blocks.

inline array_type::tensor<size_t, 1> elementsMiddleLayer() const

Elements in the middle (fine) layer.

Returns

List of element numbers.

inline array_type::tensor<size_t, 1> elementsLayer(size_t layer) const

Elements along a layer.

Returns

List of element numbers.

inline array_type::tensor<size_t, 1> elementgrid_ravel(std::vector<size_t> start_stop_rows, std::vector<size_t> start_stop_cols) const

Select region of elements from ‘matrix’ of element numbers.

Returns

List of element numbers.

inline array_type::tensor<size_t, 1> elementgrid_around_ravel(size_t e, size_t size, bool periodic = true)

Select region of elements from ‘matrix’ of element numbers around an element: square box with edge-size (2 * size + 1) * h, around element.

Parameters
  • e – The element around which to select elements.

  • size – Edge size of the square box encapsulating the selected element.

  • periodic – Assume the mesh periodic.

Returns

List of elements.

inline array_type::tensor<size_t, 1> elementgrid_leftright(size_t e, size_t left, size_t right, bool periodic = true)

Select region of elements from ‘matrix’ of element numbers around an element: left/right from element (on the same layer).

Parameters
  • e – The element around which to select elements.

  • left – Number of elements to select to the left.

  • right – Number of elements to select to the right.

  • periodic – Assume the mesh periodic.

Returns

List of elements.

inline array_type::tensor<size_t, 1> roll(size_t n)

Mapping to ‘roll’ periodically in the x-direction,.

Returns

element mapping, such that: new_elemvar = elemvar[elem_map]

class Regular : public GooseFEM::Mesh::RegularBase2d<Regular>
#include <GooseFEM/MeshQuad4.h>

Regular mesh: equi-sized elements.

Public Functions

inline Regular(size_t nelx, size_t nely, double h = 1.0)

Constructor.

Parameters
  • nelx – Number of elements in horizontal (x) direction.

  • nely – Number of elements in vertical (y) direction.

  • h – Edge size (width == height).

inline array_type::tensor<size_t, 2> elementgrid() const

Element numbers as ‘matrix’.

Returns

[nely, nelx].

namespace Map

Mesh mappings.

class FineLayer2Regular
#include <GooseFEM/MeshQuad4.h>

Map a FineLayer mesh to a Regular mesh.

The element size of the Regular corresponds to the smallest elements of the FineLayer mesh (along the middle layer).

Public Functions

inline FineLayer2Regular(const GooseFEM::Mesh::Quad4::FineLayer &mesh)

Constructors.

Parameters

mesh – The FineLayer mesh.

inline GooseFEM::Mesh::Quad4::Regular regularMesh() const

Obtain the Regular mesh.

Returns

mesh.

inline GooseFEM::Mesh::Quad4::FineLayer fineLayerMesh() const

Obtain the FineLayer mesh (copy of the mesh passed to the constructor).

Returns

mesh.

inline std::vector<std::vector<size_t>> map() const

Get element-mapping: elements of the Regular mesh per element of the FineLayer mesh.

The number of Regular elements varies between elements of the FineLayer mesh.

Returns

[nelem_finelayer, ?]

inline std::vector<std::vector<double>> mapFraction() const

To overlap fraction for each item in the mapping in map().

Returns

[nelem_finelayer, ?]

inline GooseFEM::Mesh::Quad4::Regular getRegularMesh() const

Obtain the Regular mesh.

Returns

mesh.

inline GooseFEM::Mesh::Quad4::FineLayer getFineLayerMesh() const

Obtain the FineLayer mesh (copy of the mesh passed to the constructor).

Returns

mesh.

inline std::vector<std::vector<size_t>> getMap() const

Get element-mapping: elements of the Regular mesh per element of the FineLayer mesh.

The number of Regular elements varies between elements of the FineLayer mesh.

Returns

[nelem_finelayer, ?]

inline std::vector<std::vector<double>> getMapFraction() const

To overlap fraction for each item in the mapping in getMap().

Returns

[nelem_finelayer, ?]

template<class T, size_t rank>
inline array_type::tensor<T, rank> mapToRegular(const array_type::tensor<T, rank> &data) const

Map element quantities to Regular.

The mapping is a bit simplistic: no interpolation is involved, the function just accounts the fraction of overlap between the FineLayer element and the Regular element. The mapping is such that::

 ret[e_regular, ...] <- arg[e_finelayer, ...]

Template Parameters
  • T – type of the data (e.g. double).

  • rank – rank of the data.

Parameters

data – data.

Returns

mapped data.

class RefineRegular
#include <GooseFEM/MeshQuad4.h>

Refine a Regular mesh: subdivide elements in several smaller elements.

Public Functions

inline RefineRegular(const GooseFEM::Mesh::Quad4::Regular &mesh, size_t nx, size_t ny)

Constructor.

Parameters
  • mesh – the coarse mesh.

  • nx – for each coarse element: number of fine elements in x-direction.

  • ny – for each coarse element: number of fine elements in y-direction.

inline size_t nx() const

For each coarse element: number of fine elements in x-direction.

Returns

unsigned int (same as used in constructor)

inline size_t ny() const

For each coarse element: number of fine elements in y-direction.

Returns

unsigned int (same as used in constructor)

inline GooseFEM::Mesh::Quad4::Regular coarseMesh() const

Obtain the coarse mesh (copy of the mesh passed to the constructor).

Returns

mesh

inline GooseFEM::Mesh::Quad4::Regular fineMesh() const

Obtain the fine mesh.

Returns

mesh

inline const array_type::tensor<size_t, 2> &map() const

Get element-mapping: elements of the fine mesh per element of the coarse mesh.

Returns

[nelem_coarse, nx() * ny()]

inline GooseFEM::Mesh::Quad4::Regular getCoarseMesh() const

Obtain the coarse mesh (copy of the mesh passed to the constructor).

Returns

mesh

inline GooseFEM::Mesh::Quad4::Regular getFineMesh() const

Obtain the fine mesh.

Returns

mesh

inline const array_type::tensor<size_t, 2> &getMap() const

Get element-mapping: elements of the fine mesh per element of the coarse mesh.

Returns

[nelem_coarse, nx() * ny()]

template<class T, size_t rank>
inline array_type::tensor<T, rank> meanToCoarse(const array_type::tensor<T, rank> &data) const

Compute the mean of the quantity define on the fine mesh when mapped on the coarse mesh.

Template Parameters
  • T – type of the data (e.g. double).

  • rank – rank of the data.

Parameters

data – the data [nelem_fine, …]

Returns

the average data of the coarse mesh [nelem_coarse, …]

template<class T, size_t rank, class S>
inline array_type::tensor<T, rank> averageToCoarse(const array_type::tensor<T, rank> &data, const array_type::tensor<S, rank> &weights) const

Compute the average of the quantity define on the fine mesh when mapped on the coarse mesh.

Template Parameters
  • T – type of the data (e.g. double).

  • rank – rank of the data.

  • S – type of the weights (e.g. double).

Parameters
  • data – the data [nelem_fine, …]

  • weights – the weights [nelem_fine, …]

Returns

the average data of the coarse mesh [nelem_coarse, …]

template<class T, size_t rank>
inline array_type::tensor<T, rank> mapToFine(const array_type::tensor<T, rank> &data) const

Map element quantities to the fine mesh.

The mapping is a bit simplistic: no interpolation is involved. The mapping is such that::

 ret[e_fine, ...] <- data[e_coarse, ...]

Template Parameters
  • T – type of the data (e.g. double).

  • rank – rank of the data.

Parameters

data – the data.

Returns

mapped data.

namespace Tri3

Simple meshes of and mesh operations for triangular elements of type ElementType::Tri3.

Functions

inline array_type::tensor<int, 1> getOrientation(const array_type::tensor<double, 2> &coor, const array_type::tensor<size_t, 2> &conn)

Read the orientation of a mesh of triangular elements of type ElementType::Tri3.

Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

Returns

Orientation (-1 or +1) per element [nelem].

inline array_type::tensor<size_t, 2> setOrientation(const array_type::tensor<double, 2> &coor, const array_type::tensor<size_t, 2> &conn, const array_type::tensor<int, 1> &val, int orientation = -1)

Set the orientation of a mesh of triangular elements of type ElementType::Tri3.

For efficiency this function reuses the output of getOrientation().

Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

  • val – Current orientation per element (output of getOrientation()) [nelem].

  • orientation – Target orientation (applied to all elements).

Returns

Connectivity (order of nodes-per-element may have changed) [nelem, nne].

inline array_type::tensor<size_t, 2> setOrientation(const array_type::tensor<double, 2> &coor, const array_type::tensor<size_t, 2> &conn, int orientation = -1)

Set the orientation of a mesh of triangular elements of type ElementType::Tri3.

Parameters
  • coor – Nodal coordinates [nnode, ndim].

  • conn – Connectivity [nelem, nne].

  • orientation – Target orientation (applied to all elements).

Returns

Connectivity (order of nodes-per-element may have changed) [nelem, nne].

class Regular : public GooseFEM::Mesh::RegularBase2d<Regular>
#include <GooseFEM/MeshTri3.h>

Regular grid of squares, with each square cut into two triangular elements.

Public Functions

inline Regular(size_t nelx, size_t nely, double h = 1.0)

Constructor.

Parameters
  • nelx – Number of elements in x-direction.

  • nely – Number of elements in y-direction.

  • h – Edge-size (of the squares, and thus of two of three element-edges).