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

External operator #40

Closed
wants to merge 203 commits into from
Closed

External operator #40

wants to merge 203 commits into from

Conversation

nbouziani
Copy link

This PR sits on the Interp PR (#26) and adds the ExternalOperator objects.

The Interp contains most of the necessary changes to make ExternalOperator possible as it introduces the concept of BaseFormOperator which describes operators mapping between Hilbert spaces (i.e. that are Operator and BaseForm objects at the same time).

(More details will be added soon)

…r control differentiation error + Testing changes
doc/sphinx/source/manual/form_language.rst Outdated Show resolved Hide resolved
ufl/algorithms/analysis.py Outdated Show resolved Hide resolved
ufl/algorithms/apply_derivatives.py Outdated Show resolved Hide resolved
ufl/algorithms/replace_derivative_nodes.py Outdated Show resolved Hide resolved
ufl/algorithms/replace_derivative_nodes.py Outdated Show resolved Hide resolved
ufl/core/external_operator.py Outdated Show resolved Hide resolved
ufl/core/external_operator.py Show resolved Hide resolved
ufl/core/external_operator.py Outdated Show resolved Hide resolved
ufl/differentiation.py Outdated Show resolved Hide resolved
ufl/operators.py Outdated Show resolved Hide resolved
ufl/differentiation.py Outdated Show resolved Hide resolved
nbouziani and others added 15 commits September 12, 2023 17:11
* 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 (FEniCS#120)"

This reverts commit 677358a.

* Add BaseFormOperatorDerivativeRuleset

* Fix lint

* Revert "Revert "Allow multiple subdomain data (FEniCS#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 <[email protected]>
Co-authored-by: David Ham <[email protected]>
Co-authored-by: Rob Kirby <[email protected]>
Co-authored-by: ksagiyam <[email protected]>
Co-authored-by: ksagiyam <[email protected]>
Co-authored-by: Connor Ward <[email protected]>
@nbouziani nbouziani closed this Sep 13, 2023
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.

4 participants