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