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

Allow multiple subdomain data #120

Merged
merged 9 commits into from
Oct 31, 2022
Merged

Conversation

jpdean
Copy link
Member

@jpdean jpdean commented Sep 6, 2022

Currently, UFL checks that all integrals of a particular type in a form have the same subdomain data (using the UFL ID). I'm not sure this should be UFL's job. Instead, UFL should probably just collect the data into a list and let the finite element library (e.g. dolfinx) either check the data is the same or make use of the additional data. This PR addresses this.

This PR requires FEniCS/dolfinx#2369

@@ -86,7 +86,7 @@ jobs:
with:
path: ./dolfinx
repository: FEniCS/dolfinx
ref: main
ref: jpdean/manual_integration_domains_2
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't forget to revert this before merge

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed to pass the integration test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but only because dolfinx main doesn't expect a list to be returned. I'll make a new branch of dolfinx now with a small change to account for this.

test/test_measures.py Outdated Show resolved Hide resolved
@chrisrichardson chrisrichardson merged commit 677358a into main Oct 31, 2022
@chrisrichardson chrisrichardson deleted the jpdean/multiple_subdomain_data branch October 31, 2022 12:56
nbouziani added a commit to firedrakeproject/ufl that referenced this pull request Jan 13, 2023
nbouziani added a commit to firedrakeproject/ufl that referenced this pull request Jan 13, 2023
mscroggs pushed a commit that referenced this pull request Sep 13, 2023
* Hash in matrix

* Add test for action on action

* remove eq in form as redundant

* lint + amend tests

* Fix Issue with adjoint

* small change to arguments method of adjoint class

* lint

* lint

* more style

* cleanup Action

* cleanup Action

* cleanup adjoint

* use correct action

* sanitise argument creation

* Shut up Flake8

W503 is no longer PEP8 best practice.
E129 causes spurious problems on long `if` statements.

* clean up Matrix

* Clean up duals

* Clean up functionspace

* Remove unneeded signature from Matrix

* cleanup form

* Check trivial case for Action and Adjoint

* Update possible right term for Action

* Take into account various BaseForm objects in expand_derivatives

* Add BaseForm in __init__

* Add BaseForm in as_ufl

* Update action

* Update Cofunction and Coargument for when they take in a primal space

* Add equals to FormSum

* Add __eq__ to Action

* Add __eq__ to Adjoint

* Add __eq__ and __hash__ to Coargument

* Fix typos

* Refactor analysis.py

* Add BaseFormDerivative

* Fix  for arguments, coefficients and function spaces

* Fix hash for coefficients, arguments and function spaces + some more equality fixes

* Draft BaseForm diff

* Draft: Refactor UFL types using UFLType

* Add BaseFormOperator

* Add Interp

* Remove assemble from BaseFormOperator

* Update Interp interface

* Some fixes + Add __str__ to Interp

* Fix __eq__ for Coargument

* Check trivial cases + some fixes

* Add test_interp.py

* Add UFLType handler as the default handler + Move UFLType to ufl_type.py

* Add ufl_operands and _ufl_compute_hash to BaseForm objects for MultiFunction traversal

* Add Matrix/Cofunction/Coargument differentiation + Add some ufl_type handlers

* Push arguments analysis through BaseFormDerivative

* Add Action differentiation

* Add tests for BaseForm differentiation

* Add Adjoint(Adjoint(.)) = Id

* Fix Action differentiation

* Matrix derivative is always 0 (since we can't differentiate wrt a Matrix)

* Update _handle_derivative_arguments

* Fix _analyze_form_arguments for FormSum

* Update FormSum and tests

* Fix ExprList

* Add Adjoint differentiation

* Cleanup Interp + add _ufl_expr_reconstruct_

* Cleanup BaseFormOperator

* Add BaseFormOperatorDerivative

* Make Interp public

* Add Interp differentiation

* Update test

* Delegate ufl_free_indices and ufl_index_dimensions to Interp expression

* Add handlers for Action/Adjoint/FormSum in map_integrands

* Use pytest.raises

* Add ufl_operands to Interp

* Add replace_derivative_nodes (from ExternalOperator implementation)

* Add BaseFormOperator differentiation (2 stages mechanism) from ExternalOperator implementation

* Change __eq__ to equals for dual objects

* Update AUTHORS

* Add preprocess_form

* Update analysis.py with BaseFormOperator

* Add .base_form_operators() in Form

* Fix _ufl_expr_reconstruct_ for Interp

* Update tests

* Grad differentiation + Fix few things in differentiation

* BaseFormOperator doesn't have free indices

* Cleanup

* Update doc

* Update traversal.py

* Replace expr handler by ufl_type in Replacer

* Last minute change

* Flake8

* Fix flake8

* Fix few things

* Add replacer handler for Interp

* Refactor UFL type system

* Address comments from the PR

* Add coefficients to BaseFormOperator

* Updare interp

* Fix lint

* Update date interp.py

* Update test

* Fix BaseFormOperatorCoordinateDerivative

* Fix lint

* Update arguments analysis for FormSum

* Fix lint

* Extend Action distribution over ufl.Sum

* Add test for Action distributivity wrt FormSum and Sum

* Enable Matrix on the rhs of Action

* Add ZeroBaseForm

* Add tests for ZeroBaseForm

* Update author info

* Enable Matrix on the rhs of Action

* Add ZeroBaseForm

* Add tests for ZeroBaseForm

* Update author info

* Fix Cofunction's argument

* Update expand_derivatives

* Update action

* Clean way of getting action arguments and check function spaces

* Rename _get_action_arguments

* Fix ZeroBaseForm simplification for BaseForm

* Handle Zero case for Action

* Fix typo

* Provide support for caching derivative expansion for action/adjoint

* Swap ZeroBaseForm's arguments for adjoint

* Check arguments when summing a ZeroBaseForm

* Fix argument contraction with CoefficientDerivative

* Clean up

* Update Interp reconstruct

* Fix __str__ for Action/Adjoint

* Add/Fix comments

* Fix typo

* Update warnings

* Clean up docstrings + fix flake8

* Update Interp with revisions

* Revert "Allow multiple subdomain data (#120)"

This reverts commit 677358a.

* Add BaseFormOperatorDerivativeRuleset

* Fix lint

* Revert "Revert "Allow multiple subdomain data (#120)""

This reverts commit 073579e.

* Fix typo

* Remove strong typing check for Interp.__eq__

* fix interp equality

* remove dead code

* Equip Cofunctions with an Argument in the primal space

* Equip FormSum objects with a ufl_domain

* Fix arguments collection for BaseFormDerivative

* Equip BaeForm with coefficients

* Equip BaseForm with a ufl_domain

* Add BaseFormCoordinateDerivative

* Update AUTHORS

* Fix weight analysis for FormSum composition

* Handle ufl.Zero in rhs

* Remove support for adjoint derivative

* Remove support for Action derivative when left is a 2-form

* Extend form arguments analysis to coefficients for BaseFormDerivative

* Update rules for Action arguments

* Coarguments have one argument in the primal space and one in the dual space

* Add preprocess_form

* Fix FormSum reconstruction in map_integrands

* DerivativeRuleDispatcher: Add handler for base form coordinate derivatives

* Simplify Action/Adjoint of Coarguments

* Remove checks on ZeroBaseForms' arguments

* Update Action differentiation test

* Return primal space argument for Coargument's adjoint

* Fix tests

* Fix flake8

* Fix flake8

* Add argument_slots to BaseFormOperatorDerivative

* Extend Action simplification cases to ufl.Argument

* Lift some code from external operator branch

* Fix equals for Action/Adjoint

* remove spurioius names

* Update ufl/argument.py

* Update ufl/coefficient.py

* Fix some bugs and address PR comments

* Fix spurious firedrake UFL code

* Fix flake8

* Fix test

* Update ufl/algorithms/replace_derivative_nodes.py

* Address PR comments

* Lift test change from Intepr branch

* Fix dForm/dBaseFormOperator

* Fix comment

* Fix analysis

* Fix count

* Update replace_derivative_nodes and BaseFormOperator.__eq___

* Rename Interp -> Interpolate and add interpolate helper function

* Fix flake8

* Add check on Action's left

* Lift new differentiation process from external operator branch

---------

Co-authored-by: India Marsden <imm1117@ic.ac.uk>
Co-authored-by: David Ham <David.Ham@imperial.ac.uk>
Co-authored-by: Rob Kirby <robert.c.kirby@gmail.com>
Co-authored-by: ksagiyam <k.sagiyama@imperial.ac.uk>
Co-authored-by: ksagiyam <46749170+ksagiyam@users.noreply.github.com>
Co-authored-by: Connor Ward <c.ward20@imperial.ac.uk>
mscroggs pushed a commit that referenced this pull request Sep 13, 2023
* Update AUTHORS

* Add preprocess_form

* Update analysis.py with BaseFormOperator

* Add .base_form_operators() in Form

* Fix _ufl_expr_reconstruct_ for Interp

* Update tests

* Grad differentiation + Fix few things in differentiation

* BaseFormOperator doesn't have free indices

* Cleanup

* Update doc

* Update traversal.py

* Replace expr handler by ufl_type in Replacer

* Last minute change

* Flake8

* Fix flake8

* Fix few things

* Add replacer handler for Interp

* Refactor UFL type system

* Address comments from the PR

* Add coefficients to BaseFormOperator

* Updare interp

* Some update

* Fix lint

* Fix lint

* Update date interp.py

* Update test

* Fix BaseFormOperatorCoordinateDerivative

* Fix lint

* Fix lint

* Remove deprecated ExternalOperator manipulations in compute_form_data

* Expunge external operator extraction mechanism from BaseForm objects

* Fix lint

* Rewrite external operator replace mechanism (untested)

* Add ufl_element to ExternalOperator for split

* Update arguments analysis for FormSum

* Fix lint

* Extend Action distribution over ufl.Sum

* Add test for Action distributivity wrt FormSum and Sum

* Enable Matrix on the rhs of Action

* Add ZeroBaseForm

* Add tests for ZeroBaseForm

* Update author info

* Enable Matrix on the rhs of Action

* Add ZeroBaseForm

* Add tests for ZeroBaseForm

* Update author info

* Fix Cofunction's argument

* Update expand_derivatives

* Update action

* Clean way of getting action arguments and check function spaces

* Rename _get_action_arguments

* Fix ZeroBaseForm simplification for BaseForm

* Handle Zero case for Action

* Fix ZeroBaseForm simplification for BaseForm

* Handle Zero case for Action

* Fix typo

* Provide support for caching derivative expansion for action/adjoint

* Swap ZeroBaseForm's arguments for adjoint

* Check arguments when summing a ZeroBaseForm

* Fix argument contraction with CoefficientDerivative

* Clean up

* Clean up

* Update Interp reconstruct

* Fix replace_derivative_nodes for ListTensor arguments

* Handle empty forms for Adjoint

* Fix Action __str__

* Fix __str__ for Action/Adjoint

* Set argument number locally when constructing the derivative of a BaseFormOperator

* Fix lint

* Add/Fix comments

* Fix typo

* Update warnings

* Backup

* Clean up docstrings + fix flake8

* Update Interp with revisions

* Revert "Allow multiple subdomain data (#120)"

This reverts commit 677358a.

* Add BaseFormOperatorDerivativeRuleset

* Fix lint

* Revert "Revert "Allow multiple subdomain data (#120)""

This reverts commit 073579e.

* Fix typo

* Remove spurious files

* Add BaseFormOperatorDerivativeRecorder for BaseFormOperator differentiation

* Remove strong typing check for Interp.__eq__

* fix interp equality

* remove dead code

* Equip Cofunctions with an Argument in the primal space

* Equip FormSum objects with a ufl_domain

* Fix arguments collection for BaseFormDerivative

* Equip BaeForm with coefficients

* Equip BaseForm with a ufl_domain

* Add BaseFormCoordinateDerivative

* Update AUTHORS

* Fix weight analysis for FormSum composition

* Handle ufl.Zero in rhs

* Revert "Merging"

This reverts commit 45bcf27, reversing
changes made to 8c3f111.

* Remove support for adjoint derivative

* Remove support for Action derivative when left is a 2-form

* Extend form arguments analysis to coefficients for BaseFormDerivative

* Update rules for Action arguments

* Coarguments have one argument in the primal space and one in the dual space

* Add preprocess_form

* Fix FormSum reconstruction in map_integrands

* DerivativeRuleDispatcher: Add handler for base form coordinate derivatives

* Simplify Action/Adjoint of Coarguments

* Remove checks on ZeroBaseForms' arguments

* Update Action differentiation test

* Return primal space argument for Coargument's adjoint

* Fix tests

* Fix flake8

* Fix flake8

* Fix flake8

* Fix flake8

* Fix coargument extraction within base form operators

* Add argument_slots to BaseFormOperatorDerivative

* Extend Action simplification cases to ufl.Argument

* Remove spurious code

* Remove deprecated code

* Remove deprecated __eq__ (previously remplaced by equals)

* Remove spurious space

* Fix flake8

* Lift some code from external operator branch

* Fix test

* Fix equals for Action/Adjoint

* remove spurioius names

* Update ufl/argument.py

* Update ufl/coefficient.py

* Fix some bugs and address PR comments

* Fix spurious firedrake UFL code

* Fix flake8

* Fix test

* Update ufl/algorithms/replace_derivative_nodes.py

* Address PR comments

* Lift test change from Intepr branch

* Fix dForm/dBaseFormOperator

* Fix comment

* Fix and clean few things

* Fix analysis

* Fix analysis

* Fix count

* Update ufl/core/external_operator.py

* Address PR comments

* Update ufl/differentiation.py

* Update ufl/algorithms/replace_derivative_nodes.py

* Update ufl/algorithms/replace_derivative_nodes.py

* Update replace_derivative_nodes and BaseFormOperator.__eq___

* Rename Interp -> Interpolate and add interpolate helper function

* Fix flake8

* Add __eq__ to ExternalOperator

* Fix BaseFormOperator differentiation

* Remove out-of-date doc (lifted to another branch)

* Add check on Action's left

* Lift new differentiation process from external operator branch

* Fix comment

---------

Co-authored-by: David A. Ham <david.ham@imperial.ac.uk>
Co-authored-by: Rob Kirby <robert.c.kirby@gmail.com>
Co-authored-by: ksagiyam <k.sagiyama@imperial.ac.uk>
Co-authored-by: ksagiyam <46749170+ksagiyam@users.noreply.github.com>
Co-authored-by: Connor Ward <c.ward20@imperial.ac.uk>
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.

None yet

4 participants