Skip to content

Conversation

schnellerhase
Copy link
Contributor

@schnellerhase schnellerhase commented Sep 11, 2025

With the new interface, the create_vector([V], kind="mpi") case no longer holds block data. This adds the block data, allowing to treat a single function space vector as a block vector when passing type="mpi". Caught downstream.

@schnellerhase schnellerhase changed the title Fix block data for [V] case Fix vector block data for single function space case Sep 11, 2025
@schnellerhase schnellerhase marked this pull request as ready for review September 11, 2025 20:58
@@ -123,7 +123,10 @@ def create_vector(
index_map, bs = maps[0]
ghosts = index_map.ghosts.astype(PETSc.IntType) # type: ignore[attr-defined]
size = (index_map.size_local * bs, index_map.size_global * bs)
return PETSc.Vec().createGhost(ghosts, size=size, bsize=bs, comm=index_map.comm) # type: ignore
b = PETSc.Vec().createGhost(ghosts, size=size, bsize=bs, comm=index_map.comm) # type: ignore
if kind == PETSc.Vec.Type.MPI:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if kind == None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the previous behaviour that would have been equivalent to the call create_vector(L) which did not attach block data, therefore we don't want to attach data.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If creating vector for list of a single space, i.e. create_vector([V]) is almost the same as creating a vector on a single space create_vector(V), except that the former attaches block data, then why don't we remove the whole concept of single space create_vector(V) and always require a list of spaces, be it of length one. That would simplify meaning of kind, in my opinion, so either mpi or nest. @garth-wells ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I added the 'block data' concept but I can't recall the details ;). Does it introduce any memory overhead for the single space case?

In general, I'm in favour of as few special cases as possible, and has few interface types and possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about merging this, which recovers behaviour as before (and fixes down stream usage) and having a look into removing the difference in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

@schnellerhase schnellerhase added this pull request to the merge queue Sep 12, 2025
Merged via the queue into main with commit a8af0ae Sep 12, 2025
18 of 20 checks passed
@schnellerhase schnellerhase deleted the schnellerhase/vector-block branch September 12, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants