MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / MakeStructuredSurfaceMesh

Function MakeStructuredSurfaceMesh

python/meshes.py:630–748  ·  view source on GitHub ↗

Generate a structured 2D surface mesh in 3D 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.

(quads=True, nx=10, ny=10, mapping = None, secondorder=False, bbbpts=None, bbbnames=None, flip_triangles=False)

Source from the content-addressed store, hash-verified

628
629
630def MakeStructuredSurfaceMesh(quads=True, nx=10, ny=10, mapping = None, secondorder=False, bbbpts=None, bbbnames=None, flip_triangles=False):
631 """
632 Generate a structured 2D surface mesh in 3D
633
634 Parameters
635 ----------
636 quads : bool
637 If True, a quadrilateral mesh is generated. If False, the quads are split to triangles.
638
639 nx : int
640 Number of cells in x-direction.
641
642 ny : int
643 Number of cells in y-direction.
644
645 mapping : lamda
646 Mapping to transform the generated points. If None, the identity mapping is used.
647
648 secondorder : bool
649 If True, use quadratic elements, else linear elements are used.
650
651 bbbpts : list
652 List of points which should be handled as BBBND and are named with bbbnames. The mesh (nx, ny and mapping) must be constructed in such a way that the bbbpts coincide with generated points. Otherwise an Exception is thrown.
653
654 bbbnames : list
655 List of bbbnd names as strings. Size must coincide with size of bbbpts. Otherwise an Exception is thrown.
656
657 flip_triangles : bool
658 If set tot True together with quads=False the quads are cut the other way round
659
660 Returns
661 -------
662 (ngsolve.mesh)
663 Returns generated NGSolve mesh
664
665 """
666 mesh = Mesh(dim=3)
667
668 if (bbbpts and bbbnames) and len(bbbpts) != len(bbbnames):
669 raise Exception("Lenght of bbbnames does not coincide with length of bbbpts!")
670
671 found = []
672 indbbbpts = []
673 if bbbpts:
674 for i in range(len(bbbpts)):
675 found.append(False)
676 indbbbpts.append(None)
677
678 pids = []
679 for i in range(ny+1):
680 for j in range(nx+1):
681 x,y,z = j/nx, i/ny, 0
682 pids.append(mesh.Add (MeshPoint(Pnt(x,y,z))))
683
684 mesh.Add(FaceDescriptor(surfnr=1,domin=1,bc=1))
685
686 for i in range(ny):
687 for j in range(nx):

Callers 1

test_fespaces_surfaceFunction · 0.90

Calls 4

MeshPointClass · 0.85
AddMethod · 0.80
PointsMethod · 0.80
absFunction · 0.50

Tested by 1

test_fespaces_surfaceFunction · 0.72