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