]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Thu, 21 Oct 2010 06:25:16 +0000 (06:25 +0000)
committerageay <ageay>
Thu, 21 Oct 2010 06:25:16 +0000 (06:25 +0000)
src/RENUMBER/Makefile.am
src/RENUMBER/RENUMBER_METISRenumbering.cxx
src/RENUMBER/renumbering.cxx
src/RENUMBER/testRenumbering.py

index 397ed5c44f7a8e8b7f5e95014976fec31fce9474..b170b2dd356cf394064d15d820b53e87a6f6ba11 100644 (file)
@@ -53,7 +53,7 @@ endif
 
 librenumber_la_CPPFLAGS= $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
        $(BOOST_CPPFLAGS) \
-       -I$(srcdir)/../MEDMEM -I$(srcdir)/../MEDWrapper/V2_1/Core -I$(srcdir)/../INTERP_KERNEL/Bases
+       -I$(srcdir)/../MEDMEM -I$(srcdir)/../INTERP_KERNEL/Bases
 
 librenumber_la_LDFLAGS= 
 #libmedsplitter_la_LDFLAGS= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) \
@@ -73,7 +73,7 @@ if MED_ENABLE_KERNEL
 endif
 
 librenumber_la_LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) \
-       ../MEDMEM/libmedmem.la ../MEDWrapper/V2_1/Core/libmed_V2_1.la  ../INTERP_KERNEL/libinterpkernel.la
+       ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la
 
 # Executables targets
 bin_PROGRAMS= renumber
index e5c3535b9340c0331b5e19fe82b80dcd6c335885..3a98fdf0c0ff983c79da8166b50e2e6aebec5be8 100644 (file)
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#ifdef ENABLE_PARMETIS
-// include parmetis.h even if it is not needed here
-// to avoid inclusion of c++ definitions within extern "C"
-// from metis.h from parmetis.h from mpi.h(openmpi) from mpicxx.h
-#include <parmetis.h>
-#endif
 extern "C"
 {
 #include "metis.h"
index c060039516facf77d30a4256fa12199d3bd0b56b..d5ef000c780bae9971cfadb1c44b316fcaac926a 100644 (file)
@@ -29,8 +29,7 @@
 #include "MEDMEM_Connectivity.hxx"
 #include "MEDMEM_Field.hxx"
 #include "MEDMEM_DriversDef.hxx"
-#include "MEDMEM_Med.hxx"
-#include "MEDMEM_MedMeshDriver22.hxx"
+#include "MEDMEM_MedFileBrowser.hxx"
 
 #include "RenumberingFactory.hxx"
 
@@ -40,15 +39,18 @@ using namespace std;
 using namespace MED_EN;
 using namespace MED_RENUMBER;
 
+namespace
+{
+
 void computeNeighbour(const MESH* mesh,const medGeometryElement& Type, vector<list<int> >& neighbour, int& ntot,int& nb_cell)
 {
   CONNECTIVITY* conn = (CONNECTIVITY*)mesh->getConnectivityptr();
   conn->calculateFullDescendingConnectivity(MED_CELL);
   const int* rev_conn=mesh->getReverseConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL);
   const int* rev_conn_index=mesh->getReverseConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL);
-  int nb_face= mesh->getNumberOfElementsWithPoly(MED_FACE,MED_ALL_ELEMENTS);
-  int nb_edge = mesh->getNumberOfElementsWithPoly(MED_EDGE,MED_ALL_ELEMENTS);
-  nb_cell= mesh->getNumberOfElementsWithPoly(MED_CELL,Type);
+  int nb_face= mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
+  int nb_edge = mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS);
+  nb_cell= mesh->getNumberOfElements(MED_CELL,Type);
 
   int nb_constituent;
   if(mesh->getMeshDimension()==2)
@@ -79,74 +81,8 @@ void computeNeighbour(const MESH* mesh,const medGeometryElement& Type, vector<li
 
 void changeConnectivity(MESH& mesh, const medGeometryElement& Type, const int& nb_cell, const vector<int>& iperm)
 {
-  if(Type==MED_POLYHEDRA)
     {
-      int *conn_face_index_init=(int*)mesh.getPolyhedronFacesIndex();
-      int *conn_index_init=(int*)mesh.getPolyhedronIndex(MED_FULL_INTERLACE);
-      int *conn_init=(int*)mesh.getPolyhedronConnectivity(MED_FULL_INTERLACE);
-
-      int *conn_index_renum=new int[nb_cell+1];
-      int *conn_face_index_renum=new int[conn_index_init[nb_cell]];
-      int *conn_renum=new int[conn_face_index_init[conn_index_init[nb_cell]-1]-1];
-
-      int i_cell,i_face,i_conn;
-      int iter_face=0;
-      int iter_conn=0;
-      int i2;
-      conn_index_renum[0]=1;
-      conn_face_index_renum[0]=1;
-      for(i_cell=0;i_cell<nb_cell;++i_cell)
-        {
-          i2=iperm[i_cell]-1;
-          for(i_face=conn_index_init[i2]-1;i_face<conn_index_init[i2+1]-1;++i_face)
-            {
-              for(i_conn=conn_face_index_init[i_face]-1;i_conn<conn_face_index_init[i_face+1]-1;++i_conn)
-                {
-                  conn_renum[iter_conn]=conn_init[i_conn];
-                  ++iter_conn;
-                }
-              conn_face_index_renum[iter_face+1]=iter_conn+1;
-              ++iter_face;
-            }
-          conn_index_renum[i_cell+1]=iter_face+1;
-        }
-      memcpy(conn_face_index_init,conn_face_index_renum,sizeof(int)*conn_index_init[nb_cell]);
-      memcpy(conn_index_init,conn_index_renum,sizeof(int)*(nb_cell+1));
-      memcpy(conn_init,conn_renum, sizeof(int)*(conn_face_index_init[conn_index_init[nb_cell]-1]-1));
-
-      delete[] conn_index_renum;
-      delete[] conn_face_index_renum;
-      delete[] conn_renum;
-    }
-  else if (Type==MED_POLYGON)
-    {
-      int *conn_init=(int*)mesh.getPolygonsConnectivity(MED_FULL_INTERLACE,MED_CELL);
-      int *conn_index_init=(int*)mesh.getPolygonsConnectivityIndex(MED_FULL_INTERLACE,MED_CELL);
-      int *conn_index_renum=new int[nb_cell+1];
-      int *conn_renum=new int[conn_index_init[nb_cell]-1];
-
-      int iter=0;
-      int i2;
-      conn_index_renum[0]=1;
-      for(int i=0;i<nb_cell;++i)
-        {
-          i2=iperm[i]-1;
-          for(int k=conn_index_init[i2];k<conn_index_init[i2+1];++k)
-            {
-              conn_renum[iter]=conn_init[k-1];
-              ++iter;
-            }
-          conn_index_renum[i+1]=iter+1;
-        }
-      memcpy(conn_index_init,conn_index_renum,sizeof(int)*(nb_cell+1));
-      memcpy(conn_init,conn_renum, sizeof(int)*(conn_index_init[nb_cell]-1));
-
-      delete[] conn_renum;
-      delete[] conn_index_renum;
-    }
-  else
-    {
-      const int *conn_init=mesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Type);
+      const int *conn_init=mesh.getConnectivity(MED_NODAL,MED_CELL,Type);
       const int *conn_index_init=mesh.getConnectivityIndex(MED_NODAL,MED_CELL);
       int *conn_renum=new int[conn_index_init[nb_cell]-1];
       int *conn_index_renum=new int[nb_cell+1];
@@ -166,7 +102,7 @@ void changeConnectivity(MESH& mesh, const medGeometryElement& Type, const int& n
         }
 
       CONNECTIVITY* myConnectivity=(CONNECTIVITY*)mesh.getConnectivityptr();
-      myConnectivity->setNodal(conn_renum,MED_CELL,Type);
+      myConnectivity->setNodal(conn_renum,MED_CELL,Type,conn_index_renum);
       delete[] conn_renum;
       delete[] conn_index_renum;
     }
@@ -187,6 +123,7 @@ void changeFamily(MESH* mesh, const medGeometryElement& Type, const vector<int>&
         }
     }
 }
+} // namespace
 
 int main (int argc, char** argv)
 {
@@ -213,64 +150,35 @@ int main (int argc, char** argv)
   system(s.c_str());
 
   // Reading file structure
-  const MED med_struct (MED_DRIVER,filename_in);
-  int nb_mesh, nb_fields;
-  deque<string> mesh_names,f_names;
-  nb_mesh=med_struct.getNumberOfMeshes();
-  nb_fields=med_struct.getNumberOfFields();
-  mesh_names=med_struct.getMeshNames();
-  f_names=med_struct.getFieldNames();
-  if(nb_mesh!=1)
+  const MEDFILEBROWSER med_struct (filename_in);
+  if(med_struct.getNumberOfMeshes()!=1)
     {
       cout << "There are many meshes in the file" << endl;
       return -1;
     }
-  if(mesh_names[0].c_str()!=meshname)
+  if(med_struct.getMeshNames()[0]!=meshname)
     {
       cout << "Mesh name does not match" << endl;
       return -1;
     }
-  vector<string> field_names;
-  vector<int> iternumber;
-  vector<int> ordernumber;
-  vector<int> types;
-  int nb_fields_tot=0;
-  for (int ifield = 0; ifield < nb_fields; ifield++)
-    {
-      deque<DT_IT_> dtit=med_struct.getFieldIteration(f_names[ifield]);
-      for (deque<DT_IT_>::const_iterator iter =dtit.begin(); iter!=dtit.end(); iter++)
-        {
-          field_names.push_back(f_names[ifield]);
-          iternumber.push_back(iter->dt);
-          ordernumber.push_back(iter->it);
-          ++nb_fields_tot;
-          FIELD_* field = med_struct.getField(f_names[ifield],iter->dt,iter->it);
-          if (dynamic_cast<FIELD<double>*>(field))
-            types.push_back(1);
-          else
-            types.push_back(0);
-
-        }
-    }
   t_read_st=clock();
 
   // Reading mesh
   MESH myMesh;
   myMesh.setName(meshname);
-  MED_MESH_RDONLY_DRIVER22 *drv22=new MED_MESH_RDONLY_DRIVER22(filename_in,&myMesh);
+  MED_MESH_RDONLY_DRIVER *drv22=new MED_MESH_RDONLY_DRIVER(filename_in,&myMesh);
   drv22->desactivateFacesComputation();
   int newDrv=myMesh.addDriver(*drv22);
   delete drv22;
   myMesh.read(newDrv);
-  int nb_type=myMesh.getNumberOfTypesWithPoly(MED_CELL);
+  int nb_type=myMesh.getNumberOfTypes(MED_CELL);
   if (nb_type!=1)
     {
       cout << "Mesh must have only one type of cell" << endl;
       return -1;
     }
-  medGeometryElement *Types = myMesh.getTypesWithPoly(MED_CELL);
+  const medGeometryElement *Types = myMesh.getTypes(MED_CELL);
   medGeometryElement Type=Types[0];
-  delete[] Types;
 
   t_read_mesh=clock();
   MESH* workMesh=new MESH(myMesh);
@@ -327,33 +235,38 @@ int main (int argc, char** argv)
   cout << "Computing fields      ";
   cout.flush();
   bool exist_type;
-  for(int ifield=0;ifield<nb_fields_tot;++ifield)
+  vector<string> field_names = med_struct.getFieldNames();
+  for(unsigned ifield=0;ifield<field_names.size();++ifield)
     {
-      exist_type=false;
-      FIELD<double> myField(MED_DRIVER,filename_in,field_names[ifield],iternumber[ifield],ordernumber[ifield]);
-      FIELD<double> newField(myField);
-      const SUPPORT* mySupport=newField.getSupport();
-      const medGeometryElement *typesOfSupport = mySupport->getTypes();
-      for(int t=0;t<mySupport->getNumberOfTypes();++t)
+      VEC_DT_IT_ dtit = med_struct.getFieldIteration( field_names[ifield]);
+      for ( unsigned i = 0; i < dtit.size(); ++i )
         {
-          if(typesOfSupport[t]==Type)
+          exist_type=false;
+          FIELD<double> myField(MED_DRIVER,filename_in,field_names[ifield],dtit[i].dt,dtit[i].it);
+          FIELD<double> newField(myField);
+          const SUPPORT* mySupport=newField.getSupport();
+          const medGeometryElement *typesOfSupport = mySupport->getTypes();
+          for(int t=0;t<mySupport->getNumberOfTypes();++t)
             {
-              exist_type=true;
-              break;
+              if(typesOfSupport[t]==Type)
+                {
+                  exist_type=true;
+                  break;
+                }
             }
-        }
-      if(exist_type)
-        {
-          for(int i=0;i<mySupport->getNumberOfElements(Type);++i)
+          if(exist_type)
             {
-              for(int j=0;j<newField.getNumberOfComponents();++j)
+              for(int i=0;i<mySupport->getNumberOfElements(Type);++i)
                 {
-                  newField.setValueIJ(i+1,j+1,myField.getValueIJ(iperm[i],j+1));
+                  for(int j=0;j<newField.getNumberOfComponents();++j)
+                    {
+                      newField.setValueIJ(i+1,j+1,myField.getValueIJ(iperm[i],j+1));
+                    }
                 }
             }
+          int drv=newField.addDriver(MED_DRIVER,filename_out,field_names[ifield]);
+          newField.write(drv);
         }
-      int drv=newField.addDriver(MED_DRIVER,filename_out,field_names[ifield]);
-      newField.write(drv);
     }
   t_field=clock();
   cout << " : " << (t_field-t_family)/(double) CLOCKS_PER_SEC << "s" << endl;
index 3f2ecba5cd628681e1711805027387c10217e691..f075ce8267872a195f339b9d32c2ab0de55a973e 100755 (executable)
@@ -64,7 +64,7 @@ f.rmDriver(id)
 nbcell2dboost=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
 connectivite=[2,6,13,11,11,13,14,12,6,5,15,13,12,14,10,4,13,15,16,14,5,1,7,15,14,16,9,10,15,7,8,16,16,8,3,9]
 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
-conn=m.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_QUAD4)
+conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_QUAD4)
 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
 conn2dboost=(len(conn)==len(connectivite))
 if conn2dboost:
@@ -86,7 +86,7 @@ m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
 nbcell2dmetis=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
 connectivite=[12,14,10,4,2,6,13,11,11,13,14,12,16,8,3,9,5,1,7,15,15,7,8,16,14,16,9,10,6,5,15,13,13,15,16,14]
 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
-conn=m.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_QUAD4)
+conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_QUAD4)
 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
 conn2dmetis=(len(conn)==len(connectivite))
 if conn2dmetis:
@@ -113,8 +113,8 @@ m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
 nbcell2dpolyboost=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
 connectivite=[2,5,9,10,11,10,9,12,5,6,8,9,4,11,12,16,12,9,8,13,6,1,7,8,16,12,13,15,13,8,7,14,15,13,14,3]
 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
-conn=m.getPolygonsConnectivity(MED_FULL_INTERLACE,MED_CELL)
-conn_index=m.getPolygonsConnectivityIndex(MED_FULL_INTERLACE,MED_CELL);
+conn=m.getPolygonsConnectivity(MED_CELL)
+conn_index=m.getPolygonsConnectivityIndex(MED_CELL);
 conn2dpolyboost=(len(conn)==len(connectivite))
 if conn2dpolyboost:
     for i in range(0,len(connectivite)):
@@ -134,8 +134,8 @@ m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
 nbcell2dpolymetis=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
 connectivite=[6,1,7,8,2,5,9,10,5,6,8,9,15,13,14,3,4,11,12,16,16,12,13,15,11,10,9,12,12,9,8,13,13,8,7,14]
 connectivite_index=[1,5,9,13,17,21,25,29,33,37]
-conn=m.getPolygonsConnectivity(MED_FULL_INTERLACE,MED_CELL)
-conn_index=m.getPolygonsConnectivityIndex(MED_FULL_INTERLACE,MED_CELL);
+conn=m.getPolygonsConnectivity(MED_CELL)
+conn_index=m.getPolygonsConnectivityIndex(MED_CELL);
 conn2dpolymetis=(len(conn)==len(connectivite))
 if conn2dpolymetis:
     for i in range(0,len(connectivite)):
@@ -165,7 +165,7 @@ m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
 nbcell3dboost=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
 connectivite=[23,13,5,18,27,22,14,26,17,6,13,23,25,16,22,27,27,22,14,26,24,15,7,20,9,23,18,1,21,27,26,10,25,16,22,27,19,8,15,24,2,17,23,9,12,25,27,21,21,27,26,10,11,24,20,3,12,25,27,21,4,19,24,11]
 connectivite_index=[1,9,17,25,33,41,49,57,65]
-conn=m.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_HEXA8)
+conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_HEXA8)
 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
 conn3dboost=(len(conn)==len(connectivite))
 if conn3dboost:
@@ -187,7 +187,7 @@ m = MESH(MED_DRIVER,dir_mesh+"/out_"+filename,meshname)
 nbcell3dmetis=m.getNumberOfElementsWithPoly(MED_CELL,MED_ALL_ELEMENTS)
 connectivite=[12,25,27,21,4,19,24,11,27,22,14,26,24,15,7,20,17,6,13,23,25,16,22,27,9,23,18,1,21,27,26,10,23,13,5,18,27,22,14,26,25,16,22,27,19,8,15,24,2,17,23,9,12,25,27,21,21,27,26,10,11,24,20,3]
 connectivite_index=[1,9,17,25,33,41,49,57,65]
-conn=m.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_HEXA8)
+conn=m.getConnectivity(MED_NODAL,MED_CELL,MED_HEXA8)
 conn_index=m.getConnectivityIndex(MED_NODAL,MED_CELL);
 conn3dmetis=(len(conn)==len(connectivite))
 if conn3dmetis: