Field#

A FieldContainer with pre-defined fields is created with:

FieldsMixed(region[, n, values, ...])

A container with multiple (mixed) Fields based on a Region.

A field container is created with a list of one or more fields.

FieldContainer(fields[, take])

A container for fields which holds a list or a tuple of Field instances.

Available kinds of fields:

Field(region[, dim, values, dtype])

A Field on points of a Region with dimension dim and initial point values.

FieldAxisymmetric(region[, dim, values, dtype])

An axisymmetric Field on points of a two-dimensional Region with dimension dim (default is 2) and initial point values (default is 0).

FieldPlaneStrain(region[, dim, values, dtype])

A plane strain Field on points of a two-dimensional Region with dimension dim (default is 2) and initial point values (default is 0).

FieldDual(region[, dim, values, offset, ...])

A dual field on points of a Region with dimension dim and initial point values.

Detailed API Reference

class felupe.FieldContainer(fields, take=None, **kwargs)[source]#

A container for fields which holds a list or a tuple of Field instances.

Parameters:
  • fields (list or tuple of Field, :class:``~felupe.FieldAxisymmetric`, :class:``~felupe.FieldPlaneStrain` or FieldContainer) – List with fields. The region is linked to the first field.

  • take (list of int, optional) – Take custom fields by field indices, used for extract(). If None, the fields are used in their original list item order. Default is None.

  • **kwargs (dict, optional) – Extra class attributes for the field container.

evaluate#

Methods to evaluate the deformation gradient and strain measures, see EvaluateFieldContainer for details on the provided methods.

Type:

field.EvaluateFieldContainer

slots#

The indices of the fields of a top-level field container, which belong to the fields of this field container, e.g. set by merge(). If None, the fields belong to the first fields of the top-level field container (in the same order). Default is None.

Type:

list of int or None

Examples

>>> import felupe as fem
>>>
>>> mesh = fem.Cube(n=3)
>>> region = fem.RegionHexahedron(mesh)
>>> region_dual = fem.RegionConstantHexahedron(mesh.dual(points_per_cell=1))
>>> displacement = fem.Field(region, dim=3)
>>> pressure = fem.Field(region_dual)
>>> field = fem.FieldContainer([displacement, pressure])
>>> field
<felupe FieldContainer object>
  Number of fields: 2
  Dimension of fields:
    Field: 3
    Field: 1

A new FieldContainer is also created by one of the logical-and combinations of a Field, FieldAxisymmetric, FieldPlaneStrain or FieldContainer.

>>> displacement & pressure
<felupe FieldContainer object>
  Number of fields: 2
  Dimension of fields:
    Field: 3
    Field: 1
>>> volume_ratio = fem.Field(region_dual)
>>> field & volume_ratio  # displacement & pressure & volume_ratio
<felupe FieldContainer object>
  Number of fields: 3
  Dimension of fields:
    Field: 3
    Field: 1
    Field: 1

See also

felupe.Field

Field on points of a Region with dimension dim and initial point values.

felupe.FieldAxisymmetric

An axisymmetric Field on points of a two dimensional Region with dimension dim (default is 2) and initial point values (default is 0).

felupe.FieldPlaneStrain

A plane strain Field on points of a two dimensional Region with dimension dim (default is 2) and initial point values (default is 0).

checkpoint()[source]#

Return a checkpoint of the field container.

Returns:

A dict with a copy of the field container "field" and, if available, a copy of the top-level field container "field.x0".

Return type:

dict

Notes

The field containers, their fields and the values of the fields are copied. The regions, meshes, mesh containers and indices of the fields are not copied, i.e. they are shared with the field container. These are not modified during the evaluation of a job. Changes of the region or the mesh after a checkpoint is created (e.g. by merge()) are also visible in the copied field container of the checkpoint, but they do not affect restore(), which only restores the values of the fields. The copied field container of the checkpoint holds the copied top-level field container "field.x0" as attribute x0.

See also

felupe.FieldContainer.restore

Restore a checkpoint of a field container inplace.

copy()[source]#

Return a copy of the field.

extract(grad=True, sym=False, add_identity=True, dtype=None, out=None, order='C')[source]#

Generalized extraction method which evaluates either the gradient or the field values at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is evaluated and/or the identity matrix is added to the gradient.

Parameters:
  • grad (bool or list of bool, optional) – Flag(s) for gradient evaluation(s). A boolean value is applied on the first field only and all other fields are extracted with grad=False. To enable or disable gradients per-field, use a list of boolean values instead (default is True).

  • sym (bool, optional) – Flag for symmetric part if the gradient is evaluated (default is False).

  • add_identity (bool or list of bool, optional) – Flag(s) for the addition of the identity matrix if the gradient is evaluated. A boolean value is applied on the first gradient only and all other gradients are extracted with add_identity=False. To enable or disable the addition of the identity matrix on gradients per-field, use a list of boolean values instead (default is True).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order (str or list of str, optional) – Controls the memory layout of the outputs. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

(Symmetric) gradient or interpolated field values evaluated at the integration points of each cell in the region.

Return type:

tuple of ndarray

Notes

If the gradient is not requested, the interpolation method returns the field values evaluated at the numeric integration points q for each cell c in the region (so-called trailing axes).

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]

On the other hand, the gradient method returns the gradient of the field values w.r.t. the undeformed mesh point coordinates, evaluated at the integration points of all cells in the region.

\[\left( \frac{\partial u_i}{\partial X_J} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial h_a}{\partial X_J} \right)_{(qc)}\]

See also

felupe.Field.interpolate

Interpolate field values located at mesh-points to the quadrature points in the region.

felupe.Field.grad

Gradient as partial derivative of field values w.r.t. undeformed coordinates.

extracted_fields()[source]#
imshow(*args, ax=None, dpi=None, **kwargs)[source]#

Take a screenshot of the first field of the container, show the image data in a figure and return the ax.

Link value array of other field.

Parameters:

other_field (FieldContainer or None, optional) – The other field container (default is None). If None, all fields are linked to the first field. If the field container has slots and the other field container has no slots (e.g. a top-level field container), the fields are linked to the fields of the other field container, given by the slots. Otherwise, the fields are linked 1-to-1 by their position.

merge(decimals=None, **kwargs)[source]#

Merge all fields and return a list of field containers as well as the top-level field container.

Parameters:
  • decimals (int or None, optional) – Precision decimals for merging duplicated mesh points. Default is None.

  • **kwargs (dict, optional) – Additional keyword arguments for MeshContainer.

Returns:

The top-level field container, to be used as the x0-argument in evaluate() and for the creation of boundary conditions. The given field containers are modified & reloaded in-place, along with a new attribute x0 that points to this top-level field container.

Return type:

FieldContainer

Notes

Mixed field containers, e.g. FieldsMixed, are supported, see merge() for details.

Examples

>>> import felupe as fem
>>>
>>> mesh1 = fem.Rectangle(n=3)
>>> displacement1 = fem.FieldAxisymmetric(fem.RegionQuad(mesh1), dim=2)
>>> field1 = fem.FieldContainer([displacement1])
>>>
>>> mesh2 = fem.Rectangle(a=(1, 0), b=(2, 1), n=3)
>>> displacement2 = fem.FieldAxisymmetric(fem.RegionQuad(mesh2), dim=2)
>>> field2 = fem.FieldContainer([displacement2])
>>>
>>> x0 = (field1 & field2).merge()
>>>
>>> umat = fem.NeoHookeCompressible(mu=1, lmbda=2)
>>> solid1 = fem.SolidBody(umat, field1)
>>> solid2 = fem.SolidBody(umat, field2)
>>>
>>> boundaries = fem.dof.uniaxial(x0, clamped=True)
>>>
>>> step = fem.Step(items=[solid1, solid2], boundaries=boundaries)
>>> job = fem.Job(steps=[step]).evaluate()
plot(*args, project=None, **kwargs)[source]#

Plot the first field of the container.

See also

felupe.Scene.plot

Plot method of a scene.

felupe.project

Project given values at quadrature-points to mesh-points.

felupe.topoints

Shift given values at quadrature-points to mesh-points.

reload(fields=None)[source]#

Reload the Field Container with new fields.

Parameters:

fields (list) – List of fields.

restore(checkpoint)[source]#

Restore a checkpoint inplace.

Parameters:

checkpoint (dict) – A dict with checkpoint arrays / objects.

See also

felupe.FieldContainer.checkpoint

Return a checkpoint of the field container.

revolve(n=11, phi=180)[source]#

Return a revolved field container.

Parameters:
  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

Returns:

The revolved field container.

Return type:

FieldContainer

Examples

First, create an axisymmetric field.

>>> import felupe as fem
>>>
>>> region = fem.RegionQuad(mesh=fem.Rectangle(n=6))
>>> field = fem.FieldContainer([fem.FieldAxisymmetric(region, dim=2)])
>>> field.plot().show()
../_images/field-13fa32320370af66_00_00.png

The first field of the field container is now revolved around the x-axis.

>>> new_field = field.revolve(n=11, phi=180)
>>> new_field.plot().show()
../_images/field-869cb482bf9a78d1_00_00.png

See also

SolidBody.revolve

Return a revolved solid body

SolidBodyNearlyIncompressible.revolve

Return a revolved solid body

screenshot(*args, filename='field.png', transparent_background=None, scale=None, **kwargs)[source]#

Take a screenshot of the first field of the container.

See also

pyvista.Plotter.screenshot

Take a screenshot of a PyVista plotter.

values()[source]#

Return the field values.

view(point_data=None, cell_data=None, cell_type=None, project=None)[source]#

View the field with optional given dicts of point- and cell-data items.

Parameters:
  • point_data (dict or None, optional) – Additional point-data dict (default is None).

  • cell_data (dict or None, optional) – Additional cell-data dict (default is None).

  • cell_type (pyvista.CellType or None, optional) – Cell-type of PyVista (default is None).

  • project (callable or None, optional) – Project internal cell-data at quadrature-points to mesh-points (default is None).

Returns:

A object which provides visualization methods for felupe.FieldContainer.

Return type:

felupe.ViewField

See also

felupe.ViewField

Visualization methods for felupe.FieldContainer.

felupe.project

Project given values at quadrature-points to mesh-points.

felupe.topoints

Shift given values at quadrature-points to mesh-points.

class felupe.field.EvaluateFieldContainer(field)[source]#

Methods to evaluate the deformation gradient and strain measures of a field container.

Parameters:

field (FieldContainer) – A container for fields.

Examples

>>> import felupe as fem
>>>
>>> mesh = fem.Rectangle(n=4)
>>> region = fem.RegionQuad(mesh)
>>> field = fem.FieldContainer([fem.FieldPlaneStrain(region, dim=2)])
>>>
>>> evaluate = fem.field.EvaluateFieldContainer(field)
>>> F = evaluate.deformation_gradient()
>>>
>>> F.shape  # (3, 3, nquadraturepoints, ncells)
(3, 3, 4, 9)
>>> F[..., 0, 0]  # deformation gradient of first cell, first quadrature point
array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])

See also

felupe.FieldContainer

A container which holds one or multiple (mixed) fields.

deformation_gradient()[source]#

Return the Deformation gradient tensor.

(1)#\[ \begin{align}\begin{aligned}\boldsymbol{F} &= \frac{\partial \boldsymbol{x}}{\partial \boldsymbol{X}}\\\boldsymbol{F} &= \sum_\alpha \lambda_\alpha \ \boldsymbol{n}_\alpha \otimes \boldsymbol{N}_\alpha\end{aligned}\end{align} \]
green_lagrange_strain(tensor=True, asvoigt=False, n=0)[source]#

Return the Green-Lagrange Lagrangian strain tensor or its principal values.

(2)#\[\boldsymbol{E} = \sum_\alpha \frac{1}{2} \left( \lambda_\alpha^2 - 1 \right) \ \boldsymbol{N}_\alpha \otimes \boldsymbol{N}_\alpha\]
Parameters:
  • tensor (bool, optional) – Assemble and return the strain tensor if True or return its principal values only if False. Default is True.

  • asvoigt (bool, optional) – Return the symmetric strain tensor in reduced vector storage (default is False).

  • n (int, optional) – The index of the displacement field (default is 0).

Returns:

The strain tensor or its principal values.

Return type:

ndarray of shape (N, N, …) tensor, (N * (N + 1) / 2, …) asvoigt or (N, …) princ. values

See also

math.strain

Compute a Lagrangian strain tensor.

math.strain_stretch_1d

Compute the Seth-Hill strains.

log_strain(tensor=True, asvoigt=False, n=0)[source]#

Return the logarithmic Lagrangian strain tensor or its principal values.

(3)#\[\boldsymbol{E} = \sum_\alpha \ln(\lambda_\alpha) \ \boldsymbol{N}_\alpha \otimes \boldsymbol{N}_\alpha\]
Parameters:
  • tensor (bool, optional) – Assemble and return the strain tensor if True or return its principal values only if False. Default is True.

  • asvoigt (bool, optional) – Return the symmetric strain tensor in reduced vector storage (default is False).

  • n (int, optional) – The index of the displacement field (default is 0).

Returns:

The strain tensor or its principal values.

Return type:

ndarray of shape (N, N, …) tensor, (N!, …) asvoigt or (N, …) princ. values

See also

math.strain_stretch_1d

Compute the Seth-Hill strains.

math.strain

Compute a Lagrangian strain tensor.

right_cauchy_green_deformation()[source]#

Return the right Cauchy-Green deformation tensor.

\[ \begin{align}\begin{aligned}:label:right-cauchy-green-deformation-tensor\\\boldsymbol{F} &= \frac{\partial \boldsymbol{x}}{\partial \boldsymbol{X}}\\\boldsymbol{C} &= \boldsymbol{F}^T \boldsymbol{F}\\\boldsymbol{C} &= \sum_\alpha \lambda^2_\alpha \ \boldsymbol{N}_\alpha \otimes \boldsymbol{N}_\alpha\end{aligned}\end{align} \]
strain(fun=<function strain_stretch_1d>, tensor=True, asvoigt=False, n=0, **kwargs)[source]#

Return the Lagrangian strain tensor or its principal values.

(4)#\[\boldsymbol{E} = \sum_\alpha f_\alpha \left( \lambda_\alpha \right) \ \boldsymbol{N}_\alpha \otimes \boldsymbol{N}_\alpha\]

By default, the Seth-Hill strain-stretch relation with a strain exponent of zero is used, see Eq. (5).

(5)#\[\boldsymbol{E} = \sum_\alpha \frac{1}{k} \left( \lambda_\alpha^k - 1 \right) \ \boldsymbol{N}_\alpha \otimes \boldsymbol{N}_\alpha\]
Parameters:
  • fun (callable, optional) – A callable for the one-dimensional strain-stretch relation. Its Signature must be lambda stretch, **kwargs: strain (default is the log. strain, strain_stretch_1d() with k=0).

  • tensor (bool, optional) – Assemble and return the strain tensor if True or return its principal values only if False. Default is True.

  • asvoigt (bool, optional) – Return the symmetric strain tensor in reduced vector storage (default is False).

  • n (int, optional) – The index of the displacement field (default is 0).

  • **kwargs (dict, optional) – Optional keyword-arguments are passed to the 1d strain-stretch relation.

Returns:

The strain tensor or its principal values.

Return type:

ndarray of shape (N, N, …) tensor, (N!, …) asvoigt or (N, …) princ. values

See also

math.strain

Compute a Lagrangian strain tensor.

math.strain_stretch_1d

Compute the Seth-Hill strains.

class felupe.Field(region, dim=1, values=0.0, dtype=None, **kwargs)[source]#

A Field on points of a Region with dimension dim and initial point values.

Parameters:
  • region (Region) – The region on which the field will be created.

  • dim (int, optional) – The dimension of the field (default is 1).

  • values (float or array) – A single value for all components of the field or an array of shape (region.mesh.npoints, dim). Default is 0.0.

  • dtype (data-type or None, optional) – Data-type of the array containing the field values.

  • **kwargs (dict, optional) – Extra class attributes for the field.

Notes

A slice of this field directly accesses the field-values as 1d-array. The interpolation method returns the field values evaluated at the numeric integration points q for each cell c in the region (so-called trailing axes).

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]

The gradient method returns the gradient of the field values w.r.t. the undeformed mesh point coordinates, evaluated at the integration points of all cells in the region.

\[\left( \frac{\partial u_i}{\partial X_J} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial h_a}{\partial X_J} \right)_{(qc)}\]

Examples

>>> import felupe as fem
>>>
>>> mesh = fem.Cube(n=6)
>>> region = fem.RegionHexahedron(mesh)
>>> displacement = fem.Field(region, dim=3)
>>>
>>> u = displacement.interpolate()
>>> dudX = displacement.grad()

To obtain deformation-related quantities like the right Cauchy-Green deformation tensor or the principal stretches, use the math-helpers from FElupe. These functions operate on arrays with trailing axes.

\[\boldsymbol{C} = \boldsymbol{F}^T \boldsymbol{F}\]
>>> from felupe.math import dot, transpose, eigvalsh, sqrt
>>>
>>> F = displacement.extract(grad=True, add_identity=True)
>>> C = dot(transpose(F), F)
>>> λ = sqrt(eigvalsh(C))
as_container(**kwargs)[source]#

Create a FieldContainer with the field.

copy()[source]#

Return a copy of the field.

extract(grad=True, sym=False, add_identity=True, dtype=None, out=None, order='C')[source]#

Generalized extraction method which evaluates either the gradient or the field values at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is evaluated and/or the identity matrix is added to the gradient.

Parameters:
  • grad (bool, optional) – Flag for gradient evaluation (default is True).

  • sym (bool, optional) – Flag for symmetric part if the gradient is evaluated (default is False).

  • add_identity (bool, optional) – Flag for the addition of the identity matrix if the gradient is evaluated (default is True).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

(Symmetric) gradient or interpolated field values evaluated at the integration points of each cell in the region.

Return type:

ndarray

fill(a)[source]#

Fill all field values with a scalar value.

classmethod from_mesh_container(mesh_container, dim=None, values=0.0)[source]#

Create a Field on a vertex mesh from a mesh container.

grad(sym=False, dtype=None, out=None, order='C')[source]#

Gradient as partial derivative of field values w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region. Optionally, the symmetric part the gradient is evaluated.

\[\left( \frac{\partial u_i}{\partial X_J} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial h_a}{\partial X_J} \right)_{(qc)}\]
Parameters:
  • sym (bool, optional) – Calculate the symmetric part of the gradient (default is False).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Gradient as partial derivative of field value components i at points w.r.t. the undeformed coordinates j, evaluated at the quadrature points q of cells c in the region.

Return type:

ndarray of shape (i, j, q, c)

hess(dtype=None, out=None, order='C')[source]#

Hessian as second partial derivative of field values w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region.

\[\left( \frac{\partial^2 u_i}{\partial X_J~\partial X_K} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial^2 h_a}{\partial X_J~\partial X_K} \right)_{(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Hessian as partial derivative of field value components i at points w.r.t. the undeformed coordinates j and k, evaluated at the quadrature points q of cells c in the region.

Return type:

ndarray of shape (i, j, k, q, c)

interpolate(dtype=None, out=None, order='C')[source]#

Interpolate field values located at mesh-points to the quadrature points q of cells c in the region.

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Interpolated field value components i, evaluated at the quadrature points q of each cell c in the region.

Return type:

ndarray of shape (i, q, c)

reload(region, mode='edge', **kwargs)[source]#

Reload the field with a new region in-place. The field values are extended to the new region if necessary.

Parameters:
  • region (Region) – The new region for the field.

  • mode (str, optional) – The padding mode to use if the field values need to be extended. Default is “edge”.

  • **kwargs (dict, optional) – Additional keyword arguments are passed to numpy.pad().

class felupe.FieldAxisymmetric(region, dim=1, values=0.0, dtype=None)[source]#

An axisymmetric Field on points of a two-dimensional Region with dimension dim (default is 2) and initial point values (default is 0).

Parameters:
  • region (Region) – The region on which the field will be created.

  • dim (int, optional) – The dimension of the field (default is 2).

  • values (float or array, optional) – A single value for all components of the field or an array of shape (region.mesh.npoints, dim)`. Default is 0.0.

  • dtype (data-type or None, optional) – Data-type of the array containing the field values.

Notes

  • component 1 = axial component

  • component 2 = radial component

 x_2 (radial direction)

  ^
  |        _
  |       / \
--|-----------------> x_1 (axial rotation axis)
          \_^

This is a modified Field in which the radial coordinates are evaluated at the numeric integration points q for each cell c. The grad()-method is modified in such a way that it does not only contain the in-plane 2d-gradient but also the circumferential stretch, see Eq. (6).

(6)#\[\begin{split}\frac{\partial \boldsymbol{u}}{\partial \boldsymbol{X}} = \begin{bmatrix} \left( \frac{\partial \boldsymbol{u}}{\partial \boldsymbol{X}} \right)_{2d} & \boldsymbol{0} \\ \boldsymbol{0}^T & \frac{u_r}{R} \end{bmatrix}\end{split}\]

See also

felupe.Field

Field on points of a Region with dimension dim and initial point values.

as_container(**kwargs)#

Create a FieldContainer with the field.

copy()#

Return a copy of the field.

extract(grad=True, sym=False, add_identity=True, dtype=None, out=None, order='C')#

Generalized extraction method which evaluates either the gradient or the field values at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is evaluated and/or the identity matrix is added to the gradient.

Parameters:
  • grad (bool, optional) – Flag for gradient evaluation (default is True).

  • sym (bool, optional) – Flag for symmetric part if the gradient is evaluated (default is False).

  • add_identity (bool, optional) – Flag for the addition of the identity matrix if the gradient is evaluated (default is True).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

(Symmetric) gradient or interpolated field values evaluated at the integration points of each cell in the region.

Return type:

ndarray

fill(a)#

Fill all field values with a scalar value.

classmethod from_mesh_container(mesh_container, dim=None, values=0.0)#

Create a Field on a vertex mesh from a mesh container.

grad(sym=False, dtype=None, out=None, order='C')[source]#

3D-gradient as partial derivative of field values at points w.r.t. the undeformed coordinates, evaluated at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is returned.

\[\begin{split}\frac{\partial \boldsymbol{u}}{\partial \boldsymbol{X}} = \begin{bmatrix} \left( \frac{\partial \boldsymbol{u}}{\partial \boldsymbol{X}} \right)_{2d} & \boldsymbol{0} \\ \boldsymbol{0}^T & \frac{u_r}{R} \end{bmatrix}\end{split}\]
Parameters:
  • sym (bool, optional) – Calculate the symmetric part of the gradient (default is False).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Full 3D-gradient as partial derivative of field values at points w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region.

Return type:

ndarray

hess(dtype=None, out=None, order='C')#

Hessian as second partial derivative of field values w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region.

\[\left( \frac{\partial^2 u_i}{\partial X_J~\partial X_K} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial^2 h_a}{\partial X_J~\partial X_K} \right)_{(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Hessian as partial derivative of field value components i at points w.r.t. the undeformed coordinates j and k, evaluated at the quadrature points q of cells c in the region.

Return type:

ndarray of shape (i, j, k, q, c)

interpolate(dtype=None, out=None, order='C')[source]#

Interpolate field values located at mesh-points to the quadrature points q of cells c in the region.

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Interpolated field value components i, evaluated at the quadrature points q of each cell c in the region.

Return type:

ndarray of shape (i, q, c)

reload(region, mode='edge', **kwargs)#

Reload the field with a new region in-place. The field values are extended to the new region if necessary.

Parameters:
  • region (Region) – The new region for the field.

  • mode (str, optional) – The padding mode to use if the field values need to be extended. Default is “edge”.

  • **kwargs (dict, optional) – Additional keyword arguments are passed to numpy.pad().

class felupe.FieldPlaneStrain(region, dim=2, values=0.0, dtype=None)[source]#

A plane strain Field on points of a two-dimensional Region with dimension dim (default is 2) and initial point values (default is 0).

Parameters:
  • region (Region) – The region on which the field will be created.

  • dim (int, optional) – The dimension of the field (default is 2).

  • values (float or array) – A single value for all components of the field or an array of shape (region.mesh.npoints, dim)`. Default is 0.0.

  • dtype (data-type or None, optional) – Data-type of the array containing the field values.

Notes

This is a modified Field for plane strain. The grad()-method is modified in such a way that the in-plane 2d-gradient is embedded in 3d-space, see Eq. (7).

(7)#\[\begin{split}\frac{\partial \boldsymbol{u}}{\partial \boldsymbol{X}} = \begin{bmatrix} \left( \frac{\partial \boldsymbol{u}}{\partial \boldsymbol{X}} \right)_{2d} & \boldsymbol{0} \\ \boldsymbol{0}^T & 0 \end{bmatrix}\end{split}\]

See also

felupe.Field

Field on points of a Region with dimension dim and initial point values.

as_container(**kwargs)#

Create a FieldContainer with the field.

copy()#

Return a copy of the field.

extract(grad=True, sym=False, add_identity=True, dtype=None, out=None, order='C')#

Generalized extraction method which evaluates either the gradient or the field values at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is evaluated and/or the identity matrix is added to the gradient.

Parameters:
  • grad (bool, optional) – Flag for gradient evaluation (default is True).

  • sym (bool, optional) – Flag for symmetric part if the gradient is evaluated (default is False).

  • add_identity (bool, optional) – Flag for the addition of the identity matrix if the gradient is evaluated (default is True).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

(Symmetric) gradient or interpolated field values evaluated at the integration points of each cell in the region.

Return type:

ndarray

fill(a)#

Fill all field values with a scalar value.

classmethod from_mesh_container(mesh_container, dim=None, values=0.0)#

Create a Field on a vertex mesh from a mesh container.

grad(sym=False, dtype=None, out=None, order='C')[source]#

3D-gradient as partial derivative of field values at points w.r.t. the undeformed coordinates, evaluated at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is returned.

                    |  dudX(2d) :   0   |
dudX(planestrain) = | ..................|
                    |     0     :   0   |
Parameters:
  • sym (bool, optional) – Calculate the symmetric part of the gradient (default is False).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Full 3D-gradient as partial derivative of field values at points w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region.

Return type:

ndarray

hess(dtype=None, out=None, order='C')[source]#

3D-Hessian as second partial derivative of field values at points w.r.t. the undeformed coordinates, evaluated at the integration points of all cells in the region.

Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Full 3D-hessian as second partial derivative of field values at points w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region.

Return type:

ndarray

interpolate(dtype=None, out=None, order='C')[source]#

Interpolate field values located at mesh-points to the quadrature points q of cells c in the region.

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Interpolated field value components i, evaluated at the quadrature points q of each cell c in the region.

Return type:

ndarray of shape (i, q, c)

reload(region, mode='edge', **kwargs)#

Reload the field with a new region in-place. The field values are extended to the new region if necessary.

Parameters:
  • region (Region) – The new region for the field.

  • mode (str, optional) – The padding mode to use if the field values need to be extended. Default is “edge”.

  • **kwargs (dict, optional) – Additional keyword arguments are passed to numpy.pad().

class felupe.FieldDual(region, dim=1, values=0.0, offset=0, npoints=None, mesh=None, disconnect=None, calc_points=None, **kwargs)[source]#

A dual field on points of a Region with dimension dim and initial point values.

Parameters:
  • region (Region) – The region on which the field will be created.

  • dim (int, optional) – The dimension of the field (default is 1).

  • values (float or array) – A single value for all components of the field or an array of shape (region.mesh.npoints, dim). Default is 0.0.

  • offset (int, optional) – Offset for cell connectivity of the dual mesh (default is 0).

  • npoints (int or None, optional) – Specified number of mesh points for the dual mesh (default is None).

  • mesh (Mesh or None, optional) – A mesh which is used for the dual region (default is None). If None, the mesh is taken from the region.

  • disconnect (bool or None, optional) – A flag to disconnect the dual mesh (default is None). If None, a disconnected mesh is used except for regions with quadratic-triangle or -tetra or MINI element formulations.

  • calc_points (bool or None, optional) – A flag to calculate points for the dual mesh (default is None).

  • **kwargs (dict, optional) – Optional keyword arguments for the dual region.

Examples

>>> import felupe as fem
>>>
>>> mesh = fem.Cube(n=6)
>>> region = fem.RegionHexahedron(mesh)
>>>
>>> displacement = fem.Field(region, dim=3)
>>> pressure = fem.FieldDual(region)
>>>
>>> field = fem.FieldContainer([displacement, pressure])
>>> field
<felupe FieldContainer object>
  Number of fields: 2
  Dimension of fields:
    Field: 3
    FieldDual: 1

See also

felupe.FieldContainer

A container which holds one or multiple (mixed) fields.

felupe.Field

Field on points of a Region with dimension dim and initial point values.

felupe.FieldAxisymmetric

Axisymmetric field on points of a Region with dimension dim and initial point values.

felupe.FieldPlaneStrain

Plane strain field on points of a Region with dimension dim and initial point values.

felupe.mesh.dual

Create a dual Mesh.

as_container(**kwargs)#

Create a FieldContainer with the field.

copy()#

Return a copy of the field.

extract(grad=True, sym=False, add_identity=True, dtype=None, out=None, order='C')#

Generalized extraction method which evaluates either the gradient or the field values at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is evaluated and/or the identity matrix is added to the gradient.

Parameters:
  • grad (bool, optional) – Flag for gradient evaluation (default is True).

  • sym (bool, optional) – Flag for symmetric part if the gradient is evaluated (default is False).

  • add_identity (bool, optional) – Flag for the addition of the identity matrix if the gradient is evaluated (default is True).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

(Symmetric) gradient or interpolated field values evaluated at the integration points of each cell in the region.

Return type:

ndarray

fill(a)#

Fill all field values with a scalar value.

classmethod from_mesh_container(mesh_container, dim=None, values=0.0)#

Create a Field on a vertex mesh from a mesh container.

grad(sym=False, dtype=None, out=None, order='C')#

Gradient as partial derivative of field values w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region. Optionally, the symmetric part the gradient is evaluated.

\[\left( \frac{\partial u_i}{\partial X_J} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial h_a}{\partial X_J} \right)_{(qc)}\]
Parameters:
  • sym (bool, optional) – Calculate the symmetric part of the gradient (default is False).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Gradient as partial derivative of field value components i at points w.r.t. the undeformed coordinates j, evaluated at the quadrature points q of cells c in the region.

Return type:

ndarray of shape (i, j, q, c)

hess(dtype=None, out=None, order='C')#

Hessian as second partial derivative of field values w.r.t. undeformed coordinates, evaluated at the integration points of all cells in the region.

\[\left( \frac{\partial^2 u_i}{\partial X_J~\partial X_K} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial^2 h_a}{\partial X_J~\partial X_K} \right)_{(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Hessian as partial derivative of field value components i at points w.r.t. the undeformed coordinates j and k, evaluated at the quadrature points q of cells c in the region.

Return type:

ndarray of shape (i, j, k, q, c)

interpolate(dtype=None, out=None, order='C')#

Interpolate field values located at mesh-points to the quadrature points q of cells c in the region.

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]
Parameters:
  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the output. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

Interpolated field value components i, evaluated at the quadrature points q of each cell c in the region.

Return type:

ndarray of shape (i, q, c)

reload(region, mode='edge', **kwargs)#

Reload the field with a new region in-place. The field values are extended to the new region if necessary.

Parameters:
  • region (Region) – The new region for the field.

  • mode (str, optional) – The padding mode to use if the field values need to be extended. Default is “edge”.

  • **kwargs (dict, optional) – Additional keyword arguments are passed to numpy.pad().

class felupe.FieldsMixed(region, n=3, values=(0.0, 0.0, 1.0, 0.0), axisymmetric=False, planestrain=False, offset=0, npoints=None, mesh=None, **kwargs)[source]#

A container with multiple (mixed) Fields based on a Region.

Parameters:

Notes

The dual region is chosen automatically, i.e. for a RegionHexahedron the dual region is RegionConstantHexahedron. A total number of n fields are generated inside a FieldContainer. For compatibility with ThreeFieldVariation, the third field is created with ones, all values of the other fields are initiated with zeros by default.

See also

felupe.FieldContainer

A container which holds one or multiple (mixed) fields.

felupe.Field

Field on points of a Region with dimension dim and initial point values.

felupe.FieldDual

A dual field on points of a Region with dimension dim and initial point values.

felupe.FieldAxisymmetric

Axisymmetric field on points of a Region with dimension dim and initial point values.

felupe.FieldPlaneStrain

Plane strain field on points of a Region with dimension dim and initial point values.

felupe.mesh.dual

Create a dual Mesh.

checkpoint()#

Return a checkpoint of the field container.

Returns:

A dict with a copy of the field container "field" and, if available, a copy of the top-level field container "field.x0".

Return type:

dict

Notes

The field containers, their fields and the values of the fields are copied. The regions, meshes, mesh containers and indices of the fields are not copied, i.e. they are shared with the field container. These are not modified during the evaluation of a job. Changes of the region or the mesh after a checkpoint is created (e.g. by merge()) are also visible in the copied field container of the checkpoint, but they do not affect restore(), which only restores the values of the fields. The copied field container of the checkpoint holds the copied top-level field container "field.x0" as attribute x0.

See also

felupe.FieldContainer.restore

Restore a checkpoint of a field container inplace.

copy()#

Return a copy of the field.

extract(grad=True, sym=False, add_identity=True, dtype=None, out=None, order='C')#

Generalized extraction method which evaluates either the gradient or the field values at the integration points of all cells in the region. Optionally, the symmetric part of the gradient is evaluated and/or the identity matrix is added to the gradient.

Parameters:
  • grad (bool or list of bool, optional) – Flag(s) for gradient evaluation(s). A boolean value is applied on the first field only and all other fields are extracted with grad=False. To enable or disable gradients per-field, use a list of boolean values instead (default is True).

  • sym (bool, optional) – Flag for symmetric part if the gradient is evaluated (default is False).

  • add_identity (bool or list of bool, optional) – Flag(s) for the addition of the identity matrix if the gradient is evaluated. A boolean value is applied on the first gradient only and all other gradients are extracted with add_identity=False. To enable or disable the addition of the identity matrix on gradients per-field, use a list of boolean values instead (default is True).

  • dtype (data-type or None, optional) – If provided, forces the calculation to use the data type specified. Default is None.

  • out (None or ndarray, optional) – A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly- allocated array is returned (default is None).

  • order (str or list of str, optional) – Controls the memory layout of the outputs. ‘C’ means it should be C contiguous. ‘F’ means it should be Fortran contiguous, ‘A’ means it should be ‘F’ if the inputs are all ‘F’, ‘C’ otherwise. ‘K’ means it should be as close to the layout as the inputs as is possible, including arbitrarily permuted axes. Default is ‘C’.

Returns:

(Symmetric) gradient or interpolated field values evaluated at the integration points of each cell in the region.

Return type:

tuple of ndarray

Notes

If the gradient is not requested, the interpolation method returns the field values evaluated at the numeric integration points q for each cell c in the region (so-called trailing axes).

\[u_{i(qc)} = \hat{u}_{ai}\ h_{a(qc)}\]

On the other hand, the gradient method returns the gradient of the field values w.r.t. the undeformed mesh point coordinates, evaluated at the integration points of all cells in the region.

\[\left( \frac{\partial u_i}{\partial X_J} \right)_{(qc)} = \hat{u}_{ai} \left( \frac{\partial h_a}{\partial X_J} \right)_{(qc)}\]

See also

felupe.Field.interpolate

Interpolate field values located at mesh-points to the quadrature points in the region.

felupe.Field.grad

Gradient as partial derivative of field values w.r.t. undeformed coordinates.

extracted_fields()#
imshow(*args, ax=None, dpi=None, **kwargs)#

Take a screenshot of the first field of the container, show the image data in a figure and return the ax.

Link value array of other field.

Parameters:

other_field (FieldContainer or None, optional) – The other field container (default is None). If None, all fields are linked to the first field. If the field container has slots and the other field container has no slots (e.g. a top-level field container), the fields are linked to the fields of the other field container, given by the slots. Otherwise, the fields are linked 1-to-1 by their position.

merge(decimals=None, **kwargs)#

Merge all fields and return a list of field containers as well as the top-level field container.

Parameters:
  • decimals (int or None, optional) – Precision decimals for merging duplicated mesh points. Default is None.

  • **kwargs (dict, optional) – Additional keyword arguments for MeshContainer.

Returns:

The top-level field container, to be used as the x0-argument in evaluate() and for the creation of boundary conditions. The given field containers are modified & reloaded in-place, along with a new attribute x0 that points to this top-level field container.

Return type:

FieldContainer

Notes

Mixed field containers, e.g. FieldsMixed, are supported, see merge() for details.

Examples

>>> import felupe as fem
>>>
>>> mesh1 = fem.Rectangle(n=3)
>>> displacement1 = fem.FieldAxisymmetric(fem.RegionQuad(mesh1), dim=2)
>>> field1 = fem.FieldContainer([displacement1])
>>>
>>> mesh2 = fem.Rectangle(a=(1, 0), b=(2, 1), n=3)
>>> displacement2 = fem.FieldAxisymmetric(fem.RegionQuad(mesh2), dim=2)
>>> field2 = fem.FieldContainer([displacement2])
>>>
>>> x0 = (field1 & field2).merge()
>>>
>>> umat = fem.NeoHookeCompressible(mu=1, lmbda=2)
>>> solid1 = fem.SolidBody(umat, field1)
>>> solid2 = fem.SolidBody(umat, field2)
>>>
>>> boundaries = fem.dof.uniaxial(x0, clamped=True)
>>>
>>> step = fem.Step(items=[solid1, solid2], boundaries=boundaries)
>>> job = fem.Job(steps=[step]).evaluate()
plot(*args, project=None, **kwargs)#

Plot the first field of the container.

See also

felupe.Scene.plot

Plot method of a scene.

felupe.project

Project given values at quadrature-points to mesh-points.

felupe.topoints

Shift given values at quadrature-points to mesh-points.

reload(fields=None)#

Reload the Field Container with new fields.

Parameters:

fields (list) – List of fields.

restore(checkpoint)#

Restore a checkpoint inplace.

Parameters:

checkpoint (dict) – A dict with checkpoint arrays / objects.

See also

felupe.FieldContainer.checkpoint

Return a checkpoint of the field container.

revolve(n=11, phi=180)#

Return a revolved field container.

Parameters:
  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

Returns:

The revolved field container.

Return type:

FieldContainer

Examples

First, create an axisymmetric field.

>>> import felupe as fem
>>>
>>> region = fem.RegionQuad(mesh=fem.Rectangle(n=6))
>>> field = fem.FieldContainer([fem.FieldAxisymmetric(region, dim=2)])
>>> field.plot().show()
../_images/field-13fa32320370af66_00_00.png

The first field of the field container is now revolved around the x-axis.

>>> new_field = field.revolve(n=11, phi=180)
>>> new_field.plot().show()
../_images/field-869cb482bf9a78d1_00_00.png

See also

SolidBody.revolve

Return a revolved solid body

SolidBodyNearlyIncompressible.revolve

Return a revolved solid body

screenshot(*args, filename='field.png', transparent_background=None, scale=None, **kwargs)#

Take a screenshot of the first field of the container.

See also

pyvista.Plotter.screenshot

Take a screenshot of a PyVista plotter.

values()#

Return the field values.

view(point_data=None, cell_data=None, cell_type=None, project=None)#

View the field with optional given dicts of point- and cell-data items.

Parameters:
  • point_data (dict or None, optional) – Additional point-data dict (default is None).

  • cell_data (dict or None, optional) – Additional cell-data dict (default is None).

  • cell_type (pyvista.CellType or None, optional) – Cell-type of PyVista (default is None).

  • project (callable or None, optional) – Project internal cell-data at quadrature-points to mesh-points (default is None).

Returns:

A object which provides visualization methods for felupe.FieldContainer.

Return type:

felupe.ViewField

See also

felupe.ViewField

Visualization methods for felupe.FieldContainer.

felupe.project

Project given values at quadrature-points to mesh-points.

felupe.topoints

Shift given values at quadrature-points to mesh-points.