Region#
This module contains the definition of a region as well as a boundary region along with template-regions for pre-defined combinations of elements and quadrature rules.
Core
|
A numeric region as a combination of a mesh, an element and a numeric integration scheme (quadrature rule). |
|
A numeric boundary-region as a combination of a mesh, an element and a numeric integration scheme (quadrature rule). |
Templates
|
A region with a quad element. |
|
A region with a hexahedron element. |
|
A region with a triangle element. |
|
A region with a tetra element. |
|
A region with a constant quad element. |
|
A region with a constant hexahedron element. |
|
A region with a (serendipity) quadratic quad element. |
|
A region with a (serendipity) quadratic hexahedron element. |
|
A region with a quadratic triangle element. |
|
A region with a quadratic tetra element. |
|
A region with a bi-quadratic (lagrange) quad element. |
|
A region with a tri-quadratic (lagrange) hexahedron element. |
|
A region with a triangle-MINI element. |
|
A region with a tetra-MINI element. |
|
A region with an arbitrary order lagrange element. |
|
A region with a quad element. |
|
A region with a hexahedron element. |
Detailed API Reference
- class felupe.Region(mesh, element, quadrature, grad=True)[source]#
A numeric region as a combination of a mesh, an element and a numeric integration scheme (quadrature rule).
- Parameters:
mesh (Mesh) – A mesh with points and cells.
element (Element) – The finite element formulation to be applied on the cells.
quadrature (Quadrature) – An element-compatible numeric integration scheme with points and weights.
grad (bool, optional) – A flag to invoke gradient evaluation (default is True).
- element#
The finite element formulation to be applied on the cells.
- Type:
Finite element
- quadrature#
An element-compatible numeric integration scheme with points and weights.
- Type:
Quadrature scheme
- h#
Element shape function array
h_aqof shape functionaevaluated at quadrature pointq.- Type:
ndarray
- dhdr#
Partial derivative of element shape function array
dhdr_aJqwith shape functionaw.r.t. natural element coordinateJevaluated at quadrature pointqfor every cellc(geometric gradient or Jacobian transformation betweenXandr).- Type:
ndarray
- dXdr#
Geometric gradient
dXdr_IJqcas partial derivative of undeformed coordinateIw.r.t. natural element coordinateJevaluated at quadrature pointqfor every cellc(geometric gradient or Jacobian transformation betweenXandr).- Type:
ndarray
- drdX#
Inverse of dXdr.
- Type:
ndarray
- dV#
Numeric differential volume element as product of determinant of geometric gradient
dV_qc = det(dXdr)_qc w_qand quadrature weightw_q, evaluated at quadrature pointqfor every cellc.- Type:
ndarray
- dhdX#
Partial derivative of element shape functions
dhdX_aJqcof shape functionaw.r.t. undeformed coordinateJevaluated at quadrature pointqfor every cellc.- Type:
ndarray
Notes
The gradients of the element shape functions w.r.t the undeformed coordinates are evaluated at all integration points of each cell in the region if the optional gradient argument is
True.\[ \begin{align}\begin{aligned}\frac{\partial X_I}{\partial r_J} &= \hat{X}_{aI} \frac{ \partial h_a}{\partial r_J }\\\frac{\partial h_a}{\partial X_J} &= \frac{\partial h_a}{\partial r_I} \frac{\partial r_I}{\partial X_J}\\dV &= \det\left(\frac{\partial X_I}{\partial r_J}\right) w\end{aligned}\end{align} \]Examples
>>> import felupe as fem
>>> mesh = fem.Rectangle(n=(3, 2)) >>> element = fem.Quad() >>> quadrature = fem.GaussLegendre(order=1, dim=2)
>>> region = fem.Region(mesh, element, quadrature) >>> region <felupe Region object> Element formulation: Quad Quadrature rule: GaussLegendre Gradient evaluated: True
The numeric differential volumes are the products of the determinant of the geometric gradient \(\partial X_I / \partial r_J\) and the weights w of the quadrature points. The differential volume array is of shape
(nquadraturepoints, ncells).>>> region.dV array([[0.125, 0.125], [0.125, 0.125], [0.125, 0.125], [0.125, 0.125]])
Cell-volumes may be obtained by cell-wise sums of the differential volumes located at the quadrature points.
>>> region.dV.sum(axis=0) array([0.5, 0.5])
The partial derivative of the first element shape function w.r.t. the undeformed coordinates evaluated at the second integration point of the last element of the region:
>>> region.dhdX[0, :, 1, -1] array([-1.57735027, -0.21132487])
- class felupe.RegionBoundary(mesh, element, quadrature, grad=True, only_surface=True, mask=None, ensure_3d=False)[source]#
A numeric boundary-region as a combination of a mesh, an element and a numeric integration scheme (quadrature rule).
- Parameters:
mesh (Mesh) – A mesh with points and cells.
element (Element) – The finite element formulation to be applied on the cells.
quadrature (Quadrature) – An element-compatible numeric integration scheme with points and weights.
grad (bool, optional) – A flag to invoke gradient evaluation (default is True).
only_surface (bool, optional) – A flag to use only the enclosing outline of the region (default is True).
mask (ndarray or None, optional) – A boolean array to select a specific set of points (default is None).
ensure_3d (bool, optional) – A flag to enforce 3d area normal vectors.
- element#
The finite element formulation to be applied on the cells.
- Type:
Finite element
- quadrature#
An element-compatible numeric integration scheme with points and weights.
- Type:
Quadrature scheme
- h#
Element shape function array
h_aqof shape functionaevaluated at quadrature pointq.- Type:
ndarray
- dhdr#
Partial derivative of element shape function array
dhdr_aJqwith shape functionaw.r.t. natural element coordinateJevaluated at quadrature pointqfor every cellc(geometric gradient or Jacobian transformation betweenXandr).- Type:
ndarray
- dXdr#
Geometric gradient
dXdr_IJqcas partial derivative of undeformed coordinateIw.r.t. natural element coordinateJevaluated at quadrature pointqfor every cellc(geometric gradient or Jacobian transformation betweenXandr).- Type:
ndarray
- drdX#
Inverse of dXdr.
- Type:
ndarray
- dA#
Numeric Differential area vectors.
- Type:
ndarray
- normals#
Area unit normal vectors.
- Type:
ndarray
- dV#
Numeric Differential volume element as norm of Differential area vectors.
- Type:
ndarray
- dhdX#
Partial derivative of element shape functions
dhdX_aJqcof shape functionaw.r.t. undeformed coordinateJevaluated at quadrature pointqfor every cellc.- Type:
ndarray
Notes
The gradients of the element shape functions w.r.t the undeformed coordinates are evaluated at all integration points of each cell in the region if the optional gradient argument is
True.\[ \begin{align}\begin{aligned}\frac{\partial X_I}{\partial r_J} &= \hat{X}_{aI} \frac{ \partial h_a}{\partial r_J }\\\frac{\partial h_a}{\partial X_J} &= \frac{\partial h_a}{\partial r_I} \frac{\partial r_I}{\partial X_J}\\dV &= \det\left(\frac{\partial X_I}{\partial r_J}\right) w\end{aligned}\end{align} \]Examples
>>> import felupe as fem
>>> mesh = fem.Rectangle(n=(3, 2)) >>> element = fem.Quad() >>> quadrature = fem.GaussLegendreBoundary(order=1, dim=2)
>>> region = fem.RegionBoundary(mesh, element, quadrature) >>> region <felupe Region object> Element formulation: Quad Quadrature rule: GaussLegendreBoundary Gradient evaluated: True
The numeric differential area vectors are the products of the cofactors of the geometric gradient \(\partial X_I / \partial r_J\) and the weights w of the quadrature points. The differential area vectors array is of shape
(nquadraturepoints, ndim, nboundarycells).>>> region.dA array([[[ 0. , -0.5 , 0. , 0.5 , 0. , 0. ], [ 0. , -0.5 , 0. , 0.5 , 0. , 0. ]],
- [[-0.25, -0. , -0.25, -0. , 0.25, 0.25],
[-0.25, -0. , -0.25, -0. , 0.25, 0.25]]])
In a boundary region, the numeric differential volumes are the magnitudes of the differential area vectors. For a quad mesh, the boundary cell volumes are the edge lengths.
>>> region.dV.sum(axis=0) array([0.5, 1. , 0.5, 1. , 0.5, 0.5])
Unit normal vectors are obtained by the ratio of the differential area vectors and the differential volumes.
>>> region.dA / region.dV ## this is equal to ``region.normals`` array([[[ 0., -1., 0., 1., 0., 0.], [ 0., -1., 0., 1., 0., 0.]],
- [[-1., -0., -1., -0., 1., 1.],
[-1., -0., -1., -0., 1., 1.]]])
The partial derivative of the first element shape function w.r.t. the undeformed coordinates evaluated at the second integration point of the last element of the region:
>>> region.dhdX[0, :, 1, -1] array([2. , 0.21132487])
- class felupe.RegionQuad(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendre object>, grad=True)[source]#
Bases:
RegionA region with a quad element.
- class felupe.RegionQuadBoundary(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendreBoundary object>, grad=True, only_surface=True, mask=None, ensure_3d=False)[source]#
Bases:
RegionBoundaryA region with a quad element.
- class felupe.RegionHexahedronBoundary(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendreBoundary object>, grad=True, only_surface=True, mask=None)[source]#
Bases:
RegionBoundaryA region with a hexahedron element.
- class felupe.RegionHexahedron(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendre object>, grad=True)[source]#
Bases:
RegionA region with a hexahedron element.
- class felupe.RegionTriangle(mesh, quadrature=<felupe.quadrature._triangle.Triangle object>, grad=True)[source]#
Bases:
RegionA region with a triangle element.
- class felupe.RegionTetra(mesh, quadrature=<felupe.quadrature._tetra.Tetrahedron object>, grad=True)[source]#
Bases:
RegionA region with a tetra element.
- class felupe.RegionConstantQuad(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendre object>, grad=False)[source]#
Bases:
RegionA region with a constant quad element.
- . autoclass:: felupe.RegionQuadraticQuad
- members:
- undoc-members:
- show-inheritance:
- . autoclass:: felupe.RegionBiQuadraticQuad
- members:
- undoc-members:
- show-inheritance:
- class felupe.RegionConstantHexahedron(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendre object>, grad=False)[source]#
Bases:
RegionA region with a constant hexahedron element.
- class felupe.RegionQuadraticHexahedron(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendre object>, grad=True)[source]#
Bases:
RegionA region with a (serendipity) quadratic hexahedron element.
- class felupe.RegionTriQuadraticHexahedron(mesh, quadrature=<felupe.quadrature._gausslegendre.GaussLegendre object>, grad=True)[source]#
Bases:
RegionA region with a tri-quadratic (lagrange) hexahedron element.
- class felupe.RegionQuadraticTriangle(mesh, quadrature=<felupe.quadrature._triangle.Triangle object>, grad=True)[source]#
Bases:
RegionA region with a quadratic triangle element.
- class felupe.RegionQuadraticTetra(mesh, quadrature=<felupe.quadrature._tetra.Tetrahedron object>, grad=True)[source]#
Bases:
RegionA region with a quadratic tetra element.
- class felupe.RegionTriangleMINI(mesh, quadrature=<felupe.quadrature._triangle.Triangle object>, grad=True)[source]#
Bases:
RegionA region with a triangle-MINI element.