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 33 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.ufl_element().value_shape)
assert res == a_W


def test_scalar_mult():
domain_2d = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
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
Loading