Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/homard.git] / doc / tutorials.rst
1 Exemples
2 ========
3 .. index:: single: exemple
4 .. index:: single: python
5 On trouvera ici les instructions python pour quelques configurations caractéristiques. Les fichiers de données associés sont téléchargeables. Il faut penser à modifier le contenu de la variable ``dircase`` : c'est le répertoire dans lequel les fichiers med auront été enregistrés. C'est dans ce répertoire que seront écrits les fichiers résultant des adaptations successives.
6
7 Raffinement uniforme
8 """"""""""""""""""""
9 .. index:: single: raffinement;uniforme
10
11 On fera ici trois raffinements uniformes successifs du maillage contenu dans le fichier ``tutorial_1.00.med``. Quelques remarques :
12   * la même hypothèse est utilisée à chaque itération
13   * le maillage produit porte toujours le même nom. Cela ne pose pas de problème car il est stocké dans des fichiers différents.
14
15  ::
16
17   dircase = "/tmp"
18   #
19   # Hypothesis "Hypo_0"
20   # ===================
21   Hypo_0 = homard.CreateHypothesis('Hypo_0')
22   Hypo_0.SetAdapRefinUnRef(-1, 1, 0)
23   #
24   # Case "Case_0"
25   # =============
26   Case_0 = homard.CreateCase('Case_0', 'MAILL', dircase+'/tutorial_1.00.med')
27   Case_0.SetDirName(dircase)
28   Case_0.SetConfType(1)
29   #
30   # Iterations
31   # ==========
32   # Iteration "Iter_0"
33   Iter_0 = homard.CreateIteration('Iter_0', Case_0.GetIter0Name())
34   Iter_0.SetMeshName('MESH')
35   Iter_0.SetMeshFile(dircase+'/maill.01.med')
36   homard.AssociateIterHypo('Iter_0', 'Hypo_0')
37   codret = homard.Compute('Iter_0', 1)
38
39   # Iteration "Iter_1"
40   Iter_1 = homard.CreateIteration('Iter_1', 'Iter_0')
41   Iter_1.SetMeshName('MESH')
42   Iter_1.SetMeshFile(dircase+'/maill.02.med')
43   homard.AssociateIterHypo('Iter_1', 'Hypo_0')
44   codret = homard.Compute('Iter_1', 1)
45
46   # Iteration "Iter_2"
47   Iter_2 = homard.CreateIteration('Iter_2', 'Iter_1')
48   Iter_2.SetMeshName('MESH')
49   Iter_2.SetMeshFile(dircase+'/maill.03.med')
50   homard.AssociateIterHypo('Iter_2', 'Hypo_0')
51   codret = homard.Compute('Iter_2', 1)
52
53 .. note::
54   Téléchargement des fichiers
55
56   * :download:`maillage initial<files/tutorial_1.00.med.gz>`
57   * :download:`commandes python<files/tutorial_1.py>`
58
59
60 Raffinement par des zones
61 """""""""""""""""""""""""
62 .. index:: single: zone
63
64 On procède ici au raffinement selon des zones. Pour passer du maillage initial au maillage 'M_1', on utilise une boîte encadrant le plan z=1 et une sphère centrée sur l'origine de rayon 1.05. Puis pour passer du maillage 'M_1' au maillage 'M_2', on remplace la sphère par une boîte encadrant le cube de côté 0.5, pointant sur l'origine. On notera que le type de raffinement n'a pas été précisé ; par défaut, il sera donc conforme.
65 ::
66
67   dircase = "/tmp"
68   #
69   # Creation of the zones
70   # =====================
71   # Box "Zone_0"
72   Zone_0 = homard.CreateZone('Zone_0', 2)
73   Zone_0.SetBox(-0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
74   #
75   # Sphere "Zone_1"
76   Zone_1 = homard.CreateZone('Zone_1', 4)
77   Zone_1.SetSphere(0., 0., 0., 1.05)
78   #
79   # Box "Zone_2"
80   Zone_2 = homard.CreateZone('Zone_2', 2)
81   Zone_2.SetBox(-0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
82   #
83   # Hypothesis "Hypo_0"
84   # ===================
85   Hypo_0 = homard.CreateHypothesis('Hypo_0')
86   Hypo_0.SetAdapRefinUnRef(0, 1, 0)
87   homard.AssociateHypoZone('Zone_1', 'Hypo_0')
88   homard.AssociateHypoZone('Zone_0', 'Hypo_0')
89   #
90   # Hypothesis "Hypo_1"
91   # ===================
92   Hypo_1 = homard.CreateHypothesis('Hypo_1')
93   Hypo_1.SetAdapRefinUnRef(0, 1, 0)
94   homard.AssociateHypoZone('Zone_0', 'Hypo_1')
95   homard.AssociateHypoZone('Zone_2', 'Hypo_1')
96   #
97   # Case "Case_0"
98   # =============
99   Case_0 = homard.CreateCase('Case_0', 'MZERO', dircase+'/tutorial_2.00.med')
100   Case_0.SetDirName(dircase)
101   #
102   # Iteration "Iter_0"
103   # ==================
104   Iter_0 = homard.CreateIteration('Iter_0', Case_0.GetIter0Name())
105   Iter_0.SetMeshName('M_1')
106   Iter_0.SetMeshFile(dircase+'/maill.01.med')
107   homard.AssociateIterHypo('Iter_0', 'Hypo_0')
108   codret = homard.Compute('Iter_0', 1)
109   #
110   # Iteration "Iter_1"
111   # ==================
112   Iter_1 = homard.CreateIteration('Iter_1', 'Iter_0')
113   Iter_1.SetMeshName('M_2')
114   Iter_1.SetMeshFile(dircase+'/maill.02.med')
115   homard.AssociateIterHypo('Iter_1', 'Hypo_1')
116   codret = homard.Compute('Iter_1', 1)
117
118 .. note::
119   Téléchargement des fichiers
120
121   * :download:`maillage initial<files/tutorial_2.00.med.gz>`
122   * :download:`commandes python<files/tutorial_2.py>`
123
124
125 Raffinement selon un champ
126 """"""""""""""""""""""""""
127 .. index:: single: champ
128
129 On procède ici au raffinement selon un champ. Les hypothèses servent à définir le nom du champ et les seuils de raffinement/déraffinement. La donnée du fichier et des instants est faite dans l'itération. Des champs sur les noeuds ou sur les mailles sont interpolés.
130 ::
131
132   dircase = "/tmp"
133   #
134   # Hypothesis "Hypo_0"
135   # ===================
136   Hypo_0 = homard.CreateHypothesis('Hypo_0')
137   Hypo_0.SetAdapRefinUnRef(1, 1, 0)
138   # Characterization of the field
139   Hypo_0.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
140   Hypo_0.SetUseComp(0)
141   Hypo_0.AddComp('ERREST          ')
142   Hypo_0.SetRefinThr(3, 1.0)
143   Hypo_0.SetTypeFieldInterp(2)
144   Hypo_0.AddFieldInterp('SOLU_0__DEPL____________________')
145   Hypo_0.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
146   #
147   # Hypothesis "Hypo_1"
148   # ===================
149   Hypo_1 = homard.CreateHypothesis('Hypo_1')
150   Hypo_1.SetAdapRefinUnRef(1, 1, 1)
151   # Characterization of the field
152   Hypo_1.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
153   Hypo_1.SetUseComp(0)
154   Hypo_1.AddComp('ERREST          ')
155   Hypo_1.SetRefinThr(3, 1.5)
156   Hypo_1.SetUnRefThr(3, 6.)
157   Hypo_1.SetTypeFieldInterp(2)
158   Hypo_1.AddFieldInterp('SOLU_1__DEPL____________________')
159   Hypo_1.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
160   #
161   # Case "Case_0"
162   # =============
163   Case_0 = homard.CreateCase('Case_0', 'G_0', dircase+'/tutorial_3.00.med')
164   Case_0.SetDirName(dircase)
165   #
166   # Iteration "Iter_0"
167   # ==================
168   Iter_0 = homard.CreateIteration('Iter_0', Case_0.GetIter0Name())
169   Iter_0.SetMeshName('H_1')
170   Iter_0.SetMeshFile(dircase+'/maill.01.med')
171   Iter_0.SetFieldFile(dircase+'/tutorial_3.00.med')
172   Iter_0.SetTimeStepRank( 1, 1)
173   homard.AssociateIterHypo('Iter_0', 'Hypo_0')
174   codret = homard.Compute('Iter_0', 1)
175   #
176   # Iteration "Iter_1"
177   # ==================
178   Iter_1 = homard.CreateIteration('Iter_1', 'Iter_0')
179   Iter_1.SetMeshName('H_2')
180   Iter_1.SetMeshFile(dircase+'/maill.02.med')
181   Iter_1.SetFieldFile(dircase+'/tutorial_3.01.med')
182   Iter_1.SetTimeStepRank(1, 1)
183   homard.AssociateIterHypo('Iter_1', 'Hypo_1')
184   codret = homard.Compute('Iter_1', 1)
185
186 .. note::
187   Téléchargement des fichiers
188
189   * :download:`maillage et champ étape 0<files/tutorial_3.00.med.gz>`
190   * :download:`maillage et champ étape 1<files/tutorial_3.01.med.gz>`
191   * :download:`commandes python<files/tutorial_3.py>`
192
193
194 Suivi de frontières courbes
195 """""""""""""""""""""""""""
196 .. index:: single: champ
197
198 On teste ici le suivi des frontières courbes : des frontières analytiques pour décrire les différentes surfaces des tuyaux et une frontière discrète pour décrire les lignes d'intersection des deux tuyaux. Le pilotage du raffinement est le suivant : raffinement uniforme de toutes les mailles contenues dans des groupes désignés.
199 ::
200   dircase = "/tmp"
201   #
202   # Creation of the boundaries
203   # ==========================
204   Boundary_1 = homard.CreateBoundary('intersection', 0)
205   Boundary_1.SetMeshFile(dircase+'/tutorial_4.fr.med')
206   Boundary_1.SetMeshName('PIQUAGE')
207   #
208   Boundary_2 = homard.CreateBoundary('cyl_1_ext', 1)
209   Boundary_2.SetCylinder(0.0, 25., -25., 25., 50., 75., 100.)
210   #
211   Boundary_3 = homard.CreateBoundary('cyl_2_ext', 1)
212   Boundary_3.SetCylinder(17.5, -2.5, -12.5, -100., -75., -25., 50.)
213   #
214   Boundary_4 = homard.CreateBoundary('cyl_1_int', 1)
215   Boundary_4.SetCylinder(0.0, 25., -25., 25., 50., 75., 75.)
216   #
217   Boundary_5 = homard.CreateBoundary('cyl_2_int', 1)
218   Boundary_5.SetCylinder(17.5, -2.5, -12.5, -100., -75., -25., 25.)
219   #
220   # Hypothesis "Hypo"
221   # ===================
222   # Creation of the hypothesis Hypo_1
223   Hypo_1 = homard.CreateHypothesis('Hypo_1')
224   Hypo_1.SetAdapRefinUnRef(-1, 1, 0)
225   Hypo_1.AddGroup('T1_INT')
226   Hypo_1.AddGroup('T2_INT')
227   # Creation of the hypothesis Hypo_2
228   Hypo_2 = homard.CreateHypothesis('Hypo_2')
229   Hypo_2.SetAdapRefinUnRef(-1, 1, 0)
230   Hypo_2.AddGroup('T1_EXT')
231   Hypo_2.AddGroup('T2_EXT')
232   #
233   # Case "Case"
234   # =============
235   Case = homard.CreateCase('Case', 'PIQUAGE', dircase+'/tutorial_4.00.med')
236   Case.SetDirName(dircase)
237   Case.AddBoundaryGroup( 'intersection', '' )
238   Case.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT' )
239   Case.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
240   Case.AddBoundaryGroup( 'cyl_1_int', 'T1_INT' )
241   Case.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
242   #
243   # Creation of the iterations
244   # ==========================
245   # Creation of the iteration Iter_1
246   Iter_1 = homard.CreateIteration('Iter_1', Case.GetIter0Name() )
247   Iter_1.SetMeshName('PIQUAGE_1')
248   Iter_1.SetMeshFile(dircase+'/maill.01.med')
249   homard.AssociateIterHypo('Iter_1', 'Hypo_1')
250   codret = homard.Compute('Iter_1', 1)
251   # Creation of the iteration Iter_2
252   Iter_2 = homard.CreateIteration('Iter_2', 'Iter_1' )
253   Iter_2.SetMeshName('PIQUAGE_2')
254   Iter_2.SetMeshFile(dircase+'/maill.02.med')
255   homard.AssociateIterHypo('Iter_2', 'Hypo_2')
256   codret = homard.Compute('Iter_2', 1)
257
258 .. note::
259   Téléchargement des fichiers
260
261   * :download:`maillage initial<files/tutorial_4.00.med.gz>`
262   * :download:`maillage de la frontière discrète<files/tutorial_4.fr.med.gz>`
263   * :download:`commandes python<files/tutorial_4.py>`
264
265
266 .. toctree::
267    :maxdepth: 2