This section presents functions dedicated to creation or manipulation of meshes to produce avatars (rigid or deformable). The mesh class allows to define a mesh object in the lightest way: nodes, connectivity and possibly the groups elements belongs to. In 3D only a volumic mesh can become a deformable or rigid avatar whereas a surfacic mesh can only be used to generate a rigid avatar. In 2D a mesh may define a deformable or a rigid avatar.

Hand made mesh

Again it is possible to define a mesh by hand using the class constructor and the basic methods as explained in Avatar definition section. But this solution is not usable to generate big meshes.

Basic example

m = mesh(dimension=2)
m.addNode( node(numpy.array([0.,0.]), number=1) )
m.addNode( node(numpy.array([1.,0.]), number=2) )
m.addNode( node(numpy.array([0.,1.]), number=3) )
m.addNode( node(numpy.array([1.,1.]), number=4) )
m.addBulk( element('Q4xxx', [1,2,4,3], physicalEntity='1quad') )

Available geometrical elements are:

  • 1D : Point, S2xxx, S3xxx,
  • 2D : Point, S2xxx, S3xxx, T3xxx, Q4xxx, T6xxx, Q8xxx, Q9xxx,
  • 3D : Point, S2xxx, S3xxx, T3xxx, Q4xxx, T6xxx, Q8xxx, Q9xxx, H8xxx, H20xx, TE4xx, TE10x, PRI6x, PRI15

Remember that rigid2d() and rigid3d() allow to define rigid element. It is equivalent to

element( type='Point', connectivity=[1], physicalEntity='1')

Built-in Generation

For the specific case of 2D rectangular mesh, the buildMesh2D() function can be used and for the case of 3D paralleloid mesh buildMeshH8() also.


Generating a simple rectangular mesh:

my_mesh = buildMesh2D('Q4', x0=0.025, y0=0.05, lx=0.10, ly=0.05, nb_elem_x=10, nb_elem_y=5)

Importing a mesh

The most efficient way to generate a mesh is to use a meshing software like gmsh . To this end the lecture() function allow to read a file with gmsh format. In this way any kind of mesh may be put in a mesh object.


mesh = lecture('block.msh',dim)

Mesh to avatar

Creating an avatar from a mesh is possible using:

  • deformable 2D/3D



    mesh_cube   = lecture('gmsh/cube_t4.msh', dim)
    cube=buildMeshedAvatar(mesh=mesh_cube, model=m3Dl, material=stone)
    cube.addContactors(group='102', shape='ASpxx', color='BLEUx')
    cube.imposeDrivenDof(group='105' , component=[1, 2, 3], dofty='vlocy')


    It exists various strategies for contactors:

    • 2D

      # candidates at nodes
      addContactors(group='xx', type='CSxxx', color='BLEUx')
      # candidates on edges
      addContactors(group='xx', type='CSxxx', color='BLEUx', weight=[0.25,0.75])
      # antagonist
      addContactors(group='yy', type='ASpxx', color='REDxx')
    • 3D

      # candidates at nodes
      # candidates on faces ( quadrature=0 - constant, quadrature=1  - linear, quadrature=2 - quadratic pressure)
      # antagoniste
      addContactors(group='yy', type='ASpxx', color='BLEUx')
  • rigid 2D


  • rigid 3D


    body_donut = volumicMeshToRigid3D(volumic_mesh=mesh_donut, model=mod, material=tdur, color='BLEUx')

For the rigid avatar, the mesh is used to define the boundary of the corresponding polygons/polyhedra.

The deformable avatars inherit the group of the original mesh, allowing to define the desired boundary conditions and to add the contactors on them.

Sometimes, it is wanted to explode the continuous mesh in a collection of avatars (if one wants to use cohezive zone model for example). The function allowing to obtain a container of avatars are:

Extracting a mesh from meshes

Eventually a mesh loaded from a file may contain several parts which correspond to different avatars. Using mesh.separateMeshes() it is possible to separate the meshes.


complete_mesh = lecture(name='gmsh/3_briques.msh', dim=dim)
entity2mesh=complete_mesh.separateMeshes(dim=dim, entity_type="geometricalEntity", keep_all_elements=False)
for volumic_mesh in entity2mesh.values():
   body = volumicMeshToRigid3D(volumic_mesh=volumic_mesh, model=mod, material=pdur, color='BLEUx')

The output when separting meshes is a dictionary.

By the way it is possible to directly separate a surfacic mesh in avatars using surfacicMeshesToRigid3D()

Managing groups

Groups are necessary to define model, material, contactors, boundary condition, etc.

When defining material and models with buildMeshedAvatar() one implicitely assumes that all the elements have the same group and usually uses default group all. However it is possible to define several material and model:

my_mesh = lecture('Mesh.msh', dim)
body = avatar(number=1, dimension=dim)
body.defineModel(model=modPorous, group = '11')
body.defineMaterial(material=matBiot, group = '11')
body.defineModel(model=modFluid, group = '12')
body.defineMaterial(material=matStokes, group = '12')

Applying boundary condition without group

predicates and so on

def p(x):
   return abs(x[0] - 0.0016) < 5.e-4

body.addGroupUsingPredicate(name='relax', predicate=p, super_group='12')
body.imposeDrivenDof(group='relax', component=1, dofty='vlocy')


other use of avatar.addContactors()