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

Dualspace update #25

Merged
merged 47 commits into from
Feb 1, 2022
Merged

Dualspace update #25

merged 47 commits into from
Feb 1, 2022

Conversation

nbouziani
Copy link

Update the dual space branch #21, mainly by fixing few things and extending it to cover BaseForm differentiation.

More precisely:

  1. Fix few things
  2. Update ufl/algorithms/analysis.py
  3. Add UFLType
  4. Add BaseForm differentiation

mscroggs and others added 30 commits October 28, 2021 19:13
…FEniCS#71)

* allow variant hints to be passed into VectorElement and TensorElement

* get variant from sub element (for when VectorElement family input is a FiniteElement with a variant)

* get variant of sub element properly
Comment on lines 40 to 56
elif isinstance(form, FormSum):
mapped_components = [map_integrands(function, component, only_integral_type)
for component in form.components()]
nonzero_components = [(component, 1) for component in mapped_components
# Catch ufl.Zero and zeros of dual objects
# Workaround while the role of `__eq__`/`equals` for BaseForms is clarified ?
if not component == 0]
return FormSum(*nonzero_components)
elif isinstance(form, Adjoint):
# Zeros are caught inside `Adjoint.__new__`
return Adjoint(map_integrands(function, form._form, only_integral_type))
elif isinstance(form, Action):
left = map_integrands(function, form._left, only_integral_type)
right = map_integrands(function, form._right, only_integral_type)
# Zeros are caught inside `Action.__new__`
return Action(left, right)
elif isinstance(form, (Expr, BaseForm)):
Copy link
Author

Choose a reason for hiding this comment

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

@wence- @dham : Following our discussion regarding the fact that the derivative expansion was manually pushed through in expand_derivatives. I have made some cleanup and added handlers here to address the issue raised but also to extend this behaviour to other MultiFunction objects that could eventually be fed with dual objects (cf. this commit 2fdd180)

test/test_duals.py Outdated Show resolved Hide resolved
test/test_duals.py Outdated Show resolved Hide resolved
ufl/action.py Show resolved Hide resolved
ufl/action.py Outdated Show resolved Hide resolved
ufl/adjoint.py Outdated Show resolved Hide resolved
ufl/algorithms/traversal.py Outdated Show resolved Hide resolved
ufl/argument.py Outdated Show resolved Hide resolved
ufl/coefficient.py Outdated Show resolved Hide resolved
ufl/constantvalue.py Show resolved Hide resolved
ufl/differentiation.py Outdated Show resolved Hide resolved
@nbouziani
Copy link
Author

@wence- @dham Following our discussion, the UFLType system has been refactored. The currect system uses a UFLType metaclass equipping Expr and BaseForm which facilitates having BaseForm being pushed through MultiFunction objects. In addition, the set of operations common to BaseForm and Expr has been lifted to the ufl_type decorator which now has a first stage common to all UFLType objects and a second one specific to Expr subclasses. As a consequence, BaseForm objects are now decorated with ufl_type

jpdean and others added 4 commits January 10, 2022 09:08
…EniCS#76)

* Add method for getting the facet cell

* Don't use cellname2facetname

* Remove num_facet_edges

* Make suggested changes
* Remove cellname2facetname

* Flake8
* added value_shape for WithMapping element

* raise ValueError instead of error

* Pass kwargs when reconstructing a TensorProductElement

* forget the original kwargs

Co-authored-by: Pablo Brubeck <brubeck@protonmail.com>
@dham dham merged commit a0151ed into dualspace Feb 1, 2022
@dham dham deleted the dualspace_update branch February 1, 2022 14:38
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.

7 participants