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