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