Question #114079 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/114079
Status: Open => Answered
Kristian B. Ølgaard proposed the following answer:
On 9 June 2010 19:10, Cataldo Manigrasso
<[email protected]> wrote:
> New question #114079 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/114079
>
> Hi everybody,
>
> I need to write in a ufl file a piecewise defined functional:
>
> L =
> inner(grad(v),grad(u)) if normg(u)<= t1
> 1/normg(u)*inner(grad(v),grad(u)) if t1<normg(u)<=t2
> 2*inner(grad(v),grad(u)) if normg(u)>= t2
>
> normg() is a function that gives the norm of the gradient. I tried to use
> conditional(condition, true_form, false_form) in a nested way, but it doesn't
> seem to work. Also reducing the form to one condition instead of two (i.e. a
> L= condition( norm(grad(u)), first_form, second_form) doesn't work. I tried
> to use a simpler condition like 3>2, but there was no improvement. I get an
> error "Conditional is not yet supported (yet)". Am I doing a mistake or it is
> not yet available? I hope not, I really need it and it seems it is working if
> one reads the documentation.
Conditionals are not supported (yet). As the error says. It is
supported in UFL, meaning that it is possible to create the form, but
the form compiler FFC does not generate any code because that has not
been implemented.
There is a blueprint for this
https://blueprints.launchpad.net/ffc/+spec/ufl-conditionals and it
looks like it has been assigned to me...
However, it is not on top of my TODO list and I can't say when I'll
get around to fix it. It is possible to implement a workaround until I
fix it by handling the conditionals in main.cpp and manipulate the
values of the Coefficient u.
Kristian
> Thanks a lot for the help!
>
> Here is the code of the ufl file:
>
> t1=1
> t2=2
>
> element=FiniteElement("CG","triangle",1)
>
> v = TestFunction(element)
> w = TrialFunction(element)
> f = Coefficient(element)
> u = Coefficient(element)
> # Euclidean norm of the gradient
> def normg(v):
> return sqrt(inner(grad(v),grad(v)))
>
> L = conditional( lt(normg(u),t1), inner(grad(v),grad(u))*dx,\
> 1/normg(u)*inner(grad(v),grad(u))*dx )
>
> # L = conditional( lt(normg(u),t1), m2*normg(u), \
> # conditional( lt(normg(u),t2), \
> # m2*t1, \
> # m1*normg(u))) \
> # *inner(grad(v),grad(u))/sqrt(inner(grad(u),grad(u)))*dx
>
>
>
>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : [email protected]
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
>
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.
_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to : [email protected]
Unsubscribe : https://launchpad.net/~dolfin
More help : https://help.launchpad.net/ListHelp