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.

meshes for multiple subdomains

More
3 years 7 months ago #3062 by wen jing
How to generate meshes for multiple subdomains so that its normal vector points from one area to another? Can the processing methods in the tutorial solve this problem?

The example in the tutorial :
geometry = SplineGeometry()

pnts = [ (0,0), (1,0), (1,1), (0,1), (2,0), (2,1)]
pnums = [geometry.AppendPoint(*p) for p in pnts]
lines = [ (pnums[0],pnums[1],1,1,0), (pnums[1],pnums[2],2,1,2),
(pnums[2],pnums[3],3,1,0), (pnums[3],pnums[0],4,1,0), (pnums[1], pnums[4],5,2,0),
(pnums[4],pnums[5],6,2,0), (pnums[5],pnums[2],7,2,0)]
for p1,p2,bc,left,right in lines:
geometry.Append( ["line", p1, p2], bc=bc, leftdomain=left, rightdomain=right)
return
mesh = Mesh(twoDomain().GenerateMesh (maxh=0.1))
Draw(mesh)
More
3 years 7 months ago #3067 by christopher
You can use leftdomain and rightdomain arguments for this, see here:
ngsolve.org/docu/latest/i-tutorials/unit-4.1-geom2d/geom2d.html

normal always points into rightdomain

Best
The following user(s) said Thank You: wen jing
More
3 years 7 months ago #3070 by wen jing
Thanks for your careful reply. However, I still think the interface problem is difficult to deal with. Will you present some examples of handling interface problem in tutorials? if so, it will bring a lot of help to beginners like me.

best.
More
3 years 7 months ago #3071 by wen jing
The solution you provided does not seem to be able to handle the following subdomains

def twoDomain():
geo = SplineGeometry()
geo.AddRectangle(p1=(0,0),
p2=(0,2),
bc="rectangle",
leftdomain=1,
rightdomain=0)

geo.AddRectangle(p1=(0,1),
p2=(0,2),
bc="rectangle",
leftdomain=2,
rightdomain=0)

geo.SetMaterial (1, "outer")
geo.SetMaterial (2, "inner")
return geo

ngmesh = Mesh(twoDomain().GenerateMesh(maxh=0.1))
Draw(ngmesh)

Best
More
3 years 7 months ago #3072 by christopher
first your rectangles have 0 width, second if you want to have multiple domains for now you need to define the splines of the geometry manually. See for example here:
ngsolve.org/docu/latest/i-tutorials/unit...vity/adaptivity.html
More
3 years 7 months ago #3073 by wen jing
Thans for your reply. The following meshes have not 0 width:
def twoDomain():
geo = SplineGeometry()
geo.AddRectangle(p1=(0,0),
p2=(1,2),
bc="rectangle",
leftdomain=1,
rightdomain=0)

geo.AddRectangle(p1=(0,1),
p2=(1,2),
bc="rectangle",
leftdomain=2,
rightdomain=0)

geo.SetMaterial (1, "outer")
geo.SetMaterial (2, "inner")
return geo

ngmesh = Mesh(twoDomain().GenerateMesh(maxh=0.1))
Draw(ngmesh)

Firstly, I want a meshes for multiple subdomains such that the normal vector on the interface points from a subregion, you tell me the first way, actually, the first way can not deal with this problem like this double rectangles domain. Then, the scond way can solve this?
Time to create page: 0.159 seconds