Just use ufl.conditional. See http://fenics.readthedocs.io/projects/ufl/en/latest/manual/form_language.html#conditional

 

You can use x, y = SpatialCoordinate(mesh) to get the symbols for the coordinates.

 

Regards,

 

David

 

From: <firedrake-bounces@imperial.ac.uk> on behalf of Amireh Mousavi <amireh.mousavi@math.iut.ac.ir>
Reply-To: firedrake <firedrake@imperial.ac.uk>
Date: Tuesday, 17 July 2018 at 12:03
To: firedrake <firedrake@imperial.ac.uk>
Subject: Re: [firedrake] Piecewise-defined function

 

Of course. Consider 2 dimensional domain and suppose I have four functions f1, f2, f3 and f4 defined on the mesh. How can I define a piecewise function f  on the mesh on 4 pieces of a unit square [0, 1] × [0,1]? 

Something like:

 

f  =  f1,    0 <= x[0] <=1/2 and  0 <= x[1] <=1/2

f  =  f2,    1/2 <= x[0] <=1 and  0 <= x[1] <=1/2

f  =  f3,    0 <= x[0] <=1/2 and  1/2 <= x[1] <=1

f  =  f4,    1/2 <= x[0] <=1 and  1/2 <= x[1] <=1

 


 

 

----- Original Message -----


From: Colin Cotter (colin.cotter@imperial.ac.uk)
Date: 25/04/97 17:36
To: firedrake (firedrake@imperial.ac.uk)
Subject:
Re: [firedrake] Piecewise-defined function

 

Hi Amireh,

Please can you be a bit more specific about your function?

 

 

all the best

---cjc

 

On 16 July 2018 at 21:24, Amireh Mousavi <amireh.mousavi@math.iut.ac.ir> wrote:

Dear all,

I need to define a piecewise-defined function in Firedrake but I don't know how to do it. I would appreciate if someone could give me guidance about that.
Thank you in advance.

Best,

Amireh


_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake

 

 

--

Colin Cotter

Department of Mathematics

Imperial College London

 

I don't expect a reply to this email from you outside of your normal working hours.

 


_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake