fem.properties.maybe_sample_cell_property

fem.properties.maybe_sample_cell_property(
    sdf,
    points,
    cells,
    key,
    *,
    base_points=None,
)

Sample a property per element, or return None when the scene lacks it.

The permissive counterpart of :func:sample_cell_property, for properties a study reports on rather than solves with — mass needs a density, but a study whose materials never mention one should still solve and simply not report a mass.

The presence check always runs on concrete positions (base_points, else points when it is concrete), because a traced sample cannot be inspected for NaN; only once the property is known to be specified is it re-sampled at the possibly-traced points so the value stays differentiable.

Parameters

Name Type Description Default
sdf Any Scene SDF object, or anything else (which yields None). required
points Any Node positions (N, 3) (may be traced). required
cells Any Connectivity (C, ...). required
key str Property name. required
base_points Any Concrete node positions for the presence check; defaults to points. None

Returns

Name Type Description
Any | None A (C,) array of per-element values, or None when the scene has no
Any | None material field or does not specify key everywhere.