Salome HOME
Coquilles
[modules/homard.git] / doc / files / tutorial_4.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (C) 2011-2015  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, 2011, 2014
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(4)
42 gzip_gunzip(DATA_TUTORIAL, 4, -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 # Frontieres
54 # ==========
55 boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med')
56 #
57 boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
58 #
59 boun_4_3 = homard.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
60 #
61 boun_4_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
62 #
63 boun_4_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
64 #
65 # Hypotheses
66 # ==========
67 # Creation of the hypothesis hypo_4
68 hypo_4 = homard.CreateHypothesis('hypo_4')
69 hypo_4.SetUnifRefinUnRef(1)
70 hypo_4.AddGroup('T1_INT_I')
71 hypo_4.AddGroup('T1_INT_O')
72 hypo_4.AddGroup('T2_INT')
73 # Creation of the hypothesis hypo_4_bis
74 hypo_4_bis = homard.CreateHypothesis('hypo_4_bis')
75 hypo_4_bis.SetUnifRefinUnRef(1)
76 hypo_4_bis.AddGroup('T1_EXT_I')
77 hypo_4_bis.AddGroup('T1_EXT_O')
78 hypo_4_bis.AddGroup('T2_EXT')
79 #
80 # Cas
81 # ===
82 case_4 = homard.CreateCase('Case_4', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.00.med')
83 case_4.SetDirName(DIRCASE)
84 case_4.AddBoundaryGroup( 'intersection', '' )
85 case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
86 case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
87 case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
88 case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
89 case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
90 case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
91 #
92 # Iterations
93 # ==========
94 # Iteration iter_4_1 : raffinement selon les faces internes
95 iter_4_1 = case_4.NextIteration('iter_4_1')
96 iter_4_1.SetMeshName('PIQUAGE_1')
97 iter_4_1.SetMeshFile(DIRCASE+'/maill.01.med')
98 iter_4_1.AssociateHypo('hypo_4')
99 error = iter_4_1.Compute(1, 2)
100 # Iteration iter_4_2 : raffinement selon les faces externes
101 iter_4_2 = iter_4_1.NextIteration('iter_4_2')
102 iter_4_2.SetMeshName('PIQUAGE_2')
103 iter_4_2.SetMeshFile(DIRCASE+'/maill.02.med')
104 iter_4_2.AssociateHypo('hypo_4_bis')
105 error = iter_4_2.Compute(1, 2)
106 # Iteration iter_4_3 : second raffinement selon les faces externes
107 iter_4_3 = iter_4_2.NextIteration('iter_4_3')
108 iter_4_3.SetMeshName('PIQUAGE_3')
109 iter_4_3.SetMeshFile(DIRCASE+'/maill.03.med')
110 iter_4_3.AssociateHypo('hypo_4_bis')
111 error = iter_4_3.Compute(1, 2)
112
113 # ==================================
114 gzip_gunzip(DATA_TUTORIAL, 4, 1)
115 # ==================================
116
117 if salome.sg.hasDesktop():
118   salome.sg.updateObjBrowser(1)