Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geometry indices update #12

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install dependencies
run: python3 -m pip install --break-system-packages pyvista
run: python3 -m pip install --break-system-packages pyvista pytest

- name: Run unit tests
run: python3 -m pytest test/
1 change: 1 addition & 0 deletions febug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
plot_streamlines_from_source,
plot_entity_indices, plot_entity_indices_global,
plot_entity_indices_original,
plot_geometry_indices,
plot_mesh_quality, plot_function_dofs,
plot_point_cloud)

Expand Down
32 changes: 32 additions & 0 deletions febug/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,38 @@ def get_original_indices(
local_to_label_mapping=get_original_indices)


def plot_geometry_indices(mesh: dolfinx.mesh.Mesh,
plotter: pyvista.Plotter=None):
if plotter is None:
plotter = pyvista.Plotter()

plot_mesh(mesh, tdim=0, plotter=plotter, show_owners=False)

size_local = mesh.geometry.index_map().size_local
num_ghosts = mesh.geometry.index_map().num_ghosts
entities = np.arange(size_local, dtype=np.int32)
ghosts = np.arange(size_local, size_local + num_ghosts, dtype=np.int32)

if size_local > 0:
x = mesh.geometry.x[entities]
x_polydata = pyvista.PolyData(x)
labels = np.arange(size_local)
x_polydata["labels"] = [f"{i}" for i in labels]
plotter.add_point_labels(x_polydata, "labels", **entity_label_args,
point_color="grey")

if num_ghosts > 0:
x_ghost = mesh.geometry.x[ghosts]
x_ghost_polydata = pyvista.PolyData(x_ghost)
ghost_labels = np.arange(size_local, size_local + num_ghosts)
x_ghost_polydata["labels"] = [f"{i}" for i in ghost_labels]
plotter.add_point_labels(
x_ghost_polydata, "labels", **entity_label_args,
point_color="pink")

return plotter


def plot_point_cloud(xp: np.ndarray[float],
plotter: pyvista.Plotter=None):
if plotter is None:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
print("Python 3.10 or higher required, please upgrade.")
sys.exit(1)

VERSION = "0.8.0"
VERSION = "0.9.0"

REQUIREMENTS = ["pyvista", "fenics-dolfinx>0.8.0"]
REQUIREMENTS = ["pyvista", "fenics-dolfinx>0.9.0"]


class CMakeExtension(Extension):
Expand Down
7 changes: 7 additions & 0 deletions test/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def test_plot_entity_indices_global(mesh):
febug.plot_entity_indices_global(mesh, d)


@pytest.mark.parametrize("mesh", all_meshes)
def test_plot_geometry_indices(mesh):
for d in range(mesh.topology.dim+1):
mesh.topology.create_connectivity(d, mesh.topology.dim)
febug.plot_geometry_indices(mesh)


@pytest.mark.parametrize(
"mesh,tdim", [pytest.param(msh, tdim, marks=pytest.mark.xfail(
tdim not in (0, msh.topology.dim),
Expand Down
Loading