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