Salome HOME
Insertion des valeurs définies dans les préférences comme valeurs par défaut...
[modules/homard.git] / src / HOMARD / YACSDriver.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21
22 // Pilote l'ecriture du fichier xml pour lancer un schema YACS
23
24 #include <cstring>
25 #ifndef WIN32
26 #include <unistd.h>
27 #endif
28 #include <sys/stat.h>
29
30 #include "YACSDriver.hxx"
31 #include "HOMARD.hxx"
32 #include "Utils_SALOME_Exception.hxx"
33 #include "utilities.h"
34
35 //=============================================================================
36 //=============================================================================
37 YACSDriver::YACSDriver(const std::string XMLFile, const std::string DirName):
38   _XMLFile( "" ), _DirName( "" ),
39   _Texte( "" ),
40   _Texte_parametres( "" ),
41   _noeud_1( "CreateHypothesis" ),
42   _bLu( false )
43 {
44   MESSAGE("XMLFile = "<<XMLFile<<", DirName ="<<DirName);
45   _XMLFile = XMLFile;
46   _DirName = DirName;
47 }
48 //=============================================================================
49 //=============================================================================
50 YACSDriver::~YACSDriver()
51 {
52 }
53 //===============================================================================
54 // Ajout d'une ligne simple
55 //===============================================================================
56 void YACSDriver::TexteAdd( const std::string ligne )
57 {
58 //   MESSAGE("TexteAdd, ligne ="<<ligne);
59 //
60   _Texte += ligne + "\n" ;
61 //
62 }
63 //===============================================================================
64 // Nom du fichier du maillage initial
65 //===============================================================================
66 void YACSDriver::Texte_DataInit_MeshFile( const std::string Meshfile )
67 {
68   MESSAGE("TexteInitMeshfile, Meshfile ="<<Meshfile);
69 //
70   _Texte += "         <value><string>" ;
71   _Texte += Meshfile ;
72   _Texte += "</string></value>\n" ;
73 //
74 }
75 //===============================================================================
76 // Le repertoire de calcul
77 // Le script de lancement
78 //===============================================================================
79 void YACSDriver::Texte_Alternance_Calcul_HOMARD_Calcul( const std::string FileName )
80 {
81   MESSAGE("Texte_Alternance_Calcul_HOMARD_Calcul, FileName : "<<FileName);
82 //
83   int position = FileName.find_last_of( '/' ) ;
84   std::string nomfic = FileName.substr( position+1 ) ;
85   position = nomfic.find_last_of( '.' ) ;;
86   nomfic = nomfic.substr( 0, position ) ;
87   MESSAGE("nomfic : "<<nomfic) ;
88 //
89   _Texte += "rep_calc = \"" + _DirName + "\"\n" ;
90   _Texte += "rep_script = os.path.dirname(\"" + FileName + "\")\n" ;
91   _Texte += "sys.path.append(rep_script)\n" ;
92   _Texte += "from " + nomfic + " import Script\n" ;
93 //
94 }
95 //===============================================================================
96 // Les options du cas
97 //===============================================================================
98 void YACSDriver::Texte_Iter_1_Case_Options( const std::string pythonTexte )
99 {
100   MESSAGE("Texte_Iter_1_Case_Options, pythonTexte\n"<<pythonTexte);
101 //
102   _Texte += "DirName = \"" + _DirName + "/HOMARD\"\n" ;
103   _Texte += "Case.SetDirName(DirName)\n" ;
104
105   Texte_python_1( pythonTexte, 1, "Case" ) ;
106 //
107 }
108 //===============================================================================
109 // La description des zones
110 // ZoneType : le type de la zone
111 // pythonStructure : le python correspondant a la zone
112 // methode : methode associee a la creation de la zone
113 // ZoneName : nom de la zone
114 //===============================================================================
115 std::string YACSDriver::Texte_Iter_1_Zone( int ZoneType, const std::string pythonStructure, const std::string methode, const std::string ZoneName )
116 {
117   MESSAGE("Texte_Iter_1_Zone, ZoneType = "<<ZoneType<<", pythonStructure = "<<pythonStructure);
118   MESSAGE("methode = "<<methode<<", ZoneName = "<<ZoneName );
119 //
120 // 1. Le nom du noeud
121   std::string noeud_2 = methode + "_" + ZoneName ;
122   std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1." ;
123   node += noeud_2 ;
124 // 2. Texte de controle
125   std::string texte_control = Texte_control (_noeud_1, noeud_2) ;
126   _noeud_1 = noeud_2 ;
127 // 3. Definition du service
128   _Texte += "                           <service name=\"" + noeud_2 + "\">\n" ;
129   _Texte += "                              <node>Etude_Initialisation.SetCurrentStudy</node>\n" ;
130   _Texte += "                              <method>" + methode + "</method>\n" ;
131 // 4. Les inports
132 // 4.1. Le nom de la zone
133   _Texte += Texte_inport( "string", "ZoneName" ) ;
134    TexteParametre( node, "ZoneName", "string", ZoneName ) ;
135 // 4.2. Les valeurs numeriques
136 //      ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
137 // 4.2.1. Decodage des valeurs
138 // La chaine pythonStructure est de ce genre :
139 //   CreateZoneBox( "Zone_1", 0.144, 0.216, 0.096, 0.1464, 0.076, 0.12)
140   std::string ligne = pythonStructure ;
141 // On commence par ne garder que ce qui suit la premiere virgule
142   ligne = GetStringInTexte( ligne, ",", 1 );
143 // On boucle pour isoler toutes les chaines dans les virgules
144   std::string lignebis ;
145   std::string x0, x1, x2, x3, x4, x5, x6, x7, x8  ;
146   int iaux = 0  ;
147   while ( ligne != lignebis )
148   {
149     lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
150 //     MESSAGE("lignebis = "<<lignebis );
151     if      ( iaux == 0 ) { x0 = lignebis ; }
152     else if ( iaux == 1 ) { x1 = lignebis ; }
153     else if ( iaux == 2 ) { x2 = lignebis ; }
154     else if ( iaux == 3 ) { x3 = lignebis ; }
155     else if ( iaux == 4 ) { x4 = lignebis ; }
156     else if ( iaux == 5 ) { x5 = lignebis ; }
157     else if ( iaux == 6 ) { x6 = lignebis ; }
158     else if ( iaux == 7 ) { x7 = lignebis ; }
159     ligne = GetStringInTexte( ligne, ",", 1 );
160     iaux += 1 ;
161   }
162 // La derniere valeur est toujours mise dans x8
163   x8 = GetStringInTexte ( ligne, ")", 0 ) ;
164   MESSAGE("coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
165 // 4.2. Cas du parallelepipede (2)
166   if ( ZoneType == 2 )
167   {
168     _Texte += Texte_inport( "double", "Xmini" ) ;
169     _Texte += Texte_inport( "double", "Xmaxi" ) ;
170     _Texte += Texte_inport( "double", "Ymini" ) ;
171     _Texte += Texte_inport( "double", "Ymaxi" ) ;
172     _Texte += Texte_inport( "double", "Zmini" ) ;
173     _Texte += Texte_inport( "double", "Zmaxi" ) ;
174     TexteParametre( node, "Xmini", "double", x0 ) ;
175     TexteParametre( node, "Xmaxi", "double", x1 ) ;
176     TexteParametre( node, "Ymini", "double", x2 ) ;
177     TexteParametre( node, "Ymaxi", "double", x3 ) ;
178     TexteParametre( node, "Zmini", "double", x4 ) ;
179     TexteParametre( node, "Zmaxi", "double", x8 ) ;
180   }
181 //
182 // 4.2. Cas du rectangle (11, 12, 13)
183   else if ( ( ZoneType > 10 ) && ( ZoneType < 14 ) )
184   {
185     _Texte += Texte_inport( "double", "Umini" ) ;
186     _Texte += Texte_inport( "double", "Umaxi" ) ;
187     _Texte += Texte_inport( "double", "Vmini" ) ;
188     _Texte += Texte_inport( "double", "Vmaxi" ) ;
189     _Texte += Texte_inport( "long", "Orient" ) ;
190     TexteParametre( node, "Umini", "double", x0 ) ;
191     TexteParametre( node, "Umaxi", "double", x1 ) ;
192     TexteParametre( node, "Vmini", "double", x2 ) ;
193     TexteParametre( node, "Vmaxi", "double", x3 ) ;
194     TexteParametre( node, "Orient", "int", x8 ) ;
195   }
196 //
197 // 4.2. Cas du disque (31, 32, 33) ou du disque perce (61, 62, 63)
198   else if ( ( ( ZoneType > 30 ) && ( ZoneType < 34 ) ) || ( ( ZoneType > 60 ) && ( ZoneType < 64 ) ) )
199   {
200     _Texte += Texte_inport( "double", "Ucentre" ) ;
201     _Texte += Texte_inport( "double", "Vcentre" ) ;
202     _Texte += Texte_inport( "double", "Radius" ) ;
203     TexteParametre( node, "Ucentre", "double", x0 ) ;
204     TexteParametre( node, "Vcentre", "double", x1 ) ;
205     TexteParametre( node, "Radius", "double", x2 ) ;
206     if ( ZoneType > 60 )
207     {
208       _Texte += Texte_inport( "double", "InternalRadius" ) ;
209       TexteParametre( node, "InternalRadius", "double", x3 ) ;
210     }
211     _Texte += Texte_inport( "long", "Orient" ) ;
212     TexteParametre( node, "Orient", "int", x8 ) ;
213   }
214 //
215 // 4.2. Cas de la sphere (4)
216   else if ( ZoneType == 4 )
217   {
218     _Texte += Texte_inport( "double", "Xcentre" ) ;
219     _Texte += Texte_inport( "double", "Ycentre" ) ;
220     _Texte += Texte_inport( "double", "Zcentre" ) ;
221     _Texte += Texte_inport( "double", "Radius" ) ;
222     TexteParametre( node, "Xcentre", "double", x0 ) ;
223     TexteParametre( node, "Ycentre", "double", x1 ) ;
224     TexteParametre( node, "Zcentre", "double", x2 ) ;
225     TexteParametre( node, "Radius", "double", x8 ) ;
226   }
227 //
228 // 4.2. Cas du cylindre (5) ou du tuyau (7)
229   else if ( ZoneType == 5 || ZoneType == 7 )
230   {
231     _Texte += Texte_inport( "double", "Xcentre" ) ;
232     _Texte += Texte_inport( "double", "Ycentre" ) ;
233     _Texte += Texte_inport( "double", "Zcentre" ) ;
234     _Texte += Texte_inport( "double", "Xaxis" ) ;
235     _Texte += Texte_inport( "double", "Yaxis" ) ;
236     _Texte += Texte_inport( "double", "Zaxis" ) ;
237     _Texte += Texte_inport( "double", "Radius" ) ;
238     _Texte += Texte_inport( "double", "Height" ) ;
239     TexteParametre( node, "Xcentre", "double", x0 ) ;
240     TexteParametre( node, "Ycentre", "double", x1 ) ;
241     TexteParametre( node, "Zcentre", "double", x2 ) ;
242     TexteParametre( node, "Xaxis", "double", x3 ) ;
243     TexteParametre( node, "Yaxis", "double", x4 ) ;
244     TexteParametre( node, "Zaxis", "double", x5 ) ;
245     TexteParametre( node, "Radius", "double", x6 ) ;
246     if ( ZoneType == 5 )
247     {
248       TexteParametre( node, "Height", "double", x8 ) ;
249     }
250     else
251     {
252       _Texte += Texte_inport( "double", "InternalRadius" ) ;
253       TexteParametre( node, "Height", "double", x7 ) ;
254       TexteParametre( node, "InternalRadius", "double", x8 ) ;
255     }
256   }
257 //
258 // 4.2. Erreur
259   else
260   { VERIFICATION("Type de zone inconnu." == 0); }
261
262 //
263 // 5. La fin
264   _Texte += "                              <outport name=\"return\" type=\"HOMARD_Zone\"/>\n" ;
265   _Texte += "                           </service>\n" ;
266 //
267   return texte_control ;
268 //
269 }
270 //===============================================================================
271 // La description des frontieres
272 // BoundaryType : le type de la frontiere
273 // pythonStructure : le python correspondant a la frontiere
274 // methode : methode associee a la creation de la frontiere
275 // BoundaryName : nom de la frontiere
276 //===============================================================================
277 std::string YACSDriver::Texte_Iter_1_Boundary( int BoundaryType, const std::string pythonStructure, const std::string methode, const std::string BoundaryName )
278 {
279   MESSAGE("Texte_Iter_1_Boundary, BoundaryType = "<<BoundaryType<<", pythonStructure = "<<pythonStructure);
280   MESSAGE("methode = "<<methode<<", BoundaryName = "<<BoundaryName );
281 //
282 // 1. Le nom du noeud
283   std::string noeud_2 = methode + "_" + BoundaryName ;
284   std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1." ;
285   node += noeud_2 ;
286 // 2. Texte de controle
287   std::string texte_control = Texte_control (_noeud_1, noeud_2) ;
288   _noeud_1 = noeud_2 ;
289 // 3. Definition du service
290   _Texte += "                           <service name=\"" + noeud_2 + "\">\n" ;
291   _Texte += "                              <node>Etude_Initialisation.SetCurrentStudy</node>\n" ;
292   _Texte += "                              <method>" + methode + "</method>\n" ;
293 // 4. Les inports
294 // 4.1. Le nom de la zone
295   _Texte += Texte_inport( "string", "BoundaryName" ) ;
296   TexteParametre( node, "BoundaryName", "string", BoundaryName ) ;
297 // 4.2. Les valeurs numeriques
298 //      ATTENTION : les noms doivent etre les memes que dans Gen.xml, donc HOMARD_Gen.idl
299 // 4.2.1. Decodage des valeurs
300 // La chaine pythonStructure est de ce genre :
301 //   CreateBoundaryCylinder('cyl_2', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
302 //   CreateBoundaryDi("intersection", "PIQUAGE", "/scratch/D68518/Salome/script/sfr_2d_piquage.fr.med")
303   std::string ligne = pythonStructure ;
304 // On commence par ne garder que ce qui suit la premiere virgule
305   ligne = GetStringInTexte( ligne, ",", 1 );
306 // On boucle pour isoler toutes les chaines dans les virgules
307   std::string lignebis ;
308   std::string x0, x1, x2, x3, x4, x5, x6, x7  ;
309   int iaux = 0  ;
310   while ( ligne != lignebis )
311   {
312     lignebis = GetStringInTexte ( ligne, ",", 0 ) ;
313 //     MESSAGE("lignebis = "<<lignebis );
314     if      ( iaux == 0 ) { x0 = lignebis ; }
315     else if ( iaux == 1 ) { x1 = lignebis ; }
316     else if ( iaux == 2 ) { x2 = lignebis ; }
317     else if ( iaux == 3 ) { x3 = lignebis ; }
318     else if ( iaux == 4 ) { x4 = lignebis ; }
319     else if ( iaux == 5 ) { x5 = lignebis ; }
320     else if ( iaux == 6 ) { x6 = lignebis ; }
321     ligne = GetStringInTexte( ligne, ",", 1 );
322     iaux += 1 ;
323   }
324 // La derniere valeur est toujours mise dans x7
325   x7 = GetStringInTexte ( ligne, ")", 0 ) ;
326   MESSAGE("Valeurs = "<< x0<<", "<<x1<< ", "<< x2<< ", "<< x3<<", "<<x4<<", "<<x5<<", "<<x6<<", x7"<<x7);
327 //
328 // 4.2. Cas d une frontiere discrete (0)
329   if (BoundaryType == 0) // Cas d une frontiere discrete
330   {
331     _Texte += Texte_inport( "string", "MeshName" ) ;
332     TexteParametre( node, "MeshName", "string", x0 ) ;
333     _Texte += Texte_inport( "string", "FileName" ) ;
334     TexteParametre( node, "FileName", "string", x7 ) ;
335   }
336 // 4.2. Cas du cylindre (1)
337   else if ( BoundaryType == 1 )
338   {
339     _Texte += Texte_inport( "double", "Xcentre" ) ;
340     _Texte += Texte_inport( "double", "Ycentre" ) ;
341     _Texte += Texte_inport( "double", "Zcentre" ) ;
342     _Texte += Texte_inport( "double", "Xaxis" ) ;
343     _Texte += Texte_inport( "double", "Yaxis" ) ;
344     _Texte += Texte_inport( "double", "Zaxis" ) ;
345     _Texte += Texte_inport( "double", "Radius" ) ;
346     TexteParametre( node, "Xcentre", "double", x0 ) ;
347     TexteParametre( node, "Ycentre", "double", x1 ) ;
348     TexteParametre( node, "Zcentre", "double", x2 ) ;
349     TexteParametre( node, "Xaxis", "double", x3 ) ;
350     TexteParametre( node, "Yaxis", "double", x4 ) ;
351     TexteParametre( node, "Zaxis", "double", x5 ) ;
352     TexteParametre( node, "Radius", "double", x7 ) ;
353   }
354 //
355 // 4.2. Cas de la sphere (2)
356   else if ( BoundaryType == 2 )
357   {
358     _Texte += Texte_inport( "double", "Xcentre" ) ;
359     _Texte += Texte_inport( "double", "Ycentre" ) ;
360     _Texte += Texte_inport( "double", "Zcentre" ) ;
361     _Texte += Texte_inport( "double", "Radius" ) ;
362     TexteParametre( node, "Xcentre", "double", x0 ) ;
363     TexteParametre( node, "Ycentre", "double", x1 ) ;
364     TexteParametre( node, "Zcentre", "double", x2 ) ;
365     TexteParametre( node, "Radius", "double", x7 ) ;
366   }
367 //
368 // 4.3. Cas d un cone defini par un axe et un angle
369   else if ( BoundaryType == 3 )
370   {
371     _Texte += Texte_inport( "double", "Xaxis" ) ;
372     _Texte += Texte_inport( "double", "Yaxis" ) ;
373     _Texte += Texte_inport( "double", "Zaxis" ) ;
374     _Texte += Texte_inport( "double", "Angle" ) ;
375     _Texte += Texte_inport( "double", "Xcentre" ) ;
376     _Texte += Texte_inport( "double", "Ycentre" ) ;
377     _Texte += Texte_inport( "double", "Zcentre" ) ;
378     TexteParametre( node, "Xaxis", "double", x0 ) ;
379     TexteParametre( node, "Yaxis", "double", x1 ) ;
380     TexteParametre( node, "Zaxis", "double", x2 ) ;
381     TexteParametre( node, "Angle", "double", x3 ) ;
382     TexteParametre( node, "Xcentre", "double", x4 ) ;
383     TexteParametre( node, "Ycentre", "double", x5 ) ;
384     TexteParametre( node, "Zcentre", "double", x7 ) ;
385   }
386 //
387 // 4.4. Cas d un cone defini par les 2 rayons
388   else if ( BoundaryType == 4 )
389   {
390     _Texte += Texte_inport( "double", "Xcentre1" ) ;
391     _Texte += Texte_inport( "double", "Ycentre1" ) ;
392     _Texte += Texte_inport( "double", "Zcentre1" ) ;
393     _Texte += Texte_inport( "double", "Radius1" ) ;
394     _Texte += Texte_inport( "double", "Xcentre2" ) ;
395     _Texte += Texte_inport( "double", "Ycentre2" ) ;
396     _Texte += Texte_inport( "double", "Zcentre2" ) ;
397     _Texte += Texte_inport( "double", "Radius2" ) ;
398     TexteParametre( node, "Xcentre1", "double", x0 ) ;
399     TexteParametre( node, "Ycentre1", "double", x1 ) ;
400     TexteParametre( node, "Zcentre1", "double", x2 ) ;
401     TexteParametre( node, "Radius1", "double", x3 ) ;
402     TexteParametre( node, "Xcentre2", "double", x4 ) ;
403     TexteParametre( node, "Ycentre2", "double", x5 ) ;
404     TexteParametre( node, "Zcentre2", "double", x6 ) ;
405     TexteParametre( node, "Radius2", "double", x7 ) ;
406   }
407 // 4.5. Cas du tore (5)
408   else if ( BoundaryType == 5 )
409   {
410     _Texte += Texte_inport( "double", "Xcentre" ) ;
411     _Texte += Texte_inport( "double", "Ycentre" ) ;
412     _Texte += Texte_inport( "double", "Zcentre" ) ;
413     _Texte += Texte_inport( "double", "Xaxis" ) ;
414     _Texte += Texte_inport( "double", "Yaxis" ) ;
415     _Texte += Texte_inport( "double", "Zaxis" ) ;
416     _Texte += Texte_inport( "double", "RRev" ) ;
417     _Texte += Texte_inport( "double", "RPri" ) ;
418     TexteParametre( node, "Xcentre", "double", x0 ) ;
419     TexteParametre( node, "Ycentre", "double", x1 ) ;
420     TexteParametre( node, "Zcentre", "double", x2 ) ;
421     TexteParametre( node, "Xaxis", "double", x3 ) ;
422     TexteParametre( node, "Yaxis", "double", x4 ) ;
423     TexteParametre( node, "Zaxis", "double", x5 ) ;
424     TexteParametre( node, "RRev", "double", x6 ) ;
425     TexteParametre( node, "RPri", "double", x7 ) ;
426   }
427 //
428 // 4.2. Erreur
429   else
430   { VERIFICATION("Type de frontiere inconnu." == 0); }
431
432 //
433 // 5. La fin
434   _Texte += "                              <outport name=\"return\" type=\"HOMARD_Boundary\"/>\n" ;
435   _Texte += "                           </service>\n" ;
436 //
437   return texte_control ;
438 //
439 }
440 //===============================================================================
441 // Controle des enchainements de noeud dans le noeud Iter_1
442 //===============================================================================
443   std::string YACSDriver::Texte_Iter_1_control()
444 {
445   MESSAGE("Texte_Iter_1_control");
446 //
447   std::string texte ;
448   texte  = Texte_control ("CreateCase", "Case_Options") ;
449   texte += Texte_control ("Case_Options", "CreateHypothesis") ;
450 //
451   return texte ;
452 //
453 }
454 //===============================================================================
455 // Controle des enchainements de noeuds
456 // noeud_1 : noeud de depart
457 // noeud_2 : noeud d'arrivee
458 //===============================================================================
459   std::string YACSDriver::Texte_control( const std::string noeud_1, const std::string noeud_2 )
460 {
461   MESSAGE("Texte_control, noeud_1 = "<<noeud_1<<", noeud_2 = "<<noeud_2);
462 //
463   std::string texte ;
464   texte  = "                           <control> " ;
465   texte += "<fromnode>" + noeud_1 + "</fromnode>" ;
466   texte += " <tonode>"  + noeud_2 + "</tonode>" ;
467   texte += " </control>\n" ;
468
469   return texte ;
470 //
471 }
472 //===============================================================================
473 // Inport
474 // inport_type : type de la donnee a importer
475 // inport_nom : nom de la donnee a importer
476 //===============================================================================
477   std::string YACSDriver::Texte_inport( const std::string inport_type, const std::string inport_nom )
478 {
479 //   MESSAGE("Texte_control, inport_type = "<<inport_type<<", inport_nom = "<<inport_nom);
480 //
481   std::string texte ;
482   texte  = "                              <inport " ;
483   texte += "name=\"" + inport_nom + "\" " ;
484   texte += "type=\"" + inport_type + "\"" ;
485   texte += "/>\n" ;
486
487   return texte ;
488 //
489 }
490 //===============================================================================
491 // Le repertoire d'execution
492 //===============================================================================
493 void YACSDriver::Texte_HOMARD_Exec_DirName( )
494 {
495   MESSAGE("Texte_HOMARD_Exec_DirName");
496 //
497   _Texte += "DirName = \"" + _DirName + "\"\n" ;
498 //
499 }
500 //===============================================================================
501 // Le nom du maillage
502 //===============================================================================
503 void YACSDriver::Texte_HOMARD_Exec_MeshName( const std::string MeshName )
504 {
505   MESSAGE("Texte_HOMARD_Exec_MeshName pour "<<MeshName);
506 //
507   _Texte += "MeshName = \"" + MeshName + "\"\n" ;
508 //
509 }
510 //===============================================================================
511 // Manipulation des instructions python - 1
512 // pythonTexte : le texte des instructions python a manipuler
513 // indice : numero de la premiere ligne voulue
514 // concept : nom du concept a inserer
515 //===============================================================================
516 void YACSDriver::Texte_python_1( const std::string pythonTexte, int indice, const std::string concept )
517 {
518   MESSAGE("Texte_python_1, pythonTexte\n"<<pythonTexte);
519   MESSAGE("indice = "<<indice<<", concept = "<<concept);
520 //
521 // Conversion de type
522   std::istringstream tout (pythonTexte) ;
523 //   MESSAGE("\ntout :"<<tout);
524   std::string ligne; // variable contenant chaque ligne de python
525   std::string ligne_bis ; // variable contenant la portion de ligne de python apres '.'
526   int cptr = 0 ;
527   indice -= 1 ;
528   while ( std::getline( tout, ligne ) )
529   {
530     if ( cptr > indice )
531     {
532       int position = ligne.find_first_of( "." ) ;
533 //       MESSAGE("\nposition : "<< position);
534       if ( position > 0 )
535       {
536         ligne_bis = ligne.substr( position );
537 //         MESSAGE("\nligne_bis : "<< ligne_bis);
538         _Texte += concept + ligne_bis + "\n" ;
539       }
540     }
541     cptr += 1 ;
542   }
543 //
544 }
545 //===============================================================================
546 // Manipulation des instructions python - 2
547 // pythonTexte : le texte des instructions python a manipuler
548 // mot_cle : mot-cle dans les lignes a inserer
549 // concept : nom du concept a inserer
550 //===============================================================================
551 void YACSDriver::Texte_python_2( const std::string pythonTexte, const std::string mot_cle, const std::string concept )
552 {
553   MESSAGE("Texte_python_2, pythonTexte\n"<<pythonTexte);
554   MESSAGE("mot_cle = "<<mot_cle<<", concept = "<<concept);
555 //
556 // Conversion de type
557   std::istringstream tout (pythonTexte) ;
558 //   MESSAGE("\ntout :"<<tout);
559   std::string ligne; // variable contenant chaque ligne de python
560   std::string ligne_bis ; // variable contenant la portion de ligne de python apres '.'
561   while ( std::getline( tout, ligne ) )
562   {
563     int reperage = ligne.find( mot_cle ) ;
564     if ( reperage > 0 )
565     {
566       int position = ligne.find_first_of( "." ) ;
567 //       MESSAGE("\nposition : "<< position);
568       if ( position > 0 )
569       {
570         ligne_bis = ligne.substr( position );
571 //         MESSAGE("\nligne_bis : "<< ligne_bis);
572         _Texte += concept + ligne_bis + "\n" ;
573       }
574     }
575   }
576 //
577 }
578 //===============================================================================
579 // Parametres de tests de convergence
580 //===============================================================================
581 void YACSDriver::TexteAnalyse_Test_Convergence( int MaxIter, int MaxNode, int MaxElem )
582 {
583 //
584 //   MESSAGE("TexteAnalyse_Test_Convergence");
585   std::string chaine ;
586   std::ostringstream oss1;
587   oss1 << MaxIter;
588   chaine = oss1.str();
589   _Texte += "MaxIter = " + chaine + "\n" ;
590   std::ostringstream oss2;
591   oss2 << MaxNode;
592   chaine = oss2.str();
593   _Texte += "MaxNode = " + chaine + "\n" ;
594   std::ostringstream oss3;
595   oss3 << MaxElem;
596   chaine = oss3.str();
597   _Texte += "MaxElem = " + chaine + "\n" ;
598 //
599 }
600 //===============================================================================
601 // Creation d'un parametre
602 //===============================================================================
603 void YACSDriver::TexteParametre( const std::string node, const std::string port, const std::string type_value, const std::string value )
604 {
605 //
606 //   MESSAGE("TexteParametre");
607   _Texte_parametres += "   <parameter>\n" ;
608   _Texte_parametres += "      <tonode>" + node + "</tonode>" ;
609   _Texte_parametres += "<toport>" + port + "</toport>\n" ;
610   _Texte_parametres += "      <value><" + type_value + ">" + value + "</" + type_value + "></value>\n" ;
611   _Texte_parametres += "   </parameter>\n" ;
612 //
613 }
614 //===============================================================================
615 // Ajout des parametres
616 //===============================================================================
617 void YACSDriver::TexteAddParametres( )
618 {
619 //
620   MESSAGE("TexteAddParametres");
621   TexteAdd(_Texte_parametres) ;
622 //
623 }
624 //===============================================================================
625 void YACSDriver::CreeFichier( )
626 {
627 //
628   MESSAGE("CreeFichier sur le fichier "<<_XMLFile);
629   std::ofstream Fic(_XMLFile.c_str(), std::ios::out ) ;
630   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
631   Fic.close() ;
632 //
633 }
634 //===============================================================================
635 // REMARQUE : on devrait utiliser le GetStringInTexte de HOMARD_Gen_i mais je ne sais pas
636 //            comment l'appeler. ALors je clone.
637 // Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
638 // ligne : la ligne a manipuler
639 // texte : le texte a reperer
640 // option : 0 : la chaine avant le texte
641 //          1 : la chaine apres le texte
642 // Si le texte est absent, on retourne la chaine totale
643 //===============================================================================
644 std::string YACSDriver::GetStringInTexte( const std::string ligne, const std::string texte, int option )
645 {
646 //   MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
647 //
648   std::string chaine = ligne ;
649   int position = ligne.find_first_of( texte ) ;
650   if ( position > 0 )
651   {
652     if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
653     else               { chaine = ligne.substr( position+1 ) ; }
654   }
655 // Conversion de type
656   return chaine ;
657 //
658 }