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

UFL, Constant Vectors

0 votes

Creating a constant scalar is straightforward,

vector = VectorElement("Lagrange", triangle, 2)
scalar = FiniteElement("Lagrange", triangle, 2)

# scalar constant
c = Constant(triangle)

# vector coefficient
f = Coefficient(vector)

But, how would I create a constant vector? For example for a constant body force.

asked Dec 31, 2013 by Charles FEniCS User (4,220 points)

1 Answer

0 votes
 
Best answer

I found this just after posting by searching UFL Constant Vector in google,

http://fenicsproject.org/documentation/ufl/1.0.1/ufl.html

the answer is

f = ConstantVector(vector)

I didn't find it in the text

answered Dec 31, 2013 by Charles FEniCS User (4,220 points)

Just to be precise (maybe the linked page has been edited after the answer above): the syntax is

f = VectorConstant (cell)

where cell can be, e.g., triangle.

...