]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESH/SMESH_Homard.cxx
Salome HOME
Reduce code
[modules/smesh.git] / src / SMESH / SMESH_Homard.cxx
1 // SMESH HOMARD : implementation of SMESHHOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2021  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 // Liens avec les autres structures
315 //=============================================================================
316 //=============================================================================
317 void HOMARD_Boundary::SetCaseCreation( const char* NomCasCreation )
318 {
319   _NomCasCreation = std::string( NomCasCreation );
320 }
321 //=============================================================================
322 std::string HOMARD_Boundary::GetCaseCreation() const
323 {
324   return _NomCasCreation;
325 }
326 //=============================================================================
327
328 //=============================================================================
329 /*!
330  *  default constructor:
331  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
332  */
333 //=============================================================================
334 HOMARD_Cas::HOMARD_Cas():
335   _Name(""), _NomDir("/tmp"), _ConfType(0)
336 {
337   MESSAGE("HOMARD_Cas");
338 }
339 //=============================================================================
340 HOMARD_Cas::~HOMARD_Cas()
341 //=============================================================================
342 {
343   MESSAGE("~HOMARD_Cas");
344 }
345 //=============================================================================
346 //=============================================================================
347 // Generalites
348 //=============================================================================
349 //=============================================================================
350 void HOMARD_Cas::SetName( const char* Name )
351 {
352   _Name = std::string( Name );
353 }
354 //=============================================================================
355 std::string HOMARD_Cas::GetName() const
356 {
357   return _Name;
358 }
359 //=============================================================================
360 std::string HOMARD_Cas::GetDumpPython() const
361 {
362   std::ostringstream aScript;
363   //aScript << _Name << ".SetDirName(\"" << _NomDir << "\")\n";
364   aScript << _Name << ".SetConfType(" << _ConfType << ")\n";
365   // Suivi de frontieres
366   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
367   while (it != _ListBoundaryGroup.end()) {
368     aScript << _Name << ".AddBoundaryGroup(\"" << *it << "\", \"";
369     it++;
370     aScript << *it << "\")\n";
371     it++;
372   }
373
374   return aScript.str();
375 }
376 //=============================================================================
377 //=============================================================================
378 // Caracteristiques
379 //=============================================================================
380 //=============================================================================
381 int HOMARD_Cas::SetDirName( const char* NomDir )
382 {
383   int erreur = 0 ;
384   // On vérifie qu'aucun calcul n'a eu lieu pour ce cas
385   if ( _ListIter.size() > 1 ) { erreur = 1 ; }
386   // Creation
387   if ( CHDIR(NomDir) == 0 ) {
388     _NomDir = std::string( NomDir );
389   }
390   else {
391 #ifndef WIN32
392     if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
393 #else
394     if ( _mkdir(NomDir) == 0 )
395 #endif
396     {
397       if ( CHDIR(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
398       else                      { erreur = 2 ; }
399     }
400     else { erreur = 2 ; }
401   }
402   return erreur;
403 }
404 //=============================================================================
405 std::string HOMARD_Cas::GetDirName() const
406 {
407   return _NomDir;
408 }
409 //
410 // Le type de conformite ou non conformite
411 //
412 //=============================================================================
413 void HOMARD_Cas::SetConfType( int Conftype )
414 {
415   _ConfType = Conftype;
416 }
417 //=============================================================================
418 const int HOMARD_Cas::GetConfType() const
419 {
420   return _ConfType;
421 }
422 //
423 // La boite englobante
424 //
425 //=============================================================================
426 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
427 {
428   _Boite.clear();
429   _Boite.resize( extremas.size() );
430   for ( unsigned int i = 0; i < extremas.size(); i++ )
431     _Boite[i] = extremas[i];
432 }
433 //=============================================================================
434 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
435 {
436   return _Boite;
437 }
438 //
439 // Les groupes
440 //
441 //=============================================================================
442 void HOMARD_Cas::AddGroup( const char* Group )
443 {
444   _ListGroup.push_back(Group);
445 }
446 //=============================================================================
447 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
448 {
449   _ListGroup.clear();
450   std::list<std::string>::const_iterator it = ListGroup.begin();
451   while(it != ListGroup.end())
452   {
453     _ListGroup.push_back((*it++));
454   }
455 }
456 //=============================================================================
457 const std::list<std::string>& HOMARD_Cas::GetGroups() const
458 {
459   return _ListGroup;
460 }
461 //=============================================================================
462 void HOMARD_Cas::SupprGroups()
463 {
464   _ListGroup.clear();
465 }
466 //
467 // Les frontieres
468 //
469 //=============================================================================
470 void HOMARD_Cas::AddBoundary( const char* Boundary )
471 {
472 //   MESSAGE ( ". HOMARD_Cas::AddBoundary : Boundary = " << Boundary );
473   const char* Group = "";
474   AddBoundaryGroup( Boundary, Group );
475 }
476 //=============================================================================
477 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
478 {
479 //   MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Boundary = " << Boundary );
480 //   MESSAGE ( ". HOMARD_Cas::AddBoundaryGroup : Group = " << Group );
481   _ListBoundaryGroup.push_back( Boundary );
482   _ListBoundaryGroup.push_back( Group    );
483 }
484 //=============================================================================
485 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
486 {
487   return _ListBoundaryGroup;
488 }
489 //=============================================================================
490 void HOMARD_Cas::SupprBoundaryGroup()
491 {
492   _ListBoundaryGroup.clear();
493 }
494 //=============================================================================
495 //=============================================================================
496 // Liens avec les autres structures
497 //=============================================================================
498 //=============================================================================
499 void HOMARD_Cas::AddIteration( const char* NomIteration )
500 {
501   _ListIter.push_back( std::string( NomIteration ) );
502 }
503
504 //=============================================================================
505 //=============================================================================
506 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
507   _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
508   _NomFichierConf( "" ), _NomFichierDonn( "" ), _siter( "" ), _siterp1( "" ),
509   _Texte( "" ), _bLu( false )
510 {
511   MESSAGE("siter = "<<siter<<", siterp1 = "<<siterp1);
512   // Le repertoire ou se trouve l'executable HOMARD
513   std::string dir ;
514   // TODO?
515   if ( getenv("HOMARD_ROOT_DIR") != NULL ) { dir = getenv("HOMARD_ROOT_DIR") ; }
516   dir += "/bin/salome";
517   MESSAGE("dir ="<<dir);
518   // L'executable HOMARD
519   std::string executable = "homard";
520   MESSAGE("executable ="<<executable);
521   // Memorisation du nom complet de l'executable HOMARD
522   _HOMARD_Exec = dir + "/" + executable ;
523   MESSAGE("==> _HOMARD_Exec ="<<_HOMARD_Exec) ;
524   //
525   _siter = siter ;
526   _siterp1 = siterp1 ;
527 }
528 //=============================================================================
529 //=============================================================================
530 HomardDriver::~HomardDriver()
531 {
532 }
533 //===============================================================================
534 // A. Generalites
535 //===============================================================================
536 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
537 {
538   MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
539 //
540   _Texte  = "ListeStd \"" + LogFile + "\"\n" ;
541   _Texte += "RepeTrav \"" + DirCompute + "\"\n" ;
542   _Texte += "RepeInfo \"" + DirCompute + "\"\n" ;
543   _Texte += "Langue \"" + Langue + "\"\n" ;
544 //
545 }
546 //===============================================================================
547 void HomardDriver::TexteAdap()
548 {
549   MESSAGE("TexteAdap");
550
551   _Texte += "Action   homa\n";
552   _Texte += "CCAssoci med\n";
553   _Texte += "ModeHOMA 1\n";
554   _Texte += "NumeIter " + _siter + "\n";
555   _modeHOMARD = 1;
556 }
557 //===============================================================================
558 void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
559 {
560   MESSAGE("TexteInfo: TypeBila ="<<TypeBila<<", NumeIter ="<<NumeIter);
561 //
562   _Texte += "ModeHOMA 2\n" ;
563   std::stringstream saux1 ;
564   saux1 << TypeBila ;
565   std::string saux2 = saux1.str() ;
566   _Texte += "TypeBila " + saux2 + "\n" ;
567   if ( NumeIter ==  0 )
568   {
569     _Texte += "NumeIter 0\n" ;
570     _Texte += "Action   info_av\n" ;
571     _Texte += "CCAssoci med\n" ;
572   }
573   else
574   {
575     _Texte += "NumeIter " + _siter + "\n" ;
576     _Texte += "Action   info_ap\n" ;
577     _Texte += "CCAssoci homard\n" ;
578   }
579   _modeHOMARD = 2 ;
580 //
581 }
582 //===============================================================================
583 void HomardDriver::TexteMajCoords( int NumeIter )
584 {
585   MESSAGE("TexteMajCoords: NumeIter ="<<NumeIter);
586 //
587   _Texte += "ModeHOMA 5\n" ;
588   _Texte += "NumeIter " + _siterp1 + "\n" ;
589   _Texte += "Action   homa\n" ;
590   _Texte += "CCAssoci med\n" ;
591   _Texte += "EcriFiHO N_SANS_FRONTIERE\n" ;
592   _modeHOMARD = 5 ;
593 //
594 }
595 //===============================================================================
596 // B. Les maillages en entree et en sortie
597 //===============================================================================
598 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
599 {
600   MESSAGE("TexteMaillage, NomMesh  = "<<NomMesh);
601   MESSAGE("TexteMaillage, MeshFile = "<<MeshFile);
602   MESSAGE("TexteMaillage, apres = "<<apres);
603   std::string saux ;
604   saux = "P1" ;
605   if ( apres < 1 ) { saux = "__" ; }
606
607   _Texte += "# Maillages Med " + saux + "\n" ;
608   _Texte += "CCNoMN" + saux + " \"" + NomMesh  + "\"\n" ;
609   _Texte += "CCMaiN" + saux + " \"" + MeshFile + "\"\n" ;
610 }
611
612 //===============================================================================
613 void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string liter, int apres )
614 {
615   MESSAGE("TexteMaillageHOMARD, Dir ="<<Dir<<", liter ="<<liter<<", apres ="<<apres);
616   std::string saux ;
617   if ( apres < 1 ) { saux = "__" ; }
618   else             { saux = "P1" ; }
619
620   _Texte += "# Maillage HOMARD " + liter + "\n" ;
621   _Texte += "HOMaiN" + saux + " Mai" + liter   + " \"" + Dir + "/maill." + liter   + ".hom.med\"\n" ;
622 }
623
624 //===============================================================================
625 // C. Le pilotage de l'adaptation
626 //===============================================================================
627 void HomardDriver::TexteConfRaffDera( int ConfType )
628 {
629   MESSAGE("TexteConfRaffDera, ConfType = " << ConfType);
630   //
631   // Type de conformite
632   //
633   std::string saux;
634   switch (ConfType)
635   {
636     case -2: //
637     {
638       saux = "NON_CONFORME_1_ARETE" ;
639       break;
640     }
641     case -1: //
642     {
643       saux = "CONFORME_BOITES" ;
644       break;
645     }
646     case 0: //
647     {
648       saux = "CONFORME" ;
649       break;
650     }
651     case 1: //
652     {
653       saux = "NON_CONFORME" ;
654       break;
655     }
656     case 2: //
657     {
658       saux = "NON_CONFORME_1_NOEUD" ;
659       break;
660     }
661     case 3: //
662     {
663       saux = "NON_CONFORME_INDICATEUR" ;
664       break;
665     }
666   }
667   _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
668   //
669   // Type de raffinement/deraffinement
670   //
671   saux = "TypeRaff uniforme\n" ;
672   saux += "TypeDera non" ;
673   _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
674 }
675 //===============================================================================
676 // D. Les frontieres
677 //===============================================================================
678 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
679 {
680   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
681 //
682 // Type de suivi de frontiere
683 //
684   std::stringstream saux1 ;
685   saux1 << BoundaryOption ;
686   std::string saux = saux1.str() ;
687   _Texte += "SuivFron " + saux + "\n" ;
688 //
689 }//===============================================================================
690 void HomardDriver::TexteBoundaryCAOGr(  const std::string GroupName )
691 {
692   MESSAGE("TexteBoundaryCAOGr, GroupName  = "<<GroupName);
693 //
694   _Texte += "GrFroCAO \"" + GroupName + "\"\n" ;
695 //
696 }
697
698 //===============================================================================
699 void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
700 {
701   MESSAGE("TexteBoundaryDi, MeshName  = "<<MeshName);
702   MESSAGE("TexteBoundaryDi, MeshFile  = "<<MeshFile);
703 //
704   _Texte += "#\n# Frontiere discrete\n" ;
705   _Texte += "CCNoMFro \"" + MeshName + "\"\n" ;
706   _Texte += "CCFronti \"" + MeshFile + "\"\n" ;
707 //
708 }
709 //===============================================================================
710 void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
711 {
712   MESSAGE("TexteBoundaryDiGr, GroupName  = "<<GroupName);
713 //
714   _Texte += "CCGroFro \"" + GroupName + "\"\n" ;
715 //
716 }
717 //===============================================================================
718 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 )
719 {
720   MESSAGE("TexteBoundaryAn, NameBoundary = "<<NameBoundary);
721 //   MESSAGE("TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
722   MESSAGE("TexteBoundaryAn, BoundaryType = "<<BoundaryType);
723 //   MESSAGE("TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6","<<x7);
724 //
725   std::string saux, saux2 ;
726 //
727 // Commentaires
728 //
729   std::stringstream saux1 ;
730   saux1 << NumeBoundary ;
731   saux2 = saux1.str() ;
732   saux = "#\n# Frontiere numero " + saux2 + "\n" ;
733   if ( BoundaryType == 1 )
734   { saux += "# Cylindre\n" ; }
735   if ( BoundaryType == 2 )
736   { saux += "# Sphere\n" ; }
737   if ( BoundaryType == 3 || BoundaryType == 4 )
738   { saux += "# Cone\n" ; }
739   if ( BoundaryType == 5 )
740   { saux += "# Tore\n" ; }
741 //
742 // Le nom de la frontiere
743 //
744   { std::stringstream saux1 ;
745     saux1 << NumeBoundary ;
746     saux += "FANom " + saux1.str() + " \"" + NameBoundary + "\"\n" ;
747   }
748 //
749 // Type de frontiere
750 //
751   { std::stringstream saux1 ;
752     saux1 << NumeBoundary << " " << BoundaryType ;
753     saux += "FAType " + saux1.str() + "\n" ;
754   }
755 //
756 // Cas du cylindre
757 //
758   if ( BoundaryType == 1 )
759   {
760     { std::stringstream saux1 ;
761       saux1 << NumeBoundary << " " << x0 ;
762       saux2 = saux1.str() ;
763       saux += "FAXCen " + saux1.str() + "\n" ;
764     }
765     { std::stringstream saux1 ;
766       saux1 << NumeBoundary << " " << x1 ;
767       saux += "FAYCen " + saux1.str() + "\n" ;
768     }
769     { std::stringstream saux1 ;
770       saux1 << NumeBoundary << " " << x2 ;
771       saux += "FAZCen " + saux1.str() + "\n" ;
772     }
773     { std::stringstream saux1 ;
774       saux1 << NumeBoundary << " " << x3 ;
775       saux += "FAXAxe " + saux1.str() + "\n" ;
776     }
777     { std::stringstream saux1 ;
778       saux1 << NumeBoundary << " " << x4 ;
779       saux += "FAYAxe " + saux1.str() + "\n" ;
780     }
781     { std::stringstream saux1 ;
782       saux1 << NumeBoundary << " " << x5 ;
783       saux += "FAZAxe " + saux1.str() + "\n" ;
784     }
785     { std::stringstream saux1 ;
786       saux1 << NumeBoundary << " " << x6 ;
787       saux += "FARayon " + saux1.str() + "\n" ;
788     }
789  }
790 //
791 // Cas de la sphere
792 //
793   else if ( BoundaryType == 2 )
794   {
795     { std::stringstream saux1 ;
796       saux1 << NumeBoundary << " " << x0 ;
797       saux += "FAXCen " + saux1.str() + "\n" ;
798     }
799     { std::stringstream saux1 ;
800       saux1 << NumeBoundary << " " << x1 ;
801       saux += "FAYCen " + saux1.str() + "\n" ;
802     }
803     { std::stringstream saux1 ;
804       saux1 << NumeBoundary << " " << x2 ;
805       saux += "FAZCen " + saux1.str() + "\n" ;
806     }
807     { std::stringstream saux1 ;
808       saux1 << NumeBoundary << " " << x3 ;
809       saux += "FARayon " + saux1.str() + "\n" ;
810     }
811   }
812 //
813 // Cas du cone defini par un axe et un angle
814 //
815   if ( BoundaryType == 3 )
816   {
817     { std::stringstream saux1 ;
818       saux1 << NumeBoundary << " " << x0 ;
819       saux += "FAXAxe " + saux1.str() + "\n" ;
820     }
821     { std::stringstream saux1 ;
822       saux1 << NumeBoundary << " " << x1 ;
823       saux += "FAYAxe " + saux1.str() + "\n" ;
824     }
825     { std::stringstream saux1 ;
826       saux1 << NumeBoundary << " " << x2 ;
827       saux += "FAZAxe " + saux1.str() + "\n" ;
828     }
829     { std::stringstream saux1 ;
830       saux1 << NumeBoundary << " " << x3 ;
831       saux += "FAAngle " + saux1.str() + "\n" ;
832     }
833     { std::stringstream saux1 ;
834       saux1 << NumeBoundary << " " << x4 ;
835       saux += "FAXCen " + saux1.str() + "\n" ;
836     }
837     { std::stringstream saux1 ;
838       saux1 << NumeBoundary << " " << x5 ;
839       saux += "FAYCen " + saux1.str() + "\n" ;
840     }
841     { std::stringstream saux1 ;
842       saux1 << NumeBoundary << " " << x6 ;
843       saux += "FAZCen " + saux1.str() + "\n" ;
844     }
845  }
846 //
847 // Cas du cone defini par les 2 rayons
848 //
849   if ( BoundaryType == 4 )
850   {
851     { std::stringstream saux1 ;
852       saux1 << NumeBoundary << " " << x0 ;
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 += "FARayon " + saux1.str() + "\n" ;
866     }
867     { std::stringstream saux1 ;
868       saux1 << NumeBoundary << " " << x4 ;
869       saux += "FAXCen2 " + saux1.str() + "\n" ;
870     }
871     { std::stringstream saux1 ;
872       saux1 << NumeBoundary << " " << x5 ;
873       saux += "FAYCen2 " + saux1.str() + "\n" ;
874     }
875     { std::stringstream saux1 ;
876       saux1 << NumeBoundary << " " << x6 ;
877       saux += "FAZCen2 " + saux1.str() + "\n" ;
878     }
879     { std::stringstream saux1 ;
880       saux1 << NumeBoundary << " " << x7 ;
881       saux += "FARayon2 " + saux1.str() + "\n" ;
882     }
883  }
884 //
885 // Cas du tore
886 //
887   if ( BoundaryType == 5 )
888   {
889     { std::stringstream saux1 ;
890       saux1 << NumeBoundary << " " << x0 ;
891       saux2 = saux1.str() ;
892       saux += "FAXCen " + saux1.str() + "\n" ;
893     }
894     { std::stringstream saux1 ;
895       saux1 << NumeBoundary << " " << x1 ;
896       saux += "FAYCen " + saux1.str() + "\n" ;
897     }
898     { std::stringstream saux1 ;
899       saux1 << NumeBoundary << " " << x2 ;
900       saux += "FAZCen " + saux1.str() + "\n" ;
901     }
902     { std::stringstream saux1 ;
903       saux1 << NumeBoundary << " " << x3 ;
904       saux += "FAXAxe " + saux1.str() + "\n" ;
905     }
906     { std::stringstream saux1 ;
907       saux1 << NumeBoundary << " " << x4 ;
908       saux += "FAYAxe " + saux1.str() + "\n" ;
909     }
910     { std::stringstream saux1 ;
911       saux1 << NumeBoundary << " " << x5 ;
912       saux += "FAZAxe " + saux1.str() + "\n" ;
913     }
914     { std::stringstream saux1 ;
915       saux1 << NumeBoundary << " " << x6 ;
916       saux += "FARayon  " + saux1.str() + "\n" ;
917     }
918     { std::stringstream saux1 ;
919       saux1 << NumeBoundary << " " << x7 ;
920       saux += "FARayon2 " + saux1.str() + "\n" ;
921     }
922  }
923 //
924   _Texte += saux + "#\n" ;
925 //
926 }
927 //===============================================================================
928 void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
929 {
930   MESSAGE("TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
931 //   MESSAGE("TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
932 //   MESSAGE("TexteBoundaryAnGr, GroupName  = "<<GroupName);
933 //
934 // Commentaires
935 //
936   std::string saux, saux2 ;
937   std::stringstream saux1 ;
938   saux1 << NumeBoundary ;
939   saux2 = saux1.str() ;
940   saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
941 //
942   saux += "FGNomFro " + saux2 + " \"" + NameBoundary + "\"\n" ;
943   saux += "FGNomGro " + saux2 + " \"" + GroupName + "\"\n" ;
944 //
945   _Texte += saux + "#\n" ;
946 //
947 }
948 //===============================================================================
949 // F. Les options avancees
950 //===============================================================================
951 void HomardDriver::TexteAdvanced( int NivMax, double DiamMin, int AdapInit, int ExtraOutput )
952 {
953   MESSAGE("TexteAdvanced, NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<
954           ", AdapInit ="<<AdapInit<<", ExtraOutput ="<<ExtraOutput);
955
956   if ( NivMax > 0 )
957   {
958     _Texte += "# Niveaux extremes\n" ;
959     { std::stringstream saux1 ;
960       saux1 << NivMax ;
961       _Texte += "NiveauMa " + saux1.str() + "\n" ;
962     }
963   }
964   if ( DiamMin > 0 )
965   {
966     _Texte += "# Diametre minimal\n" ;
967     { std::stringstream saux1 ;
968       saux1 << DiamMin ;
969       _Texte += "DiametMi " + saux1.str()  + "\n" ;
970     }
971   }
972   if ( AdapInit != 0 )
973   {
974     if ( AdapInit > 0 )
975     { _Texte += "# Raffinement" ; }
976     else
977     { _Texte += "# Deraffinement" ; }
978     _Texte += " des regions sans indicateur\n" ;
979     { std::stringstream saux1 ;
980       saux1 << AdapInit ;
981       _Texte += "AdapInit " + saux1.str() + "\n" ;
982     }
983   }
984   if ( ExtraOutput % 2 == 0 )
985   {
986     _Texte += "# Sortie des niveaux de raffinement\n" ;
987     _Texte += "NCNiveau NIVEAU\n" ;
988   }
989   if ( ExtraOutput % 3 == 0 )
990   {
991     _Texte += "# Sortie des qualités des mailles\n" ;
992     _Texte += "NCQualit QUAL\n" ;
993   }
994   if ( ExtraOutput % 5 == 0 )
995   {
996     _Texte += "# Sortie des diamètres des mailles\n" ;
997     _Texte += "NCDiamet DIAM\n" ;
998   }
999   if ( ExtraOutput % 7 == 0 )
1000   {
1001     _Texte += "# Sortie des parents des mailles\n" ;
1002     _Texte += "NCParent PARENT\n" ;
1003   }
1004   if ( ExtraOutput % 11 == 0 )
1005   {
1006     _Texte += "# Volumes voisins par recollement\n" ;
1007     _Texte += "NCVoisRc Voisin-Recollement\n" ;
1008   }
1009 }
1010 //===============================================================================
1011 // G. Les messages
1012 //===============================================================================
1013 void HomardDriver::TexteInfoCompute( int MessInfo )
1014 {
1015   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);
1016
1017   if ( MessInfo != 0 )
1018   {
1019      _Texte += "# Messages d'informations\n" ;
1020     { std::stringstream saux1 ;
1021       saux1 << MessInfo ;
1022       _Texte += "MessInfo " + saux1.str()  + "\n" ;
1023     }
1024    }
1025 }
1026 //===============================================================================
1027 void HomardDriver::CreeFichier( )
1028 {
1029 //
1030   if ( _modeHOMARD == 1 )
1031   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ; }
1032   else if ( _modeHOMARD == 2 )
1033   { _NomFichierConf = _NomFichierConfBase + "." + _siter + ".info" ; }
1034   else if ( _modeHOMARD == 5 )
1035   { _NomFichierConf = _NomFichierConfBase + ".majc" ; }
1036 //
1037   std::ofstream Fic(_NomFichierConf.c_str(), std::ios::out ) ;
1038   if (Fic.is_open() == true) { Fic << _Texte << std::endl ; }
1039   Fic.close() ;
1040 //
1041 }
1042 //===============================================================================
1043 // Creation du fichier de donnees pour l'information
1044 //===============================================================================
1045 void HomardDriver::CreeFichierDonn( )
1046 {
1047 //
1048   MESSAGE("CreeFichierDonn");
1049   _NomFichierDonn = "info.donn" ;
1050 //
1051   std::string data ;
1052   data  = "0\n" ;
1053   data += "0\n" ;
1054   data += "q\n" ;
1055   std::ofstream Fic(_NomFichierDonn.c_str(), std::ios::out ) ;
1056   if (Fic.is_open() == true) { Fic << data << std::endl ; }
1057   Fic.close() ;
1058 //
1059 }
1060 //===============================================================================
1061 int HomardDriver::ExecuteHomard()
1062 {
1063   MESSAGE("ExecuteHomard");
1064   std::string commande ;
1065   int codret ;
1066   // Copie des Fichiers HOMARD
1067   commande = "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
1068   codret = system(commande.c_str()) ;
1069
1070 // Execution de HOMARD
1071   if ( codret == 0)
1072   {
1073     commande = _HOMARD_Exec.c_str() ;
1074     if ( _NomFichierDonn != "" ) { commande += " < " + _NomFichierDonn ; }
1075     codret = system(commande.c_str());
1076     if ( codret != 0) { MESSAGE ( "Erreur en executant HOMARD : " << codret ); };
1077     _NomFichierDonn = "" ;
1078   };
1079   return codret ;
1080 }
1081
1082 //=============================================================================
1083 //=============================================================================
1084 HOMARD_Gen::HOMARD_Gen()
1085 {
1086   MESSAGE("HOMARD_Gen");
1087 }
1088
1089 //=============================================================================
1090 //=============================================================================
1091 HOMARD_Gen::~HOMARD_Gen()
1092 {
1093   MESSAGE("~HOMARD_Gen");
1094 }
1095 //=============================================================================
1096
1097 //=============================================================================
1098 /*!
1099  *  default constructor:
1100  */
1101 //=============================================================================
1102 HOMARD_Iteration::HOMARD_Iteration():
1103   _Name( "" ),
1104   _Etat( 0 ),
1105   _NumIter( -1 ),
1106   _NomMesh( "" ),
1107   _MeshFile( "" ),
1108   _LogFile( "" ),
1109   _NomDir( "" ),
1110   _FileInfo( "" ),
1111   _MessInfo( 1 )
1112 {
1113   MESSAGE("HOMARD_Iteration");
1114 }
1115 //=============================================================================
1116 /*!
1117  *
1118  */
1119 //=============================================================================
1120 HOMARD_Iteration::~HOMARD_Iteration()
1121 {
1122   MESSAGE("~HOMARD_Iteration");
1123 }
1124 //=============================================================================
1125 //=============================================================================
1126 // Generalites
1127 //=============================================================================
1128 //=============================================================================
1129 void HOMARD_Iteration::SetName( const char* Name )
1130 {
1131   _Name = std::string( Name );
1132 }
1133 //=============================================================================
1134 std::string HOMARD_Iteration::GetName() const
1135 {
1136   return _Name;
1137 }
1138 //=============================================================================
1139 //=============================================================================
1140 // Caracteristiques
1141 //=============================================================================
1142 //=============================================================================
1143 void HOMARD_Iteration::SetDirNameLoc( const char* NomDir )
1144 {
1145   _NomDir = std::string( NomDir );
1146 }
1147 //=============================================================================
1148 std::string HOMARD_Iteration::GetDirNameLoc() const
1149 {
1150    return _NomDir;
1151 }
1152 //=============================================================================
1153 void HOMARD_Iteration::SetNumber( int NumIter )
1154 {
1155   _NumIter = NumIter;
1156 }
1157 //=============================================================================
1158 int HOMARD_Iteration::GetNumber() const
1159 {
1160   return _NumIter;
1161 }
1162 //=============================================================================
1163 void HOMARD_Iteration::SetState( int etat )
1164 {
1165   _Etat = etat;
1166 }
1167 //=============================================================================
1168 int HOMARD_Iteration::GetState() const
1169 {
1170   return _Etat;
1171 }
1172 //=============================================================================
1173 void HOMARD_Iteration::SetMeshName( const char* NomMesh )
1174 {
1175   _NomMesh = std::string( NomMesh );
1176 }
1177 //=============================================================================
1178 std::string HOMARD_Iteration::GetMeshName() const
1179 {
1180   return _NomMesh;
1181 }
1182 //=============================================================================
1183 void HOMARD_Iteration::SetMeshFile( const char* MeshFile )
1184 {
1185   _MeshFile = std::string( MeshFile );
1186 }
1187 //=============================================================================
1188 std::string HOMARD_Iteration::GetMeshFile() const
1189 {
1190   return _MeshFile;
1191 }
1192 //=============================================================================
1193 void HOMARD_Iteration::SetLogFile( const char* LogFile )
1194 {
1195   _LogFile = std::string( LogFile );
1196 }
1197 //=============================================================================
1198 std::string HOMARD_Iteration::GetLogFile() const
1199 {
1200   return _LogFile;
1201 }
1202 //=============================================================================
1203 void HOMARD_Iteration::SetFileInfo( const char* FileInfo )
1204 {
1205   _FileInfo = std::string( FileInfo );
1206 }
1207 //=============================================================================
1208 std::string HOMARD_Iteration::GetFileInfo() const
1209 {
1210   return _FileInfo;
1211 }
1212 //=============================================================================
1213 void HOMARD_Iteration::SetInfoCompute( int MessInfo )
1214 {
1215   _MessInfo = MessInfo;
1216 }
1217 //=============================================================================
1218 int HOMARD_Iteration::GetInfoCompute() const
1219 {
1220   return _MessInfo;
1221 }
1222
1223 } // namespace SMESHHOMARDImpl /end/