Salome HOME
Création automatique de schémas YACS à partir d'un cas
authornicolas <nicolas>
Tue, 10 Sep 2013 09:12:25 +0000 (09:12 +0000)
committernicolas <nicolas>
Tue, 10 Sep 2013 09:12:25 +0000 (09:12 +0000)
21 files changed:
doc/en/divers.rst
doc/en/tui_create_case.rst
doc/files/yacs_01.xml
doc/fr/divers.rst
doc/fr/tui_create_case.rst
idl/HOMARD_Cas.idl
idl/HOMARD_Gen.idl
resources/Makefile.am
src/HOMARD/HOMARD_Hypothesis.cxx
src/HOMARD/HOMARD_Iteration.cxx
src/HOMARD/HOMARD_Zone.cxx
src/HOMARD/HomardDriver.cxx
src/HOMARD/HomardDriver.hxx
src/HOMARD/Makefile.am
src/HOMARD/YACSDriver.cxx [new file with mode: 0644]
src/HOMARD/YACSDriver.hxx [new file with mode: 0644]
src/HOMARDGUI/Makefile.am
src/HOMARD_I/HOMARD_Cas_i.cxx
src/HOMARD_I/HOMARD_Cas_i.hxx
src/HOMARD_I/HOMARD_Gen_i.cxx
src/HOMARD_I/HOMARD_Gen_i.hxx

index 7fc39e01f1899c506edc03d503c0f3ee39d66c5b..28d4c90ca9187ff96185a8f2fd51fcfc79fed625 100644 (file)
@@ -48,3 +48,5 @@ SALOME VERSION 7.2.1 :
    - English documentation
    - Addition of a function:
      ``iter.SetInfoCompute(MessInfo)`` : gives options to track the computation (see :ref:`tui_create_iteration`)
+   - Automatic creation of YACS schema:
+     ``case.WriteYACSSchema(ScriptFile, DirName, MeshFile)`` : writes a schema YACS relative to the case (see :ref:`tui_create_case`)
index 575a8d7bf5f42527ca270d377c7f95105f64b6c6..2f6e2b2598d529b3ad7e38375633a502b6d5d286 100644 (file)
@@ -89,6 +89,7 @@ Creation of a case by pursuit of a computed iteration
 
 Methods of the class cas
 ************************
+.. index:: single: yacs
 
 +---------------------------------------------------------------+
 +---------------------------------------------------------------+
@@ -181,6 +182,17 @@ Methods of the class cas
 |         * 0: corresponds to an initial mesh                   |
 |         * other value: pursuit of an iteration with number n  |
 +---------------------------------------------------------------+
+| .. module:: WriteYACSSchema                                   |
+|                                                               |
+| **WriteYACSSchema(ScriptFile, DirName, MeshFile)**            |
+|     Writes a schema YACS relative to the case.                |
+|                                                               |
+|     - ``ScriptFile`` : name of the file that contains the     |
+|       script to launch the computation                        |
+|     - ``DirName`` : the directory for the computation         |
+|     - ``MeshFile`` : name of the file that contains the mesh  |
+|       for the very first computation                          |
++---------------------------------------------------------------+
 
 Advanced options
 ****************
index 423585458626d18ba7b72ff2aa4d9b914c5fc082..9b299b2b80b0d9e95b8b9127f2296427eb1b77de 100644 (file)
@@ -111,7 +111,7 @@ NumCalcP1 = NumCalc + 1
 MeshName = " "
 FileName = " "
 #
-NbCalcMax = 50
+NbCalcMax = 5
 #
 MessInfo = None
 Error = 0
index cb5794951c85569e3398721dc512b4c6dfd94bb3..ad2e6b54bcd336713034187d354b907e4c99e76d 100644 (file)
@@ -48,6 +48,8 @@ SALOME VERSION 7.2.1 :
    - Documentation en anglais
    - Ajout de fonctions :
      ``iter.SetInfoCompute(MessInfo)`` : précise des options pour suivre le calcul de l'itération (voir :ref:`tui_create_iteration`)
+   - Creation automatique de schéma YACS :
+     ``case.WriteYACSSchema(ScriptFile, DirName, MeshFile)`` : écrit un schéma YACS correspondant au cas (voir :ref:`tui_create_case`)
 
 
 
index ea05eae5b764d9158c312811396cf797c99be64b..67db96afb02a64312682e24923744b21c68cb0bf 100644 (file)
@@ -91,6 +91,7 @@ Cr
 
 Méthodes de la classe cas
 """""""""""""""""""""""""
+.. index:: single: yacs
 
 +---------------------------------------------------------------+
 +---------------------------------------------------------------+
@@ -181,6 +182,18 @@ M
 |         * 0 : correspond à un maillage initial                |
 |         * autre valeur : poursuite d'une itération de numéro n|
 +---------------------------------------------------------------+
+| .. module:: WriteYACSSchema                                   |
+|                                                               |
+| **WriteYACSSchema(ScriptFile, DirName, MeshFile)**            |
+|     Ecrit un schéma YACS correspondant au cas.                |
+|                                                               |
+|     - ``ScriptFile`` : nom du fichier contenant le script de  |
+|       lancement du calcul                                     |
+|     - ``DirName`` : le repertoire de lancement des calculs    |
+|       du schéma                                               |
+|     - ``MeshFile`` : nom du fichier contenant le maillage pour|
+|       le premier calcul                                       |
++---------------------------------------------------------------+
 
 Les options avancées
 ^^^^^^^^^^^^^^^^^^^^
index d7a1220eb04d7de01abfb0111eba440e355a402d..747b4859342934e383656431444c891b02af810c 100644 (file)
@@ -90,6 +90,11 @@ module HOMARD
 
     void     AddIteration (in string IterName)             raises (SALOME::SALOME_Exception);
 
+// YACS
+    long     WriteYACSSchema(in string ScriptFile, in string DirName, in string MeshFile)
+                                                           raises (SALOME::SALOME_Exception);
+
+
   };
 };
 #endif
index 3becace8b9c8e23dcbac9f7fd3403bb7c50ef94b..49192eaa05b61b98664d0ae244bfa45bf78504c3 100644 (file)
@@ -44,6 +44,8 @@ module HOMARD
 // A. Les methodes qui suivent sont celles que l'on retrouvera dans
 //    le fichier resources/HOMARDCatalog.xml.in pour definir le composant HOMARD dans YACS
 //    A priori, ce sont les seules sont l'utilisateur doit connaitre l'existence.
+//    ATTENTION : si les noms des arguments changent dans les Createxxxx, il faudra les changer
+//                dans YACSDriver pour assurer la coherence
 //
 // A.1. Les creations
 //
@@ -183,6 +185,10 @@ module HOMARD
     void  PublishResultInSmesh(in string FileName, in long Option)
                                                            raises (SALOME::SALOME_Exception);
 
+//
+    long   WriteYACSSchema(in string CaseName, in string ScriptFile, in string DirName, in string MeshFile)
+                                                           raises (SALOME::SALOME_Exception);
+
   };
 };
 
index 45ad93fb4a37ba440da1044ed64f75732facba74..25d3f461982ab617e0d923b09faf5c828a65a952 100644 (file)
@@ -64,6 +64,7 @@ dist_salomeres_DATA =   \
        texte_2.png \
        triangle.png \
        whatis.png \
+       yacs_01.xml \
        zone_boxdxyz.png \
        zone_boxdxyz_2.png \
        zone_icone.png \
index 65f742a64d3c253c744b566bab9863fff675ffbe..a3ca10fe7abceb1238e578d67203178eb8faa7cf 100644 (file)
@@ -385,7 +385,7 @@ void HOMARD_Hypothesis::UnLinkIteration( const char* NomIteration )
   if ( it != _ListIter.end() )
   {
     MESSAGE ("Dans UnLinkIteration pour " << NomIteration) ;
-    _ListIter.erase( it ) ;
+    it = _ListIter.erase( it ) ;
   }
 }
 //=============================================================================
@@ -402,20 +402,28 @@ const std::list<std::string>& HOMARD_Hypothesis::GetIterations() const
 void HOMARD_Hypothesis::AddZone( const char* NomZone, int TypeUse )
 {
   MESSAGE ("Dans AddZone pour " << NomZone) ;
+// On commence par la supprimer au cas ou elle aurait deja ete inseree
+// Cela peut se produire dans un schema YACS quand on repasse plusieurs fois par la
+// definition de l'hypothese
+  SupprZone( NomZone ) ;
+// Insertion veritable
+// . Nom de la zone
   _ListZone.push_back( std::string( NomZone ) );
+// . Usage de la zone
   std::stringstream saux1 ;
   saux1 << TypeUse ;
-  std::string saux2 = saux1.str() ;
-  _ListZone.push_back( saux2 );
+  _ListZone.push_back( saux1.str() );
 }
 //=============================================================================
 void HOMARD_Hypothesis::SupprZone( const char* NomZone )
 {
   MESSAGE ("Dans SupprZone pour " << NomZone) ;
   std::list<std::string>::iterator it = find( _ListZone.begin(), _ListZone.end(), NomZone );
+// Attention a supprimer le nom de zone et le type d'usage
   if ( it != _ListZone.end() )
   {
-    _ListZone.erase( it );
+    it = _ListZone.erase( it );
+    it = _ListZone.erase( it );
   }
 }
 //=============================================================================
index e9ec47322c0fc9fbd930775a9af3275e559dd6d2..55166324f721ea42a1c8b7759b15f6b0e22a35df 100644 (file)
@@ -240,7 +240,7 @@ void HOMARD_Iteration::UnLinkNextIteration( const char* NomIteration )
   if ( it != _mesIterFilles.end() )
   {
     MESSAGE ("Dans UnLinkNextIteration pour " << NomIteration) ;
-    _mesIterFilles.erase( it ) ;
+    it = _mesIterFilles.erase( it ) ;
   }
 }
 //=============================================================================
index 2eb2d31bc0c8526a206dd213882786eb09643232..b0e862c2e552a1abceef7bde9ac3fb91ce6133b3 100644 (file)
@@ -314,7 +314,7 @@ void HOMARD_Zone::SupprHypo( const char* NomHypo )
   if ( it != _ListHypo.end() )
   {
     MESSAGE ("Dans SupprHypo pour " << NomHypo) ;
-    _ListHypo.erase( it ) ;
+    it = _ListHypo.erase( it ) ;
   }
 }
 //=============================================================================
index dc65e673689f44eb7f592608f45d5a95fcdd7d0e..04e810b8c43db196da761bb360af8bf9a8a85ee1 100644 (file)
@@ -19,9 +19,9 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+// Pilote l'ecriture du fichier de configuration pour lancer l'execution de HOMARD
 
 #include <cstring>
-// #include <string.h>
 #include <unistd.h>
 #include <sys/stat.h>
 
@@ -240,13 +240,11 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
 //
   std::stringstream saux1 ;
   saux1 << NumeZone ;
-  saux2 = saux1.str() ;
-  saux = "#\n# Zone numero " + saux2 + "\n" ;
+  saux = "#\n# Zone numero " + saux1.str() + "\n" ;
 //
   { std::stringstream saux1 ;
     saux1 << NumeZone << " " << ZoneTypeHOMARD ;
-    saux2 = saux1.str() ;
-    saux += "ZoRaType " + saux2 + "\n" ;
+    saux += "ZoRaType " + saux1.str() + "\n" ;
   }
 //
 // Cas du rectangle
@@ -257,23 +255,19 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "#Rectangle\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmin " + saux2 + "\n" ;
+      saux += "ZoRaXmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmax " + saux2 + "\n" ;
+      saux += "ZoRaXmax " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmin " + saux2 + "\n" ;
+      saux += "ZoRaYmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmax " + saux2 + "\n" ;
+      saux += "ZoRaYmax " + saux1.str() + "\n" ;
     }
   }
 //
@@ -283,23 +277,19 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "#Rectangle\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmin " + saux2 + "\n" ;
+      saux += "ZoRaXmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmax " + saux2 + "\n" ;
+      saux += "ZoRaXmax " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmin " + saux2 + "\n" ;
+      saux += "ZoRaYmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmax " + saux2 + "\n" ;
+      saux += "ZoRaYmax " + saux1.str() + "\n" ;
     }
   }
 //
@@ -309,23 +299,19 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "#Rectangle\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmin " + saux2 + "\n" ;
+      saux += "ZoRaXmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmax " + saux2 + "\n" ;
+      saux += "ZoRaXmax " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmin " + saux2 + "\n" ;
+      saux += "ZoRaYmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmax " + saux2 + "\n" ;
+      saux += "ZoRaYmax " + saux1.str() + "\n" ;
     }
   }
 //
@@ -336,33 +322,27 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "# Boite\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmin " + saux2 + "\n" ;
+      saux += "ZoRaXmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXmax " + saux2 + "\n" ;
+      saux += "ZoRaXmax " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmin " + saux2 + "\n" ;
+      saux += "ZoRaYmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYmax " + saux2 + "\n" ;
+      saux += "ZoRaYmax " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaZmin " + saux2 + "\n" ;
+      saux += "ZoRaZmin " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaZmax " + saux2 + "\n" ;
+      saux += "ZoRaZmax " + saux1.str() + "\n" ;
     }
   }
 //
@@ -373,13 +353,11 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXCen " + saux2 + "\n" ;
+      saux += "ZoRaXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYCen " + saux2 + "\n" ;
+      saux += "ZoRaYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x6 ;
@@ -390,8 +368,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     if ( ZoneType == 61 )
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x8 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaRayI " + saux2 + "\n" ;
+      saux += "ZoRaRayI " + saux1.str() + "\n" ;
     }
   }
   else if ( ZoneType == 32 or ZoneType == 62 )
@@ -399,13 +376,11 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXCen " + saux2 + "\n" ;
+      saux += "ZoRaXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYCen " + saux2 + "\n" ;
+      saux += "ZoRaYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x6 ;
@@ -416,8 +391,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     if ( ZoneType == 62 )
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x8 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaRayI " + saux2 + "\n" ;
+      saux += "ZoRaRayI " + saux1.str() + "\n" ;
     }
   }
   else if ( ZoneType == 33 or ZoneType == 63 )
@@ -425,13 +399,11 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXCen " + saux2 + "\n" ;
+      saux += "ZoRaXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYCen " + saux2 + "\n" ;
+      saux += "ZoRaYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x6 ;
@@ -442,8 +414,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     if ( ZoneType == 63 )
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x8 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaRayI " + saux2 + "\n" ;
+      saux += "ZoRaRayI " + saux1.str() + "\n" ;
     }
   }
 //
@@ -454,23 +425,19 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXCen " + saux2 + "\n" ;
+      saux += "ZoRaXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYCen " + saux2 + "\n" ;
+      saux += "ZoRaYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaZCen " + saux2 + "\n" ;
+      saux += "ZoRaZCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaRayo " + saux2 + "\n" ;
+      saux += "ZoRaRayo " + saux1.str() + "\n" ;
     }
   }
 //
@@ -482,33 +449,27 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     else                 { saux += "# Tuyau\n" ; }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXBas " + saux2 + "\n" ;
+      saux += "ZoRaXBas " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYBas " + saux2 + "\n" ;
+      saux += "ZoRaYBas " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaZBas " + saux2 + "\n" ;
+      saux += "ZoRaZBas " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaXAxe " + saux2 + "\n" ;
+      saux += "ZoRaXAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaYAxe " + saux2 + "\n" ;
+      saux += "ZoRaYAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaZAxe " + saux2 + "\n" ;
+      saux += "ZoRaZAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x6 ;
@@ -518,14 +479,12 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
     }
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x7 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaHaut " + saux2 + "\n" ;
+      saux += "ZoRaHaut " + saux1.str() + "\n" ;
     }
     if ( ZoneType == 7 )
     { std::stringstream saux1 ;
       saux1 << NumeZone << " " << x8 ;
-      saux2 = saux1.str() ;
-      saux += "ZoRaRayI " + saux2 + "\n" ;
+      saux += "ZoRaRayI " + saux1.str() + "\n" ;
     }
   }
 //
@@ -581,8 +540,7 @@ void HomardDriver::TexteField( const std::string FieldName, const std::string Fi
   {
     std::stringstream saux1 ;
     saux1 << ThreshR ;
-    saux2 = saux1.str() ;
-    _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
+    _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
   }
 //
   saux = " " ;
@@ -598,8 +556,7 @@ void HomardDriver::TexteField( const std::string FieldName, const std::string Fi
   {
     std::stringstream saux1 ;
     saux1 << ThreshC ;
-    saux2 = saux1.str() ;
-    _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
+    _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
   }
 //
   saux = " " ;
@@ -690,16 +647,14 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
 //
   { std::stringstream saux1 ;
     saux1 << NumeBoundary ;
-    saux2 = saux1.str() ;
-    saux += "FANom " + saux2 + " \"" + NameBoundary + "\"\n" ;
+    saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
   }
 //
 // Type de frontiere
 //
   { std::stringstream saux1 ;
     saux1 << NumeBoundary << " " << BoundaryType ;
-    saux2 = saux1.str() ;
-    saux += "FAType " + saux2 + "\n" ;
+    saux += "FAType " + saux1.str() + "\n" ;
   }
 //
 // Cas du cylindre
@@ -709,37 +664,31 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x0 ;
       saux2 = saux1.str() ;
-      saux += "FAXCen " + saux2 + "\n" ;
+      saux += "FAXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "FAYCen " + saux2 + "\n" ;
+      saux += "FAYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "FAZCen " + saux2 + "\n" ;
+      saux += "FAZCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "FAXAxe " + saux2 + "\n" ;
+      saux += "FAXAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "FAYAxe " + saux2 + "\n" ;
+      saux += "FAYAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "FAZAxe " + saux2 + "\n" ;
+      saux += "FAZAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x6 ;
-      saux2 = saux1.str() ;
-      saux += "FARayon " + saux2 + "\n" ;
+      saux += "FARayon " + saux1.str() + "\n" ;
     }
  }
 //
@@ -749,23 +698,19 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
   {
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "FAXCen " + saux2 + "\n" ;
+      saux += "FAXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "FAYCen " + saux2 + "\n" ;
+      saux += "FAYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "FAZCen " + saux2 + "\n" ;
+      saux += "FAZCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "FARayon " + saux2 + "\n" ;
+      saux += "FARayon " + saux1.str() + "\n" ;
     }
   }
 //
@@ -775,38 +720,31 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
   {
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "FAXAxe " + saux2 + "\n" ;
+      saux += "FAXAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "FAYAxe " + saux2 + "\n" ;
+      saux += "FAYAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "FAZAxe " + saux2 + "\n" ;
+      saux += "FAZAxe " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "FAAngle " + saux2 + "\n" ;
+      saux += "FAAngle " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "FAXCen " + saux2 + "\n" ;
+      saux += "FAXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "FAYCen " + saux2 + "\n" ;
+      saux += "FAYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x6 ;
-      saux2 = saux1.str() ;
-      saux += "FAZCen " + saux2 + "\n" ;
+      saux += "FAZCen " + saux1.str() + "\n" ;
     }
  }
 //
@@ -816,43 +754,35 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
   {
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x0 ;
-      saux2 = saux1.str() ;
-      saux += "FAXCen " + saux2 + "\n" ;
+      saux += "FAXCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x1 ;
-      saux2 = saux1.str() ;
-      saux += "FAYCen " + saux2 + "\n" ;
+      saux += "FAYCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x2 ;
-      saux2 = saux1.str() ;
-      saux += "FAZCen " + saux2 + "\n" ;
+      saux += "FAZCen " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x3 ;
-      saux2 = saux1.str() ;
-      saux += "FARayon " + saux2 + "\n" ;
+      saux += "FARayon " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x4 ;
-      saux2 = saux1.str() ;
-      saux += "FAXCen2 " + saux2 + "\n" ;
+      saux += "FAXCen2 " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x5 ;
-      saux2 = saux1.str() ;
-      saux += "FAYCen2 " + saux2 + "\n" ;
+      saux += "FAYCen2 " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x6 ;
-      saux2 = saux1.str() ;
-      saux += "FAZCen2 " + saux2 + "\n" ;
+      saux += "FAZCen2 " + saux1.str() + "\n" ;
     }
     { std::stringstream saux1 ;
       saux1 << NumeBoundary << " " << x7 ;
-      saux2 = saux1.str() ;
-      saux += "FARayon2 " + saux2 + "\n" ;
+      saux += "FARayon2 " + saux1.str() + "\n" ;
     }
  }
 //
@@ -917,14 +847,12 @@ void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldN
     {
       std::stringstream saux1 ;
       saux1 << _TimeStep ;
-      std::string saux2 = saux1.str() ;
-      _Texte += "CCChaPdT " + saux + " " + saux2  + "\n" ;
+      _Texte += "CCChaPdT " + saux + " " + saux1.str()  + "\n" ;
     }
     {
       std::stringstream saux1 ;
       saux1 << _Rank ;
-      std::string saux2 = saux1.str() ;
-      _Texte += "CCChaNuO " + saux + " " + saux2  + "\n" ;
+      _Texte += "CCChaNuO " + saux + " " + saux1.str()  + "\n" ;
     }
   }
 }
@@ -943,8 +871,7 @@ void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int Ada
     _Texte += "# Niveaux extremes\n" ;
     { std::stringstream saux1 ;
       saux1 << NivMax ;
-      std::string saux2 = saux1.str() ;
-      _Texte += "NiveauMa " + saux2 + "\n" ;
+      _Texte += "NiveauMa " + saux1.str() + "\n" ;
     }
   }
   if ( DiamMin > 0 )
@@ -952,8 +879,7 @@ void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int Ada
     _Texte += "# Diametre minimal\n" ;
     { std::stringstream saux1 ;
       saux1 << DiamMin ;
-      std::string saux2 = saux1.str() ;
-      _Texte += "DiametMi " + saux2  + "\n" ;
+      _Texte += "DiametMi " + saux1.str()  + "\n" ;
     }
   }
   if ( AdapInit != 0 )
@@ -965,8 +891,7 @@ void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int Ada
     _Texte += " des regions sans indicateur\n" ;
     { std::stringstream saux1 ;
       saux1 << AdapInit ;
-      std::string saux2 = saux1.str() ;
-      _Texte += "AdapInit " + saux2 + "\n" ;
+      _Texte += "AdapInit " + saux1.str() + "\n" ;
     }
   }
   if ( LevelOutput != 0 )
@@ -985,8 +910,7 @@ void HomardDriver::TexteInfoCompute( int MessInfo )
      _Texte += "# Messages d'informations\n" ;
     { std::stringstream saux1 ;
       saux1 << MessInfo ;
-      std::string saux2 = saux1.str() ;
-      _Texte += "MessInfo " + saux2  + "\n" ;
+      _Texte += "MessInfo " + saux1.str()  + "\n" ;
     }
    }
 }
index 55f8180f46fb54c8c5e6e5ade96bcf675facf9f1..f98c11af0cec2f62503345a76f11841284ab110d 100644 (file)
@@ -19,8 +19,8 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-# ifndef __HOMARDDRIVER_H__
-# define __HOMARDDRIVER_H__
+# ifndef _HOMARDDRIVER_HXX_
+# define _HOMARDDRIVER_HXX_
 
 #include <iostream>
 #include <fstream>
@@ -58,19 +58,9 @@ public:
   void        TexteFieldInterpName( int NumeChamp, const std::string FieldName );
   void        TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput );
   void        TexteInfoCompute( int MessInfo );
-  void        CloseFichier();
   //
   int         ExecuteHomard(int option);
   //
-  bool        LireFichier();
-  bool        EcrireFichier();
-  void        SetTexte( const std::string texte );
-  std::string GetTexte();
-  std::string GetFichierInfo();
-  std::string GetFichierBasic();
-  std::string GetFichierResultMed();
-  std::string GetFichierHomard();
-  int         GetFichierNumeroIter();
 
 public:
   std::string _HOMARD_Exec;
@@ -85,8 +75,6 @@ public:
   int         _Rank;
   bool _bLu;
 
-private :
-  std::string GetStringInTexte( std::string chaineCherchee, int longueur = 9 );
 };
 
-# endif         /* # ifndef __HOMARDDRIVER_H__ */
+# endif         /* # ifndef _HOMARDDRIVER_HXX_ */
index 62fc27cb05b4b9704fe9fa48dc20d08701f38897..c3df60cd5b41ee11b339d6e46769caa78a401e23 100755 (executable)
@@ -31,7 +31,8 @@ salomeinclude_HEADERS = \
        HOMARD_Zone.hxx \
        HOMARD_Gen.hxx \
        HOMARD_DriverTools.hxx \
-       HomardDriver.hxx
+       HomardDriver.hxx \
+       YACSDriver.hxx
 
 # Libraries targets
 lib_LTLIBRARIES = libHOMARDImpl.la
@@ -43,7 +44,8 @@ dist_libHOMARDImpl_la_SOURCES = \
        HOMARD_Zone.cxx \
        HOMARD_Gen.cxx \
        HOMARD_DriverTools.cxx \
-       HomardDriver.cxx
+       HomardDriver.cxx \
+       YACSDriver.cxx
 
 libHOMARDImpl_la_CPPFLAGS = \
        $(KERNEL_CXXFLAGS)
diff --git a/src/HOMARD/YACSDriver.cxx b/src/HOMARD/YACSDriver.cxx
new file mode 100644 (file)
index 0000000..f48fb7e
--- /dev/null
@@ -0,0 +1,419 @@
+//  HOMARD HOMARD : implementation of HOMARD idl descriptions
+//
+// Copyright (C) 2011-2013  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// Pilote l'ecriture du fichier xml pour lancer un schema YACS
+
+#include <cstring>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "Utils_SALOME_Exception.hxx"
+#include "utilities.h"
+#include "YACSDriver.hxx"
+
+//=============================================================================
+//=============================================================================
+YACSDriver::YACSDriver(const std::string YACSFile, const std::string DirName):
+  _YACSFile( "" ), _DirName( "" ),
+  _Texte( "" ),
+  _Texte_parametres( "" ),
+  _bLu( false )
+{
+  MESSAGE("YACSFile = "<<YACSFile<<", DirName ="<<DirName);
+  _YACSFile = YACSFile;
+  _DirName = DirName;
+}
+//=============================================================================
+//=============================================================================
+YACSDriver::~YACSDriver()
+{
+}
+//===============================================================================
+// Ajout d'une ligne simple
+//===============================================================================
+void YACSDriver::TexteAdd( const std::string ligne )
+{
+//   MESSAGE("TexteAdd, ligne ="<<ligne);
+//
+  _Texte += ligne + "\n" ;
+//
+}
+//===============================================================================
+// Nom du fichier du maillage initial
+//===============================================================================
+void YACSDriver::Texte_DataInit_MeshFile( const std::string Meshfile )
+{
+  MESSAGE("TexteInitMeshfile, Meshfile ="<<Meshfile);
+//
+  _Texte += "         <value><string>" ;
+  _Texte += Meshfile ;
+  _Texte += "</string></value>\n" ;
+//
+}
+//===============================================================================
+// Le repertoire de calcul
+// Le script de lancement
+//===============================================================================
+void YACSDriver::Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName )
+{
+  MESSAGE("Texte_Alternance_Calcul_HOMARD_Calcul, FileName : "<<FileName);
+//
+  int position = FileName.find_last_of( '/' ) ;
+  std::string nomfic = FileName.substr( position+1 ) ;
+  position = nomfic.find_last_of( '.' ) ;;
+  nomfic = nomfic.substr( 0, position ) ;
+  MESSAGE("nomfic : "<<nomfic) ;
+//
+  _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" ;
+//
+}
+//===============================================================================
+// Les options du cas
+//===============================================================================
+void YACSDriver::Texte_HOMARD_Init_au_debut_Case_Options( const std::string pythonTexte )
+{
+  MESSAGE("Texte_HOMARD_Init_au_debut_Case_Options, pythonTexte\n"<<pythonTexte);
+//
+  _Texte += "DirName = \"" + _DirName + "/HOMARD\"\n" ;
+  _Texte += "Case.SetDirName(DirName)\n" ;
+
+  Texte_python( pythonTexte, 1, "Case" ) ;
+//
+}
+//===============================================================================
+// La description des zones
+// ZoneType : le type de la zone
+// pythonZone : le python correspondant a la zone
+// methode : methode associee a la creation de la zone
+// ZoneName : nom de la zone
+// noeud_1 : noeud de depart
+//===============================================================================
+std::string YACSDriver::Texte_HOMARD_Init_au_debut_Zone( int ZoneType, const std::string pythonZone, const std::string methode, const std::string ZoneName, const std::string noeud_1 )
+{
+  MESSAGE("Texte_HOMARD_Init_au_debut_Zone, ZoneType = "<<ZoneType<<", pythonZone = "<<pythonZone);
+  MESSAGE("methode = "<<methode<<", ZoneName = "<<ZoneName<<", noeud_1 = "<<noeud_1 );
+//
+// 1. Le nom du noeud
+  std::string noeud_2 = methode + "_" + ZoneName ;
+  std::string node = "Tant_que_le_calcul_n_a_pas_converge.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_HOMARD_Init_au_debut." ;
+  node += noeud_2 ;
+// 2. Texte de controle
+  std::string texte_control = Texte_control (noeud_1, noeud_2) ;
+// 3. Definition du service
+  _Texte += "                           <service name=\"" + noeud_2 + "\">\n" ;
+  _Texte += "                              <node>Etude_Initialisation.SetCurrentStudy</node>\n" ;
+  _Texte += "                              <method>" + methode + "</method>\n" ;
+// 4. Les inports
+// 4.1. Le nom de la zone
+  _Texte += Texte_inport( "string", "ZoneName" ) ;
+   TexteParametre( node, "ZoneName", "string", ZoneName ) ;
+// 4.2. Les valeurs numeriques
+//      ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
+// 4.2.1. Decodage des valeurs
+// La chaine pythonZone est de ce genre :
+//   CreateZoneBox( "Zone_1", 0.144, 0.216, 0.096, 0.1464, 0.076, 0.12)
+  std::string ligne = pythonZone ;
+// On commence par ne garder que ce qui suit la premiere virgule
+  ligne = GetStringInTexte( ligne, ",", 1 );
+// On boucle pour isoler toutes les chaines dans les virgules
+  std::string lignebis ;
+  std::string x0, x1, x2, x3, x4, x5, x6, x7, x8  ;
+  int iaux = 0  ;
+  while ( ligne != lignebis )
+  {
+    lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
+//     MESSAGE("lignebis = "<<lignebis );
+    if      ( iaux == 0 ) { x0 = lignebis ; }
+    else if ( iaux == 1 ) { x1 = lignebis ; }
+    else if ( iaux == 2 ) { x2 = lignebis ; }
+    else if ( iaux == 3 ) { x3 = lignebis ; }
+    else if ( iaux == 4 ) { x4 = lignebis ; }
+    else if ( iaux == 5 ) { x5 = lignebis ; }
+    else if ( iaux == 6 ) { x6 = lignebis ; }
+    else if ( iaux == 7 ) { x7 = lignebis ; }
+    ligne = GetStringInTexte( ligne, ",", 1 );
+    iaux += 1 ;
+  }
+// La derniere valeur est toujours mise dans x8
+  x8 = GetStringInTexte ( ligne, ")", 0 ) ;
+  MESSAGE("coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
+// 4.2. Cas du parallelepipede (2)
+  if ( ZoneType == 2 )
+  {
+    _Texte += Texte_inport( "double", "Xmini" ) ;
+    _Texte += Texte_inport( "double", "Xmaxi" ) ;
+    _Texte += Texte_inport( "double", "Ymini" ) ;
+    _Texte += Texte_inport( "double", "Ymaxi" ) ;
+    _Texte += Texte_inport( "double", "Zmini" ) ;
+    _Texte += Texte_inport( "double", "Zmaxi" ) ;
+    TexteParametre( node, "Xmini", "double", x0 ) ;
+    TexteParametre( node, "Xmaxi", "double", x1 ) ;
+    TexteParametre( node, "Ymini", "double", x2 ) ;
+    TexteParametre( node, "Ymaxi", "double", x3 ) ;
+    TexteParametre( node, "Zmini", "double", x4 ) ;
+    TexteParametre( node, "Zmaxi", "double", x8 ) ;
+  }
+//
+// 4.2. Cas du rectangle (11, 12, 13)
+  else if ( ( ZoneType > 10 ) and ( ZoneType < 14 ) )
+  {
+    _Texte += Texte_inport( "double", "Umini" ) ;
+    _Texte += Texte_inport( "double", "Umaxi" ) ;
+    _Texte += Texte_inport( "double", "Vmini" ) ;
+    _Texte += Texte_inport( "double", "Vmaxi" ) ;
+    _Texte += Texte_inport( "long", "Orient" ) ;
+    TexteParametre( node, "Umini", "double", x0 ) ;
+    TexteParametre( node, "Umaxi", "double", x1 ) ;
+    TexteParametre( node, "Vmini", "double", x2 ) ;
+    TexteParametre( node, "Vmaxi", "double", x3 ) ;
+    TexteParametre( node, "Orient", "int", x8 ) ;
+  }
+//
+// 4.2. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63)
+  else if ( ( ( ZoneType > 30 ) and ( ZoneType < 34 ) ) or ( ( ZoneType > 60 ) and ( ZoneType < 64 ) ) )
+  {
+    _Texte += Texte_inport( "double", "Ucentre" ) ;
+    _Texte += Texte_inport( "double", "Vcentre" ) ;
+    _Texte += Texte_inport( "double", "Radius" ) ;
+    TexteParametre( node, "Ucentre", "double", x0 ) ;
+    TexteParametre( node, "Vcentre", "double", x1 ) ;
+    TexteParametre( node, "Radius", "double", x2 ) ;
+    if ( ZoneType > 60 )
+    {
+      _Texte += Texte_inport( "double", "InternalRadius" ) ;
+      TexteParametre( node, "InternalRadius", "double", x3 ) ;
+    }
+    _Texte += Texte_inport( "long", "Orient" ) ;
+    TexteParametre( node, "Orient", "int", x8 ) ;
+  }
+//
+// 4.2. Cas de la sphere (4)
+  else if ( ZoneType == 4 )
+  {
+    _Texte += Texte_inport( "double", "Xcentre" ) ;
+    _Texte += Texte_inport( "double", "Ycentre" ) ;
+    _Texte += Texte_inport( "double", "Zcentre" ) ;
+    _Texte += Texte_inport( "double", "Radius" ) ;
+    TexteParametre( node, "Xcentre", "double", x0 ) ;
+    TexteParametre( node, "Ycentre", "double", x1 ) ;
+    TexteParametre( node, "Zcentre", "double", x2 ) ;
+    TexteParametre( node, "Radius", "double", x8 ) ;
+  }
+//
+// 4.2. Cas du cylindre (5) ou du tuyau (7)
+  else if ( ZoneType == 5 or ZoneType == 7 )
+  {
+    _Texte += Texte_inport( "double", "Xcentre" ) ;
+    _Texte += Texte_inport( "double", "Ycentre" ) ;
+    _Texte += Texte_inport( "double", "Zcentre" ) ;
+    _Texte += Texte_inport( "double", "Xaxis" ) ;
+    _Texte += Texte_inport( "double", "Yaxis" ) ;
+    _Texte += Texte_inport( "double", "Zaxis" ) ;
+    _Texte += Texte_inport( "double", "Radius" ) ;
+    _Texte += Texte_inport( "double", "Height" ) ;
+    TexteParametre( node, "Xcentre", "double", x0 ) ;
+    TexteParametre( node, "Ycentre", "double", x1 ) ;
+    TexteParametre( node, "Zcentre", "double", x2 ) ;
+    TexteParametre( node, "Xaxis", "double", x3 ) ;
+    TexteParametre( node, "Yaxis", "double", x4 ) ;
+    TexteParametre( node, "Zaxis", "double", x5 ) ;
+    TexteParametre( node, "Radius", "double", x6 ) ;
+    if ( ZoneType == 5 )
+    {
+      TexteParametre( node, "Height", "double", x8 ) ;
+    }
+    else
+    {
+      _Texte += Texte_inport( "double", "InternalRadius" ) ;
+      TexteParametre( node, "Height", "double", x7 ) ;
+      TexteParametre( node, "InternalRadius", "double", x8 ) ;
+    }
+  }
+//
+// 4.2. Erreur
+  else
+  { ASSERT("Type de zone inconnu." == 0); }
+
+//
+// 5. La fin
+  _Texte += "                              <outport name=\"return\" type=\"HOMARD_Zone\"/>\n" ;
+  _Texte += "                           </service>\n" ;
+//
+  return texte_control ;
+//
+}
+//===============================================================================
+// Controle des enchainements de noeud dans le noeud HOMARD_Init_au_debut
+//===============================================================================
+  std::string YACSDriver::Texte_HOMARD_Init_au_debut_control()
+{
+  MESSAGE("Texte_HOMARD_Init_au_debut_control");
+//
+  std::string texte ;
+  texte  = Texte_control ("CreateCase", "Case_Options") ;
+  texte += Texte_control ("Case_Options", "CreateHypothesis") ;
+//
+  return texte ;
+//
+}
+//===============================================================================
+// Controle des enchainements de noeuds
+// noeud_1 : noeud de depart
+// noeud_2 : noeud d'arrivee
+//===============================================================================
+  std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2 )
+{
+  MESSAGE("Texte_control, noeud_1 = "<<noeud_1<<", noeud_2 = "<<noeud_2);
+//
+  std::string texte ;
+  texte  = "                           <control> " ;
+  texte += "<fromnode>" + noeud_1 + "</fromnode>" ;
+  texte += " <tonode>"  + noeud_2 + "</tonode>" ;
+  texte += " </control>\n" ;
+
+  return texte ;
+//
+}
+//===============================================================================
+// Inport
+// inport_type : type de la donnee a importer
+// inport_nom : nom de la donnee a importer
+//===============================================================================
+  std::string YACSDriver::Texte_inport( const std::string inport_type, const std::string inport_nom )
+{
+//   MESSAGE("Texte_control, inport_type = "<<inport_type<<", inport_nom = "<<inport_nom);
+//
+  std::string texte ;
+  texte  = "                              <inport " ;
+  texte += "name=\"" + inport_nom + "\" " ;
+  texte += "type=\"" + inport_type + "\"" ;
+  texte += "/>\n" ;
+
+  return texte ;
+//
+}
+//===============================================================================
+// Le repertoire d'execution
+//===============================================================================
+void YACSDriver::Texte_HOMARD_Exec_DirName( )
+{
+  MESSAGE("Texte_HOMARD_Exec_DirName");
+//
+  _Texte += "DirName = \"" + _DirName + "\"\n" ;
+//
+}
+//===============================================================================
+// Manipulation des instructions python
+// pythonTexte : le texte des instructions python a manipuler
+// indice : numero de la premiere ligne voulue
+// concept : nom du concept a inserer
+//===============================================================================
+void YACSDriver::Texte_python( const std::string pythonTexte, int indice, const std::string concept )
+{
+  MESSAGE("Texte_python, pythonTexte\n"<<pythonTexte);
+  MESSAGE("indice = "<<indice<<", concept = "<<concept);
+//
+// Conversion de type
+  std::istringstream tout (pythonTexte) ;
+//   MESSAGE("\ntout :"<<tout);
+  std::string ligne; // variable contenant chaque ligne de python
+  std::string ligne_bis ; // variable contenant la portion de ligne de python apres '.'
+  int cptr = 0 ;
+  indice -= 1 ;
+  while ( std::getline( tout, ligne ) )
+  {
+    if ( cptr > indice )
+    {
+      int position = ligne.find_first_of( "." ) ;
+//       MESSAGE("\nposition : "<< position);
+      if ( position > 0 )
+      {
+        ligne_bis = ligne.substr( position );
+//         MESSAGE("\nligne_bis : "<< ligne_bis);
+        _Texte += concept + ligne_bis + "\n" ;
+      }
+    }
+    cptr += 1 ;
+  }
+//
+}
+//===============================================================================
+// Creation d'un parametre
+//===============================================================================
+void YACSDriver::TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value )
+{
+//
+//   MESSAGE("TexteParametre");
+  _Texte_parametres += "   <parameter>\n" ;
+  _Texte_parametres += "      <tonode>" + node + "</tonode>" ;
+  _Texte_parametres += "<toport>" + port + "</toport>\n" ;
+  _Texte_parametres += "      <value><" + type_value + ">" + value + "</" + type_value + "></value>\n" ;
+  _Texte_parametres += "   </parameter>\n" ;
+//
+}
+//===============================================================================
+// Ajout des parametres
+//===============================================================================
+void YACSDriver::TexteAddParametres( )
+{
+//
+  MESSAGE("TexteAddParametres");
+  TexteAdd(_Texte_parametres) ;
+//
+}
+//===============================================================================
+void YACSDriver::CreeFichier( )
+{
+//
+  MESSAGE("CreeFichier sur le fichier "<<_YACSFile);
+  std::ofstream Fic(_YACSFile.c_str(), std::ios::out ) ;
+  if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
+  Fic.close() ;
+//
+}
+//===============================================================================
+// REMARQUE : on devrait utiliser le GetStringInTexte de HOMARD_Gen_i mais je ne sais pas
+//            comment l'appeler. ALors je clone.
+// Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
+// ligne : la ligne a manipuler
+// texte : le texte a reperer
+// option : 0 : la chaine avant le texte
+//          1 : la chaine apres le texte
+// Si le texte est absent, on retourne la chaine totale
+//===============================================================================
+std::string YACSDriver::GetStringInTexte( const std::string ligne, const std::string texte, int option )
+{
+//   MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
+//
+  std::string chaine = ligne ;
+  int position = ligne.find_first_of( texte ) ;
+  if ( position > 0 )
+  {
+    if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
+    else               { chaine = ligne.substr( position+1 ) ; }
+  }
+// Conversion de type
+  return chaine ;
+//
+}
diff --git a/src/HOMARD/YACSDriver.hxx b/src/HOMARD/YACSDriver.hxx
new file mode 100644 (file)
index 0000000..b95cf1f
--- /dev/null
@@ -0,0 +1,60 @@
+//  HOMARD HOMARD : implementation of HOMARD idl descriptions
+//
+// Copyright (C) 2011-2013  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+# ifndef __YACSDRIVER_H__
+# define __YACSDRIVER_H__
+
+#include <iostream>
+#include <fstream>
+
+class YACSDriver
+{
+public:
+  YACSDriver(const std::string YACSFile, const std::string DirName) ;
+  ~YACSDriver() ;
+  //
+  void        TexteAdd( const std::string ligne ) ;
+  void        Texte_DataInit_MeshFile( const std::string Meshfile ) ;
+  void        Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName ) ;
+  void        Texte_HOMARD_Init_au_debut_Case_Options( const std::string pythonCas ) ;
+  std::string Texte_HOMARD_Init_au_debut_Zone( int ZoneType, const std::string pythonZone, const std::string methode, const std::string ZoneName, const std::string noeud_1 ) ;
+  std::string Texte_HOMARD_Init_au_debut_control() ;
+  std::string Texte_control( const std::string noeud_1, const std::string noeud_2 ) ;
+  std::string Texte_inport( const std::string inport_type, const std::string inport_nom ) ;
+  void        Texte_HOMARD_Exec_DirName( ) ;
+  void        Texte_python( const std::string pythonTexte, int indice, const std::string concept ) ;
+  void        TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value ) ;
+  void        TexteAddParametres( ) ;
+  void        CreeFichier() ;
+  //
+
+public:
+  std::string _YACSFile;
+  std::string _DirName;
+  std::string _Texte;
+  std::string _Texte_parametres;
+  bool _bLu;
+
+private :
+  std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ;
+};
+
+# endif         /* # ifndef __YACSDRIVER_H__ */
index 7af8208c18fd6641158e02e64a0c99b120a299f4..12d17bc13e39d67608d33eb5d4b9c41891476c45 100644 (file)
@@ -138,7 +138,8 @@ libHOMARD_la_LDFLAGS  =                 \
 # resources files
 nodist_salomeres_DATA =  \
        HOMARD_msg_en.qm \
-       HOMARD_msg_fr.qm
+       HOMARD_msg_fr.qm \
+       HOMARD_msg_ja.qm
 
 UI_FILES = \
 CreateBoundaryAn.ui \
index 91e7e5e6ba2165bdb1520878e71146c1f0d5b636..3a0a2a28b705762e4c56283ba42ec5506cf0a4ef 100755 (executable)
@@ -416,3 +416,26 @@ void HOMARD_Cas_i::AddIteration( const char* NomIteration )
   ASSERT( myHomardCas );
   myHomardCas->AddIteration( NomIteration );
 }
+//=============================================================================
+//=============================================================================
+// YACS
+//=============================================================================
+//=============================================================================
+//=============================================================================
+// Ecriture d'un schema YACS
+// ScriptFile : nom du fichier contenant le script de lancement du calcul
+// DirName : le repertoire de lancement des calculs du schéma
+// MeshFile : nom du fichier contenant le maillage pour le premier calcul
+//=============================================================================
+CORBA::Long HOMARD_Cas_i::WriteYACSSchema( const char* ScriptFile, const char* DirName, const char* MeshFile )
+{
+//
+  ASSERT( myHomardCas );
+// Nom du cas
+  const char* CaseName = GetName() ;
+  MESSAGE ( "WriteYACSSchema : Schema YACS pour le cas " << CaseName);
+  MESSAGE ( "ScriptFile : " << ScriptFile);
+  MESSAGE ( "DirName    : " << DirName);
+  MESSAGE ( "MeshFile   : " << MeshFile);
+  return _gen_i->WriteYACSSchema(CaseName, ScriptFile, DirName, MeshFile) ;
+}
index 8f729be8c1f8261e4f40d9dfa6a66168bf9341ce..86afbdbc1e7a4f1f7cd4e3cfc23296b6b9ccf5e7 100644 (file)
@@ -99,6 +99,9 @@ public:
 
   void                   AddIteration( const char* NomIteration );
 
+// YACS
+  CORBA::Long            WriteYACSSchema( const char* ScriptFile, const char* DirName, const char* MeshFile );
+
 private:
   ::HOMARD_Cas*          myHomardCas;
 
index f76c9d4032268eea5209fc5973b39f03b0779f58..a5892955aa07e94a75bb6547035b7dde3088632e 100755 (executable)
@@ -26,6 +26,7 @@
 #include "HomardDriver.hxx"
 #include "HOMARD_DriverTools.hxx"
 #include "HomardMedCommun.h"
+#include "YACSDriver.hxx"
 
 #include "HOMARD_version.h"
 
@@ -399,7 +400,7 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long
   // Retrait dans la descendance de l'iteration parent
   if ( numero > 0 )
   {
-    const char* nomIterationParent = myIteration->GetIterParentName();
+    std::string nomIterationParent = myIteration->GetIterParentName();
     MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
     HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
     if (CORBA::is_nil(myIterationParent))
@@ -416,7 +417,7 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long
   // suppression du lien avec l'hypothese
   if ( numero > 0 )
   {
-    const char* nomHypo = myIteration->GetHypoName();
+    std::string nomHypo = myIteration->GetHypoName();
     HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
     ASSERT(!CORBA::is_nil(myHypo));
     myHypo->UnLinkIteration(nomIter);
@@ -591,8 +592,8 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
         throw SALOME::SALOME_Exception(es);
         return ;
     };
-    const char* nomDir     = myIteration->GetDirName();
-    const char* nomFichier = myIteration->GetMeshFile();
+    std::string nomDir     = myIteration->GetDirName();
+    std::string nomFichier = myIteration->GetMeshFile();
     std::string commande= "rm -rf " + std::string(nomDir);
     if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
     MESSAGE ( "commande = " << commande );
@@ -605,7 +606,7 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
       return ;
     }
   // Suppression du maillage publie dans SMESH
-    const char* MeshName = myIteration->GetMeshName() ;
+    std::string MeshName = myIteration->GetMeshName() ;
     DeleteResultInSmesh(nomFichier, MeshName) ;
   };
 
@@ -2693,21 +2694,13 @@ void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardD
     NumZone = iaux/2 + 1 ;
     HOMARD::double_array* zone = myZone->GetCoords();
     if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
-    {
-      myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.);
-    }
+    { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
     else if ( ZoneType == 4 ) // Cas d une sphere
-    {
-      myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.);
-    }
+    { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
     else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
-    {
-      myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.);
-    }
+    { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
     else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
-    {
-      myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]);
-    }
+    { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
     else { ASSERT("ZoneType est incorrect." == 0) ; }
     iaux += 1 ;
   }
@@ -2733,7 +2726,7 @@ void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HO
   MESSAGE( ". TimeStep = " << TimeStep );
   int Rank = myIteration->GetRank();
   MESSAGE( ". Rank = " << Rank );
-//  Les informations sur les champ
+//  Les informations sur les champs
   HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
 //  Le nom
   const char* FieldName = aInfosHypo->FieldName;
@@ -3288,7 +3281,7 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
             MESSAGE ( "PublishResultInSmesh : depublication" );
             SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
             CORBA::String_var value2=anAttr2->Value();
-            const char* MeshName = value2 ;
+            std::string MeshName = string(value2) ;
             MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
             DeleteResultInSmesh(NomFich, MeshName) ;
           }
@@ -3327,7 +3320,7 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
 
 }
 //=============================================================================
-void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName)
+void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
 {
   MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
   if (CORBA::is_nil(myCurrentStudy))
@@ -3357,13 +3350,13 @@ void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName
      {
        SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
        CORBA::String_var value=anAttr->Value();
-       if (strcmp((const char*)value,NomFich) == 0)
+       if (strcmp((const char*)value,NomFich.c_str()) == 0)
        {
          if (aSO->FindAttribute(aGAttr,"AttributeName"))
          {
            SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
            CORBA::String_var value2=anAttr2->Value();
-           if (strcmp((const char*)value2,MeshName) == 0)
+           if (strcmp((const char*)value2,MeshName.c_str()) == 0)
            {
              myBuilder->RemoveObjectWithChildren( aSO ) ;
            }
@@ -3423,8 +3416,225 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No
 
   aStudyBuilder->CommitCommand();
 }
+//
+//=============================================================================
+//=============================================================================
+// YACS
+//=============================================================================
+//=============================================================================
+//=============================================================================
+// Ecriture d'un schema YACS
+// nomCas : nom du cas a traiter
+// FileName : nom du fichier contenant le script de lancement du calcul
+// DirName : le repertoire de lancement des calculs du schéma
+//=============================================================================
+CORBA::Long HOMARD_Gen_i::WriteYACSSchema (const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
+{
+  MESSAGE ( "WriteYACSSchema : Schema YACS pour le cas " << nomCas);
+  MESSAGE ( "ScriptFile : " << ScriptFile);
+  MESSAGE ( "DirName    : " << DirName);
+  MESSAGE ( "MeshFile   : " << MeshFile);
+
+  int codret = 0;
+
+  // A. Le cas
+  // A.1. L'objet cas
+  HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
+  ASSERT(!CORBA::is_nil(myCase));
+  // A.2. Le repertoire du cas
+  std::string nomDirCase = myCase->GetDirName();
+  MESSAGE ( ". nomDirCase = " << nomDirCase );
+  // A.3. Les instructions python associees au cas
+  CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
+  std::string pythonCas = dumpCorbaCase.in();
+  MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
+
+  // D. Les iterations
+  // D.1. L'iteration initiale
+  HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
+  std::string Iter0Name = myCase->GetIter0Name() ;
+  MESSAGE (". Iter0Name = " << Iter0Name);
+  // D.2. L'iteration numero 1
+  HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
+  int numberOfIter = maListe->length();
+  if ( numberOfIter > 1 )
+  {
+    MESSAGE (". numberOfIter = " << numberOfIter);
+    SALOME::ExceptionStruct es ;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "Une seule iteration est permise." ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+    return 0;
+  }
+  std::string Iter1Name = std::string((*maListe)[0]);
+  MESSAGE ("... Iter1Name = " << Iter1Name);
+  HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
+  MESSAGE (". Iter1 = " << Iter1);
+
+  // C. L'hypothese
+  // C.1. La structure
+  std::string nomHypo = Iter1->GetHypoName();
+  MESSAGE (". nomHypo = " << nomHypo);
+  HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
+  ASSERT(!CORBA::is_nil(myHypo));
+  // C.2. Les caracteristiques de l'adaptation
+  HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
+  ASSERT(ListTypes->length() == 3);
+  int TypeAdap = (*ListTypes)[0];
+//   int TypeRaff = (*ListTypes)[1];
+//   int TypeDera = (*ListTypes)[2];
+  // C.3. Les instructions python associees a l'hypothese
+  CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
+  std::string pythonHypo = dumpCorbaHypo.in();
+  MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
+
+  // E. Les fichiers du schema
+  // E.1. Le fichier du schema de reference
+  // Le repertoire ou se trouve l'executable 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) ; }
+  YACSFile_base += "/share/salome/resources/homard/yacs_01.xml" ;
+  MESSAGE("YACSFile_base ="<<YACSFile_base);
+  // E.2. Le fichier du schema a creer
+  std::string YACSFile = nomDirCase ;
+  YACSFile += "/schema.xml" ;
+  MESSAGE (". YACSFile = " << YACSFile);
+  YACSDriver* myDriver = new YACSDriver(YACSFile, DirName);
+
+  // F. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
+  std::ifstream fichier( YACSFile_base.c_str() );
+  if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
+  {
+    // F.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
+    std::string ligne; // variable contenant chaque ligne lue
+    std::string mot_cle;
+    while ( std::getline( fichier, ligne ) )
+    {
+      // F.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
+      std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
+      ligne_bis >> mot_cle ;
+      // F.1.2. Le maillage initial
+      if ( mot_cle == "DataInit_MeshFile" )
+      {
+        myDriver->Texte_DataInit_MeshFile(MeshFile);
+      }
+      // F.1.3. Le script de lancement
+      else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
+      {
+        myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile);
+      }
+      // F.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);
+      }
+      // F.1.5. Execution de HOMARD : le repertoire du cas
+      else if ( mot_cle == "HOMARD_Exec_DirName" )
+      {
+        myDriver->Texte_HOMARD_Exec_DirName();
+      }
+      // F.1.6. Execution de HOMARD : les options de l'hypothese
+      else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
+      {
+        myDriver->Texte_python( pythonHypo, 3, "Hypo" ) ;
+      }
+      // F.1.7. Zones : les creations
+      else if ( mot_cle == "HOMARD_Init_au_debut_Zone" )
+      {
+        std::string saux ;
+        if ( TypeAdap == 0 )
+        { YACSDriverTexteZone( myHypo, myDriver ) ; }
+        else
+        {
+          saux = myDriver->Texte_HOMARD_Init_au_debut_control();
+          myDriver->TexteAdd(saux);
+        }
+      }
+      // F.1.8. Zones : les parametres
+      else if ( mot_cle == "PARAMETRES" )
+      {
+        if ( TypeAdap == 0 )
+        { myDriver->TexteAddParametres(); }
+      }
+      // F.1.n. La ligne est recopiee telle quelle
+      else
+      {
+        myDriver->TexteAdd(ligne);
+      }
+    }
+    // F.2. Ecriture du texte dans le fichier
+    if ( codret == 0 )
+    { myDriver->CreeFichier(); }
+  }
+  else
+  {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "The reference file for the YACS schema cannot be read." ;
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  delete myDriver;
+
+  return codret ;
+}
 //=============================================================================
+// Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
 //=============================================================================
+void HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
+{
+  MESSAGE ( "YACSDriverTexteZone" );
+  // A. Les zones associees a cette hypothese
+  HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
+  int numberOfZonesx2 = ListZone->length();
+
+  // B. Initialisation du texte de controle
+  std::string texte_control = myDriver->Texte_HOMARD_Init_au_debut_control() ;
+
+  // C. Parcours des zones
+  std::string noeud = "CreateHypothesis" ;
+  for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
+  {
+    // 1. Reperage de la zone
+    std::string ZoneName = std::string((*ListZone)[iaux]);
+    MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
+    HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
+    ASSERT(!CORBA::is_nil(myZone));
+    // 2. Les instructions python associees a la zone
+    //    La premiere ligne est un commentaire a eliminer
+    //    La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
+    CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
+    std::string pythonZone_0 = dumpCorbaZone.in();
+    MESSAGE ("pythonZone_0 :"<<pythonZone_0);
+    std::istringstream tout (pythonZone_0) ;
+    std::string ligne ;
+    std::string pythonZone ;
+    while ( std::getline( tout, ligne ) )
+    { pythonZone = GetStringInTexte ( ligne, ".", 1 ) ; }
+    MESSAGE ("pythonZone :\n"<<pythonZone);
+    // 3. Decodage du nom du service
+    std::string methode = GetStringInTexte ( pythonZone, "(", 0 ) ;
+    MESSAGE ( "... methode = " << methode);
+    // 4. Mise en place des instructions
+    int ZoneType = myZone->GetType();
+    MESSAGE ( "... ZoneType = " << ZoneType);
+    std::string texte_control_zone ;
+    texte_control_zone = myDriver->Texte_HOMARD_Init_au_debut_Zone(ZoneType, pythonZone, methode, ZoneName, noeud );
+    texte_control += texte_control_zone ;
+    // 5. Decalage
+    noeud = methode + "_" + ZoneName ;
+    iaux += 1 ;
+  }
+
+  // D. Ajout du texte de controle
+  MESSAGE ( "... texte_control =\n" << texte_control);
+  myDriver->TexteAdd(texte_control) ;
+
+  return ;
+}
 //
 //=============================================================================
 //=============================================================================
@@ -4030,6 +4240,29 @@ char* HOMARD_Gen_i::getVersion()
   return CORBA::string_dup(HOMARD_VERSION_STR);
 #endif
 }
+//===============================================================================
+// Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
+// ligne : la ligne a manipuler
+// texte : le texte a reperer
+// option : 0 : la chaine avant le texte
+//          1 : la chaine apres le texte
+// Si le texte est absent, on retourne la chaine totale
+//===============================================================================
+std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string texte, int option )
+{
+//   MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
+//
+  std::string chaine = ligne ;
+  int position = ligne.find_first_of( texte ) ;
+  if ( position > 0 )
+  {
+    if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
+    else               { chaine = ligne.substr( position+1 ) ; }
+  }
+// Conversion de type
+  return chaine ;
+//
+}
 
 //=============================================================================
 extern "C"
index 517629c0d292661beaf9006bc154acf77458c3fb..509e07dab8d561f1b66ec24f1c7455d266940c99 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "HOMARD_Gen.hxx"
 #include "HomardDriver.hxx"
+#include "YACSDriver.hxx"
 #include "SALOME_Component_i.hxx"
 #include "SALOME_NamingService.hxx"
 #include "Utils_CorbaException.hxx"
@@ -174,11 +175,15 @@ public:
 
   CORBA::Boolean                  VerifieDir(const char* nomDir);
 
-  void                            PublishResultInSmesh(const char* NomFich, CORBA::Long Option);
-  void                            DeleteResultInSmesh(const char* NomFich, const char* MeshName);
   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich,
                                                             const char* Commentaire);
   void                            PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName);
+  void                            PublishResultInSmesh(const char* NomFich, CORBA::Long Option);
+  void                            DeleteResultInSmesh(std::string NomFich, std::string MeshName);
+
+// YACS
+  CORBA::Long                     WriteYACSSchema (const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile);
+  void                            YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver);
 
   void                            IsValidStudy();
 
@@ -272,6 +277,7 @@ PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
                                             CORBA::Boolean& isValidScript);
 
   virtual char*                   getVersion();
+  std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ;
 
 private:
   struct StudyContext