Fc simesh matplotlib package, User's Guide

fc_simesh_matplotlib package, User's

Guide ?

Fran?ois Cuvelier:

June 14, 2017

Abstract

fc_simesh The

Python package allows to use simplices meshes gener-

gmsh 2 3 ated from

(in dimension or ) or an hypercube triangulation (in any

fc_simesh_matplotlib dimension). The

Python package presented in

fc_simesh this report is an add-on to the

Python package. A particular

care was taken to the graphics representations of meshes and datas on

meshes by using matplotlib package.

Contents

fc_simesh_matplotlib plotmesh 1 Functions of the 1.1 function

package

2

.......................... 2

1.1.1 2D example . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.1.2 3D example . . . . . . . . . . . . . . . . . . . . . . . . . . 3

plot 1.1.3 3D surface example . . . . . . . . . . . . . . . . . . . . . . 4

1.2 function

............................ 5

1.2.1 2D example . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.2.2 3D example . . . . . . . . . . . . . . . . . . . . . . . . . . 7

plotiso 1.2.3 3D surface example . . . . . . . . . . . . . . . . . . . . . . 8

1.3 function

........................... 9

1.3.1 2D example . . . . . . . . . . . . . . . . . . . . . . . . . . 10

fc_hypermesh fc_oogmsh fc_tools ?Compiled with Python 3.6.0, packages

fc_simesh matplotlib fc_simesh_matplotlib dev,

-devand the plotting libraries

-dev,

-dev,

-

-2.0.0,

-

2.0.0

: Universit? Paris 13, Sorbonne Paris Cit?, LAGA, CNRS UMR 7539, 99 Avenue J-B Cl?-

ment, F-93430 Villetaneuse, France, cuvelier@math.univ-paris13.fr.

This work was partially supported by ANR Dedales.

1

quiver 1.3.2 function

. . . . . . . . . . . . . . . . . . . . . . . 10

1.3.3 2D example . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.3.4 3D example . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.3.5 3D surface example . . . . . . . . . . . . . . . . . . . . . . 13

1 Functions of the fc_simesh_matplotlib package

plotmesh 1.1 function TsiMheepshlotombejescht. function displays the mesh or parts of the mesh dened by an

Syntaxe

siplt.plotmesh(Th ,) siplt.plotmesh(Th,Key=Value , ...)

Description

siplt .plotmesh(Th,) displays all the Th.d-dimensional simplices elements.

siplt .plotmesh(Th,Key=Value, ...) species function options using one or more , Key Value pair arguments. Options of rst level are

, d : to specify the dimension of the simplices elements (default : ) Th.d , labels : to select the labels of the elements to display, , color : to specify the color of the displayed mesh elements. (default

: use one color by displayed mesh elements), , legend : add a legend to graph if True (default : ) False

The options of second level depend on the type of elementaries mesh elements to represent. One can use any option of the following functions according to the type of d-simplex to be represented.

? In dimension 3, , if d "" 3, Line3DCollection function is used , if d "" 2, Poly3DCollection function is used , if d "" 1, Line3DCollection function is used , if d "" 0, ax. scatter function is used

? In dimension 2, , if d "" 2, plt . triplot function is used, , if d "" 1, ax.plot function is used , if d "" 0, ax.plot function is used

? dimension 1, not yet implemented

2

1.1.1 2D example

The following example use the .geo le condenser11.geo which is in the directory geodir of the toolbox ....

m e s h f i l e=gmsh . b u i l d m e s h 2 d ( ' c o n d e n s e r 1 1 ' , 2 5 ) Th=s i M e s h ( m e s h f i l e ) plt . figure (1) s i p l t . p l o t m e s h ( Th , l e g e n d=T r u e ) set_axes_equal () plt . figure (2)

# , ' L i n e s t y l e ' , ' : ' ) s i p l t . p l o t m e s h (Th , l a b e l s = [ 1 0 , 2 0 ] , l e g e n d=True )

s i p l t . p l o t m e s h ( Th , l a b e l s = [ 2 , 4 , 6 , 8 ] , c o l o r = ' b l a c k ' ) plt . axis ( ' o f f ' ) ; set_axes_equal () plt . figure (3) s i p l t . p l o t m e s h ( Th , c o l o r = ' L i g h t G r a y ' ) s i p l t . p l o t m e s h ( Th , d =1 , l e g e n d=True , l i n e w i d t h =2) plt . axis ( ' o f f ' ) ; set_axes_equal () plt . figure (4) s i p l t . p l o t m e s h ( Th , c o l o r = ' L i g h t G r a y ' ) s i p l t . p l o t m e s h ( Th , d =1 , l e g e n d=True , l a b e l s = [ 1 , 3 , 5 , 7 , 2 0 , 1 0 1 , 1 0 2 , 1 0 3 , 1 0 4 ] ) plt . axis ( ' o f f ' ) ; set_axes_equal ()

Listing 1: 2D plot mesh

1.1.2 3D example

The following example use the .geo le cylinderkey.geo which is in the directory geodir of the toolbox. This le contains description of a 3D mesh with simplices of dimensions 1, 2 and 3.

3

m e s h f i l e=gmsh . b u i l d m e s h 3 d ( ' c y l i n d e r k e y ' , 1 5 ) Th=s i M e s h ( m e s h f i l e ) plt . figure (1) s i p l t . p l o t m e s h ( Th , l e g e n d=T r u e ) s i p l t . p l o t m e s h ( Th , d =1 , c o l o r = ' b l a c k ' , l i n e w i d t h =3) set_axes_equal () plt . figure (2) s i p l t . p l o t m e s h ( Th , d =2 , l e g e n d=T r u e ) plt . axis ( ' o f f ' ) , set_axes_equal () plt . figure (3) s i p l t . p l o t m e s h ( Th , d =2 , l a b e l s = [ 1 , 1 0 0 0 , 1 0 2 0 , 1 0 2 1 ] , c o l o r = ' L i g h t G r a y ' , a l p h a = 0 . 0 5 ) s i p l t . p l o t m e s h ( Th , d =2 , l a b e l s = [ 1 0 , 1 1 , 3 1 , 2 0 0 0 , 2 0 2 0 , 2 0 2 1 ] , l e g e n d=True , a l p h a =1) plt . axis ( ' o f f ' ) ; set_axes_equal ()

Listing 2: 3D plot mesh

1.1.3 3D surface example

The following example use the .geo le demisphere5.geo which is in the directory geodir of the toolbox. This le contains description of a 3D surface mesh with simplices of dimensions 1 and 2.

4

m e s h f i l e=gmsh . b u i l d m e s h 3 d s ( ' d e m i s p h e r e 5 ' , 2 0 ) Th=s i M e s h ( m e s h f i l e ) Th=s i M e s h ( m e s h f i l e ) plt . figure (1) s i p l t . p l o t m e s h ( Th , l e g e n d=T r u e ) plt . figure (2) s i p l t . p l o t m e s h ( Th , c o l o r = ' L i g h t G r a y ' , a l p h a = 0 . 1 ) s i p l t . p l o t m e s h ( Th , d =1 , l e g e n d=True , l i n e w i d t h =2) plt . figure (3) s i p l t . p l o t m e s h ( Th , l a b e l s = [ 1 , 1 0 , 1 3 , 1 2 ] , f a c e c o l o r =None ) s i p l t . p l o t m e s h ( Th , l a b e l s = [ 1 1 ] , e d g e c o l o r= ' b l a c k ' ) plt . figure (4) s i p l t . p l o t m e s h ( Th , l e g e n d=True , l a b e l s = [ 1 0 , 1 3 , 1 2 ] , e d g e c o l o r= ' b l a c k ' ) s i p l t . p l o t m e s h ( Th , l a b e l s = [ 1 , 1 1 ] , c o l o r = ' L i g h t G r a y ' , a l p h a = 0 . 1 )

Listing 3: 3D surface mesh : plot function

plot 1.2 function

plot The

function displays scalar datas on the mesh or parts of the mesh

siMesh dened by an

object.

Syntaxe

siplt.plot(Th ,u) siplt.plot(Th ,u,Key=Value , ...)

Description

siplt . plot(Th,u) displays data u on all the Th.d-dimensional simplices elements. The data u is an 1D-array of size Th.nq or Th.nqGlobal or . Th.nqParent

siplt . plot(Th,u,Key=Value, ...) species function options using one or more , Key Value pair arguments. Options of rst level are

5

, d : to specify the dimension of the simplices elements (default : ) Th.d , labels : to select the labels of the elements to display data, , plane : if , True (default : ) False The second level options depend on the type of elementaries mesh elements on which we want to represent datas. One can use any option of the following functions according to the type of d-simplex. ? In dimension 3,

, if d "" 3, scatter3D function is used , if d "" 2, Poly3DCollection function is used. , if d "" 1, Line3DCollection function is used. ? In dimension 2, , if d "" 2, tripcolor function is used. , if d "" 1, LineCollection function is used. ? Dimension 1 : not implemented.

1.2.1 2D example

The following example use the .geo le condenser11.geo which is in the directory geodir of the package.

6

import numpy as np

m e s h f i l e=gmsh . b u i l d m e s h 2 d ( ' c o n d e n s e r 1 1 ' , 2 5 )

lambda Th=s i M e s h ( m e s h f i l e )

u=Th . f e v a l (

? x , y : 5 np . e x p ( 3 ( x 2+y 2 ) ) np . c o s ( x ) np . s i n ( y ) )

p l t . rcParams [ ' t e x t . u s e t e x ' ]= True

p l t . rcParams [ ' t e x t . l a t e x . u n i c o d e ' ]= True

plt . ion ()

f i g=p l t . f i g u r e ( 1 )

s i p l t . p l o t ( Th , u )

plt . colorbar ()

plt . figure (2)

s i p l t . p l o t ( Th , u , l a b e l s = [ 2 0 , 2 , 4 , 6 , 8 ] )

s i p l t . p l o t m e s h ( Th , l a b e l s = 1 0 , c o l o r = ' L i g h t G r a y ' )

plt . figure (3)

h= s i p l t . p l o t ( Th , u , p l a n e=F a l s e , c o l o r m a p= ' v i r i d i s ' )

plt . colorbar (h)

plt . figure (4)

s i p l t . p l o t ( Th , u , l a b e l s = [ 1 0 , 2 0 ] , p l a n e=F a l s e , c o l o r m a p= ' v i r i d i s ' )

s i p l t . p l o t ( Th , u , l a b e l s = [ 2 , 4 , 6 , 8 ] , p l a n e=F a l s e )

p l t . show ( )

Listing 4: 2D mesh : plot function

1.2.2 3D example

The following example use the .geo le cylinderkey.geo which is in the directory geodir of the toolbox. This le contains description of a 3D mesh with simplices of dimensions 1, 2 and 3.

7

m e s h f i l e=gmsh . b u i l d m e s h 3 d ( ' c y l i n d e r k e y ' , 1 5 )

Th=s i M e s h ( m e s h f i l e ) plt . close ( ' all ' )

plt . ion ()

p l t . rcParams [ ' t e x t . u s e t e x ' ]= True

p l t . rcParams [ ' t e x t . l a t e x . u n i c o d e ' ]= True

lambda p l t . c l o s e ( ' a l l ' )

u=Th . f e v a l (

x , y , z : 3 x2?y3+ z 2+xy )

#ax = f i g=p l tf i.gf i.ggucar e( ( 1p)r o j e c t i o n ='3d ')

h= s i p l t . p l o t ( Th , u , s =2)

plt . colorbar (h)

plt . figure (2)

h2= s i p l t . p l o t ( Th , u , d =2 , l a b e l s = [ 1 0 0 0 , 1 0 2 0 , 1 0 2 1 , 2 0 0 0 , 2 0 2 0 , 2 0 2 1 ] ) s i p l t . p l o t ( Th , u , d =2 , l a b e l s = [ 1 0 , 1 1 , 3 1 ] , e d g e c o l o r= ' b l a c k ' , l i n e w i d t h = 0 . 5 )

p l t . c o l o r b a r ( h2 )

plt . figure (3)

h2= s i p l t . p l o t ( Th , u , d =2 , l a b e l s = [ 2 0 0 0 , 2 0 2 0 , 2 0 2 1 ] )

h1= s i p l t . p l o t ( Th , u , d =1 , l a b e l s = [ 1 0 7 5 , 1 0 7 7 , 1 0 7 8 , 1 0 8 1 ] , l i n e w i d t h =3)

s i p l t . p l o t m e s h ( Th , d =2 , l a b e l s = [ 1 0 , 1 1 , 3 1 ] , c o l o r = ' L i g h t G r a y ' , a l p h a = 0 . 2 ) pl t . gca () . set_axis_off ()

p l t . c o l o r b a r ( h1 )

plt . figure (4)

s i p l t . p l o t ( Th , u , d =2 , l a b e l s = [ 1 ] , a l p h a = 0 . 1 )

s i p l t . p l o t ( Th , u , d =2 , l a b e l s = [ 2 0 0 0 , 2 0 2 0 , 2 0 2 1 ] ) s i p l t . p l o t ( Th , u , d =1 , l a b e l s = [ 1 0 7 5 , 1 0 7 7 , 1 0 7 8 , 1 0 8 1 ] , l i n e w i d t h =3)

s i p l t . p l o t m e s h ( Th , d =2 , l a b e l s = [ 1 0 , 1 1 , 3 1 ] , c o l o r = ' L i g h t G r a y ' , a l p h a = 0 . 2 )

s i p l t . p l o t m e s h ( Th , d =1 , l a b e l s = [ 1 0 8 0 , 1 0 7 9 ] , c o l o r = ' b l a c k ' , l i n e w i d t h =2)

pl t . gca () . set_axis_off ()

Listing 5: 3D mesh : plot function

1.2.3 3D surface example

The following example use the .geo le demisphere5.geo which is in the directory geodir of the toolbox. This le contains description of a 3D surface mesh with simplices of dimensions 1 and 2.

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download