CoefficientFunction with spacial condition

More
4 years 7 months ago #2531 by NilsHM
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:
Code:
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
More
4 years 7 months ago #2532 by mneunteufel
Hi Nils,

I think the IfPos-CoefficientFunction is what you are looking for.
Code:
IfPos(x,0,IfPos(-x,0,1))

Maybe you need to "regularize" it a bit
Code:
eps = 1e-8 IfPos(x-eps,0,IfPos(-x-eps,0,1))

Best
Michael
The following user(s) said Thank You: NilsHM
More
4 years 7 months ago #2533 by NilsHM
Thanks!

That was exactly what I needed.

Best
Time to create page: 0.111 seconds