Salome HOME
Frontière analytique torique
[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   if ( BoundaryType == 5 )
661   { saux += "# Tore\n" ; }
662 //
663 // Le nom de la frontiere
664 //
665   { std::stringstream saux1 ;
666     saux1 << NumeBoundary ;
667     saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
668   }
669 //
670 // Type de frontiere
671 //
672   { std::stringstream saux1 ;
673     saux1 << NumeBoundary << " " << BoundaryType ;
674     saux += "FAType " + saux1.str() + "\n" ;
675   }
676 //
677 // Cas du cylindre
678 //
679   if ( BoundaryType == 1 )
680   {
681     { std::stringstream saux1 ;
682       saux1 << NumeBoundary << " " << x0 ;
683       saux2 = saux1.str() ;
684       saux += "FAXCen " + saux1.str() + "\n" ;
685     }
686     { std::stringstream saux1 ;
687       saux1 << NumeBoundary << " " << x1 ;
688       saux += "FAYCen " + saux1.str() + "\n" ;
689     }
690     { std::stringstream saux1 ;
691       saux1 << NumeBoundary << " " << x2 ;
692       saux += "FAZCen " + saux1.str() + "\n" ;
693     }
694     { std::stringstream saux1 ;
695       saux1 << NumeBoundary << " " << x3 ;
696       saux += "FAXAxe " + saux1.str() + "\n" ;
697     }
698     { std::stringstream saux1 ;
699       saux1 << NumeBoundary << " " << x4 ;
700       saux += "FAYAxe " + saux1.str() + "\n" ;
701     }
702     { std::stringstream saux1 ;
703       saux1 << NumeBoundary << " " << x5 ;
704       saux += "FAZAxe " + saux1.str() + "\n" ;
705     }
706     { std::stringstream saux1 ;
707       saux1 << NumeBoundary << " " << x6 ;
708       saux += "FARayon " + saux1.str() + "\n" ;
709     }
710  }
711 //
712 // Cas de la sphere
713 //
714   else if ( BoundaryType == 2 )
715   {
716     { std::stringstream saux1 ;
717       saux1 << NumeBoundary << " " << x0 ;
718       saux += "FAXCen " + saux1.str() + "\n" ;
719     }
720     { std::stringstream saux1 ;
721       saux1 << NumeBoundary << " " << x1 ;
722       saux += "FAYCen " + saux1.str() + "\n" ;
723     }
724     { std::stringstream saux1 ;
725       saux1 << NumeBoundary << " " << x2 ;
726       saux += "FAZCen " + saux1.str() + "\n" ;
727     }
728     { std::stringstream saux1 ;
729       saux1 << NumeBoundary << " " << x3 ;
730       saux += "FARayon " + saux1.str() + "\n" ;
731     }
732   }
733 //
734 // Cas du cone defini par un axe et un angle
735 //
736   if ( BoundaryType == 3 )
737   {
738     { std::stringstream saux1 ;
739       saux1 << NumeBoundary << " " << x0 ;
740       saux += "FAXAxe " + saux1.str() + "\n" ;
741     }
742     { std::stringstream saux1 ;
743       saux1 << NumeBoundary << " " << x1 ;
744       saux += "FAYAxe " + saux1.str() + "\n" ;
745     }
746     { std::stringstream saux1 ;
747       saux1 << NumeBoundary << " " << x2 ;
748       saux += "FAZAxe " + saux1.str() + "\n" ;
749     }
750     { std::stringstream saux1 ;
751       saux1 << NumeBoundary << " " << x3 ;
752       saux += "FAAngle " + saux1.str() + "\n" ;
753     }
754     { std::stringstream saux1 ;
755       saux1 << NumeBoundary << " " << x4 ;
756       saux += "FAXCen " + saux1.str() + "\n" ;
757     }
758     { std::stringstream saux1 ;
759       saux1 << NumeBoundary << " " << x5 ;
760       saux += "FAYCen " + saux1.str() + "\n" ;
761     }
762     { std::stringstream saux1 ;
763       saux1 << NumeBoundary << " " << x6 ;
764       saux += "FAZCen " + saux1.str() + "\n" ;
765     }
766  }
767 //
768 // Cas du cone defini par les 2 rayons
769 //
770   if ( BoundaryType == 4 )
771   {
772     { std::stringstream saux1 ;
773       saux1 << NumeBoundary << " " << x0 ;
774       saux += "FAXCen " + saux1.str() + "\n" ;
775     }
776     { std::stringstream saux1 ;
777       saux1 << NumeBoundary << " " << x1 ;
778       saux += "FAYCen " + saux1.str() + "\n" ;
779     }
780     { std::stringstream saux1 ;
781       saux1 << NumeBoundary << " " << x2 ;
782       saux += "FAZCen " + saux1.str() + "\n" ;
783     }
784     { std::stringstream saux1 ;
785       saux1 << NumeBoundary << " " << x3 ;
786       saux += "FARayon " + saux1.str() + "\n" ;
787     }
788     { std::stringstream saux1 ;
789       saux1 << NumeBoundary << " " << x4 ;
790       saux += "FAXCen2 " + saux1.str() + "\n" ;
791     }
792     { std::stringstream saux1 ;
793       saux1 << NumeBoundary << " " << x5 ;
794       saux += "FAYCen2 " + saux1.str() + "\n" ;
795     }
796     { std::stringstream saux1 ;
797       saux1 << NumeBoundary << " " << x6 ;
798       saux += "FAZCen2 " + saux1.str() + "\n" ;
799     }
800     { std::stringstream saux1 ;
801       saux1 << NumeBoundary << " " << x7 ;
802       saux += "FARayon2 " + saux1.str() + "\n" ;
803     }
804  }
805 //
806 // Cas du tore
807 //
808   if ( BoundaryType == 5 )
809   {
810     { std::stringstream saux1 ;
811       saux1 << NumeBoundary << " " << x0 ;
812       saux2 = saux1.str() ;
813       saux += "FAXCen " + saux1.str() + "\n" ;
814     }
815     { std::stringstream saux1 ;
816       saux1 << NumeBoundary << " " << x1 ;
817       saux += "FAYCen " + saux1.str() + "\n" ;
818     }
819     { std::stringstream saux1 ;
820       saux1 << NumeBoundary << " " << x2 ;
821       saux += "FAZCen " + saux1.str() + "\n" ;
822     }
823     { std::stringstream saux1 ;
824       saux1 << NumeBoundary << " " << x3 ;
825       saux += "FAXAxe " + saux1.str() + "\n" ;
826     }
827     { std::stringstream saux1 ;
828       saux1 << NumeBoundary << " " << x4 ;
829       saux += "FAYAxe " + saux1.str() + "\n" ;
830     }
831     { std::stringstream saux1 ;
832       saux1 << NumeBoundary << " " << x5 ;
833       saux += "FAZAxe " + saux1.str() + "\n" ;
834     }
835     { std::stringstream saux1 ;
836       saux1 << NumeBoundary << " " << x6 ;
837       saux += "FARayon  " + saux1.str() + "\n" ;
838     }
839     { std::stringstream saux1 ;
840       saux1 << NumeBoundary << " " << x7 ;
841       saux += "FARayon2 " + saux1.str() + "\n" ;
842     }
843  }
844 //
845   _Texte += saux + "#\n" ;
846 //
847 }
848 //===============================================================================
849 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
850 {
851   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
852 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
853 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
854 //
855 // Commentaires
856 //
857   std::string saux, saux2 ;
858   std::stringstream saux1 ;
859   saux1 << NumeBoundary ;
860   saux2 = saux1.str() ;
861   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
862 //
863   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
864   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
865 //
866   _Texte += saux + "#\n" ;
867 //
868 }
869 //===============================================================================
870 // E. Les interpolations
871 //===============================================================================
872 // Les fichiers d'entree et de sortie des champs a interpoler
873 void HomardDriver::TexteFieldInterp( const std::string FieldFile, const std::string MeshFile )
874 {
875   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
876 //
877   _Texte += "#\n# Interpolations des champs\n" ;
878 //
879 // Fichier en entree
880   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
881 // Fichier en sortie
882   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
883 //
884 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
885 }
886 //===============================================================================
887 // Tous les champs sont a interpoler
888 void HomardDriver::TexteFieldInterpAll( )
889 {
890   MESSAGE("TexteFieldInterpAll");
891 //
892   _Texte += "CCChaTou oui\n" ;
893 }
894 //===============================================================================
895 // Ecrit les caracteristiques de chaque interpolation sous la forme :
896 //   CCChaNom 1 "DEPL"     ! Nom du 1er champ a interpoler
897 //   CCChaTIn 1 0          ! Mode d'interpolation : automatique
898 //   CCChaNom 2 "VOLUME"   ! Nom du 2nd champ a interpoler
899 //   CCChaTIn 2 1          ! Mode d'interpolation : une variable extensive
900 //   CCChaPdT 2 14         ! Pas de temps 14
901 //   CCChaNuO 2 14         ! Numero d'ordre 14
902 //   etc.
903 //
904 // NumeChamp : numero d'ordre du champ a interpoler
905 // FieldName : nom du champ
906 // TypeInterp : type d'interpolation
907 // TimeStep : pas de temps retenu (>0 si pas de precision)
908 // Rank : numero d'ordre retenu
909 //
910 void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank)
911 {
912   MESSAGE("TexteFieldInterpNameType, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName<<", TypeInterp = "<<TypeInterp);
913   MESSAGE("TexteFieldInterpNameType, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
914 // Numero d'ordre du champ a interpoler
915   std::stringstream saux1 ;
916   saux1 << NumeChamp ;
917   std::string saux = saux1.str() ;
918 // Nom du champ
919   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
920 // Type d'interpolation pour le champ
921   _Texte +="CCChaTIn " + saux + " " + TypeInterp + "\n" ;
922 //
923   if ( TimeStep >= 0 )
924   {
925     {
926       std::stringstream saux1 ;
927       saux1 << TimeStep ;
928       _Texte += "CCChaPdT " + saux + " " + saux1.str()  + "\n" ;
929     }
930     {
931       std::stringstream saux1 ;
932       saux1 << Rank ;
933       _Texte += "CCChaNuO " + saux + " " + saux1.str()  + "\n" ;
934     }
935   }
936 }
937 //===============================================================================
938 // F. Les options avancees
939 //===============================================================================
940 void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput )
941 {
942   MESSAGE("TexteAdvanced, Pyram ="<<Pyram<<", NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", LevelOutput ="<<LevelOutput);
943
944   if ( Pyram > 0 )
945   {
946     _Texte += "# Autorisation de pyramides dans le maillage initial\n" ;
947     _Texte += "TypeElem ignore_pyra\n" ;
948   }
949   if ( NivMax > 0 )
950   {
951     _Texte += "# Niveaux extremes\n" ;
952     { std::stringstream saux1 ;
953       saux1 << NivMax ;
954       _Texte += "NiveauMa " + saux1.str() + "\n" ;
955     }
956   }
957   if ( DiamMin > 0 )
958   {
959     _Texte += "# Diametre minimal\n" ;
960     { std::stringstream saux1 ;
961       saux1 << DiamMin ;
962       _Texte += "DiametMi " + saux1.str()  + "\n" ;
963     }
964   }
965   if ( AdapInit != 0 )
966   {
967     if ( AdapInit > 0 )
968     { _Texte += "# Raffinement" ; }
969     else
970     { _Texte += "# Deraffinement" ; }
971     _Texte += " des regions sans indicateur\n" ;
972     { std::stringstream saux1 ;
973       saux1 << AdapInit ;
974       _Texte += "AdapInit " + saux1.str() + "\n" ;
975     }
976   }
977   if ( LevelOutput != 0 )
978   {
979     _Texte += "# Sortie des niveaux de raffinement\n" ;
980     _Texte += "NCNiveau NIVEAU\n" ;
981   }
982 }
983 //===============================================================================
984 // G. Les messages
985 //===============================================================================
986 void HomardDriver::TexteInfoCompute( int MessInfo )
987 {
988   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
989
990   if ( MessInfo != 0 )
991   {
992      _Texte += "# Messages d'informations\n" ;
993     { std::stringstream saux1 ;
994       saux1 << MessInfo ;
995       _Texte += "MessInfo " + saux1.str()  + "\n" ;
996     }
997    }
998 }
999 //===============================================================================
1000 void HomardDriver::CreeFichier( )
1001 {
1002 //
1003   if ( _siter != _siterp1 )
1004   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
1005   else
1006   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
1007 //
1008   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
1009   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
1010   Fic.close() ;
1011 //
1012 }
1013 //===============================================================================
1014 // Creation du fichier de donnees pour l'information
1015 //===============================================================================
1016 void HomardDriver::CreeFichierDonn( )
1017 {
1018 //
1019   MESSAGE("CreeFichierDonn");
1020   _NomFichierDonn = "info.donn" ;
1021 //
1022   std::string data ;
1023   data  = "0\n" ;
1024   data += "0\n" ;
1025   data += "q\n" ;
1026   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
1027   if (Fic.is_open() == true) { Fic << data << std::endl ; }
1028   Fic.close() ;
1029 //
1030 }
1031 //===============================================================================
1032 int HomardDriver::ExecuteHomard(int option)
1033 {
1034   MESSAGE("ExecuteHomard, avec option = "<<option);
1035   std::string commande ;
1036   int codret ;
1037 // Copie des Fichiers HOMARD
1038   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
1039   codret = system(commande.c_str()) ;
1040
1041 // Execution de HOMARD
1042   if ( codret == 0)
1043   {
1044     commande = _HOMARD_Exec.c_str() ;
1045     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
1046     codret = system(commande.c_str());
1047     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
1048     _NomFichierDonn = "" ;
1049   };
1050   return codret ;
1051 }