Salome HOME
Fixes by Gérald NICOLAS
authorgdd <gdd>
Tue, 3 May 2011 16:30:50 +0000 (16:30 +0000)
committergdd <gdd>
Tue, 3 May 2011 16:30:50 +0000 (16:30 +0000)
Fix by Gilles DAVID (Python Dump)

src/HOMARD/HomardDriver.cxx
src/HOMARD/HomardDriver.hxx
src/HOMARD_I/HOMARD_Gen_i.cxx
src/HOMARD_I/HOMARD_Gen_i.hxx
tests/test_1.00.med
tests/test_1.01.med
tests/test_1.02.med
tests/test_2.00.med
tests/test_2.fr.med
tests/test_3.00.med
tests/test_3.fr.med

index da93013337f220e83b85efdc2cf01566ca6df0b9..caaa95b3dbe70e9b2bf37808fda890eb21bd798c 100644 (file)
@@ -342,27 +342,34 @@ void HomardDriver::TexteBoundaryOption( int BoundaryOption )
 //
 }
 ////=============================================================================
-void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile, const std::string GroupName )
+void HomardDriver::TexteBoundaryDi(  const std::string MeshName, const std::string MeshFile )
 {
   MESSAGE("Dans HomardDriver::TexteBoundaryDi, MeshName  = "<<MeshName);
   MESSAGE("Dans HomardDriver::TexteBoundaryDi, MeshFile  = "<<MeshFile);
-  MESSAGE("Dans HomardDriver::TexteBoundaryDi, GroupName = "<<GroupName);
 //
   _Texte += "CCNoMFro " + MeshName + "\n" ;
   _Texte += "CCFronti " + MeshFile + "\n" ;
-  if ( GroupName.size() > 0 ) _Texte += "CCGroFro " + GroupName + "\n" ;
 //
 }
 ////=============================================================================
-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 )
+void HomardDriver::TexteBoundaryDiGr(  const std::string GroupName )
 {
+  MESSAGE("Dans HomardDriver::TexteBoundaryDiGr, GroupName  = "<<GroupName);
+//
+  _Texte += "CCGroFro " + GroupName + "\n" ;
+//
+}
+////=============================================================================
+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 )
+{
+  MESSAGE("Dans HomardDriver::TexteBoundaryAn, NameBoundary = "<<NameBoundary);
   MESSAGE("Dans HomardDriver::TexteBoundaryAn, NumeBoundary = "<<NumeBoundary);
   MESSAGE("Dans HomardDriver::TexteBoundaryAn, BoundaryType = "<<BoundaryType);
   MESSAGE("Dans HomardDriver::TexteBoundaryAn, coor         = "<< x0<<","<<x1<< ","<< x2<< ","<< x3<<","<<x4<<","<<x5<<","<<x6);
 //
   std::string saux, saux2 ;
 //
-// Type de zones
+// Commentaires
 //
   std::stringstream saux1 ;
   saux1 << NumeBoundary ;
@@ -372,19 +379,21 @@ void HomardDriver::TexteBoundaryAn( int NumeBoundary, int BoundaryType, const st
   { saux += "# Cylindre\n" ; }
   if ( BoundaryType == 2 )
   { saux += "# Sphere\n" ; }
+//
+// Le nom de la frontiere
 //
   { std::stringstream saux1 ;
-    saux1 << NumeBoundary << " " << BoundaryType ;
+    saux1 << NumeBoundary ;
     saux2 = saux1.str() ;
-    saux += "FAType " + saux2 + "\n" ;
+    saux += "FANom " + saux2 + " '" + NameBoundary + "'\n" ;
   }
 //
-// Le groupe
+// Type de frontiere
 //
   { std::stringstream saux1 ;
-    saux1 << NumeBoundary ;
+    saux1 << NumeBoundary << " " << BoundaryType ;
     saux2 = saux1.str() ;
-    saux += "FAGroupe " + saux2 + " '" + Group + "'\n" ;
+    saux += "FAType " + saux2 + "\n" ;
   }
 //
 // Cas du cylindre
@@ -458,6 +467,27 @@ void HomardDriver::TexteBoundaryAn( int NumeBoundary, int BoundaryType, const st
 //
 }
 ////=============================================================================
+void HomardDriver::TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName )
+{
+  MESSAGE("Dans HomardDriver::TexteBoundaryAnGr, NameBoundary  = "<<NameBoundary);
+  MESSAGE("Dans HomardDriver::TexteBoundaryAnGr, NumeBoundary  = "<<NumeBoundary);
+  MESSAGE("Dans HomardDriver::TexteBoundaryAnGr, GroupName  = "<<GroupName);
+//
+// Commentaires
+//
+  std::string saux, saux2 ;
+  std::stringstream saux1 ;
+  saux1 << NumeBoundary ;
+  saux2 = saux1.str() ;
+  saux = "#\n# Lien Frontiere/Groupe numero " + saux2 + "\n" ;
+//
+  saux += "FGNomFro " + saux2 + " '" + NameBoundary + "'\n" ;
+  saux += "FGNomGro " + saux2 + " '" + GroupName + "'\n" ;
+//
+  _Texte += saux + "#\n" ;
+//
+}
+////=============================================================================
 void HomardDriver::TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile, int TimeStep, int Rank )
 {
   MESSAGE("Dans HomardDriver::TexteFieldInterp, TypeFieldInterp = "<<TypeFieldInterp);
index 2058e3a651298667816f916cc0c6084fcaf722b9..00b1ee3cbc879ba7a72a5d80ba3526ca68b6f2c4 100644 (file)
@@ -22,8 +22,10 @@ public:
   void        TexteCompo( int NumeComp, const std::string NomCompo);
 
   void        TexteBoundaryOption( int BoundaryOption );
-  void        TexteBoundaryDi( const std::string MeshName, const std::string MeshFile, const std::string GroupName );
-  void        TexteBoundaryAn( int NumeBoundary, int BoundaryType, const std::string Group, double x0, double x1, double x2, double x3, double x4, double x5, double x6 );
+  void        TexteBoundaryDi( const std::string MeshName, const std::string MeshFile );
+  void        TexteBoundaryDiGr( const std::string GroupName );
+  void        TexteBoundaryAn( const std::string NameBoundary, int NumeBoundary, int BoundaryType, double x0, double x1, double x2, double x3, double x4, double x5, double x6 );
+  void        TexteBoundaryAnGr( const std::string NameBoundary, int NumeBoundary, const std::string GroupName );
 
   void        TexteFieldInterp( int TypeFieldInterp, const std::string FieldFile, const std::string MeshFile,
                                 int TimeStep, int Rank );
index 904968527ebbe8810de356fbaabce649b64bab20..e1ba138efbd181e6e20a679b389c99c31af8f67f 100755 (executable)
 
 using  namespace std;
 
+//=======================================================================
+//function : RemoveTabulation
+//purpose  : 
+//=======================================================================
+std::string RemoveTabulation( std::string theScript )
+{
+  std::string::size_type aPos = 0;
+  while( aPos < theScript.length() )
+  {
+    aPos = theScript.find( "\n\t", aPos );
+    if( aPos == std::string::npos )
+      break;
+    theScript.replace( aPos, 2, "\n" );
+    aPos++;
+  }
+  return theScript;
+}
+      
 //=============================================================================
 /*!
  *  standard constructor
@@ -1197,12 +1215,81 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
   }
 
   // E.5. Ajout des informations liees a l'eventuel suivi de frontiere
+  // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
+  std::list<std::string>  ListeBoundaryTraitees ;
   HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
   int numberOfitems = ListBoundaryGroupType->length();
   MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
   int BoundaryOption = 1 ;
   int NumBoundaryAnalytical = 0 ;
   for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
+  {
+    std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
+    MESSAGE ( "... BoundaryName = " << BoundaryName);
+    int A_faire = 1 ;
+    std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
+    while (it != ListeBoundaryTraitees.end())
+    {
+      MESSAGE ( "... BoundaryNameTraitee = " << *it);
+      if ( BoundaryName == *it ) { A_faire = 0 ; }
+      it++;
+    }
+    if ( A_faire == 1 )
+    {
+// Caracteristiques de la frontiere
+      HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
+      ASSERT(!CORBA::is_nil(myBoundary));
+      int BoundaryType = myBoundary->GetBoundaryType();
+      MESSAGE ( "... BoundaryType = " << BoundaryType );
+// Ecriture selon le type
+      if (BoundaryType == 0) // Cas d une frontiere discrete
+      {
+        const char* MeshName = myBoundary->GetMeshName() ;
+        const char* MeshFile = myBoundary->GetMeshFile() ;
+        myDriver->TexteBoundaryDi( MeshName, MeshFile);
+        BoundaryOption = BoundaryOption*2 ;
+      }
+      else if (BoundaryType == 1) // Cas d un cylindre
+      {
+        NumBoundaryAnalytical++ ;
+        HOMARD::double_array* coor = myBoundary->GetCylinder();
+        myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6]);
+        BoundaryOption = BoundaryOption*3 ;
+      }
+      else if (BoundaryType == 2) // Cas d une sphere
+      {
+        NumBoundaryAnalytical++ ;
+        HOMARD::double_array* coor = myBoundary->GetSphere();
+        myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0.);
+        BoundaryOption = BoundaryOption*3 ;
+      }
+// Memorisation du traitement
+      ListeBoundaryTraitees.push_back( BoundaryName );
+    }
+  }
+  NumBoundaryAnalytical = 0 ;
+  for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
+  {
+    std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
+    MESSAGE ( "... BoundaryName = " << BoundaryName);
+    HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
+    ASSERT(!CORBA::is_nil(myBoundary));
+    int BoundaryType = myBoundary->GetBoundaryType();
+    MESSAGE ( "... BoundaryType = " << BoundaryType );
+//  Recuperation du nom du groupe
+    std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
+    MESSAGE ( "... GroupName = " << GroupName);
+    if (BoundaryType == 0) // Cas d une frontiere discrete
+    {
+      if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
+    }
+    else // Cas d une frontiere analytique
+    {
+      NumBoundaryAnalytical++ ;
+      myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
+    }
+  }
+/*  for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
   {
     std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
     MESSAGE ( "... BoundaryName = " << BoundaryName);
@@ -1234,7 +1321,7 @@ CORBA::Boolean HOMARD_Gen_i::Compute(const char* nomIteration, CORBA::Long etatM
       myDriver->TexteBoundaryAn(NumBoundaryAnalytical, BoundaryType, GroupName, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0.);
       BoundaryOption = BoundaryOption*3 ;
     }
-  }
+  }*/
   myDriver->TexteBoundaryOption(BoundaryOption);
 
   // E.6. Ajout des informations liees a l'eventuelle interpolation des champs
@@ -2352,6 +2439,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
 //==========================================================================
 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
                                        CORBA::Boolean isPublished,
+                                       CORBA::Boolean isMultiFile,
                                        CORBA::Boolean& isValidScript)
 {
    MESSAGE ("Entree dans DumpPython");
@@ -2370,10 +2458,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
    aScript += "\"\"\"\n";
    aScript += "__revision__ = \"V1.2\"\n";
    aScript += "import HOMARD\n";
-   aScript += "import salome\n";
+   if( isMultiFile )
+      aScript += "import salome\n";
    aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
-   aScript += "def RebuildData(theStudy):\n";
-   aScript += "\thomard.SetCurrentStudy(theStudy)\n";
+   if( isMultiFile ) {
+      aScript += "def RebuildData(theStudy):\n";
+      aScript += "\thomard.SetCurrentStudy(theStudy)\n";
+   }
+   else
+      aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
 
 
    if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
@@ -2461,8 +2554,14 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
     std::string dumpIter = dumpCorbaIter.in();
     aScript+=dumpIter;
    }
-
-
+   
+    if( isMultiFile )
+      aScript += "\n\tpass";
+    aScript += "\n";
+
+    if( !isMultiFile ) // remove unnecessary tabulation
+      aScript = RemoveTabulation( aScript );
+    
    const size_t aLen = strlen(aScript.c_str());
    char* aBuffer = new char[aLen+1];
    strcpy(aBuffer, aScript.c_str());
index 6f44d12b3fb48a6488ce40b55a25a441f696408c..cac1cefe0e8261756d75de9c94587fb6f83ebceb 100644 (file)
@@ -164,6 +164,7 @@ private:
 
   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
                                        CORBA::Boolean isPublished,
+                                       CORBA::Boolean isMultiFile,
                                        CORBA::Boolean& isValidScript);
 
 
index 767d4f62247468d3c7f1d2cfd52c5e96e66a6089..316e14050d754d42c8730519febf8b27a25e4c31 100644 (file)
Binary files a/tests/test_1.00.med and b/tests/test_1.00.med differ
index 91d7fb34bbe958237b8879e3e1c2c3c814fc24ed..661ce2318de22e2d90edbbe4e9f04c47f660e412 100644 (file)
Binary files a/tests/test_1.01.med and b/tests/test_1.01.med differ
index 4e94dcdd0af04c636bac25ccb2aac39ffc334dbd..1a9688c14bf74071b709a0673dd5c67b875cfb2a 100644 (file)
Binary files a/tests/test_1.02.med and b/tests/test_1.02.med differ
index 05e3849b89285c6543707c81a6a77dc8e0eafe19..b4ada0fe318f08b18780453432dd5aa8d98f47f1 100644 (file)
Binary files a/tests/test_2.00.med and b/tests/test_2.00.med differ
index 48ceb7d05a5c08266f5f816c948a4adc0883851f..33315ed5eff5506f08d214ee1c407ce653200950 100644 (file)
Binary files a/tests/test_2.fr.med and b/tests/test_2.fr.med differ
index 0b41f32825a499167891ccb9d6b6d5ed33a31c20..c76b750e987b85ada88f0a2dfcbae2112d7d694d 100644 (file)
Binary files a/tests/test_3.00.med and b/tests/test_3.00.med differ
index 657ab6d2fb9b0fc20629f81fd8c1343227f40318..99b15ca64b513a7d89be91eb4b7091da6697a671 100644 (file)
Binary files a/tests/test_3.fr.med and b/tests/test_3.fr.med differ