Salome HOME
Copyright update 2022
[modules/smesh.git] / src / SMESH / SMESH_Homard.cxx
1 // SMESH HOMARD : implementation of SMESHHOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2022  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 #include "SMESH_Homard.hxx"
23
24 #include <Utils_SALOME_Exception.hxx>
25 #include <utilities.h>
26
27 #include <iostream>
28 #include <sstream>
29 #include <cstdlib>
30 #include <sys/stat.h>
31
32 #ifndef WIN32
33 #include <unistd.h>
34 #else
35 #include <direct.h>
36 #endif
37
38 // La gestion des repertoires
39 #ifndef CHDIR
40   #ifdef WIN32
41     #define CHDIR _chdir
42   #else
43     #define CHDIR chdir
44   #endif
45 #endif
46
47 namespace SMESHHOMARDImpl
48 {
49
50 //=============================================================================
51 /*!
52  *  default constructor:
53  */
54 //=============================================================================
55 HOMARD_Boundary::HOMARD_Boundary():
56   _Name( "" ),_Type( 1 ),
57   _Xmin( 0 ), _Xmax( 0 ), _Ymin( 0 ), _Ymax( 0 ), _Zmin( 0 ), _Zmax( 0 ),
58   _Xaxe( 0 ), _Yaxe( 0 ), _Zaxe( 0 ),
59   _Xcentre( 0 ), _Ycentre( 0 ), _Zcentre( 0 ), _rayon( 0 ),
60   _Xincr( 0 ), _Yincr( 0 ), _Zincr( 0 )
61 {
62   MESSAGE("HOMARD_Boundary");
63 }
64
65 //=============================================================================
66 HOMARD_Boundary::~HOMARD_Boundary()
67 {
68   MESSAGE("~HOMARD_Boundary");
69 }
70 //=============================================================================
71 //=============================================================================
72 // Generalites
73 //=============================================================================
74 //=============================================================================
75 void HOMARD_Boundary::SetName( const char* Name )
76 {
77   _Name = std::string( Name );
78 }
79 //=============================================================================
80 std::string HOMARD_Boundary::GetName() const
81 {
82   return _Name;
83 }
84 //=============================================================================
85 std::string HOMARD_Boundary::GetDumpPython() const
86 {
87   std::ostringstream aScript;
88   switch (_Type) {
89     case -1:
90     {
91       aScript << _Name << " = smeshhomard.CreateBoundaryCAO(\"" << _Name << "\", ";
92       aScript << "\"" << _DataFile << "\")\n";
93       break ;
94     }
95     case 0:
96     {
97       aScript << _Name << " = smeshhomard.CreateBoundaryDi(\"" << _Name << "\", ";
98       aScript << "\"" << _MeshName << "\", ";
99       aScript << "\"" << _DataFile << "\")\n";
100       break ;
101     }
102     case 1:
103     {
104       aScript << _Name << " = smeshhomard.CreateBoundaryCylinder(\"" << _Name << "\", ";
105       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _rayon << ")\n";
106       break ;
107     }
108     case 2:
109     {
110       aScript << _Name << " = smeshhomard.CreateBoundarySphere(\"" << _Name << "\", ";
111       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _rayon << ")\n";
112       break ;
113     }
114     case 3:
115     {
116       aScript << _Name << " = smeshhomard.CreateBoundaryConeA(\"" << _Name << "\", ";
117       aScript << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Angle << ", " << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ")\n";
118       break ;
119     }
120     case 4:
121     {
122       aScript << _Name << " = smeshhomard.CreateBoundaryConeR(\"" << _Name << "\", ";
123       aScript << _Xcentre1 << ", " << _Ycentre1 << ", " << _Zcentre1 << ", " << _Rayon1 << ", " << _Xcentre2 << ", " << _Ycentre2 << ", " << _Zcentre2 << ", " << _Rayon2 << ")\n";
124       break ;
125     }
126     case 5:
127     {
128       aScript << _Name << " = smeshhomard.CreateBoundaryTorus(\"" << _Name << "\", ";
129       aScript << _Xcentre << ", " << _Ycentre << ", " << _Zcentre << ", " << _Xaxe << ", " << _Yaxe << ", " << _Zaxe << ", " << _Rayon1 << ", " << _Rayon2 << ")\n";
130       break ;
131     }
132   }
133
134   return aScript.str();
135 }
136 //=============================================================================
137 //=============================================================================
138 // Caracteristiques
139 //=============================================================================
140 //=============================================================================
141 void HOMARD_Boundary::SetType( int Type )
142 {
143   _Type = Type;
144 }
145 //=============================================================================
146 int HOMARD_Boundary::GetType() const
147 {
148   return _Type;
149 }
150 //=============================================================================
151 void HOMARD_Boundary::SetMeshName( const char* MeshName )
152 {
153   _MeshName = std::string( MeshName );
154 }
155 //=============================================================================
156 std::string HOMARD_Boundary::GetMeshName() const
157 {
158   return _MeshName;
159 }
160 //=============================================================================
161 void HOMARD_Boundary::SetDataFile( const char* DataFile )
162 {
163   _DataFile = std::string( DataFile );
164 }
165 //=============================================================================
166 std::string HOMARD_Boundary::GetDataFile() const
167 {
168   return _DataFile;
169 }
170 //=======================================================================================
171 void HOMARD_Boundary::SetCylinder( double X0, double X1, double X2,
172                                    double X3, double X4, double X5, double X6 )
173 {
174   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
175   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
176   _rayon = X6;
177 }
178 //======================================================================
179 void HOMARD_Boundary::SetSphere( double X0, double X1, double X2, double X3 )
180 {
181   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
182   _rayon = X3;
183 }
184 //======================================================================
185 void HOMARD_Boundary::SetConeR( double Xcentre1, double Ycentre1, double Zcentre1, double Rayon1,
186                                 double Xcentre2, double Ycentre2, double Zcentre2, double Rayon2)
187 {
188   _Xcentre1 = Xcentre1; _Ycentre1 = Ycentre1; _Zcentre1 = Zcentre1;
189   _Rayon1 = Rayon1;
190   _Xcentre2 = Xcentre2; _Ycentre2 = Ycentre2; _Zcentre2 = Zcentre2;
191   _Rayon2 = Rayon2;
192 }
193 //======================================================================
194 void HOMARD_Boundary::SetConeA( double Xaxe, double Yaxe, double Zaxe, double Angle,
195                                 double Xcentre, double Ycentre, double Zcentre)
196 {
197   _Xaxe = Xaxe; _Yaxe = Yaxe; _Zaxe = Zaxe;
198   _Angle = Angle;
199   _Xcentre = Xcentre; _Ycentre = Ycentre; _Zcentre = Zcentre;
200 }
201 //=======================================================================================
202 void HOMARD_Boundary::SetTorus( double X0, double X1, double X2,
203                                 double X3, double X4, double X5, double X6, double X7 )
204 {
205   _Xcentre = X0; _Ycentre = X1; _Zcentre = X2;
206   _Xaxe = X3; _Yaxe = X4; _Zaxe = X5;
207   _Rayon1 = X6;
208   _Rayon2 = X7;
209 }
210 //=======================================================================================
211 std::vector<double> HOMARD_Boundary::GetCoords() const
212 {
213   std::vector<double> mesCoor;
214   switch (_Type)
215   {
216     //  Cylindre
217     case 1:
218     {
219       mesCoor.push_back( _Xcentre );
220       mesCoor.push_back( _Ycentre );
221       mesCoor.push_back( _Zcentre );
222       mesCoor.push_back( _Xaxe );
223       mesCoor.push_back( _Yaxe );
224       mesCoor.push_back( _Zaxe );
225       mesCoor.push_back( _rayon );
226       break ;
227     }
228     //  Sphere
229     case 2:
230     {
231       mesCoor.push_back( _Xcentre );
232       mesCoor.push_back( _Ycentre );
233       mesCoor.push_back( _Zcentre );
234       mesCoor.push_back( _rayon );
235       break ;
236     }
237     //  Cone defini par un axe et un angle
238     case 3:
239     {
240       mesCoor.push_back( _Xaxe );
241       mesCoor.push_back( _Yaxe );
242       mesCoor.push_back( _Zaxe );
243       mesCoor.push_back( _Angle );
244       mesCoor.push_back( _Xcentre );
245       mesCoor.push_back( _Ycentre );
246       mesCoor.push_back( _Zcentre );
247       break ;
248     }
249     //  Cone defini par les 2 rayons
250     case 4:
251     {
252       mesCoor.push_back( _Xcentre1 );
253       mesCoor.push_back( _Ycentre1 );
254       mesCoor.push_back( _Zcentre1 );
255       mesCoor.push_back( _Rayon1 );
256       mesCoor.push_back( _Xcentre2 );
257       mesCoor.push_back( _Ycentre2 );
258       mesCoor.push_back( _Zcentre2 );
259       mesCoor.push_back( _Rayon2 );
260       break ;
261     }
262     //  Tore
263     case 5:
264     {
265       mesCoor.push_back( _Xcentre );
266       mesCoor.push_back( _Ycentre );
267       mesCoor.push_back( _Zcentre );
268       mesCoor.push_back( _Xaxe );
269       mesCoor.push_back( _Yaxe );
270       mesCoor.push_back( _Zaxe );
271       mesCoor.push_back( _Rayon1 );
272       mesCoor.push_back( _Rayon2 );
273       break ;
274     }
275     default:
276       break ;
277   }
278   return mesCoor;
279 }
280 //======================================================================
281 void HOMARD_Boundary::SetLimit( double X0, double X1, double X2 )
282 {
283   _Xincr = X0; _Yincr = X1; _Zincr = X2;
284 }
285 //=======================================================================================
286 std::vector<double> HOMARD_Boundary::GetLimit() const
287 {
288   std::vector<double> mesLimit;
289   mesLimit.push_back( _Xincr );
290   mesLimit.push_back( _Yincr );
291   mesLimit.push_back( _Zincr );
292   return mesLimit;
293 }
294 //=============================================================================
295 void HOMARD_Boundary::AddGroup( const char* Group)
296 {
297   _ListGroupSelected.push_back(Group);
298 }
299 //=============================================================================
300 void HOMARD_Boundary::SetGroups( const std::list<std::string>& ListGroup )
301 {
302   _ListGroupSelected.clear();
303   std::list<std::string>::const_iterator it = ListGroup.begin();
304   while(it != ListGroup.end())
305     _ListGroupSelected.push_back((*it++));
306 }
307 //=============================================================================
308 const std::list<std::string>& HOMARD_Boundary::GetGroups() const
309 {
310   return _ListGroupSelected;
311 }
312 //=============================================================================
313
314 //=============================================================================
315 /*!
316  *  default constructor:
317  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
318  */
319 //=============================================================================
320 HOMARD_Cas::HOMARD_Cas():
321   _NomDir("/tmp")
322 {
323   MESSAGE("HOMARD_Cas");
324 }
325 //=============================================================================
326 HOMARD_Cas::~HOMARD_Cas()
327 //=============================================================================
328 {
329   MESSAGE("~HOMARD_Cas");
330 }
331 //=============================================================================
332 //=============================================================================
333 // Generalites
334 //=============================================================================
335 //=============================================================================
336 std::string HOMARD_Cas::GetDumpPython() const
337 {
338   std::ostringstream aScript;
339   // Suivi de frontieres
340   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
341   while (it != _ListBoundaryGroup.end()) {
342     aScript << "smeshhomard.AddBoundaryGroup(\"" << *it << "\", \"";
343     it++;
344     aScript << *it << "\")\n";
345     it++;
346   }
347
348   return aScript.str();
349 }
350 //=============================================================================
351 //=============================================================================
352 // Caracteristiques
353 //=============================================================================
354 //=============================================================================
355 int HOMARD_Cas::SetDirName( const char* NomDir )
356 {
357   int erreur = 0 ;
358   // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
359   if ( _ListIter.size() > 1 ) { erreur = 1 ; }
360   // Creation
361   if ( CHDIR(NomDir) == 0 ) {
362     _NomDir = std::string( NomDir );
363   }
364   else {
365 #ifndef WIN32
366     if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
367 #else
368     if ( _mkdir(NomDir) == 0 )
369 #endif
370     {
371       if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
372       else                      { erreur = 2 ; }
373     }
374     else { erreur = 2 ; }
375   }
376   return erreur;
377 }
378 //=============================================================================
379 std::string HOMARD_Cas::GetDirName() const
380 {
381   return _NomDir;
382 }
383 //
384 // La boite englobante
385 //
386 //=============================================================================
387 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
388 {
389   _Boite.clear();
390   _Boite.resize( extremas.size() );
391   for ( unsigned int i = 0; i < extremas.size(); i++ )
392     _Boite[i] = extremas[i];
393 }
394 //=============================================================================
395 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
396 {
397   return _Boite;
398 }
399 //
400 // Les groupes
401 //
402 //=============================================================================
403 void HOMARD_Cas::AddGroup( const char* Group )
404 {
405   _ListGroup.push_back(Group);
406 }
407 //=============================================================================
408 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
409 {
410   _ListGroup.clear();
411   std::list<std::string>::const_iterator it = ListGroup.begin();
412   while(it != ListGroup.end())
413   {
414     _ListGroup.push_back((*it++));
415   }
416 }
417 //=============================================================================
418 const std::list<std::string>& HOMARD_Cas::GetGroups() const
419 {
420   return _ListGroup;
421 }
422 //=============================================================================
423 void HOMARD_Cas::SupprGroups()
424 {
425   _ListGroup.clear();
426 }
427 //
428 // Les frontieres
429 //
430 //=============================================================================
431 void HOMARD_Cas::AddBoundary( const char* Boundary )
432 {
433 //   MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary );
434   const char* Group = "";
435   AddBoundaryGroup( Boundary, Group );
436 }
437 //=============================================================================
438 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
439 {
440 //   MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary );
441 //   MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group );
442   _ListBoundaryGroup.push_back( Boundary );
443   _ListBoundaryGroup.push_back( Group    );
444 }
445 //=============================================================================
446 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
447 {
448   return _ListBoundaryGroup;
449 }
450 //=============================================================================
451 void HOMARD_Cas::SupprBoundaryGroup()
452 {
453   _ListBoundaryGroup.clear();
454 }
455 //=============================================================================
456 //=============================================================================
457 // Liens avec les autres structures
458 //=============================================================================
459 //=============================================================================
460 void HOMARD_Cas::AddIteration( const char* NomIteration )
461 {
462   _ListIter.push_back( std::string( NomIteration ) );
463 }
464
465 //=============================================================================
466 //=============================================================================
467 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
468   _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
469   _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ),
470   _Texte( "" ), _bLu( false )
471 {
472   MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
473   // Le repertoire ou se trouve l'executable HOMARD
474   std::string dir ;
475   // TODO?
476   if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
477   dir += "/bin/salome";
478   MESSAGE("dir ="<<dir);
479   // L'executable HOMARD
480   std::string executable = "homard";
481   MESSAGE("executable ="<<executable);
482   // Memorisation du nom complet de l'executable HOMARD
483   _HOMARD_Exec = dir + "/" + executable ;
484   MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
485   //
486   _siter = siter ;
487   _siterp1 = siterp1 ;
488 }
489 //=============================================================================
490 //=============================================================================
491 HomardDriver::~HomardDriver()
492 {
493 }
494 //===============================================================================
495 // A. Generalites
496 //===============================================================================
497 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
498 {
499   MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
500 //
501   _Texte  = "ListeStd \"" + LogFile + "\"\n" ;
502   _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
503   _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
504   _Texte += "Langue \"" + Langue + "\"\n" ;
505 //
506 }
507 //===============================================================================
508 void HomardDriver::TexteAdap()
509 {
510   MESSAGE("TexteAdap");
511
512   _Texte += "Action   homa\n";
513   _Texte += "CCAssoci med\n";
514   _Texte += "ModeHOMA 1\n";
515   _Texte += "NumeIter " + _siter + "\n";
516   _modeHOMARD = 1;
517 }
518 //===============================================================================
519 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
520 {
521   MESSAGE("TexteInfo: TypeBila ="<<TypeBila<<", NumeIter ="<<NumeIter);
522 //
523   _Texte += "ModeHOMA 2\n" ;
524   std::stringstream saux1 ;
525   saux1 << TypeBila ;
526   std::string saux2 = saux1.str() ;
527   _Texte += "TypeBila " + saux2 + "\n" ;
528   if ( NumeIter ==  0 )
529   {
530     _Texte += "NumeIter 0\n" ;
531     _Texte += "Action   info_av\n" ;
532     _Texte += "CCAssoci med\n" ;
533   }
534   else
535   {
536     _Texte += "NumeIter " + _siter + "\n" ;
537     _Texte += "Action   info_ap\n" ;
538     _Texte += "CCAssoci homard\n" ;
539   }
540   _modeHOMARD = 2 ;
541 //
542 }
543 //===============================================================================
544 void HomardDriver::TexteMajCoords( int NumeIter )
545 {
546   MESSAGE("TexteMajCoords: NumeIter ="<<NumeIter);
547 //
548   _Texte += "ModeHOMA 5\n" ;
549   _Texte += "NumeIter " + _siterp1 + "\n" ;
550   _Texte += "Action   homa\n" ;
551   _Texte += "CCAssoci med\n" ;
552   _Texte += "EcriFiHO N_SANS_FRONTIERE\n" ;
553   _modeHOMARD = 5 ;
554 //
555 }
556 //===============================================================================
557 // B. Les maillages en entree et en sortie
558 //===============================================================================
559 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
560 {
561   MESSAGE("TexteMaillage, NomMesh  = "<<NomMesh);
562   MESSAGE("TexteMaillage, MeshFile = "<<MeshFile);
563   MESSAGE("TexteMaillage, apres = "<<apres);
564   std::string saux ;
565   saux = "P1" ;
566   if ( apres < 1 ) { saux = "__" ; }
567
568   _Texte += "# Maillages Med " + saux + "\n" ;
569   _Texte += "CCNoMN" + saux + " \"" + NomMesh  + "\"\n" ;
570   _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
571 }
572
573 //===============================================================================
574 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
575 {
576   MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
577   std::string saux ;
578   if ( apres < 1 ) { saux = "__" ; }
579   else             { saux = "P1" ; }
580
581   _Texte += "# Maillage HOMARD " + liter + "\n" ;
582   _Texte += "HOMaiN" + saux + " Mai" + liter   + " \"" + Dir + "/maill." + liter   + ".hom.med\"\n" ;
583 }
584
585 //===============================================================================
586 // C. Le pilotage de l'adaptation
587 //===============================================================================
588 void HomardDriver::TexteConfRaffDera( int ConfType )
589 {
590   MESSAGE("TexteConfRaffDera, ConfType = " << ConfType);
591   //
592   // Type de conformite
593   //
594   std::string saux;
595   switch (ConfType)
596   {
597     case -2: //
598     {
599       saux = "NON_CONFORME_1_ARETE" ;
600       break;
601     }
602     case -1: //
603     {
604       saux = "CONFORME_BOITES" ;
605       break;
606     }
607     case 0: //
608     {
609       saux = "CONFORME" ;
610       break;
611     }
612     case 1: //
613     {
614       saux = "NON_CONFORME" ;
615       break;
616     }
617     case 2: //
618     {
619       saux = "NON_CONFORME_1_NOEUD" ;
620       break;
621     }
622     case 3: //
623     {
624       saux = "NON_CONFORME_INDICATEUR" ;
625       break;
626     }
627   }
628   _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
629   //
630   // Type de raffinement/deraffinement
631   //
632   saux = "TypeRaff uniforme\n" ;
633   saux += "TypeDera non" ;
634   _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
635 }
636 //===============================================================================
637 // D. Les frontieres
638 //===============================================================================
639 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
640 {
641   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
642 //
643 // Type de suivi de frontiere
644 //
645   std::stringstream saux1 ;
646   saux1 << BoundaryOption ;
647   std::string saux = saux1.str() ;
648   _Texte += "SuivFron " + saux + "\n" ;
649 //
650 }//===============================================================================
651 void HomardDriver::TexteBoundaryCAOGr(  const std::string GroupName )
652 {
653   MESSAGE("TexteBoundaryCAOGr, GroupName  = "<<GroupName);
654 //
655   _Texte += "GrFroCAO \"" + GroupName + "\"\n" ;
656 //
657 }
658
659 //===============================================================================
660 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
661 {
662   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
663   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
664 //
665   _Texte += "#\n# Frontiere discrete\n" ;
666   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
667   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
668 //
669 }
670 //===============================================================================
671 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
672 {
673   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
674 //
675   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
676 //
677 }
678 //===============================================================================
679 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 )
680 {
681   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
682 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
683   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
684 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
685 //
686   std::string saux, saux2 ;
687 //
688 // Commentaires
689 //
690   std::stringstream saux1 ;
691   saux1 << NumeBoundary ;
692   saux2 = saux1.str() ;
693   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
694   if ( BoundaryType == 1 )
695   { saux += "# Cylindre\n" ; }
696   if ( BoundaryType == 2 )
697   { saux += "# Sphere\n" ; }
698   if ( BoundaryType == 3 || BoundaryType == 4 )
699   { saux += "# Cone\n" ; }
700   if ( BoundaryType == 5 )
701   { saux += "# Tore\n" ; }
702 //
703 // Le nom de la frontiere
704 //
705   { std::stringstream saux1 ;
706     saux1 << NumeBoundary ;
707     saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
708   }
709 //
710 // Type de frontiere
711 //
712   { std::stringstream saux1 ;
713     saux1 << NumeBoundary << " " << BoundaryType ;
714     saux += "FAType " + saux1.str() + "\n" ;
715   }
716 //
717 // Cas du cylindre
718 //
719   if ( BoundaryType == 1 )
720   {
721     { std::stringstream saux1 ;
722       saux1 << NumeBoundary << " " << x0 ;
723       saux2 = saux1.str() ;
724       saux += "FAXCen " + saux1.str() + "\n" ;
725     }
726     { std::stringstream saux1 ;
727       saux1 << NumeBoundary << " " << x1 ;
728       saux += "FAYCen " + saux1.str() + "\n" ;
729     }
730     { std::stringstream saux1 ;
731       saux1 << NumeBoundary << " " << x2 ;
732       saux += "FAZCen " + saux1.str() + "\n" ;
733     }
734     { std::stringstream saux1 ;
735       saux1 << NumeBoundary << " " << x3 ;
736       saux += "FAXAxe " + saux1.str() + "\n" ;
737     }
738     { std::stringstream saux1 ;
739       saux1 << NumeBoundary << " " << x4 ;
740       saux += "FAYAxe " + saux1.str() + "\n" ;
741     }
742     { std::stringstream saux1 ;
743       saux1 << NumeBoundary << " " << x5 ;
744       saux += "FAZAxe " + saux1.str() + "\n" ;
745     }
746     { std::stringstream saux1 ;
747       saux1 << NumeBoundary << " " << x6 ;
748       saux += "FARayon " + saux1.str() + "\n" ;
749     }
750  }
751 //
752 // Cas de la sphere
753 //
754   else if ( BoundaryType == 2 )
755   {
756     { std::stringstream saux1 ;
757       saux1 << NumeBoundary << " " << x0 ;
758       saux += "FAXCen " + saux1.str() + "\n" ;
759     }
760     { std::stringstream saux1 ;
761       saux1 << NumeBoundary << " " << x1 ;
762       saux += "FAYCen " + saux1.str() + "\n" ;
763     }
764     { std::stringstream saux1 ;
765       saux1 << NumeBoundary << " " << x2 ;
766       saux += "FAZCen " + saux1.str() + "\n" ;
767     }
768     { std::stringstream saux1 ;
769       saux1 << NumeBoundary << " " << x3 ;
770       saux += "FARayon " + saux1.str() + "\n" ;
771     }
772   }
773 //
774 // Cas du cone defini par un axe et un angle
775 //
776   if ( BoundaryType == 3 )
777   {
778     { std::stringstream saux1 ;
779       saux1 << NumeBoundary << " " << x0 ;
780       saux += "FAXAxe " + saux1.str() + "\n" ;
781     }
782     { std::stringstream saux1 ;
783       saux1 << NumeBoundary << " " << x1 ;
784       saux += "FAYAxe " + saux1.str() + "\n" ;
785     }
786     { std::stringstream saux1 ;
787       saux1 << NumeBoundary << " " << x2 ;
788       saux += "FAZAxe " + saux1.str() + "\n" ;
789     }
790     { std::stringstream saux1 ;
791       saux1 << NumeBoundary << " " << x3 ;
792       saux += "FAAngle " + saux1.str() + "\n" ;
793     }
794     { std::stringstream saux1 ;
795       saux1 << NumeBoundary << " " << x4 ;
796       saux += "FAXCen " + saux1.str() + "\n" ;
797     }
798     { std::stringstream saux1 ;
799       saux1 << NumeBoundary << " " << x5 ;
800       saux += "FAYCen " + saux1.str() + "\n" ;
801     }
802     { std::stringstream saux1 ;
803       saux1 << NumeBoundary << " " << x6 ;
804       saux += "FAZCen " + saux1.str() + "\n" ;
805     }
806  }
807 //
808 // Cas du cone defini par les 2 rayons
809 //
810   if ( BoundaryType == 4 )
811   {
812     { std::stringstream saux1 ;
813       saux1 << NumeBoundary << " " << x0 ;
814       saux += "FAXCen " + saux1.str() + "\n" ;
815     }
816     { std::stringstream saux1 ;
817       saux1 << NumeBoundary << " " << x1 ;
818       saux += "FAYCen " + saux1.str() + "\n" ;
819     }
820     { std::stringstream saux1 ;
821       saux1 << NumeBoundary << " " << x2 ;
822       saux += "FAZCen " + saux1.str() + "\n" ;
823     }
824     { std::stringstream saux1 ;
825       saux1 << NumeBoundary << " " << x3 ;
826       saux += "FARayon " + saux1.str() + "\n" ;
827     }
828     { std::stringstream saux1 ;
829       saux1 << NumeBoundary << " " << x4 ;
830       saux += "FAXCen2 " + saux1.str() + "\n" ;
831     }
832     { std::stringstream saux1 ;
833       saux1 << NumeBoundary << " " << x5 ;
834       saux += "FAYCen2 " + saux1.str() + "\n" ;
835     }
836     { std::stringstream saux1 ;
837       saux1 << NumeBoundary << " " << x6 ;
838       saux += "FAZCen2 " + saux1.str() + "\n" ;
839     }
840     { std::stringstream saux1 ;
841       saux1 << NumeBoundary << " " << x7 ;
842       saux += "FARayon2 " + saux1.str() + "\n" ;
843     }
844  }
845 //
846 // Cas du tore
847 //
848   if ( BoundaryType == 5 )
849   {
850     { std::stringstream saux1 ;
851       saux1 << NumeBoundary << " " << x0 ;
852       saux2 = saux1.str() ;
853       saux += "FAXCen " + saux1.str() + "\n" ;
854     }
855     { std::stringstream saux1 ;
856       saux1 << NumeBoundary << " " << x1 ;
857       saux += "FAYCen " + saux1.str() + "\n" ;
858     }
859     { std::stringstream saux1 ;
860       saux1 << NumeBoundary << " " << x2 ;
861       saux += "FAZCen " + saux1.str() + "\n" ;
862     }
863     { std::stringstream saux1 ;
864       saux1 << NumeBoundary << " " << x3 ;
865       saux += "FAXAxe " + saux1.str() + "\n" ;
866     }
867     { std::stringstream saux1 ;
868       saux1 << NumeBoundary << " " << x4 ;
869       saux += "FAYAxe " + saux1.str() + "\n" ;
870     }
871     { std::stringstream saux1 ;
872       saux1 << NumeBoundary << " " << x5 ;
873       saux += "FAZAxe " + saux1.str() + "\n" ;
874     }
875     { std::stringstream saux1 ;
876       saux1 << NumeBoundary << " " << x6 ;
877       saux += "FARayon  " + saux1.str() + "\n" ;
878     }
879     { std::stringstream saux1 ;
880       saux1 << NumeBoundary << " " << x7 ;
881       saux += "FARayon2 " + saux1.str() + "\n" ;
882     }
883  }
884 //
885   _Texte += saux + "#\n" ;
886 //
887 }
888 //===============================================================================
889 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
890 {
891   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
892 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
893 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
894 //
895 // Commentaires
896 //
897   std::string saux, saux2 ;
898   std::stringstream saux1 ;
899   saux1 << NumeBoundary ;
900   saux2 = saux1.str() ;
901   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
902 //
903   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
904   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
905 //
906   _Texte += saux + "#\n" ;
907 //
908 }
909 //===============================================================================
910 // F. Les options avancees
911 //===============================================================================
912 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int ExtraOutput )
913 {
914   MESSAGE("TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<
915           ", AdapInit ="<<AdapInit<<", ExtraOutput ="<<ExtraOutput);
916
917   if ( NivMax > 0 )
918   {
919     _Texte += "# Niveaux extremes\n" ;
920     { std::stringstream saux1 ;
921       saux1 << NivMax ;
922       _Texte += "NiveauMa " + saux1.str() + "\n" ;
923     }
924   }
925   if ( DiamMin > 0 )
926   {
927     _Texte += "# Diametre minimal\n" ;
928     { std::stringstream saux1 ;
929       saux1 << DiamMin ;
930       _Texte += "DiametMi " + saux1.str()  + "\n" ;
931     }
932   }
933   if ( AdapInit != 0 )
934   {
935     if ( AdapInit > 0 )
936     { _Texte += "# Raffinement" ; }
937     else
938     { _Texte += "# Deraffinement" ; }
939     _Texte += " des regions sans indicateur\n" ;
940     { std::stringstream saux1 ;
941       saux1 << AdapInit ;
942       _Texte += "AdapInit " + saux1.str() + "\n" ;
943     }
944   }
945   if ( ExtraOutput % 2 == 0 )
946   {
947     _Texte += "# Sortie des niveaux de raffinement\n" ;
948     _Texte += "NCNiveau NIVEAU\n" ;
949   }
950   if ( ExtraOutput % 3 == 0 )
951   {
952     _Texte += "# Sortie des qualités des mailles\n" ;
953     _Texte += "NCQualit QUAL\n" ;
954   }
955   if ( ExtraOutput % 5 == 0 )
956   {
957     _Texte += "# Sortie des diamètres des mailles\n" ;
958     _Texte += "NCDiamet DIAM\n" ;
959   }
960   if ( ExtraOutput % 7 == 0 )
961   {
962     _Texte += "# Sortie des parents des mailles\n" ;
963     _Texte += "NCParent PARENT\n" ;
964   }
965   if ( ExtraOutput % 11 == 0 )
966   {
967     _Texte += "# Volumes voisins par recollement\n" ;
968     _Texte += "NCVoisRc Voisin-Recollement\n" ;
969   }
970 }
971 //===============================================================================
972 // G. Les messages
973 //===============================================================================
974 void HomardDriver::TexteInfoCompute( int MessInfo )
975 {
976   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
977
978   if ( MessInfo != 0 )
979   {
980      _Texte += "# Messages d'informations\n" ;
981     { std::stringstream saux1 ;
982       saux1 << MessInfo ;
983       _Texte += "MessInfo " + saux1.str()  + "\n" ;
984     }
985    }
986 }
987 //===============================================================================
988 void HomardDriver::CreeFichier( )
989 {
990 //
991   if ( _modeHOMARD == 1 )
992   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
993   else if ( _modeHOMARD == 2 )
994   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
995   else if ( _modeHOMARD == 5 )
996   { _NomFichierConf = _NomFichierConfBase + ".majc" ; }
997 //
998   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
999   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
1000   Fic.close() ;
1001 //
1002 }
1003 //===============================================================================
1004 // Creation du fichier de donnees pour l'information
1005 //===============================================================================
1006 void HomardDriver::CreeFichierDonn( )
1007 {
1008 //
1009   MESSAGE("CreeFichierDonn");
1010   _NomFichierDonn = "info.donn" ;
1011 //
1012   std::string data ;
1013   data  = "0\n" ;
1014   data += "0\n" ;
1015   data += "q\n" ;
1016   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
1017   if (Fic.is_open() == true) { Fic << data << std::endl ; }
1018   Fic.close() ;
1019 //
1020 }
1021 //===============================================================================
1022 int HomardDriver::ExecuteHomard()
1023 {
1024   MESSAGE("ExecuteHomard");
1025   std::string commande ;
1026   int codret ;
1027   // Copie des Fichiers HOMARD
1028   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
1029   codret = system(commande.c_str()) ;
1030
1031 // Execution de HOMARD
1032   if ( codret == 0)
1033   {
1034     commande = _HOMARD_Exec.c_str() ;
1035     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
1036     codret = system(commande.c_str());
1037     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
1038     _NomFichierDonn = "" ;
1039   };
1040   return codret ;
1041 }
1042
1043 //=============================================================================
1044 //=============================================================================
1045 HOMARD_Gen::HOMARD_Gen()
1046 {
1047   MESSAGE("HOMARD_Gen");
1048 }
1049
1050 //=============================================================================
1051 //=============================================================================
1052 HOMARD_Gen::~HOMARD_Gen()
1053 {
1054   MESSAGE("~HOMARD_Gen");
1055 }
1056 //=============================================================================
1057
1058 //=============================================================================
1059 /*!
1060  *  default constructor:
1061  */
1062 //=============================================================================
1063 HOMARD_Iteration::HOMARD_Iteration():
1064   _Name( "" ),
1065   _Etat( 0 ),
1066   _NumIter( -1 ),
1067   _NomMesh( "" ),
1068   _MeshFile( "" ),
1069   _LogFile( "" ),
1070   _NomDir( "" ),
1071   _FileInfo( "" ),
1072   _MessInfo( 1 )
1073 {
1074   MESSAGE("HOMARD_Iteration");
1075 }
1076 //=============================================================================
1077 /*!
1078  *
1079  */
1080 //=============================================================================
1081 HOMARD_Iteration::~HOMARD_Iteration()
1082 {
1083   MESSAGE("~HOMARD_Iteration");
1084 }
1085 //=============================================================================
1086 //=============================================================================
1087 // Generalites
1088 //=============================================================================
1089 //=============================================================================
1090 void HOMARD_Iteration::SetName( const char* Name )
1091 {
1092   _Name = std::string( Name );
1093 }
1094 //=============================================================================
1095 std::string HOMARD_Iteration::GetName() const
1096 {
1097   return _Name;
1098 }
1099 //=============================================================================
1100 //=============================================================================
1101 // Caracteristiques
1102 //=============================================================================
1103 //=============================================================================
1104 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
1105 {
1106   _NomDir = std::string( NomDir );
1107 }
1108 //=============================================================================
1109 std::string HOMARD_Iteration::GetDirNameLoc() const
1110 {
1111    return _NomDir;
1112 }
1113 //=============================================================================
1114 void HOMARD_Iteration::SetNumber( int NumIter )
1115 {
1116   _NumIter = NumIter;
1117 }
1118 //=============================================================================
1119 int HOMARD_Iteration::GetNumber() const
1120 {
1121   return _NumIter;
1122 }
1123 //=============================================================================
1124 void HOMARD_Iteration::SetState( int etat )
1125 {
1126   _Etat = etat;
1127 }
1128 //=============================================================================
1129 int HOMARD_Iteration::GetState() const
1130 {
1131   return _Etat;
1132 }
1133 //=============================================================================
1134 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
1135 {
1136   _NomMesh = std::string( NomMesh );
1137 }
1138 //=============================================================================
1139 std::string HOMARD_Iteration::GetMeshName() const
1140 {
1141   return _NomMesh;
1142 }
1143 //=============================================================================
1144 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
1145 {
1146   _MeshFile = std::string( MeshFile );
1147 }
1148 //=============================================================================
1149 std::string HOMARD_Iteration::GetMeshFile() const
1150 {
1151   return _MeshFile;
1152 }
1153 //=============================================================================
1154 void HOMARD_Iteration::SetLogFile( const char* LogFile )
1155 {
1156   _LogFile = std::string( LogFile );
1157 }
1158 //=============================================================================
1159 std::string HOMARD_Iteration::GetLogFile() const
1160 {
1161   return _LogFile;
1162 }
1163 //=============================================================================
1164 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
1165 {
1166   _FileInfo = std::string( FileInfo );
1167 }
1168 //=============================================================================
1169 std::string HOMARD_Iteration::GetFileInfo() const
1170 {
1171   return _FileInfo;
1172 }
1173 //=============================================================================
1174 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
1175 {
1176   _MessInfo = MessInfo;
1177 }
1178 //=============================================================================
1179 int HOMARD_Iteration::GetInfoCompute() const
1180 {
1181   return _MessInfo;
1182 }
1183
1184 } // namespace SMESHHOMARDImpl /end/