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

Fix zero simplification in BaseForm.__add__ #262

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ebb10c1
Add trimmed serendipity
rckirby Feb 27, 2020
3ff2d50
Fix value shape for trimmed serendipity
rckirby Feb 27, 2020
c9bb809
ufl plumbing update for trimmed serendipity.
Justincrum Apr 10, 2020
87cd5a0
Plumbing for SminusDiv.py
Justincrum Apr 14, 2020
c17ccb5
Adding in element stuff for SminusCurl.
Justincrum Sep 8, 2020
0449576
Merge remote-tracking branch 'origin' into trimmedSerendipity
Justincrum Sep 22, 2020
5eea76b
Merge remote-tracking branch 'origin/master' into trimmedSerendipity
rckirby Jun 23, 2022
5b141d8
Merge pull request #23 from firedrakeproject/trimmedSerendipity
rckirby Jun 27, 2022
9135be1
Merge branch 'FEniCS:main' into master
dham Aug 4, 2022
3f5ad50
Merge branch 'main' into merge_fenics
dham Oct 13, 2022
0c592ec
Merge pull request #30 from firedrakeproject/merge_fenics
dham Oct 13, 2022
e2d2268
Fix typo
nbouziani Jan 15, 2023
13435fb
Merge pull request #32 from firedrakeproject/merge_fenics
dham Jan 25, 2023
f4babc4
Merge remote-tracking branch 'upstream/main' into ksagiyam/merge_upst…
ksagiyam Feb 24, 2023
772485d
Merge pull request #34 from firedrakeproject/ksagiyam/merge_upstream
ksagiyam Mar 13, 2023
16e3bbe
Merge remote-tracking branch 'fenics/main' into dham/merge_fenics
dham Jun 1, 2023
3c62318
Merge pull request #37 from firedrakeproject/dham/merge_fenics
dham Jun 2, 2023
55c281d
Merge remote-tracking branch 'upstream/main'
connorjward Aug 8, 2023
32c09fb
remove spurioius names
dham Sep 12, 2023
2e170ce
Merge pull request #41 from firedrakeproject/dham/fix_element_list
dham Sep 12, 2023
77fc281
Merge branch 'FEniCS:main' into master
dham Sep 12, 2023
f74efca
Merge remote-tracking branch 'fenics/main'
dham Sep 12, 2023
fd43d0d
Merge branch 'FEniCS:main' into master
dham Sep 20, 2023
7fbbd64
Merge branch 'FEniCS:main' into master
dham Sep 21, 2023
cf66c4b
Merge branch 'FEniCS:main' into master
dham Sep 22, 2023
ab66c9f
Merge remote-tracking branch 'upstream/main' into dolci/merge_upstream_2
Ig-dolci Nov 7, 2023
3f337c8
Merge pull request #46 from firedrakeproject/dolci/merge_upstream_2
JDBetteridge Nov 15, 2023
fa06f13
Merge remote-tracking branch 'upstream/main' into JHopeCollins/upstre…
JHopeCollins Nov 30, 2023
054b061
Merge pull request #48 from firedrakeproject/JHopeCollins/upstream-up…
JHopeCollins Nov 30, 2023
9f8ce94
Merge commit '109aa7d35ddaa7b1cccbf069831266c2cbe10856' into ksagiyam…
ksagiyam Feb 28, 2024
fbd288e
Merge pull request #49 from firedrakeproject/ksagiyam/merge_upstream_…
dham Feb 28, 2024
68f1c26
Fix BaseForm.__add__ simplification of Zero
nbouziani Mar 26, 2024
ca5069f
Merge branch 'main' into fix_baseform_add_zero_simplification
nbouziani Mar 26, 2024
652b0d8
Fix ruff
nbouziani Mar 26, 2024
b0ae20a
Fix test
nbouziani Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/test_duals.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def test_addition():
V = FunctionSpace(domain_2d, f_2d)
V_dual = V.dual()

fvector_2d = FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1)
W = FunctionSpace(domain_2d, fvector_2d)

u = TrialFunction(V)
v = TestFunction(V)

Expand Down Expand Up @@ -152,6 +155,11 @@ def test_addition():
res -= ZeroBaseForm((v,))
assert res == L

# Simplification with respect to ufl.Zero
a_W = Matrix(W, W)
res = a_W + Zero(W.value_shape)
assert res == a_W


def test_scalar_mult():
domain_2d = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
Expand Down
216 changes: 108 additions & 108 deletions ufl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,147 +44,147 @@

* Cells::

- AbstractCell
- Cell
- TensorProductCell
- vertex
- interval
- triangle
- tetrahedron
- quadrilateral
- hexahedron
- prism
- pyramid
- pentatope
- tesseract
-AbstractCell
-Cell
-TensorProductCell
-vertex
-interval
-triangle
-tetrahedron
-quadrilateral
-hexahedron
-prism
-pyramid
-pentatope
-tesseract

* Domains::

- AbstractDomain
- Mesh
- MeshView
-AbstractDomain
-Mesh
-MeshView

* Sobolev spaces::

- L2
- H1
- H2
- HInf
- HDiv
- HCurl
- HEin
- HDivDiv
-L2
-H1
-H2
-HInf
-HDiv
-HCurl
-HEin
-HDivDiv


* Pull backs::

- identity_pullback
- contravariant_piola
- covariant_piola
- l2_piola
- double_contravariant_piola
- double_covariant_piola
-identity_pullback
-contravariant_piola
-covariant_piola
-l2_piola
-double_contravariant_piola
-double_covariant_piola

* Function spaces::

- FunctionSpace
- MixedFunctionSpace
-FunctionSpace
-MixedFunctionSpace

* Arguments::

- Argument
- TestFunction
- TrialFunction
- Arguments
- TestFunctions
- TrialFunctions
-Argument
-TestFunction
-TrialFunction
-Arguments
-TestFunctions
-TrialFunctions

* Coefficients::

- Coefficient
- Constant
- VectorConstant
- TensorConstant
-Coefficient
-Constant
-VectorConstant
-TensorConstant

* Splitting form arguments in mixed spaces::

- split
-split

* Literal constants::

- Identity
- PermutationSymbol
-Identity
-PermutationSymbol

* Geometric quantities::

- SpatialCoordinate
- FacetNormal
- CellNormal
- CellVolume
- CellDiameter
- Circumradius
- MinCellEdgeLength
- MaxCellEdgeLength
- FacetArea
- MinFacetEdgeLength
- MaxFacetEdgeLength
- Jacobian
- JacobianDeterminant
- JacobianInverse
-SpatialCoordinate
-FacetNormal
-CellNormal
-CellVolume
-CellDiameter
-Circumradius
-MinCellEdgeLength
-MaxCellEdgeLength
-FacetArea
-MinFacetEdgeLength
-MaxFacetEdgeLength
-Jacobian
-JacobianDeterminant
-JacobianInverse

* Indices::

- Index
- indices
- i, j, k, l
- p, q, r, s
-Index
-indices
-i, j, k, l
-p, q, r, s

* Scalar to tensor expression conversion::

- as_tensor
- as_vector
- as_matrix
-as_tensor
-as_vector
-as_matrix

* Unit vectors and matrices::

- unit_vector
- unit_vectors
- unit_matrix
- unit_matrices
-unit_vector
-unit_vectors
-unit_matrix
-unit_matrices

* Tensor algebra operators::

- outer, inner, dot, cross, perp
- det, inv, cofac
- transpose, tr, diag, diag_vector
- dev, skew, sym
-outer, inner, dot, cross, perp
-det, inv, cofac
-transpose, tr, diag, diag_vector
-dev, skew, sym

* Elementwise tensor operators::

- elem_mult
- elem_div
- elem_pow
- elem_op
-elem_mult
-elem_div
-elem_pow
-elem_op

* Differential operators::

- variable
- diff,
- grad, nabla_grad
- div, nabla_div
- curl, rot
- Dx, Dn
-variable
(-diff,)
-grad, nabla_grad
-div, nabla_div
-curl, rot
-Dx, Dn

* Nonlinear functions::

- max_value, min_value
- abs, sign
- sqrt
- exp, ln, erf
- cos, sin, tan
- acos, asin, atan, atan2
- cosh, sinh, tanh
- bessel_J, bessel_Y, bessel_I, bessel_K
-max_value, min_value
-abs, sign
-sqrt
-exp, ln, erf
-cos, sin, tan
-acos, asin, atan, atan2
-cosh, sinh, tanh
-bessel_J, bessel_Y, bessel_I, bessel_K

* Complex operations::

Expand All @@ -193,10 +193,10 @@

* Discontinuous Galerkin operators::

- v('+'), v('-')
- jump
- avg
- cell_avg, facet_avg
-v("+"), v("-")
-jump
-avg
-cell_avg, facet_avg

* Conditional operators::

Expand All @@ -207,21 +207,21 @@

* Integral measures::

- dx, ds, dS, dP
- dc, dC, dO, dI, dX
- ds_b, ds_t, ds_tb, ds_v, dS_h, dS_v
-dx, ds, dS, dP
-dc, dC, dO, dI, dX
-ds_b, ds_t, ds_tb, ds_v, dS_h, dS_v

* Form transformations::

- rhs, lhs
- system
- functional
- replace
- adjoint
- action
- energy_norm,
- sensitivity_rhs
- derivative
-rhs, lhs
-system
-functional
-replace
-adjoint
-action
(-energy_norm,)
-sensitivity_rhs
-derivative
"""

# Copyright (C) 2008-2016 Martin Sandve Alnæs and Anders Logg
Expand Down
1 change: 0 additions & 1 deletion ufl/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# recommended to use. The __all__ list below is a start based
# on grepping of other FEniCS code for ufl.algorithm imports.


__all__ = [
"estimate_total_polynomial_degree",
"sort_elements",
Expand Down
1 change: 0 additions & 1 deletion ufl/algorithms/apply_restrictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later


from ufl.algorithms.map_integrands import map_integrand_dags
from ufl.classes import Restricted
from ufl.corealg.map_dag import map_expr_dag
Expand Down
1 change: 1 addition & 0 deletions ufl/algorithms/check_arities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Check arities."""

from itertools import chain

from ufl.classes import Argument, Zero
Expand Down
1 change: 0 additions & 1 deletion ufl/compound_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#
# Modified by Anders Logg, 2009-2010


from ufl.constantvalue import Zero, zero
from ufl.core.multiindex import Index, indices
from ufl.operators import sqrt
Expand Down
1 change: 0 additions & 1 deletion ufl/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#
# Modified by Massimiliano Leoni, 2016.


from ufl.core.terminal import Terminal
from ufl.core.ufl_type import ufl_type
from ufl.utils.counted import Counted
Expand Down
2 changes: 1 addition & 1 deletion ufl/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __add__(self, other):
if isinstance(other, (int, float)) and other == 0:
# Allow adding 0 or 0.0 as a no-op, needed for sum([a,b])
return self
elif isinstance(other, Zero) and not (other.ufl_shape or other.ufl_free_indices):
elif isinstance(other, Zero):
# Allow adding ufl Zero as a no-op, needed for sum([a,b])
return self

Expand Down
2 changes: 1 addition & 1 deletion ufl/formatting/ufl2unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class UC:
left_double_angled_bracket = "⟪"
right_double_angled_bracket = "⟫"

combining_right_arrow_above = "\u20D7"
combining_right_arrow_above = "\u20d7"
combining_overline = "\u0305"


Expand Down
1 change: 0 additions & 1 deletion ufl/indexsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later


from ufl.constantvalue import Zero
from ufl.core.expr import Expr, ufl_err_str
from ufl.core.multiindex import MultiIndex
Expand Down
Loading