kaolin.physics.simplicits.PhysicsPoints

API

class kaolin.physics.simplicits.PhysicsPoints(pts, yms, prs, rhos, appx_vol, strict_checks=True)

Bases: PhysicsPointsProtocol, TensorContainerBase

Point-sampled object with material properties.

pts

Points tensor representing the object’s geometry, of shape \((N, 3)\) (in \(m\)).

Type

torch.Tensor

yms

Young’s moduli defining material stiffness, of shape \((N,)\) (in \(kg/m/s^2\)).

Type

torch.Tensor

prs

Poisson’s ratios defining material compressibility, of shape \((N,)\).

Type

torch.Tensor

rhos

Density defining material density, of shape \((N,)\) (in \(kg/m^3\)).

Type

torch.Tensor

appx_vol

Approximate volume, as a scalar (in \(m^3\)).

Type

torch.Tensor

__init__(pts, yms, prs, rhos, appx_vol, strict_checks=True)

Initialize the class.

Parameters
  • pts (torch.Tensor) – Points tensor of shape \((N, 3)\) representing the object’s geometry (in \(m\))

  • yms (Union[torch.Tensor, float]) – Young’s moduli defining material stiffness (in \(kg/m/s^2\)). Can be either: - A tensor of shape \((N,)\) for per-point values - A float value that will be applied to all points

  • prs (Union[torch.Tensor, float]) – Poisson’s ratios defining material compressibility. Can be either: - A tensor of shape \((N,)\) for per-point values - A float value that will be applied to all points

  • rhos (Union[torch.Tensor, float]) – Density defining material density (in \(kg/m^3\)). Can be either: - A tensor of shape \((N,)\) for per-point values - A float value that will be applied to all points

  • appx_vol (Union[torch.Tensor, float]) – Approximate volume (in \(m^3\)). Can be either: - A tensor of shape \((1,)\) - A float value

as_dict(only_tensors=False) Dict[str, Any]

Return all non-None attributes as a {name: value} dict.

classmethod assert_supported(attr)

Raises an exception if class does not support provided attribute name.

check_other_attribute(attr, log_error=False)

Checks a non-tensor attribute validity; returns True if ok.

check_sanity(log_error=True)

Validates that all tensor attributes are correct; implement abstract methods.

Parameters

log_error (bool) – If True, logs each failed check via logger.error.

Returns

True if all checks pass, False otherwise.

Return type

bool

check_tensor_attribute(attr, log_error=False)

Checks tensor attribute validity; returns True if valid.

classmethod class_other_attributes()

Returns attribute names that are not PyTorch tensors or dicts thereof.

classmethod class_tensor_attributes()

Returns attribute names that are PyTorch tensors or dicts thereof.

cpu(attributes: Optional[Sequence[str]] = None)

Calls cpu on all or selected tensor attributes; returns a shallow copy.

cuda(device: Optional[Union[int, device, str]] = None, attributes: Optional[Sequence[str]] = None)

Calls cuda on all or selected tensor attributes; returns a shallow copy.

describe_attribute(attr, print_stats=False, detailed=False)

Outputs an informative string about an attribute; the same method used for all attributes in to_string.

Parameters
  • attr (str) – attribute name

  • print_stats (bool) – if to print statistics about values in each tensor

  • detailed (bool) – if to include additional information about each tensor

Returns

multi-line string with attribute information

Return type

(str)

Raises

ValueError if attr is not supported

detach(attributes: Optional[Sequence[str]] = None)

Detaches all or selected tensor attributes; returns a shallow copy.

get_attributes(only_tensors=False)

Returns names of all attributes that are currently set to non-None value in this class instance.

Parameters

only_tensors – if true, will only include tensor attributes

Returns

list of string names

Return type

(list)

subsample(num_pts=None, sample_indices=None)

Subsample into another PhysicsPoints.

Parameters
  • num_pts (int, optional) – Number of points to sample. Mutually exclusive with sample_indices.

  • sample_indices (torch.Tensor, optional) – Explicit indices to use for subsampling, of shape \((\text{num_pts},)\). Mutually exclusive with num_pts.

Returns

The subsampled PhysicsPoints, of size \((\text{num_pts})\).

Return type

(PhysicsPoints)

to(*args: Any, attributes: Optional[Sequence[str]] = None, **kwargs: Any)

Moves or casts tensors like torch.Tensor.to() / torch.nn.Module.to().

Parameters
  • *args – forwarded to tensor.to(*args)

  • attributes (list of str, optional) – if set, only these tensor attributes are updated

  • **kwargs – forwarded to tensor.to(**kwargs)

Returns

shallow copy with converted tensors

Return type

PointSamples

to_string(print_stats=False, detailed=False)

Returns information about tensor attributes currently contained in the object.

Parameters
  • print_stats (bool) – if to print statistics about values in each tensor

  • detailed (bool) – if to include additional information about each tensor

Returns

multi-line string with attribute information

Return type

(str)