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