Salome HOME
Merge from V6_main 13/12/2012
[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 ( saux != " " )
539   {
540     std::stringstream saux1 ;
541     saux1 << ThreshR ;
542     saux2 = saux1.str() ;
543     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
544   }
545 //
546   saux = " " ;
547   if ( TypeThC == 1 )
548   { saux = "Bas" ; }
549   if ( TypeThC == 2 )
550   { saux = "BRe" ; }
551   if ( TypeThC == 3 )
552   { saux = "BPE" ; }
553   if ( saux != " " )
554   {
555     std::stringstream saux1 ;
556     saux1 << ThreshC ;
557     saux2 = saux1.str() ;
558     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
559   }
560 //
561   saux = " " ;
562   if ( UsField == 0 )
563   { saux = "MAILLE" ; }
564   if ( UsField == 1 )
565   { saux = "SAUT" ; }
566   if ( saux != " " )
567   {
568     _Texte += "CCModeFI " + saux  + "\n" ;
569   }
570 //
571   saux = " " ;
572   if ( UsCmpI == 0 )
573   { saux = "L2" ; }
574   if ( UsCmpI == 1 )
575   { saux = "INFINI" ; }
576   if ( UsCmpI == 2 )
577   { saux = "V_RELATIVE" ; }
578   if ( saux != " " )
579   {
580     _Texte += "CCUsCmpI " + saux  + "\n" ;
581   }
582 }
583
584 ////=============================================================================
585 void HomardDriver::TexteGroup( const std::string GroupName )
586 {
587   MESSAGE("TexteGroup, GroupName = "<<GroupName);
588 //
589   _Texte += "CCGroAda \"" + GroupName  + "\"\n" ;
590 //
591 }
592 ////=============================================================================
593 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
594 {
595   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
596 //
597 // Type de suivi de frontiere
598 //
599   std::stringstream saux1 ;
600   saux1 << BoundaryOption ;
601   std::string saux = saux1.str() ;
602   _Texte += "SuivFron " + saux + "\n" ;
603 //
604 }
605 ////=============================================================================
606 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
607 {
608   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
609   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
610 //
611   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
612   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
613 //
614 }
615 ////=============================================================================
616 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
617 {
618   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
619 //
620   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
621 //
622 }
623 ////=============================================================================
624 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 )
625 {
626   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
627 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
628   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
629 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6);
630 //
631   std::string saux, saux2 ;
632 //
633 // Commentaires
634 //
635   std::stringstream saux1 ;
636   saux1 << NumeBoundary ;
637   saux2 = saux1.str() ;
638   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
639   if ( BoundaryType == 1 )
640   { saux += "# Cylindre\n" ; }
641   if ( BoundaryType == 2 )
642   { saux += "# Sphere\n" ; }
643 //
644 // Le nom de la frontiere
645 //
646   { std::stringstream saux1 ;
647     saux1 << NumeBoundary ;
648     saux2 = saux1.str() ;
649     saux += "FANom " + saux2 + " \"" + NameBoundary + "\"\n" ;
650   }
651 //
652 // Type de frontiere
653 //
654   { std::stringstream saux1 ;
655     saux1 << NumeBoundary << " " << BoundaryType ;
656     saux2 = saux1.str() ;
657     saux += "FAType " + saux2 + "\n" ;
658   }
659 //
660 // Cas du cylindre
661 //
662   if ( BoundaryType == 1 )
663   {
664     { std::stringstream saux1 ;
665       saux1 << NumeBoundary << " " << x0 ;
666       saux2 = saux1.str() ;
667       saux += "FAXCen " + saux2 + "\n" ;
668     }
669     { std::stringstream saux1 ;
670       saux1 << NumeBoundary << " " << x1 ;
671       saux2 = saux1.str() ;
672       saux += "FAYCen " + saux2 + "\n" ;
673     }
674     { std::stringstream saux1 ;
675       saux1 << NumeBoundary << " " << x2 ;
676       saux2 = saux1.str() ;
677       saux += "FAZCen " + saux2 + "\n" ;
678     }
679     { std::stringstream saux1 ;
680       saux1 << NumeBoundary << " " << x3 ;
681       saux2 = saux1.str() ;
682       saux += "FAXAxe " + saux2 + "\n" ;
683     }
684     { std::stringstream saux1 ;
685       saux1 << NumeBoundary << " " << x4 ;
686       saux2 = saux1.str() ;
687       saux += "FAYAxe " + saux2 + "\n" ;
688     }
689     { std::stringstream saux1 ;
690       saux1 << NumeBoundary << " " << x5 ;
691       saux2 = saux1.str() ;
692       saux += "FAZAxe " + saux2 + "\n" ;
693     }
694      { std::stringstream saux1 ;
695       saux1 << NumeBoundary << " " << x6 ;
696       saux2 = saux1.str() ;
697       saux += "FARayon " + saux2 + "\n" ;
698     }
699  }
700 //
701 // Cas de la sphere
702 //
703   else if ( BoundaryType == 2 )
704   {
705     { std::stringstream saux1 ;
706       saux1 << NumeBoundary << " " << x0 ;
707       saux2 = saux1.str() ;
708       saux += "FAXCen " + saux2 + "\n" ;
709     }
710     { std::stringstream saux1 ;
711       saux1 << NumeBoundary << " " << x1 ;
712       saux2 = saux1.str() ;
713       saux += "FAYCen " + saux2 + "\n" ;
714     }
715     { std::stringstream saux1 ;
716       saux1 << NumeBoundary << " " << x2 ;
717       saux2 = saux1.str() ;
718       saux += "FAZCen " + saux2 + "\n" ;
719     }
720     { std::stringstream saux1 ;
721       saux1 << NumeBoundary << " " << x3 ;
722       saux2 = saux1.str() ;
723       saux += "FARayon " + saux2 + "\n" ;
724     }
725   }
726 //
727   _Texte += saux + "#\n" ;
728 //
729 }
730 ////=============================================================================
731 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
732 {
733   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
734 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
735 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
736 //
737 // Commentaires
738 //
739   std::string saux, saux2 ;
740   std::stringstream saux1 ;
741   saux1 << NumeBoundary ;
742   saux2 = saux1.str() ;
743   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
744 //
745   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
746   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
747 //
748   _Texte += saux + "#\n" ;
749 //
750 }
751 ////=============================================================================
752 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
753 {
754   MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
755   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
756   MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
757 //
758 // Type d'interpolation
759 //
760   _Texte += "# Interpolations des champs\n" ;
761   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
762   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
763   if ( TypeFieldInterp == 1 )
764   {
765     _Texte += "CCChaTou oui\n" ;
766   }
767 //
768   _TimeStep = TimeStep ;
769   _Rank = Rank ;
770 //
771 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
772 }
773 ////=============================================================================
774 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
775 {
776   MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
777   std::stringstream saux1 ;
778   saux1 << NumeChamp+1 ;
779   std::string saux = saux1.str() ;
780   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
781 //
782   MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
783   if ( _TimeStep >= 0 )
784   {
785     {
786       std::stringstream saux1 ;
787       saux1 << _TimeStep ;
788       std::string saux2 = saux1.str() ;
789       _Texte += "CCChaPdT " + saux + " " + saux2  + "\n" ;
790     }
791     {
792       std::stringstream saux1 ;
793       saux1 << _Rank ;
794       std::string saux2 = saux1.str() ;
795       _Texte += "CCChaNuO " + saux + " " + saux2  + "\n" ;
796     }
797   }
798 }
799 ////=============================================================================
800 void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput )
801 {
802   MESSAGE("TexteAdvanced, Pyram ="<<Pyram<<", NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", LevelOutput ="<<LevelOutput);
803   std::string saux ;
804
805   if ( Pyram > 0 )
806   {
807     _Texte += "# Autorisation de pyramides dans le maillage initial\n" ;
808     _Texte += "TypeElem ignore_pyra\n" ;
809   }
810   if ( NivMax > 0 )
811   {
812     _Texte += "# Niveaux extremes\n" ;
813     { std::stringstream saux1 ;
814       saux1 << NivMax ;
815       std::string saux2 = saux1.str() ;
816       _Texte += "NiveauMa " + saux2 + "\n" ;
817     }
818   }
819   if ( DiamMin > 0 )
820   {
821     _Texte += "# Diametre minimal\n" ;
822     { std::stringstream saux1 ;
823       saux1 << DiamMin ;
824       std::string saux2 = saux1.str() ;
825       _Texte += "DiametMi " + saux2  + "\n" ;
826     }
827   }
828   if ( AdapInit != 0 )
829   {
830     if ( AdapInit > 0 )
831     { _Texte += "# Raffinement" ; }
832     else
833     { _Texte += "# Deraffinement" ; }
834     _Texte += " des regions sans indicateur\n" ;
835     { std::stringstream saux1 ;
836       saux1 << AdapInit ;
837       std::string saux2 = saux1.str() ;
838       _Texte += "AdapInit " + saux2 + "\n" ;
839     }
840   }
841   if ( LevelOutput != 0 )
842   {
843     _Texte += "# Sortie des niveaux de raffinement\n" ;
844     _Texte += "NCNiveau NIVEAU\n" ;
845   }
846 }
847
848 ////=============================================================================
849 void HomardDriver::CreeFichier( )
850 {
851 //
852   _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ;
853 //
854   std::ofstream FicConf(_NomFichierConf.c_str(), std::ios::out ) ;
855   if (FicConf.is_open() == true)
856   {
857     FicConf << _Texte << std::endl ;
858   }
859   FicConf.close() ;
860 //
861 }
862
863 ////=============================================================================
864 int HomardDriver::ExecuteHomard()
865 {
866 // Copie des Fichiers HOMARD
867   std::string commande= "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
868   system(commande.c_str());
869
870   MESSAGE("ExecuteHomard");
871   int codret = system(_HOMARD_Exec.c_str()) ;
872   if ( codret != 0)
873   {
874       // GERALD -- QMESSAGE BOX
875       MESSAGE ( "Erreur en executant HOMARD : " << codret );
876 //       ASSERT("Erreur en executant HOMARD" == 0);
877   };
878
879   return codret ;
880 }