CoefficientFunction with spacial condition

Hello everyone,

I would like to set a CoefficientFunction that is different on the y-axis than anywhere else.
I hoped to do this as follows:

cf1 = 2*x cf2 = CoefficientFunction(1) cf = CoefficientFunction([cf2 if X == 0.0 else cf1 for X in x])
but cf now is zero everwhere.

How can I make cf be cf1 but cf2 on the y-axis?

Best
Nils

Hi Nils,

I think the IfPos-CoefficientFunction is what you are looking for.

IfPos(x,0,IfPos(-x,0,1))

Maybe you need to “regularize” it a bit

eps = 1e-8 IfPos(x-eps,0,IfPos(-x-eps,0,1))

Best
Michael

Thanks!

That was exactly what I needed.

Best