Hi Lawrence,


works perfectly, thanks!


All the best,

Tobias




Von: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> im Auftrag von Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk>
Gesendet: Dienstag, 18. Oktober 2016 18:12
An: firedrake
Betreff: Re: [firedrake] assign different values on subdomains
 


On 18/10/16 18:00, Schwedes, Tobias wrote:
> Hi all,
>
>
> I would like to assign different values of some function u on
> subdomains of a 2-D domain. More precisely, I want to have u equal to
> 1 for y > x and equal to 0 otherwise. For that reason I guess one
> needs to be able to define subdomains. Besides the Issue on

Here are two ways:

x, y = SpatialCoordinate(mesh)

subdomain = SubDomainData(y > x)

u = Function(V)

u.interpolate(as_ufl(1), subset=subdomain)

This will create a subset that marks all cells as "active" if their
coordinate, evaluated at the cell center, has y > x.  This is, I
think, equivalent to your dolfin code.

Alternately, if you want the expression to be evaluated quad-point-wise:

x, y = SpatialCoordinate(mesh)

u = conditional(y > x, 1, 0)

Now use u as normal in your expressions.  If you need to visualise
this field you will obviously have to interpolate it into some space.

Cheers,

Lawrence