]> SALOME platform Git repositories - modules/homard.git/blob - doc/tutorials.rst
Salome HOME
version 5_1_4 HOMARD_SRC
[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.
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+'/m0.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.
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   #
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__________')
150   Hypo_1.SetUseComp(0)
151   Hypo_1.AddComp('ERREST          ')
152   Hypo_1.SetRefinThr(3, 1.5)
153   Hypo_1.SetUnRefThr(3, 6.)
154   #
155   # Case "Case_0"
156   # =============
157   Case_0 = homard.CreateCase('Case_0', 'G_0', dircase+'/tutorial_3.00.med')
158   Case_0.SetDirName(dircase)
159   #
160   # Iteration "Iter_0"
161   # ==================
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)
168   #
169   # Iteration "Iter_1"
170   # ==================
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)
177
178 .. note::
179   Téléchargement des fichiers
180
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>`
184
185
186 .. toctree::
187    :maxdepth: 2