Skip to main content

Generate conforming meshes of hypercubes, hyperrectangles or of any d-orthotopes by simplices or orthotopes with their m-faces

Project description

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

The fc_hypermesh Python package allows to generate conforming meshes of hypercubes, hyperrectangles or of any d-orthotopes by simplices or orthotopes with their m-faces

Introduction:

sysfs line plot

This implements Vectorized algorithms for regular tessellations of d-orthotopes and theirfaces, Cuvelier F. and Scarella G., 2017

More documentation is available on fc_hypermesh Python package dedicated web page.

This package was tested under:

Installation:

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

pip install fc_hypermesh -U

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

import fc_hypermesh
fc_hypermesh.demos.demo01()

Examples usage:

  • Meshing the rectangle [-1,1]x[0,1] by simplices with 12+1 points in x-axis and 5+1 points in y-axis:

    from fc_hypermesh import OrthMesh
    oTh=OrthMesh(2,[12,5],type='simplicial',box=[[-1,1],[0,1]])
    print(oTh)
    

    The output of the print(oTh) command is:

    OrthMesh object
          d : 2
      Mesh  :  EltMesh object
        type (str): simplicial
        type : 0
          d : 2
          m : 2
          q : (2,78)
          me : (3,120)
    
    Number of 1-faces : 4
      [ 0] (type,nq,nme) : (simplicial,6,5)
      [ 1] (type,nq,nme) : (simplicial,6,5)
      [ 2] (type,nq,nme) : (simplicial,13,12)
      [ 3] (type,nq,nme) : (simplicial,13,12)
    Number of 0-faces : 4
      [ 0] (type,nq,nme) : (simplicial,1,1)
      [ 1] (type,nq,nme) : (simplicial,1,1)
      [ 2] (type,nq,nme) : (simplicial,1,1)
      [ 3] (type,nq,nme) : (simplicial,1,1)
    

    If matplotlib package is installed one can represent the mesh

    import matplotlib.pyplot as plt
    plt.ion()
    plt.figure(1)
    oTh.plotmesh(legend=True)
    plt.figure(2)
    oTh.plotmesh(m=1,legend=True,linewidth=3)
    plt.axis('off')
    
    OrthMesh_2D_simplicial_fig1 OrthMesh_2D_simplicial_fig2
  • Meshing the rectangular cuboid [-1,1]x[0,1]x[0,2] by simplices with 11+1 points in x-axis, 5+1 points in y-axis and 10+1 points in z-axis:

    from fc_hypermesh import OrthMesh
    oTh=OrthMesh(3,[10,5,10],box=[[-1,1],[0,1],[0,2]])
    

    If matplotlib package is installed one can represent the mesh

    from fc_tools.graphics import set_axes_equal
    import matplotlib.pyplot as plt
    plt.ion()
    plt.figure(1)
    oTh.plotmesh(legend=True,linewidth=0.5)
    set_axes_equal()
    plt.figure(2)
    oTh.plotmesh(m=2,legend=True,edgecolor=[0,0,0])
    plt.axis('off')
    set_axes_equal()
    
    OrthMesh_3D_simplicial_fig1 OrthMesh_3D_simplicial_fig2
  • Meshing the rectangle [-1,1]x[0,1] by orthotopes with 12+1 points in x-axis, 5+1 points in y-axis and 10+1 points in z-axis:

    from fc_hypermesh import OrthMesh
    oTh=OrthMesh(2,[12,5],type='orthotope',box=[[-1,1],[0,1]])
    

    If matplotlib package is installed one can represent the mesh

    from fc_tools.graphics import set_axes_equal
    import matplotlib.pyplot as plt
    plt.ion()
    plt.figure(1)
    oTh.plotmesh(legend=True)
    set_axes_equal()
    plt.figure(2)
    oTh.plotmesh(m=1,legend=True,linewidth=3)
    plt.axis('off')
    set_axes_equal()
    
    OrthMesh_2D_orthotope_fig1 OrthMesh_2D_orthotope_fig2
  • Meshing the rectangular cuboid [-1,1]x[0,1]x[0,2] by orthotopes with 11+1 points in x-axis, 5+1 points in y-axis and 10+1 points in z-axis:

    from fc_hypermesh import OrthMesh
    oTh=OrthMesh(3,[10,5,10],type='orthotope', box=[[-1,1],[0,1],[0,2]])
    

    If matplotlib package is installed one can represent the mesh

    from fc_tools.graphics import set_axes_equal
    import matplotlib.pyplot as plt
    plt.ion()
    plt.figure(1)
    oTh.plotmesh(legend=True,linewidth=0.5)
    set_axes_equal()
    plt.figure(2)
    oTh.plotmesh(m=2,legend=True,edgecolor=[0,0,0])
    plt.axis('off')
    set_axes_equal()
    
    OrthMesh_3D_orthotope_fig1 OrthMesh_3D_orthotope_fig2

Testing :

There are seven demos functions in the fc_hypermesh package named demo01 to demo07. The source code is in module demos.py. For example, run the following code under Python:

import fc_hypermesh
fc_hypermesh.demo01()

Benchmarking:

import fc_hypermesh
fc_hypermesh.bench_gen(3,'simplicial',[[-1,1],[-1,1],[-1,1]],range(20,170,20))

The output of this code is:

# BENCH in dimension 3 with simplicial mesh
#d: 3
#type: simplicial
#box: [[-1, 1], [-1, 1], [-1, 1]]
#desc:  N        nq       nme    time(s)
      20      9261     48000     0.214
      40     68921    384000     0.211
      60    226981   1296000     0.274
      80    531441   3072000     0.363
      100   1030301   6000000     0.492
      120   1771561  10368000     0.679
      140   2803221  16464000     0.951
      160   4173281  24576000     1.323
import fc_hypermesh
fc_hypermesh.bench_gen(5,'orthotope',[[-1,1],[-1,1],[-1,1],[-1,1],[-1,1]],[5,10,15,20,25,27])

The output of this code is:

# BENCH in dimension 5 with orthotope mesh
#d: 5
#type: orthotope
#box: [[-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1]]
#desc:  N        nq       nme    time(s)
        5      7776      3125     0.468
      10    161051    100000     0.512
      15   1048576    759375     0.738
      20   4084101   3200000     1.223
      25  11881376   9765625     2.542
      27  17210368  14348907     3.350

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
fc_hypermesh-0.0.12.tar.gz (15.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page