]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HomardDriver.cxx
Salome HOME
Création automatique de schémas YACS à partir d'un cas
[modules/homard.git] / src / HOMARD / HomardDriver.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 de configuration pour lancer l'execution de HOMARD
23
24 #include <cstring>
25 #include <unistd.h>
26 #include <sys/stat.h>
27
28 #include "Utils_SALOME_Exception.hxx"
29 #include "utilities.h"
30 #include "HomardDriver.hxx"
31
32 //=============================================================================
33 //=============================================================================
34 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
35   _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
36   _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ),
37   _Texte( "" ), _bLu( false )
38 {
39   MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
40 // Le repertoire ou se trouve l'executable HOMARD
41   std::string dir ;
42   if ( getenv("HOMARD_REP_EXE_PRIVATE") != NULL ) { dir = getenv("HOMARD_REP_EXE_PRIVATE") ; }
43   else                                            { dir = getenv("HOMARD_REP_EXE") ; }
44   MESSAGE("dir ="<<dir);
45 // L'executable HOMARD
46   std::string executable ;
47   if ( getenv("HOMARD_EXE_PRIVATE") != NULL ) { executable = getenv("HOMARD_EXE_PRIVATE") ; }
48   else                                        { executable = getenv("HOMARD_EXE") ; }
49   MESSAGE("executable ="<<executable);
50 // Memorisation du nom complet de l'executable HOMARD
51   _HOMARD_Exec = dir + "/" + executable ;
52   MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
53 //
54   _siter = siter ;
55   _siterp1 = siterp1 ;
56 }
57 //=============================================================================
58 //=============================================================================
59 HomardDriver::~HomardDriver()
60 {
61 }
62 //===============================================================================
63 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
64 {
65   MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
66 //
67   _Texte  = "ListeStd \"" + LogFile + "\"\n" ;
68   _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
69   _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
70   _Texte += "Langue \"" + Langue + "\"\n" ;
71 //
72 }
73 //===============================================================================
74 void HomardDriver::TexteAdap( )
75 {
76   MESSAGE("TexteAdap");
77 //
78   _Texte += "Action   homa\n" ;
79   _Texte += "CCAssoci med\n" ;
80   _Texte += "ModeHOMA 1\n" ;
81   _Texte += "NumeIter " + _siter + "\n" ;
82 //
83 }
84 //===============================================================================
85 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
86 {
87   MESSAGE("TexteInit, TypeBila ="<<TypeBila);
88 //
89   _Texte += "ModeHOMA 2\n" ;
90   std::stringstream saux1 ;
91   saux1 << TypeBila ;
92   std::string saux2 = saux1.str() ;
93   _Texte += "TypeBila " + saux2 + "\n" ;
94   if ( NumeIter ==  0 )
95   {
96     _Texte += "NumeIter 0\n" ;
97     _Texte += "Action   info_av\n" ;
98     _Texte += "CCAssoci med\n" ;
99   }
100   else
101   {
102     _Texte += "NumeIter " + _siter + "\n" ;
103     _Texte += "Action   info_ap\n" ;
104     _Texte += "CCAssoci homard\n" ;
105   }
106 //
107 }
108
109 //===============================================================================
110 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
111 {
112   MESSAGE("TexteMaillage, NomMesh ="<<NomMesh<<", MeshFile ="<<MeshFile<<", apres ="<<apres);
113   std::string saux ;
114   saux = "P1" ;
115   if ( apres < 1 ) { saux = "__" ; }
116
117   _Texte += "# Maillages Med " + saux + "\n" ;
118   _Texte += "CCNoMN" + saux + " \"" + NomMesh  + "\"\n" ;
119   _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
120 }
121
122 //===============================================================================
123 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
124 {
125   MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
126   std::string saux ;
127   if ( apres < 1 ) { saux = "__" ; }
128   else             { saux = "P1" ; }
129
130   _Texte += "# Maillage HOMARD " + liter + "\n" ;
131   _Texte += "HOMaiN" + saux + " Mai" + liter   + " \"" + Dir + "/maill." + liter   + ".hom.med\"\n" ;
132 }
133
134 //===============================================================================
135 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
136 {
137   MESSAGE("TexteConfRaffDera, ConfType ="<<ConfType);
138   MESSAGE("TexteConfRaffDera, TypeAdap ="<<TypeAdap<<", TypeRaff ="<<TypeRaff<<", TypeDera ="<<TypeDera);
139 //
140 // Type de conformite
141 //
142   std::string saux ;
143   switch (ConfType)
144   {
145     case 1: //
146     {
147       saux = "conforme" ;
148       break;
149     }
150     case 2: //
151     {
152       saux = "non_conforme_1_noeud" ;
153       break;
154     }
155     case 3: //
156     {
157       saux = "non_conforme_1_arete" ;
158       break;
159     }
160     case 4: //
161     {
162       saux = "non_conforme_indicateur" ;
163       break;
164     }
165   }
166   _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
167 //
168 // Type de raffinement/deraffinement
169 //
170   if ( TypeAdap == -1 )
171   {
172     if ( TypeRaff == 1 )
173     {
174       saux = "TypeRaff uniforme\n" ;
175     }
176     else
177     {
178       saux = "TypeRaff non\n" ;
179     }
180     if ( TypeDera == 1 )
181     {
182       saux += "TypeDera uniforme" ;
183     }
184     else
185     {
186       saux += "TypeDera non" ;
187     }
188   }
189   else
190   {
191     if ( TypeRaff == 1 )
192     {
193       saux = "TypeRaff libre\n" ;
194     }
195     else
196     {
197       saux = "TypeRaff non\n" ;
198     }
199     if ( TypeDera == 1 )
200     {
201       saux += "TypeDera libre" ;
202     }
203     else
204     {
205       saux += "TypeDera non" ;
206     }
207   }
208   _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
209 //
210 //   MESSAGE("A la fin de HomardDriver::TexteConfRaffDera, _Texte ="<<_Texte);
211 }
212 //===============================================================================
213 void HomardDriver::TexteCompo( int NumeComp, const std::string NompCompo)
214 {
215   MESSAGE("TexteCompo, NumeComp = "<<NumeComp<<", NompCompo = "<<NompCompo);
216   _Texte +="CCCoChaI \"" + NompCompo + "\"\n" ;
217 }
218 //===============================================================================
219 void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8 )
220 {
221   MESSAGE("TexteZone, NumeZone = "<<NumeZone<<", ZoneType = "<<ZoneType<<", TypeUse = "<<TypeUse);
222   MESSAGE("TexteZone, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
223 //
224   std::string saux, saux2 ;
225 //
226 // Type de zones
227 // On convertit le type de zone au sens du module HOMARD dans Salome, ZoneType, dans le
228 // type au sens de l'executable HOMARD, ZoneTypeHOMARD
229 // Attention a mettre le bon signe a ZoneTypeHOMARD :
230 //    >0 signifie que l'on raffinera les mailles contenues dans la zone,
231 //    <0 signifie que l'on deraffinera
232 //
233   int ZoneTypeHOMARD ;
234   if ( ZoneType >= 11 and ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
235   else if ( ZoneType >= 31 and ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
236   else if ( ZoneType >= 61 and ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
237   else { ZoneTypeHOMARD = ZoneType ; }
238 //
239   if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
240 //
241   std::stringstream saux1 ;
242   saux1 << NumeZone ;
243   saux = "#\n# Zone numero " + saux1.str() + "\n" ;
244 //
245   { std::stringstream saux1 ;
246     saux1 << NumeZone << " " << ZoneTypeHOMARD ;
247     saux += "ZoRaType " + saux1.str() + "\n" ;
248   }
249 //
250 // Cas du rectangle
251 //
252   if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
253 //                                        Y Homard <=> Y Salome
254   {
255     saux += "#Rectangle\n" ;
256     { std::stringstream saux1 ;
257       saux1 << NumeZone << " " << x0 ;
258       saux += "ZoRaXmin " + saux1.str() + "\n" ;
259     }
260     { std::stringstream saux1 ;
261       saux1 << NumeZone << " " << x1 ;
262       saux += "ZoRaXmax " + saux1.str() + "\n" ;
263     }
264     { std::stringstream saux1 ;
265       saux1 << NumeZone << " " << x2 ;
266       saux += "ZoRaYmin " + saux1.str() + "\n" ;
267     }
268     { std::stringstream saux1 ;
269       saux1 << NumeZone << " " << x3 ;
270       saux += "ZoRaYmax " + saux1.str() + "\n" ;
271     }
272   }
273 //
274   else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
275 //                                             Y Homard <=> Z Salome
276   {
277     saux += "#Rectangle\n" ;
278     { std::stringstream saux1 ;
279       saux1 << NumeZone << " " << x2 ;
280       saux += "ZoRaXmin " + saux1.str() + "\n" ;
281     }
282     { std::stringstream saux1 ;
283       saux1 << NumeZone << " " << x3 ;
284       saux += "ZoRaXmax " + saux1.str() + "\n" ;
285     }
286     { std::stringstream saux1 ;
287       saux1 << NumeZone << " " << x4 ;
288       saux += "ZoRaYmin " + saux1.str() + "\n" ;
289     }
290     { std::stringstream saux1 ;
291       saux1 << NumeZone << " " << x5 ;
292       saux += "ZoRaYmax " + saux1.str() + "\n" ;
293     }
294   }
295 //
296   else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
297 //                                             Y Homard <=> Z Salome
298   {
299     saux += "#Rectangle\n" ;
300     { std::stringstream saux1 ;
301       saux1 << NumeZone << " " << x0 ;
302       saux += "ZoRaXmin " + saux1.str() + "\n" ;
303     }
304     { std::stringstream saux1 ;
305       saux1 << NumeZone << " " << x1 ;
306       saux += "ZoRaXmax " + saux1.str() + "\n" ;
307     }
308     { std::stringstream saux1 ;
309       saux1 << NumeZone << " " << x4 ;
310       saux += "ZoRaYmin " + saux1.str() + "\n" ;
311     }
312     { std::stringstream saux1 ;
313       saux1 << NumeZone << " " << x5 ;
314       saux += "ZoRaYmax " + saux1.str() + "\n" ;
315     }
316   }
317 //
318 // Cas du parallelepipede
319 //
320   else if ( ZoneType == 2 )
321   {
322     saux += "# Boite\n" ;
323     { std::stringstream saux1 ;
324       saux1 << NumeZone << " " << x0 ;
325       saux += "ZoRaXmin " + saux1.str() + "\n" ;
326     }
327     { std::stringstream saux1 ;
328       saux1 << NumeZone << " " << x1 ;
329       saux += "ZoRaXmax " + saux1.str() + "\n" ;
330     }
331     { std::stringstream saux1 ;
332       saux1 << NumeZone << " " << x2 ;
333       saux += "ZoRaYmin " + saux1.str() + "\n" ;
334     }
335     { std::stringstream saux1 ;
336       saux1 << NumeZone << " " << x3 ;
337       saux += "ZoRaYmax " + saux1.str() + "\n" ;
338     }
339     { std::stringstream saux1 ;
340       saux1 << NumeZone << " " << x4 ;
341       saux += "ZoRaZmin " + saux1.str() + "\n" ;
342     }
343     { std::stringstream saux1 ;
344       saux1 << NumeZone << " " << x5 ;
345       saux += "ZoRaZmax " + saux1.str() + "\n" ;
346     }
347   }
348 //
349 // Cas du disque
350 //
351   else if ( ZoneType == 31 or ZoneType == 61 )
352   {
353     saux += "# Sphere\n" ;
354     { std::stringstream saux1 ;
355       saux1 << NumeZone << " " << x0 ;
356       saux += "ZoRaXCen " + saux1.str() + "\n" ;
357     }
358     { std::stringstream saux1 ;
359       saux1 << NumeZone << " " << x1 ;
360       saux += "ZoRaYCen " + saux1.str() + "\n" ;
361     }
362     { std::stringstream saux1 ;
363       saux1 << NumeZone << " " << x6 ;
364       saux2 = saux1.str() ;
365       if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
366       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
367     }
368     if ( ZoneType == 61 )
369     { std::stringstream saux1 ;
370       saux1 << NumeZone << " " << x8 ;
371       saux += "ZoRaRayI " + saux1.str() + "\n" ;
372     }
373   }
374   else if ( ZoneType == 32 or ZoneType == 62 )
375   {
376     saux += "# Sphere\n" ;
377     { std::stringstream saux1 ;
378       saux1 << NumeZone << " " << x1 ;
379       saux += "ZoRaXCen " + saux1.str() + "\n" ;
380     }
381     { std::stringstream saux1 ;
382       saux1 << NumeZone << " " << x2 ;
383       saux += "ZoRaYCen " + saux1.str() + "\n" ;
384     }
385     { std::stringstream saux1 ;
386       saux1 << NumeZone << " " << x6 ;
387       saux2 = saux1.str() ;
388       if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
389       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
390     }
391     if ( ZoneType == 62 )
392     { std::stringstream saux1 ;
393       saux1 << NumeZone << " " << x8 ;
394       saux += "ZoRaRayI " + saux1.str() + "\n" ;
395     }
396   }
397   else if ( ZoneType == 33 or ZoneType == 63 )
398   {
399     saux += "# Sphere\n" ;
400     { std::stringstream saux1 ;
401       saux1 << NumeZone << " " << x0 ;
402       saux += "ZoRaXCen " + saux1.str() + "\n" ;
403     }
404     { std::stringstream saux1 ;
405       saux1 << NumeZone << " " << x2 ;
406       saux += "ZoRaYCen " + saux1.str() + "\n" ;
407     }
408     { std::stringstream saux1 ;
409       saux1 << NumeZone << " " << x6 ;
410       saux2 = saux1.str() ;
411       if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
412       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
413     }
414     if ( ZoneType == 63 )
415     { std::stringstream saux1 ;
416       saux1 << NumeZone << " " << x8 ;
417       saux += "ZoRaRayI " + saux1.str() + "\n" ;
418     }
419   }
420 //
421 // Cas de la sphere
422 //
423   else if ( ZoneType == 4 )
424   {
425     saux += "# Sphere\n" ;
426     { std::stringstream saux1 ;
427       saux1 << NumeZone << " " << x0 ;
428       saux += "ZoRaXCen " + saux1.str() + "\n" ;
429     }
430     { std::stringstream saux1 ;
431       saux1 << NumeZone << " " << x1 ;
432       saux += "ZoRaYCen " + saux1.str() + "\n" ;
433     }
434     { std::stringstream saux1 ;
435       saux1 << NumeZone << " " << x2 ;
436       saux += "ZoRaZCen " + saux1.str() + "\n" ;
437     }
438     { std::stringstream saux1 ;
439       saux1 << NumeZone << " " << x3 ;
440       saux += "ZoRaRayo " + saux1.str() + "\n" ;
441     }
442   }
443 //
444 // Cas du cylindre ou du tuyau
445 //
446   else if ( ZoneType == 5 or ZoneType == 7 )
447   {
448     if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
449     else                 { saux += "# Tuyau\n" ; }
450     { std::stringstream saux1 ;
451       saux1 << NumeZone << " " << x0 ;
452       saux += "ZoRaXBas " + saux1.str() + "\n" ;
453     }
454     { std::stringstream saux1 ;
455       saux1 << NumeZone << " " << x1 ;
456       saux += "ZoRaYBas " + saux1.str() + "\n" ;
457     }
458     { std::stringstream saux1 ;
459       saux1 << NumeZone << " " << x2 ;
460       saux += "ZoRaZBas " + saux1.str() + "\n" ;
461     }
462     { std::stringstream saux1 ;
463       saux1 << NumeZone << " " << x3 ;
464       saux += "ZoRaXAxe " + saux1.str() + "\n" ;
465     }
466     { std::stringstream saux1 ;
467       saux1 << NumeZone << " " << x4 ;
468       saux += "ZoRaYAxe " + saux1.str() + "\n" ;
469     }
470     { std::stringstream saux1 ;
471       saux1 << NumeZone << " " << x5 ;
472       saux += "ZoRaZAxe " + saux1.str() + "\n" ;
473     }
474     { std::stringstream saux1 ;
475       saux1 << NumeZone << " " << x6 ;
476       saux2 = saux1.str() ;
477      if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
478      else                 { saux += "ZoRaRayE " + saux2 + "\n" ; }
479     }
480     { std::stringstream saux1 ;
481       saux1 << NumeZone << " " << x7 ;
482       saux += "ZoRaHaut " + saux1.str() + "\n" ;
483     }
484     if ( ZoneType == 7 )
485     { std::stringstream saux1 ;
486       saux1 << NumeZone << " " << x8 ;
487       saux += "ZoRaRayI " + saux1.str() + "\n" ;
488     }
489   }
490 //
491   _Texte += saux + "#\n" ;
492 //
493 //   MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
494 }
495 //===============================================================================
496 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
497                int TypeThR, double ThreshR, int TypeThC, double ThreshC,
498                int UsField, int UsCmpI )
499 {
500   MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
501   MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
502
503   std::string saux, saux2 ;
504 //
505 //
506   _Texte += "# Champ d'indicateurs\n" ;
507   _Texte += "CCIndica \"" + FieldFile  + "\"\n" ;
508   _Texte += "CCNoChaI \"" + FieldName  + "\"\n" ;
509
510 // Cas ou on prend le dernier pas de temps
511   if ( TimeStep == -2 )
512   { _Texte += "CCNumPTI Last\n" ; }
513 // Cas avec pas de temps
514   else if ( TimeStep >= 0 )
515   {
516     {
517       std::stringstream saux1 ;
518       saux1 << TimeStep ;
519       saux2 = saux1.str() ;
520       _Texte += "CCNumPTI " + saux2  + "\n" ;
521     }
522     {
523       std::stringstream saux1 ;
524       saux1 << Rank ;
525       saux2 = saux1.str() ;
526       _Texte += "CCNumOrI " + saux2  + "\n" ;
527     }
528   }
529 //
530   saux = " " ;
531   if ( TypeThR == 1 )
532   { saux = "Hau" ; }
533   if ( TypeThR == 2 )
534   { saux = "HRe" ; }
535   if ( TypeThR == 3 )
536   { saux = "HPE" ; }
537   if ( TypeThR == 4 )
538   { saux = "HMS" ; }
539   if ( saux != " " )
540   {
541     std::stringstream saux1 ;
542     saux1 << ThreshR ;
543     _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
544   }
545 //
546   saux = " " ;
547   if ( TypeThC == 1 )
548   { saux = "Bas" ; }
549   if ( TypeThC == 2 )
550   { saux = "BRe" ; }
551   if ( TypeThC == 3 )
552   { saux = "BPE" ; }
553   if ( TypeThC == 4 )
554   { saux = "BMS" ; }
555   if ( saux != " " )
556   {
557     std::stringstream saux1 ;
558     saux1 << ThreshC ;
559     _Texte += "Seuil" + saux + " " + saux1.str()  + "\n" ;
560   }
561 //
562   saux = " " ;
563   if ( UsField == 0 )
564   { saux = "MAILLE" ; }
565   if ( UsField == 1 )
566   { saux = "SAUT" ; }
567   if ( saux != " " )
568   {
569     _Texte += "CCModeFI " + saux  + "\n" ;
570   }
571 //
572   saux = " " ;
573   if ( UsCmpI == 0 )
574   { saux = "L2" ; }
575   if ( UsCmpI == 1 )
576   { saux = "INFINI" ; }
577   if ( UsCmpI == 2 )
578   { saux = "V_RELATIVE" ; }
579   if ( saux != " " )
580   {
581     _Texte += "CCUsCmpI " + saux  + "\n" ;
582   }
583 }
584 //===============================================================================
585 void HomardDriver::TexteGroup( const std::string GroupName )
586 {
587   MESSAGE("TexteGroup, GroupName = "<<GroupName);
588 //
589   _Texte += "CCGroAda \"" + GroupName  + "\"\n" ;
590 //
591 }
592 //===============================================================================
593 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
594 {
595   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
596 //
597 // Type de suivi de frontiere
598 //
599   std::stringstream saux1 ;
600   saux1 << BoundaryOption ;
601   std::string saux = saux1.str() ;
602   _Texte += "SuivFron " + saux + "\n" ;
603 //
604 }
605 //===============================================================================
606 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
607 {
608   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
609   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
610 //
611   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
612   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
613 //
614 }
615 //===============================================================================
616 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
617 {
618   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
619 //
620   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
621 //
622 }
623 //===============================================================================
624 void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoundary, int BoundaryType, double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7 )
625 {
626   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
627 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
628   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
629 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
630 //
631   std::string saux, saux2 ;
632 //
633 // Commentaires
634 //
635   std::stringstream saux1 ;
636   saux1 << NumeBoundary ;
637   saux2 = saux1.str() ;
638   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
639   if ( BoundaryType == 1 )
640   { saux += "# Cylindre\n" ; }
641   if ( BoundaryType == 2 )
642   { saux += "# Sphere\n" ; }
643   if ( BoundaryType == 3 or BoundaryType == 4 )
644   { saux += "# Cone\n" ; }
645 //
646 // Le nom de la frontiere
647 //
648   { std::stringstream saux1 ;
649     saux1 << NumeBoundary ;
650     saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
651   }
652 //
653 // Type de frontiere
654 //
655   { std::stringstream saux1 ;
656     saux1 << NumeBoundary << " " << BoundaryType ;
657     saux += "FAType " + saux1.str() + "\n" ;
658   }
659 //
660 // Cas du cylindre
661 //
662   if ( BoundaryType == 1 )
663   {
664     { std::stringstream saux1 ;
665       saux1 << NumeBoundary << " " << x0 ;
666       saux2 = saux1.str() ;
667       saux += "FAXCen " + saux1.str() + "\n" ;
668     }
669     { std::stringstream saux1 ;
670       saux1 << NumeBoundary << " " << x1 ;
671       saux += "FAYCen " + saux1.str() + "\n" ;
672     }
673     { std::stringstream saux1 ;
674       saux1 << NumeBoundary << " " << x2 ;
675       saux += "FAZCen " + saux1.str() + "\n" ;
676     }
677     { std::stringstream saux1 ;
678       saux1 << NumeBoundary << " " << x3 ;
679       saux += "FAXAxe " + saux1.str() + "\n" ;
680     }
681     { std::stringstream saux1 ;
682       saux1 << NumeBoundary << " " << x4 ;
683       saux += "FAYAxe " + saux1.str() + "\n" ;
684     }
685     { std::stringstream saux1 ;
686       saux1 << NumeBoundary << " " << x5 ;
687       saux += "FAZAxe " + saux1.str() + "\n" ;
688     }
689     { std::stringstream saux1 ;
690       saux1 << NumeBoundary << " " << x6 ;
691       saux += "FARayon " + saux1.str() + "\n" ;
692     }
693  }
694 //
695 // Cas de la sphere
696 //
697   else if ( BoundaryType == 2 )
698   {
699     { std::stringstream saux1 ;
700       saux1 << NumeBoundary << " " << x0 ;
701       saux += "FAXCen " + saux1.str() + "\n" ;
702     }
703     { std::stringstream saux1 ;
704       saux1 << NumeBoundary << " " << x1 ;
705       saux += "FAYCen " + saux1.str() + "\n" ;
706     }
707     { std::stringstream saux1 ;
708       saux1 << NumeBoundary << " " << x2 ;
709       saux += "FAZCen " + saux1.str() + "\n" ;
710     }
711     { std::stringstream saux1 ;
712       saux1 << NumeBoundary << " " << x3 ;
713       saux += "FARayon " + saux1.str() + "\n" ;
714     }
715   }
716 //
717 // Cas du cone defini par un axe et un angle
718 //
719   if ( BoundaryType == 3 )
720   {
721     { std::stringstream saux1 ;
722       saux1 << NumeBoundary << " " << x0 ;
723       saux += "FAXAxe " + saux1.str() + "\n" ;
724     }
725     { std::stringstream saux1 ;
726       saux1 << NumeBoundary << " " << x1 ;
727       saux += "FAYAxe " + saux1.str() + "\n" ;
728     }
729     { std::stringstream saux1 ;
730       saux1 << NumeBoundary << " " << x2 ;
731       saux += "FAZAxe " + saux1.str() + "\n" ;
732     }
733     { std::stringstream saux1 ;
734       saux1 << NumeBoundary << " " << x3 ;
735       saux += "FAAngle " + saux1.str() + "\n" ;
736     }
737     { std::stringstream saux1 ;
738       saux1 << NumeBoundary << " " << x4 ;
739       saux += "FAXCen " + saux1.str() + "\n" ;
740     }
741     { std::stringstream saux1 ;
742       saux1 << NumeBoundary << " " << x5 ;
743       saux += "FAYCen " + saux1.str() + "\n" ;
744     }
745     { std::stringstream saux1 ;
746       saux1 << NumeBoundary << " " << x6 ;
747       saux += "FAZCen " + saux1.str() + "\n" ;
748     }
749  }
750 //
751 // Cas du cone defini par les 2 rayons
752 //
753   if ( BoundaryType == 4 )
754   {
755     { std::stringstream saux1 ;
756       saux1 << NumeBoundary << " " << x0 ;
757       saux += "FAXCen " + saux1.str() + "\n" ;
758     }
759     { std::stringstream saux1 ;
760       saux1 << NumeBoundary << " " << x1 ;
761       saux += "FAYCen " + saux1.str() + "\n" ;
762     }
763     { std::stringstream saux1 ;
764       saux1 << NumeBoundary << " " << x2 ;
765       saux += "FAZCen " + saux1.str() + "\n" ;
766     }
767     { std::stringstream saux1 ;
768       saux1 << NumeBoundary << " " << x3 ;
769       saux += "FARayon " + saux1.str() + "\n" ;
770     }
771     { std::stringstream saux1 ;
772       saux1 << NumeBoundary << " " << x4 ;
773       saux += "FAXCen2 " + saux1.str() + "\n" ;
774     }
775     { std::stringstream saux1 ;
776       saux1 << NumeBoundary << " " << x5 ;
777       saux += "FAYCen2 " + saux1.str() + "\n" ;
778     }
779     { std::stringstream saux1 ;
780       saux1 << NumeBoundary << " " << x6 ;
781       saux += "FAZCen2 " + saux1.str() + "\n" ;
782     }
783     { std::stringstream saux1 ;
784       saux1 << NumeBoundary << " " << x7 ;
785       saux += "FARayon2 " + saux1.str() + "\n" ;
786     }
787  }
788 //
789   _Texte += saux + "#\n" ;
790 //
791 }
792 //===============================================================================
793 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
794 {
795   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
796 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
797 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
798 //
799 // Commentaires
800 //
801   std::string saux, saux2 ;
802   std::stringstream saux1 ;
803   saux1 << NumeBoundary ;
804   saux2 = saux1.str() ;
805   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
806 //
807   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
808   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
809 //
810   _Texte += saux + "#\n" ;
811 //
812 }
813 //===============================================================================
814 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
815 {
816   MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
817   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
818   MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
819 //
820 // Type d'interpolation
821 //
822   _Texte += "# Interpolations des champs\n" ;
823   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
824   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
825   if ( TypeFieldInterp == 1 )
826   {
827     _Texte += "CCChaTou oui\n" ;
828   }
829 //
830   _TimeStep = TimeStep ;
831   _Rank = Rank ;
832 //
833 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
834 }
835 //===============================================================================
836 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
837 {
838   MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
839   std::stringstream saux1 ;
840   saux1 << NumeChamp+1 ;
841   std::string saux = saux1.str() ;
842   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
843 //
844   MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
845   if ( _TimeStep >= 0 )
846   {
847     {
848       std::stringstream saux1 ;
849       saux1 << _TimeStep ;
850       _Texte += "CCChaPdT " + saux + " " + saux1.str()  + "\n" ;
851     }
852     {
853       std::stringstream saux1 ;
854       saux1 << _Rank ;
855       _Texte += "CCChaNuO " + saux + " " + saux1.str()  + "\n" ;
856     }
857   }
858 }
859 //===============================================================================
860 void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput )
861 {
862   MESSAGE("TexteAdvanced, Pyram ="<<Pyram<<", NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", LevelOutput ="<<LevelOutput);
863
864   if ( Pyram > 0 )
865   {
866     _Texte += "# Autorisation de pyramides dans le maillage initial\n" ;
867     _Texte += "TypeElem ignore_pyra\n" ;
868   }
869   if ( NivMax > 0 )
870   {
871     _Texte += "# Niveaux extremes\n" ;
872     { std::stringstream saux1 ;
873       saux1 << NivMax ;
874       _Texte += "NiveauMa " + saux1.str() + "\n" ;
875     }
876   }
877   if ( DiamMin > 0 )
878   {
879     _Texte += "# Diametre minimal\n" ;
880     { std::stringstream saux1 ;
881       saux1 << DiamMin ;
882       _Texte += "DiametMi " + saux1.str()  + "\n" ;
883     }
884   }
885   if ( AdapInit != 0 )
886   {
887     if ( AdapInit > 0 )
888     { _Texte += "# Raffinement" ; }
889     else
890     { _Texte += "# Deraffinement" ; }
891     _Texte += " des regions sans indicateur\n" ;
892     { std::stringstream saux1 ;
893       saux1 << AdapInit ;
894       _Texte += "AdapInit " + saux1.str() + "\n" ;
895     }
896   }
897   if ( LevelOutput != 0 )
898   {
899     _Texte += "# Sortie des niveaux de raffinement\n" ;
900     _Texte += "NCNiveau NIVEAU\n" ;
901   }
902 }
903 //===============================================================================
904 void HomardDriver::TexteInfoCompute( int MessInfo )
905 {
906   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
907
908   if ( MessInfo != 0 )
909   {
910      _Texte += "# Messages d'informations\n" ;
911     { std::stringstream saux1 ;
912       saux1 << MessInfo ;
913       _Texte += "MessInfo " + saux1.str()  + "\n" ;
914     }
915    }
916 }
917 //===============================================================================
918 void HomardDriver::CreeFichier( )
919 {
920 //
921   if ( _siter != _siterp1 )
922   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
923   else
924   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
925 //
926   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
927   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
928   Fic.close() ;
929 //
930 }
931 //===============================================================================
932 // Creation du fichier de donnees pour l'information
933 //===============================================================================
934 void HomardDriver::CreeFichierDonn( )
935 {
936 //
937   MESSAGE("CreeFichierDonn");
938   _NomFichierDonn = "info.donn" ;
939 //
940   std::string data ;
941   data  = "0\n" ;
942   data += "0\n" ;
943   data += "q\n" ;
944   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
945   if (Fic.is_open() == true) { Fic << data << std::endl ; }
946   Fic.close() ;
947 //
948 }
949 //===============================================================================
950 int HomardDriver::ExecuteHomard(int option)
951 {
952   MESSAGE("ExecuteHomard, avec option = "<<option);
953   std::string commande ;
954   int codret ;
955 // Copie des Fichiers HOMARD
956   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
957   codret = system(commande.c_str()) ;
958
959 // Execution de HOMARD
960   if ( codret == 0)
961   {
962     commande = _HOMARD_Exec.c_str() ;
963     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
964     codret = system(commande.c_str());
965     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
966     _NomFichierDonn = "" ;
967   };
968   return codret ;
969 }