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