From: nicolas Date: Thu, 19 Sep 2013 15:26:50 +0000 (+0000) Subject: Mise à jour de la documentation X-Git-Tag: V7_3_0a1~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97e4e858387f05b6260ff7ed68c9b73f99aecb22;p=modules%2Fhomard.git Mise à jour de la documentation Correction des tutorial_*.py Création automatique de schémas YACS (suite) --- diff --git a/doc/en/tutorials.rst b/doc/en/tutorials.rst index 93e4f9e5..74beaa55 100644 --- a/doc/en/tutorials.rst +++ b/doc/en/tutorials.rst @@ -37,7 +37,7 @@ One will make here three successive uniform refinements of the mesh contained in .. literalinclude:: ../files/tutorial_1.py - :lines: 53-86 + :lines: 57-89 .. note:: Download the files @@ -53,7 +53,7 @@ Refinement by zones One proceeds here to refinement according to zones. To pass from the initial mesh to the mesh 'M_1', one uses a box framing the z=1 plane and a sphere centered on the origin with radius 1.05. Then to pass from the mesh 'M_1' to the mesh 'M_2', one replaces the sphere by a box framing the cube on side 0.5, pointing on the origin. It will be noted that the type of refinement was not specified; by default, it will be thus in conformity. .. literalinclude:: ../files/tutorial_2.py - :lines: 53-98 + :lines: 57-101 .. note:: Download the files @@ -70,7 +70,7 @@ One proceeds here to refinement according to a field. The hypotheses are used to To adapt the H_1 mesh resulting from the Iter_1 iteration, two alternatives are applied. In the first, Iter_2, the field is a scalar field of indicators of error and one cuts out the 1.5% of elements where the error is largest. In the second alternative, Iter_2_bis, one is based on a vector field and one examines the jump of this vector between an element and its neighbors: one will cut out where the infinite standard of this jump is higher than the absolute threshold of 0.0001. .. literalinclude:: ../files/tutorial_3.py - :lines: 53-128 + :lines: 57-131 .. note:: Download the files @@ -89,7 +89,7 @@ One tests the follow-up of the curved borders here: analytical borders to descri Scheme YACS carrying out this adaptation is downloadable. .. literalinclude:: ../files/tutorial_4.py - :lines: 53-112 + :lines: 57-115 .. note:: Download the files @@ -108,7 +108,7 @@ The instructions to adapt a 2D mesh are exactly identical to those necessary to In the case presented here, one for the first time refines all the elements contained in a bored disk, then in one second iteration, all the elements contained in a rectangle. One will note the use of the follow-up of the circular borders of the field. .. literalinclude:: ../files/tutorial_5.py - :lines: 53-98 + :lines: 57-101 .. note:: Download the files diff --git a/doc/en/yacs.rst b/doc/en/yacs.rst index 1eb77788..9146bc79 100644 --- a/doc/en/yacs.rst +++ b/doc/en/yacs.rst @@ -14,8 +14,8 @@ Here is the description of a scheme for a computation in which a value is to be .. image:: ../images/yacs_01.png :align: center :alt: yacs - allure générale - :width: 535 - :height: 362 + :width: 512 + :height: 306 .. note:: Among all the treated data, certain are unchanging: the name of the directory of calculation, the name of the case, the name of the hypothesis of adaptation, etc. It was chosen to impose them 'hard' in the various parameters of service or within the scripts python. We could also define them a priori in a node PresetNode and then pass on them by links. We did not hold this solution because it increases strongly the number of parameters and links attached to every node. It is very penalizing for the legibility of the scheme. The only data which are going to circulate are the ones been imperative by the description of the service and those that evolve during the execution of the scheme. @@ -27,7 +27,7 @@ The main boxes are: - DataInit : initialisation of the initial mesh - Etude_Initialisation : launching of the module HOMARD inside SALOME -- Tant_que_le_calcul_n_a_pas_converge : gestion of the loop computation/adaptation +- Boucle_de_convergence : gestion of the loop computation/adaptation - Bilan : final information DataInit @@ -67,15 +67,15 @@ The service SetCurrentStudy connects this study to an instance of HOMARD. :lines: 63-68 -Tant_que_le_calcul_n_a_pas_converge -=================================== -The box Tant_que_le_calcul_n_a_pas_converge is type WhileLoop. The condition is initialized in 1: the internal block Alternance_Calcul_HOMARD is executed. Within this block, we calculate and we adapt the mesh; when the process has to stop either as a result of error, or by convergence, the condition passes in 0. The loop ends and we pass in the following box, Bilan. +Boucle_de_convergence +===================== +The box Boucle_de_convergence is type WhileLoop. The condition is initialized in 1: the internal block Alternance_Calcul_HOMARD is executed. Within this block, we calculate and we adapt the mesh; when the process has to stop either as a result of error, or by convergence, the condition passes in 0. The loop ends and we pass in the following box, Bilan. .. image:: ../images/yacs_c_01.png :align: center :alt: Boucle - :width: 195 - :height: 142 + :width: 163 + :height: 93 Bilan ===== @@ -88,7 +88,7 @@ Bilan This box is a node python that takes in input a character string, MessInfo. If everything passed well, this message is empty. A window QT appears to confirm the convergence. If there was a problem, the message contains messages emitted during the calculations. The window QT shows this message. .. literalinclude:: ../files/yacs_01.xml - :lines: 424-437 + :lines: 406-419 Loop for the calculations @@ -96,8 +96,8 @@ Loop for the calculations .. image:: ../images/yacs_c_02.png :align: center :alt: Boucle - :width: 323 - :height: 158 + :width: 338 + :height: 152 This box is a block that manages the computation, the adaptation and the analysis. @@ -112,58 +112,60 @@ Calcul This box is a node python that is going to drive the calculation. In input, we find the number of the calculation (0 at first) and the name of the file which contains the mesh on which to calculate. In output, we find an integer which represents the error on this calculation (0 so everything goes well) and a dictionary python gathering the results of the calculation. The body of the node is established by the launch of a script python that activates the calculation. .. literalinclude:: ../files/yacs_01.xml - :lines: 77-104 + :lines: 77-103 In this example, we must define: - rep_calc : the directory in which will be executed the calculation. -- rep_script : the directory in which is the python that will launch the calculation. This directory is to be added to the PATH. From this directory, we shall import LanceCas from the file LanceCas.py +- rep_script : the directory in which is the python that will launch the calculation. This directory is to be added to the PATH. From this directory, we shall import Script from the file ScriptAster.py -The python LanceCas is programmed as the user wishes it so that the calculation can be made on the current mesh. According to the mode of launch of the code of calculation, we can need other information, as the number of the calculation or the directory of the calculation for example. The freedom is total. In our case, the arguments of input are the name of the file of mesh, the number of the calculation and the directory of calculation. They are given in a list python: ["--rep_calc=rep_calc", "--numero=numCalc", "--mesh_file=MeshFile"] +The python Script is programmed as the user wishes it so that the calculation can be made on the current mesh. According to the mode of launch of the code of calculation, we can need other information, as the number of the calculation or the directory of the calculation for example. The freedom is total. In our case, the arguments of input are the name of the file of mesh, the number of the calculation and the directory of calculation. They are given in a list python: ["--rep_calc=rep_calc", "--num=numCalc", "--mesh_file=MeshFile"] ]. On the other hand the output of the script has to obey the following rule. We get back a code of error, an error message and a dictionary. This dictionary contains necessarily the following keys: - "FileName" : the name of the file that contains the results of the calculation -- "MeshName" : the name of the used mesh -- "V00" : the value the convergence of which we want to test +- "V_TEST" : the value the convergence of which we want to test Adaptation ========== .. image:: ../images/yacs_c_04.png :align: center :alt: Adaptation - :width: 672 - :height: 569 + :width: 661 + :height: 566 The box Adaptation is a Switch node driven by the code of error of the previous calculation. If this code is nil, YACS will activate the box Adaptation_HOMARD that will launch the adaptation. If the code is not nil, we pass directly in the box Arret_boucle. Adaptation_HOMARD ----------------- -The first task tries to execute concern the initialization of the data necessary for HOMARD in the box HOMARD_Initialisation. This box is a switch node driven by the number of the calculation. In the starting up, the number is nil and YACS activates the box Homard_init_au_debut. +The first task tries to execute concern the initialization of the data necessary for HOMARD in the box HOMARD_Initialisation. This box is a switch node driven by the number of the calculation. In the starting up, the number is nil and YACS activates the box Iter_1. -Homard_init_au_debut -^^^^^^^^^^^^^^^^^^^^ +Iter_1 +^^^^^^ .. image:: ../images/yacs_c_06.png :align: center - :alt: Homard_init_au_debut + :alt: Iter_1 :width: 481 - :height: 150 + :height: 151 This box begins by creating the case HOMARD by calling the CreateCase service. .. literalinclude:: ../files/yacs_01.xml - :lines: 220-227 + :lines: 208-215 -The name of the case CaseName is imposed on "Calculation". The parameters of input MeshName and FileName arises from the output of the previous calculation. The parameter of output is an instance of case. +The name of the case CaseName is imposed on "Calcul". The name of the case MeshName is imposed on "BOX". The parameters of input FileName arise from the output of the previous calculation. The parameter of output is an instance of case. + +.. literalinclude:: ../files/yacs_01.xml + :lines: 443-446 .. literalinclude:: ../files/yacs_01.xml - :lines: 461-464 + :lines: 483-486 The options of this case must be now given. It is made by the node python CaseOptions. It is imperative to give the directory of calculation. We shall look at the description of the functions in:ref: ' tui_create_case '. In output, we get back the instance of the iteration corresponding to the initial state of the case. .. literalinclude:: ../files/yacs_01.xml - :lines: 228-242 + :lines: 216-228 Finally, a hypothesis is created by calling the CreateHypothèse service. The parameter of output is an instance of hypothese. @@ -177,45 +179,45 @@ Once initialized, the adaptation can be calculated. It is the goal of the Homard :width: 153 :height: 141 -The directory of calculation is recovered. +The directory of calculation is recovered. The name of the mesh is given. .. literalinclude:: ../files/yacs_01.xml - :lines: 258-263 + :lines: 245-250 ../.. .. literalinclude:: ../files/yacs_01.xml - :lines: 339-347 + :lines: 325-333 The hypothesis transmitted in input parameter characterized (look :ref:`tui_create_hypothese`) : .. literalinclude:: ../files/yacs_01.xml - :lines: 267-291 + :lines: 254-278 It is necessary to establish a name for the future iteration. To make sure that the name was never used, one installs a mechanism of incremental naming starting from the name of the initial iteration. As this initial name is the name of the initial mesh, one obtains a succession of names in the form: M_001, M_002, M_003, etc .. literalinclude:: ../files/yacs_01.xml - :lines: 293-303 + :lines: 280-290 The iteration is supplemented : hypothesis, future mesh, field (look :ref:`tui_create_iteration`) : .. literalinclude:: ../files/yacs_01.xml - :lines: 305-325 + :lines: 292-311 The iteration is calculated. If it were correct, variable OK equals 1: one will be able to continue the execution of the scheme. If there were a problem, variable OK equals 0 to mean that calculation must stop; an error message then is given. .. literalinclude:: ../files/yacs_01.xml - :lines: 327-338 + :lines: 313-324 After this execution, the process leaves the Adaptation_HOMARD node, then Adaptation node. One arrives then at the node of analysis. -Homard_init_ensuite -^^^^^^^^^^^^^^^^^^^ +Iter_n +^^^^^^ .. image:: ../images/yacs_c_07.png :align: center - :alt: Homard_init_ensuite + :alt: Iter_n :width: 323 - :height: 97 + :height: 92 For the following passing in the block of adaptation, it is necessary to recover: @@ -235,57 +237,52 @@ Arret_boucle The Arret_boucle block is present to only make forward variables because the input parameters of the nodes must always be filled. It is a very simple python: .. literalinclude:: ../files/yacs_01.xml - :lines: 185-196 + :lines: 173-184 Analyse ======= .. image:: ../images/yacs_c_05.png :align: center :alt: Analyse - :width: 155 - :height: 169 + :width: 156 + :height: 139 The Analyse block is a script python which ensures the complete control of the process by examining the causes of possible error successively. .. literalinclude:: ../files/yacs_01.xml - :lines: 105-118 + :lines: 104-116 ../.. .. literalinclude:: ../files/yacs_01.xml - :lines: 173-182 + :lines: 162-170 One starts by analyzing the return of the computer code: .. literalinclude:: ../files/yacs_01.xml - :lines: 120-125 - -Checking of the presence of the name of the mesh in the dictionary of the results: - -.. literalinclude:: ../files/yacs_01.xml - :lines: 127-134 + :lines: 118-123 Checking of the presence of the name of the result file in the dictionary of the results: .. literalinclude:: ../files/yacs_01.xml - :lines: 136-143 + :lines: 125-132 -Checking of convergence. That supposes that the value to be tested is present in the dictionary under the key 'V00'. Here, one set up a test on the variation of the value of one calculation at the other. With the first passage, nothing is tested. In the following passing, one tests if the relative variation is lower than 1 thousandths. One could have set up an absolute test if one had recovered a total level of error for example. +Checking of convergence. That supposes that the value to be tested is present in the dictionary under the key 'V_TEST'. Here, one set up a test on the variation of the value of one calculation at the other. With the first passage, nothing is tested. In the following passing, one tests if the relative variation is lower than 1 thousandths. One could have set up an absolute test if one had recovered a total level of error for example. .. literalinclude:: ../files/yacs_01.xml - :lines: 145-163 + :lines: 134-152 Lastly, it is checked that a maximum nomber of adaptations is not exceeded: .. literalinclude:: ../files/yacs_01.xml - :lines: 165-170 + :lines: 154-159 Use this scheme *************** To reproduce this example, download: * :download:`the scheme <../files/yacs_01.xml>` - * :download:`an example of python script <../files/yacs_script.tgz>` + * :download:`an example of python script <../files/yacs_script.py>` It should be adapted to simulation considered. In particular, it is necessary: diff --git a/doc/files/tutorial_1.py b/doc/files/tutorial_1.py index 9f14755d..20d1b331 100644 --- a/doc/files/tutorial_1.py +++ b/doc/files/tutorial_1.py @@ -54,13 +54,13 @@ homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Hypothesis "Hypo_1" -# =================== +# Hypotheses +# ========== Hypo_1 = homard.CreateHypothesis('Hypo_1') Hypo_1.SetAdapRefinUnRef(-1, 1, 0) # -# Case "Case_1" -# ============= +# Cas +# === Case_1 = homard.CreateCase('Case_1', 'MAILL', data_dir+'/tutorial_1.00.med') Case_1.SetDirName(dircase) Case_1.SetConfType(1) diff --git a/doc/files/tutorial_2.py b/doc/files/tutorial_2.py index 46375f71..6d0ee6bf 100644 --- a/doc/files/tutorial_2.py +++ b/doc/files/tutorial_2.py @@ -54,8 +54,8 @@ homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Creation of the zones -# ===================== +# Creation des zones +# ================== # Box "Zone_0" Zone_0 = homard.CreateZoneBox ('Zone_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1) # @@ -65,27 +65,27 @@ Zone_1 = homard.CreateZoneSphere ('Zone_1', 0., 0., 0., 1.05) # Box "Zone_2" Zone_2 = homard.CreateZoneBox ('Zone_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51) # -# Hypothesis "Hypo_2" -# =================== +# Hypothese "Hypo_2" +# ================== Hypo_2 = homard.CreateHypothesis('Hypo_2') Hypo_2.SetAdapRefinUnRef(0, 1, 0) Hypo_2.AddZone('Zone_1', 1) Hypo_2.AddZone('Zone_0', 1) # -# Hypothesis "Hypo_2_bis" -# =================== +# Hypothese "Hypo_2_bis" +# ====================== Hypo_2_bis = homard.CreateHypothesis('Hypo_2_bis') Hypo_2_bis.SetAdapRefinUnRef(0, 1, 0) Hypo_2_bis.AddZone('Zone_0', 1) Hypo_2_bis.AddZone('Zone_2', 1) # -# Case "Case_2" -# ============= +# Cas +# === Case_2 = homard.CreateCase('Case_2', 'MZERO', data_dir+'/tutorial_2.00.med') Case_2.SetDirName(dircase) # # Iteration "Iter_2_0" -# ================== +# ==================== Iter_2_0 = Case_2.NextIteration('Iter_2_0') Iter_2_0.SetMeshName('M_1') Iter_2_0.SetMeshFile(dircase+'/maill.01.med') @@ -93,7 +93,7 @@ Iter_2_0.AssociateHypo('Hypo_2') codret = Iter_2_0.Compute(1, 2) # # Iteration "Iter_2_1" -# ================== +# ==================== Iter_2_1 = Iter_2_0.NextIteration('Iter_2_1') Iter_2_1.SetMeshName('M_2') Iter_2_1.SetMeshFile(dircase+'/maill.02.med') diff --git a/doc/files/tutorial_3.py b/doc/files/tutorial_3.py index 86ba7bb9..55943ecc 100644 --- a/doc/files/tutorial_3.py +++ b/doc/files/tutorial_3.py @@ -54,8 +54,8 @@ homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Hypothesis "Hypo_0vers1" -# ======================== +# Hypothese "Hypo_0vers1" +# ======================= Hypo_0vers1 = homard.CreateHypothesis('Hypo_0vers1') Hypo_0vers1.SetAdapRefinUnRef(1, 1, 0) # Characterization of the field @@ -67,8 +67,8 @@ Hypo_0vers1.SetTypeFieldInterp(2) Hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________') Hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________') # -# Hypothesis "Hypo_1vers2" -# ======================== +# Hypothese "Hypo_1vers2" +# ======================= Hypo_1vers2 = homard.CreateHypothesis('Hypo_1vers2') Hypo_1vers2.SetAdapRefinUnRef(1, 1, 1) # Characterization of the field @@ -81,8 +81,8 @@ Hypo_1vers2.SetTypeFieldInterp(2) Hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________') Hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________') # -# Hypothesis "Hypo_1vers2_bis" -# ============================ +# Hypothese "Hypo_1vers2_bis" +# =========================== Hypo_1vers2_bis = homard.CreateHypothesis('Hypo_1vers2_bis') Hypo_1vers2_bis.SetAdapRefinUnRef(1, 1, 1) # Characterization of the field @@ -95,13 +95,13 @@ Hypo_1vers2_bis.SetRefinThr(1, 0.0001) Hypo_1vers2_bis.SetUnRefThr(1, 0.000001) Hypo_1vers2_bis.SetTypeFieldInterp(0) # -# Case "Case_3" -# ============= +# Cas +# === Case_3 = homard.CreateCase('Case_3', 'G_0', data_dir+'/tutorial_3.00.med') Case_3.SetDirName(dircase) # # Iteration "Iter_3_1" -# ================== +# ==================== Iter_3_1 = Case_3.NextIteration('Iter_3_1') Iter_3_1.SetMeshName('H_1') Iter_3_1.SetMeshFile(dircase+'/maill.01.med') @@ -111,7 +111,7 @@ Iter_3_1.AssociateHypo('Hypo_0vers1') codret = Iter_3_1.Compute(1, 2) # # Iteration "Iter_3_2" -# ================== +# ==================== Iter_3_2 = Iter_3_1.NextIteration('Iter_3_2') Iter_3_2.SetMeshName('H_2') Iter_3_2.SetMeshFile(dircase+'/maill.02.med') @@ -121,7 +121,7 @@ Iter_3_2.AssociateHypo('Hypo_1vers2') codret = Iter_3_2.Compute(1, 2) # # Iteration "Iter_3_2_bis" -# ====================== +# ======================== Iter_3_2_bis = Iter_3_1.NextIteration('Iter_3_2_bis') Iter_3_2_bis.SetMeshName('H_2_bis') Iter_3_2_bis.SetMeshFile(dircase+'/maill.02.bis.med') diff --git a/doc/files/tutorial_4.py b/doc/files/tutorial_4.py index 73b10b77..662efa46 100644 --- a/doc/files/tutorial_4.py +++ b/doc/files/tutorial_4.py @@ -54,8 +54,8 @@ homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Creation of the boundaries -# ========================== +# Frontieres +# ========== Boun_4_1 = homard.CreateBoundaryDi('intersection', 'PIQUAGE', data_dir+'/tutorial_4.fr.med') # Boun_4_2 = homard.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.) @@ -66,7 +66,7 @@ Boun_4_4 = homard.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., # Boun_4_5 = homard.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.) # -# Hypothesis +# Hypotheses # ========== # Creation of the hypothesis Hypo_4 Hypo_4 = homard.CreateHypothesis('Hypo_4') @@ -81,8 +81,8 @@ Hypo_4_bis.AddGroup('T1_EXT_I') Hypo_4_bis.AddGroup('T1_EXT_O') Hypo_4_bis.AddGroup('T2_EXT') # -# Case "Case_4" -# ============= +# Cas +# === Case_4 = homard.CreateCase('Case_4', 'PIQUAGE', data_dir+'/tutorial_4.00.med') Case_4.SetDirName(dircase) Case_4.AddBoundaryGroup( 'intersection', '' ) @@ -93,21 +93,21 @@ Case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' ) Case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' ) Case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' ) # -# Creation of the iterations -# ========================== -# Creation of the iteration Iter_4_1 : raffinement selon les faces internes +# Iterations +# ========== +# Iteration Iter_4_1 : raffinement selon les faces internes Iter_4_1 = Case_4.NextIteration('Iter_4_1') Iter_4_1.SetMeshName('PIQUAGE_1') Iter_4_1.SetMeshFile(dircase+'/maill.01.med') Iter_4_1.AssociateHypo('Hypo_4') codret = Iter_4_1.Compute(1, 2) -# Creation of the iteration Iter_4_2 : raffinement selon les faces externes +# Iteration Iter_4_2 : raffinement selon les faces externes Iter_4_2 = Iter_4_1.NextIteration('Iter_4_2') Iter_4_2.SetMeshName('PIQUAGE_2') Iter_4_2.SetMeshFile(dircase+'/maill.02.med') Iter_4_2.AssociateHypo('Hypo_4_bis') codret = Iter_4_2.Compute(1, 2) -# Creation of the iteration Iter_4_3 : second raffinement selon les faces externes +# Iteration Iter_4_3 : second raffinement selon les faces externes Iter_4_3 = Iter_4_2.NextIteration('Iter_4_3') Iter_4_3.SetMeshName('PIQUAGE_3') Iter_4_3.SetMeshFile(dircase+'/maill.03.med') diff --git a/doc/files/tutorial_5.py b/doc/files/tutorial_5.py index 03da77fe..a9069877 100644 --- a/doc/files/tutorial_5.py +++ b/doc/files/tutorial_5.py @@ -54,19 +54,19 @@ homard = salome.lcc.FindOrLoadComponent("FactoryServer", "HOMARD") study_main = salome.myStudyManager.NewStudy("HOMARD") homard.SetCurrentStudy(salome.myStudy) # -# Creation of the boundaries -# ========================== +# Frontiere +# ========= # Creation of the discrete boundary Boun_5_1 Boun_5_1 = homard.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', data_dir+'/tutorial_5.fr.med') # -# Creation of the zones -# ===================== +# Creation des zones +# ================== # Creation of the disk with hole enveloppe enveloppe = homard.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 ) # Creation of the rectangle quart_sup quart_sup = homard.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 ) # -# Hypothesis +# Hypotheses # ========== # Creation of the hypothesis Hypo_5 Hypo_5 = homard.CreateHypothesis('Hypo_5') @@ -77,15 +77,15 @@ Hypo_5_bis = homard.CreateHypothesis('Hypo_5_bis') Hypo_5_bis.SetAdapRefinUnRef(0, 1, 0) Hypo_5_bis.AddZone('quart_sup', 1) # -# Case "Case_5" -# ============= +# Cas +# === Case_5 = homard.CreateCase('Case_5', 'COEUR_2D', data_dir+'/tutorial_5.00.med') Case_5.SetDirName(dircase) Case_5.SetConfType(3) Case_5.AddBoundaryGroup('Boun_5_1', '') # # Iteration "Iter_5_1" -# ================== +# ==================== Iter_5_1 = Case_5.NextIteration('Iter_5_1') Iter_5_1.SetMeshName('COEUR_2D_01') Iter_5_1.SetMeshFile(dircase+'/maill.01.med') @@ -93,7 +93,7 @@ Iter_5_1.AssociateHypo('Hypo_5') codret = Iter_5_1.Compute(1, 2) # # Iteration "Iter_5_2" -# ================== +# ==================== Iter_5_2 = Iter_5_1.NextIteration('Iter_5_2') Iter_5_2.SetMeshName('COEUR_2D_02') Iter_5_2.SetMeshFile(dircase+'/maill.02.med') diff --git a/doc/files/yacs_01.xml b/doc/files/yacs_01.xml index 9b299b2b..c62572b5 100644 --- a/doc/files/yacs_01.xml +++ b/doc/files/yacs_01.xml @@ -72,27 +72,26 @@ NewStudy = StudyManager.NewStudy("my_homard_study") SetCurrentStudy theStudy - + @@ -238,7 +227,7 @@ Iter0 = Case.GetIter0() -HOMARD_Init_au_debut +Iter_1 CreateCase return Case_Options Case @@ -251,6 +240,7 @@ HOMARD_Init_au_debut import os # Repertoire d'execution HOMARD_Exec_DirName +HOMARD_Exec_MeshName # # Hypothese # ========= @@ -284,7 +274,6 @@ Iter = LastIter.NextIteration(IterName) Iter.AssociateHypo(HypoName) # # . Le nom du futur maillage -MeshName = dico_resu["MeshName"] Iter.SetMeshName(MeshName) # # . Le fichier du futur maillage @@ -319,19 +308,19 @@ else : HOMARD_Initialisation HOMARD_Exec - HOMARD_Initialisation.default_HOMARD_Init_ensuite.LastIteration return + HOMARD_Initialisation.default_Iter_n.LastIteration return HOMARD_Exec LastIter - HOMARD_Initialisation.p1_HOMARD_Init_au_debut.Case_Options Iter0 + HOMARD_Initialisation.p1_Iter_1.Case_Options Iter0 HOMARD_Exec LastIter - HOMARD_Initialisation.default_HOMARD_Init_ensuite.GetHypothesis return + HOMARD_Initialisation.default_Iter_n.GetHypothesis return HOMARD_Exec Hypo - HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateHypothesis return + HOMARD_Initialisation.p1_Iter_1.CreateHypothesis return HOMARD_Exec Hypo @@ -355,13 +344,9 @@ else : Analyse NumCalcP1 Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec NumAdapt - - Analyse MeshName - Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateCase MeshName - Analyse FileName - Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateCase FileName + Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase FileName Analyse MessInfo @@ -408,66 +393,66 @@ else : DataInit Etude_Initialisation - Etude_Initialisation Tant_que_le_calcul_n_a_pas_converge - Tant_que_le_calcul_n_a_pas_converge Bilan + Etude_Initialisation Boucle_de_convergence + Boucle_de_convergence Bilan DataInit MeshFile - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Calcul MeshFile + Boucle_de_convergence.Alternance_Calcul_HOMARD.Calcul MeshFile - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.default_Arret_boucle.Arret OK - Tant_que_le_calcul_n_a_pas_converge condition + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.default_Arret_boucle.Arret OK + Boucle_de_convergence condition - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec OK - Tant_que_le_calcul_n_a_pas_converge condition + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec OK + Boucle_de_convergence condition - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.default_Arret_boucle.Arret MessInfo + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.default_Arret_boucle.Arret MessInfo Bilan MessInfo - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec MessInfo + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec MessInfo Bilan MessInfo - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateCaseCaseName + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCaseCaseName Calcul - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.CalculnumCalc + Boucle_de_convergence.Alternance_Calcul_HOMARD.CalculnumCalc 0 - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptationselect + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptationselect 0 - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisationselect + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisationselect 0 - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_HOMARD_Init_ensuite.LastIterationCaseName + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_Iter_n.LastIterationCaseName Calcul - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_HOMARD_Init_ensuite.GetHypothesisHypoName + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_Iter_n.GetHypothesisHypoName Hypo - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateHypothesisHypoName + Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateHypothesisHypoName Hypo - Tant_que_le_calcul_n_a_pas_convergecondition + Boucle_de_convergencecondition true - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.AnalyseNumCalc + Boucle_de_convergence.Alternance_Calcul_HOMARD.AnalyseNumCalc 0 - Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.AnalyseErrCalc + Boucle_de_convergence.Alternance_Calcul_HOMARD.AnalyseErrCalc 0 PARAMETRES @@ -476,22 +461,22 @@ PARAMETRES - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/HOMARD/HOMARD_Iteration.cxx b/src/HOMARD/HOMARD_Iteration.cxx index 16517a84..09bc0ad3 100644 --- a/src/HOMARD/HOMARD_Iteration.cxx +++ b/src/HOMARD/HOMARD_Iteration.cxx @@ -113,8 +113,8 @@ std::string HOMARD_Iteration::GetDumpPython() const // MESSAGE (".. Hypothese " << _NomHypo ); aScript << "\t" << _Name << ".AssociateHypo(\"" << _NomHypo << "\")\n"; - if (_Etat == true) { aScript << "\tcodret = " <<_Name << ".Compute(1, 2)\n"; } - else { aScript << "\t#codret = " <<_Name << ".Compute(1, 2)\n"; } + if (_Etat == true) { aScript << "\tcodret = " <<_Name << ".Compute(1, 1)\n"; } + else { aScript << "\t#codret = " <<_Name << ".Compute(1, 1)\n"; } // MESSAGE (". Fin de l ecriture de l iteration " << _Name ); return aScript.str(); diff --git a/src/HOMARD/HOMARD_YACS.cxx b/src/HOMARD/HOMARD_YACS.cxx index 0e238804..99b4c94f 100644 --- a/src/HOMARD/HOMARD_YACS.cxx +++ b/src/HOMARD/HOMARD_YACS.cxx @@ -78,10 +78,15 @@ std::string HOMARD_YACS::GetDumpPython() const MESSAGE (". Ecriture du schema " << _Name ); std::ostringstream aScript; aScript << "\n# Creation of the schema " << _Name << "\n"; -// Le fichier du maillage initial - aScript << "\t" << _Name << ".SetMeshFile(\"" << _MeshFile << "\")\n"; +// Creation du schema + aScript << "\t" << _Name << " = " << _NomCas << ".CreateYACSSchema(\"" << _Name << "\", \"" << _ScriptFile << "\", \"" << _NomDir << "\", \"" << _MeshFile << "\")\n"; +// Le type de schema + aScript << "\t" << _Name << ".SetType(" << _Type << ")\n"; -// MESSAGE (". Fin de l ecriture du schema " << _Name ); +// L'ecriture eventuelle du schema + aScript << "\t#" << _Name << ".Write()\n"; + + MESSAGE (". Fin de l ecriture du schema " << _Name ); return aScript.str(); } diff --git a/src/HOMARD/YACSDriver.cxx b/src/HOMARD/YACSDriver.cxx index a8202e39..a598c5a8 100644 --- a/src/HOMARD/YACSDriver.cxx +++ b/src/HOMARD/YACSDriver.cxx @@ -86,15 +86,15 @@ void YACSDriver::Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileNa _Texte += "rep_calc = \"" + _DirName + "\"\n" ; _Texte += "rep_script = os.path.dirname(\"" + FileName + "\")\n" ; _Texte += "sys.path.append(rep_script)\n" ; - _Texte += "from " + nomfic + " import LanceCas\n" ; + _Texte += "from " + nomfic + " import Script\n" ; // } //=============================================================================== // Les options du cas //=============================================================================== -void YACSDriver::Texte_HOMARD_Init_au_debut_Case_Options( const std::string pythonTexte ) +void YACSDriver::Texte_Iter_1_Case_Options( const std::string pythonTexte ) { - MESSAGE("Texte_HOMARD_Init_au_debut_Case_Options, pythonTexte\n"<addWidget(Script); - PushFile = new QPushButton(CreateYACS); - PushFile->setObjectName(QString::fromUtf8("PushFile")); - PushFile->setAutoDefault(false); + PBScriptFile = new QPushButton(CreateYACS); + PBScriptFile->setObjectName(QString::fromUtf8("PBScriptFile")); + PBScriptFile->setAutoDefault(false); - _2->addWidget(PushFile); + _2->addWidget(PBScriptFile); LEScriptFile = new QLineEdit(CreateYACS); LEScriptFile->setObjectName(QString::fromUtf8("LEScriptFile")); @@ -143,11 +143,11 @@ public: hboxLayout->addWidget(DirectoryStart); - PushDir = new QPushButton(CreateYACS); - PushDir->setObjectName(QString::fromUtf8("PushDir")); - PushDir->setAutoDefault(false); + PBDir = new QPushButton(CreateYACS); + PBDir->setObjectName(QString::fromUtf8("PBDir")); + PBDir->setAutoDefault(false); - hboxLayout->addWidget(PushDir); + hboxLayout->addWidget(PBDir); LEDirName = new QLineEdit(CreateYACS); LEDirName->setObjectName(QString::fromUtf8("LEDirName")); @@ -169,11 +169,11 @@ public: _3->addWidget(MeshFile); - PushFile_2 = new QPushButton(CreateYACS); - PushFile_2->setObjectName(QString::fromUtf8("PushFile_2")); - PushFile_2->setAutoDefault(false); + PBMeshFile = new QPushButton(CreateYACS); + PBMeshFile->setObjectName(QString::fromUtf8("PBMeshFile")); + PBMeshFile->setAutoDefault(false); - _3->addWidget(PushFile_2); + _3->addWidget(PBMeshFile); LEMeshFile = new QLineEdit(CreateYACS); LEMeshFile->setObjectName(QString::fromUtf8("LEMeshFile")); @@ -249,11 +249,11 @@ public: Case->setText(QApplication::translate("CreateYACS", "Case", 0, QApplication::UnicodeUTF8)); PBCaseName->setText(QString()); Script->setText(QApplication::translate("CreateYACS", "Script", 0, QApplication::UnicodeUTF8)); - PushFile->setText(QString()); + PBScriptFile->setText(QString()); DirectoryStart->setText(QApplication::translate("CreateYACS", "Directory", 0, QApplication::UnicodeUTF8)); - PushDir->setText(QString()); + PBDir->setText(QString()); MeshFile->setText(QApplication::translate("CreateYACS", "Mesh file", 0, QApplication::UnicodeUTF8)); - PushFile_2->setText(QString()); + PBMeshFile->setText(QString()); RBStatic->setText(QApplication::translate("CreateYACS", "Static", 0, QApplication::UnicodeUTF8)); RBTransient->setText(QApplication::translate("CreateYACS", "Transient", 0, QApplication::UnicodeUTF8)); GroupButtons->setTitle(QString()); diff --git a/src/HOMARDGUI/CreateYACS.ui b/src/HOMARDGUI/CreateYACS.ui index 53a1f363..aab5bc5b 100644 --- a/src/HOMARDGUI/CreateYACS.ui +++ b/src/HOMARDGUI/CreateYACS.ui @@ -90,7 +90,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -164,7 +164,7 @@ - + diff --git a/src/HOMARDGUI/HOMARDGUI.cxx b/src/HOMARDGUI/HOMARDGUI.cxx index 56949368..3f59dd16 100644 --- a/src/HOMARDGUI/HOMARDGUI.cxx +++ b/src/HOMARDGUI/HOMARDGUI.cxx @@ -306,7 +306,7 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) if (monIter == QString("")) break; try { - homardGen->Compute(monIter.toStdString().c_str(), 0, 1, -1, 2); + homardGen->Compute(monIter.toStdString().c_str(), 0, 1, -1, 1); } catch( SALOME::SALOME_Exception& S_ex ) { @@ -369,7 +369,8 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) // Edition d'un schema YACS else if (HOMARD_UTILS::isYACS(obj)) { - MonEditYACS *aDlg = new MonEditYACS(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ; + MESSAGE("appel de MonEditYACS"); + MonEditYACS *aDlg = new MonEditYACS(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ; aDlg->show(); } // Edition d'une zone @@ -468,11 +469,11 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) break; } - case 1302: // Affichage du fichier mess + case 1302: // Affichage de fichier texte { MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() ); _PTR(SObject) obj = chercheMonObjet(); - if ((obj) and ((HOMARD_UTILS::isFilelog(obj) or HOMARD_UTILS::isFileSummary(obj)))) + if ( (obj) and ( HOMARD_UTILS::isFileType(obj,QString("log")) or HOMARD_UTILS::isFileType(obj,QString("Summary")) or HOMARD_UTILS::isFileType(obj,QString("xml")) ) ) { MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ; if ( aDlg->_codret == 0 ) { aDlg->show(); } @@ -486,7 +487,7 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) MESSAGE("command " << theCommandID << " activated"); QString Name=HOMARD_QT_COMMUN::SelectionArbreEtude(QString("CasHomard"), 1); MESSAGE("Name " << Name.toStdString().c_str() << " choisi dans arbre"); - MonCreateYACS *aDlg = new MonCreateYACS( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), Name ) ; + MonCreateYACS *aDlg = new MonCreateYACS( true, HOMARD::HOMARD_Gen::_duplicate(homardGen), Name ) ; aDlg->show(); break; } @@ -496,9 +497,18 @@ bool HOMARDGUI::OnGUIEvent (int theCommandID) MESSAGE("etape 1402") MESSAGE("command " << theCommandID << " activated"); QString Name=HOMARD_QT_COMMUN::SelectionArbreEtude(QString("YACSHomard"), 1); - MESSAGE("YACSHomard " << Name.toStdString().c_str() << " choisi dans arbre"); - MonCreateYACS *aDlg = new MonCreateYACS( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), Name ) ; - aDlg->show(); + if (Name == QString("")) break; + try + { + homardGen->YACSWrite(Name.toStdString().c_str()); + } + catch( SALOME::SALOME_Exception& S_ex ) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr(CORBA::string_dup(S_ex.details.text)) ); + getApp()->updateObjectBrowser(); + return false; + } break; } @@ -643,8 +653,8 @@ void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& t } else if ( HOMARD_UTILS::isYACS(obj) ) { - pix = resMgr->loadPixmap( "HOMARD", "save.png" ); - menu->addAction(QIcon(pix), tr(QString("HOM_MEN_YACS").toLatin1().data()), this, SLOT(YACSWrite())); + pix = resMgr->loadPixmap( "HOMARD", "write.png" ); + menu->addAction(QIcon(pix), tr(QString("HOM_MEN_WRITE").toLatin1().data()), this, SLOT(YACSWrite())); EditObject = true ; DeleteObject = true ; } @@ -653,7 +663,7 @@ void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& t EditObject = true ; DeleteObject = true ; } - else if ( HOMARD_UTILS::isFilelog(obj) or HOMARD_UTILS::isFileSummary(obj) ) + else if ( HOMARD_UTILS::isFileType(obj,QString("log")) or HOMARD_UTILS::isFileType(obj,QString("Summary")) or HOMARD_UTILS::isFileType(obj,QString("xml")) ) { pix = resMgr->loadPixmap( "HOMARD", "texte.png" ); menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT_MESS_FILE").toLatin1().data()), this, SLOT(EditAsciiFile())); @@ -698,11 +708,6 @@ void HOMARDGUI::Delete() this->OnGUIEvent(1211); } -// void HOMARDGUI::EditAsciiFile() -// { -// this->OnGUIEvent(1301); -// } - void HOMARDGUI::EditAsciiFile() { this->OnGUIEvent(1302); diff --git a/src/HOMARDGUI/HOMARDGUI_Utils.cxx b/src/HOMARDGUI/HOMARDGUI_Utils.cxx index a5072978..89d7de23 100644 --- a/src/HOMARDGUI/HOMARDGUI_Utils.cxx +++ b/src/HOMARDGUI/HOMARDGUI_Utils.cxx @@ -259,18 +259,11 @@ bool HOMARD_UTILS::isZone(_PTR(SObject) MonObj) return isObject( MonObj, QString("ZoneHomard"), -1 ) ; } //================================================================ -// Retourne vrai si l objet est un fichier de messages +// Retourne vrai si l objet est un fichier de type TypeFile //================================================================ -bool HOMARD_UTILS::isFilelog(_PTR(SObject) MonObj) +bool HOMARD_UTILS::isFileType(_PTR(SObject) MonObj, QString TypeFile) { - return isObject( MonObj, QString("log"), 0 ) ; -} -//================================================================ -// Retourne vrai si l objet est un fichier de bilan -//================================================================ -bool HOMARD_UTILS::isFileSummary(_PTR(SObject) MonObj) -{ - return isObject( MonObj, QString("Summary"), 0 ) ; + return isObject( MonObj, TypeFile, 0 ) ; } //========================================================================================================= diff --git a/src/HOMARDGUI/HOMARDGUI_Utils.h b/src/HOMARDGUI/HOMARDGUI_Utils.h index c538aa78..e4315ba9 100644 --- a/src/HOMARDGUI/HOMARDGUI_Utils.h +++ b/src/HOMARDGUI/HOMARDGUI_Utils.h @@ -80,8 +80,7 @@ namespace HOMARD_UTILS { bool isIter(_PTR(SObject) MonObj); bool isYACS(_PTR(SObject) MonObj); bool isZone(_PTR(SObject) MonObj); - bool isFilelog(_PTR(SObject) MonObj); - bool isFileSummary(_PTR(SObject) MonObj); + bool isFileType(_PTR(SObject) MonObj, QString TypeFile); bool isObject(_PTR(SObject) MonObj, QString TypeObject, int option ); void PushOnHelp(QString monFichierAide, QString contexte); diff --git a/src/HOMARDGUI/HOMARD_msg_en.ts b/src/HOMARDGUI/HOMARD_msg_en.ts index ef7d0bb9..ffeb40f1 100644 --- a/src/HOMARDGUI/HOMARD_msg_en.ts +++ b/src/HOMARDGUI/HOMARD_msg_en.ts @@ -51,6 +51,10 @@ HOM_MEN_EDIT_MESS_FILE Show the file + + HOM_MEN_WRITE + Write + HOM_TOP_HOMARD HOMARD diff --git a/src/HOMARDGUI/HOMARD_msg_fr.ts b/src/HOMARDGUI/HOMARD_msg_fr.ts index 41887385..77b334a9 100644 --- a/src/HOMARDGUI/HOMARD_msg_fr.ts +++ b/src/HOMARDGUI/HOMARD_msg_fr.ts @@ -51,6 +51,10 @@ HOM_MEN_EDIT_MESS_FILE Afficher le fichier + + HOM_MEN_WRITE + Ecrire + HOM_TOP_HOMARD HOMARD diff --git a/src/HOMARDGUI/HOMARD_msg_ja.ts b/src/HOMARDGUI/HOMARD_msg_ja.ts index a2b415db..a7079d5f 100644 --- a/src/HOMARDGUI/HOMARD_msg_ja.ts +++ b/src/HOMARDGUI/HOMARD_msg_ja.ts @@ -51,6 +51,10 @@ HOM_MEN_EDIT_MESS_FILE Show the file + + HOM_MEN_WRITE + Write + HOM_TOP_HOMARD HOMARD diff --git a/src/HOMARDGUI/MonCreateYACS.cxx b/src/HOMARDGUI/MonCreateYACS.cxx index 74538e81..0bf0acd6 100644 --- a/src/HOMARDGUI/MonCreateYACS.cxx +++ b/src/HOMARDGUI/MonCreateYACS.cxx @@ -30,40 +30,39 @@ using namespace std; #include +// ---------------------------------------------------------------------- +MonCreateYACS::MonCreateYACS (bool modal, HOMARD::HOMARD_Gen_var myHomardGen0, QString CaseName ): // ---------------------------------------------------------------------- /* Constructs a MonCreateYACS * Sets attributes to default values */ // ---------------------------------------------------------------------- -MonCreateYACS::MonCreateYACS (QWidget* parent, bool modal, HOMARD::HOMARD_Gen_var myHomardGen0, QString CaseName ) - : - Ui_CreateYACS(), - _aCaseName(CaseName), - _aScriptFile(""), - _aDirName(""), - _aMeshFile("") -{ - MESSAGE("Debut du constructeur de MonCreateYACS"); - myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0); - setupUi(this); - setModal(modal); + Ui_CreateYACS(), + _aCaseName(CaseName), + _aScriptFile(""), + _aDirName(""), + _aMeshFile("") + { +// MESSAGE("Debut du constructeur de MonCreateYACS"); + myHomardGen=HOMARD::HOMARD_Gen::_duplicate(myHomardGen0); + setupUi(this); + setModal(modal); - InitConnect(); + InitConnect(); - SetNewName() ; + SetNewName() ; - if (_aCaseName != QString("")) - { SetCaseName(); } - else - {setModal(false); /* permet selection du cas dans l arbre d etude */} + if (_aCaseName != QString("")) + { SetCaseName(); } + else + {setModal(false); /* permet selection du cas dans l arbre d etude */} - adjustSize(); - MESSAGE("Fin du constructeur de MonCreateYACS"); -} + adjustSize(); +// MESSAGE("Fin du constructeur de MonCreateYACS"); + } // ---------------------------------------------------------------------- -MonCreateYACS::MonCreateYACS(QWidget* parent, - HOMARD::HOMARD_Gen_var myHomardGen0, +MonCreateYACS::MonCreateYACS(HOMARD::HOMARD_Gen_var myHomardGen0, QString caseName): // ---------------------------------------------------------------------- // Constructeur appele par MonEditYACS @@ -72,7 +71,7 @@ MonCreateYACS::MonCreateYACS(QWidget* parent, _Name (""), Chgt (false) { - // MESSAGE("Debut de MonCreateYACS") +// MESSAGE("Debut du constructeur de MonCreateYACS appele par MonEditYACS"); setupUi(this) ; setModal(true) ; @@ -90,9 +89,9 @@ void MonCreateYACS::InitConnect() // ------------------------------------------------------------------------ { connect( PBCaseName, SIGNAL(pressed()), this, SLOT(SetCaseName())); - connect( PushDir, SIGNAL(pressed()), this, SLOT(SetDirName())); - connect( PushFile, SIGNAL(pressed()), this, SLOT(SetScriptFile())); - connect( PushFile_2, SIGNAL(pressed()), this, SLOT(SetMeshFile())); + connect( PBScriptFile, SIGNAL(pressed()), this, SLOT(SetScriptFile())); + connect( PBDir, SIGNAL(pressed()), this, SLOT(SetDirName())); + connect( PBMeshFile, SIGNAL(pressed()), this, SLOT(SetMeshFile())); connect( RBStatic, SIGNAL(clicked()), this, SLOT(SetType(1))); connect( RBTransient, SIGNAL(clicked()), this, SLOT(SetType(2))); @@ -108,12 +107,6 @@ bool MonCreateYACS::PushOnApply() { MESSAGE("PushOnApply"); - if ( _aCaseName == QString ("")) - { - QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), - QObject::tr("HOM_CASE_NAME") ); - return false; - } // Le fichier du script QString aFileName=LEScriptFile->text().trimmed(); if (aFileName ==QString("")) @@ -160,31 +153,76 @@ bool MonCreateYACS::PushOnApply() return false; } - HOMARD_UTILS::updateObjBrowser(); - MESSAGE ("_aCaseName.toStdString " << _aCaseName.toStdString() ); + bool bOK = CreateOrUpdate() ; + + if ( bOK ) { HOMARD_UTILS::updateObjBrowser() ; } + + return bOK; +} +// --------------------------------------------------- +bool MonCreateYACS:: CreateOrUpdate() +//---------------------------------------------------- +// Creation ou modification du schema +{ + MESSAGE("CreateOrUpdate"); + bool bOK = true ; + + // Le cas + if ( _aCaseName == QString ("")) + { + QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), + QObject::tr("HOM_CASE_NAME") ); + return false; + } + // Les donnees + QString aScriptFile=LEScriptFile->text().trimmed(); + if ( aScriptFile != _aScriptFile ) + { + _aScriptFile = aScriptFile ; + Chgt = true ; + } + QString aDirName=LEDirName->text().trimmed(); + if ( aDirName != _aDirName ) + { + _aDirName = aDirName ; + Chgt = true ; + } + QString aMeshFile=LEMeshFile->text().trimmed(); + if ( aMeshFile != _aMeshFile ) + { + _aMeshFile = aMeshFile ; + Chgt = true ; + } -// Creation de l'objet CORBA + // Creation de l'objet CORBA try { _Name=LEName->text().trimmed(); - aYACS=myHomardGen->CreateYACSSchema(CORBA::string_dup(_Name.toStdString().c_str()), _aCaseName.toStdString().c_str(), _aScriptFile.toStdString().c_str(), _aDirName.toStdString().c_str(), _aMeshFile.toStdString().c_str()); -// _parent->AddYACS(_Name); + aYACS=myHomardGen->CreateYACSSchema(CORBA::string_dup(_Name.toStdString().c_str()), CORBA::string_dup(_aCaseName.toStdString().c_str()), CORBA::string_dup(_aScriptFile.toStdString().c_str()), CORBA::string_dup(_aDirName.toStdString().c_str()), CORBA::string_dup(_aMeshFile.toStdString().c_str())); } catch( SALOME::SALOME_Exception& S_ex ) { QMessageBox::critical( 0, QObject::tr("HOM_ERROR"), QObject::tr(CORBA::string_dup(S_ex.details.text)) ); - return false; + bOK = false; } -return true; + // Options + if ( bOK ) + { aYACS->SetType(_Type) ; } + + // Ecriture du fichier + if ( bOK ) + { aYACS->Write() ; } + + return bOK; } // --------------------------- void MonCreateYACS::PushOnOK() // --------------------------- { bool bOK = PushOnApply(); - if ( bOK ) this->close(); + if ( bOK ) this->close(); } //------------------------------ void MonCreateYACS::PushOnHelp() @@ -225,8 +263,6 @@ void MonCreateYACS::SetCaseName() _aCaseName=HOMARD_QT_COMMUN::SelectionArbreEtude(QString("CasHomard"), 1); if (_aCaseName == QString("")) { raise();return;}; } -/* MESSAGE ("appel de GetCase avec _aCaseName = " << _aCaseName.toStdString() );*/ - aCase = myHomardGen->GetCase(_aCaseName.toStdString().c_str()); LECaseName->setText(_aCaseName); } // ------------------------------------------------------------------------ diff --git a/src/HOMARDGUI/MonCreateYACS.h b/src/HOMARDGUI/MonCreateYACS.h index 39043f20..2f1d8843 100644 --- a/src/HOMARDGUI/MonCreateYACS.h +++ b/src/HOMARDGUI/MonCreateYACS.h @@ -35,11 +35,11 @@ class MonCreateYACS : public QDialog, public Ui_CreateYACS Q_OBJECT public: - MonCreateYACS( QWidget* parent, bool modal, HOMARD::HOMARD_Gen_var myHomardGen, QString CaseName); + MonCreateYACS( bool modal, HOMARD::HOMARD_Gen_var myHomardGen, QString CaseName); virtual ~MonCreateYACS(); protected : - MonCreateYACS( QWidget* parent, HOMARD::HOMARD_Gen_var myHomardGen, QString CaseName); + MonCreateYACS( HOMARD::HOMARD_Gen_var myHomardGen, QString CaseName); QString _Name; QString _aCaseName; @@ -52,10 +52,10 @@ class MonCreateYACS : public QDialog, public Ui_CreateYACS bool Chgt; HOMARD::HOMARD_YACS_var aYACS; - HOMARD::HOMARD_Cas_var aCase ; HOMARD::HOMARD_Gen_var myHomardGen; virtual void InitConnect(); + virtual bool CreateOrUpdate(); public slots: virtual void SetNewName(); diff --git a/src/HOMARDGUI/MonEditYACS.cxx b/src/HOMARDGUI/MonEditYACS.cxx index 9986a305..99ff258b 100644 --- a/src/HOMARDGUI/MonEditYACS.cxx +++ b/src/HOMARDGUI/MonEditYACS.cxx @@ -32,10 +32,10 @@ using namespace std; herite de MonCreateYACS */ // ------------------------------------------------------------- -MonEditYACS::MonEditYACS ( QWidget* parent, bool modal, +MonEditYACS::MonEditYACS ( bool modal, HOMARD::HOMARD_Gen_var myHomardGen, QString Name ): - MonCreateYACS(parent, modal, myHomardGen, Name) + MonCreateYACS(myHomardGen, Name) { MESSAGE("Debut de MonEditYACS" << Name.toStdString().c_str()); setWindowTitle(QObject::tr("HOM_YACS_EDIT_WINDOW_TITLE")); @@ -56,25 +56,19 @@ void MonEditYACS::InitValEdit() LEName->setText(_Name); LEName->setReadOnly(true); - QString aCaseName = aYACS->GetCaseName(); - LECaseName->setText(aCaseName); + QString _aCaseName = aYACS->GetCaseName(); + LECaseName->setText(_aCaseName); LECaseName->setReadOnly(true); - PushDir->setVisible(0); + PBCaseName->setVisible(0); QString aScriptFile = aYACS->GetScriptFile(); LEScriptFile->setText(aScriptFile); - LEScriptFile->setReadOnly(true); - PushDir->setVisible(0); QString aDirName = aYACS->GetDirName(); LEDirName->setText(aDirName); - LEDirName->setReadOnly(true); - PushDir->setVisible(0); QString aMeshFile = aYACS->GetMeshFile(); LEMeshFile->setText(aMeshFile); - LEMeshFile->setReadOnly(true); - PushDir->setVisible(0); int Type=aYACS->GetType(); if(Type==1) { RBStatic->setChecked(true); } @@ -85,9 +79,32 @@ void MonEditYACS::InitValEdit() adjustSize(); } -// ------------------------------------- -bool MonEditYACS::PushOnApply() -// ------------------------------------- +// --------------------------------------------------- +bool MonEditYACS:: CreateOrUpdate() +//---------------------------------------------------- +// Modification du schema { + MESSAGE("CreateOrUpdate"); + + // Les donnees + QString aScriptFile=LEScriptFile->text().trimmed(); + if ( aScriptFile != _aScriptFile ) + { + _aScriptFile = aScriptFile ; + aYACS->SetScriptFile(CORBA::string_dup(_aScriptFile.toStdString().c_str())) ; + } + QString aDirName=LEDirName->text().trimmed(); + if ( aDirName != _aDirName ) + { + _aDirName = aDirName ; + aYACS->SetDirName(CORBA::string_dup(_aDirName.toStdString().c_str())) ; + } + QString aMeshFile=LEMeshFile->text().trimmed(); + if ( aMeshFile != _aMeshFile ) + { + _aMeshFile = aMeshFile ; + aYACS->SetMeshFile(CORBA::string_dup(_aMeshFile.toStdString().c_str())) ; + } + return true ; -}; +} diff --git a/src/HOMARDGUI/MonEditYACS.h b/src/HOMARDGUI/MonEditYACS.h index 232e4965..3b9d5f4a 100644 --- a/src/HOMARDGUI/MonEditYACS.h +++ b/src/HOMARDGUI/MonEditYACS.h @@ -32,14 +32,14 @@ class MonEditYACS : public MonCreateYACS { Q_OBJECT public: - MonEditYACS( QWidget* parent, bool modal, + MonEditYACS( bool modal, HOMARD::HOMARD_Gen_var myHomardGen, QString Name ); virtual ~MonEditYACS(); protected : virtual void InitValEdit(); - virtual bool PushOnApply(); + virtual bool CreateOrUpdate(); public slots: diff --git a/src/HOMARD_I/HOMARD_Cas_i.cxx b/src/HOMARD_I/HOMARD_Cas_i.cxx index b44f36b7..8338f814 100755 --- a/src/HOMARD_I/HOMARD_Cas_i.cxx +++ b/src/HOMARD_I/HOMARD_Cas_i.cxx @@ -283,25 +283,42 @@ void HOMARD_Cas_i::AddBoundaryGroup( const char* BoundaryName, const char* Group { MESSAGE ("AddBoundaryGroup : BoundaryName = "<< BoundaryName << ", Group = " << Group ); ASSERT( myHomardCas ); - // La frontiere est-elle deja enregistree pour ce cas ? + // A. La liste des frontiere+groupes const std::list& ListBoundaryGroup = myHomardCas->GetBoundaryGroup(); std::list::const_iterator it; - int existe = 0; + // B. La frontiere + // B.1. La frontiere est-elle deja enregistree pour ce cas ? + bool existe = false ; for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) { - if ( *it == BoundaryName ) - { existe = 1 ; } +// MESSAGE (".. Frontiere : "<< *it ); + if ( *it == BoundaryName ) { existe = true ; } it++ ; } - // Enregistrement de la frontiere dans la reference du cas - myHomardCas->AddBoundaryGroup( BoundaryName, Group ); - // Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas - if ( existe == 0 ) + // B.2. Pour une nouvelle frontiere, publication dans l'arbre d'etudes sous le cas + if ( !existe ) { char* CaseName = GetName() ; MESSAGE ( "AddBoundaryGroup : insertion de la frontiere dans l'arbre de " << CaseName ); _gen_i->PublishBoundaryUnderCase(CaseName, BoundaryName) ; } + // C. Le groupe est-il deja enregistre pour une frontiere de ce cas ? + for ( it = ListBoundaryGroup.begin(); it != ListBoundaryGroup.end(); it++ ) + { + std::string boun = *it ; + it++ ; +// MESSAGE (".. Group : "<< *it ); + if ( *it == Group ) + { INFOS ("Le groupe " << Group << " est deja associe a la frontiere " << boun) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid AddBoundaryGroup"; + throw SALOME::SALOME_Exception(es); + return ; + } + } + // D. Enregistrement du couple (frontiere,groupe) dans la reference du cas + myHomardCas->AddBoundaryGroup( BoundaryName, Group ); } //============================================================================= HOMARD::ListBoundaryGroupType* HOMARD_Cas_i::GetBoundaryGroup() diff --git a/src/HOMARD_I/HOMARD_Gen_i.cxx b/src/HOMARD_I/HOMARD_Gen_i.cxx index 5629b019..9bce3685 100755 --- a/src/HOMARD_I/HOMARD_Gen_i.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i.cxx @@ -1023,9 +1023,9 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIteratio return HOMARD::HOMARD_Iteration::_duplicate(myIteration); } //============================================================================= -HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* YACSName) +HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS) { - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName]; + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; ASSERT(!CORBA::is_nil(myYACS)); return HOMARD::HOMARD_YACS::_duplicate(myYACS); } @@ -3308,7 +3308,6 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt break ; } } - MESSAGE("Appel de PublishInStudyAttr pour name = "<object_to_string(theObject) ) ; return aResultSO._retn(); @@ -3316,10 +3315,9 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt //=========================================================================== void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder, SALOMEDS::SObject_var aResultSO, - const char* name, const char* value, const char* icone, const char* ior) + const char* name, const char* comment, const char* icone, const char* ior) { - MESSAGE("PublishInStudyAttr pour name = "<SetValue(value); + aCommentAttrib->SetValue(comment); } // Ajout de l'icone @@ -3380,6 +3378,31 @@ void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* Bo aStudyBuilder->CommitCommand(); +}; +//===================================================================================== +void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName) +{ + MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName ); + + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); + SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + ASSERT(!CORBA::is_nil(aYACSSO)); + + HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase))); + ASSERT(!CORBA::is_nil(aCaseSO)); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO); + aStudyBuilder->Addreference(aSubSO, aCaseSO); + + aStudyBuilder->CommitCommand(); + }; //============================================================================= void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) @@ -3514,24 +3537,8 @@ void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire) { // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); - if (CORBA::is_nil(myCurrentStudy)) - { - SALOME::ExceptionStruct es; - es.type = SALOME::BAD_PARAM; - es.text = "Invalid study context"; - throw SALOME::SALOME_Exception(es); - return ; - }; - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter]; - if (CORBA::is_nil(myIteration)) - { - SALOME::ExceptionStruct es; - es.type = SALOME::BAD_PARAM; - es.text = "Invalid iteration"; - throw SALOME::SALOME_Exception(es); - return ; - }; + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); if (CORBA::is_nil(myIteration)) { @@ -3548,7 +3555,7 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); // Pour les fichiers med, on affiche une icone de maillage -// Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte' +// Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte' // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n std::string icone ; std::string ior = " " ; @@ -3562,6 +3569,34 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No } // //============================================================================= +void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire) +{ +// MESSAGE (" PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + + SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid YACSStudy Object"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO); + std::string icone = "texte_2.png" ; + std::string ior = " " ; + PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ; + + aStudyBuilder->CommitCommand(); +} +// +//============================================================================= //============================================================================= // YACS //============================================================================= @@ -3572,16 +3607,16 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No // FileName : nom du fichier contenant le script de lancement du calcul // DirName : le repertoire de lancement des calculs du schéma //============================================================================= -HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* YACSName, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile) +HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile) { - INFOS ( "CreateYACSSchema : Schema YACS " << YACSName ); + INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS ); INFOS ( ". nomCas : " << nomCas); INFOS ( ". ScriptFile : " << ScriptFile); INFOS ( ". DirName : " << DirName); INFOS ( ". MeshFile : " << MeshFile); // A. Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(YACSName) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end()) + if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(nomYACS) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end()) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -3600,13 +3635,15 @@ HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* YACSName, co throw SALOME::SALOME_Exception(es); return 0; }; - myYACS->SetName( YACSName ) ; + myYACS->SetName( nomYACS ) ; // C. Enregistrement - myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName] = myYACS; + myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS] = myYACS; SALOMEDS::SObject_var aSO; - SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, YACSName); + SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, nomYACS); + + PublishCaseUnderYACS(nomYACS, nomCas); // D. Caracterisation myYACS->SetDirName( DirName ) ; @@ -3620,6 +3657,26 @@ HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* YACSName, co //============================================================================= // Ecriture d'un schema YACS //============================================================================= +CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS) +{ + INFOS ( "YACSWrite : Ecriture de " << nomYACS ); +// Le repertoire du cas + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); + std::string casename = myYACS->GetCaseName() ; + HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(casename.c_str()) ; + std::string dirnamecase = caseyacs->GetDirName() ; +// Le nom par defaut du fichier du schema + std::string YACSFile ; + YACSFile = dirnamecase + "/schema.xml" ; + + int codret = YACSWriteOnFile(nomYACS, YACSFile.c_str()) ; + + return codret ; +} +//============================================================================= +// Ecriture d'un schema YACS +//============================================================================= CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* YACSFile) { INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << YACSFile ); @@ -3651,6 +3708,8 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* YACSF HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ; std::string Iter0Name = myCase->GetIter0Name() ; MESSAGE (". Iter0Name = " << Iter0Name); + std::string MeshName = Iter0->GetMeshName(); + MESSAGE (". MeshName = " << MeshName); // D.2. L'iteration numero 1 HOMARD::listeIterFilles* maListe = Iter0->GetIterations(); int numberOfIter = maListe->length(); @@ -3690,7 +3749,15 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* YACSF // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD std::string YACSFile_base ; if ( getenv("HOMARD_ROOT_DIR") != NULL ) { YACSFile_base = getenv("HOMARD_ROOT_DIR") ; } - else { ASSERT("HOMARD_ROOT_DIR est inconnu." == 0) ; } + else + { + SALOME::ExceptionStruct es ; + es.type = SALOME::BAD_PARAM; + std::string text = "HOMARD_ROOT_DIR est inconnu." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + return 0; + } YACSFile_base += "/share/salome/resources/homard/yacs_01.xml" ; MESSAGE("YACSFile_base ="<> mot_cle ; // G.1.2. Le maillage initial if ( mot_cle == "DataInit_MeshFile" ) - { - myDriver->Texte_DataInit_MeshFile(MeshFile); - } + { myDriver->Texte_DataInit_MeshFile(MeshFile); } // G.1.3. Le script de lancement else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" ) - { - myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); - } + { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); } // G.1.4. Les options du cas - else if ( mot_cle == "HOMARD_Init_au_debut_Case_Options" ) - { - myDriver->Texte_HOMARD_Init_au_debut_Case_Options(pythonCas); - } + else if ( mot_cle == "Iter_1_Case_Options" ) + { myDriver->Texte_Iter_1_Case_Options(pythonCas); } // G.1.5. Execution de HOMARD : le repertoire du cas else if ( mot_cle == "HOMARD_Exec_DirName" ) + { myDriver->Texte_HOMARD_Exec_DirName(); } + // G.1.6. Execution de HOMARD : le nom du maillage + else if ( mot_cle == "HOMARD_Exec_MeshName" ) { - myDriver->Texte_HOMARD_Exec_DirName(); + myDriver->Texte_HOMARD_Exec_MeshName(MeshName); + std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ; + myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ; } - // G.1.6. Execution de HOMARD : les options de l'hypothese + // G.1.7. Execution de HOMARD : les options de l'hypothese else if ( mot_cle == "HOMARD_Exec_Hypo_Options" ) + { myDriver->Texte_python( pythonHypo, 3, "Hypo" ) ; } + // G.1.8. Zones et frontieres : les creations + else if ( mot_cle == "Iter_1" ) { - myDriver->Texte_python( pythonHypo, 3, "Hypo" ) ; - } - // G.1.7. Zones et frontieres : les creations - else if ( mot_cle == "HOMARD_Init_au_debut" ) - { - std::string texte_control = myDriver->Texte_HOMARD_Init_au_debut_control() ; + std::string texte_control = myDriver->Texte_Iter_1_control() ; if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; } texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ; myDriver->TexteAdd(texte_control); } - // G.1.8. Zones : les parametres + // G.1.9. Les parametres else if ( mot_cle == "PARAMETRES" ) - { - if ( TypeAdap == 0 ) - { myDriver->TexteAddParametres(); } - } + { myDriver->TexteAddParametres(); } // G.1.n. La ligne est recopiee telle quelle - else - { - myDriver->TexteAdd(ligne); - } + else { myDriver->TexteAdd(ligne); } } // G.2. Ecriture du texte dans le fichier if ( codret == 0 ) @@ -3767,6 +3825,11 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* YACSF delete myDriver; + // H. Publication du fichier dans l'arbre + + std::string Commentaire = "xml" ; + PublishFileUnderYACS(nomYACS, YACSFile, Commentaire.c_str()); + return codret ; } //============================================================================= @@ -3807,7 +3870,7 @@ std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHy int ZoneType = myZone->GetType(); MESSAGE ( "... ZoneType = " << ZoneType); std::string texte_control_0 ; - texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Zone(ZoneType, pythonStructure, methode, ZoneName ); + texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName ); texte_control += texte_control_0 ; // 5. Decalage iaux += 1 ; @@ -3866,7 +3929,7 @@ std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, int BoundaryType = myBoundary->GetType(); MESSAGE ( "... BoundaryType = " << BoundaryType); std::string texte_control_0 ; - texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Boundary(BoundaryType, pythonStructure, methode, BoundaryName ); + texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName ); texte_control += texte_control_0 ; // 5. Memorisation du traitement ListeBoundaryTraitees.push_back( BoundaryName ); @@ -4347,8 +4410,8 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin(); it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone) { - HOMARD::HOMARD_Zone_var maZone = (*it_zone).second; - CORBA::String_var dumpCorbaZone = maZone->GetDumpPython(); + HOMARD::HOMARD_Zone_var myZone = (*it_zone).second; + CORBA::String_var dumpCorbaZone = myZone->GetDumpPython(); std::string dumpZone = dumpCorbaZone.in(); MESSAGE (dumpZone<<"\n"); aScript += dumpZone; @@ -4424,6 +4487,24 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, aScript += dumpIter; } + + if (myContextMap[GetCurrentStudyID()]._mesYACSs.size() > 0) + { + MESSAGE (". Ecritures des schemas YACS"); + aScript += "#\n# Creation of the schemas YACS"; + aScript += "\n# ============================"; + } + std::map::const_iterator it_yacs; + for ( it_yacs = myContextMap[GetCurrentStudyID()]._mesYACSs.begin(); + it_yacs != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); ++it_yacs) + { + HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second; + CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython(); + std::string dumpYACS = dumpCorbaYACS.in(); + MESSAGE (dumpYACS<<"\n"); + aScript += dumpYACS; + } + MESSAGE (". Ecritures finales"); if( isMultiFile ) aScript += "\n\tpass"; diff --git a/src/HOMARD_I/HOMARD_Gen_i.hxx b/src/HOMARD_I/HOMARD_Gen_i.hxx index 1af594b5..66efe93f 100644 --- a/src/HOMARD_I/HOMARD_Gen_i.hxx +++ b/src/HOMARD_I/HOMARD_Gen_i.hxx @@ -179,14 +179,16 @@ public: CORBA::Boolean VerifieDir(const char* nomDir); - void PublishFileUnderIteration(const char* NomIter, const char* NomFich, - const char* Commentaire); + void PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire); + void PublishFileUnderYACS(const char* NomYACS, const char* NomFich, const char* Commentaire); void PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName); + void PublishCaseUnderYACS(const char* YACSName, const char* CaseName); void PublishResultInSmesh(const char* NomFich, CORBA::Long Option); void DeleteResultInSmesh(std::string NomFich, std::string MeshName); // YACS HOMARD::HOMARD_YACS_ptr CreateYACSSchema (const char* YACSName, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile); + CORBA::Long YACSWrite(const char* nomYACS); CORBA::Long YACSWriteOnFile(const char* nomYACS, const char* YACSFile); std::string YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver); std::string YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver); @@ -266,7 +268,7 @@ private: HOMARD::HOMARD_Zone_ptr theObject, const char* theName); virtual void PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder, SALOMEDS::SObject_var aResultSO, - const char* theName, const char* value, const char* icone, const char* ior); + const char* theName, const char* comment, const char* icone, const char* ior); PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject); diff --git a/src/HOMARD_I/HOMARD_YACS_i.cxx b/src/HOMARD_I/HOMARD_YACS_i.cxx index b5928a7a..2e197115 100644 --- a/src/HOMARD_I/HOMARD_YACS_i.cxx +++ b/src/HOMARD_I/HOMARD_YACS_i.cxx @@ -178,17 +178,9 @@ char* HOMARD_YACS_i::GetCaseName() CORBA::Long HOMARD_YACS_i::Write() { MESSAGE ( "Write : ecriture du schema"); - ASSERT( myHomardYACS ); -// -// Le repertoire du cas - std::string casename = GetCaseName() ; - HOMARD::HOMARD_Cas_ptr caseyacs = _gen_i->GetCase(casename.c_str()) ; - std::string dirnamecase = caseyacs->GetDirName() ; -// Le nom par defaut du fichier du schema - std::string YACSFile ; - YACSFile = dirnamecase + "/schema.xml" ; // - return WriteOnFile(YACSFile.c_str()) ; + char* nomYACS = GetName() ; + return _gen_i->YACSWrite(nomYACS) ; } //============================================================================= CORBA::Long HOMARD_YACS_i::WriteOnFile( const char* YACSFile )