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-hypermesh_400.png

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

Introduction:

sysfs line plot

This implements Vectorized algorithms for regular and conforming tessellations of d-orthotopes and their faces with high-order orthotopes or simplicial elements, Cuvelier F., 2019

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

Installation:

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

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='simplex',box=[[-1,1],[0,1]])
    print(oTh)

    The output of the print(oTh) command is:

    OrthMesh object
            d : 2
        order : 1
          box : [[-1.0, 1.0], [0.0, 1.0]]
      mapping : None
    Mesh (order,type,nq,nme) : (1,simplex,78,120)
    Number of 1-faces : 4
      [ 0] (order,type,nq,nme) : (1,simplex,6,5)
      [ 1] (order,type,nq,nme) : (1,simplex,6,5)
      [ 2] (order,type,nq,nme) : (1,simplex,13,12)
      [ 3] (order,type,nq,nme) : (1,simplex,13,12)
    Number of 0-faces : 4
      [ 0] (order,type,nq,nme) : (1,simplex,1,1)
      [ 1] (order,type,nq,nme) : (1,simplex,1,1)
      [ 2] (order,type,nq,nme) : (1,simplex,1,1)
      [ 3] (order,type,nq,nme) : (1,simplex,1,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)
    plt.figure(2)
    oTh.plotmesh(m=1,legend=True,linewidth=3)
    plt.axis('off')
    set_axes_equal()

    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 eight demos functions in the fc_hypermesh.demos module named demo01 to demo08. The source code is in module demos.py. For example, run the following code under Python:

import fc_hypermesh
fc_hypermesh.demos.demo01()

Benchmarking:

  • Bench of the OrthMesh constructor for a 3-dimensional orthotope tessellated with (order 1) simplices.

    import fc_hypermesh
    fc_hypermesh.bench(3,range(20,170,20),type='simplex',box=[[-1,1],[-1,1],[-1,1]])

    The output of this code is:

    #---------------------------------------------------------------------------
    #    computer: zbook17
    #      system: Ubuntu 18.04.3 LTS (x86_64)
    #   processor: Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
    #              (1 procs/4 cores by proc/2 threads by core)
    #         RAM: 31.3 Go
    #    software: Python
    #     release: 3.7.6
    #---------------------------------------------------------------------------
    # fc_hypermesh.OrthMesh constructor with
    #   d      =3
    #   type   =simplex
    #   order  =1
    #   box    =[[-1, 1], [-1, 1], [-1, 1]]
    #   mapping=None
    #---------------------------------------------------------------------------
    #date:2019-12-29_14-13-35
    #nbruns:5
    #numpy:      i8        i8        i8            f8
    #format: {:>7d}   {:>10d}   {:>10d}      {:11.3f}
    #labels:      N        nq       nme   OrthMesh(s)
                 20      9261     48000         0.196
                 40     68921    384000         0.209
                 60    226981   1296000         0.302
                 80    531441   3072000         0.411
                100   1030301   6000000         0.576
                120   1771561  10368000         0.840
                140   2803221  16464000         1.197
                160   4173281  24576000         1.679
  • Bench of the OrthMesh constructor for a 3-dimensional orthotope tessellated with 3-order simplices.

    import fc_hypermesh
    fc_hypermesh.bench(3,range(10,61,10),order=3,type='simplex',box=[[-1,1],[-1,1],[-1,1]])

    The output of this code is:

    #---------------------------------------------------------------------------
    #    computer: zbook17
    #      system: Ubuntu 18.04.3 LTS (x86_64)
    #   processor: Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
    #              (1 procs/4 cores by proc/2 threads by core)
    #         RAM: 31.3 Go
    #    software: Python
    #     release: 3.7.6
    #---------------------------------------------------------------------------
    # fc_hypermesh.OrthMesh constructor with
    #   d      =3
    #   type   =simplex
    #   order  =3
    #   box    =[[-1, 1], [-1, 1], [-1, 1]]
    #   mapping=None
    #---------------------------------------------------------------------------
    #date:2019-12-29_14-26-34
    #nbruns:5
    #numpy:      i8        i8        i8            f8
    #format: {:>7d}   {:>10d}   {:>10d}      {:11.3f}
    #labels:      N        nq       nme   OrthMesh(s)
                 10     29791      6000         0.143
                 20    226981     48000         0.222
                 30    753571    162000         0.269
                 40   1771561    384000         0.357
                 50   3442951    750000         0.500
                 60   5929741   1296000         0.733
  • Bench of the OrthMesh constructor for a 5-dimensional orthotope tessellated with (order 1) orthotopes.

    import fc_hypermesh
    fc_hypermesh.bench(5,[5,10,15,20,25,27],type='orthotope',box=[[-1,1],[-1,1],[-1,1],[-1,1],[-1,1]])

    The output of this code is:

    #---------------------------------------------------------------------------
    #    computer: zbook17
    #      system: Ubuntu 18.04.3 LTS (x86_64)
    #   processor: Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
    #              (1 procs/4 cores by proc/2 threads by core)
    #         RAM: 31.3 Go
    #    software: Python
    #     release: 3.7.6
    #---------------------------------------------------------------------------
    # fc_hypermesh.OrthMesh constructor with
    #   d      =5
    #   type   =orthotope
    #   order  =1
    #   box    =[[-1, 1], [-1, 1], [-1, 1], [-1, 1], [-1, 1]]
    #   mapping=None
    #---------------------------------------------------------------------------
    #date:2019-12-29_14-18-30
    #nbruns:5
    #numpy:      i8        i8        i8            f8
    #format: {:>7d}   {:>10d}   {:>10d}      {:11.3f}
    #labels:      N        nq       nme   OrthMesh(s)
                  5      7776      3125         0.427
                 10    161051    100000         0.529
                 15   1048576    759375         0.844
                 20   4084101   3200000         1.789
                 25  11881376   9765625         4.296
                 27  17210368  14348907         5.958

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_hypermesh-0.1.1.tar.gz (20.8 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