Salome HOME
updated copyright message
[modules/homard.git] / doc / en / tutorials.rst
1 Examples
2 ########
3 .. index:: single: example
4 .. index:: single: python
5
6 One will find here the instructions python for some characteristic configurations. The associated data files are downloadable. It is necessary to think of adapting the value of the variable ``data_dir``: it is the directory in which the files med will have been recorded.
7 It is in the directory ``dircase`` that the files will be written resulting from the successive adaptations. This directory is created by default in ``/tmp``.
8
9 Loading of the module HOMARD
10 ****************************
11 .. index:: single: YACS
12
13 The loading of the module HOMARD is done in a way similar to the other modules.
14
15  ::
16
17   import HOMARD
18   homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')
19   homard.UpdateStudy()
20
21 To use the module HOMARD within a distributed scheme YACS, the loading is made as follows:
22
23  ::
24
25   import HOMARD
26   my_container.load_component_Library('HOMARD')
27   homard = my_container.create_component_instance('HOMARD',0)
28   homard.UpdateStudy()
29
30 Uniform refinement
31 ******************
32 .. index:: single: refinement;uniform
33
34 One will make here three successive uniform refinements of the mesh contained in the file ``tutorial_1.00.med``. Some notes:
35   * the same hypothesis is used with each iteration
36   * the produced mesh always bears the same name. That does not pose a problem because it is stored in different files.
37
38
39 .. literalinclude:: ../files/tutorial_1.py
40    :language: python
41    :start-after: Début des commandes
42    :end-before: Fin des commandes
43
44 .. note::
45   Download the files
46
47   * :download:`initial mesh<../files/tutorial_1.00.med>`
48   * :download:`python script<../files/tutorial_1.py>`
49   * :download:`python script for the creation of the test directory<../files/tutorial_util.py>`
50
51
52
53 Refinement by zones
54 *******************
55 .. index:: single: zone
56
57 One proceeds here to refinement according to zones. To pass from the initial mesh to the mesh 'M_1', one uses a box framing the z=1 plane and a sphere centered on the origin with radius 1.05. Then to pass from the mesh 'M_1' to the mesh 'M_2', one replaces the sphere by a box framing the cube on side 0.5, pointing on the origin and the meshes in the very first zone are unrefined.
58
59 .. literalinclude:: ../files/tutorial_2.py
60    :language: python
61    :start-after: Début des commandes
62    :end-before: Fin des commandes
63
64 .. note::
65   Download the files
66
67   * :download:`initial mesh<../files/tutorial_2.00.med>`
68   * :download:`python script<../files/tutorial_2.py>`
69   * :download:`python script for the creation of the test directory<../files/tutorial_util.py>`
70
71
72 Refinement driven by a field
73 ****************************
74 .. index:: single: field
75
76 One proceeds here to refinement according to a field. The hypotheses are used to define the name of the field and the thresholds of refinement/unrefinement. The input of the file and the instants is made in the iteration. Fields on the nodes or the elements are interpolated.
77 To adapt the H_1 mesh resulting from the Iter_1 iteration, two alternatives are applied. In the first, Iter_2, the field is a scalar field of indicators of error and one cuts out the 1.5% of elements where the error is largest. In the second alternative, Iter_2_bis, one is based on a vector field and one examines the jump of this vector between an element and its neighbors: one will cut out where the infinite standard of this jump is higher than the absolute threshold of 0.0001.
78
79 .. literalinclude:: ../files/tutorial_3.py
80    :language: python
81    :start-after: Début des commandes
82    :end-before: Fin des commandes
83
84 .. note::
85   Download the files
86
87   * :download:`mesh and field stage 0<../files/tutorial_3.00.med>`
88   * :download:`mesh and field stage 1<../files/tutorial_3.01.med>`
89   * :download:`python script<../files/tutorial_3.py>`
90   * :download:`python script for the creation of the test directory<../files/tutorial_util.py>`
91
92
93 Non plane boundaries
94 ********************
95 .. index:: single: boundary
96 .. index:: single: CAO
97 .. index:: single: YACS
98
99 One tests the follow-up of the curved borders here, giving the representation of the domain by its CAO. That CAO is given in a XAO format file.
100 The driving of refinement is the following: uniform refinement of all the elements contained in indicated groups. One starts by refining the inner faces with the pipes; then, one refines continuation twice the external faces with the pipes.
101 Scheme YACS carrying out this adaptation is downloadable.
102
103 .. literalinclude:: ../files/tutorial_4.py
104    :language: python
105    :start-after: Début des commandes
106    :end-before: Fin des commandes
107
108 .. note::
109   Téléchargement des fichiers
110
111   * :download:`initial mesh<../files/tutorial_4.00.med>`
112   * :download:`CAO<../files/tutorial_4.xao>`
113   * :download:`python scrip<../files/tutorial_4.py>`
114   * :download:`python script for the creation of the test directory<../files/tutorial_util.py>`
115   * :download:`YACS scheme<../files/tutorial_4.xml>`
116
117 If the CAO is not available, the boundaries can be approximated: analytical borders to describe various surfaces of the pipes and a discrete border to describe the intersecting lines of the two pipes. Only the definition of the boundaries has to be modified.
118
119 .. literalinclude:: ../files/tutorial_6.py
120    :start-after: Début des commandes
121    :end-before: Fin des commandes
122
123 .. note::
124   Download the files
125
126   * :download:`initial mesh<../files/tutorial_4.00.med>`
127   * :download:`mesh of the discrete boundary<../files/tutorial_6.fr.med>`
128   * :download:`python script<../files/tutorial_6.py>`
129   * :download:`python script for the creation of the test directory<../files/tutorial_util.py>`
130   * :download:`YACS scheme<../files/tutorial_6.xml>`
131
132
133 Specific instructions for a 2D mesh
134 ***********************************
135 .. index:: single: 2D
136
137 The instructions to adapt a 2D mesh are exactly identical to those necessary to the adaptation of a 3D mesh. The only exception relates to refinement according to geometrical zones: different functions are used to be able to define 2D zones. One gives the 2D coordinates zones, by specifying the orientation of the plane of the mesh.
138 In the case presented here, one for the first time refines all the elements contained in a bored disk, then in one second iteration, all the elements contained in a rectangle. One will note the use of the follow-up of the circular borders of the field.
139
140 .. literalinclude:: ../files/tutorial_5.py
141    :language: python
142    :start-after: Début des commandes
143    :end-before: Fin des commandes
144
145 .. note::
146   Download the files
147
148   * :download:`initial mesh<../files/tutorial_5.00.med>`
149   * :download:`mesh of the discrete boundary<../files/tutorial_5.fr.med>`
150   * :download:`python script<../files/tutorial_5.py>`
151   * :download:`python script for the creation of the test directory<../files/tutorial_util.py>`
152
153
154 .. toctree::
155    :maxdepth: 2
156