.. _gmsh: http://gmsh.info
.. _fc-oogmsh: http://www.math.univ-paris13.fr/~cuvelier/software/fc-oogmsh-Python.html
.. _www.python.org: http://www.python.org/
.. _python: http://www.python.org/
.. _Anaconda: https://www.anaconda.com
.. _Miniconda: https://conda.io/miniconda.html
.. _Canopy: https://www.enthought.com/product/canopy/
.. image:: http://www.math.univ-paris13.fr/~cuvelier/software/codes/Python/fc-oogmsh/pyfc-oogmsh_400.png
:width: 200px
:align: left
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'
.. csv-table:: Package test on
:header: "System", "Python", `gmsh`_
:widths: 12, 12, 12
**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
.. code::
pip install fc_oogmsh -U
Configuration:
--------------
One have to configure the package for using with `gmsh`_.
For the default configuration we run under Python:
.. code:: 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:
.. code:: python
import fc_oogmsh
fc_oogmsh.configure(gmsh='/usr/local/GMSH/gmsh-4.2.0-Linux/bin/gmsh')
- For example, under Windows:
.. code:: python
import fc_oogmsh
fc_oogmsh.configure(gmsh=r'C:\Users\toto\GMSH\gmsh-4.2.0-Windows\gmsh.exe')
- For example, under MacOS:
.. code:: python
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
.. code:: python
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
.. code:: python
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
.. code:: python
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'>