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