The Higher Education and Research forge

Home My Page Projects Code Snippets Project Openings MMD
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

authorAlain <alain.bastide@univ-reunion.fr>
Wed, 24 Jun 2020 14:06:44 +0000 (18:06 +0400)
committerAlain <alain.bastide@univ-reunion.fr>
Sun, 28 Jun 2020 02:58:45 +0000 (06:58 +0400)
CMakeLists.txt
src/main.c
src/mmd.h

index 68597e4..531fe31 100644 (file)
@@ -9,14 +9,19 @@ if(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Release)
 endif()
 
-set(CMAKE_C_FLAGS "-Wall -Wextra")
+set(CMAKE_C_FLAGS "-Wall -Wextra -Wabi")
 set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG -march=skylake     -mtune=skylake")
 set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -march=skylake         -mtune=skylake")
 
-if(CMAKE_BUILD_TYPE EQUAL "DEBUGRelease")
+if(CMAKE_BUILD_TYPE EQUAL "Debug")
     set(CMAKE_C_FLAGS_RELEASE "-g -DNDEBUG -march=skylake      -mtune=skylake")
 endif()
 
+
+if(CMAKE_BUILD_TYPE EQUAL "Release")
+    set(CMAKE_C_FLAGS_RELEASE "-03 -march=skylake      -mtune=skylake")
+endif()
+
 #OptimizeForArchitecture()
 
 set (VTK_DIR "/usr/include/vtk-7.1")
index 8a52fd6..fc5ac56 100644 (file)
@@ -21,7 +21,10 @@ connectivity_int  hexaedron_localNodeListNumbers[HEXAHEDRON_FACES]={ \
   QUAD \
 };
 
-
+#define PT1 0
+#define PT2 1
+#define CELL1 0
+#define CELL2 1
 
 connectivity_int  hexaedron_localSegmentList[HEXAHEDRON_SEGMENTS][SEGMENTVERTEX]={ \
   {0,1}, \
@@ -729,6 +732,31 @@ void freeMemory(struct primalMesh * myPrimalMesh)
       free(myPrimalMesh->faceToCells);
     }
   
+  if(myPrimalMesh->cellToSegmentOwner!=NULL)
+    {
+      for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+        free(myPrimalMesh->cellToSegmentOwner[celli]);
+      free(myPrimalMesh->cellToSegmentOwner);  
+    }
+  
+  if(myPrimalMesh->cellToSegmentNeighbour!=NULL)
+    {
+      for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+        free(myPrimalMesh->cellToSegmentNeighbour[celli]);
+      free(myPrimalMesh->cellToSegmentNeighbour);  
+    }
+  
+  if(myPrimalMesh->cellToSegmentOwnerNumber!=NULL)
+    {
+      free(myPrimalMesh->cellToSegmentOwnerNumber);  
+    }
+  
+  if(myPrimalMesh->cellToSegmentNeighbourNumber!=NULL)
+    {
+      free(myPrimalMesh->cellToSegmentNeighbourNumber); 
+    }
+  
+  
   endFunction(__FUNCTION__, t);
   
 }
@@ -1452,7 +1480,7 @@ void setHexahedreCellToFacesOwnerNeighbour(struct primalMesh * myPrimalMesh)
   
   for(connectivity_int cellAi=0;cellAi<myPrimalMesh->cellNumber;cellAi++)
     {
-      if(cellAi % 1000 == 0 && cellAi != 0)
+      if(cellAi % 10000 == 0 && cellAi != 0)
         release_print( "%-40s :  (%ld)\n ","CELLS", cellAi);
       
       for (connectivity_int faceAi=0;faceAi<HEXAHEDRON_FACES;faceAi++)
@@ -1697,7 +1725,197 @@ void setHexahedreSegments(struct primalMesh * myPrimalMesh)
   
   clock_t t=startFunction(__FUNCTION__);
   affiche("\n");
-  affiche("%s : REFAIRE CETTE FONCTION EN UTILISANT CELLTOFACE PUIS REDUIRE LA RECHERCHE DANS SEGMENTS EN INTRODUISANT PAR EXEMPLE CELLTOSEGMENTS\n",__FUNCTION__);
+  //  affiche("%s : REFAIRE CETTE FONCTION EN UTILISANT CELLTOFACE PUIS REDUIRE LA RECHERCHE DANS SEGMENTS EN INTRODUISANT PAR EXEMPLE CELLTOSEGMENTS\n",__FUNCTION__);
+  
+  connectivity_int * vertexList         = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+  connectivity_int * vertexListInverted = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+  connectivity_int * copyFace           = (connectivity_int * ) malloc(sizeof (connectivity_int)*(QUAD+1));
+  
+  connectivity_int testSegment = 0;
+  
+  myPrimalMesh->segments  = (connectivity_int ** ) realloc(myPrimalMesh->segments, sizeof (connectivity_int*)*(0));
+  
+  /// MODIF
+  
+  char ** cellSegmentTest  = (char ** ) malloc(sizeof (char*)*myPrimalMesh->cellNumber);
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      cellSegmentTest[celli]  = (char * ) malloc(sizeof (char)*HEXAHEDRON_SEGMENTS);
+      memset(cellSegmentTest[celli],0,sizeof (char)*HEXAHEDRON_SEGMENTS);
+    }
+  
+  myPrimalMesh->cellToSegmentOwner  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->cellNumber);
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      myPrimalMesh->cellToSegmentOwner[celli]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*0);
+    }
+  
+  myPrimalMesh->cellToSegmentOwnerNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
+  memset(myPrimalMesh->cellToSegmentOwnerNumber, 0, myPrimalMesh->cellNumber*sizeof(connectivity_int));
+  
+  myPrimalMesh->cellToSegmentNeighbour  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->cellNumber);
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      myPrimalMesh->cellToSegmentNeighbour[celli]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*0);
+    }
+  
+  myPrimalMesh->cellToSegmentNeighbourNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
+  memset(myPrimalMesh->cellToSegmentNeighbourNumber, 0, myPrimalMesh->cellNumber*sizeof(connectivity_int));
+  
+  /// MODIF
+  for (connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      for (connectivity_int segmentAi=0;segmentAi<HEXAHEDRON_SEGMENTS;segmentAi++)
+        { 
+          if(cellSegmentTest[celli][segmentAi] ==0)
+            {
+              connectivity_int localPointA1 = hexaedron_localSegmentList[segmentAi][PT1];
+              connectivity_int localPointA2 = hexaedron_localSegmentList[segmentAi][PT2];
+              
+              cellSegmentTest[celli][segmentAi] = 1;
+              
+              myPrimalMesh->segments  = (connectivity_int ** ) realloc(myPrimalMesh->segments, sizeof (connectivity_int*)*(myPrimalMesh->segmentNumber+1));
+              myPrimalMesh->segments[myPrimalMesh->segmentNumber]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+              
+              myPrimalMesh->segments[myPrimalMesh->segmentNumber][PT1] = myPrimalMesh->cellToVertex[celli][localPointA1];
+              myPrimalMesh->segments[myPrimalMesh->segmentNumber][PT2] = myPrimalMesh->cellToVertex[celli][localPointA2];
+              
+              myPrimalMesh->segmentNumber++;
+              
+              myPrimalMesh->cellToSegmentOwner[celli]  = (connectivity_int * ) realloc( myPrimalMesh->cellToSegmentOwner[celli], sizeof (connectivity_int)*(myPrimalMesh->cellToSegmentOwnerNumber[celli]+1));
+              
+              myPrimalMesh->cellToSegmentOwner[celli][myPrimalMesh->cellToSegmentOwnerNumber[celli]] = myPrimalMesh->segmentNumber -1;
+              
+              myPrimalMesh->cellToSegmentOwnerNumber[celli]++;
+              
+              if(myPrimalMesh->segmentNumber % 10000 == 0 && myPrimalMesh->segmentNumber != 0)
+                release_print( "%-40s :  (%ld)\n ","SEGMENTS", myPrimalMesh->segmentNumber);
+              
+              for (connectivity_int cellAi=0;cellAi<myPrimalMesh->cellToCellsNumbers[celli];cellAi++)
+                {      
+                  connectivity_int selectedCell = myPrimalMesh->cellToCells[celli][cellAi];
+                  
+                  
+                  if(celli!=selectedCell) {
+                      
+                      //                      affiche("selectedCell %ld:%ld\n",celli,selectedCell);
+                      
+                      for (connectivity_int segmentBi=0;segmentBi<HEXAHEDRON_SEGMENTS;segmentBi++)
+                        { 
+                          if(cellSegmentTest[selectedCell][segmentBi] ==0)
+                            {
+                              
+                              connectivity_int localPointB1 = hexaedron_localSegmentList[segmentBi][PT1];
+                              connectivity_int localPointB2 = hexaedron_localSegmentList[segmentBi][PT2];
+                              
+                              if(
+                                 myPrimalMesh->cellToVertex[celli][localPointA1] == myPrimalMesh->cellToVertex[selectedCell][localPointB1] 
+                                 &&
+                                 myPrimalMesh->cellToVertex[celli][localPointA2] == myPrimalMesh->cellToVertex[selectedCell][localPointB2] 
+                                 )
+                                {
+                                  //                                  affiche("A: %ld %ld\n",segmentAi,segmentBi);
+                                  cellSegmentTest[selectedCell][segmentBi] = 1;
+                                  
+                                }
+                              else 
+                                if(
+                                   myPrimalMesh->cellToVertex[celli][localPointA1] == myPrimalMesh->cellToVertex[selectedCell][localPointB2] 
+                                   &&
+                                   myPrimalMesh->cellToVertex[celli][localPointA2] == myPrimalMesh->cellToVertex[selectedCell][localPointB1] 
+                                   )
+                                  {
+                                    //                                    affiche("B: %ld %ld\n",segmentAi,segmentBi);
+                                    cellSegmentTest[selectedCell][segmentBi] = -1;
+                                  }
+                              
+                              
+                              if(cellSegmentTest[selectedCell][segmentBi] !=0)
+                                {
+                                  
+                                  myPrimalMesh->cellToSegmentNeighbour[selectedCell]  = (connectivity_int * ) realloc( myPrimalMesh->cellToSegmentNeighbour[selectedCell], sizeof (connectivity_int)*(myPrimalMesh->cellToSegmentNeighbourNumber[selectedCell]+1));
+                                  
+                                  myPrimalMesh->cellToSegmentNeighbour[selectedCell][myPrimalMesh->cellToSegmentNeighbourNumber[selectedCell]] = myPrimalMesh->segmentNumber -1;
+                                  
+                                  myPrimalMesh->cellToSegmentNeighbourNumber[selectedCell]++;
+                                  
+                                }
+                              
+                            }
+                          
+                        }
+                    }  
+                  else 
+                    {
+                      //                      affiche("Noeud voisin \n");
+                    }
+                  
+                }
+            }
+        }
+      
+    }
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      debug_print( "%-40s : %ld ( ","cellToSegmentOwner", celli);
+      
+      for(connectivity_int segmenti=0;segmenti<myPrimalMesh->cellToSegmentOwnerNumber[celli];segmenti++)
+        {
+          debug_print( "%ld " , myPrimalMesh->cellToSegmentOwner[celli][segmenti] );
+        }
+      debug_print(")\n");
+    }  
+  
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      debug_print( "%-40s : %ld ( ","cellToSegmentNeighbour", celli);
+      
+      for(connectivity_int segmenti=0;segmenti<myPrimalMesh->cellToSegmentNeighbourNumber[celli];segmenti++)
+        {
+          debug_print( "%ld " , myPrimalMesh->cellToSegmentNeighbour[celli][segmenti] );
+        }
+      debug_print(")\n");
+    }  
+  
+#ifdef DEBUG
+  for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->segments", segmentAi);
+      
+      for(connectivity_int vertexAi=0;vertexAi<SEGMENTVERTEX;vertexAi++)
+        {
+          debug_print( "%ld " , myPrimalMesh->segments[segmentAi][vertexAi] );
+        }
+      debug_print(")\n");
+    }
+  
+#endif
+  
+  free(copyFace);
+  free(vertexList);
+  free(vertexListInverted);
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    free(cellSegmentTest[celli]);
+  free(cellSegmentTest);  
+  
+  
+  
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+void setHexahedreSegments2(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  affiche("%s : Nouvelle fonction setHexahedreSegments pour réduire le temps de calcul\n",__FUNCTION__);
   
   connectivity_int * vertexList         = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
   connectivity_int * vertexListInverted = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
@@ -1895,6 +2113,239 @@ void setHexahedreSegmentToFaces(struct primalMesh * myPrimalMesh)
   clock_t t=startFunction(__FUNCTION__);
   affiche("\n");
   
+  connectivity_int * vertexList         = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+  connectivity_int * vertexListInverted = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+  connectivity_int * copyFace           = (connectivity_int * ) malloc(sizeof (connectivity_int)*(QUAD+1));
+  connectivity_int segmentAi = 0;
+  connectivity_int testSegment=0;
+  connectivity_int faceAi =0;
+  
+  //connectivity_int testSegment = 0;
+  
+//  affiche("%s : REDUIRE LE TEMPS DE CETTE FONCTION EN DEFINISSANT DE NOUVELLES MATRICES avec FACETOCELL puis CELLTOSEGMENTS \n",__FUNCTION__);
+  
+  myPrimalMesh->segmentToFaceOwner  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->segmentNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->segmentNumber;ii++) {
+      myPrimalMesh->segmentToFaceOwner[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->segmentToFaceOwnerNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->segmentNumber);
+  memset(myPrimalMesh->segmentToFaceOwnerNumber, 0, myPrimalMesh->segmentNumber*sizeof(connectivity_int));
+  
+  
+  myPrimalMesh->segmentToFaceNeighbour  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->segmentNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->segmentNumber;ii++) {
+      myPrimalMesh->segmentToFaceNeighbour[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->segmentToFaceNeighbourNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->segmentNumber);
+  memset(myPrimalMesh->segmentToFaceNeighbourNumber, 0, myPrimalMesh->segmentNumber*sizeof(connectivity_int));
+  
+  
+  for (connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      if(celli % 10000 == 0 && celli != 0)
+        release_print( "%-40s :  (%ld)\n ","CELL", celli);
+      
+      
+      
+      for (connectivity_int facei=0;facei<myPrimalMesh->cellToFacesOwnerNumber[celli];facei++)
+        {
+          faceAi = myPrimalMesh->cellToFacesOwner[celli][facei];
+          
+          memcpy(copyFace,myPrimalMesh->faces[faceAi],sizeof (connectivity_int)*(QUAD));
+          copyFace[QUAD] = copyFace[0];  
+          
+          for (connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
+            {
+              testSegment=0;
+              
+              for (connectivity_int segmenti=0;segmenti<myPrimalMesh->cellToSegmentOwnerNumber[celli] && testSegment==0;segmenti++)
+                {
+                  
+                  segmentAi = myPrimalMesh->cellToSegmentOwner[celli][segmenti];
+                  vertexListInverted[0]=myPrimalMesh->segments[segmentAi][1];
+                  vertexListInverted[1]=myPrimalMesh->segments[segmentAi][0];
+                  
+                  if(memcmp(&(copyFace[vertexAi]),(myPrimalMesh->segments[segmentAi]),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                    {
+                      
+                      myPrimalMesh->segmentToFaceOwner[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceOwner[segmentAi], (myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]+1) * sizeof (connectivity_int));
+                      myPrimalMesh->segmentToFaceOwner[segmentAi][myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]] = faceAi;
+                      myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]++;
+                      testSegment=1;
+                    }
+                  else
+                    if(memcmp(&(copyFace[vertexAi]),(vertexListInverted),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                      {
+                        
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceNeighbour[segmentAi], (myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]+1)*sizeof (connectivity_int));
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi][myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]] = faceAi;
+                        myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]++;
+                        testSegment=2;
+                      }
+                  
+                }
+              
+              for (connectivity_int segmenti=0;segmenti<myPrimalMesh->cellToSegmentNeighbourNumber[celli] && testSegment==0;segmenti++)
+                {
+                  
+                  segmentAi = myPrimalMesh->cellToSegmentNeighbour[celli][segmenti];
+                  vertexListInverted[0]=myPrimalMesh->segments[segmentAi][1];
+                  vertexListInverted[1]=myPrimalMesh->segments[segmentAi][0];
+                  
+                  if(memcmp(&(copyFace[vertexAi]),(myPrimalMesh->segments[segmentAi]),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                    {
+                      
+                      myPrimalMesh->segmentToFaceOwner[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceOwner[segmentAi], (myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]+1) * sizeof (connectivity_int));
+                      myPrimalMesh->segmentToFaceOwner[segmentAi][myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]] = faceAi;
+                      myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]++;
+                      testSegment=1;
+                    }
+                  else
+                    if(memcmp(&(copyFace[vertexAi]),(vertexListInverted),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                      {
+                        
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceNeighbour[segmentAi], (myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]+1)*sizeof (connectivity_int));
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi][myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]] = faceAi;
+                        myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]++;
+                        testSegment=2;
+                      }
+                  
+                  
+                  
+                }
+            }
+        }
+      
+      for (connectivity_int facei=0;facei<myPrimalMesh->cellToFacesNeighbourNumber[celli];facei++)
+        {
+          faceAi = myPrimalMesh->cellToFacesNeighbour[celli][facei];
+          
+          memcpy(copyFace,myPrimalMesh->faces[faceAi],sizeof (connectivity_int)*(QUAD));
+          copyFace[QUAD] = copyFace[0];  
+          
+          for (connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
+            {
+              testSegment=0;
+              
+              for (connectivity_int segmenti=0;segmenti<myPrimalMesh->cellToSegmentOwnerNumber[celli] && testSegment==0;segmenti++)
+                {
+                  
+                  segmentAi = myPrimalMesh->cellToSegmentOwner[celli][segmenti];
+                  vertexListInverted[0]=myPrimalMesh->segments[segmentAi][1];
+                  vertexListInverted[1]=myPrimalMesh->segments[segmentAi][0];
+                  
+                  if(memcmp(&(copyFace[vertexAi]),(myPrimalMesh->segments[segmentAi]),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                    {
+                      
+                      myPrimalMesh->segmentToFaceOwner[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceOwner[segmentAi], (myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]+1) * sizeof (connectivity_int));
+                      myPrimalMesh->segmentToFaceOwner[segmentAi][myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]] = faceAi;
+                      myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]++;
+                      testSegment=1;
+                    }
+                  else
+                    if(memcmp(&(copyFace[vertexAi]),(vertexListInverted),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                      {
+                        
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceNeighbour[segmentAi], (myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]+1)*sizeof (connectivity_int));
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi][myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]] = faceAi;
+                        myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]++;
+                        testSegment=2;
+                      }
+                }
+              
+              for (connectivity_int segmenti=0;segmenti<myPrimalMesh->cellToSegmentNeighbourNumber[celli] && testSegment==0;segmenti++)
+                {
+                  segmentAi = myPrimalMesh->cellToSegmentNeighbour[celli][segmenti];
+                  vertexListInverted[0]=myPrimalMesh->segments[segmentAi][1];
+                  vertexListInverted[1]=myPrimalMesh->segments[segmentAi][0];
+                  
+                  if(memcmp(&(copyFace[vertexAi]),(myPrimalMesh->segments[segmentAi]),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                    {
+                      
+                      myPrimalMesh->segmentToFaceOwner[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceOwner[segmentAi], (myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]+1) * sizeof (connectivity_int));
+                      myPrimalMesh->segmentToFaceOwner[segmentAi][myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]] = faceAi;
+                      myPrimalMesh->segmentToFaceOwnerNumber[segmentAi]++;
+                      testSegment=1;
+                    }
+                  else
+                    if(memcmp(&(copyFace[vertexAi]),(vertexListInverted),sizeof (connectivity_int)*SEGMENTVERTEX)==0)
+                      {
+                        
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi] = (connectivity_int *) realloc(myPrimalMesh->segmentToFaceNeighbour[segmentAi], (myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]+1)*sizeof (connectivity_int));
+                        myPrimalMesh->segmentToFaceNeighbour[segmentAi][myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]] = faceAi;
+                        myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi]++;
+                        testSegment=2;
+                      }
+                  
+                  
+                }
+            }
+        }
+      
+      
+      
+      
+      
+    }
+  
+#ifdef DEBUG
+  
+  
+  
+  for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
+    {
+      
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->segmentToFaceOwner", segmentAi);
+      
+      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->segmentToFaceOwnerNumber[segmentAi];faceAi++)
+        {
+          debug_print( "%ld " , myPrimalMesh->segmentToFaceOwner[segmentAi][faceAi] );
+        }
+      
+      debug_print(")\n");
+      
+    }
+  
+  
+  
+  
+  
+  
+  for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
+    {
+      
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->segmentToFaceNeighbour", segmentAi);
+      
+      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->segmentToFaceNeighbourNumber[segmentAi];faceAi++)
+        {
+          debug_print( "%ld " , myPrimalMesh->segmentToFaceNeighbour[segmentAi][faceAi] );
+        }
+      
+      debug_print(")\n");
+      
+    }
+  
+#endif
+  
+  free(copyFace);
+  free(vertexList);
+  free(vertexListInverted);
+  
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+void setHexahedreSegmentToFaces2(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
   connectivity_int * vertexList         = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
   connectivity_int * vertexListInverted = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
   connectivity_int * copyFace           = (connectivity_int * ) malloc(sizeof (connectivity_int)*(QUAD+1));
@@ -2047,7 +2498,7 @@ void setHexahedreDualFaces(struct primalMesh * myPrimalMesh)
               selectedSegment = myPrimalMesh->vertexToSegments[selectedVertex][segmenti];
               
               // Est-ce que les segments sont bien attachés à la cellule selectedCell
-
+              
               for(connectivity_int facei=0;facei<myPrimalMesh->segmentToFaceOwnerNumber[selectedSegment];facei++)
                 {
                   
@@ -2607,14 +3058,14 @@ int main (void)
 #ifdef DEBUG
   
   myPrimalMesh.M = 2; // cell number on X
-  myPrimalMesh.N = 1; // cell number on Y
+  myPrimalMesh.N = 2; // cell number on Y
   myPrimalMesh.P = 1; // cell number on Z
   
 #else
   
-  myPrimalMesh.M = 20; // cell number on X
-  myPrimalMesh.N = 20; // cell number on Y
-  myPrimalMesh.P = 2; // cell number on Z
+  myPrimalMesh.M = 200; // cell number on X
+  myPrimalMesh.N = 200; // cell number on Y
+  myPrimalMesh.P = 200; // cell number on Z
   
 #endif
   myPrimalMesh.vertex                 = NULL;
@@ -2634,6 +3085,12 @@ int main (void)
   myPrimalMesh.vertexToSegments       = NULL;
   myPrimalMesh.cellToCells            = NULL;
   myPrimalMesh.cellToCellsNumbers     = NULL;
+  myPrimalMesh.cellToSegmentOwner     = NULL;
+  myPrimalMesh.cellToSegmentNeighbour = NULL;
+  myPrimalMesh.cellToSegmentOwnerNumber       = NULL;
+  myPrimalMesh.cellToSegmentNeighbourNumber   = NULL;  
+  
+  
   
   // FACES
   myPrimalMesh.faces                  = NULL;
@@ -2664,7 +3121,7 @@ int main (void)
   // nombre de vertex par cellules **cellToVertexNumber
   setHexahedreCellToVertexNumber(&myPrimalMesh);
   
-  // création du lien cellules vers vertex **cellToVertex
+  // création du lien cellules vers vertex **cellToVertex 
   setHexahedreCellToVertex(&myPrimalMesh);
   
   // lien vertex vers cellules
@@ -2679,6 +3136,8 @@ int main (void)
   
   setHexahedreFaceToCells(&myPrimalMesh);
   
+  //  OLD
+  
   setHexahedreSegments(&myPrimalMesh);
   
   setHexahedreVertexToSegments(&myPrimalMesh);
@@ -2692,6 +3151,8 @@ int main (void)
   
   setHexahedreVolumeCentroid(&myPrimalMesh);
   
+  // OLD
+  
   fflush(stderr);
   fflush(stdout);
   
@@ -2706,3 +3167,4 @@ int main (void)
 
 
 
+
index c12650d..0dbd615 100644 (file)
--- a/src/mmd.h
+++ b/src/mmd.h
@@ -92,6 +92,11 @@ struct primalMesh {
     connectivity_int **     cellToFacesNeighbour;
     connectivity_int *      cellToFacesOwnerNumber;
     connectivity_int *      cellToFacesNeighbourNumber;
+    connectivity_int **     cellToSegmentOwner;
+    connectivity_int *      cellToSegmentOwnerNumber;
+    connectivity_int **     cellToSegmentNeighbour;
+    connectivity_int *      cellToSegmentNeighbourNumber;
+    
     connectivity_int **     vertexToFaces;
     connectivity_int *      vertexToFacesNumber;
     connectivity_int **     vertexToSegmentOwner;