Skip to main content

Generate and read mesh files by using gmsh and given .geo files

Project description

http://www.math.univ-paris13.fr/~cuvelier/software/codes/Python/fc-oogmsh/pyfc-oogmsh_400.png

The fc_oogmsh Python package make it possible to generate mesh files from .geo file by using gmsh which must be installed. It’s also possible with the ooGmsh2 or ooGmsh4 class to read the mesh file and to store its contains in more user-friendly form. This package must be regarded as a very simple interface between gmsh files and Python. So you are free to create any objects you want from an ooGmsh2 or ooGmsh4 object. The ooGmsh2 is used to read MSH files stored with format version ‘2.2’ and the ooGmsh4 class is used for formats version ‘4.0’ and ‘4.1’

Package test on

System

Python

gmsh

CentOS 7.6

2,7.16, 3.5.7, 3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

Debian 9.9

2,7.16, 3.5.7, 3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

Fedora 29

2,7.16, 3.5.7, 3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

OpenSuse 15.0

3.5.7, 3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

Ubuntu 18.04

2,7.16, 3.5.7, 3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

Windows 10 (1809)

3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

MacOS Mojave (10.14.4)

3.5.4, 3.6.8, 3.7.3 (python)

4.3.0, 4.2.3, 4.1.5, 4.0.7, 3.0.6

Documentation is available on fc-oogmsh dedicated web page.

Installation:

The fc_oogmsh Python package is available from the Python Package Index, so to install/upgrade simply type

pip install fc_oogmsh -U

Configuration:

One have to configure the package for using with gmsh. For the default configuration we run under Python:

import fc_oogmsh
fc_oogmsh.configure()

The function fc_oogmsh.configure() try to guess where is the gmsh binary. If this command failed or if we want to specify the gmsh binary location, one can use the gmsh option to specify the gmsh binary file with full path.

  • For example, under Linux:

    import fc_oogmsh
    fc_oogmsh.configure(gmsh='/usr/local/GMSH/gmsh-4.2.0-Linux/bin/gmsh')
  • For example, under Windows:

    import fc_oogmsh
    fc_oogmsh.configure(gmsh=r'C:\Users\toto\GMSH\gmsh-4.2.0-Windows\gmsh.exe')
  • For example, under MacOS:

    import fc_oogmsh
    fc_oogmsh.configure(gmsh='/Users/toto/GMSH/4.2.0/Gmsh.app/Contents/MacOS/gmsh')

Now, it’s possible to run one of the demo functions

import fc_oogmsh
fc_oogmsh.demo02()

The output of the demo02() function under Linux is:

***********************
Running demo02 function
***********************
*** Build mesh file
[fc_oogmsh] Using input file: /home/cuvelier/Travail/Recherch/python/fc-oogmsh/src/fc_oogmsh/geodir/2d/condenser11.geo
[fc_oogmsh] Overwritting mesh file /home/cuvelier/.local/share/fc_oogmsh/meshes/condenser11-25.msh
[fc_oogmsh] Use option verbose=3 to see gmsh output
*** Read mesh file
*** Print oGh ->
ooGmsh4 object
    dim : 2
      d : 2
  types : [1 2]
    nq : 3483
      q : ndarray object[float64], size (2, 3483)
toGlobal: ndarray object[int32], size (3483,)
Entities:<class 'fc_oogmsh.msh.Entities'>
Nodes   :<class 'fc_oogmsh.msh.Nodes'>
Elements:<class 'fc_oogmsh.msh.Elements'>

Examples usage:

  • We use the geometry file condenser11.geo given with the package to generate a 2D mesh file

    meshfile=fc_oogmsh.buildmesh2d('condenser11',25,force=True)

    The output of this command is:

    fc_oogmsh] Using input file: /home/cuvelier/Travail/Recherch/python/fc-oogmsh/src/fc_oogmsh/geodir/2d/condenser11.geo
    [fc_oogmsh] Overwritting mesh file /home/cuvelier/.local/share/fc_oogmsh/meshes/condenser11-25.msh
    [fc_oogmsh] Use option verbose=3 to see gmsh output

    Thereafter one can read the mesh file by using the ooGmsh4 object constructor and print some informations

    oGh=fc_oogmsh.ooGmsh4(meshfile)
    print('*** Print oGh ->')
    print(oGh)

    The output of these commands are:

    *** Print oGh ->
    ooGmsh4 object
        dim : 2
          d : 2
      types : [1 2]
        nq : 3483
          q : ndarray object[float64], size (2, 3483)
    toGlobal: ndarray object[int32], size (3483,)
    Entities:<class 'fc_oogmsh.msh.Entities'>
    Nodes   :<class 'fc_oogmsh.msh.Nodes'>
    Elements:<class 'fc_oogmsh.msh.Elements'>

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

fc_oogmsh-0.1.0.tar.gz (28.9 kB view hashes)

Uploaded Source

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