Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

CoefficientFunction with spacial condition

More
4 years 2 weeks 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 2 weeks 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 2 weeks ago #2533 by NilsHM
Thanks!

That was exactly what I needed.

Best
Time to create page: 0.102 seconds