Salome HOME
Merge from V6_main 11/02/2013
[modules/med.git] / src / MEDPartitioner / MEDPARTITIONER_MeshCollectionDriver.cxx
index c2c997d0e060d096b196ddc4ccd7113cd872f0e5..f41349581ebcd9641ca9f5ff31f4ea6932e285aa 100644 (file)
@@ -228,18 +228,18 @@ void MeshCollectionDriver::writeMedFile(int idomain, const std::string& distfile
   std::vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
   ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain);
   ParaMEDMEM::MEDCouplingUMesh* faceMesh=_collection->getFaceMesh(idomain);
-  ParaMEDMEM::MEDCouplingUMesh* faceMeshFilter=0;
+  //ParaMEDMEM::MEDCouplingUMesh* faceMeshFilter=0;
   
   std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName=");
-  std::string cleFilter=Cle1ToStr("filterFaceOnCell",idomain);
-  ParaMEDMEM::DataArrayInt* filter=0;
-  if (_collection->getMapDataArrayInt().find(cleFilter)!=_collection->getMapDataArrayInt().end())
-    {
-      filter=_collection->getMapDataArrayInt().find(cleFilter)->second;
-      int* index=filter->getPointer();
-      faceMeshFilter=(ParaMEDMEM::MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true);
-      faceMesh=faceMeshFilter;
-    }
+  // std::string cleFilter=Cle1ToStr("filterFaceOnCell",idomain);
+  // ParaMEDMEM::DataArrayInt* filter=0;
+  // if (_collection->getMapDataArrayInt().find(cleFilter)!=_collection->getMapDataArrayInt().end())
+  //   {
+  //     filter=_collection->getMapDataArrayInt().find(cleFilter)->second;
+  //     int* index=filter->getPointer();
+  //     faceMeshFilter=(ParaMEDMEM::MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true);
+  //     faceMesh=faceMeshFilter;
+  //   }
   cellMesh->setName(finalMeshName.c_str());
   meshes.push_back(cellMesh);
   
@@ -250,60 +250,45 @@ void MeshCollectionDriver::writeMedFile(int idomain, const std::string& distfile
       meshes.push_back(faceMesh);
     }
   
-  ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0;
-  if (MyGlobals::_Creates_Boundary_Faces>0)
-    {
-      //try to write Boundary meshes
-      bool keepCoords=false; //TODO or true
-      boundaryMesh=(ParaMEDMEM::MEDCouplingUMesh *) cellMesh->buildBoundaryMesh(keepCoords);
-      boundaryMesh->setName("boundaryMesh");
-    }
-  
+  //ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0;
+  // if (MyGlobals::_Creates_Boundary_Faces>0)
+  //   {
+  //     //try to write Boundary meshes
+  //     bool keepCoords=false; //TODO or true
+  //     boundaryMesh=(ParaMEDMEM::MEDCouplingUMesh *) cellMesh->buildBoundaryMesh(keepCoords);
+  //     boundaryMesh->setName("boundaryMesh");
+  //   }
+
   MEDLoader::WriteUMeshes(distfilename.c_str(), meshes, true);
-  if (faceMeshFilter!=0)
-    faceMeshFilter->decrRef();
-  
-  if (boundaryMesh!=0)
-    {
-      //doing that testMesh becomes second mesh sorted by alphabetical order of name
-      MEDLoader::WriteUMesh(distfilename.c_str(), boundaryMesh, false);
-      boundaryMesh->decrRef();
-    }
+  // if (faceMeshFilter!=0)
+  //   faceMeshFilter->decrRef();
+
+  // if (boundaryMesh!=0)
+  //   {
+  //     //doing that testMesh becomes second mesh sorted by alphabetical order of name
+  //     MEDLoader::WriteUMesh(distfilename.c_str(), boundaryMesh, false);
+  //     boundaryMesh->decrRef();
+  //   }
   ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename.c_str(), _collection->getMesh(idomain)->getName());
-  
+
   mfm->setFamilyInfo(_collection->getFamilyInfo());
   mfm->setGroupInfo(_collection->getGroupInfo());
-  
+
   std::string key=Cle1ToStr("faceFamily_toArray",idomain);
-  if (_collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
+  if ( meshes.size() == 2 &&
+      _collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
     {
       ParaMEDMEM::DataArrayInt *fam=_collection->getMapDataArrayInt().find(key)->second;
-      ParaMEDMEM::DataArrayInt *famFilter=0;
-      if (filter!=0)
-        {
-          int* index=filter->getPointer();
-          int nbTuples=filter->getNbOfElems();
-          //not the good one...buildPartOfMySelf do not exist for DataArray 
-          //Filter=fam->renumberAndReduce(index, filter->getNbOfElems());
-          famFilter=ParaMEDMEM::DataArrayInt::New();
-          famFilter->alloc(nbTuples,1);
-          int* pfamFilter=famFilter->getPointer();
-          int* pfam=fam->getPointer();
-          for (int i=0; i<nbTuples; i++)
-            pfamFilter[i]=pfam[index[i]];
-          fam=famFilter;
-          mfm->setFamilyFieldArr(-1,fam);
-          famFilter->decrRef();
-        }
+      mfm->setFamilyFieldArr(-1,fam);
     }
-  
+
   key=Cle1ToStr("cellFamily_toArray",idomain);
   if (_collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
     mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(key)->second);
-  
+
   mfm->write(distfilename.c_str(),0);
   key="/inewFieldDouble="+IntToStr(idomain)+"/";
-    
+
   std::map<std::string,ParaMEDMEM::DataArrayDouble*>::iterator it;
   int nbfFieldFound=0;
   for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++)