1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2019 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Python script for HOMARD
22 Test tutorial_3 associe au tutorial 3
24 __revision__ = "V4.06"
26 #========================================================================
27 TEST_NAME = "tutorial_3"
30 #========================================================================
34 # ==================================
35 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
36 # Repertoire des scripts utilitaires
37 REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
38 REP_PYTHON = os.path.normpath(REP_PYTHON)
39 sys.path.append(REP_PYTHON)
40 from test_util import get_dir
41 from test_util import get_dir_tutorial
42 from test_util import test_results
43 # ==================================
44 # Répertoires pour ce test
45 REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
46 DATA_TUTORIAL = get_dir_tutorial(PATH_HOMARD)
47 # ==================================
54 IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
55 IPAR.append("AP_MODULES_LIST", "Homard")
58 #========================= Debut de la fonction ==================================
60 def homard_exec(nom, ficmed, verbose=False):
62 Python script for HOMARD
69 # HOMARD.UpdateStudy()
75 # Hypothese "hypo_0vers1"
76 # =======================
77 hypo_0vers1 = HOMARD.CreateHypothesis('hypo_0vers1')
78 # Characterization of the field
79 hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
80 hypo_0vers1.SetUseComp(0)
81 hypo_0vers1.AddComp('ERREST ')
82 hypo_0vers1.SetRefinThr(3, 1.0)
83 hypo_0vers1.SetTypeFieldInterp(2)
84 hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
85 hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
87 # Hypothese "hypo_1vers2"
88 # =======================
89 hypo_1vers2 = HOMARD.CreateHypothesis('hypo_1vers2')
90 # Characterization of the field
91 hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
92 hypo_1vers2.SetUseComp(0)
93 hypo_1vers2.AddComp('ERREST ')
94 hypo_1vers2.SetRefinThr(3, 1.5)
95 hypo_1vers2.SetUnRefThr(3, 6.)
96 hypo_1vers2.SetTypeFieldInterp(2)
97 hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
98 hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
100 # Hypothese "hypo_1vers2_bis"
101 # ===========================
102 hypo_1vers2_bis = HOMARD.CreateHypothesis('hypo_1vers2_bis')
103 # Characterization of the field
104 hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
105 hypo_1vers2_bis.SetUseComp(1)
106 hypo_1vers2_bis.AddComp('DX')
107 hypo_1vers2_bis.AddComp('DY')
108 hypo_1vers2_bis.AddComp('DZ')
109 hypo_1vers2_bis.SetRefinThr(1, 0.0001)
110 hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
111 hypo_1vers2_bis.SetTypeFieldInterp(0)
117 le_cas = HOMARD.CreateCase('case_3', nom, ficmed)
118 le_cas.SetDirName(DIRCASE)
127 print(". Itérations")
128 # Iteration "iter_3_1"
129 # ====================
130 iter_3_1 = le_cas.NextIteration('iter_3_1')
131 iter_3_1.SetMeshName('H_1')
132 iter_3_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
133 iter_3_1.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.00.med"))
134 iter_3_1.SetTimeStepRank( 1, 1)
135 iter_3_1.AssociateHypo('hypo_0vers1')
136 erreur = iter_3_1.Compute(1, option)
140 # Iteration "iter_3_2"
141 # ====================
142 iter_3_2 = iter_3_1.NextIteration('iter_3_2')
143 iter_3_2.SetMeshName('H_2')
144 iter_3_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
145 iter_3_2.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med"))
146 iter_3_2.SetTimeStepRank(1, 1)
147 iter_3_2.AssociateHypo('hypo_1vers2')
148 erreur = iter_3_2.Compute(1, option)
152 # Iteration "iter_3_2_bis"
153 # ========================
154 iter_3_2_bis = iter_3_1.NextIteration('iter_3_2_bis')
155 iter_3_2_bis.SetMeshName('H_2_bis')
156 iter_3_2_bis.SetMeshFile(os.path.join(DIRCASE, "maill.02.bis.med"))
157 iter_3_2_bis.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med"))
158 iter_3_2_bis.SetTimeStepRank(1, 1)
159 iter_3_2_bis.AssociateHypo('hypo_1vers2_bis')
160 erreur = iter_3_2_bis.Compute(1, option)
167 message += "Erreur au calcul de l'itération %d" % erreur
169 return erreur, message
171 #========================== Fin de la fonction ==================================
177 # A. Exec of HOMARD-SALOME
179 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
180 assert HOMARD is not None, "Impossible to load homard engine"
181 HOMARD.SetLanguageShort("fr")
183 FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med")
185 ERREUR, MESSAGE = homard_exec("G_0", FICMED, DEBUG)
186 except RuntimeError as eee:
188 MESSAGE = str(eee.message)
191 MESSAGE += "Pb in homard_exec"
194 # B. Test of the results
197 DESTROY_DIR = not DEBUG
198 test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
203 raise Exception(MESSAGE)
205 if salome.sg.hasDesktop():
206 salome.sg.updateObjBrowser()
207 iparameters.getSession().restoreVisualState(1)