Skip to content

liblaf.apple.sim.element.triangle ¤

Classes:

ElementTriangle ¤

Bases: Element

ElementTriangle()

Methods:

  • 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.

  • replace
  • tree_at

Attributes:

__dataclass_fields__ class-attribute ¤

__dataclass_fields__: dict[str, Field[Any]]

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

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
17
18
19
20
21
22
23
@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
25
26
27
28
29
30
@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
32
33
34
35
36
37
@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)

replace ¤

replace(**changes: Any) -> Self
Source code in src/liblaf/apple/struct/tree/_pytree.py
19
20
def replace(self, **changes: Any) -> Self:
    return dataclasses.replace(self, **changes)

tree_at ¤

tree_at(
    where: Callable[[Self], Node | Sequence[Node]],
    replace: Any | Sequence[Any] = MISSING,
    replace_fn: Callable[[Node], Any] = MISSING,
    is_leaf: Callable[[Any], bool] | None = None,
) -> Self
Source code in src/liblaf/apple/struct/tree/_pytree.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def tree_at(
    self,
    where: Callable[[Self], Node | Sequence[Node]],
    replace: Any | Sequence[Any] | MISSING = MISSING,
    replace_fn: Callable[[Node], Any] | MISSING = MISSING,
    is_leaf: Callable[[Any], bool] | None = None,
) -> Self:
    kwargs: dict[str, Any] = {}
    if replace is not MISSING:
        kwargs["replace"] = replace
    if replace_fn is not MISSING:
        kwargs["replace_fn"] = replace_fn
    if is_leaf is not None:
        kwargs["is_leaf"] = is_leaf
    return eqx.tree_at(where, self, **kwargs)