Salome HOME
InfoCompute
[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   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   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 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
538                int TypeThR, double ThreshR, int TypeThC, double ThreshC,
539                int UsField, int UsCmpI )
540 {
541   MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
542   MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
543
544   std::string saux, saux2 ;
545 //
546 //
547   _Texte += "# Champ d'indicateurs\n" ;
548   _Texte += "CCIndica \"" + FieldFile  + "\"\n" ;
549   _Texte += "CCNoChaI \"" + FieldName  + "\"\n" ;
550
551 // Cas ou on prend le dernier pas de temps
552   if ( TimeStep == -2 )
553   { _Texte += "CCNumPTI Last\n" ; }
554 // Cas avec pas de temps
555   else if ( TimeStep >= 0 )
556   {
557     {
558       std::stringstream saux1 ;
559       saux1 << TimeStep ;
560       saux2 = saux1.str() ;
561       _Texte += "CCNumPTI " + saux2  + "\n" ;
562     }
563     {
564       std::stringstream saux1 ;
565       saux1 << Rank ;
566       saux2 = saux1.str() ;
567       _Texte += "CCNumOrI " + saux2  + "\n" ;
568     }
569   }
570 //
571   saux = " " ;
572   if ( TypeThR == 1 )
573   { saux = "Hau" ; }
574   if ( TypeThR == 2 )
575   { saux = "HRe" ; }
576   if ( TypeThR == 3 )
577   { saux = "HPE" ; }
578   if ( TypeThR == 4 )
579   { saux = "HMS" ; }
580   if ( saux != " " )
581   {
582     std::stringstream saux1 ;
583     saux1 << ThreshR ;
584     saux2 = saux1.str() ;
585     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
586   }
587 //
588   saux = " " ;
589   if ( TypeThC == 1 )
590   { saux = "Bas" ; }
591   if ( TypeThC == 2 )
592   { saux = "BRe" ; }
593   if ( TypeThC == 3 )
594   { saux = "BPE" ; }
595   if ( TypeThC == 4 )
596   { saux = "BMS" ; }
597   if ( saux != " " )
598   {
599     std::stringstream saux1 ;
600     saux1 << ThreshC ;
601     saux2 = saux1.str() ;
602     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
603   }
604 //
605   saux = " " ;
606   if ( UsField == 0 )
607   { saux = "MAILLE" ; }
608   if ( UsField == 1 )
609   { saux = "SAUT" ; }
610   if ( saux != " " )
611   {
612     _Texte += "CCModeFI " + saux  + "\n" ;
613   }
614 //
615   saux = " " ;
616   if ( UsCmpI == 0 )
617   { saux = "L2" ; }
618   if ( UsCmpI == 1 )
619   { saux = "INFINI" ; }
620   if ( UsCmpI == 2 )
621   { saux = "V_RELATIVE" ; }
622   if ( saux != " " )
623   {
624     _Texte += "CCUsCmpI " + saux  + "\n" ;
625   }
626 }
627 //===============================================================================
628 void HomardDriver::TexteGroup( const std::string GroupName )
629 {
630   MESSAGE("TexteGroup, GroupName = "<<GroupName);
631 //
632   _Texte += "CCGroAda \"" + GroupName  + "\"\n" ;
633 //
634 }
635 //===============================================================================
636 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
637 {
638   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
639 //
640 // Type de suivi de frontiere
641 //
642   std::stringstream saux1 ;
643   saux1 << BoundaryOption ;
644   std::string saux = saux1.str() ;
645   _Texte += "SuivFron " + saux + "\n" ;
646 //
647 }
648 //===============================================================================
649 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
650 {
651   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
652   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
653 //
654   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
655   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
656 //
657 }
658 //===============================================================================
659 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
660 {
661   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
662 //
663   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
664 //
665 }
666 //===============================================================================
667 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 )
668 {
669   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
670 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
671   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
672 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
673 //
674   std::string saux, saux2 ;
675 //
676 // Commentaires
677 //
678   std::stringstream saux1 ;
679   saux1 << NumeBoundary ;
680   saux2 = saux1.str() ;
681   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
682   if ( BoundaryType == 1 )
683   { saux += "# Cylindre\n" ; }
684   if ( BoundaryType == 2 )
685   { saux += "# Sphere\n" ; }
686   if ( BoundaryType == 3 or BoundaryType == 4 )
687   { saux += "# Cone\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 // Cas du cone defini par un axe et un angle
773 //
774   if ( BoundaryType == 3 )
775   {
776     { std::stringstream saux1 ;
777       saux1 << NumeBoundary << " " << x0 ;
778       saux2 = saux1.str() ;
779       saux += "FAXAxe " + saux2 + "\n" ;
780     }
781     { std::stringstream saux1 ;
782       saux1 << NumeBoundary << " " << x1 ;
783       saux2 = saux1.str() ;
784       saux += "FAYAxe " + saux2 + "\n" ;
785     }
786     { std::stringstream saux1 ;
787       saux1 << NumeBoundary << " " << x2 ;
788       saux2 = saux1.str() ;
789       saux += "FAZAxe " + saux2 + "\n" ;
790     }
791     { std::stringstream saux1 ;
792       saux1 << NumeBoundary << " " << x3 ;
793       saux2 = saux1.str() ;
794       saux += "FAAngle " + saux2 + "\n" ;
795     }
796     { std::stringstream saux1 ;
797       saux1 << NumeBoundary << " " << x4 ;
798       saux2 = saux1.str() ;
799       saux += "FAXCen " + saux2 + "\n" ;
800     }
801     { std::stringstream saux1 ;
802       saux1 << NumeBoundary << " " << x5 ;
803       saux2 = saux1.str() ;
804       saux += "FAYCen " + saux2 + "\n" ;
805     }
806     { std::stringstream saux1 ;
807       saux1 << NumeBoundary << " " << x6 ;
808       saux2 = saux1.str() ;
809       saux += "FAZCen " + saux2 + "\n" ;
810     }
811  }
812 //
813 // Cas du cone defini par les 2 rayons
814 //
815   if ( BoundaryType == 4 )
816   {
817     { std::stringstream saux1 ;
818       saux1 << NumeBoundary << " " << x0 ;
819       saux2 = saux1.str() ;
820       saux += "FAXCen " + saux2 + "\n" ;
821     }
822     { std::stringstream saux1 ;
823       saux1 << NumeBoundary << " " << x1 ;
824       saux2 = saux1.str() ;
825       saux += "FAYCen " + saux2 + "\n" ;
826     }
827     { std::stringstream saux1 ;
828       saux1 << NumeBoundary << " " << x2 ;
829       saux2 = saux1.str() ;
830       saux += "FAZCen " + saux2 + "\n" ;
831     }
832     { std::stringstream saux1 ;
833       saux1 << NumeBoundary << " " << x3 ;
834       saux2 = saux1.str() ;
835       saux += "FARayon " + saux2 + "\n" ;
836     }
837     { std::stringstream saux1 ;
838       saux1 << NumeBoundary << " " << x4 ;
839       saux2 = saux1.str() ;
840       saux += "FAXCen2 " + saux2 + "\n" ;
841     }
842     { std::stringstream saux1 ;
843       saux1 << NumeBoundary << " " << x5 ;
844       saux2 = saux1.str() ;
845       saux += "FAYCen2 " + saux2 + "\n" ;
846     }
847     { std::stringstream saux1 ;
848       saux1 << NumeBoundary << " " << x6 ;
849       saux2 = saux1.str() ;
850       saux += "FAZCen2 " + saux2 + "\n" ;
851     }
852     { std::stringstream saux1 ;
853       saux1 << NumeBoundary << " " << x7 ;
854       saux2 = saux1.str() ;
855       saux += "FARayon2 " + saux2 + "\n" ;
856     }
857  }
858 //
859   _Texte += saux + "#\n" ;
860 //
861 }
862 //===============================================================================
863 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
864 {
865   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
866 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
867 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
868 //
869 // Commentaires
870 //
871   std::string saux, saux2 ;
872   std::stringstream saux1 ;
873   saux1 << NumeBoundary ;
874   saux2 = saux1.str() ;
875   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
876 //
877   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
878   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
879 //
880   _Texte += saux + "#\n" ;
881 //
882 }
883 //===============================================================================
884 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
885 {
886   MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
887   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
888   MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
889 //
890 // Type d'interpolation
891 //
892   _Texte += "# Interpolations des champs\n" ;
893   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
894   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
895   if ( TypeFieldInterp == 1 )
896   {
897     _Texte += "CCChaTou oui\n" ;
898   }
899 //
900   _TimeStep = TimeStep ;
901   _Rank = Rank ;
902 //
903 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
904 }
905 //===============================================================================
906 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
907 {
908   MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
909   std::stringstream saux1 ;
910   saux1 << NumeChamp+1 ;
911   std::string saux = saux1.str() ;
912   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
913 //
914   MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
915   if ( _TimeStep >= 0 )
916   {
917     {
918       std::stringstream saux1 ;
919       saux1 << _TimeStep ;
920       std::string saux2 = saux1.str() ;
921       _Texte += "CCChaPdT " + saux + " " + saux2  + "\n" ;
922     }
923     {
924       std::stringstream saux1 ;
925       saux1 << _Rank ;
926       std::string saux2 = saux1.str() ;
927       _Texte += "CCChaNuO " + saux + " " + saux2  + "\n" ;
928     }
929   }
930 }
931 //===============================================================================
932 void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput )
933 {
934   MESSAGE("TexteAdvanced, Pyram ="<<Pyram<<", NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", LevelOutput ="<<LevelOutput);
935
936   if ( Pyram > 0 )
937   {
938     _Texte += "# Autorisation de pyramides dans le maillage initial\n" ;
939     _Texte += "TypeElem ignore_pyra\n" ;
940   }
941   if ( NivMax > 0 )
942   {
943     _Texte += "# Niveaux extremes\n" ;
944     { std::stringstream saux1 ;
945       saux1 << NivMax ;
946       std::string saux2 = saux1.str() ;
947       _Texte += "NiveauMa " + saux2 + "\n" ;
948     }
949   }
950   if ( DiamMin > 0 )
951   {
952     _Texte += "# Diametre minimal\n" ;
953     { std::stringstream saux1 ;
954       saux1 << DiamMin ;
955       std::string saux2 = saux1.str() ;
956       _Texte += "DiametMi " + saux2  + "\n" ;
957     }
958   }
959   if ( AdapInit != 0 )
960   {
961     if ( AdapInit > 0 )
962     { _Texte += "# Raffinement" ; }
963     else
964     { _Texte += "# Deraffinement" ; }
965     _Texte += " des regions sans indicateur\n" ;
966     { std::stringstream saux1 ;
967       saux1 << AdapInit ;
968       std::string saux2 = saux1.str() ;
969       _Texte += "AdapInit " + saux2 + "\n" ;
970     }
971   }
972   if ( LevelOutput != 0 )
973   {
974     _Texte += "# Sortie des niveaux de raffinement\n" ;
975     _Texte += "NCNiveau NIVEAU\n" ;
976   }
977 }
978 //===============================================================================
979 void HomardDriver::TexteInfoCompute( int MessInfo )
980 {
981   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
982
983   if ( MessInfo != 0 )
984   {
985      _Texte += "# Messages d'informations\n" ;
986     { std::stringstream saux1 ;
987       saux1 << MessInfo ;
988       std::string saux2 = saux1.str() ;
989       _Texte += "MessInfo " + saux2  + "\n" ;
990     }
991    }
992 }
993 //===============================================================================
994 void HomardDriver::CreeFichier( )
995 {
996 //
997   if ( _siter != _siterp1 )
998   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
999   else
1000   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
1001 //
1002   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
1003   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
1004   Fic.close() ;
1005 //
1006 }
1007 //===============================================================================
1008 // Creation du fichier de donnees pour l'information
1009 //===============================================================================
1010 void HomardDriver::CreeFichierDonn( )
1011 {
1012 //
1013   MESSAGE("CreeFichierDonn");
1014   _NomFichierDonn = "info.donn" ;
1015 //
1016   std::string data ;
1017   data  = "0\n" ;
1018   data += "0\n" ;
1019   data += "q\n" ;
1020   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
1021   if (Fic.is_open() == true) { Fic << data << std::endl ; }
1022   Fic.close() ;
1023 //
1024 }
1025 //===============================================================================
1026 int HomardDriver::ExecuteHomard(int option)
1027 {
1028   MESSAGE("ExecuteHomard, avec option = "<<option);
1029   std::string commande ;
1030   int codret ;
1031 // Copie des Fichiers HOMARD
1032   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
1033   codret = system(commande.c_str()) ;
1034
1035 // Execution de HOMARD
1036   if ( codret == 0)
1037   {
1038     commande = _HOMARD_Exec.c_str() ;
1039     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
1040     codret = system(commande.c_str());
1041     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
1042     _NomFichierDonn = "" ;
1043   };
1044   return codret ;
1045 }