gridap / gridap/Gridap.jl

Symmetry detection of terms

Open
#785 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
879
Forks
119
Avg merge
6d 3h
Merged PRs (30d)
4

Description

Hi,

I noticed that this
```
a(u,v) = ∫(0.1*v⋅u)dΩ
```
yields `issymmetric(get_matrix(op)) == false`
while this
```
a(u,v) = ∫(0.1*(v⋅u))dΩ
```
works as expected.
I wouldn't expect general symbolic simplification to work but this simple case had me tricked for quite a while since it is just down to order of execution.

MWE:
```
L = 1.0
domain = (0.0, L, 0.0, L)
n = 4
partition = (n,n)
model = CartesianDiscreteModel(domain,partition)

Ω = Triangulation(model)
dΩ = Measure(Ω,2)

V = TestFESpace(model,
ReferenceFE(lagrangian,Float64,3),
conformity=:L2)
U = TrialFESpace(V)
b(v) = 0

a(u,v) = ∫(0.1*u⋅v)dΩ # not symmetric
op = AffineFEOperator(a,b, U, V)
issymmetric(get_matrix(op))

a(u,v) = ∫(0.1*(u⋅v))dΩ # symmetric due to brackets
op = AffineFEOperator(a,b, U, V)
issymmetric(get_matrix(op))

a(u,v) = ∫(1.0*u⋅v)dΩ # special case with prefactor 1
op = AffineFEOperator(a,b, U, V)
issymmetric(get_matrix(op))
```

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Julia MWE and compare the unparenthesized and parenthesized forms of the bilinear expression. Trace how get_matrix(op) is checked by issymmetric for these cases, then verify that equivalent expressions produce the same symmetry result, including the prefactor-1 case.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.