Salome HOME
integration of modifications from Gérald Nicolas
[modules/homard.git] / doc / files / tutorial_3.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3
4 # Copyright (C) 2011-2012  CEA/DEN, EDF R&D
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 """
24 Exemple de couplage HOMARD-Salome
25 Copyright EDF-R&D 1996, 2010, 2013
26 """
27 __revision__ = "V1.4"
28 #
29 # ==================================
30 # Repertoire a personnaliser
31 # Ce repertoire contiendra les fichiers de resultats : maill.01.med, maill.02.med
32 dircase = "/tmp"
33 # ==================================
34 import os
35 # Ce repertoire contient les fichiers de donnees : tutorial_3.00.med, tutorial_3.01.med
36 pathHomard = os.getenv('HOMARD_ROOT_DIR')
37 data_dir = os.path.join(pathHomard, "share/doc/salome/gui/HOMARD/_downloads")
38 #
39 import salome
40 salome.salome_init()
41 import HOMARD
42 #
43 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
44 study_main = salome.myStudyManager.NewStudy("HOMARD")
45 homard.SetCurrentStudy(salome.myStudy)
46 #
47 # Hypothesis "Hypo_0vers1"
48 # ========================
49 Hypo_0vers1 = homard.CreateHypothesis('Hypo_0vers1')
50 Hypo_0vers1.SetAdapRefinUnRef(1, 1, 0)
51 # Characterization of the field
52 Hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
53 Hypo_0vers1.SetUseComp(0)
54 Hypo_0vers1.AddComp('ERREST          ')
55 Hypo_0vers1.SetRefinThr(3, 1.0)
56 Hypo_0vers1.SetTypeFieldInterp(2)
57 Hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
58 Hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
59 #
60 # Hypothesis "Hypo_1vers2"
61 # ========================
62 Hypo_1vers2 = homard.CreateHypothesis('Hypo_1vers2')
63 Hypo_1vers2.SetAdapRefinUnRef(1, 1, 1)
64 # Characterization of the field
65 Hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
66 Hypo_1vers2.SetUseComp(0)
67 Hypo_1vers2.AddComp('ERREST          ')
68 Hypo_1vers2.SetRefinThr(3, 1.5)
69 Hypo_1vers2.SetUnRefThr(3, 6.)
70 Hypo_1vers2.SetTypeFieldInterp(2)
71 Hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
72 Hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
73 #
74 # Hypothesis "Hypo_1vers2_bis"
75 # ============================
76 Hypo_1vers2_bis = homard.CreateHypothesis('Hypo_1vers2_bis')
77 Hypo_1vers2_bis.SetAdapRefinUnRef(1, 1, 1)
78 # Characterization of the field
79 Hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
80 Hypo_1vers2_bis.SetUseComp(1)
81 Hypo_1vers2_bis.AddComp('DX')
82 Hypo_1vers2_bis.AddComp('DY')
83 Hypo_1vers2_bis.AddComp('DZ')
84 Hypo_1vers2_bis.SetRefinThr(1, 0.0001)
85 Hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
86 Hypo_1vers2_bis.SetTypeFieldInterp(0)
87 #
88 # Case "Case_1"
89 # =============
90 Case_1 = homard.CreateCase('Case_1', 'G_0', data_dir+'/tutorial_3.00.med')
91 Case_1.SetDirName(dircase)
92 #
93 # Iteration "Iter_1"
94 # ==================
95 Iter_1 = Case_1.NextIteration('Iter_1')
96 Iter_1.SetMeshName('H_1')
97 Iter_1.SetMeshFile(dircase+'/maill.01.med')
98 Iter_1.SetFieldFile(data_dir+'/tutorial_3.00.med')
99 Iter_1.SetTimeStepRank( 1, 1)
100 Iter_1.AssociateHypo('Hypo_0vers1')
101 codret = Iter_1.Compute(1)
102 #
103 # Iteration "Iter_2"
104 # ==================
105 Iter_2 = Iter_1.NextIteration('Iter_2')
106 Iter_2.SetMeshName('H_2')
107 Iter_2.SetMeshFile(dircase+'/maill.02.med')
108 Iter_2.SetFieldFile(data_dir+'/tutorial_3.01.med')
109 Iter_2.SetTimeStepRank(1, 1)
110 Iter_2.AssociateHypo('Hypo_1vers2')
111 codret = Iter_2.Compute(1)
112 #
113 # Iteration "Iter_2_bis"
114 # ======================
115 Iter_2_bis = Iter_1.NextIteration('Iter_2_bis')
116 Iter_2_bis.SetMeshName('H_2_bis')
117 Iter_2_bis.SetMeshFile(dircase+'/maill.02.bis.med')
118 Iter_2_bis.SetFieldFile(data_dir+'/tutorial_3.01.med')
119 Iter_2_bis.SetTimeStepRank(1, 1)
120 Iter_2_bis.AssociateHypo('Hypo_1vers2_bis')
121 codret = Iter_2_bis.Compute(1)
122 #
123 if salome.sg.hasDesktop():
124   salome.sg.updateObjBrowser(1)