5 #include "Utils_SALOME_Exception.hxx"
7 #include "HomardDriver.hxx"
9 //=============================================================================
10 //=============================================================================
11 HomardDriver::HomardDriver(const std::string siter, const std::string siterp1):
12 _HOMARD_Exec( "" ), _NomDir( "" ), _NomFichierConfBase( "HOMARD.Configuration" ),
13 _NomFichierConf( "" ), _siter( "" ), _siterp1( "" ),
14 _Texte( "" ), _bLu( false )
16 // Memorisation du nom complet de l'executable HOMARD
17 char* dirchar; char* execchar;
19 std::string executable;
20 if ( !(dirchar = getenv("HOMARD_REP_EXE")) )
21 dir = "/logiciels/HOMARD/HOMARD_PUBLIC/Linux64" ;
23 dir = std::string(dirchar);
24 if ( !(execchar = getenv("HOMARD_EXE")) )
25 executable = "HOMARD";
27 executable = std::string(execchar);
28 _HOMARD_Exec = dir + "/" + executable ;
34 //=============================================================================
35 //=============================================================================
36 HomardDriver::~HomardDriver()
40 ////=============================================================================
41 void HomardDriver::TexteInit( const std::string DirCompute, const std::string DirComputePa, const std::string MessFile )
44 _Texte = "Action homa\n" ;
45 _Texte += "CCAssoci med\n" ;
46 _Texte += "ModeHOMA 1\n" ;
47 _Texte += "NumeIter " + _siter + "\n" ;
48 _Texte += "ListeStd " + MessFile + "\n" ;
49 _Texte += "# Maillages HOMARD \n" ;
50 _Texte += "HOMaiN__ Mai" + _siter + " " + DirComputePa + "/maill." + _siter + ".hom.med\n" ;
51 _Texte += "HOMaiNP1 Mai" + _siterp1 + " " + DirCompute + "/maill." + _siterp1 + ".hom.med\n" ;
52 _Texte += "RepeTrav " + DirCompute + "\n" ;
56 ////=============================================================================
57 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
61 if ( apres < 1 ) { saux = "__" ; }
63 _Texte += "# Maillages Med " + saux + "\n" ;
64 _Texte += "CCNoMN" + saux + " \"" + NomMesh + "\"\n" ;
65 _Texte += "CCMaiN" + saux + " " + MeshFile + "\n" ;
68 ////=============================================================================
69 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
71 // std::cerr << "Dans HomardDriver::TexteConfRaffDera, ConfType ="<<ConfType << std::endl;
72 // std::cerr << "Dans HomardDriver::TexteConfRaffDera, TypeAdap ="<<TypeAdap << std::endl;
73 // std::cerr << "Dans HomardDriver::TexteConfRaffDera, TypeRaff ="<<TypeRaff << std::endl;
74 // std::cerr << "Dans HomardDriver::TexteConfRaffDera, TypeDera ="<<TypeDera << std::endl;
88 saux = "non_conforme_1_noeud" ;
93 saux = "non_conforme_1_arete" ;
98 saux = "non_conforme_indicateur" ;
102 _Texte += "# Type de conformite\nTypeConf " + saux + "\n" ;
104 // Type de raffinement/deraffinement
106 if ( TypeAdap == -1 )
110 saux = "TypeRaff uniforme\n" ;
114 saux = "TypeRaff non\n" ;
118 saux += "TypeDera uniforme" ;
122 saux += "TypeDera non" ;
129 saux = "TypeRaff libre\n" ;
133 saux = "TypeRaff non\n" ;
137 saux += "TypeDera libre" ;
141 saux += "TypeDera non" ;
144 _Texte += "# Type de raffinement/deraffinement\n" + saux + "\n" ;
146 // std::cerr << "A la fin de TexteConfRaffDera _Texte ="<<_Texte << std::endl;
148 ////=============================================================================
149 void HomardDriver::TexteCompo( int NumeComp, const std::string NompCompo)
151 // std::cerr << "Dans TexteCompo de HomardDriver NompCompo = "<<NompCompo << std::endl;
152 _Texte +="CCCoChaI \"" + NompCompo + "\"\n" ;
155 ////=============================================================================
156 void HomardDriver::TexteZone( int NumeZone, int ZoneType, double x0, double x1, double x2, double x3, double x4, double x5 )
158 // std::cerr << "Dans TexteZone de HomardDriver NumeZone = "<<NumeZone << std::endl;
159 // std::cerr << "Dans TexteZone de HomardDriver ZoneType = "<<ZoneType << std::endl;
160 // std::cerr << "Dans TexteZone de HomardDriver coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5 <<std::endl;
162 std::string saux, saux2 ;
166 std::stringstream saux1 ;
168 saux2 = saux1.str() ;
169 saux = "#\n# Zone numero " + saux2 + "\n" ;
171 { std::stringstream saux1 ;
172 saux1 << NumeZone << " " << ZoneType ;
173 saux2 = saux1.str() ;
174 saux += "ZoRaType " + saux2 + "\n" ;
177 // Cas du rectangle/parallelepipede
181 saux += "# Boite\n" ;
182 { std::stringstream saux1 ;
183 saux1 << NumeZone << " " << x0 ;
184 saux2 = saux1.str() ;
185 saux += "ZoRaXmin " + saux2 + "\n" ;
187 { std::stringstream saux1 ;
188 saux1 << NumeZone << " " << x1 ;
189 saux2 = saux1.str() ;
190 saux += "ZoRaXmax " + saux2 + "\n" ;
192 { std::stringstream saux1 ;
193 saux1 << NumeZone << " " << x2 ;
194 saux2 = saux1.str() ;
195 saux += "ZoRaYmin " + saux2 + "\n" ;
197 { std::stringstream saux1 ;
198 saux1 << NumeZone << " " << x3 ;
199 saux2 = saux1.str() ;
200 saux += "ZoRaYmax " + saux2 + "\n" ;
202 { std::stringstream saux1 ;
203 saux1 << NumeZone << " " << x4 ;
204 saux2 = saux1.str() ;
205 saux += "ZoRaZmin " + saux2 + "\n" ;
207 { std::stringstream saux1 ;
208 saux1 << NumeZone << " " << x5 ;
209 saux2 = saux1.str() ;
210 saux += "ZoRaZmax " + saux2 + "\n" ;
214 // Cas du cercle/sphere
216 else if ( ZoneType == 4 )
218 saux += "# Sphere\n" ;
219 { std::stringstream saux1 ;
220 saux1 << NumeZone << " " << x0 ;
221 saux2 = saux1.str() ;
222 saux += "ZoRaXCen " + saux2 + "\n" ;
224 { std::stringstream saux1 ;
225 saux1 << NumeZone << " " << x1 ;
226 saux2 = saux1.str() ;
227 saux += "ZoRaYCen " + saux2 + "\n" ;
229 { std::stringstream saux1 ;
230 saux1 << NumeZone << " " << x2 ;
231 saux2 = saux1.str() ;
232 saux += "ZoRaZCen " + saux2 + "\n" ;
234 { std::stringstream saux1 ;
235 saux1 << NumeZone << " " << x3 ;
236 saux2 = saux1.str() ;
237 saux += "ZoRaRayo " + saux2 + "\n" ;
241 _Texte += saux + "#\n" ;
243 // std::cerr << "A la fin de TexteZone _Texte ="<<_Texte << std::endl;
246 ////=============================================================================
247 void HomardDriver::TexteField( const std::string FieldName, const std::string FieldFile, int TimeStep, int Rank,
248 int TypeThR, double ThreshR, int TypeThC, double ThreshC, int UsCmpI )
250 MESSAGE("TexteField, FieldName = "<<FieldName<<", FieldFile = "<<FieldFile);
251 MESSAGE("TexteField, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
253 std::string saux, saux2 ;
256 _Texte += "# Champ d'indicateurs\n" ;
257 _Texte += "CCIndica " + FieldFile + "\n" ;
258 _Texte += "CCNoChaI \"" + FieldName + "\"\n" ;
260 // std::cerr << "HomardDriver::TexteField TimeStep" << TimeStep<<std::endl;
261 // std::cerr << "HomardDriver::TexteField Rank" << Rank<<std::endl;
262 // Cas ou on prend le dernier pas de temps
263 if ( TimeStep == -2 )
264 { _Texte += "CCNumPTI Last\n" ; }
265 // Cas avec pas de temps
266 else if ( TimeStep >= 0 )
269 std::stringstream saux1 ;
271 saux2 = saux1.str() ;
272 _Texte += "CCNumPTI " + saux2 + "\n" ;
275 std::stringstream saux1 ;
277 saux2 = saux1.str() ;
278 _Texte += "CCNumOrI " + saux2 + "\n" ;
291 std::stringstream saux1 ;
293 saux2 = saux1.str() ;
294 _Texte += "Seuil" + saux + " " + saux2 + "\n" ;
306 std::stringstream saux1 ;
308 saux2 = saux1.str() ;
309 _Texte += "Seuil" + saux + " " + saux2 + "\n" ;
316 { saux = "INFINI" ; }
318 { saux = "V_RELATIVE" ; }
321 _Texte += "CCUsCmpI " + saux + "\n" ;
325 ////=============================================================================
326 void HomardDriver::TexteGroup( const std::string GroupName )
328 // std::cerr << "Dans HomardDriver::TexteGroup NomGroupe ="<<NomGroupe << std::endl;
330 _Texte += "CCGroAda " + GroupName + "\n" ;
333 ////=============================================================================
334 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
336 // std::cerr << "Dans HomardDriver::TexteBoundaryOption, BoundaryOption ="<<BoundaryOption << std::endl;
338 // Type de suivi de frontiere
340 std::stringstream saux1 ;
341 saux1 << BoundaryOption ;
342 std::string saux = saux1.str() ;
343 _Texte += "SuivFron " + saux + "\n" ;
345 // std::cerr << "A la fin de TexteBoundaryOption _Texte ="<<_Texte << std::endl;
347 ////=============================================================================
348 void HomardDriver::TexteBoundaryDi( const std::string MeshName, const std::string MeshFile, const std::string GroupName )
350 MESSAGE("Dans TexteBoundaryDi de HomardDriver MeshName = "<<MeshName);
351 MESSAGE("Dans TexteBoundaryDi de HomardDriver MeshFile = "<<MeshFile);
352 MESSAGE("Dans TexteBoundaryDi de HomardDriver GroupName = "<<GroupName);
354 _Texte += "CCNoMFro " + MeshName + "\n" ;
355 _Texte += "CCFronti " + MeshFile + "\n" ;
356 if ( GroupName.size() > 0 ) _Texte += "CCGroFro " + GroupName + "\n" ;
358 // std::cerr << "A la fin de TexteBoundaryOption _Texte ="<<_Texte << std::endl;
360 ////=============================================================================
361 void HomardDriver::TexteBoundaryAn( int NumeBoundary, int BoundaryType, const std::string Group, double x0, double x1, double x2, double x3, double x4, double x5, double x6 )
363 MESSAGE("Dans TexteBoundaryAn de HomardDriver NumeBoundary = "<<NumeBoundary);
364 MESSAGE("Dans TexteBoundaryAn de HomardDriver BoundaryType = "<<BoundaryType);
365 MESSAGE("Dans TexteBoundaryAn de HomardDriver coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6);
367 std::string saux, saux2 ;
371 std::stringstream saux1 ;
372 saux1 << NumeBoundary ;
373 saux2 = saux1.str() ;
374 saux = "#\n# Frontiere numero " + saux2 + "\n" ;
375 if ( BoundaryType == 1 )
376 { saux += "# Cylindre\n" ; }
377 if ( BoundaryType == 2 )
378 { saux += "# Sphere\n" ; }
380 { std::stringstream saux1 ;
381 saux1 << NumeBoundary << " " << BoundaryType ;
382 saux2 = saux1.str() ;
383 saux += "FAType " + saux2 + "\n" ;
388 { std::stringstream saux1 ;
389 saux1 << NumeBoundary ;
390 saux2 = saux1.str() ;
391 saux += "FAGroupe " + saux2 + " '" + Group + "'\n" ;
396 if ( BoundaryType == 1 )
398 { std::stringstream saux1 ;
399 saux1 << NumeBoundary << " " << x0 ;
400 saux2 = saux1.str() ;
401 saux += "FAXCen " + saux2 + "\n" ;
403 { std::stringstream saux1 ;
404 saux1 << NumeBoundary << " " << x1 ;
405 saux2 = saux1.str() ;
406 saux += "FAYCen " + saux2 + "\n" ;
408 { std::stringstream saux1 ;
409 saux1 << NumeBoundary << " " << x2 ;
410 saux2 = saux1.str() ;
411 saux += "FAZCen " + saux2 + "\n" ;
413 { std::stringstream saux1 ;
414 saux1 << NumeBoundary << " " << x3 ;
415 saux2 = saux1.str() ;
416 saux += "FAXAxe " + saux2 + "\n" ;
418 { std::stringstream saux1 ;
419 saux1 << NumeBoundary << " " << x4 ;
420 saux2 = saux1.str() ;
421 saux += "FAYAxe " + saux2 + "\n" ;
423 { std::stringstream saux1 ;
424 saux1 << NumeBoundary << " " << x5 ;
425 saux2 = saux1.str() ;
426 saux += "FAZAxe " + saux2 + "\n" ;
428 { std::stringstream saux1 ;
429 saux1 << NumeBoundary << " " << x6 ;
430 saux2 = saux1.str() ;
431 saux += "FARayon " + saux2 + "\n" ;
437 else if ( BoundaryType == 2 )
439 { std::stringstream saux1 ;
440 saux1 << NumeBoundary << " " << x0 ;
441 saux2 = saux1.str() ;
442 saux += "FAXCen " + saux2 + "\n" ;
444 { std::stringstream saux1 ;
445 saux1 << NumeBoundary << " " << x1 ;
446 saux2 = saux1.str() ;
447 saux += "FAYCen " + saux2 + "\n" ;
449 { std::stringstream saux1 ;
450 saux1 << NumeBoundary << " " << x2 ;
451 saux2 = saux1.str() ;
452 saux += "FAZCen " + saux2 + "\n" ;
454 { std::stringstream saux1 ;
455 saux1 << NumeBoundary << " " << x3 ;
456 saux2 = saux1.str() ;
457 saux += "FARayon " + saux2 + "\n" ;
461 _Texte += saux + "#\n" ;
463 // std::cerr << "A la fin de TexteBoundaryAn _Texte ="<<_Texte << std::endl;
465 ////=============================================================================
466 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
468 MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
469 MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
470 MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
472 // Type d'interpolation
474 _Texte += "# Interpolations des champs\n" ;
475 _Texte += "CCSolN__ " + FieldFile + "\n" ;
476 _Texte += "CCSolNP1 " + MeshFile + "\n" ;
477 if ( TypeFieldInterp == 1 )
479 _Texte += "CCChaTou oui\n" ;
482 _TimeStep = TimeStep ;
485 // std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
487 ////=============================================================================
488 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
490 MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
491 std::stringstream saux1 ;
492 saux1 << NumeChamp+1 ;
493 std::string saux = saux1.str() ;
494 _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
496 MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
497 if ( _TimeStep >= 0 )
500 std::stringstream saux1 ;
502 std::string saux2 = saux1.str() ;
503 _Texte += "CCChaPdT " + saux + " " + saux2 + "\n" ;
506 std::stringstream saux1 ;
508 std::string saux2 = saux1.str() ;
509 _Texte += "CCChaNuO " + saux + " " + saux2 + "\n" ;
515 ////=============================================================================
516 void HomardDriver::CreeFichier( )
519 _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ;
521 std::ofstream FicConf(_NomFichierConf.c_str(), std::ios::out ) ;
522 if (FicConf.is_open() == true)
524 FicConf << _Texte << std::endl ;
530 ////=============================================================================
531 int HomardDriver::ExecuteHomard()
533 // Copie des Fichiers HOMARD
534 std::string commande= "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
535 system(commande.c_str());
537 MESSAGE("ExecuteHomard");
538 int codret = system(_HOMARD_Exec.c_str()) ;
541 // GERALD -- QMESSAGE BOX
542 MESSAGE ( "Erreur en executant HOMARD : " << codret );
543 // ASSERT("Erreur en executant HOMARD" == 0);