Salome HOME
automatisation FronTrack - fichiers à télécharger
[modules/homard.git] / doc / files / tutorial_3.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2011-2016  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 1996, 2010, 2018
26 """
27 __revision__ = "V3.1"
28 #
29 import os
30 import sys
31 #
32 # ==================================
33 PATH_HOMARD = os.getenv("HOMARD_ROOT_DIR")
34 # Repertoire des donnees du tutorial
35 DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
36 DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
37 sys.path.append(DATA_TUTORIAL)
38 from tutorial_util import gzip_gunzip
39 from tutorial_util import creation_dircase
40 # ==================================
41 DIRCASE = creation_dircase(3)
42 gzip_gunzip(DATA_TUTORIAL, 3, -1)
43 # ==================================
44 #
45 import salome
46 salome.salome_init()
47 import HOMARD
48 #
49 homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD")
50 homard.SetCurrentStudy(salome.myStudy)
51 #
52 #============================= Début des commandes =============================
53 #
54 # Hypothese "hypo_0vers1"
55 # =======================
56 hypo_0vers1 = homard.CreateHypothesis('hypo_0vers1')
57 # Characterization of the field
58 hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
59 hypo_0vers1.SetUseComp(0)
60 hypo_0vers1.AddComp('ERREST          ')
61 hypo_0vers1.SetRefinThr(3, 1.0)
62 hypo_0vers1.SetTypeFieldInterp(2)
63 hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
64 hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
65 #
66 # Hypothese "hypo_1vers2"
67 # =======================
68 hypo_1vers2 = homard.CreateHypothesis('hypo_1vers2')
69 # Characterization of the field
70 hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
71 hypo_1vers2.SetUseComp(0)
72 hypo_1vers2.AddComp('ERREST          ')
73 hypo_1vers2.SetRefinThr(3, 1.5)
74 hypo_1vers2.SetUnRefThr(3, 6.)
75 hypo_1vers2.SetTypeFieldInterp(2)
76 hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
77 hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
78 #
79 # Hypothese "hypo_1vers2_bis"
80 # ===========================
81 hypo_1vers2_bis = homard.CreateHypothesis('hypo_1vers2_bis')
82 # Characterization of the field
83 hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
84 hypo_1vers2_bis.SetUseComp(1)
85 hypo_1vers2_bis.AddComp('DX')
86 hypo_1vers2_bis.AddComp('DY')
87 hypo_1vers2_bis.AddComp('DZ')
88 hypo_1vers2_bis.SetRefinThr(1, 0.0001)
89 hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
90 hypo_1vers2_bis.SetTypeFieldInterp(0)
91 #
92 # Cas
93 # ===
94 le_cas = homard.CreateCase('Case_3', 'G_0', os.path.join(DATA_TUTORIAL, "tutorial_3.00.med"))
95 le_cas.SetDirName(DIRCASE)
96 #
97 # Iteration "iter_3_1"
98 # ====================
99 iter_3_1 = le_cas.NextIteration('iter_3_1')
100 iter_3_1.SetMeshName('H_1')
101 iter_3_1.SetMeshFile(os.path.join(DIRCASE, "maill.01.med"))
102 iter_3_1.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.00.med"))
103 iter_3_1.SetTimeStepRank( 1, 1)
104 iter_3_1.AssociateHypo('hypo_0vers1')
105 erreur = iter_3_1.Compute(1, 2)
106 #
107 # Iteration "iter_3_2"
108 # ====================
109 iter_3_2 = iter_3_1.NextIteration('iter_3_2')
110 iter_3_2.SetMeshName('H_2')
111 iter_3_2.SetMeshFile(os.path.join(DIRCASE, "maill.02.med"))
112 iter_3_2.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med"))
113 iter_3_2.SetTimeStepRank(1, 1)
114 iter_3_2.AssociateHypo('hypo_1vers2')
115 erreur = iter_3_2.Compute(1, 2)
116 #
117 # Iteration "iter_3_2_bis"
118 # ========================
119 iter_3_2_bis = iter_3_1.NextIteration('iter_3_2_bis')
120 iter_3_2_bis.SetMeshName('H_2_bis')
121 iter_3_2_bis.SetMeshFile(os.path.join(DIRCASE, "maill.02.bis.med"))
122 iter_3_2_bis.SetFieldFile(os.path.join(DATA_TUTORIAL, "tutorial_3.01.med"))
123 iter_3_2_bis.SetTimeStepRank(1, 1)
124 iter_3_2_bis.AssociateHypo('hypo_1vers2_bis')
125 erreur = iter_3_2_bis.Compute(1, 2)
126 #
127 #============================== Fin des commandes ==============================
128 #
129 # ==================================
130 gzip_gunzip(DATA_TUTORIAL, 3, 1)
131 # ==================================
132
133 if salome.sg.hasDesktop():
134   salome.sg.updateObjBrowser(True)