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

Wrap discrete_gradient in Python #3037

Merged
merged 16 commits into from
Feb 20, 2024
Merged

Wrap discrete_gradient in Python #3037

merged 16 commits into from
Feb 20, 2024

Conversation

mscroggs
Copy link
Member

@mscroggs mscroggs commented Feb 5, 2024

Resolves #3022

@bleyerj
Copy link

bleyerj commented Feb 5, 2024

The lines

The discrete gradient operator A interpolates the gradient of
a Lagrange finite element function into a Nedelec (first kind)
space.
Args:
space0: Lagrange space to interpolate the gradient from
space1: Nedelec space to interpolate into

seem to suggest that this is made for Lagrange -> Nedelec only. Is this really the case?
I was at some point interested in having a discrete gradient operator from Lagrange to DG for instance, or a Quadrature space.

@michalhabera
Copy link
Contributor

The lines

The discrete gradient operator A interpolates the gradient of
a Lagrange finite element function into a Nedelec (first kind)
space.
Args:
space0: Lagrange space to interpolate the gradient from
space1: Nedelec space to interpolate into

seem to suggest that this is made for Lagrange -> Nedelec only. Is this really the case?
I was at some point interested in having a discrete gradient operator from Lagrange to DG for instance, or a Quadrature space.

The code makes assumptions that target space maps using covariant Piola, which would fail if you use DG. Just note that you can always build these discrete operators using dolfinx.Expression that contains ufl.TrialFunction on the input space. Assembly of these expressions into PETSc/scipy matrix is not implemented yet, but you can easily write a custom (Numba) loop that does that. I presented this in my FEniCS2021 talk, can find the snippets if you want.

python/dolfinx/fem/__init__.py Outdated Show resolved Hide resolved
python/dolfinx/fem/petsc.py Show resolved Hide resolved
@garth-wells garth-wells added this to the v0.8.0 milestone Feb 15, 2024
@mscroggs mscroggs added this pull request to the merge queue Feb 20, 2024
Merged via the queue into main with commit e3fb2a1 Feb 20, 2024
19 checks passed
@mscroggs mscroggs deleted the mscroggs/discrete_gradient branch February 20, 2024 14:57
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.

Wrap discrete gradients in Python
4 participants