Salome HOME
Ajout de 5 tests qui sont les clones des 5 tutorials
[modules/homard.git] / doc / files / tutorial_3.py
1 #!/usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3
4 # Copyright (C) 2011-2014  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, or (at your option) any later version.
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, 2014
26 """
27 __revision__ = "V1.9"
28 #
29 import os
30 import sys
31 #
32 # ==================================
33 pathHomard = os.getenv('HOMARD_ROOT_DIR')
34 # Repertoire des donnees du tutorial
35 data_dir = os.path.join(pathHomard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
36 data_dir = os.path.normpath(data_dir)
37 sys.path.append(data_dir)
38 from tutorial_util import gzip_gunzip
39 from tutorial_util import creation_dircase
40 # ==================================
41 dircase = creation_dircase(3)
42 gzip_gunzip(data_dir, 3, -1)
43 # ==================================
44 #
45 import salome
46 salome.salome_init()
47 import HOMARD
48 #
49 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
50 study_main = salome.myStudyManager.NewStudy("HOMARD")
51 homard.SetCurrentStudy(salome.myStudy)
52 #
53 # Hypothese "Hypo_0vers1"
54 # =======================
55 Hypo_0vers1 = homard.CreateHypothesis('Hypo_0vers1')
56 # Characterization of the field
57 Hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
58 Hypo_0vers1.SetUseComp(0)
59 Hypo_0vers1.AddComp('ERREST          ')
60 Hypo_0vers1.SetRefinThr(3, 1.0)
61 Hypo_0vers1.SetTypeFieldInterp(2)
62 Hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
63 Hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
64 #
65 # Hypothese "Hypo_1vers2"
66 # =======================
67 Hypo_1vers2 = homard.CreateHypothesis('Hypo_1vers2')
68 # Characterization of the field
69 Hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
70 Hypo_1vers2.SetUseComp(0)
71 Hypo_1vers2.AddComp('ERREST          ')
72 Hypo_1vers2.SetRefinThr(3, 1.5)
73 Hypo_1vers2.SetUnRefThr(3, 6.)
74 Hypo_1vers2.SetTypeFieldInterp(2)
75 Hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
76 Hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
77 #
78 # Hypothese "Hypo_1vers2_bis"
79 # ===========================
80 Hypo_1vers2_bis = homard.CreateHypothesis('Hypo_1vers2_bis')
81 # Characterization of the field
82 Hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
83 Hypo_1vers2_bis.SetUseComp(1)
84 Hypo_1vers2_bis.AddComp('DX')
85 Hypo_1vers2_bis.AddComp('DY')
86 Hypo_1vers2_bis.AddComp('DZ')
87 Hypo_1vers2_bis.SetRefinThr(1, 0.0001)
88 Hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
89 Hypo_1vers2_bis.SetTypeFieldInterp(0)
90 #
91 # Cas
92 # ===
93 Case_3 = homard.CreateCase('Case_3', 'G_0', data_dir+'/tutorial_3.00.med')
94 Case_3.SetDirName(dircase)
95 #
96 # Iteration "Iter_3_1"
97 # ====================
98 Iter_3_1 = Case_3.NextIteration('Iter_3_1')
99 Iter_3_1.SetMeshName('H_1')
100 Iter_3_1.SetMeshFile(dircase+'/maill.01.med')
101 Iter_3_1.SetFieldFile(data_dir+'/tutorial_3.00.med')
102 Iter_3_1.SetTimeStepRank( 1, 1)
103 Iter_3_1.AssociateHypo('Hypo_0vers1')
104 error = Iter_3_1.Compute(1, 2)
105 #
106 # Iteration "Iter_3_2"
107 # ====================
108 Iter_3_2 = Iter_3_1.NextIteration('Iter_3_2')
109 Iter_3_2.SetMeshName('H_2')
110 Iter_3_2.SetMeshFile(dircase+'/maill.02.med')
111 Iter_3_2.SetFieldFile(data_dir+'/tutorial_3.01.med')
112 Iter_3_2.SetTimeStepRank(1, 1)
113 Iter_3_2.AssociateHypo('Hypo_1vers2')
114 error = Iter_3_2.Compute(1, 2)
115 #
116 # Iteration "Iter_3_2_bis"
117 # ========================
118 Iter_3_2_bis = Iter_3_1.NextIteration('Iter_3_2_bis')
119 Iter_3_2_bis.SetMeshName('H_2_bis')
120 Iter_3_2_bis.SetMeshFile(dircase+'/maill.02.bis.med')
121 Iter_3_2_bis.SetFieldFile(data_dir+'/tutorial_3.01.med')
122 Iter_3_2_bis.SetTimeStepRank(1, 1)
123 Iter_3_2_bis.AssociateHypo('Hypo_1vers2_bis')
124 error = Iter_3_2_bis.Compute(1, 2)
125
126 # ==================================
127 gzip_gunzip(data_dir, 3, 1)
128 # ==================================
129
130 if salome.sg.hasDesktop():
131   salome.sg.updateObjBrowser(1)