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).

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.0.tar.gz (30.1 MB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: gmsh_api-4.13.0.tar.gz
  • Upload date:
  • Size: 30.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for gmsh_api-4.13.0.tar.gz
Algorithm Hash digest
SHA256 4fb3439ac67a912348dfe342826820e0b9525c16a43f619cadb05dd8990669c4
MD5 ae2253dbccc730f0166a5e8de31559de
BLAKE2b-256 e5fb8f6a7514f7b948d52a3a9419202b5492bfd7fd4acca374aa407b7235188c

See more details on using hashes here.

Supported by

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