How to define vector Expression with complicated piecewise behavior?

3 months ago by
K D  
I'm trying to define a vector source term. Physically, this could be the body force in elasticity. I have a complicated piecewise definition that I want to use. That is, I need to use a bunch of if-elif statements.

For simple expressions, I am able to use the usual Expression syntax. My piecewise expression seems too complicated for the "conditional" option. I found this approach:
but I have 2 problems with that.
1) I can get it to work, I don't understand how and why. I'd like to understand better before using it.  Can anyone explain or point me to the right place in the documentation.

2) the link describes the scalar case. I tried and failed to do the vector case. I would appreciate help with that. Maybe the answer to my first question will also help me to generalize it myself.

Community: FEniCS Project

1 Answer

3 months ago by
K D  

I was able to figure out my answer at this page:
See the first example in Section 3.  I had not changed the return (1,) to return (2,) in the example at the link in the original question.

Please login to add an answer/comment or follow this question.

Similar posts:
Search »