Salome HOME
Frontière analytique torique
[modules/homard.git] / src / HOMARD / HomardDriver.cxx
index 04e810b8c43db196da761bb360af8bf9a8a85ee1..12f70941549c1c38e0e45b427ee900987a96cbff 100644 (file)
 // Pilote l'ecriture du fichier de configuration pour lancer l'execution de HOMARD
 
 #include <cstring>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <sys/stat.h>
 
+#include "HomardDriver.hxx"
 #include "Utils_SALOME_Exception.hxx"
 #include "utilities.h"
-#include "HomardDriver.hxx"
 
 //=============================================================================
 //=============================================================================
@@ -60,6 +62,8 @@ HomardDriver::~HomardDriver()
 {
 }
 //===============================================================================
+// A. Generalites
+//===============================================================================
 void HomardDriver::TexteInit( const std::string DirCompute, const std::string LogFile, const std::string Langue )
 {
   MESSAGE("TexteInit, DirCompute ="<<DirCompute<<", LogFile ="<<LogFile);
@@ -105,7 +109,8 @@ void HomardDriver::TexteInfo( int TypeBila, int NumeIter )
   }
 //
 }
-
+//===============================================================================
+// B. Les maillages en entree et en sortie
 //===============================================================================
 void HomardDriver::TexteMaillage( const std::string NomMesh, const std::string MeshFile, int apres )
 {
@@ -131,6 +136,8 @@ void HomardDriver::TexteMaillageHOMARD( const std::string Dir, const std::string
   _Texte += "HOMaiN" + saux + " Mai" + liter   + " \"" + Dir + "/maill." + liter   + ".hom.med\"\n" ;
 }
 
+//===============================================================================
+// C. Le pilotage de l'adaptation
 //===============================================================================
 void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff, int TypeDera )
 {
@@ -142,6 +149,11 @@ void HomardDriver::TexteConfRaffDera( int ConfType, int TypeAdap, int TypeRaff,
   std::string saux ;
   switch (ConfType)
   {
+    case -1: //
+    {
+      saux = "conforme_boites" ;
+      break;
+    }
     case 1: //
     {
       saux = "conforme" ;
@@ -231,9 +243,9 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
 //    <0 signifie que l'on deraffinera
 //
   int ZoneTypeHOMARD ;
-  if ( ZoneType >= 11 and ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
-  else if ( ZoneType >= 31 and ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
-  else if ( ZoneType >= 61 and ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
+  if ( ZoneType >= 11 && ZoneType <= 13 ) { ZoneTypeHOMARD = 1 ; }
+  else if ( ZoneType >= 31 && ZoneType <= 33 ) { ZoneTypeHOMARD = 3 ; }
+  else if ( ZoneType >= 61 && ZoneType <= 63 ) { ZoneTypeHOMARD = 6 ; }
   else { ZoneTypeHOMARD = ZoneType ; }
 //
   if ( TypeUse < 0 ) { ZoneTypeHOMARD = -ZoneTypeHOMARD ; }
@@ -348,7 +360,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
 //
 // Cas du disque
 //
-  else if ( ZoneType == 31 or ZoneType == 61 )
+  else if ( ZoneType == 31 || ZoneType == 61 )
   {
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
@@ -371,7 +383,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
       saux += "ZoRaRayI " + saux1.str() + "\n" ;
     }
   }
-  else if ( ZoneType == 32 or ZoneType == 62 )
+  else if ( ZoneType == 32 || ZoneType == 62 )
   {
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
@@ -394,7 +406,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
       saux += "ZoRaRayI " + saux1.str() + "\n" ;
     }
   }
-  else if ( ZoneType == 33 or ZoneType == 63 )
+  else if ( ZoneType == 33 || ZoneType == 63 )
   {
     saux += "# Sphere\n" ;
     { std::stringstream saux1 ;
@@ -443,7 +455,7 @@ void HomardDriver::TexteZone( int NumeZone, int ZoneType, int TypeUse, double x0
 //
 // Cas du cylindre ou du tuyau
 //
-  else if ( ZoneType == 5 or ZoneType == 7 )
+  else if ( ZoneType == 5 || ZoneType == 7 )
   {
     if ( ZoneType == 5 ) { saux += "# Cylindre\n" ; }
     else                 { saux += "# Tuyau\n" ; }
@@ -519,6 +531,7 @@ void HomardDriver::TexteField( const std::string FieldName, const std::string Fi
       saux2 = saux1.str() ;
       _Texte += "CCNumPTI " + saux2  + "\n" ;
     }
+    if ( Rank >= 0 )
     {
       std::stringstream saux1 ;
       saux1 << Rank ;
@@ -590,6 +603,8 @@ void HomardDriver::TexteGroup( const std::string GroupName )
 //
 }
 //===============================================================================
+// D. Les frontieres
+//===============================================================================
 void HomardDriver::TexteBoundaryOption( int BoundaryOption )
 {
   MESSAGE("TexteBoundaryOption, BoundaryOption = "<<BoundaryOption);
@@ -640,8 +655,10 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
   { saux += "# Cylindre\n" ; }
   if ( BoundaryType == 2 )
   { saux += "# Sphere\n" ; }
-  if ( BoundaryType == 3 or BoundaryType == 4 )
+  if ( BoundaryType == 3 || BoundaryType == 4 )
   { saux += "# Cone\n" ; }
+  if ( BoundaryType == 5 )
+  { saux += "# Tore\n" ; }
 //
 // Le nom de la frontiere
 //
@@ -785,6 +802,45 @@ void HomardDriver::TexteBoundaryAn( const std::string NameBoundary, int NumeBoun
       saux += "FARayon2 " + saux1.str() + "\n" ;
     }
  }
+//
+// Cas du tore
+//
+  if ( BoundaryType == 5 )
+  {
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x0 ;
+      saux2 = saux1.str() ;
+      saux += "FAXCen " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x1 ;
+      saux += "FAYCen " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x2 ;
+      saux += "FAZCen " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x3 ;
+      saux += "FAXAxe " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x4 ;
+      saux += "FAYAxe " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x5 ;
+      saux += "FAZAxe " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x6 ;
+      saux += "FARayon  " + saux1.str() + "\n" ;
+    }
+    { std::stringstream saux1 ;
+      saux1 << NumeBoundary << " " << x7 ;
+      saux += "FARayon2 " + saux1.str() + "\n" ;
+    }
+ }
 //
   _Texte += saux + "#\n" ;
 //
@@ -811,52 +867,76 @@ void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBo
 //
 }
 //===============================================================================
-void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
+// E. Les interpolations
+//===============================================================================
+// Les fichiers d'entree et de sortie des champs a interpoler
+void HomardDriver::TexteFieldInterp( const std::string FieldFile, const std::string MeshFile )
 {
-  MESSAGE("TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
   MESSAGE("TexteFieldInterp, FieldFile = "<<FieldFile<<", MeshFile = "<<MeshFile);
-  MESSAGE("TexteFieldInterp, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
 //
-// Type d'interpolation
+  _Texte += "#\n# Interpolations des champs\n" ;
 //
-  _Texte += "# Interpolations des champs\n" ;
+// Fichier en entree
   _Texte += "CCSolN__ \"" + FieldFile + "\"\n" ;
+// Fichier en sortie
   _Texte += "CCSolNP1 \"" + MeshFile  + "\"\n" ;
-  if ( TypeFieldInterp == 1 )
-  {
-    _Texte += "CCChaTou oui\n" ;
-  }
-//
-  _TimeStep = TimeStep ;
-  _Rank = Rank ;
 //
 //  std::cerr << "A la fin de TexteFieldInterp _Texte ="<<_Texte << std::endl;
 }
 //===============================================================================
-void HomardDriver::TexteFieldInterpName( int NumeChamp, const std::string FieldName)
+// Tous les champs sont a interpoler
+void HomardDriver::TexteFieldInterpAll( )
+{
+  MESSAGE("TexteFieldInterpAll");
+//
+  _Texte += "CCChaTou oui\n" ;
+}
+//===============================================================================
+// Ecrit les caracteristiques de chaque interpolation sous la forme :
+//   CCChaNom 1 "DEPL"     ! Nom du 1er champ a interpoler
+//   CCChaTIn 1 0          ! Mode d'interpolation : automatique
+//   CCChaNom 2 "VOLUME"   ! Nom du 2nd champ a interpoler
+//   CCChaTIn 2 1          ! Mode d'interpolation : une variable extensive
+//   CCChaPdT 2 14         ! Pas de temps 14
+//   CCChaNuO 2 14         ! Numero d'ordre 14
+//   etc.
+//
+// NumeChamp : numero d'ordre du champ a interpoler
+// FieldName : nom du champ
+// TypeInterp : type d'interpolation
+// TimeStep : pas de temps retenu (>0 si pas de precision)
+// Rank : numero d'ordre retenu
+//
+void HomardDriver::TexteFieldInterpNameType( int NumeChamp, const std::string FieldName, const std::string TypeInterp, int TimeStep, int Rank)
 {
-  MESSAGE("TexteFieldInterpName, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName);
+  MESSAGE("TexteFieldInterpNameType, NumeChamp = "<<NumeChamp<<", FieldName = "<<FieldName<<", TypeInterp = "<<TypeInterp);
+  MESSAGE("TexteFieldInterpNameType, TimeStep = "<<TimeStep<<", Rank = "<<Rank);
+// Numero d'ordre du champ a interpoler
   std::stringstream saux1 ;
-  saux1 << NumeChamp+1 ;
+  saux1 << NumeChamp ;
   std::string saux = saux1.str() ;
+// Nom du champ
   _Texte +="CCChaNom " + saux + " \"" + FieldName + "\"\n" ;
+// Type d'interpolation pour le champ
+  _Texte +="CCChaTIn " + saux + " " + TypeInterp + "\n" ;
 //
-  MESSAGE("TexteFieldInterpName, _TimeStep = "<<_TimeStep<<", _Rank = "<<_Rank);
-  if ( _TimeStep >= 0 )
+  if ( TimeStep >= 0 )
   {
     {
       std::stringstream saux1 ;
-      saux1 << _TimeStep ;
+      saux1 << TimeStep ;
       _Texte += "CCChaPdT " + saux + " " + saux1.str()  + "\n" ;
     }
     {
       std::stringstream saux1 ;
-      saux1 << _Rank ;
+      saux1 << Rank ;
       _Texte += "CCChaNuO " + saux + " " + saux1.str()  + "\n" ;
     }
   }
 }
 //===============================================================================
+// F. Les options avancees
+//===============================================================================
 void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int AdapInit, int LevelOutput )
 {
   MESSAGE("TexteAdvanced, Pyram ="<<Pyram<<", NivMax ="<<NivMax<<", DiamMin ="<<DiamMin<<", AdapInit ="<<AdapInit<<", LevelOutput ="<<LevelOutput);
@@ -901,6 +981,8 @@ void HomardDriver::TexteAdvanced( int Pyram, int NivMax, double DiamMin, int Ada
   }
 }
 //===============================================================================
+// G. Les messages
+//===============================================================================
 void HomardDriver::TexteInfoCompute( int MessInfo )
 {
   MESSAGE("TexteAdvanced, MessInfo ="<<MessInfo);