Generate a structured 2D mesh Parameters ---------- quads : bool If True, a quadrilateral mesh is generated. If False, the quads are split to triangles. nx : int Number of cells in x-direction. ny : int Number of cells in y-direction. secondorder :
(quads=True, nx=10, ny=10, secondorder=False, periodic_x=False, periodic_y=False, mapping = None, bbpts=None, bbnames=None, flip_triangles=False, boundarylayer=None, hppnts=None)
| 45 | return ngsmesh |
| 46 | |
| 47 | def MakeStructured2DMesh(quads=True, nx=10, ny=10, secondorder=False, periodic_x=False, periodic_y=False, mapping = None, bbpts=None, bbnames=None, flip_triangles=False, boundarylayer=None, hppnts=None): |
| 48 | """ |
| 49 | Generate a structured 2D mesh |
| 50 | |
| 51 | Parameters |
| 52 | ---------- |
| 53 | quads : bool |
| 54 | If True, a quadrilateral mesh is generated. If False, the quads are split to triangles. |
| 55 | |
| 56 | nx : int |
| 57 | Number of cells in x-direction. |
| 58 | |
| 59 | ny : int |
| 60 | Number of cells in y-direction. |
| 61 | |
| 62 | secondorder : bool |
| 63 | If True, second order curved elements are used. |
| 64 | |
| 65 | periodic_x: bool |
| 66 | If True, the left and right boundaries are identified to generate a periodic mesh in x-direction. |
| 67 | |
| 68 | periodic_y: bool |
| 69 | If True, the top and bottom boundaries are identified to generate a periodic mesh in y-direction. |
| 70 | |
| 71 | mapping: lamda |
| 72 | Mapping to transform the generated points. If None, the identity mapping is used. |
| 73 | |
| 74 | bbpts : list |
| 75 | List of points which should be handled as BBND and are named with bbnames. The mesh (nx, ny and mapping) must be constructed in such a way that the bbpts coincide with generated points. Otherwise an Exception is thrown. |
| 76 | |
| 77 | bbnames : list |
| 78 | List of bbnd names as strings. Size must coincide with size of bbpts. Otherwise an Exception is thrown. |
| 79 | |
| 80 | flip_triangles : bool |
| 81 | If set to True together with quads=False the quads are cut the other way round |
| 82 | |
| 83 | boundarylayer : dict |
| 84 | If not None it expects a dictionary of the form { "boundaryname" : [t1,...,tn] } where ti denote the thickness of layer i. The number of layers are included in nx/ny. After the layers are placed the remaining number of cells are used to divide the remaining grid uniformly. |
| 85 | |
| 86 | hppnts : list |
| 87 | If not None it expects a list of the form [ (px1,py1, hpref1), (px2,py2, hpref2), ... ] where px,py are the point coordinates which have to be resolved in the mesh and hpref the refinement factor |
| 88 | |
| 89 | Returns |
| 90 | ------- |
| 91 | (ngsolve.mesh) |
| 92 | Returns generated 2D NGSolve mesh |
| 93 | |
| 94 | """ |
| 95 | mesh = Mesh() |
| 96 | mesh.dim=2 |
| 97 | |
| 98 | if (bbpts and bbnames) and len(bbpts) != len(bbnames): |
| 99 | raise Exception("Lenght of bbnames does not coincide with length of bbpts!") |
| 100 | |
| 101 | found = [] |
| 102 | indbbpts = [] |
| 103 | if bbpts: |
| 104 | for i in range(len(bbpts)): |