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