CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [Gmsh] Prism model in GMSH (https://www.cfd-online.com/Forums/openfoam-meshing/126713-prism-model-gmsh.html)

djamel November 24, 2013 14:02

Prism model in GMSH
 
1 Attachment(s)
Hello everybody this is a 3D model in GMSH.
may be it helps you.

nhowlett June 4, 2023 20:08

Following on from djamel, below is code to create prisms of 1 element depth (for 2D simulations in OpenFoam, for example).


Code:

# Rectangular domain with boundary condition for a jet inlet. Rectangle is
# extruded 1 element deep (for compatibility with OpenFOAM), creating
# prisms.
#
# Successfully executed using Gmsh version 4.11.1
#
# prerequisites
import gmsh
import sys
gmsh.initialize()
gmsh.clear()

# modify
name = "mesh2dJetWithoutBall"
meshSize = 1
length = 350
height = 20

gmsh.model.add(name)

# create surface (bounding & mouth as separate entities)
gmsh.model.geo.addPoint(0,        -(height / 2),    0, meshSize, 1)
gmsh.model.geo.addPoint(length, -(height / 2),    0, meshSize, 2)
gmsh.model.geo.addPoint(length,  (height / 2),    0, meshSize, 3)
gmsh.model.geo.addPoint(0,      (height / 2),  0, meshSize, 4)
gmsh.model.geo.addPoint(0,                      1,  0, meshSize, 5)
gmsh.model.geo.addPoint(0,                      -1,    0, meshSize, 6)

gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(2, 3, 2)
gmsh.model.geo.addLine(3, 4, 3)
gmsh.model.geo.addLine(4, 5, 4)
gmsh.model.geo.addLine(5, 6, 5)
gmsh.model.geo.addLine(6, 1, 6)

gmsh.model.geo.addCurveLoop([1, 2, 3, 4, 5, 6], 1)
gmsh.model.geo.addPlaneSurface([1], 1)
gmsh.model.geo.synchronize()

# define slice (volume) geometry and mesh of slice dimension (depth)
dz = 1
dataExtrusion = gmsh.model.geo.extrude(
  [(2, 1)], 0, 0, dz, [0, 1], [0, 1.0], recombine = True)
gmsh.model.geo.synchronize()

# create BC's
gmsh.model.addPhysicalGroup(2, [33], name = "mouth")
gmsh.model.addPhysicalGroup(2, [17, 21, 25, 29, 37], name = "atmos")
gmsh.model.addPhysicalGroup(2, [1, 38], name = "slice")

# mesh then save
gmsh.model.mesh.generate(3)
gmsh.write(name + ".msh")

# view in GUI
gmsh.fltk.run()
gmsh.finalize()



All times are GMT -4. The time now is 19:03.