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+'/tutorial_1.00.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. Des champs sur les noeuds ou sur les mailles sont interpolés.
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)
143 Hypo_0.SetTypeFieldInterp(2)
144 Hypo_0.AddFieldInterp('SOLU_0__DEPL____________________')
145 Hypo_0.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
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__________')
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__________')
163 Case_0 = homard.CreateCase('Case_0', 'G_0', dircase+'/tutorial_3.00.med')
164 Case_0.SetDirName(dircase)
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)
178 Iter_1 = homard.CreateIteration('Iter_1', 'Iter_0')
179 Iter_1.SetMeshName('H_2')
180 Iter_1.SetMeshFile('/tmp/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)
187 Téléchargement des fichiers
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>`
194 Suivi de frontières courbes
195 """""""""""""""""""""""""""
196 .. index:: single: champ
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.
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')
208 Boundary_2 = homard.CreateBoundary('cyl_1_ext', 1)
209 Boundary_2.SetCylinder(0.0, 25., -25., 25., 50., 75., 100.)
211 Boundary_3 = homard.CreateBoundary('cyl_2_ext', 1)
212 Boundary_3.SetCylinder(17.5, -2.5, -12.5, -100., -75., -25., 50.)
214 Boundary_4 = homard.CreateBoundary('cyl_1_int', 1)
215 Boundary_4.SetCylinder(0.0, 25., -25., 25., 50., 75., 75.)
217 Boundary_5 = homard.CreateBoundary('cyl_2_int', 1)
218 Boundary_5.SetCylinder(17.5, -2.5, -12.5, -100., -75., -25., 25.)
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')
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' )
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)
259 Téléchargement des fichiers
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>`