mesh.txt 5.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

.. py:currentmodule:: pylmgc90.pre_lmgc

Mesh
====

This section presents functions dedicated to creation
or manipulation of meshes to produce avatars (rigid or deformable). 
The :py:class:`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.

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

Hand made mesh
--------------

Basic example ::

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

mozul's avatar
mozul committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Available elements are: 

 * 'Rxx2D','Rxx3D',
 * 'SPRG2','SPRG3','Beam','Cable','S2xth',
 * 'Q4xxx','Q4P0x','Q44xx',
 * 'T3xxx','DKTxx','T33xx',
 * 'Q8xxx','Q8Rxx','Q84xx',
 * 'Q9xxx',
 * 'T6xxx','T63xx',
 * 'TE4xx','TE4lx','TE44x',
 * 'TE10x','TE104',
 * 'H8xxx','H88xx','SHB8x',
 * 'H20xx','H20Rx','H208x','SHB20',
 * 'PRI6x','SHB6x',
 * 'PRI15','SHB15'
  
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

Remember that rigid2D() and rigid3d() allow to define *rigid* element.

Built-in Generation
-------------------

For the specific case of 2D rectangular mesh, the :py:func:`buildMesh2D` function can
be used and for the case of 3D paralleloid mesh :py:func:`buildMeshH8`
also.

**Example:**

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 <http://www.geuz.org/gmsh/>`_ . To this end the :py:func:`lecture`
function allow to read a file with gmsh format. In this way any kind of mesh
may be put in a mesh object. 

**Example:** ::

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

Mesh to avatar
--------------

Creating an avatar from a mesh is possible using:

* deformable 2D/3D

  :py:func:`buildMeshedAvatar`

  **Example:** ::

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

* rigid 2D

  :py:func:`rigidFromMesh2D`

* rigid 3D

  * :py:func:`volumicMeshToRigid3D`
  * :py:func:`surfacicMeshToRigid3D`

  **Example:** ::

     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:

* :py:func:`explodeMeshedAvatar2D`
* :py:func:`rigidsFromMesh2D`


Extracting a mesh from meshes
-----------------------------

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

**Example:** ::

   dim=3
   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')
      bodies.addAvatar(body)

The output when separting meshes is a dictionary. 

By the way it is possible to directly separate a surfacic mesh in
avatars using  :py:func:`surfacicMeshesToRigid3D`

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

When defining material and models with :py:func:`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)
  my_mesh.rankRenumbering()
  body = avatar(number=1, type='MAILx', dimension=dim)
  body.addBulks(my_mesh.bulks)
  body.addNodes(my_mesh.nodes)
  body.defineGroups()
  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')

Miscellaneous
-------------

other use of :py:func:`avatar.addContactors` ::

  outil.addContactors(group='11',type='ALpxx',color='BLUEx',reverse='yes')