Skip to content

liblaf.apple.sim.element.triangle ¤

Classes:

ElementTriangle ¤

Bases: Element

Methods:

  • __pdoc__

    ...

  • __repr__
  • evolve
  • function

    Return the shape functions at given coordinates.

  • gradient

    Return the gradient of shape functions at given coordinates.

  • hessian

    Return the Hessian of shape functions at given coordinates.

  • tree_at

Attributes:

cells property ¤

cells: Integer[Array, ' points']

dim property ¤

dim: int

n_points property ¤

n_points: int

points property ¤

points: Float[Array, 'points=3 dim=2']

quadrature property ¤

quadrature: Scheme

__pdoc__ ¤

__pdoc__(**kwargs) -> AbstractDoc

...

References
  1. wadler_lindig._definitions._pformat_dataclass()
Source code in src/liblaf/apple/sim/element/triangle.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    with jax.ensure_compile_time_eval():
        return jnp.asarray([[0, 0], [1, 0], [0, 1]], dtype=float)

@override
def function(
    self, coords: Float[ArrayLike, "dim=2"], /
) -> Float[Array, "points=3"]:
    coords = jnp.asarray(coords)
    r, s = coords
    return jnp.asarray([1 - r - s, r, s])

@override
def gradient(
    self, coords: Float[ArrayLike, "dim=2"], /
) -> Float[Array, "points=3 dim=2"]:
    with jax.ensure_compile_time_eval():
        return jnp.asarray([[-1, -1], [1, 0], [0, 1]], dtype=float)

@override
def hessian(
    self, coords: Float[ArrayLike, "dim=2"], /
) -> Float[Array, "points=3 dim=2 dim=2"]:
    with jax.ensure_compile_time_eval():
        return jnp.zeros((3, 2, 2), dtype=float)

__repr__ ¤

__repr__() -> str

evolve ¤

evolve(**changes) -> Self

function ¤

function(
    coords: Float[ArrayLike, "dim=2"],
) -> Float[Array, "points=3"]

Return the shape functions at given coordinates.

Source code in src/liblaf/apple/sim/element/triangle.py
20
21
22
23
24
25
26
@override
def function(
    self, coords: Float[ArrayLike, "dim=2"], /
) -> Float[Array, "points=3"]:
    coords = jnp.asarray(coords)
    r, s = coords
    return jnp.asarray([1 - r - s, r, s])

gradient ¤

gradient(
    coords: Float[ArrayLike, "dim=2"],
) -> Float[Array, "points=3 dim=2"]

Return the gradient of shape functions at given coordinates.

Source code in src/liblaf/apple/sim/element/triangle.py
28
29
30
31
32
33
@override
def gradient(
    self, coords: Float[ArrayLike, "dim=2"], /
) -> Float[Array, "points=3 dim=2"]:
    with jax.ensure_compile_time_eval():
        return jnp.asarray([[-1, -1], [1, 0], [0, 1]], dtype=float)

hessian ¤

hessian(
    coords: Float[ArrayLike, "dim=2"],
) -> Float[Array, "points=3 dim=2 dim=2"]

Return the Hessian of shape functions at given coordinates.

Source code in src/liblaf/apple/sim/element/triangle.py
35
36
37
38
39
40
@override
def hessian(
    self, coords: Float[ArrayLike, "dim=2"], /
) -> Float[Array, "points=3 dim=2 dim=2"]:
    with jax.ensure_compile_time_eval():
        return jnp.zeros((3, 2, 2), dtype=float)

tree_at ¤

tree_at(
    where: Callable[[Self], Node | Sequence[Node]],
    replace: Any | Sequence[Any] = ...,
    replace_fn: Callable[[Node], Any] = ...,
    is_leaf: Callable[[Any], bool] | None = None,
) -> Self