Skip to content

Change interface of fem.petsc.create_vector to allow for general list of function spaces #3694

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

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

schnellerhase
Copy link
Contributor

@schnellerhase schnellerhase commented Apr 8, 2025

The creation of PETSc vectors relies internally on a list of tuples (IndexMap, bs). Given a list of such and a vector kind we can create the corresponding coefficient vector. Previously this functionality was not exposed to the user directly and only supported indirectly by passing a Form from which the spaces would then be extracted.

  • Introduces la.petsc.create_vector which now takes a list of (IndexMap, bs) tuples and returns a PETSc.Vec object. The interface of fem.petsc.create_vector is extended to allow for function spaces as input as well. Vectors can therefore now be create by a list of function spaces: b = dolfinx.fem.create_vector([V, W]) and no longer require a form to be present for such construction. And alternatively from a general sequence of index maps and blocks sizes, without the presence of any function spaces with la.petsc.create_vector.
  • Introduces _assign_block_data which factors out the attachment of block information to PETSc vectors.
  • Internal switch to LBYL.

@schnellerhase schnellerhase force-pushed the create_vector_from_spaces branch from 9591f98 to 7e9c3e2 Compare April 8, 2025 21:07
@schnellerhase schnellerhase changed the title Change interface of la.petsc.create_vector to allow for general list of function spaces Change interface of fem.petsc.create_vector to allow for general list of function spaces Apr 12, 2025
@schnellerhase schnellerhase marked this pull request as ready for review April 12, 2025 15:19
@francesco-ballarin francesco-ballarin added this to the 0.10.0 milestone Jul 9, 2025
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