Source code for physicsnemo.mesh.primitives.basic.single_point_3d
# SPDX-FileCopyrightText: Copyright (c) 2023 - 2026 NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Single point in 3D space.
Dimensional: 0D manifold in 3D space.
"""
import torch
from physicsnemo.mesh.mesh import Mesh
[docs]
def load(device: torch.device | str = "cpu") -> Mesh[0, 3]:
"""Create a mesh with a single point in 3D space.
Parameters
----------
device : str
Compute device ('cpu' or 'cuda').
Returns
-------
Mesh[0, 3]
Mesh with n_manifold_dims=0, n_spatial_dims=3, n_cells=1.
"""
points = torch.tensor([[0.5, 0.5, 0.5]], dtype=torch.float32, device=device)
cells = torch.tensor([[0]], dtype=torch.int64, device=device)
return Mesh(points=points, cells=cells)