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 9 months ago #2905 by Yongbin
Mesh was created by Yongbin
Hi ,everyone ! I want to generate the simlar mesh below at [- 1,1] [-1,1], but the following code is at [0,1] [0,1]. how to modify it? Thank you in advance for your reply!

Yongbin


######################################################
from ngsolve import *
import ngsolve.meshes as ngm

ngsglobals.msg_level = 1

i = 4
mesh = ngm.MakeStructured2DMesh(quads=False, nx = 2**i ,ny = 2**i)
Draw(mesh)
########################################################
More
3 years 9 months ago #2906 by mneunteufel
Replied by mneunteufel on topic Mesh
Hi Yongbin,

you can use a mapping function to deform the unit-square. The following code gives you the mesh [-1,1]x[-1,1]
Code:
from ngsolve import * import ngsolve.meshes as ngm ngsglobals.msg_level = 1 i = 4 mapping = lambda x,y : (2*x-1,2*y-1) mesh = ngm.MakeStructured2DMesh(quads=False, nx = 2**i ,ny = 2**i, mapping=mapping) Draw(mesh)

Best,
Michael
The following user(s) said Thank You: Yongbin
More
3 years 9 months ago #2907 by Yongbin
Replied by Yongbin on topic Mesh
Hi,mneunteufel

Thank you for your reply!

Bset Regards
Yongbin Han
Time to create page: 0.139 seconds