- Thank you received: 0
meshes for multiple subdomains
4 years 3 months ago #3062
by wen jing
meshes for multiple subdomains was created 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)
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)
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 3 months ago #3067
by christopher
Replied by christopher on topic meshes for multiple subdomains
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
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
4 years 3 months ago #3070
by wen jing
Replied by wen jing on topic meshes for multiple subdomains
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.
best.
4 years 3 months ago #3071
by wen jing
Replied by wen jing on topic meshes for multiple subdomains
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
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
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 3 months ago #3072
by christopher
Replied by christopher on topic meshes for multiple subdomains
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
ngsolve.org/docu/latest/i-tutorials/unit...vity/adaptivity.html
4 years 3 months ago #3073
by wen jing
Replied by wen jing on topic meshes for multiple subdomains
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?
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.120 seconds