Skip to main content

gmsh - API for a great Finite Element Mesher

Project description

gmsh_api

simple package to use gmsh via the original gmsh_api (https://gitlab.onelab.info/gmsh/gmsh/blob/master/api/gmsh.py, https://gmsh.info/bin/Linux/gmsh-X.Y.Z-Linux64-sdk.tgz).

https://gmsh.info/bin/Linux/

Christophe Geuzaine is a hero.

Usage

# gmsh_api package with some useful classes 
import gmsh_api
# original gmsh-api from gmsh package
import gmsh_api.gmsh as gmsh

gmsh.initialize()

gmsh.option.setNumber("General.Terminal", 1)
gmsh.option.setNumber("Mesh.Algorithm", 5) # delquad
gmsh.option.setNumber("Mesh.RecombineAll", 1)

gmsh.model.add("square")
gmsh.model.geo.addPoint(0, 0, 0, 0.6, 1)
gmsh.model.geo.addPoint(1, 0, 0, 0.6, 2)
gmsh.model.geo.addPoint(1, 1, 0, 0.5, 3)
gmsh.model.geo.addPoint(0, 1, 0, 0.4, 4)
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(2, 3, 2)
gmsh.model.geo.addLine(3, 4, 3)

# try automatic assignement of tag
line4 = gmsh.model.geo.addLine(4, 1)
gmsh.model.geo.addCurveLoop([1, 2, 3, line4], 1)
gmsh.model.geo.addPlaneSurface([1], 6)
gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(2)
#gmsh.write("square.unv")

mesh = gmsh_api.Mesh.from_gmsh(gmsh)
print(mesh.nodes)
print(mesh.elements)

Store mesh properties with pandas dataframes!

mesh.nodes

      nid         x         y    z
 1      1  0         0           0
 2      2  1         0           0
 3      3  1         1           0
 4      4  0         1           0
 5      5  0.5       0           0
 6      6  1         0.522774    0
 7      7  0.728708  1           0
 8      8  0.472136  1           0
 9      9  0.229485  1           0
10     10  0         0.786636    0
11     11  0         0.55051     0
12     12  0         0.289194    0
13     13  0.267268  0.304987    0
14     14  0.703727  0.740444    0
15     15  0.387068  0.62141     0
16     16  0.637319  0.370788    0
17     17  0.189356  0.818467    0

mesh.elements

      pid    elid  type      n_nodes  nodes                 nidxs
 0      1      17  shell4          4  [9L, 17L, 15L, 8L]    [9L, 17L, 15L, 8L]
 1      1      18  shell4          4  [15L, 17L, 10L, 11L]  [15L, 17L, 10L, 11L]
 2      1      19  shell4          4  [10L, 17L, 9L, 4L]    [10L, 17L, 9L, 4L]
 3      1      20  shell4          4  [5L, 16L, 15L, 13L]   [5L, 16L, 15L, 13L]
 4      1      21  shell4          4  [6L, 14L, 15L, 16L]   [6L, 14L, 15L, 16L]
 5      1      22  shell4          4  [6L, 16L, 5L, 2L]     [6L, 16L, 5L, 2L]
 6      1      23  shell4          4  [15L, 14L, 7L, 8L]    [15L, 14L, 7L, 8L]
 7      1      24  shell4          4  [15L, 11L, 12L, 13L]  [15L, 11L, 12L, 13L]
 8      1      25  shell4          4  [5L, 13L, 12L, 1L]    [5L, 13L, 12L, 1L]
 9      1      26  shell4          4  [6L, 3L, 7L, 14L]     [6L, 3L, 7L, 14L]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmsh_api-4.13.1.tar.gz (34.2 MB view details)

Uploaded Source

File details

Details for the file gmsh_api-4.13.1.tar.gz.

File metadata

  • Download URL: gmsh_api-4.13.1.tar.gz
  • Upload date:
  • Size: 34.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for gmsh_api-4.13.1.tar.gz
Algorithm Hash digest
SHA256 95bb8b21c21d4b9dcb0c49b8dd8ae7eff3972a4cfa635e4fbb9a9214cc7de60f
MD5 133a5c64c0001c6b4f943a1fb524d332
BLAKE2b-256 89ed814c239157515473be8ada8cbbc90b53c12a60d283ef46bbbd7c3e1630f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page