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.
9 .. index:: single: raffinement;uniforme
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.
21 Hypo_0 = homard.CreateHypothesis('Hypo_0')
22 Hypo_0.SetAdapRefinUnRef(-1, 1, 0)
26 Case_0 = homard.CreateCase('Case_0', 'MAILL', dircase+'/m0.med')
27 Case_0.SetDirName(dircase)
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)
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)
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)
54 Téléchargement des fichiers
56 * :download:`maillage initial<files/tutorial_1.00.med.gz>`
57 * :download:`commandes python<files/tutorial_1.py>`
60 Raffinement par des zones
61 """""""""""""""""""""""""
62 .. index:: single: zone
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.
69 # Creation of the zones
70 # =====================
72 Zone_0 = homard.CreateZone('Zone_0', 2)
73 Zone_0.SetBox(-0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
76 Zone_1 = homard.CreateZone('Zone_1', 4)
77 Zone_1.SetSphere(0., 0., 0., 1.05)
80 Zone_2 = homard.CreateZone('Zone_2', 2)
81 Zone_2.SetBox(-0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
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')
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')
99 Case_0 = homard.CreateCase('Case_0', 'MZERO', dircase+'/tutorial_2.00.med')
100 Case_0.SetDirName(dircase)
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)
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)
119 Téléchargement des fichiers
121 * :download:`maillage initial<files/tutorial_2.00.med.gz>`
122 * :download:`commandes python<files/tutorial_2.py>`
125 Raffinement selon un champ
126 """"""""""""""""""""""""""
127 .. index:: single: champ
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.
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__________')
141 Hypo_0.AddComp('ERREST ')
142 Hypo_0.SetRefinThr(3, 1.0)
144 # Hypothesis "Hypo_1"
145 # ===================
146 Hypo_1 = homard.CreateHypothesis('Hypo_1')
147 Hypo_1.SetAdapRefinUnRef(1, 1, 1)
148 # Characterization of the field
149 Hypo_1.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
151 Hypo_1.AddComp('ERREST ')
152 Hypo_1.SetRefinThr(3, 1.5)
153 Hypo_1.SetUnRefThr(3, 6.)
157 Case_0 = homard.CreateCase('Case_0', 'G_0', dircase+'/tutorial_3.00.med')
158 Case_0.SetDirName(dircase)
162 Iter_0 = homard.CreateIteration('Iter_0', Case_0.GetIter0Name())
163 Iter_0.SetMeshName('H_1')
164 Iter_0.SetMeshFile(dircase+'/maill.01.med')
165 Iter_0.SetField(dircase+'/tutorial_3.00.med', 1, 1)
166 homard.AssociateIterHypo('Iter_0', 'Hypo_0')
167 codret = homard.Compute('Iter_0', 1)
171 Iter_1 = homard.CreateIteration('Iter_1', 'Iter_0')
172 Iter_1.SetMeshName('H_2')
173 Iter_1.SetMeshFile('/tmp/maill.02.med')
174 Iter_1.SetField(dircase+'/tutorial_3.01.med', 1, 1)
175 homard.AssociateIterHypo('Iter_1', 'Hypo_1')
176 codret = homard.Compute('Iter_1', 1)
179 Téléchargement des fichiers
181 * :download:`maillage et champ étape 0<files/tutorial_3.00.med.gz>`
182 * :download:`maillage et champ étape 1<files/tutorial_3.01.med.gz>`
183 * :download:`commandes python<files/tutorial_3.py>`