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