Salome HOME
integration of modifications from Gerald Nicolas
[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( "" ), _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 DirComputePa, const std::string MessFile )
64 {
65   MESSAGE("TexteInit, MessFile ="<<MessFile<<", DirCompute ="<<DirCompute<<", DirComputePa ="<<DirComputePa);
66 //
67   _Texte  = "Action   homa\n" ;
68   _Texte += "CCAssoci med\n" ;
69   _Texte += "ModeHOMA 1\n" ;
70   _Texte += "NumeIter " + _siter + "\n" ;
71   _Texte += "ListeStd \"" + MessFile + "\"\n" ;
72   _Texte += "# Maillages HOMARD \n" ;
73   _Texte += "HOMaiN__ Mai" + _siter   + " \"" + DirComputePa + "/maill." + _siter   + ".hom.med\"\n" ;
74   _Texte += "HOMaiNP1 Mai" + _siterp1 + " \"" + DirCompute   + "/maill." + _siterp1 + ".hom.med\"\n" ;
75   _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
76 //
77 }
78
79 ////=============================================================================
80 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
81 {
82   MESSAGE("TexteMaillage, NomMesh ="<<NomMesh<<", MeshFile ="<<MeshFile);
83   std::string saux ;
84   saux = "P1" ;
85   if ( apres < 1 ) { saux = "__" ; }
86
87   _Texte += "# Maillages Med " + saux + "\n" ;
88   _Texte += "CCNoMN" + saux + " \"" + NomMesh  + "\"\n" ;
89   _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
90 }
91
92 ////=============================================================================
93 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
94 {
95   MESSAGE("TexteConfRaffDera, ConfType ="<<ConfType);
96   MESSAGE("TexteConfRaffDera, TypeAdap ="<<TypeAdap<<", TypeRaff ="<<TypeRaff<<", TypeDera ="<<TypeDera);
97 //
98 // Type de conformite
99 //
100   std::string saux ;
101   switch (ConfType)
102   {
103     case 1: //
104     {
105       saux = "conforme" ;
106       break;
107     }
108     case 2: //
109     {
110       saux = "non_conforme_1_noeud" ;
111       break;
112     }
113     case 3: //
114     {
115       saux = "non_conforme_1_arete" ;
116       break;
117     }
118     case 4: //
119     {
120       saux = "non_conforme_indicateur" ;
121       break;
122     }
123   }
124   _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
125 //
126 // Type de raffinement/deraffinement
127 //
128   if ( TypeAdap == -1 )
129   {
130     if ( TypeRaff == 1 )
131     {
132       saux = "TypeRaff uniforme\n" ;
133     }
134     else
135     {
136       saux = "TypeRaff non\n" ;
137     }
138     if ( TypeDera == 1 )
139     {
140       saux += "TypeDera uniforme" ;
141     }
142     else
143     {
144       saux += "TypeDera non" ;
145     }
146   }
147   else
148   {
149     if ( TypeRaff == 1 )
150     {
151       saux = "TypeRaff libre\n" ;
152     }
153     else
154     {
155       saux = "TypeRaff non\n" ;
156     }
157     if ( TypeDera == 1 )
158     {
159       saux += "TypeDera libre" ;
160     }
161     else
162     {
163       saux += "TypeDera non" ;
164     }
165   }
166   _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
167 //
168 //   MESSAGE("A la fin de HomardDriver::TexteConfRaffDera, _Texte ="<<_Texte);
169 }
170 ////=============================================================================
171 void HomardDriver::TexteCompo( int NumeComp, const std::string NompCompo)
172 {
173   MESSAGE("TexteCompo, NumeComp = "<<NumeComp<<", NompCompo = "<<NompCompo);
174   _Texte +="CCCoChaI \"" + NompCompo + "\"\n" ;
175 }
176
177 ////=============================================================================
178 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 )
179 {
180   MESSAGE("TexteZone, NumeZone = "<<NumeZone<<", ZoneType = "<<ZoneType<<", TypeUse = "<<TypeUse);
181   MESSAGE("TexteZone, coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6<<","<<x7<<","<<x8);
182 //
183   std::string saux, saux2 ;
184 //
185 // Type de zones
186 // On convertit le type de zone au sens du module HOMARD dans Salome, ZoneType, dans le
187 // type au sens de l'executable HOMARD, ZoneTypeHOMARD
188 // Attention a mettre le bon signe a ZoneTypeHOMARD :
189 //    >0 signifie que l'on raffinera les mailles contenues dans la zone,
190 //    <0 signifie que l'on deraffinera
191 //
192   int ZoneTypeHOMARD ;
193   if ( ZoneType >= 11 and ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
194   else if ( ZoneType >= 31 and ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
195   else if ( ZoneType >= 61 and ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
196   else { ZoneTypeHOMARD = ZoneType ; }
197 //
198   if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
199 //
200   std::stringstream saux1 ;
201   saux1 << NumeZone ;
202   saux2 = saux1.str() ;
203   saux = "#\n# Zone numero " + saux2 + "\n" ;
204 //
205   { std::stringstream saux1 ;
206     saux1 << NumeZone << " " << ZoneTypeHOMARD ;
207     saux2 = saux1.str() ;
208     saux += "ZoRaType " + saux2 + "\n" ;
209   }
210 //
211 // Cas du rectangle
212 //
213   if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
214 //                                        Y Homard <=> Y Salome
215   {
216     saux += "#Rectangle\n" ;
217     { std::stringstream saux1 ;
218       saux1 << NumeZone << " " << x0 ;
219       saux2 = saux1.str() ;
220       saux += "ZoRaXmin " + saux2 + "\n" ;
221     }
222     { std::stringstream saux1 ;
223       saux1 << NumeZone << " " << x1 ;
224       saux2 = saux1.str() ;
225       saux += "ZoRaXmax " + saux2 + "\n" ;
226     }
227     { std::stringstream saux1 ;
228       saux1 << NumeZone << " " << x2 ;
229       saux2 = saux1.str() ;
230       saux += "ZoRaYmin " + saux2 + "\n" ;
231     }
232     { std::stringstream saux1 ;
233       saux1 << NumeZone << " " << x3 ;
234       saux2 = saux1.str() ;
235       saux += "ZoRaYmax " + saux2 + "\n" ;
236     }
237   }
238 //
239   else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
240 //                                             Y Homard <=> Z Salome
241   {
242     saux += "#Rectangle\n" ;
243     { std::stringstream saux1 ;
244       saux1 << NumeZone << " " << x2 ;
245       saux2 = saux1.str() ;
246       saux += "ZoRaXmin " + saux2 + "\n" ;
247     }
248     { std::stringstream saux1 ;
249       saux1 << NumeZone << " " << x3 ;
250       saux2 = saux1.str() ;
251       saux += "ZoRaXmax " + saux2 + "\n" ;
252     }
253     { std::stringstream saux1 ;
254       saux1 << NumeZone << " " << x4 ;
255       saux2 = saux1.str() ;
256       saux += "ZoRaYmin " + saux2 + "\n" ;
257     }
258     { std::stringstream saux1 ;
259       saux1 << NumeZone << " " << x5 ;
260       saux2 = saux1.str() ;
261       saux += "ZoRaYmax " + saux2 + "\n" ;
262     }
263   }
264 //
265   else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
266 //                                             Y Homard <=> Z Salome
267   {
268     saux += "#Rectangle\n" ;
269     { std::stringstream saux1 ;
270       saux1 << NumeZone << " " << x0 ;
271       saux2 = saux1.str() ;
272       saux += "ZoRaXmin " + saux2 + "\n" ;
273     }
274     { std::stringstream saux1 ;
275       saux1 << NumeZone << " " << x1 ;
276       saux2 = saux1.str() ;
277       saux += "ZoRaXmax " + saux2 + "\n" ;
278     }
279     { std::stringstream saux1 ;
280       saux1 << NumeZone << " " << x4 ;
281       saux2 = saux1.str() ;
282       saux += "ZoRaYmin " + saux2 + "\n" ;
283     }
284     { std::stringstream saux1 ;
285       saux1 << NumeZone << " " << x5 ;
286       saux2 = saux1.str() ;
287       saux += "ZoRaYmax " + saux2 + "\n" ;
288     }
289   }
290 //
291 // Cas du parallelepipede
292 //
293   else if ( ZoneType == 2 )
294   {
295     saux += "# Boite\n" ;
296     { std::stringstream saux1 ;
297       saux1 << NumeZone << " " << x0 ;
298       saux2 = saux1.str() ;
299       saux += "ZoRaXmin " + saux2 + "\n" ;
300     }
301     { std::stringstream saux1 ;
302       saux1 << NumeZone << " " << x1 ;
303       saux2 = saux1.str() ;
304       saux += "ZoRaXmax " + saux2 + "\n" ;
305     }
306     { std::stringstream saux1 ;
307       saux1 << NumeZone << " " << x2 ;
308       saux2 = saux1.str() ;
309       saux += "ZoRaYmin " + saux2 + "\n" ;
310     }
311     { std::stringstream saux1 ;
312       saux1 << NumeZone << " " << x3 ;
313       saux2 = saux1.str() ;
314       saux += "ZoRaYmax " + saux2 + "\n" ;
315     }
316     { std::stringstream saux1 ;
317       saux1 << NumeZone << " " << x4 ;
318       saux2 = saux1.str() ;
319       saux += "ZoRaZmin " + saux2 + "\n" ;
320     }
321     { std::stringstream saux1 ;
322       saux1 << NumeZone << " " << x5 ;
323       saux2 = saux1.str() ;
324       saux += "ZoRaZmax " + saux2 + "\n" ;
325     }
326   }
327 //
328 // Cas du disque
329 //
330   else if ( ZoneType == 31 or ZoneType == 61 )
331   {
332     saux += "# Sphere\n" ;
333     { std::stringstream saux1 ;
334       saux1 << NumeZone << " " << x0 ;
335       saux2 = saux1.str() ;
336       saux += "ZoRaXCen " + saux2 + "\n" ;
337     }
338     { std::stringstream saux1 ;
339       saux1 << NumeZone << " " << x1 ;
340       saux2 = saux1.str() ;
341       saux += "ZoRaYCen " + saux2 + "\n" ;
342     }
343     { std::stringstream saux1 ;
344       saux1 << NumeZone << " " << x6 ;
345       saux2 = saux1.str() ;
346       if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
347       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
348     }
349     if ( ZoneType == 61 )
350     { std::stringstream saux1 ;
351       saux1 << NumeZone << " " << x8 ;
352       saux2 = saux1.str() ;
353       saux += "ZoRaRayI " + saux2 + "\n" ;
354     }
355   }
356   else if ( ZoneType == 32 or ZoneType == 62 )
357   {
358     saux += "# Sphere\n" ;
359     { std::stringstream saux1 ;
360       saux1 << NumeZone << " " << x1 ;
361       saux2 = saux1.str() ;
362       saux += "ZoRaXCen " + saux2 + "\n" ;
363     }
364     { std::stringstream saux1 ;
365       saux1 << NumeZone << " " << x2 ;
366       saux2 = saux1.str() ;
367       saux += "ZoRaYCen " + saux2 + "\n" ;
368     }
369     { std::stringstream saux1 ;
370       saux1 << NumeZone << " " << x6 ;
371       saux2 = saux1.str() ;
372       if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
373       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
374     }
375     if ( ZoneType == 62 )
376     { std::stringstream saux1 ;
377       saux1 << NumeZone << " " << x8 ;
378       saux2 = saux1.str() ;
379       saux += "ZoRaRayI " + saux2 + "\n" ;
380     }
381   }
382   else if ( ZoneType == 33 or ZoneType == 63 )
383   {
384     saux += "# Sphere\n" ;
385     { std::stringstream saux1 ;
386       saux1 << NumeZone << " " << x0 ;
387       saux2 = saux1.str() ;
388       saux += "ZoRaXCen " + saux2 + "\n" ;
389     }
390     { std::stringstream saux1 ;
391       saux1 << NumeZone << " " << x2 ;
392       saux2 = saux1.str() ;
393       saux += "ZoRaYCen " + saux2 + "\n" ;
394     }
395     { std::stringstream saux1 ;
396       saux1 << NumeZone << " " << x6 ;
397       saux2 = saux1.str() ;
398       if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
399       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
400     }
401     if ( ZoneType == 63 )
402     { std::stringstream saux1 ;
403       saux1 << NumeZone << " " << x8 ;
404       saux2 = saux1.str() ;
405       saux += "ZoRaRayI " + saux2 + "\n" ;
406     }
407   }
408 //
409 // Cas de la sphere
410 //
411   else if ( ZoneType == 4 )
412   {
413     saux += "# Sphere\n" ;
414     { std::stringstream saux1 ;
415       saux1 << NumeZone << " " << x0 ;
416       saux2 = saux1.str() ;
417       saux += "ZoRaXCen " + saux2 + "\n" ;
418     }
419     { std::stringstream saux1 ;
420       saux1 << NumeZone << " " << x1 ;
421       saux2 = saux1.str() ;
422       saux += "ZoRaYCen " + saux2 + "\n" ;
423     }
424     { std::stringstream saux1 ;
425       saux1 << NumeZone << " " << x2 ;
426       saux2 = saux1.str() ;
427       saux += "ZoRaZCen " + saux2 + "\n" ;
428     }
429     { std::stringstream saux1 ;
430       saux1 << NumeZone << " " << x3 ;
431       saux2 = saux1.str() ;
432       saux += "ZoRaRayo " + saux2 + "\n" ;
433     }
434   }
435 //
436 // Cas du cylindre ou du tuyau
437 //
438   else if ( ZoneType == 5 or ZoneType == 7 )
439   {
440     if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
441     else                 { saux += "# Tuyau\n" ; }
442     { std::stringstream saux1 ;
443       saux1 << NumeZone << " " << x0 ;
444       saux2 = saux1.str() ;
445       saux += "ZoRaXBas " + saux2 + "\n" ;
446     }
447     { std::stringstream saux1 ;
448       saux1 << NumeZone << " " << x1 ;
449       saux2 = saux1.str() ;
450       saux += "ZoRaYBas " + saux2 + "\n" ;
451     }
452     { std::stringstream saux1 ;
453       saux1 << NumeZone << " " << x2 ;
454       saux2 = saux1.str() ;
455       saux += "ZoRaZBas " + saux2 + "\n" ;
456     }
457     { std::stringstream saux1 ;
458       saux1 << NumeZone << " " << x3 ;
459       saux2 = saux1.str() ;
460       saux += "ZoRaXAxe " + saux2 + "\n" ;
461     }
462     { std::stringstream saux1 ;
463       saux1 << NumeZone << " " << x4 ;
464       saux2 = saux1.str() ;
465       saux += "ZoRaYAxe " + saux2 + "\n" ;
466     }
467     { std::stringstream saux1 ;
468       saux1 << NumeZone << " " << x5 ;
469       saux2 = saux1.str() ;
470       saux += "ZoRaZAxe " + saux2 + "\n" ;
471     }
472     { std::stringstream saux1 ;
473       saux1 << NumeZone << " " << x6 ;
474       saux2 = saux1.str() ;
475      if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
476      else                 { saux += "ZoRaRayE " + saux2 + "\n" ; }
477     }
478     { std::stringstream saux1 ;
479       saux1 << NumeZone << " " << x7 ;
480       saux2 = saux1.str() ;
481       saux += "ZoRaHaut " + saux2 + "\n" ;
482     }
483     if ( ZoneType == 7 )
484     { std::stringstream saux1 ;
485       saux1 << NumeZone << " " << x8 ;
486       saux2 = saux1.str() ;
487       saux += "ZoRaRayI " + saux2 + "\n" ;
488     }
489   }
490 //
491   _Texte += saux + "#\n" ;
492 //
493 //   MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
494 }
495
496 ////=============================================================================
497 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
498                int TypeThR, double ThreshR, int TypeThC, double ThreshC,
499                int UsField, int UsCmpI )
500 {
501   MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
502   MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
503
504   std::string saux, saux2 ;
505 //
506 //
507   _Texte += "# Champ d'indicateurs\n" ;
508   _Texte += "CCIndica \"" + FieldFile  + "\"\n" ;
509   _Texte += "CCNoChaI \"" + FieldName  + "\"\n" ;
510
511 // Cas ou on prend le dernier pas de temps
512   if ( TimeStep == -2 )
513   { _Texte += "CCNumPTI Last\n" ; }
514 // Cas avec pas de temps
515   else if ( TimeStep >= 0 )
516   {
517     {
518       std::stringstream saux1 ;
519       saux1 << TimeStep ;
520       saux2 = saux1.str() ;
521       _Texte += "CCNumPTI " + saux2  + "\n" ;
522     }
523     {
524       std::stringstream saux1 ;
525       saux1 << Rank ;
526       saux2 = saux1.str() ;
527       _Texte += "CCNumOrI " + saux2  + "\n" ;
528     }
529   }
530 //
531   saux = " " ;
532   if ( TypeThR == 1 )
533   { saux = "Hau" ; }
534   if ( TypeThR == 2 )
535   { saux = "HRe" ; }
536   if ( TypeThR == 3 )
537   { saux = "HPE" ; }
538   if ( TypeThR == 4 )
539   { saux = "HMS" ; }
540   if ( saux != " " )
541   {
542     std::stringstream saux1 ;
543     saux1 << ThreshR ;
544     saux2 = saux1.str() ;
545     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
546   }
547 //
548   saux = " " ;
549   if ( TypeThC == 1 )
550   { saux = "Bas" ; }
551   if ( TypeThC == 2 )
552   { saux = "BRe" ; }
553   if ( TypeThC == 3 )
554   { saux = "BPE" ; }
555   if ( TypeThC == 4 )
556   { saux = "BMS" ; }
557   if ( saux != " " )
558   {
559     std::stringstream saux1 ;
560     saux1 << ThreshC ;
561     saux2 = saux1.str() ;
562     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
563   }
564 //
565   saux = " " ;
566   if ( UsField == 0 )
567   { saux = "MAILLE" ; }
568   if ( UsField == 1 )
569   { saux = "SAUT" ; }
570   if ( saux != " " )
571   {
572     _Texte += "CCModeFI " + saux  + "\n" ;
573   }
574 //
575   saux = " " ;
576   if ( UsCmpI == 0 )
577   { saux = "L2" ; }
578   if ( UsCmpI == 1 )
579   { saux = "INFINI" ; }
580   if ( UsCmpI == 2 )
581   { saux = "V_RELATIVE" ; }
582   if ( saux != " " )
583   {
584     _Texte += "CCUsCmpI " + saux  + "\n" ;
585   }
586 }
587
588 ////=============================================================================
589 void HomardDriver::TexteGroup( const std::string GroupName )
590 {
591   MESSAGE("TexteGroup, GroupName = "<<GroupName);
592 //
593   _Texte += "CCGroAda \"" + GroupName  + "\"\n" ;
594 //
595 }
596 ////=============================================================================
597 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
598 {
599   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
600 //
601 // Type de suivi de frontiere
602 //
603   std::stringstream saux1 ;
604   saux1 << BoundaryOption ;
605   std::string saux = saux1.str() ;
606   _Texte += "SuivFron " + saux + "\n" ;
607 //
608 }
609 ////=============================================================================
610 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
611 {
612   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
613   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
614 //
615   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
616   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
617 //
618 }
619 ////=============================================================================
620 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
621 {
622   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
623 //
624   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
625 //
626 }
627 ////=============================================================================
628 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 )
629 {
630   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
631 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
632   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
633 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6);
634 //
635   std::string saux, saux2 ;
636 //
637 // Commentaires
638 //
639   std::stringstream saux1 ;
640   saux1 << NumeBoundary ;
641   saux2 = saux1.str() ;
642   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
643   if ( BoundaryType == 1 )
644   { saux += "# Cylindre\n" ; }
645   if ( BoundaryType == 2 )
646   { saux += "# Sphere\n" ; }
647 //
648 // Le nom de la frontiere
649 //
650   { std::stringstream saux1 ;
651     saux1 << NumeBoundary ;
652     saux2 = saux1.str() ;
653     saux += "FANom " + saux2 + " \"" + NameBoundary + "\"\n" ;
654   }
655 //
656 // Type de frontiere
657 //
658   { std::stringstream saux1 ;
659     saux1 << NumeBoundary << " " << BoundaryType ;
660     saux2 = saux1.str() ;
661     saux += "FAType " + saux2 + "\n" ;
662   }
663 //
664 // Cas du cylindre
665 //
666   if ( BoundaryType == 1 )
667   {
668     { std::stringstream saux1 ;
669       saux1 << NumeBoundary << " " << x0 ;
670       saux2 = saux1.str() ;
671       saux += "FAXCen " + saux2 + "\n" ;
672     }
673     { std::stringstream saux1 ;
674       saux1 << NumeBoundary << " " << x1 ;
675       saux2 = saux1.str() ;
676       saux += "FAYCen " + saux2 + "\n" ;
677     }
678     { std::stringstream saux1 ;
679       saux1 << NumeBoundary << " " << x2 ;
680       saux2 = saux1.str() ;
681       saux += "FAZCen " + saux2 + "\n" ;
682     }
683     { std::stringstream saux1 ;
684       saux1 << NumeBoundary << " " << x3 ;
685       saux2 = saux1.str() ;
686       saux += "FAXAxe " + saux2 + "\n" ;
687     }
688     { std::stringstream saux1 ;
689       saux1 << NumeBoundary << " " << x4 ;
690       saux2 = saux1.str() ;
691       saux += "FAYAxe " + saux2 + "\n" ;
692     }
693     { std::stringstream saux1 ;
694       saux1 << NumeBoundary << " " << x5 ;
695       saux2 = saux1.str() ;
696       saux += "FAZAxe " + saux2 + "\n" ;
697     }
698      { std::stringstream saux1 ;
699       saux1 << NumeBoundary << " " << x6 ;
700       saux2 = saux1.str() ;
701       saux += "FARayon " + saux2 + "\n" ;
702     }
703  }
704 //
705 // Cas de la sphere
706 //
707   else if ( BoundaryType == 2 )
708   {
709     { std::stringstream saux1 ;
710       saux1 << NumeBoundary << " " << x0 ;
711       saux2 = saux1.str() ;
712       saux += "FAXCen " + saux2 + "\n" ;
713     }
714     { std::stringstream saux1 ;
715       saux1 << NumeBoundary << " " << x1 ;
716       saux2 = saux1.str() ;
717       saux += "FAYCen " + saux2 + "\n" ;
718     }
719     { std::stringstream saux1 ;
720       saux1 << NumeBoundary << " " << x2 ;
721       saux2 = saux1.str() ;
722       saux += "FAZCen " + saux2 + "\n" ;
723     }
724     { std::stringstream saux1 ;
725       saux1 << NumeBoundary << " " << x3 ;
726       saux2 = saux1.str() ;
727       saux += "FARayon " + saux2 + "\n" ;
728     }
729   }
730 //
731   _Texte += saux + "#\n" ;
732 //
733 }
734 ////=============================================================================
735 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
736 {
737   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
738 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
739 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
740 //
741 // Commentaires
742 //
743   std::string saux, saux2 ;
744   std::stringstream saux1 ;
745   saux1 << NumeBoundary ;
746   saux2 = saux1.str() ;
747   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
748 //
749   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
750   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
751 //
752   _Texte += saux + "#\n" ;
753 //
754 }
755 ////=============================================================================
756 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
757 {
758   MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
759   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
760   MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
761 //
762 // Type d'interpolation
763 //
764   _Texte += "# Interpolations des champs\n" ;
765   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
766   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
767   if ( TypeFieldInterp == 1 )
768   {
769     _Texte += "CCChaTou oui\n" ;
770   }
771 //
772   _TimeStep = TimeStep ;
773   _Rank = Rank ;
774 //
775 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
776 }
777 ////=============================================================================
778 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
779 {
780   MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
781   std::stringstream saux1 ;
782   saux1 << NumeChamp+1 ;
783   std::string saux = saux1.str() ;
784   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
785 //
786   MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
787   if ( _TimeStep >= 0 )
788   {
789     {
790       std::stringstream saux1 ;
791       saux1 << _TimeStep ;
792       std::string saux2 = saux1.str() ;
793       _Texte += "CCChaPdT " + saux + " " + saux2  + "\n" ;
794     }
795     {
796       std::stringstream saux1 ;
797       saux1 << _Rank ;
798       std::string saux2 = saux1.str() ;
799       _Texte += "CCChaNuO " + saux + " " + saux2  + "\n" ;
800     }
801   }
802 }
803 ////=============================================================================
804 void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput )
805 {
806   MESSAGE("TexteAdvanced, Pyram ="<<Pyram<<", NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", LevelOutput ="<<LevelOutput);
807   std::string saux ;
808
809   if ( Pyram > 0 )
810   {
811     _Texte += "# Autorisation de pyramides dans le maillage initial\n" ;
812     _Texte += "TypeElem ignore_pyra\n" ;
813   }
814   if ( NivMax > 0 )
815   {
816     _Texte += "# Niveaux extremes\n" ;
817     { std::stringstream saux1 ;
818       saux1 << NivMax ;
819       std::string saux2 = saux1.str() ;
820       _Texte += "NiveauMa " + saux2 + "\n" ;
821     }
822   }
823   if ( DiamMin > 0 )
824   {
825     _Texte += "# Diametre minimal\n" ;
826     { std::stringstream saux1 ;
827       saux1 << DiamMin ;
828       std::string saux2 = saux1.str() ;
829       _Texte += "DiametMi " + saux2  + "\n" ;
830     }
831   }
832   if ( AdapInit != 0 )
833   {
834     if ( AdapInit > 0 )
835     { _Texte += "# Raffinement" ; }
836     else
837     { _Texte += "# Deraffinement" ; }
838     _Texte += " des regions sans indicateur\n" ;
839     { std::stringstream saux1 ;
840       saux1 << AdapInit ;
841       std::string saux2 = saux1.str() ;
842       _Texte += "AdapInit " + saux2 + "\n" ;
843     }
844   }
845   if ( LevelOutput != 0 )
846   {
847     _Texte += "# Sortie des niveaux de raffinement\n" ;
848     _Texte += "NCNiveau NIVEAU\n" ;
849   }
850 }
851
852 ////=============================================================================
853 void HomardDriver::CreeFichier( )
854 {
855 //
856   _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ;
857 //
858   std::ofstream FicConf(_NomFichierConf.c_str(), std::ios::out ) ;
859   if (FicConf.is_open() == true)
860   {
861     FicConf << _Texte << std::endl ;
862   }
863   FicConf.close() ;
864 //
865 }
866
867 ////=============================================================================
868 int HomardDriver::ExecuteHomard()
869 {
870 // Copie des Fichiers HOMARD
871   std::string commande= "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
872   system(commande.c_str());
873
874   MESSAGE("ExecuteHomard");
875   int codret = system(_HOMARD_Exec.c_str()) ;
876   if ( codret != 0)
877   {
878       // GERALD -- QMESSAGE BOX
879       MESSAGE ( "Erreur en executant HOMARD : " << codret );
880 //       ASSERT("Erreur en executant HOMARD" == 0);
881   };
882
883   return codret ;
884 }