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.

Mesh

More
3 years 11 months ago - 3 years 11 months ago #2563 by Yongbin
Mesh was created by Yongbin
Hi, everyone! I want to add a square obstacle in the channel. Now, the following code is obviously wrong,
######
from netgen.geom2d import SplineGeometry
geo = SplineGeometry()
geo.AddRectangle( (0, 0), (40, 10), bcs = ("wall", "outlet", "wall", "inlet"))
geo.AddRectangle((5, 0), (6, 1))
mesh = Mesh( geo.GenerateMesh(maxh=0.6))

Many thanks!
Yongbin Han
Last edit: 3 years 11 months ago by Yongbin.
More
3 years 11 months ago #2564 by mneunteufel
Replied by mneunteufel on topic Mesh
Hi Yongbin,

you have to use the leftdomain, rightdomain flag to label your boundaries, e.g.
Code:
from ngsolve import * from netgen.geom2d import SplineGeometry geo = SplineGeometry() geo.AddRectangle( (0, 0), (40, 10), bcs = ("wall", "outlet", "wall", "inlet"), leftdomain=1, rightdomain=0) geo.AddRectangle((5, 0.2), (6, 1), leftdomain=0, rightdomain=1) mesh = Mesh( geo.GenerateMesh(maxh=0.6))

Secondly, in your code the rectangles have a shared edge, which is not allowed. I refer to this post a solution by adding your geometry edge by edge.

Best
Michael
The following user(s) said Thank You: Yongbin
More
3 years 11 months ago #2576 by Yongbin
Replied by Yongbin on topic Mesh
Hi,mneunteufel, I have now finished this code with your help.
Thank you very much!

Yongbin Han
Time to create page: 0.122 seconds