Expression defined by a long string
Asked by
Yi Jiang
Hi all,
I am trying to generate an Expression from a very long string, something like
for i in range(N):
Str += "sqrt( (x[0]-%g)*(x[0]-%g) + (x[1]-%g)*(x[1]-%g) )"%(X[i], X[i], Y[i], Y[i])
where N could be 1000 or even bigger. When I compile it by
Exp = Expression(Str)
I still can get a result, but it may take a very long time, say 1 hour. I need this Expression to define a weak form, and to interpolate it into a finite element space, which also takes a lot of time. Is there a more efficient way to define such a function/
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Yi Jiang
- Solved:
- Last query:
- Last reply:
To post a message you must log in.