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

Separate cpp.Expression and ufl.Coefficient #1

Closed
garth-wells opened this issue Apr 10, 2018 · 1 comment
Closed

Separate cpp.Expression and ufl.Coefficient #1

garth-wells opened this issue Apr 10, 2018 · 1 comment
Labels
proposal Suggested change or addition

Comments

@garth-wells
Copy link
Member

From @blechta

Expressions have element associated with them. That enables any expression to be used immediately in integrals. This poses several problems:

  1. Not all expressions are intended to be used in integrals. Why should they have element.
  2. Attached element does not have any relevance apart of integrals. This is confusing
  3. degree kwarg being shortcut for Lagrange element is overly confusing.

Proposal is to separate Expression from ufl.Coefficient in a following spirit

expression = Expression("x[0]*x[0]")
expression.eval(...)  # ok
u = interpolate(expression, some_function_space)  # ok
bc = DirichletBC(space, expression, where)  # ok
expression*dx  # failure: is not ufl expression

Expression(expression, element=...)*dx  # ok
create_pointwise_expression(expression, ...)*dx  # ok

The last two lines could be renamed to something more sensible, e.g.,

Coefficient(expression, element)*dx  # ok

See #2 for discussion about pointwise expressions.

@garth-wells
Copy link
Member Author

See #183.

michalhabera pushed a commit that referenced this issue Feb 3, 2020
jorgensd pushed a commit that referenced this issue Jul 22, 2022
Split interpolation into sub-routines
jorgensd pushed a commit that referenced this issue Sep 7, 2022
Various updates to the PML demo
jhale pushed a commit that referenced this issue Apr 12, 2024
This PR allows for a `dlx.la.Vector` (rather than a `dlx.fem.Function`) to manage the memory and the scope of the `petsc4py.PETSc.vec` object that wraps the underlying data.

The implementation of the property `dlx.fem.Function.vector` was also modified to delegate the creation of the wrapper to the underlying `dlx.la.Vector`.

All changes are backward compatible.
github-merge-queue bot pushed a commit that referenced this issue Apr 12, 2024
* Let dlx.la.Vector manage the scope of the petsc4py wrapper (#1)

This PR allows for a `dlx.la.Vector` (rather than a `dlx.fem.Function`) to manage the memory and the scope of the `petsc4py.PETSc.vec` object that wraps the underlying data.

The implementation of the property `dlx.fem.Function.vector` was also modified to delegate the creation of the wrapper to the underlying `dlx.la.Vector`.

All changes are backward compatible.

* Update python/dolfinx/fem/function.py

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>

* Update python/dolfinx/fem/function.py

Remove # type: ignore

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>

* Deprecate dlx.fem.Function.vector; replace it with dlx.fem.Function.x.petsc_vec

* Fix ruff checks

* Fix ruff checks import order

* Ruff formatt fix

* Update function.py

Fix spelling in warnings message.

* Update function.py

Specify that it is a deprecation warning

* Ruff formatting error

---------

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Suggested change or addition
Projects
None yet
Development

No branches or pull requests

1 participant