This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Scalar and vector-valued expression

+1 vote

Hi,
I 'm using c++ dolfin.
I was wondering if

 Expression ()

and

 Expression(1)

initialize the same object or not. Because I would expect that a vector-valued expression of dimension 1 should be the same as a scalar expression, but I'm getting some error if I use the latter in a scalar problem.

asked Jul 30, 2013 by gedeone FEniCS User (1,110 points)

1 Answer

+2 votes
 
Best answer

It is not the same because scalar is rank 0 and vector is rank 1. Of course you can appropriately convert between them. On UFL level

vector = as_vector((scalar,))
scalar = vector[0]
answered Jul 31, 2013 by Jan Blechta FEniCS Expert (51,420 points)
selected Aug 8, 2013 by Jan Blechta
...