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 8 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(s). 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.

This introduces/changes 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.

Additionally, the dispatching internally has been reworked, it no longer relies on try-except blocks.

@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
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.

2 participants