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