.. _tui_create_iteration:
The iteration
-#############
+=============
.. index:: single: iteration
.. index:: single: hypothesis
The variables are described in :ref:`gui_create_iteration`.
Methods of the class homard
-***************************
+"""""""""""""""""""""""""""
+---------------------------------------------------------------+
+---------------------------------------------------------------+
+---------------------------------------------------------------+
Methods of both classes cas and iteration
-*****************************************
+"""""""""""""""""""""""""""""""""""""""""
+---------------------------------------------------------------+
+---------------------------------------------------------------+
+---------------------------------------------------------------+
Methods of the class iteration
-******************************
+""""""""""""""""""""""""""""""
General methods
-===============
+^^^^^^^^^^^^^^^
+---------------------------------------------------------------+
+---------------------------------------------------------------+
+---------------------------------------------------------------+
Information about the meshes
-============================
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+---------------------------------------------------------------+
+---------------------------------------------------------------+
+---------------------------------------------------------------+
Information about the field
-===========================
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+---------------------------------------------------------------+
+---------------------------------------------------------------+
| Returns the selected rank for the field |
+---------------------------------------------------------------+
+Miscellenaous
+^^^^^^^^^^^^^
+
++---------------------------------------------------------------+
++---------------------------------------------------------------+
+| .. module:: SetInfoCompute |
+| |
+| **SetInfoCompute(MessInfo)** |
+| Defines options to track the computation of the iteration |
+| |
+| - ``MessInfo`` : integer that drives prints, as a multiple|
+| of 2, 3 and 5 |
+| |
+| * 1 : nothing (default) |
+| * 2x : computational time |
+| * 3x : MED files |
+| * 5x : memory |
++---------------------------------------------------------------+
+| .. module:: GetInfoCompute |
+| |
+| **GetInfoCompute()** |
+| Returns the options to track the computation |
++---------------------------------------------------------------+
+
+
Example
-*******
+"""""""
.. index:: single: mesh;initial
To create the first iteration, the starting point is the iteration associated to the initial mesh. It is the one that defines the case.
Similar graphical input
-***********************
+"""""""""""""""""""""""
Look at :ref:`gui_create_iteration`
This box is type PresetNode's elementary node. Its only function is to initialize the variable MeshFile that contains the name of the file of the initial mesh.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 70-74
+ :lines: 38-42
Etude_Initialisation
====================
The python node StudyCreation initialize the SALOME study that is given through the output:
.. literalinclude:: ../files/yacs_01.xml
- :lines: 39-57
+ :lines: 44-62
The service SetCurrentStudy connects this study to an instance of HOMARD.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 58-63
+ :lines: 63-68
Tant_que_le_calcul_n_a_pas_converge
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: 155-182
+ :lines: 77-104
In this example, we must define:
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: 77-90
+ :lines: 105-118
../..
.. literalinclude:: ../files/yacs_01.xml
- :lines: 145-154
+ :lines: 173-182
One starts by analyzing the return of the computer code:
.. literalinclude:: ../files/yacs_01.xml
- :lines: 92-97
+ :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: 99-106
+ :lines: 127-134
Checking of the presence of the name of the result file in the dictionary of the results:
.. literalinclude:: ../files/yacs_01.xml
- :lines: 108-115
+ :lines: 136-143
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.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 117-135
+ :lines: 145-163
Lastly, it is checked that a maximum nomber of adaptations is not exceeded:
.. literalinclude:: ../files/yacs_01.xml
- :lines: 137-142
+ :lines: 165-170
Use this scheme
<property name="container_name" value="FactoryServer"/>
<property name="name" value="localhost"/>
</container>
+ <datanode name="DataInit">
+ <parameter name="MeshFile" type="string">
+ <value><string>/scratch/D68518/HOMARD_SVN/trunk/training/tet_aster_ther/maill.00.med</string></value>
+ </parameter>
+ </datanode>
<bloc name="Etude_Initialisation">
<inline name="StudyCreation">
<script><code><![CDATA[
<tonode>SetCurrentStudy</tonode> <toport>theStudy</toport>
</datalink>
</bloc>
- <datanode name="DataInit">
- <parameter name="MeshFile" type="string">
- <value><string>/scratch/D68518/HOMARD_SVN/trunk/training/tet_aster_ther/maill.00.med</string></value>
- </parameter>
- </datanode>
<while name="Tant_que_le_calcul_n_a_pas_converge">
<bloc name="Alternance_Calcul_HOMARD">
+ <inline name="Calcul">
+ <script><code><![CDATA[
+import sys
+import os
+# REPBASE : le repertoire de base de l'application
+REPBASE = os.environ["HOMARD_TRAINING"]
+rep_calc = os.path.join(REPBASE, "tet_aster_ther")
+rep_script = os.path.join(REPBASE, "script")
+sys.path.append(rep_script)
+from LanceCas import LanceCas
+#
+argu = ["-v"]
+argu.append("--rep_calc=" + rep_calc)
+argu.append("--numero=%d" % numCalc)
+argu.append("--mesh_file=" + MeshFile)
+#
+LanceCas_A = LanceCas(argu)
+#
+Error, message_erreur, dico_resu = LanceCas_A.calcul ()
+#
+dico_resu["rep_calc"] = rep_calc
+#
+]]></code></script>
+ <inport name="numCalc" type="int"/>
+ <inport name="MeshFile" type="string"/>
+ <outport name="Error" type="int"/>
+ <outport name="dico_resu" type="pyobj"/>
+ </inline>
<inline name="Analyse">
<script><code><![CDATA[
global NumCalc
<outport name="FileName" type="string"/>
<outport name="MessInfo" type="string"/>
</inline>
- <inline name="Calcul">
- <script><code><![CDATA[
-import sys
-import os
-# REPBASE : le repertoire de base de l'application
-REPBASE = os.environ["HOMARD_TRAINING"]
-rep_calc = os.path.join(REPBASE, "tet_aster_ther")
-rep_script = os.path.join(REPBASE, "script")
-sys.path.append(rep_script)
-from LanceCas import LanceCas
-#
-argu = ["-v"]
-argu.append("--rep_calc=" + rep_calc)
-argu.append("--numero=%d" % numCalc)
-argu.append("--mesh_file=" + MeshFile)
-#
-LanceCas_A = LanceCas(argu)
-#
-Error, message_erreur, dico_resu = LanceCas_A.calcul ()
-#
-dico_resu["rep_calc"] = rep_calc
-#
-]]></code></script>
- <inport name="numCalc" type="int"/>
- <inport name="MeshFile" type="string"/>
- <outport name="Error" type="int"/>
- <outport name="dico_resu" type="pyobj"/>
- </inline>
<switch name="Adaptation" select="0">
<default>
<bloc name="Arret_boucle">
</bloc>
</case>
</switch>
- <control> <fromnode>Analyse</fromnode> <tonode>Adaptation</tonode> </control>
<control> <fromnode>Calcul</fromnode> <tonode>Analyse</tonode> </control>
+ <control> <fromnode>Analyse</fromnode> <tonode>Adaptation</tonode> </control>
<datalink control="false">
<fromnode>Analyse</fromnode> <fromport>Error</fromport>
<tonode>Adaptation</tonode> <toport>select</toport>
]]></code></script>
<inport name="MessInfo" type="string"/>
</inline>
- <control> <fromnode>Etude_Initialisation</fromnode> <tonode>Tant_que_le_calcul_n_a_pas_converge</tonode> </control>
<control> <fromnode>DataInit</fromnode> <tonode>Etude_Initialisation</tonode> </control>
+ <control> <fromnode>Etude_Initialisation</fromnode> <tonode>Tant_que_le_calcul_n_a_pas_converge</tonode> </control>
<control> <fromnode>Tant_que_le_calcul_n_a_pas_converge</fromnode> <tonode>Bilan</tonode> </control>
<datalink control="false">
<fromnode>DataInit</fromnode> <fromport>MeshFile</fromport>
<tonode>Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Analyse</tonode><toport>ErrCalc</toport>
<value><int>0</int></value>
</parameter>
- <presentation name="Etude_Initialisation" x="174.906" y="32" width="325" height="99" expanded="1" expx="174.906" expy="32" expWidth="325" expHeight="99" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateCase" x="4" y="32" width="158" height="117" expanded="1" expx="4" expy="32" expWidth="158" expHeight="117" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec" x="504.042" y="32" width="158" height="144" expanded="1" expx="504.042" expy="32" expWidth="158" expHeight="144" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut" x="5" y="59" width="483.5" height="153" expanded="1" expx="5" expy="59" expWidth="483.5" expHeight="153" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="704" height="977" expanded="1" expx="0" expy="0" expWidth="704" expHeight="977" shownState="0"/>
<presentation name="DataInit" x="4" y="32" width="158" height="63" expanded="1" expx="4" expy="32" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD" x="10" y="59" width="682.042" height="778" expanded="1" expx="10" expy="59" expWidth="682.042" expHeight="778" shownState="0"/>
+ <presentation name="Etude_Initialisation" x="175" y="32" width="325" height="99" expanded="1" expx="175" expy="32" expWidth="325" expHeight="99" shownState="0"/>
+ <presentation name="Etude_Initialisation.StudyCreation" x="4" y="32" width="158" height="63" expanded="1" expx="4" expy="32" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="Etude_Initialisation.SetCurrentStudy" x="163" y="32" width="158" height="63" expanded="1" expx="163" expy="32" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge" x="4" y="132" width="696" height="841" expanded="1" expx="4" expy="132" expWidth="696" expHeight="841" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD" x="4" y="59" width="682" height="778" expanded="1" expx="10" expy="59" expWidth="682" expHeight="778" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Calcul" x="4" y="32" width="158" height="90" expanded="1" expx="4" expy="32" expWidth="158" expHeight="90" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation" x="4" y="204" width="674.042" height="570" expanded="1" expx="4" expy="204" expWidth="674.042" expHeight="570" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Analyse" x="181" y="32" width="158" height="171" expanded="1" expx="181" expy="32" expWidth="158" expHeight="171" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation" x="4" y="204" width="674" height="570" expanded="1" expx="4" expy="204" expWidth="674" expHeight="570" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.default_Arret_boucle" x="4" y="59" width="166" height="153" expanded="1" expx="4" expy="59" expWidth="166" expHeight="153" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.default_Arret_boucle.Arret" x="4" y="32" width="158" height="117" expanded="1" expx="4" expy="32" expWidth="158" expHeight="117" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD" x="4" y="213" width="666" height="353" expanded="1" expx="4" expy="213" expWidth="666" expHeight="353" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation" x="4" y="32" width="492" height="316" expanded="1" expx="4" expy="32" expWidth="492" expHeight="316" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut" x="4" y="59" width="483" height="153" expanded="1" expx="4" expy="59" expWidth="483" expHeight="153" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateCase" x="4" y="32" width="158" height="117" expanded="1" expx="4" expy="32" expWidth="158" expHeight="117" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.Case_Options" x="163" y="32" width="158" height="63" expanded="1" expx="163" expy="32" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD" x="4" y="213" width="666.042" height="353" expanded="1" expx="4" expy="213" expWidth="666.042" expHeight="353" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation" x="5" y="33" width="492.5" height="316" expanded="1" expx="5" expy="33" expWidth="492.5" expHeight="316" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateHypothesis" x="322" y="32" width="158" height="63" expanded="1" expx="322" expy="32" expWidth="158" expHeight="63" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_HOMARD_Init_ensuite" x="4" y="213" width="325" height="99" expanded="1" expx="4" expy="213" expWidth="325" expHeight="99" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_HOMARD_Init_ensuite.LastIteration" x="4" y="32" width="158" height="63" expanded="1" expx="4" expy="32" expWidth="158" expHeight="63" shownState="0"/>
<presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.default_HOMARD_Init_ensuite.GetHypothesis" x="163" y="32" width="158" height="63" expanded="1" expx="163" expy="32" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut.CreateHypothesis" x="321.5" y="32" width="158" height="63" expanded="1" expx="321.5" expy="32" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Bilan" x="535.69" y="36.4207" width="158" height="63" expanded="1" expx="535.69" expy="36.4207" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge" x="4" y="132" width="696.042" height="841" expanded="1" expx="4" expy="132" expWidth="696.042" expHeight="841" shownState="0"/>
- <presentation name="Etude_Initialisation.StudyCreation" x="4" y="32" width="158" height="63" expanded="1" expx="4" expy="32" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Etude_Initialisation.SetCurrentStudy" x="163" y="32" width="158" height="63" expanded="1" expx="163" expy="32" expWidth="158" expHeight="63" shownState="0"/>
- <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Analyse" x="181.788" y="32" width="158" height="171" expanded="1" expx="181.788" expy="32" expWidth="158" expHeight="171" shownState="0"/>
- <presentation name="__ROOT__" x="0" y="0" width="704.042" height="977" expanded="1" expx="0" expy="0" expWidth="704.042" expHeight="977" shownState="0"/>
+ <presentation name="Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Exec" x="504" y="32" width="158" height="144" expanded="1" expx="504" expy="32" expWidth="158" expHeight="144" shownState="0"/>
+ <presentation name="Bilan" x="535" y="32" width="158" height="63" expanded="1" expx="535" expy="36" expWidth="158" expHeight="63" shownState="0"/>
</proc>
Cette boîte est un noeud élémentaire de type PresetNode. Sa seule fonction est d'initialiser la variable MeshFile qui contient le nom du fichier du maillage initial.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 70-74
+ :lines: 38-42
Etude_Initialisation
====================
Le noeud python StudyCreation sert à initialiser l'étude SALOME qui est fournie en sortie :
.. literalinclude:: ../files/yacs_01.xml
- :lines: 39-57
+ :lines: 44-62
Le service SetCurrentStudy affecte cette étude à une instance de HOMARD.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 58-63
+ :lines: 63-68
Tant_que_le_calcul_n_a_pas_converge
Cette boîte est un noeud python qui va piloter le calcul. En entrée, on trouve le numéro du calcul (0 au départ) et le nom du fichier qui contient le maillage sur lequel calculer. En sortie, on trouve un entier qui représente l'erreur sur ce calcul (0 si tout va bien) et un dictionnaire python rassemblant les résultats du calcul. Le corps du noeud est constitué par le lancement d'un script python qui active le calcul.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 155-182
+ :lines: 77-104
Dans cet exemple, il faut définir :
Le bloc Analyse est un script python qui assure le contrôle complet du processus en examinant successivement les causes d'erreur possible.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 77-90
+ :lines: 105-118
../..
.. literalinclude:: ../files/yacs_01.xml
- :lines: 145-154
+ :lines: 173-182
On commence par analyser le retour du code de calcul :
.. literalinclude:: ../files/yacs_01.xml
- :lines: 92-97
+ :lines: 120-125
Vérification de la présence du nom du maillage dans le dictionnaire des résultats :
.. literalinclude:: ../files/yacs_01.xml
- :lines: 99-106
+ :lines: 127-134
Vérification de la présence du nom du fichier de résultats dans le dictionnaire des résultats :
.. literalinclude:: ../files/yacs_01.xml
- :lines: 108-115
+ :lines: 136-143
Vérification de la convergence. Cela suppose que la valeur à tester est présente dans le dictionnaire sous la clé 'V00'. Ici, on a mis en place un test sur la variation de la valeur d'un calcul à l'autre. Au premier passage, on ne teste rien. Aux passages suivants, on teste si la variation relative est inférieure à 1 millième. On aurait pu mettre en place un test absolu si on avait récupéré un niveau global d'erreur par exemple.
.. literalinclude:: ../files/yacs_01.xml
- :lines: 117-135
+ :lines: 145-163
Enfin, on vérifie que l'on ne dépasse pas un nomber maximal d'adaptations :
.. literalinclude:: ../files/yacs_01.xml
- :lines: 137-142
+ :lines: 165-170
Utiliser ce schéma