Salome HOME
51bf17654466445af381a8fc741e410228328b2c
[modules/homard.git] / src / HOMARD / HomardDriver.cxx
1 //  HOMARD HOMARD : implementaion of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011  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")) )
42     dir = "/local00/HOMARD_SVN/trunk/bin" ;
43   else
44     dir = std::string(dirchar);
45   if ( !(execchar = getenv("HOMARD_EXE")) )
46     executable = "HOMARD.out";
47   else
48     executable = std::string(execchar);
49   _HOMARD_Exec = dir + "/" + executable ;
50   MESSAGE("Dans 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("Dans TexteInit, MessFile ="<<MessFile);
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("Dans 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("Dans TexteConfRaffDera, ConfType ="<<ConfType);
96   MESSAGE("Dans 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("Dans TexteCompo, NumeComp = "<<NumeComp<<", NompCompo = "<<NompCompo);
174   _Texte +="CCCoChaI \"" + NompCompo + "\"\n" ;
175 }
176
177 ////=============================================================================
178 void HomardDriver::TexteZone( int NumeZone, int ZoneType, 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);
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 //
187   int ZoneTypeHOMARD ;
188   if ( ZoneType >= 11 and ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
189   else if ( ZoneType >= 31 and ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
190   else if ( ZoneType >= 61 and ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
191   else { ZoneTypeHOMARD = ZoneType ; }
192 //
193   std::stringstream saux1 ;
194   saux1 << NumeZone ;
195   saux2 = saux1.str() ;
196   saux = "#\n# Zone numero " + saux2 + "\n" ;
197 //
198   { std::stringstream saux1 ;
199     saux1 << NumeZone << " " << ZoneTypeHOMARD ;
200     saux2 = saux1.str() ;
201     saux += "ZoRaType " + saux2 + "\n" ;
202   }
203 //
204 // Cas du rectangle
205 //
206   if ( ZoneType == 11 ) // Z est constant X Homard <=> X Salome
207 //                                        Y Homard <=> Y Salome
208   {
209     saux += "#Rectangle\n" ;
210     { std::stringstream saux1 ;
211       saux1 << NumeZone << " " << x0 ;
212       saux2 = saux1.str() ;
213       saux += "ZoRaXmin " + saux2 + "\n" ;
214     }
215     { std::stringstream saux1 ;
216       saux1 << NumeZone << " " << x1 ;
217       saux2 = saux1.str() ;
218       saux += "ZoRaXmax " + saux2 + "\n" ;
219     }
220     { std::stringstream saux1 ;
221       saux1 << NumeZone << " " << x2 ;
222       saux2 = saux1.str() ;
223       saux += "ZoRaYmin " + saux2 + "\n" ;
224     }
225     { std::stringstream saux1 ;
226       saux1 << NumeZone << " " << x3 ;
227       saux2 = saux1.str() ;
228       saux += "ZoRaYmax " + saux2 + "\n" ;
229     }
230   }
231 //
232   else if ( ZoneType == 12 ) // X est constant X Homard <=> Y Salome
233 //                                             Y Homard <=> Z Salome
234   {
235     saux += "#Rectangle\n" ;
236     { std::stringstream saux1 ;
237       saux1 << NumeZone << " " << x2 ;
238       saux2 = saux1.str() ;
239       saux += "ZoRaXmin " + saux2 + "\n" ;
240     }
241     { std::stringstream saux1 ;
242       saux1 << NumeZone << " " << x3 ;
243       saux2 = saux1.str() ;
244       saux += "ZoRaXmax " + saux2 + "\n" ;
245     }
246     { std::stringstream saux1 ;
247       saux1 << NumeZone << " " << x4 ;
248       saux2 = saux1.str() ;
249       saux += "ZoRaYmin " + saux2 + "\n" ;
250     }
251     { std::stringstream saux1 ;
252       saux1 << NumeZone << " " << x5 ;
253       saux2 = saux1.str() ;
254       saux += "ZoRaYmax " + saux2 + "\n" ;
255     }
256   }
257 //
258   else if ( ZoneType == 13 ) // Y est constant X Homard <=> X Salome
259 //                                             Y Homard <=> Z Salome
260   {
261     saux += "#Rectangle\n" ;
262     { std::stringstream saux1 ;
263       saux1 << NumeZone << " " << x0 ;
264       saux2 = saux1.str() ;
265       saux += "ZoRaXmin " + saux2 + "\n" ;
266     }
267     { std::stringstream saux1 ;
268       saux1 << NumeZone << " " << x1 ;
269       saux2 = saux1.str() ;
270       saux += "ZoRaXmax " + saux2 + "\n" ;
271     }
272     { std::stringstream saux1 ;
273       saux1 << NumeZone << " " << x4 ;
274       saux2 = saux1.str() ;
275       saux += "ZoRaYmin " + saux2 + "\n" ;
276     }
277     { std::stringstream saux1 ;
278       saux1 << NumeZone << " " << x5 ;
279       saux2 = saux1.str() ;
280       saux += "ZoRaYmax " + saux2 + "\n" ;
281     }
282   }
283 //
284 // Cas du parallelepipede
285 //
286   else if ( ZoneType == 2 )
287   {
288     saux += "# Boite\n" ;
289     { std::stringstream saux1 ;
290       saux1 << NumeZone << " " << x0 ;
291       saux2 = saux1.str() ;
292       saux += "ZoRaXmin " + saux2 + "\n" ;
293     }
294     { std::stringstream saux1 ;
295       saux1 << NumeZone << " " << x1 ;
296       saux2 = saux1.str() ;
297       saux += "ZoRaXmax " + saux2 + "\n" ;
298     }
299     { std::stringstream saux1 ;
300       saux1 << NumeZone << " " << x2 ;
301       saux2 = saux1.str() ;
302       saux += "ZoRaYmin " + saux2 + "\n" ;
303     }
304     { std::stringstream saux1 ;
305       saux1 << NumeZone << " " << x3 ;
306       saux2 = saux1.str() ;
307       saux += "ZoRaYmax " + saux2 + "\n" ;
308     }
309     { std::stringstream saux1 ;
310       saux1 << NumeZone << " " << x4 ;
311       saux2 = saux1.str() ;
312       saux += "ZoRaZmin " + saux2 + "\n" ;
313     }
314     { std::stringstream saux1 ;
315       saux1 << NumeZone << " " << x5 ;
316       saux2 = saux1.str() ;
317       saux += "ZoRaZmax " + saux2 + "\n" ;
318     }
319   }
320 //
321 // Cas du disque
322 //
323   else if ( ZoneType == 31 or ZoneType == 61 )
324   {
325     saux += "# Sphere\n" ;
326     { std::stringstream saux1 ;
327       saux1 << NumeZone << " " << x0 ;
328       saux2 = saux1.str() ;
329       saux += "ZoRaXCen " + saux2 + "\n" ;
330     }
331     { std::stringstream saux1 ;
332       saux1 << NumeZone << " " << x1 ;
333       saux2 = saux1.str() ;
334       saux += "ZoRaYCen " + saux2 + "\n" ;
335     }
336     { std::stringstream saux1 ;
337       saux1 << NumeZone << " " << x6 ;
338       saux2 = saux1.str() ;
339       if ( ZoneType == 61 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
340       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
341     }
342     if ( ZoneType == 61 )
343     { std::stringstream saux1 ;
344       saux1 << NumeZone << " " << x8 ;
345       saux2 = saux1.str() ;
346       saux += "ZoRaRayI " + saux2 + "\n" ;
347     }
348   }
349   else if ( ZoneType == 32 or ZoneType == 62 )
350   {
351     saux += "# Sphere\n" ;
352     { std::stringstream saux1 ;
353       saux1 << NumeZone << " " << x1 ;
354       saux2 = saux1.str() ;
355       saux += "ZoRaXCen " + saux2 + "\n" ;
356     }
357     { std::stringstream saux1 ;
358       saux1 << NumeZone << " " << x2 ;
359       saux2 = saux1.str() ;
360       saux += "ZoRaYCen " + saux2 + "\n" ;
361     }
362     { std::stringstream saux1 ;
363       saux1 << NumeZone << " " << x6 ;
364       saux2 = saux1.str() ;
365       if ( ZoneType == 62 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
366       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
367     }
368     if ( ZoneType == 62 )
369     { std::stringstream saux1 ;
370       saux1 << NumeZone << " " << x8 ;
371       saux2 = saux1.str() ;
372       saux += "ZoRaRayI " + saux2 + "\n" ;
373     }
374   }
375   else if ( ZoneType == 33 or ZoneType == 63 )
376   {
377     saux += "# Sphere\n" ;
378     { std::stringstream saux1 ;
379       saux1 << NumeZone << " " << x0 ;
380       saux2 = saux1.str() ;
381       saux += "ZoRaXCen " + saux2 + "\n" ;
382     }
383     { std::stringstream saux1 ;
384       saux1 << NumeZone << " " << x2 ;
385       saux2 = saux1.str() ;
386       saux += "ZoRaYCen " + saux2 + "\n" ;
387     }
388     { std::stringstream saux1 ;
389       saux1 << NumeZone << " " << x6 ;
390       saux2 = saux1.str() ;
391       if ( ZoneType == 63 ) { saux += "ZoRaRayE " + saux2 + "\n" ; }
392       else                  { saux += "ZoRaRayo " + saux2 + "\n" ; }
393     }
394     if ( ZoneType == 63 )
395     { std::stringstream saux1 ;
396       saux1 << NumeZone << " " << x8 ;
397       saux2 = saux1.str() ;
398       saux += "ZoRaRayI " + saux2 + "\n" ;
399     }
400   }
401 //
402 // Cas de la sphere
403 //
404   else if ( ZoneType == 4 )
405   {
406     saux += "# Sphere\n" ;
407     { std::stringstream saux1 ;
408       saux1 << NumeZone << " " << x0 ;
409       saux2 = saux1.str() ;
410       saux += "ZoRaXCen " + saux2 + "\n" ;
411     }
412     { std::stringstream saux1 ;
413       saux1 << NumeZone << " " << x1 ;
414       saux2 = saux1.str() ;
415       saux += "ZoRaYCen " + saux2 + "\n" ;
416     }
417     { std::stringstream saux1 ;
418       saux1 << NumeZone << " " << x2 ;
419       saux2 = saux1.str() ;
420       saux += "ZoRaZCen " + saux2 + "\n" ;
421     }
422     { std::stringstream saux1 ;
423       saux1 << NumeZone << " " << x3 ;
424       saux2 = saux1.str() ;
425       saux += "ZoRaRayo " + saux2 + "\n" ;
426     }
427   }
428 //
429 // Cas du cylindre ou du tuyau
430 //
431   else if ( ZoneType == 5 or ZoneType == 7 )
432   {
433     if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
434     else                 { saux += "# Tuyau\n" ; }
435     { std::stringstream saux1 ;
436       saux1 << NumeZone << " " << x0 ;
437       saux2 = saux1.str() ;
438       saux += "ZoRaXBas " + saux2 + "\n" ;
439     }
440     { std::stringstream saux1 ;
441       saux1 << NumeZone << " " << x1 ;
442       saux2 = saux1.str() ;
443       saux += "ZoRaYBas " + saux2 + "\n" ;
444     }
445     { std::stringstream saux1 ;
446       saux1 << NumeZone << " " << x2 ;
447       saux2 = saux1.str() ;
448       saux += "ZoRaZBas " + saux2 + "\n" ;
449     }
450     { std::stringstream saux1 ;
451       saux1 << NumeZone << " " << x3 ;
452       saux2 = saux1.str() ;
453       saux += "ZoRaXAxe " + saux2 + "\n" ;
454     }
455     { std::stringstream saux1 ;
456       saux1 << NumeZone << " " << x4 ;
457       saux2 = saux1.str() ;
458       saux += "ZoRaYAxe " + saux2 + "\n" ;
459     }
460     { std::stringstream saux1 ;
461       saux1 << NumeZone << " " << x5 ;
462       saux2 = saux1.str() ;
463       saux += "ZoRaZAxe " + saux2 + "\n" ;
464     }
465     { std::stringstream saux1 ;
466       saux1 << NumeZone << " " << x6 ;
467       saux2 = saux1.str() ;
468      if ( ZoneType == 5 ) { saux += "ZoRaRayo " + saux2 + "\n" ; }
469      else                 { saux += "ZoRaRayE " + saux2 + "\n" ; }
470     }
471     { std::stringstream saux1 ;
472       saux1 << NumeZone << " " << x7 ;
473       saux2 = saux1.str() ;
474       saux += "ZoRaHaut " + saux2 + "\n" ;
475     }
476     if ( ZoneType == 7 )
477     { std::stringstream saux1 ;
478       saux1 << NumeZone << " " << x8 ;
479       saux2 = saux1.str() ;
480       saux += "ZoRaRayI " + saux2 + "\n" ;
481     }
482   }
483 //
484   _Texte += saux + "#\n" ;
485 //
486 //   MESSAGE("A la fin de HomardDriver::TexteZone, _Texte ="<<_Texte);
487 }
488
489 ////=============================================================================
490 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
491                int TypeThR, double ThreshR, int TypeThC, double ThreshC,
492                int UsField, int UsCmpI )
493 {
494   MESSAGE("Dans TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
495   MESSAGE("Dans TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
496
497   std::string saux, saux2 ;
498 //
499 //
500   _Texte += "# Champ d'indicateurs\n" ;
501   _Texte += "CCIndica " + FieldFile  + "\n" ;
502   _Texte += "CCNoChaI \"" + FieldName  + "\"\n" ;
503
504 // Cas ou on prend le dernier pas de temps
505   if ( TimeStep == -2 )
506   { _Texte += "CCNumPTI Last\n" ; }
507 // Cas avec pas de temps
508   else if ( TimeStep >= 0 )
509   {
510     {
511       std::stringstream saux1 ;
512       saux1 << TimeStep ;
513       saux2 = saux1.str() ;
514       _Texte += "CCNumPTI " + saux2  + "\n" ;
515     }
516     {
517       std::stringstream saux1 ;
518       saux1 << Rank ;
519       saux2 = saux1.str() ;
520       _Texte += "CCNumOrI " + saux2  + "\n" ;
521     }
522   }
523 //
524   saux = " " ;
525   if ( TypeThR == 1 )
526   { saux = "Hau" ; }
527   if ( TypeThR == 2 )
528   { saux = "HRe" ; }
529   if ( TypeThR == 3 )
530   { saux = "HPE" ; }
531   if ( saux != " " )
532   {
533     std::stringstream saux1 ;
534     saux1 << ThreshR ;
535     saux2 = saux1.str() ;
536     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
537   }
538 //
539   saux = " " ;
540   if ( TypeThC == 1 )
541   { saux = "Bas" ; }
542   if ( TypeThC == 2 )
543   { saux = "BRe" ; }
544   if ( TypeThC == 3 )
545   { saux = "BPE" ; }
546   if ( saux != " " )
547   {
548     std::stringstream saux1 ;
549     saux1 << ThreshC ;
550     saux2 = saux1.str() ;
551     _Texte += "Seuil" + saux + " " + saux2  + "\n" ;
552   }
553 //
554   saux = " " ;
555   if ( UsField == 0 )
556   { saux = "MAILLE" ; }
557   if ( UsField == 1 )
558   { saux = "SAUT" ; }
559   if ( saux != " " )
560   {
561     _Texte += "CCModeFI " + saux  + "\n" ;
562   }
563 //
564   saux = " " ;
565   if ( UsCmpI == 0 )
566   { saux = "L2" ; }
567   if ( UsCmpI == 1 )
568   { saux = "INFINI" ; }
569   if ( UsCmpI == 2 )
570   { saux = "V_RELATIVE" ; }
571   if ( saux != " " )
572   {
573     _Texte += "CCUsCmpI " + saux  + "\n" ;
574   }
575 }
576
577 ////=============================================================================
578 void HomardDriver::TexteGroup( const std::string GroupName )
579 {
580   MESSAGE("Dans TexteGroup, GroupName = "<<GroupName);
581 //
582   _Texte += "CCGroAda " + GroupName  + "\n" ;
583 //
584 }
585 ////=============================================================================
586 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
587 {
588   MESSAGE("Dans TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
589 //
590 // Type de suivi de frontiere
591 //
592   std::stringstream saux1 ;
593   saux1 << BoundaryOption ;
594   std::string saux = saux1.str() ;
595   _Texte += "SuivFron " + saux + "\n" ;
596 //
597 }
598 ////=============================================================================
599 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
600 {
601   MESSAGE("Dans TexteBoundaryDi, MeshName  = "<<MeshName);
602   MESSAGE("Dans TexteBoundaryDi, MeshFile  = "<<MeshFile);
603 //
604   _Texte += "CCNoMFro " + MeshName + "\n" ;
605   _Texte += "CCFronti " + MeshFile + "\n" ;
606 //
607 }
608 ////=============================================================================
609 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
610 {
611   MESSAGE("Dans TexteBoundaryDiGr, GroupName  = "<<GroupName);
612 //
613   _Texte += "CCGroFro " + GroupName + "\n" ;
614 //
615 }
616 ////=============================================================================
617 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 )
618 {
619   MESSAGE("Dans TexteBoundaryAn, NameBoundary = "<<NameBoundary);
620 //   MESSAGE("Dans TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
621   MESSAGE("Dans TexteBoundaryAn, BoundaryType = "<<BoundaryType);
622 //   MESSAGE("Dans TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6);
623 //
624   std::string saux, saux2 ;
625 //
626 // Commentaires
627 //
628   std::stringstream saux1 ;
629   saux1 << NumeBoundary ;
630   saux2 = saux1.str() ;
631   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
632   if ( BoundaryType == 1 )
633   { saux += "# Cylindre\n" ; }
634   if ( BoundaryType == 2 )
635   { saux += "# Sphere\n" ; }
636 //
637 // Le nom de la frontiere
638 //
639   { std::stringstream saux1 ;
640     saux1 << NumeBoundary ;
641     saux2 = saux1.str() ;
642     saux += "FANom " + saux2 + " \"" + NameBoundary + "\"\n" ;
643   }
644 //
645 // Type de frontiere
646 //
647   { std::stringstream saux1 ;
648     saux1 << NumeBoundary << " " << BoundaryType ;
649     saux2 = saux1.str() ;
650     saux += "FAType " + saux2 + "\n" ;
651   }
652 //
653 // Cas du cylindre
654 //
655   if ( BoundaryType == 1 )
656   {
657     { std::stringstream saux1 ;
658       saux1 << NumeBoundary << " " << x0 ;
659       saux2 = saux1.str() ;
660       saux += "FAXCen " + saux2 + "\n" ;
661     }
662     { std::stringstream saux1 ;
663       saux1 << NumeBoundary << " " << x1 ;
664       saux2 = saux1.str() ;
665       saux += "FAYCen " + saux2 + "\n" ;
666     }
667     { std::stringstream saux1 ;
668       saux1 << NumeBoundary << " " << x2 ;
669       saux2 = saux1.str() ;
670       saux += "FAZCen " + saux2 + "\n" ;
671     }
672     { std::stringstream saux1 ;
673       saux1 << NumeBoundary << " " << x3 ;
674       saux2 = saux1.str() ;
675       saux += "FAXAxe " + saux2 + "\n" ;
676     }
677     { std::stringstream saux1 ;
678       saux1 << NumeBoundary << " " << x4 ;
679       saux2 = saux1.str() ;
680       saux += "FAYAxe " + saux2 + "\n" ;
681     }
682     { std::stringstream saux1 ;
683       saux1 << NumeBoundary << " " << x5 ;
684       saux2 = saux1.str() ;
685       saux += "FAZAxe " + saux2 + "\n" ;
686     }
687      { std::stringstream saux1 ;
688       saux1 << NumeBoundary << " " << x6 ;
689       saux2 = saux1.str() ;
690       saux += "FARayon " + saux2 + "\n" ;
691     }
692  }
693 //
694 // Cas de la sphere
695 //
696   else if ( BoundaryType == 2 )
697   {
698     { std::stringstream saux1 ;
699       saux1 << NumeBoundary << " " << x0 ;
700       saux2 = saux1.str() ;
701       saux += "FAXCen " + saux2 + "\n" ;
702     }
703     { std::stringstream saux1 ;
704       saux1 << NumeBoundary << " " << x1 ;
705       saux2 = saux1.str() ;
706       saux += "FAYCen " + saux2 + "\n" ;
707     }
708     { std::stringstream saux1 ;
709       saux1 << NumeBoundary << " " << x2 ;
710       saux2 = saux1.str() ;
711       saux += "FAZCen " + saux2 + "\n" ;
712     }
713     { std::stringstream saux1 ;
714       saux1 << NumeBoundary << " " << x3 ;
715       saux2 = saux1.str() ;
716       saux += "FARayon " + saux2 + "\n" ;
717     }
718   }
719 //
720   _Texte += saux + "#\n" ;
721 //
722 }
723 ////=============================================================================
724 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
725 {
726   MESSAGE("Dans TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
727 //   MESSAGE("Dans TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
728 //   MESSAGE("Dans TexteBoundaryAnGr, GroupName  = "<<GroupName);
729 //
730 // Commentaires
731 //
732   std::string saux, saux2 ;
733   std::stringstream saux1 ;
734   saux1 << NumeBoundary ;
735   saux2 = saux1.str() ;
736   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
737 //
738   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
739   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
740 //
741   _Texte += saux + "#\n" ;
742 //
743 }
744 ////=============================================================================
745 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
746 {
747   MESSAGE("Dans TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
748   MESSAGE("Dans TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
749   MESSAGE("Dans TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
750 //
751 // Type d'interpolation
752 //
753   _Texte += "# Interpolations des champs\n" ;
754   _Texte += "CCSolN__ " + FieldFile  + "\n" ;
755   _Texte += "CCSolNP1 " + MeshFile  + "\n" ;
756   if ( TypeFieldInterp == 1 )
757   {
758     _Texte += "CCChaTou oui\n" ;
759   }
760 //
761   _TimeStep = TimeStep ;
762   _Rank = Rank ;
763 //
764 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
765 }
766 ////=============================================================================
767 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
768 {
769   MESSAGE("Dans TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
770   std::stringstream saux1 ;
771   saux1 << NumeChamp+1 ;
772   std::string saux = saux1.str() ;
773   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
774 //
775   MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
776   if ( _TimeStep >= 0 )
777   {
778     {
779       std::stringstream saux1 ;
780       saux1 << _TimeStep ;
781       std::string saux2 = saux1.str() ;
782       _Texte += "CCChaPdT " + saux + " " + saux2  + "\n" ;
783     }
784     {
785       std::stringstream saux1 ;
786       saux1 << _Rank ;
787       std::string saux2 = saux1.str() ;
788       _Texte += "CCChaNuO " + saux + " " + saux2  + "\n" ;
789     }
790   }
791 }
792 ////=============================================================================
793 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin)
794 {
795   MESSAGE("Dans TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin);
796   std::string saux ;
797
798   _Texte += "# Niveaux extremes\n" ;
799   { std::stringstream saux1 ;
800     saux1 << NivMax ;
801     std::string saux2 = saux1.str() ;
802     _Texte += "NiveauMa " + saux2 + "\n" ;
803   }
804   {
805     std::stringstream saux1 ;
806     saux1 << DiamMin ;
807     std::string saux2 = saux1.str() ;
808     _Texte += "DiametMi " + saux2  + "\n" ;
809   }
810 }
811
812 ////=============================================================================
813 void HomardDriver::CreeFichier( )
814 {
815 //
816   _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ;
817 //
818   std::ofstream FicConf(_NomFichierConf.c_str(), std::ios::out ) ;
819   if (FicConf.is_open() == true)
820   {
821     FicConf << _Texte << std::endl ;
822   }
823   FicConf.close() ;
824 //
825 }
826
827 ////=============================================================================
828 int HomardDriver::ExecuteHomard()
829 {
830 // Copie des Fichiers HOMARD
831   std::string commande= "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
832   system(commande.c_str());
833
834   MESSAGE("ExecuteHomard");
835   int codret = system(_HOMARD_Exec.c_str()) ;
836   if ( codret != 0)
837   {
838       // GERALD -- QMESSAGE BOX
839       MESSAGE ( "Erreur en executant HOMARD : " << codret );
840 //       ASSERT("Erreur en executant HOMARD" == 0);
841   };
842
843   return codret ;
844 }