`ufl.split` incompatible with `ufl.as_vector`
- Dominant language
- Python
- Stars
- 150
- Forks
- 79
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 10
Description
I found a useful case that is not correctly handled by `ufl.split`.
Consider the simple code snapshot below. Both `broken_case` and `working_case` return a vector-like expression, however `ufl.split` is unable to correctly extract the list of components for the broken case.
```
import dolfin as dl
import ufl
def broken_case():
print("Construct a vector using as_vector")
a = dl.Constant(1.)
b = dl.Constant(2.)
return ufl.as_vector( (a,b) )
def working_case():
print("Construct a vector constant")
return dl.Constant( (1., 2.) )
v = working_case()
print( ufl.split(v) )
v = broken_case()
print( ufl.split(v) )
```
which produces the output.
```
Construct a vector constant
(Indexed(Coefficient(FunctionSpace(None, VectorElement(FiniteElement('Real', None, 0), dim=2)), 0), MultiIndex((FixedIndex(0),))), Indexed(Coefficient(FunctionSpace(None, VectorElement(FiniteElement('Real', None, 0), dim=2)), 0), MultiIndex((FixedIndex(1),))))
Construct a vector using as_vector
Don't know how to split [f_1, f_2].
Traceback (most recent call last):
File "my_tesst.py", line 18, in
print( ufl.split(v) )
File "/Users/uvilla/anaconda3/envs/fenics-2019.1/lib/python3.7/site-packages/ufl/split_functions.py", line 61, in split
error("Don't know how to split %s." % (v,))
File "/Users/uvilla/anaconda3/envs/fenics-2019.1/lib/python3.7/site-packages/ufl/log.py", line 172, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Don't know how to split [f_1, f_2].
```
On the other hand:
```
v = broken_case()
a,b= v
```
produces the desired effect.
Then, my question is: Would make sense to replace [this error line](https://github.com/FEniCS/ufl/blob/3cdfb8acfeeb5404804e12a304b65f58c51d822c/ufl/split_functions.py#L50) with `return v`?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.