Skip to content
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
9 changes: 8 additions & 1 deletion cpp/dolfinx/mesh/Topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,14 @@ std::shared_ptr<const common::IndexMap> Topology::index_map(int dim) const
if (_entity_types[dim].size() > 1)
throw std::runtime_error(
"Multiple index maps of this dimension. Call index_maps instead.");
return this->index_maps(dim).at(0);
auto im = index_maps(dim);
if (im.empty())
{
throw std::runtime_error(std::format(
"Missing IndexMap in Topology. Maybe you need to create_entities({}).",
dim));
}
return im.at(0);
}
//-----------------------------------------------------------------------------
std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
Expand Down
17 changes: 3 additions & 14 deletions python/dolfinx/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,7 @@ def index_map(self, dim: int) -> _cpp.common.IndexMap:
Returns:
Index map for the entities of dimension ``dim``.
"""
if (imap := self._cpp_object.index_map(dim)) is not None:
return imap
else:
raise RuntimeError(
f"Entities of dimension {dim} has not been computed."
f"Call `dolfinx.mesh.Topology.create_entities({dim}) first."
)
return self._cpp_object.index_map(dim)

def index_maps(self, dim: int) -> list[_cpp.common.IndexMap]:
"""Get the IndexMaps that describes the parallel distribution of
Expand All @@ -200,14 +194,9 @@ def index_maps(self, dim: int) -> list[_cpp.common.IndexMap]:

Returns:
List of IndexMaps for the entities of dimension ``dim``.
May be empty if not yet computed.
"""
if (imaps := self._cpp_object.index_maps(dim)) is not None:
return imaps
else:
raise RuntimeError(
f"Entities of dimension {dim} have not been computed."
f"Call `dolfinx.mesh.Topology.create_entities({dim}) first."
)
return self._cpp_object.index_maps(dim)

def interprocess_facets(self) -> npt.NDArray[np.int32]:
"""List of inter-process facets, if facet topology has been
Expand Down
Loading