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 )
350 // std::cerr << "Dans HomardDriver::TexteBoundaryDi, MeshName ="<<MeshName << std::endl;
352 _Texte += "CCNoMFro " + MeshName + "\n" ;
353 _Texte += "CCFronti " + MeshFile + "\n" ;
355 // std::cerr << "A la fin de TexteBoundaryOption _Texte ="<<_Texte << std::endl;
357 ////=============================================================================
358 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 )
360 std::cerr << "Dans TexteBoundaryAn de HomardDriver NumeBoundary = "<<NumeBoundary << std::endl;
361 std::cerr << "Dans TexteBoundaryAn de HomardDriver BoundaryType = "<<BoundaryType << std::endl;
362 std::cerr << "Dans TexteBoundaryAn de HomardDriver coor = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6 <<std::endl;
364 std::string saux, saux2 ;
368 std::stringstream saux1 ;
369 saux1 << NumeBoundary ;
370 saux2 = saux1.str() ;
371 saux = "#\n# Frontiere numero " + saux2 + "\n" ;
372 if ( BoundaryType == 1 )
373 { saux += "# Cylindre\n" ; }
374 if ( BoundaryType == 2 )
375 { saux += "# Sphere\n" ; }
377 { std::stringstream saux1 ;
378 saux1 << NumeBoundary << " " << BoundaryType ;
379 saux2 = saux1.str() ;
380 saux += "FAType " + saux2 + "\n" ;
385 { std::stringstream saux1 ;
386 saux1 << NumeBoundary ;
387 saux2 = saux1.str() ;
388 saux += "FAGroupe " + saux2 + " '" + Group + "'\n" ;
393 if ( BoundaryType == 1 )
395 { std::stringstream saux1 ;
396 saux1 << NumeBoundary << " " << x0 ;
397 saux2 = saux1.str() ;
398 saux += "FAXCen " + saux2 + "\n" ;
400 { std::stringstream saux1 ;
401 saux1 << NumeBoundary << " " << x1 ;
402 saux2 = saux1.str() ;
403 saux += "FAYCen " + saux2 + "\n" ;
405 { std::stringstream saux1 ;
406 saux1 << NumeBoundary << " " << x2 ;
407 saux2 = saux1.str() ;
408 saux += "FAZCen " + saux2 + "\n" ;
410 { std::stringstream saux1 ;
411 saux1 << NumeBoundary << " " << x3 ;
412 saux2 = saux1.str() ;
413 saux += "FAXAxe " + saux2 + "\n" ;
415 { std::stringstream saux1 ;
416 saux1 << NumeBoundary << " " << x4 ;
417 saux2 = saux1.str() ;
418 saux += "FAYAxe " + saux2 + "\n" ;
420 { std::stringstream saux1 ;
421 saux1 << NumeBoundary << " " << x5 ;
422 saux2 = saux1.str() ;
423 saux += "FAZAxe " + saux2 + "\n" ;
425 { std::stringstream saux1 ;
426 saux1 << NumeBoundary << " " << x6 ;
427 saux2 = saux1.str() ;
428 saux += "FARayon " + saux2 + "\n" ;
434 else if ( BoundaryType == 2 )
436 { std::stringstream saux1 ;
437 saux1 << NumeBoundary << " " << x0 ;
438 saux2 = saux1.str() ;
439 saux += "FAXCen " + saux2 + "\n" ;
441 { std::stringstream saux1 ;
442 saux1 << NumeBoundary << " " << x1 ;
443 saux2 = saux1.str() ;
444 saux += "FAYCen " + saux2 + "\n" ;
446 { std::stringstream saux1 ;
447 saux1 << NumeBoundary << " " << x2 ;
448 saux2 = saux1.str() ;
449 saux += "FAZCen " + saux2 + "\n" ;
451 { std::stringstream saux1 ;
452 saux1 << NumeBoundary << " " << x3 ;
453 saux2 = saux1.str() ;
454 saux += "FARayon " + saux2 + "\n" ;
458 _Texte += saux + "#\n" ;
460 // std::cerr << "A la fin de TexteBoundaryAn _Texte ="<<_Texte << std::endl;
462 ////=============================================================================
463 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
465 MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
466 MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
467 MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
469 // Type d'interpolation
471 _Texte += "# Interpolations des champs\n" ;
472 _Texte += "CCSolN__ " + FieldFile + "\n" ;
473 _Texte += "CCSolNP1 " + MeshFile + "\n" ;
474 if ( TypeFieldInterp == 1 )
476 _Texte += "CCChaTou oui\n" ;
479 _TimeStep = TimeStep ;
482 // std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
484 ////=============================================================================
485 void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
487 MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
488 std::stringstream saux1 ;
489 saux1 << NumeChamp+1 ;
490 std::string saux = saux1.str() ;
491 _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
493 MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
494 if ( _TimeStep >= 0 )
497 std::stringstream saux1 ;
499 std::string saux2 = saux1.str() ;
500 _Texte += "CCChaPdT " + saux + " " + saux2 + "\n" ;
503 std::stringstream saux1 ;
505 std::string saux2 = saux1.str() ;
506 _Texte += "CCChaNuO " + saux + " " + saux2 + "\n" ;
512 ////=============================================================================
513 void HomardDriver::CreeFichier( )
516 _NomFichierConf = _NomFichierConfBase + "." + _siter + ".vers." + _siterp1 ;
518 std::ofstream FicConf(_NomFichierConf.c_str(), std::ios::out ) ;
519 if (FicConf.is_open() == true)
521 FicConf << _Texte << std::endl ;
527 ////=============================================================================
528 int HomardDriver::ExecuteHomard()
530 // Copie des Fichiers HOMARD
531 std::string commande= "cp " + _NomFichierConf + " " + _NomFichierConfBase ;
532 system(commande.c_str());
534 MESSAGE("ExecuteHomard");
535 int codret = system(_HOMARD_Exec.c_str()) ;
538 // GERALD -- QMESSAGE BOX
539 MESSAGE ( "Erreur en executant HOMARD : " << codret );
540 // ASSERT("Erreur en executant HOMARD" == 0);