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.

Piecewise CoefficientFunction

More
3 years 1 week ago - 3 years 1 week ago #3599 by Ryanleaf
Dear All,

I have a quick question. I am trying to define a piecewise Coefficient function. I noticed that I could achieve this by doing something like this,
" domain_values = {'inner': 3.7, 'outer': 1}
values_list = [domain_values[mat]
for mat in mesh.GetMaterials()]
cf = CoefficientFunction(values_list)
Draw(cf, mesh, 'piecewise') "
I am wondering is it possible to define a piecewise coefficient function without setting actual domains?
Write a coefficient function f like:
f(x,y,z)=x.  when x^2+y^2>1
f(x,y,z)=y.  when x^2+y^2<=1
Without creating a cylinder domain?

Thanks,
Ryan
Last edit: 3 years 1 week ago by Ryanleaf.
More
3 years 1 week ago #3600 by schruste
Hi,

Try IfPos(x*x+y*y-1,x,y) .

Best,
Christoph
The following user(s) said Thank You: Ryanleaf
Time to create page: 0.118 seconds