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>
Sun, 28 Jun 2020 12:02:27 +0000 (16:02 +0400)
committerAlain <alain.bastide@univ-reunion.fr>
Sun, 28 Jun 2020 12:02:27 +0000 (16:02 +0400)
35 files changed:
.gitignore
CMakeLists.txt
CTestTestfile.cmake [new file with mode: 0644]
Makefile [new file with mode: 0644]
cmake_install.cmake [new file with mode: 0644]
src/dual.c [new file with mode: 0644]
src/dual.h [new file with mode: 0644]
src/listop.c [new file with mode: 0644]
src/listop.h [new file with mode: 0644]
src/main.c
src/memory.c [new file with mode: 0644]
src/memory.h [new file with mode: 0644]
src/mmd.c [new file with mode: 0644]
src/mmd.h
src/primal.c [new file with mode: 0644]
src/primal.h [new file with mode: 0644]
src/savedata.c [new file with mode: 0644]
src/savedata.h [new file with mode: 0644]
test/CMakeFiles/CMakeDirectoryInformation.cmake [new file with mode: 0644]
test/CMakeFiles/progress.marks [new file with mode: 0644]
test/CMakeFiles/test01.dir/C.includecache [new file with mode: 0644]
test/CMakeFiles/test01.dir/DependInfo.cmake [new file with mode: 0644]
test/CMakeFiles/test01.dir/build.make [new file with mode: 0644]
test/CMakeFiles/test01.dir/cmake_clean.cmake [new file with mode: 0644]
test/CMakeFiles/test01.dir/depend.internal [new file with mode: 0644]
test/CMakeFiles/test01.dir/depend.make [new file with mode: 0644]
test/CMakeFiles/test01.dir/flags.make [new file with mode: 0644]
test/CMakeFiles/test01.dir/link.txt [new file with mode: 0644]
test/CMakeFiles/test01.dir/progress.make [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0644]
test/CTestTestfile.cmake [new file with mode: 0644]
test/Makefile [new file with mode: 0644]
test/cmake_install.cmake [new file with mode: 0644]
test/test01 [new file with mode: 0755]
test/test01.c [new file with mode: 0644]

index 1a056b8..9fe914e 100644 (file)
@@ -38,7 +38,5 @@ build/
 CMakeLists.txt.user
 *.odt
 *.tcl
-test/
 Testing/
-CTest*
 python/
index d3ea5f8..b13b6a6 100644 (file)
@@ -27,9 +27,6 @@ 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")
 
 find_package(VTK REQUIRED)
 vtk_module_config(VTK
@@ -40,7 +37,7 @@ vtk_module_config(VTK
   vtkRendering${VTK_RENDERING_BACKEND}
 )
 include(${VTK_USE_FILE})
-
 #find_package(VTK REQUIRED)
 #find_package(VTK COMPONENTS
 #  vtkCommonCore
@@ -62,12 +59,11 @@ message("CXXFLAGS:" ${CMAKE_CXX_FLAGS})
 message("CFLAGS  :" ${CMAKE_C_FLAGS})
 
 
-include(CTest)
-ENABLE_TESTING()
+#include(CTest)
+#ENABLE_TESTING()
 
-#ADD_TEST( testname testexecutable args )
-set ( TESTS ${CMAKE_SOURCE_DIR}/test/test )
-add_subdirectory(${TESTS})
+#set ( TESTS ${CMAKE_SOURCE_DIR}/test )
+#add_subdirectory(${TESTS})
 
 
 
diff --git a/CTestTestfile.cmake b/CTestTestfile.cmake
new file mode 100644 (file)
index 0000000..888b941
--- /dev/null
@@ -0,0 +1,7 @@
+# CMake generated Testfile for 
+# Source directory: /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+# Build directory: /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+# 
+# This file includes the relevant testing commands required for 
+# testing this directory and lists subdirectories to be tested as well.
+subdirs("test")
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..95ef397
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,408 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+# Default target executed when no arguments are given to make.
+default_target: all
+
+.PHONY : default_target
+
+# Allow only one "make -f Makefile2" at a time, but pass parallelism.
+.NOTPARALLEL:
+
+
+#=============================================================================
+# Special targets provided by cmake.
+
+# Disable implicit rules so canonical targets will work.
+.SUFFIXES:
+
+
+# Disable VCS-based implicit rules.
+% : %,v
+
+
+# Disable VCS-based implicit rules.
+% : RCS/%
+
+
+# Disable VCS-based implicit rules.
+% : RCS/%,v
+
+
+# Disable VCS-based implicit rules.
+% : SCCS/s.%
+
+
+# Disable VCS-based implicit rules.
+% : s.%
+
+
+.SUFFIXES: .hpux_make_needs_suffix_list
+
+
+# Command-line flag to silence nested $(MAKE).
+$(VERBOSE)MAKESILENT = -s
+
+# Suppress display of executed commands.
+$(VERBOSE).SILENT:
+
+
+# A target that is always out of date.
+cmake_force:
+
+.PHONY : cmake_force
+
+#=============================================================================
+# Set environment variables for the build.
+
+# The shell in which to execute make rules.
+SHELL = /bin/sh
+
+# The CMake executable.
+CMAKE_COMMAND = /usr/bin/cmake
+
+# The command to remove a file.
+RM = /usr/bin/cmake -E rm -f
+
+# Escaping for special characters.
+EQUALS = =
+
+# The top-level source directory on which CMake was run.
+CMAKE_SOURCE_DIR = /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+# The top-level build directory on which CMake was run.
+CMAKE_BINARY_DIR = /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+#=============================================================================
+# Targets provided globally by CMake.
+
+# Special rule for the target rebuild_cache
+rebuild_cache:
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
+       /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+.PHONY : rebuild_cache
+
+# Special rule for the target rebuild_cache
+rebuild_cache/fast: rebuild_cache
+
+.PHONY : rebuild_cache/fast
+
+# Special rule for the target edit_cache
+edit_cache:
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
+       /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
+.PHONY : edit_cache
+
+# Special rule for the target edit_cache
+edit_cache/fast: edit_cache
+
+.PHONY : edit_cache/fast
+
+# The main all target
+all: cmake_check_build_system
+       $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles/progress.marks
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
+       $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles 0
+.PHONY : all
+
+# The main clean target
+clean:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
+.PHONY : clean
+
+# The main clean target
+clean/fast: clean
+
+.PHONY : clean/fast
+
+# Prepare targets for installation.
+preinstall: all
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
+.PHONY : preinstall
+
+# Prepare targets for installation.
+preinstall/fast:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
+.PHONY : preinstall/fast
+
+# clear depends
+depend:
+       $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
+.PHONY : depend
+
+#=============================================================================
+# Target rules for targets named MMD
+
+# Build rule for target.
+MMD: cmake_check_build_system
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 MMD
+.PHONY : MMD
+
+# fast build rule for target.
+MMD/fast:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/build
+.PHONY : MMD/fast
+
+src/dual.o: src/dual.c.o
+
+.PHONY : src/dual.o
+
+# target to build an object file
+src/dual.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/dual.c.o
+.PHONY : src/dual.c.o
+
+src/dual.i: src/dual.c.i
+
+.PHONY : src/dual.i
+
+# target to preprocess a source file
+src/dual.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/dual.c.i
+.PHONY : src/dual.c.i
+
+src/dual.s: src/dual.c.s
+
+.PHONY : src/dual.s
+
+# target to generate assembly for a file
+src/dual.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/dual.c.s
+.PHONY : src/dual.c.s
+
+src/listop.o: src/listop.c.o
+
+.PHONY : src/listop.o
+
+# target to build an object file
+src/listop.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/listop.c.o
+.PHONY : src/listop.c.o
+
+src/listop.i: src/listop.c.i
+
+.PHONY : src/listop.i
+
+# target to preprocess a source file
+src/listop.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/listop.c.i
+.PHONY : src/listop.c.i
+
+src/listop.s: src/listop.c.s
+
+.PHONY : src/listop.s
+
+# target to generate assembly for a file
+src/listop.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/listop.c.s
+.PHONY : src/listop.c.s
+
+src/main.o: src/main.c.o
+
+.PHONY : src/main.o
+
+# target to build an object file
+src/main.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/main.c.o
+.PHONY : src/main.c.o
+
+src/main.i: src/main.c.i
+
+.PHONY : src/main.i
+
+# target to preprocess a source file
+src/main.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/main.c.i
+.PHONY : src/main.c.i
+
+src/main.s: src/main.c.s
+
+.PHONY : src/main.s
+
+# target to generate assembly for a file
+src/main.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/main.c.s
+.PHONY : src/main.c.s
+
+src/memory.o: src/memory.c.o
+
+.PHONY : src/memory.o
+
+# target to build an object file
+src/memory.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/memory.c.o
+.PHONY : src/memory.c.o
+
+src/memory.i: src/memory.c.i
+
+.PHONY : src/memory.i
+
+# target to preprocess a source file
+src/memory.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/memory.c.i
+.PHONY : src/memory.c.i
+
+src/memory.s: src/memory.c.s
+
+.PHONY : src/memory.s
+
+# target to generate assembly for a file
+src/memory.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/memory.c.s
+.PHONY : src/memory.c.s
+
+src/mmd.o: src/mmd.c.o
+
+.PHONY : src/mmd.o
+
+# target to build an object file
+src/mmd.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/mmd.c.o
+.PHONY : src/mmd.c.o
+
+src/mmd.i: src/mmd.c.i
+
+.PHONY : src/mmd.i
+
+# target to preprocess a source file
+src/mmd.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/mmd.c.i
+.PHONY : src/mmd.c.i
+
+src/mmd.s: src/mmd.c.s
+
+.PHONY : src/mmd.s
+
+# target to generate assembly for a file
+src/mmd.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/mmd.c.s
+.PHONY : src/mmd.c.s
+
+src/primal.o: src/primal.c.o
+
+.PHONY : src/primal.o
+
+# target to build an object file
+src/primal.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/primal.c.o
+.PHONY : src/primal.c.o
+
+src/primal.i: src/primal.c.i
+
+.PHONY : src/primal.i
+
+# target to preprocess a source file
+src/primal.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/primal.c.i
+.PHONY : src/primal.c.i
+
+src/primal.s: src/primal.c.s
+
+.PHONY : src/primal.s
+
+# target to generate assembly for a file
+src/primal.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/primal.c.s
+.PHONY : src/primal.c.s
+
+src/savedata.o: src/savedata.c.o
+
+.PHONY : src/savedata.o
+
+# target to build an object file
+src/savedata.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/savedata.c.o
+.PHONY : src/savedata.c.o
+
+src/savedata.i: src/savedata.c.i
+
+.PHONY : src/savedata.i
+
+# target to preprocess a source file
+src/savedata.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/savedata.c.i
+.PHONY : src/savedata.c.i
+
+src/savedata.s: src/savedata.c.s
+
+.PHONY : src/savedata.s
+
+# target to generate assembly for a file
+src/savedata.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/savedata.c.s
+.PHONY : src/savedata.c.s
+
+src/tensor.o: src/tensor.c.o
+
+.PHONY : src/tensor.o
+
+# target to build an object file
+src/tensor.c.o:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/tensor.c.o
+.PHONY : src/tensor.c.o
+
+src/tensor.i: src/tensor.c.i
+
+.PHONY : src/tensor.i
+
+# target to preprocess a source file
+src/tensor.c.i:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/tensor.c.i
+.PHONY : src/tensor.c.i
+
+src/tensor.s: src/tensor.c.s
+
+.PHONY : src/tensor.s
+
+# target to generate assembly for a file
+src/tensor.c.s:
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/MMD.dir/build.make CMakeFiles/MMD.dir/src/tensor.c.s
+.PHONY : src/tensor.c.s
+
+# Help Target
+help:
+       @echo "The following are some of the valid targets for this Makefile:"
+       @echo "... all (the default if no target is provided)"
+       @echo "... clean"
+       @echo "... depend"
+       @echo "... edit_cache"
+       @echo "... rebuild_cache"
+       @echo "... MMD"
+       @echo "... src/dual.o"
+       @echo "... src/dual.i"
+       @echo "... src/dual.s"
+       @echo "... src/listop.o"
+       @echo "... src/listop.i"
+       @echo "... src/listop.s"
+       @echo "... src/main.o"
+       @echo "... src/main.i"
+       @echo "... src/main.s"
+       @echo "... src/memory.o"
+       @echo "... src/memory.i"
+       @echo "... src/memory.s"
+       @echo "... src/mmd.o"
+       @echo "... src/mmd.i"
+       @echo "... src/mmd.s"
+       @echo "... src/primal.o"
+       @echo "... src/primal.i"
+       @echo "... src/primal.s"
+       @echo "... src/savedata.o"
+       @echo "... src/savedata.i"
+       @echo "... src/savedata.s"
+       @echo "... src/tensor.o"
+       @echo "... src/tensor.i"
+       @echo "... src/tensor.s"
+.PHONY : help
+
+
+
+#=============================================================================
+# Special targets to cleanup operation of make.
+
+# Special rule to run CMake to check the build system integrity.
+# No rule that depends on this can have commands that come from listfiles
+# because they might be regenerated.
+cmake_check_build_system:
+       $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
+.PHONY : cmake_check_build_system
+
diff --git a/cmake_install.cmake b/cmake_install.cmake
new file mode 100644 (file)
index 0000000..e7ddbcb
--- /dev/null
@@ -0,0 +1,49 @@
+# Install script for directory: /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX "/usr/local")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+  if(BUILD_TYPE)
+    string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+           CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+  else()
+    set(CMAKE_INSTALL_CONFIG_NAME "Release")
+  endif()
+  message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+  if(COMPONENT)
+    message(STATUS "Install component: \"${COMPONENT}\"")
+    set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+  else()
+    set(CMAKE_INSTALL_COMPONENT)
+  endif()
+endif()
+
+# Install shared libraries without execute permission?
+if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
+  set(CMAKE_INSTALL_SO_NO_EXE "1")
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+  set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
+if(CMAKE_INSTALL_COMPONENT)
+  set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
+else()
+  set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
+endif()
+
+string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
+       "${CMAKE_INSTALL_MANIFEST_FILES}")
+file(WRITE "/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/${CMAKE_INSTALL_MANIFEST}"
+     "${CMAKE_INSTALL_MANIFEST_CONTENT}")
diff --git a/src/dual.c b/src/dual.c
new file mode 100644 (file)
index 0000000..eac1835
--- /dev/null
@@ -0,0 +1,443 @@
+#include "mmd.h"
+#include "dual.h"
+#include "tensor.h"
+#include "listop.h"
+
+
+
+
+void setDualFaces(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  connectivity_int selectedCell = 0;
+  connectivity_int selectedVertex = 0;
+  connectivity_int * selectedSegments = NULL;
+  connectivity_int selectedSegmentNumber = 0;
+  connectivity_int * selectedFaces = NULL;
+  connectivity_int   selectedFacesNumber = 0;
+  
+  myDualMesh->internalDualFaces  = (dataType *** ) malloc(sizeof (dataType**)*myDualMesh->internalDualFacesNumber);
+  
+  myDualMesh->segmentToInternalDualFace = (connectivity_int **) malloc(sizeof (connectivity_int*)*myPrimalMesh->segmentNumber);
+  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
+    {
+      myDualMesh->segmentToInternalDualFace[segmenti] = NULL;
+    }  
+  myDualMesh->segmentToInternalDualFaceNumber = (connectivity_int *) malloc(sizeof (connectivity_int)*myPrimalMesh->segmentNumber);
+  memset(myDualMesh->segmentToInternalDualFaceNumber,0,myPrimalMesh->segmentNumber*sizeof (connectivity_int) );
+  
+  
+  connectivity_int * output1;
+  connectivity_int lenOutput1;
+  
+  
+  connectivity_int * output2;
+  connectivity_int lenOutput2;
+  
+  
+  connectivity_int * output3;
+  connectivity_int lenOutput3;
+  
+  output1  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
+  output2  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
+  output3  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
+  selectedFaces  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
+  selectedSegments = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      
+      selectedCell = celli;
+      if(celli % 100000== 0 && celli != 0)
+        release_print( "%-40s :  (%ld)\n","CELL", celli);
+      
+      unionTwoIntegerSet(&selectedFaces, &selectedFacesNumber,
+                         (myPrimalMesh->cellToFacesOwner[celli]) , myPrimalMesh->cellToFacesOwnerNumber[celli] , 
+                         (myPrimalMesh->cellToFacesNeighbour[celli]) , myPrimalMesh->cellToFacesNeighbourNumber[celli]);
+      
+      
+#ifdef DEBUG      
+      debug_print( " ( ");
+      
+      for(connectivity_int vertexi=0;vertexi<selectedFacesNumber;vertexi++)
+        {
+          debug_print( "%ld " , selectedFaces[vertexi] );
+        }
+      debug_print(" )");
+      debug_print(" \n");
+#endif  
+      
+      unionTwoIntegerSet(&selectedSegments, &selectedSegmentNumber,
+                         (myPrimalMesh->cellToSegmentOwner[celli]) , myPrimalMesh->cellToSegmentOwnerNumber[celli] , 
+                         (myPrimalMesh->cellToSegmentNeighbour[celli]) , myPrimalMesh->cellToSegmentNeighbourNumber[celli]);
+      
+      
+      
+      for(connectivity_int segmenti=0;segmenti<selectedSegmentNumber;segmenti++)
+        {
+          // select segments attached to one cell          
+          
+          
+          //          for(connectivity_int facei=0;facei<selectedFacesNumber;facei++)
+          //            {          
+          // select faces attached to one segment
+          // We have to intersect previous set and this one
+          
+          intersectTwoIntegerSet(&output1,&lenOutput1,
+                                 selectedFaces,selectedFacesNumber,
+                                 myPrimalMesh->segmentToFaceOwner[selectedSegments[segmenti]],myPrimalMesh->segmentToFaceOwnerNumber[selectedSegments[segmenti]]
+              );
+          
+          intersectTwoIntegerSet(&output2,&lenOutput2,
+                                 selectedFaces,selectedFacesNumber,
+                                 myPrimalMesh->segmentToFaceNeighbour[selectedSegments[segmenti]],myPrimalMesh->segmentToFaceNeighbourNumber[selectedSegments[segmenti]]
+              );
+          
+          unionTwoIntegerSet(&output3, &lenOutput3,
+                             output1 , lenOutput1 , 
+                             output2 , lenOutput2);
+          
+          
+#ifdef DEBUG
+          
+          debug_print( "Intersect %ld ( ",celli);
+          
+          for(connectivity_int vertexi=0;vertexi<selectedFacesNumber;vertexi++)
+            {
+              debug_print( "%ld " , selectedFaces[vertexi] );
+            }
+          debug_print(" ) ");
+          debug_print( "( ");
+          
+          for(connectivity_int vertexi=0;vertexi<selectedSegmentNumber;vertexi++)
+            {
+              debug_print( "%ld " , selectedSegments[vertexi] );
+            }
+          debug_print(" ) ");
+          debug_print( "( ");
+          
+          for(connectivity_int vertexi=0;vertexi<lenOutput1;vertexi++)
+            {
+              debug_print( "%ld " ,output1[vertexi] );
+            }
+          for(connectivity_int vertexi=0;vertexi<lenOutput2;vertexi++)
+            {
+              debug_print( "%ld " ,output2[vertexi] );
+            }
+          debug_print(" )");
+          debug_print(" \n");
+          
+#endif              
+          
+          if(lenOutput3==2) {
+              //selectedSegments[segmenti]
+              myDualMesh->internalDualFaces = (dataType ***) realloc(myDualMesh->internalDualFaces, (myDualMesh->internalDualFacesNumber+1) * sizeof (dataType**));
+              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber] = (dataType **) malloc( HEXAHEDRON_DUAL_FACE_POINT * sizeof (dataType*));   
+              //              memset(myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber], 0, HEXAHEDRON_DUAL_FACE_POINT*sizeof(connectivity_int));
+              
+              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT1] = (myPrimalMesh->faceCentres[output3[0]]); 
+              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT2] = (myPrimalMesh->volumeCentroid[celli]); 
+              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT3] = (myPrimalMesh->faceCentres[output3[1]]); 
+              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT4] = (myPrimalMesh->segmentCentres[selectedSegments[segmenti]]); 
+              
+              
+              myDualMesh->segmentToInternalDualFace[selectedSegments[segmenti]]= (connectivity_int*) realloc(myDualMesh->segmentToInternalDualFace[selectedSegments[segmenti]] ,sizeof (connectivity_int)*(myDualMesh->segmentToInternalDualFaceNumber[selectedSegments[segmenti]]+1));
+              
+              myDualMesh->segmentToInternalDualFace[selectedSegments[segmenti]][ myDualMesh->segmentToInternalDualFaceNumber[selectedSegments[segmenti]] ] = myDualMesh->internalDualFacesNumber;
+              myDualMesh->segmentToInternalDualFaceNumber[selectedSegments[segmenti]]++;
+              
+              myDualMesh->internalDualFacesNumber++;              
+            }
+          //              else 
+          //                {
+          //                  affiche("Error on setDualFaces definition\n");
+          //                  exit(1);
+          //                }
+        }
+      //        }
+    }
+  
+#ifdef DEBUG
+  
+  
+  
+  for(connectivity_int faceAi=0;faceAi<myDualMesh->internalDualFacesNumber;faceAi++)
+    {
+      
+      debug_print( "%-40s : %ld","myDualMesh->internalDualFaces", faceAi);
+      
+      for(connectivity_int pointi=0;pointi<HEXAHEDRON_DUAL_FACE_POINT;pointi++)
+        {
+          debug_print( " ( ");
+          
+          for(connectivity_int vertexi=0;vertexi<DIM3D;vertexi++)
+            {
+              debug_print( "%lf " , myDualMesh->internalDualFaces[faceAi][pointi][vertexi] );
+            }
+          debug_print(" )");
+        }
+      debug_print(" \n");
+      
+    }
+  
+  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
+    {
+      
+      debug_print( "%-40s : %ld","myDualMesh->segmentToInternalDualFace", segmenti);
+      
+      debug_print( " ( ");
+      
+      
+      for(connectivity_int facei=0;facei<myDualMesh->segmentToInternalDualFaceNumber[segmenti];facei++)
+        {
+          debug_print( "%ld " , myDualMesh->segmentToInternalDualFace[segmenti][facei] );
+        }
+      
+      debug_print(" )");
+      debug_print(" \n");
+      
+    }
+  
+  
+  
+  
+  
+  
+#endif
+  
+  free(selectedFaces);
+  free(selectedSegments);
+  free(output1);
+  free(output2);
+  free(output3);
+  
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+void setDualFacesCentres(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  connectivity_int actualPoint;
+  connectivity_int nextPoint;
+  
+  dataType *fC;
+
+  dataType  * result1 = (dataType * ) malloc(sizeof (dataType)*DIM3D);
+  dataType  * result2 = (dataType * ) malloc(sizeof (dataType)*DIM3D);
+  dataType    result3 = 0.0;
+  dataType    result4 = 0.0;
+  connectivity_int  face  =0.0;  
+  connectivity_int * segmentVector=NULL;
+  
+  fC =(dataType *) calloc(DIM3D, sizeof(dataType));
+  
+  
+  myDualMesh->internalDualFaceCentres  = (dataType ** ) malloc(sizeof (dataType*)*myDualMesh->internalDualFacesNumber);
+  for(connectivity_int i=0; i<myDualMesh->internalDualFacesNumber; i++)
+    {
+      myDualMesh->internalDualFaceCentres[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
+      memset(myDualMesh->internalDualFaceCentres[i], 0.0, DIM3D*sizeof(dataType));
+    }
+  
+  
+  
+  myDualMesh->internalDualFaceArea  = (dataType ** ) malloc(sizeof (dataType*)*myDualMesh->internalDualFacesNumber);
+  for(connectivity_int i=0; i<myDualMesh->internalDualFacesNumber; i++)
+    {
+      myDualMesh->internalDualFaceArea[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
+      memset(myDualMesh->internalDualFaceArea[i], 0.0, DIM3D*sizeof(dataType));
+    }
+  
+  
+  for(connectivity_int faceAi=0;faceAi<myDualMesh->internalDualFacesNumber;faceAi++)
+    {
+      if(faceAi % 1000000== 0 && faceAi != 0)
+        release_print( "%-40s :  (%ld)\n","FACE", faceAi);
+      
+      
+      zeroVector(&fC);
+      
+      for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
+        {
+          actualPoint = vertexAi;
+          
+          sumTwoVectors(&fC,fC,myDualMesh->internalDualFaces[faceAi][actualPoint]);
+          
+        }
+      
+      
+      scalarDivVector(&(myDualMesh->internalDualFaceCentres[faceAi]), QUAD,fC);
+      
+#ifdef DEBUG      
+      debug_print( "%-40s : %ld %d ( ","myDualMesh->internalDualFaceCentres Esti", faceAi, QUAD);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , myDualMesh->internalDualFaceCentres[faceAi][ii]);
+        }
+      debug_print(")\n");
+#endif
+      if(QUAD==3) {
+          
+          // Triangle
+          affiche("NON IMPLEMENTED ...");
+          exit(1);
+          
+        }
+      else
+        { //https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C
+          dataType *sumN;
+          dataType sumA       = ZEROSCALAR;
+          dataType *sumAc;
+          
+          dataType *c;
+          dataType a          = ZEROSCALAR;
+          dataType * n       ;
+          
+          dataType *result1;
+          dataType *result2;
+          
+          
+          result1 =(dataType *) calloc(DIM3D, sizeof(dataType));
+          sumN =(dataType *) calloc(DIM3D, sizeof(dataType));
+          sumAc =(dataType *) calloc(DIM3D, sizeof(dataType));
+          c =(dataType *) calloc(DIM3D, sizeof(dataType));
+          n =(dataType *) calloc(DIM3D, sizeof(dataType));
+          result2 =(dataType *) calloc(DIM3D, sizeof(dataType));
+          
+          
+          
+          for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++) 
+            {
+              
+              actualPoint = vertexAi;
+              nextPoint = (vertexAi + 1) % QUAD;
+              
+              sumThreeVectors(&c, (myDualMesh->internalDualFaces[faceAi][actualPoint]), (myDualMesh->internalDualFaces[faceAi][nextPoint]), (myDualMesh->internalDualFaceCentres[faceAi]) );
+              
+              subTwoVectors(&result1, (myDualMesh->internalDualFaces[faceAi][nextPoint]), (myDualMesh->internalDualFaces[faceAi][actualPoint]));
+              subTwoVectors(&result2, (myDualMesh->internalDualFaceCentres[faceAi]), (myDualMesh->internalDualFaces[faceAi][actualPoint]));
+              
+              crossProduct(&n, result1, result2);
+              mag(&(a), n);
+              
+              sumTwoVectors(&sumN, sumN, n);
+              
+              sumA+=a;
+              scalarDotVector(&result1, a, c);
+              sumTwoVectors(&sumAc, sumAc, result1);
+            }
+          
+          if (sumA < SMALL)
+            {
+              zeroVector( &(myDualMesh->internalDualFaceArea[faceAi]) );
+            }
+          else
+            {
+              scalarDotVector(&(myDualMesh->internalDualFaceCentres[faceAi]), 1.0/(3.0*sumA), sumAc); //correct faceCentres after estimating them
+              scalarDotVector(&(myDualMesh->internalDualFaceArea[faceAi]), 0.5, sumN);
+            }
+          
+          
+          free(sumN);
+          free(sumAc);
+          free(c);
+          free(n)       ;
+          free(result1);
+          free(result2);
+          
+        }
+      
+    }
+  
+  // correct direction of seg and area vector of dual mesh
+  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
+    {    
+      segmentVector = myPrimalMesh->segments[segmenti];
+      
+
+      subTwoVectors(&result1, myPrimalMesh->vertex[segmentVector[PT2]], myPrimalMesh->vertex[segmentVector[PT1]]);      
+      
+      for(connectivity_int facei=0;facei<myDualMesh->segmentToInternalDualFaceNumber[segmenti];facei++)
+        {
+          face  = myDualMesh->segmentToInternalDualFace[segmenti][facei];
+          
+          dotProduct(&result4, result1, myDualMesh->internalDualFaceArea[face]) ;     
+          if(result4<0.0)
+            {
+              for(connectivity_int pointi=0;pointi<DIM3D;pointi++)
+                {
+                  myDualMesh->internalDualFaceArea[face][pointi] *= -1.0;
+                }              
+            }
+        }
+      
+      
+#ifdef DEBUG      
+      
+      dotProduct(&result4, result1, myDualMesh->internalDualFaceArea[face]) ;     
+
+      debug_print( "%-40s : %ld ( ","VECTOR", segmenti);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , result1[ii]);
+        }
+      
+      debug_print(") ");     
+      
+      debug_print( "%lf ", result4);
+      
+      debug_print("\n");      
+#endif      
+    }
+  
+  
+  
+  
+  
+  
+  
+#ifdef DEBUG     
+  for(connectivity_int faceAi=0;faceAi<myDualMesh->internalDualFacesNumber;faceAi++)
+    {          
+      debug_print( "%-40s : %ld %d ( ","myDualMesh->internalDualFaceCentres", faceAi, QUAD);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , myDualMesh->internalDualFaceCentres[faceAi][ii]);
+        }
+      
+      debug_print(")\n");
+      
+      debug_print( "%-40s : %ld ( ","myDualMesh->internalDualFaceArea", faceAi);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , myDualMesh->internalDualFaceArea[faceAi][ii]);
+        }
+      
+      debug_print(")\n");
+    }     
+#endif          
+  
+  
+  free(result1);
+  free(result2);
+  free(fC);    
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
diff --git a/src/dual.h b/src/dual.h
new file mode 100644 (file)
index 0000000..d01f68d
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef DUAL_H
+#define DUAL_H
+
+#include "mmd.h"
+
+void setDualFaces(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh);
+
+void setDualFacesCentres(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh);
+
+
+#endif // DUAL_H
diff --git a/src/listop.c b/src/listop.c
new file mode 100644 (file)
index 0000000..bc6e442
--- /dev/null
@@ -0,0 +1,187 @@
+#include "listop.h"
+
+
+/*!
+ * \fn void rotate(connectivity_int arr[], connectivity_int n)
+ * \brief Circular displacement 
+ * \param arr { vector  }
+ * \param n { Offset number }
+ * \return arr {vector with inverted values}
+ * 
+ * Circular displacement of the elements of a vector arr of n elements
+ */
+
+void rotate(connectivity_int arr[], connectivity_int n)
+{
+  connectivity_int x = arr[0], i;
+  for (i = 0; i <n-1; i++)
+    arr[i] = arr[i+1];
+  arr[n-1] = x;
+}
+
+
+void removeDuplicates(connectivity_int arr[], connectivity_int * size)
+{
+  for(connectivity_int i=0; i<(*size); i++)
+    {
+      for(connectivity_int j=i+1; j<(*size); j++)
+        {
+          /* If any duplicate found */
+          if(arr[i] == arr[j])
+            {
+              /* Delete the current duplicate element */
+              for(connectivity_int k=j; k<(*size)-1; k++)
+                {
+                  arr[k] = arr[k + 1];
+                }
+              
+              /* Decrement size after removing duplicate element */
+              (*size)--;
+              
+              /* If shifting of elements occur then don't increment j */
+              j--;
+            }
+        }
+    }
+}
+
+void sortListConnectivity(connectivity_int a[], connectivity_int  n)
+{
+  connectivity_int tmp = 0;
+  
+  for (connectivity_int i = 0; i < n; i++)                     //Loop for ascending ordering
+    {
+      for (connectivity_int j = 0; j < n; j++)             //Loop for comparing other values
+        {
+          if (a[j] > a[i])                //Comparing other array elements
+            {
+              tmp = a[i];         //Using temporary variable for storing last value
+              a[i] = a[j];            //replacing value
+              a[j] = tmp;             //storing last value
+            }
+        }
+    }
+  
+}
+
+
+void sortList(connectivity_int ** vector,connectivity_int vectorSize, connectivity_int position)
+{
+  
+  for(connectivity_int ii=0;ii<position;ii++)
+    rotate(*vector, vectorSize);
+  
+}
+
+long findInList(connectivity_int * vector,connectivity_int vectorSize, connectivity_int value)
+{
+  
+  for(connectivity_int ii=0;ii<vectorSize;ii++)
+    {
+      if(vector[ii]==value)
+        {
+          return (long)(ii);
+        }
+    }
+  
+  return -1;
+  
+}
+connectivity_int findMinInList(connectivity_int * vector,connectivity_int vectorSize)
+{
+  
+  connectivity_int              position=0;
+  
+  for(connectivity_int ii=1;ii<vectorSize;ii++)
+    {
+      if(vector[position]>vector[ii])
+        {
+          position=ii;
+        }
+    }
+  
+  return(position);
+}
+
+
+void invertListSort(connectivity_int ** result,connectivity_int * vector,connectivity_int vectorSize)
+{
+  connectivity_int position = 0;
+  
+  for(connectivity_int ii=0;ii<vectorSize;ii++)
+    (*result)[ii] = vector[vectorSize -1 - ii];
+  position = findMinInList((*result),vectorSize);
+  sortList(result, vectorSize, position);
+  
+}
+
+void intersectTwoIntegerSet(connectivity_int ** output , connectivity_int * lenOutput , connectivity_int * inputOne , connectivity_int  lenInputOne , connectivity_int * inputTwo, connectivity_int  lenInputTwo)
+{
+  
+  (*lenOutput)=0;
+  //  affiche("%ld\n",lenInputOne);
+  //  affiche("%ld\n",lenInputTwo);
+  
+  for(connectivity_int posAi=0;posAi<lenInputOne;posAi++)
+    for(connectivity_int posBi=0;posBi<lenInputTwo;posBi++)
+      {
+        if(inputOne[posAi]==inputTwo[posBi])
+          {
+            (*output)[(*lenOutput)] = inputOne[posAi];
+            (*lenOutput)++;
+          }
+      }
+  
+  removeDuplicates((*output), lenOutput);
+}
+
+
+
+void unionTwoIntegerSet(connectivity_int ** output , connectivity_int * lenOutput , connectivity_int * inputOne , connectivity_int  lenInputOne , connectivity_int * inputTwo, connectivity_int  lenInputTwo)
+{
+  
+  (*lenOutput)=0;
+  //  affiche("%ld\n",lenInputOne);
+  //  affiche("%ld\n",lenInputTwo);
+  
+//  (*output) = (connectivity_int * ) malloc(sizeof(connectivity_int)*(lenInputOne+lenInputTwo));
+  
+  for(connectivity_int posAi=0;posAi<lenInputOne;posAi++)
+    {
+      (*output)[(*lenOutput)] = inputOne[posAi];
+      (*lenOutput)++;
+    }
+  
+  for(connectivity_int posBi=0;posBi<lenInputTwo;posBi++)
+    {
+      (*output)[(*lenOutput)] = inputTwo[posBi];
+      (*lenOutput)++;
+    }
+  
+  removeDuplicates((*output), lenOutput);
+}
+
+
+void findListFromList(connectivity_int ** matrix, connectivity_int * matrixRowNumbers, connectivity_int size, connectivity_int * whatToFind, connectivity_int sizewhatToFind )
+{
+  
+  //connectivity_int tmp = 0;
+  
+  for (connectivity_int i = 0; i < size; i++)
+    {
+      if(findInList(matrix[i],matrixRowNumbers[i], whatToFind[0])!=-1)
+        {
+          for (connectivity_int j = 0; j < matrixRowNumbers[i]; j++)
+            {
+              
+              for (connectivity_int k=1;k<sizewhatToFind;k++)
+                {
+                  
+                }
+              
+            }
+        }
+    }
+  
+}
+
diff --git a/src/listop.h b/src/listop.h
new file mode 100644 (file)
index 0000000..8caef4a
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef LISTOP_H
+#define LISTOP_H
+#include "mmd.h"
+
+
+
+void rotate(connectivity_int arr[], connectivity_int n);
+
+void removeDuplicates(connectivity_int arr[], connectivity_int * size);
+
+void sortListConnectivity(connectivity_int a[], connectivity_int  n);
+
+void sortList(connectivity_int ** vector,connectivity_int vectorSize, connectivity_int position);
+
+long findInList(connectivity_int * vector,connectivity_int vectorSize, connectivity_int value);
+
+connectivity_int findMinInList(connectivity_int * vector,connectivity_int vectorSize);
+
+void invertListSort(connectivity_int ** result,connectivity_int * vector,connectivity_int vectorSize);
+
+void intersectTwoIntegerSet(connectivity_int ** output , connectivity_int * lenOutput , connectivity_int * inputOne , connectivity_int  lenInputOne , connectivity_int * inputTwo, connectivity_int  lenInputTwo);
+
+void unionTwoIntegerSet(connectivity_int ** output , connectivity_int * lenOutput , connectivity_int * inputOne , connectivity_int  lenInputOne , connectivity_int * inputTwo, connectivity_int  lenInputTwo);
+
+void findListFromList(connectivity_int ** matrix, connectivity_int * matrixRowNumbers, connectivity_int size, connectivity_int * whatToFind, connectivity_int sizewhatToFind );
+
+#endif // LISTOP_H
index 75f5dea..eae2d65 100644 (file)
 #include "mmd.h"
 #include "tensor.h"
 #include <signal.h>
+#include "primal.h"
+#include "listop.h"
+#include "memory.h"
+#include "dual.h"
 
-connectivity_int  hexaedron_localNodeList[HEXAHEDRON_FACES][QUAD]={ \
-  {0,3,2,1}, \
-  {0,1,5,4}, \
-  {0,4,7,3}, \
-  {1,2,6,5}, \
-  {4,5,6,7}, \
-  {3,7,6,2} \
-};
-
-
-connectivity_int  hexaedron_localNodeListNumbers[HEXAHEDRON_FACES]={ \
-  QUAD, \
-  QUAD, \
-  QUAD, \
-  QUAD, \
-  QUAD, \
-  QUAD \
-};
-
-#define PT1 0
-#define PT2 1
-#define PT3 2
-#define PT4 3
-#define CELL1 0
-#define CELL2 1
-
-connectivity_int  hexaedron_localSegmentList[HEXAHEDRON_SEGMENTS][SEGMENTVERTEX]={ \
-  {0,1}, \
-  {1,5}, \
-  {5,4}, \
-  {4,0}, \
-  {4,7}, \
-  {1,2}, \
-  {2,3}, \
-  {3,7}, \
-  {7,6}, \
-  {6,2}, \
-  {5,6}, \
-  {0,3} \
-};
-
-
-connectivity_int  hexaedron_localSegmentsListNumbers[HEXAHEDRON_SEGMENTS]={ \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX, \
-  SEGMENTVERTEX \
-};
-
-
-/*!
- * \fn void rotate(connectivity_int arr[], connectivity_int n)
- * \brief Circular displacement 
- * \param arr { vector  }
- * \param n { Offset number }
- * \return arr {vector with inverted values}
- * 
- * Circular displacement of the elements of a vector arr of n elements
- */
-void rotate(connectivity_int arr[], connectivity_int n)
-{
-  connectivity_int x = arr[0], i;
-  for (i = 0; i <n-1; i++)
-    arr[i] = arr[i+1];
-  arr[n-1] = x;
-}
-
-clock_t startFunction(const char * functionName)
-{
-  affiche("%-40s : Start\n", functionName);
-  
-  return clock();
-}
-
-void endFunction(const char * functionName, clock_t t)
-{
-  t = clock() - t;
-  double time_taken = ((double)t) / CLOCKS_PER_SEC; // in seconds
-  
-  affiche("%-40s : %f seconds to execute\n", functionName, time_taken);
-  
-}
-
-void removeDuplicates(connectivity_int arr[], connectivity_int * size)
-{
-  for(connectivity_int i=0; i<(*size); i++)
-    {
-      for(connectivity_int j=i+1; j<(*size); j++)
-        {
-          /* If any duplicate found */
-          if(arr[i] == arr[j])
-            {
-              /* Delete the current duplicate element */
-              for(connectivity_int k=j; k<(*size)-1; k++)
-                {
-                  arr[k] = arr[k + 1];
-                }
-              
-              /* Decrement size after removing duplicate element */
-              (*size)--;
-              
-              /* If shifting of elements occur then don't increment j */
-              j--;
-            }
-        }
-    }
-}
-
-void sortListConnectivity(connectivity_int a[], connectivity_int  n)
-{
-  connectivity_int tmp = 0;
-  
-  for (connectivity_int i = 0; i < n; i++)                     //Loop for ascending ordering
-    {
-      for (connectivity_int j = 0; j < n; j++)             //Loop for comparing other values
-        {
-          if (a[j] > a[i])                //Comparing other array elements
-            {
-              tmp = a[i];         //Using temporary variable for storing last value
-              a[i] = a[j];            //replacing value
-              a[j] = tmp;             //storing last value
-            }
-        }
-    }
-  
-}
-
-
-void sortList(connectivity_int ** vector,connectivity_int vectorSize, connectivity_int position)
-{
-  
-  for(connectivity_int ii=0;ii<position;ii++)
-    rotate(*vector, vectorSize);
-  
-}
-
-long findInList(connectivity_int * vector,connectivity_int vectorSize, connectivity_int value)
-{
-  
-  for(connectivity_int ii=0;ii<vectorSize;ii++)
-    {
-      if(vector[ii]==value)
-        {
-          return (long)(ii);
-        }
-    }
-  
-  return -1;
-  
-}
-connectivity_int findMinInList(connectivity_int * vector,connectivity_int vectorSize)
-{
-  
-  connectivity_int              position=0;
-  
-  for(connectivity_int ii=1;ii<vectorSize;ii++)
-    {
-      if(vector[position]>vector[ii])
-        {
-          position=ii;
-        }
-    }
-  
-  return(position);
-}
-
-
-void invertListSort(connectivity_int ** result,connectivity_int * vector,connectivity_int vectorSize)
-{
-  connectivity_int position = 0;
-  
-  for(connectivity_int ii=0;ii<vectorSize;ii++)
-    (*result)[ii] = vector[vectorSize -1 - ii];
-  position = findMinInList((*result),vectorSize);
-  sortList(result, vectorSize, position);
-  
-}
-
-void intersectTwoIntegerSet(connectivity_int ** output , connectivity_int * lenOutput , connectivity_int * inputOne , connectivity_int  lenInputOne , connectivity_int * inputTwo, connectivity_int  lenInputTwo)
-{
-  
-  (*lenOutput)=0;
-  //  affiche("%ld\n",lenInputOne);
-  //  affiche("%ld\n",lenInputTwo);
-  
-  for(connectivity_int posAi=0;posAi<lenInputOne;posAi++)
-    for(connectivity_int posBi=0;posBi<lenInputTwo;posBi++)
-      {
-        if(inputOne[posAi]==inputTwo[posBi])
-          {
-            (*output)[(*lenOutput)] = inputOne[posAi];
-            (*lenOutput)++;
-          }
-      }
-  
-  removeDuplicates((*output), lenOutput);
-}
-
-
-
-void unionTwoIntegerSet(connectivity_int ** output , connectivity_int * lenOutput , connectivity_int * inputOne , connectivity_int  lenInputOne , connectivity_int * inputTwo, connectivity_int  lenInputTwo)
-{
-  
-  (*lenOutput)=0;
-  //  affiche("%ld\n",lenInputOne);
-  //  affiche("%ld\n",lenInputTwo);
-  
-  (*output) = (connectivity_int * ) malloc(sizeof(connectivity_int)*(lenInputOne+lenInputTwo));
-  
-  for(connectivity_int posAi=0;posAi<lenInputOne;posAi++)
-    {
-      (*output)[(*lenOutput)] = inputOne[posAi];
-      (*lenOutput)++;
-    }
-  
-  for(connectivity_int posBi=0;posBi<lenInputTwo;posBi++)
-    {
-      (*output)[(*lenOutput)] = inputTwo[posBi];
-      (*lenOutput)++;
-    }
-  
-  removeDuplicates((*output), lenOutput);
-}
-
-
-void findListFromList(connectivity_int ** matrix, connectivity_int * matrixRowNumbers, connectivity_int size, connectivity_int * whatToFind, connectivity_int sizewhatToFind )
-{
-  
-  //connectivity_int tmp = 0;
-  
-  for (connectivity_int i = 0; i < size; i++)
-    {
-      if(findInList(matrix[i],matrixRowNumbers[i], whatToFind[0])!=-1)
-        {
-          for (connectivity_int j = 0; j < matrixRowNumbers[i]; j++)
-            {
-              
-              for (connectivity_int k=1;k<sizewhatToFind;k++)
-                {
-                  
-                }
-              
-            }
-        }
-    }
-  
-}
-
-
-
-
-//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
-void allocMemoryForMatrixDataType(dataType *** result, connectivity_int N, connectivity_int M )
-{
-  
-  //    affiche("\n");
-  connectivity_int sum=0;
-  
-  (*result) = (dataType **) malloc(N * sizeof(dataType *));
-  if((*result)==NULL)
-    {
-      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-      exit(1);
-    }
-  for(connectivity_int i=0; i<N; i++)
-    {
-      (*result)[i] = (dataType *) malloc(M * sizeof(dataType));
-      memset((*result)[i], 0.0, M*sizeof(connectivity_int));
-      if((*result)[i]==NULL)
-        {
-          debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-          debug_print("i=%ld M=%ld N=%ld  \n",i, M, N);
-          exit(1);
-        }
-    }
-  
-  sum = sizeof(dataType *)*N + M * sizeof(dataType) ;
-  
-  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
-  
-  
-  
-}
-
-//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
-void allocMemoryForVectorDataType(dataType ** result, connectivity_int N )
-{
-  
-  //    affiche("\n");
-  connectivity_int sum=0;
-  
-  (*result) = (dataType *) malloc(N * sizeof(dataType ));
-  if((*result)==NULL)
-    {
-      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-      exit(1);
-    }
-  
-  sum = sizeof(dataType )*N ;
-  
-  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
-  
-  
-  
-}
-
-
-//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
-void allocMemoryForVectorConnectivity(connectivity_int ** result, connectivity_int N )
-{
-  
-  //    affiche("\n");
-  connectivity_int sum=0;
-  
-  (*result) = (connectivity_int *) malloc(N * sizeof(connectivity_int ));
-  if((*result)==NULL)
-    {
-      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-      exit(1);
-    }
-  
-  sum = sizeof(connectivity_int )*N ;
-  
-  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
-  
-  
-  
-}
-
-
-//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
-void allocMemoryForMatrixConnectivity(connectivity_int *** result, connectivity_int N, connectivity_int M )
-{
-  
-  //    affiche("\n");
-  connectivity_int sum=0;
-  
-  (*result) = (connectivity_int **) malloc(N * sizeof(connectivity_int *));
-  if((*result)==NULL)
-    {
-      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-      exit(1);
-    }
-  for(connectivity_int i=0; i<N; i++)
-    {
-      (*result)[i] = (connectivity_int *) malloc(M * sizeof(connectivity_int));
-      memset((*result)[i], 0.0, M*sizeof(connectivity_int));
-      if((*result)[i]==NULL)
-        {
-          debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-          debug_print("i=%ld M=%ld N=%ld  \n",i, M, N);
-          exit(1);
-        }
-    }
-  
-  sum = sizeof(connectivity_int *)*N + M * sizeof(connectivity_int) ;
-  
-  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
-  
-}
-
-
-void allocMemoryForSpecialMatrixConnectivity(connectivity_int *** result, connectivity_int N, connectivity_short *M )
-{
-  
-  connectivity_int sum=0;
-  
-  //    affiche("\n");
-  
-  (*result) = (connectivity_int **) malloc(N * sizeof(connectivity_int *));
-  if((*result)==NULL)
-    {
-      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-      exit(1);
-    }
-  for(connectivity_int i=0; i<N; i++)
-    {
-      (*result)[i] = (connectivity_int *) malloc(M[i] * sizeof(connectivity_int));
-      memset((*result)[i], 0.0, M[i]*sizeof(connectivity_int));
-      sum+=M[i] * sizeof(connectivity_int);
-      
-      if((*result)[i]==NULL) {
-          debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
-          debug_print("i=%ld M=%d N=%ld  \n",i, M[i], N);
-          exit(1);
-        }
-    }
-  sum = sizeof(connectivity_int *)*N + sum ;
-  
-  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
-  
-}
-
-
-//void allocMemory(struct primalMesh * myPrimalMesh)
-//{
-//  clock_t t=startFunction(__FUNCTION__);
-
-
-
-//    myPrimalMesh->vertex = (dataType **) malloc(myPrimalMesh->vertexNumber * sizeof(dataType *));
-//    //ERROR_TEST( (myPrimalMesh->vertex) );
-//    for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-//    {
-//        myPrimalMesh->vertex[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-//        memset(myPrimalMesh->vertex[i], 0.0, DIM3D*sizeof(dataType));
-//    }
-
-//    myPrimalMesh->cellToVertexNumber = (connectivity_short *) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_short));
-
-
-
-//    myPrimalMesh->faceToVertexNumber = (connectivity_short *) malloc(myPrimalMesh->faceNumber * sizeof(connectivity_short));
-
-
-//    myPrimalMesh->faceCentres = (dataType **) malloc(myPrimalMesh->faceNumber * sizeof(dataType *));
-//    for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-//    {
-//        myPrimalMesh->faceCentres[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-//        memset(myPrimalMesh->faceCentres[i], 0.0, DIM3D*sizeof(dataType));
-//    }
-
-//    myPrimalMesh->faceAreas = (dataType **) malloc(myPrimalMesh->faceNumber * sizeof(dataType*));
-//    for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-//    {
-//        myPrimalMesh->faceAreas[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-//        memset(myPrimalMesh->faceAreas[i], 0.0, DIM3D*sizeof(dataType));
-//    }
-
-//    myPrimalMesh->volumeCentroid = (dataType **) malloc(myPrimalMesh->cellNumber * sizeof(dataType*));
-//    for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-//    {
-//        myPrimalMesh->volumeCentroid[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-//        memset(myPrimalMesh->volumeCentroid[i], 0.0, DIM3D*sizeof(dataType));
-//    }
-
-//    //    myPrimalMesh->cellToFacesNumber = (connectivity_short*) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_short));
-
-
-//    myPrimalMesh->volume  = (dataType *) malloc(myPrimalMesh->cellNumber * sizeof(dataType));
-//    memset(myPrimalMesh->volume, 0.0, myPrimalMesh->cellNumber*sizeof(dataType));
-
-
-
-//    myPrimalMesh->segmentToVertex = (connectivity_int **) malloc(myPrimalMesh->segmentNumber * sizeof(connectivity_int*));
-//    for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
-//    {
-//        myPrimalMesh->segmentToVertex[i] = (connectivity_int *) malloc( SEGMENTVERTEX * sizeof(connectivity_int));
-//        memset(myPrimalMesh->segmentToVertex[i], 0.0, SEGMENTVERTEX*sizeof(connectivity_int));
-//    }
-
-
-
-//    myPrimalMesh->faceToSegments = (connectivity_int **) malloc(myPrimalMesh->faceNumber * sizeof(connectivity_int*));
-//    for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-//    {
-//        myPrimalMesh->faceToSegments[i] = (connectivity_int *) malloc( QUAD * sizeof(connectivity_int));
-//        memset(myPrimalMesh->faceToSegments[i], 0.0, QUAD*sizeof(connectivity_int));
-//    }
-
-//    myPrimalMesh->vertexToSegmentNumber  = (connectivity_short *) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_short));
-//    memset(myPrimalMesh->vertexToSegmentNumber, 0.0, myPrimalMesh->vertexNumber*sizeof(connectivity_short));
-
-
-//  endFunction(__FUNCTION__, t);
-
-//}
-
-
-
-//void allocMemory2(struct primalMesh * myPrimalMesh)
-//{
-//  clock_t t=startFunction(__FUNCTION__);
-
-
-//    myPrimalMesh->cellToVertex = (connectivity_int **) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_int *));
-//    for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-//    {
-//        myPrimalMesh->cellToVertex[i] = (connectivity_int *) malloc(myPrimalMesh->cellToVertexNumber[i] * sizeof(connectivity_int));
-//        memset(myPrimalMesh->cellToVertex[i], 0, myPrimalMesh->cellToVertexNumber[i]*sizeof(connectivity_int));
-//    }
-
-//    myPrimalMesh->faceToVertex = (connectivity_int **) malloc(myPrimalMesh->faceNumber * sizeof(connectivity_int *));
-//    for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-//    {
-//        myPrimalMesh->faceToVertex[i] = (connectivity_int *) malloc(myPrimalMesh->faceToVertexNumber[i] * sizeof(connectivity_int));
-//        memset(myPrimalMesh->faceToVertex[i], 0, myPrimalMesh->faceToVertexNumber[i]*sizeof(connectivity_int));
-//    }
-
-//    myPrimalMesh->cellToFaces = (connectivity_int **) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_int *));
-//    for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-//    {
-//        myPrimalMesh->cellToFaces[i] = (connectivity_int *) malloc(myPrimalMesh->cellToFacesNumber[i] * sizeof(connectivity_int));
-//        memset(myPrimalMesh->cellToFaces[i], 0, myPrimalMesh->cellToFacesNumber[i]*sizeof(connectivity_int));
-//    }
-
-
-
-//  endFunction(__FUNCTION__, t);
-
-//}
-
-void freeMemory(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh)
-{
-  clock_t t=startFunction(__FUNCTION__);
-  
-  
-  if(myPrimalMesh->vertex!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-        {
-          if(myPrimalMesh->vertex[i]!=NULL)
-            free(myPrimalMesh->vertex[i]);
-        }
-      free(myPrimalMesh->vertex);
-    }
-  
-  if(myPrimalMesh->cellToVertexNumber!=NULL){
-      free(myPrimalMesh->cellToVertexNumber);
-    }
-  
-  if(myPrimalMesh->cellToVertex!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-        {
-          if(myPrimalMesh->cellToVertex[i]!=NULL)
-            free(myPrimalMesh->cellToVertex[i]);
-        }
-      free(myPrimalMesh->cellToVertex);
-    }
-  
-  if(myPrimalMesh->faceToVertex!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-        {
-          if(myPrimalMesh->faceToVertex[i]!=NULL)
-            free(myPrimalMesh->faceToVertex[i]);
-        }
-      free(myPrimalMesh->faceToVertex);
-    }
-  
-  if(myPrimalMesh->faceToVertexNumber!=NULL){
-      free(myPrimalMesh->faceToVertexNumber);
-    }
-  
-  if(myPrimalMesh->faceCentres!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-        {
-          if(myPrimalMesh->faceCentres[i]!=NULL)
-            free(myPrimalMesh->faceCentres[i]);
-        }
-      free(myPrimalMesh->faceCentres);
-    }
-  
-  
-  if(myPrimalMesh->faceAreas!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-        {
-          if(myPrimalMesh->faceAreas[i]!=NULL)
-            free(myPrimalMesh->faceAreas[i]);
-        }
-      free(myPrimalMesh->faceAreas);
-    }
-  
-  if(myPrimalMesh->cellToFaces!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-        {
-          if(myPrimalMesh->cellToFaces[i]!=NULL)
-            free(myPrimalMesh->cellToFaces[i]);
-        }
-      free(myPrimalMesh->cellToFaces);
-    }
-  
-  if(myPrimalMesh->volumeCentroid!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-        {
-          if(myPrimalMesh->volumeCentroid[i]!=NULL)
-            free(myPrimalMesh->volumeCentroid[i]);
-        }
-      free(myPrimalMesh->volumeCentroid);
-    }
-  
-  if(myPrimalMesh->cellToFacesNumber!=NULL){
-      free(myPrimalMesh->cellToFacesNumber);
-    }
-  
-  if(myPrimalMesh->volume!=NULL){
-      free(myPrimalMesh->volume);
-    }
-  
-  
-  //  if(myPrimalMesh->segmentToVertex!=NULL){
-  //      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
-  //        {
-  //          if(myPrimalMesh->segmentToVertex[i]!=NULL)
-  //            free(myPrimalMesh->segmentToVertex[i]);
-  //        }
-  //      free(myPrimalMesh->segmentToVertex);
-  //    }
-  
-  if(myPrimalMesh->faceToSegments!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-        {
-          if(myPrimalMesh->faceToSegments[i]!=NULL)
-            free(myPrimalMesh->faceToSegments[i]);
-        }
-      free(myPrimalMesh->faceToSegments);
-    }
-  
-  
-  if(myPrimalMesh->vertexToSegmentNumber!=NULL){
-      free(myPrimalMesh->vertexToSegmentNumber);
-    }
-  
-  
-  if(myPrimalMesh->vertexToSegments!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-        {
-          if(myPrimalMesh->vertexToSegments[i]!=NULL)
-            free(myPrimalMesh->vertexToSegments[i]);
-        }
-      free(myPrimalMesh->vertexToSegments);
-    }
-  
-  
-  
-  if(myPrimalMesh->vertexToCells!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-        {
-          if(myPrimalMesh->vertexToCells[i]!=NULL)
-            free(myPrimalMesh->vertexToCells[i]);
-        }
-      free(myPrimalMesh->vertexToCells);
-    }
-  
-  
-  
-  if(myPrimalMesh->vertexToCells!=NULL){
-      
-      free(myPrimalMesh->vertexToCellNumbers);
-    }
-  
-  
-  if(myPrimalMesh->cellToCellsNumbers!=NULL){
-      
-      free(myPrimalMesh->cellToCellsNumbers);
-    }
-  
-  
-  if(myPrimalMesh->cellToCells!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-        {
-          if(myPrimalMesh->cellToCells[i]!=NULL)
-            free(myPrimalMesh->cellToCells[i]);
-        }
-      free(myPrimalMesh->cellToCells);
-    }
-  
-  
-  
-  if(myPrimalMesh->faces!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-        {
-          if(myPrimalMesh->faces[i]!=NULL)
-            free(myPrimalMesh->faces[i]);
-        }
-      free(myPrimalMesh->faces);
-    }
-  
-  
-  if(myPrimalMesh->cellToFacesOwnerNumber!=NULL)
-    free(myPrimalMesh->cellToFacesOwnerNumber);
-  if(myPrimalMesh->cellToFacesNeighbourNumber!=NULL)
-    free(myPrimalMesh->cellToFacesNeighbourNumber);
-  
-  
-  if(myPrimalMesh->cellToFacesNeighbour!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-        {
-          if(myPrimalMesh->cellToFacesNeighbour[i]!=NULL)
-            free(myPrimalMesh->cellToFacesNeighbour[i]);
-        }
-      free(myPrimalMesh->cellToFacesNeighbour);
-    }
-  
-  
-  if(myPrimalMesh->cellToFacesOwner!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-        {
-          if(myPrimalMesh->cellToFacesOwner[i]!=NULL)
-            free(myPrimalMesh->cellToFacesOwner[i]);
-        }
-      free(myPrimalMesh->cellToFacesOwner);
-    }
-  
-  
-  if(myPrimalMesh->segments!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
-        {
-          if(myPrimalMesh->segments[i]!=NULL)
-            free(myPrimalMesh->segments[i]);
-        }
-      free(myPrimalMesh->segments);
-    }
-  
-  
-  
-  if(myPrimalMesh->vertexToSegmentOwner!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-        {
-          if(myPrimalMesh->vertexToSegmentOwner[i]!=NULL)
-            free(myPrimalMesh->vertexToSegmentOwner[i]);
-        }
-      free(myPrimalMesh->vertexToSegmentOwner);
-    }
-  
-  
-  
-  if(myPrimalMesh->vertexToSegmentNeighbour!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-        {
-          if(myPrimalMesh->vertexToSegmentNeighbour[i]!=NULL)
-            free(myPrimalMesh->vertexToSegmentNeighbour[i]);
-        }
-      free(myPrimalMesh->vertexToSegmentNeighbour);
-    }
-  
-  
-  if(myPrimalMesh->vertexToSegmentOwnerNumber!=NULL)
-    free(myPrimalMesh->vertexToSegmentOwnerNumber);
-  if(myPrimalMesh->vertexToSegmentNeighbourNumber!=NULL)
-    free(myPrimalMesh->vertexToSegmentNeighbourNumber);
-  
-  
-  
-  
-  if(myPrimalMesh->segmentToFaceOwnerNumber!=NULL)
-    free(myPrimalMesh->segmentToFaceOwnerNumber);
-  
-  
-  if(myPrimalMesh->segmentToFaceOwner!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
-        {
-          if(myPrimalMesh->segmentToFaceOwner[i]!=NULL)
-            free(myPrimalMesh->segmentToFaceOwner[i]);
-        }
-      free(myPrimalMesh->segmentToFaceOwner);
-    }
-  
-  if(myPrimalMesh->segmentToFaceNeighbourNumber!=NULL)
-    free(myPrimalMesh->segmentToFaceNeighbourNumber);
-  
-  if(myPrimalMesh->segmentToFaceNeighbour!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
-        {
-          if(myPrimalMesh->segmentToFaceNeighbour[i]!=NULL)
-            free(myPrimalMesh->segmentToFaceNeighbour[i]);
-        }
-      free(myPrimalMesh->segmentToFaceNeighbour);
-    }
-  
-  
-  if(myPrimalMesh->faceToCellsNumber!=NULL)
-    free(myPrimalMesh->faceToCellsNumber);
-  
-  if(myPrimalMesh->faceToCells!=NULL){
-      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-        {
-          if(myPrimalMesh->faceToCells[i]!=NULL)
-            free(myPrimalMesh->faceToCells[i]);
-        }
-      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); 
-    }
-  
-  
-  
-  /// DUAL MESH
-  
-  
-  if(myDualMesh->internalDualFaces!=NULL)
-    {
-      for(connectivity_int facei=0;facei<myDualMesh->internalDualFacesNumber;facei++)
-        free(myDualMesh->internalDualFaces[facei]);
-      free(myDualMesh->internalDualFaces);  
-    }
-  
-  
-  
-  if(myDualMesh->segmentToInternalDualFace!=NULL)
-    {
-      for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
-        free(myDualMesh->segmentToInternalDualFace[segmenti]);
-      free(myDualMesh->segmentToInternalDualFace);  
-    }
-  
-  
-  if(myDualMesh->segmentToInternalDualFaceNumber!=NULL)
-    {
-      free(myDualMesh->segmentToInternalDualFaceNumber); 
-    }
-  
-  
-  
-  
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-void setHexahedreVertex(struct primalMesh * myPrimalMesh)
-{
-  
-  //    clock_t t;
-  //    t = clock();
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  // definition des vertex
-  connectivity_int it_vertex=0;
-  //    connectivity_int it_cell=0;
-  
-  dataType L=myPrimalMesh->L/myPrimalMesh->M;
-  dataType l=myPrimalMesh->l/myPrimalMesh->N;
-  dataType H=myPrimalMesh->H/myPrimalMesh->P;
-  
-  allocMemoryForMatrixDataType(&(myPrimalMesh->vertex) , myPrimalMesh->vertexNumber,DIM3D);
-  
-  for(connectivity_int i=0;i<myPrimalMesh->M+1;i++)
-    for(connectivity_int j=0;j<myPrimalMesh->N+1;j++)
-      for(connectivity_int k=0;k<myPrimalMesh->P+1;k++)
-        {
-          it_vertex = k + j*(myPrimalMesh->P+1) +i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-          myPrimalMesh->vertex[it_vertex][0] = i * L;
-          myPrimalMesh->vertex[it_vertex][1] = j * l;
-          myPrimalMesh->vertex[it_vertex][2] = k * H;
-#ifdef DEBUG  
-          debug_print("%-40s : %ld (%f,%f,%f)\n","myPrimalMesh->vertex", it_vertex, myPrimalMesh->vertex[it_vertex][0], myPrimalMesh->vertex[it_vertex][1], myPrimalMesh->vertex[it_vertex][2]);
-#endif
-        }
-  
-  endFunction(__FUNCTION__, t);
-  
-  
-}
-
-void setHexahedreCellToVertexNumber(struct primalMesh * myPrimalMesh)
-{
-  clock_t t=startFunction(__FUNCTION__);
-  
-  // definition des vertex
-  //    connectivity_int it_vertex=0;
-  connectivity_int it_cell=0;
-  
-  
-  myPrimalMesh->cellToVertexNumber = (connectivity_int *) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_int));
-  
-  // hexaedron number of vertex on hexaedron
-  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
-    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
-      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
-        {
-          it_cell     = k + j*myPrimalMesh->P + i*myPrimalMesh->P*myPrimalMesh->N;
-          myPrimalMesh->cellToVertexNumber[it_cell]=HEXAHEDRON;
-          debug_print("%-40s : %ld (%ld)\n","myPrimalMesh->cellToVertexNumber", it_cell, myPrimalMesh->cellToVertexNumber[it_cell] );
-        }
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-//void setHexahedreFaceToVertexNumber(struct primalMesh * myPrimalMesh)
-//{
-//  // vertex number on faces
-//  clock_t t=startFunction(__FUNCTION__);
-
-//  myPrimalMesh->faceToVertexNumber = (connectivity_short *) malloc(myPrimalMesh->faceNumber * sizeof(connectivity_short));
-
-//  for(connectivity_int i=0;i<myPrimalMesh->faceNumber;i++)
-//    {
-
-
-//      myPrimalMesh->faceToVertexNumber[i] = QUAD;
-
-//      debug_print( "%-40s : %ld (%d)\n",
-//                   "myPrimalMesh.faceToVertexNumber",
-//                   i,
-//                   myPrimalMesh->faceToVertexNumber[i]
-//                   );
-
-
-//    }
-//  endFunction(__FUNCTION__, t);
-//}
-
-//void setHexahedreCellToFacesNumber(struct primalMesh * myPrimalMesh)
-//{
-
-//  clock_t t=startFunction(__FUNCTION__);
-
-//  myPrimalMesh->cellToFacesNumber = (connectivity_short*) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_short));
-
-
-//  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
-//    {
-//      if(myPrimalMesh->cellToVertexNumber[i] == HEXAHEDRON)
-//        myPrimalMesh->cellToFacesNumber[i] = HEXAHEDRON_FACES;
-
-//    }
-
-//  for(connectivity_int ii=0;ii<myPrimalMesh->cellNumber;ii++)
-//    {
-//      debug_print( "%-40s : %ld (%d) \n" ,"myPrimalMesh->cellToFacesNumber", ii, myPrimalMesh->cellToFacesNumber[ii]);
-//    }
-//  endFunction(__FUNCTION__, t);
-//}
-
-
-void setHexahedreCellToVertex(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  
-  connectivity_int it_vertex=0;
-  connectivity_int it_vertex2=0;
-  connectivity_int it_vertex3=0;
-  connectivity_int it_vertex4=0;
-  connectivity_int it_vertex5=0;
-  connectivity_int it_vertex6=0;
-  connectivity_int it_vertex7=0;
-  connectivity_int it_vertex8=0;
-  connectivity_int it_cell=0;
-  // cell 0 : 0 1 9 8 / 2 3 11 10
-  // hexaedron vertex number to define hexaedron
-  
-  connectivity_int vN1 = (myPrimalMesh->P+1) ;
-  connectivity_int vN2 = (myPrimalMesh->P+1)*(myPrimalMesh->N+1) ;
-  connectivity_int cN1 = myPrimalMesh->P*myPrimalMesh->N;
-  
-  
-  
-  myPrimalMesh->cellToVertex = (connectivity_int **) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_int *));
-  for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-    {
-      myPrimalMesh->cellToVertex[i] = (connectivity_int *) malloc(myPrimalMesh->cellToVertexNumber[i] * sizeof(connectivity_int));
-      memset(myPrimalMesh->cellToVertex[i], 0, myPrimalMesh->cellToVertexNumber[i]*sizeof(connectivity_int));
-    }
-  
-  
-  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
-    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
-      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
-        {
-          it_cell     = k + j*myPrimalMesh->P + i*cN1; //cN1 = myPrimalMesh->P*myPrimalMesh->N;
-          
-          /*
-*                 it_vertex =   k      + j*(myPrimalMesh->P+1) +i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-            it_vertex2 = (k + 1) + j*(myPrimalMesh->P+1) +i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-            it_vertex3 = (k + 1) + j*(myPrimalMesh->P+1) +(i+1)*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-            it_vertex4 =  k      + j*(myPrimalMesh->P+1) +(i+1)*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-*/
-          it_vertex =   k      + j*vN1 +i*vN2; // vN2 = (myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-          it_vertex2 = it_vertex  + 1;
-          it_vertex3 = it_vertex2 + vN2; // vN2 = (myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-          it_vertex4 = it_vertex3 - 1;
-          
-          myPrimalMesh->cellToVertex[it_cell][0]=it_vertex;
-          myPrimalMesh->cellToVertex[it_cell][1]=it_vertex2;
-          myPrimalMesh->cellToVertex[it_cell][2]=it_vertex3;
-          myPrimalMesh->cellToVertex[it_cell][3]=it_vertex4;
-          
-          
-          
-          it_vertex5 =  k      + (j+1)*vN1 +i*vN2;
-          it_vertex6 = (k + 1) + (j+1)*vN1 +i*vN2;
-          it_vertex7 = (k + 1) + (j+1)*vN1 +(i+1)*vN2;
-          it_vertex8 =  k      + (j+1)*vN1 +(i+1)*vN2;
-          
-          myPrimalMesh->cellToVertex[it_cell][4]=it_vertex5;
-          myPrimalMesh->cellToVertex[it_cell][5]=it_vertex6;
-          myPrimalMesh->cellToVertex[it_cell][6]=it_vertex7;
-          myPrimalMesh->cellToVertex[it_cell][7]=it_vertex8;
-          
-          
-#ifdef DEBUG  
-          
-          debug_print("%-40s : %ld (%ld %ld %ld %ld %ld %ld %ld %ld)\n",
-                      "myPrimalMesh->cellToVertex",
-                      it_cell,
-                      myPrimalMesh->cellToVertex[it_cell][0],
-              myPrimalMesh->cellToVertex[it_cell][1],
-              myPrimalMesh->cellToVertex[it_cell][2],
-              myPrimalMesh->cellToVertex[it_cell][3],
-              myPrimalMesh->cellToVertex[it_cell][4],
-              myPrimalMesh->cellToVertex[it_cell][5],
-              myPrimalMesh->cellToVertex[it_cell][6],
-              myPrimalMesh->cellToVertex[it_cell][7] );
-#endif
-          
-        }
-  endFunction(__FUNCTION__, t);
-}
-
-
-//void setHexahedreFaceToVertex(struct primalMesh * myPrimalMesh)
-//{
-
-//  clock_t t=startFunction(__FUNCTION__);
-//  affiche("\n");
-
-//  connectivity_int it_cell=0;
-
-//  // vertex number on faces
-//  connectivity_int cN1 =  myPrimalMesh->P*myPrimalMesh->N;
-
-//  connectivity_int it_surface=0;
-//  connectivity_int it_face=0;
-
-
-//  allocMemoryForSpecialMatrixConnectivity(&(myPrimalMesh->faceToVertex),myPrimalMesh->faceNumber, myPrimalMesh->faceToVertexNumber);
-
-
-
-//  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
-//    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
-//      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
-//        {
-//          //it_surface = k + j*(myPrimalMesh->P+1) + i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-//          it_cell     = k + j*myPrimalMesh->P + i*cN1; //cN1 = myPrimalMesh->P*myPrimalMesh->N;
-//          it_face     = 0;
-
-//          if(myPrimalMesh->cellToVertexNumber[it_cell] == HEXAHEDRON)
-//            {
-//              connectivity_int vertexList[HEXAHEDRON];
-//              // FACE 1
-//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][0];
-//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][3];
-//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][2];
-//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][1];
-
-//              //                    vertexList[0] = myPrimalMesh->cellToVertex[it_cell][0];
-//              //                    vertexList[1] = myPrimalMesh->cellToVertex[it_cell][3];
-//              //                    vertexList[2] = myPrimalMesh->cellToVertex[it_cell][2];
-//              //                    vertexList[3] = myPrimalMesh->cellToVertex[it_cell][1];
-
-//              //                    // FAIRE TRIER LISTE
-//              //                    // INVERT LISTE et TRIER LISTE
-
-//              //                    myPrimalMesh->faceToVertex[it_surface][0] = vertexList[0];
-//              //                    myPrimalMesh->faceToVertex[it_surface][1] = vertexList[3];
-//              //                    myPrimalMesh->faceToVertex[it_surface][2] = vertexList[2];
-//              //                    myPrimalMesh->faceToVertex[it_surface][3] = vertexList[1];
-
-//              it_surface+=1;
-
-//              // FACE 2
-//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][0];
-//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][1];
-//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][5];
-//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][4];
-
-//              it_surface+=1;
-
-
-//              // FACE 3
-//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][0];
-//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][4];
-//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][7];
-//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][3];
-
-//              it_surface+=1;
-
-
-//              // FACE 4
-//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][1];
-//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][2];
-//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][6];
-//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][5];
-
-//              it_surface+=1;
-
-
-//              // FACE 5
-//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][4];
-//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][5];
-//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][6];
-//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][7];
-
-//              it_surface+=1;
-
-
-//              // FACE 6
-//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][3];
-//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][7];
-//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][6];
-//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][2];
-
-//              it_surface+=1;
-
-//            }
-
-//        }
-
-//  for(connectivity_int k=0;k<myPrimalMesh->faceNumber;k++)
-//    {
-//      debug_print( "%-40s : %ld ( ","myPrimalMesh->faceToVertex", k);
-
-//      for(connectivity_int ii=0;ii<myPrimalMesh->faceToVertexNumber[k];ii++)
-//        {
-//          debug_print( "%ld " , myPrimalMesh->faceToVertex[k][ii]);
-//        }
-//      debug_print(")\n");
-//    }
-
-
-//  endFunction(__FUNCTION__, t);
-
-//}
-
-void setHexahedreVertexToCellNumbers(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  myPrimalMesh->vertexToCellNumbers = (connectivity_int *) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int));
-  memset(myPrimalMesh->vertexToCellNumbers, 0, myPrimalMesh->vertexNumber*sizeof(connectivity_int));
-  
-  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
-    {
-      for(connectivity_int i=0;i<myPrimalMesh->cellToVertexNumber[k];i++)
-        {
-          myPrimalMesh->vertexToCellNumbers[myPrimalMesh->cellToVertex[k][i]]++;
-        }
-    }
-  
-#ifdef DEBUG  
-  
-  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToCellNumbers", k);
-      
-      {
-        debug_print( "%ld " , myPrimalMesh->vertexToCellNumbers[k]);
-      }
-      debug_print(")\n");
-    }
-#endif  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-
-void setHexahedreVertexToCells(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  connectivity_int * tmp ;
-  
-  myPrimalMesh->vertexToCells = (connectivity_int **) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int *));
-  
-  for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-    {
-      myPrimalMesh->vertexToCells[i] = (connectivity_int *) malloc(myPrimalMesh->vertexToCellNumbers[i] * sizeof(connectivity_int));
-      memset(myPrimalMesh->vertexToCells[i], 0, myPrimalMesh->vertexToCellNumbers[i]*sizeof(connectivity_int));
-    }
-  
-  tmp = (connectivity_int *) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int));
-  memset(tmp,0, myPrimalMesh->vertexNumber * sizeof(connectivity_int));
-  
-  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
-    {
-      for(connectivity_int i=0;i<myPrimalMesh->cellToVertexNumber[k];i++)
-        {
-          myPrimalMesh->vertexToCells[myPrimalMesh->cellToVertex[k][i]][tmp[myPrimalMesh->cellToVertex[k][i]]] = k;
-          tmp[myPrimalMesh->cellToVertex[k][i]]++;
-        }
-    }
-  
-  
-  
-  
-#ifdef DEBUG  
-  for(connectivity_int k=0;k<myPrimalMesh->vertexNumber;k++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToCells", k);
-      
-      for(connectivity_int ii=0;ii<myPrimalMesh->vertexToCellNumbers[k];ii++)
-        {
-          debug_print( "%ld " , myPrimalMesh->vertexToCells[k][ii]);
-        }
-      debug_print(")\n");
-    }
-#endif
-  free(tmp);
-  
-  endFunction(__FUNCTION__, t);
-  
-  
-}
-
-
-
-void setHexahedreCellToCells(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  connectivity_int it_cell=0;
-  
-  // vertex number on faces
-  connectivity_int cN1 =  myPrimalMesh->P*myPrimalMesh->N;
-  
-  //  connectivity_int it_face=0;
-  //    connectivity_int it_segment=0;
-  
-  //  allocMemoryForMatrixConnectivity(&(myPrimalMesh->segmentToVertex),myPrimalMesh->segmentNumber,SEGMENTVERTEX);
-  connectivity_int * vertexList= (connectivity_int *) malloc(SEGMENTVERTEX * sizeof(connectivity_int));
-  
-  myPrimalMesh->cellToCells = (connectivity_int **) malloc( (myPrimalMesh->cellNumber) * sizeof(connectivity_int *));
-  myPrimalMesh->cellToCellsNumbers = (connectivity_int *) malloc( (myPrimalMesh->cellNumber) * sizeof(connectivity_int));
-  
-  connectivity_int * cellList  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024*10);
-  
-  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
-    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
-      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
-        {
-          //it_surface = k + j*(myPrimalMesh->P+1) + i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
-          it_cell     = k + j*myPrimalMesh->P + i*cN1; //cN1 = myPrimalMesh->P*myPrimalMesh->N;
-          //          it_face     = 0;
-          
-          if(myPrimalMesh->cellToVertexNumber[it_cell] == HEXAHEDRON)
-            {
-              
-              connectivity_int cellNumbers    = 0 ;
-              connectivity_int vertexSelect   = 0 ;
-              
-              for (connectivity_short vertexi=0;vertexi<HEXAHEDRON;vertexi++)
-                {
-                  
-                  vertexSelect = myPrimalMesh->cellToVertex[it_cell][vertexi];
-                  
-                  for (connectivity_short celli=0;celli<myPrimalMesh->vertexToCellNumbers[vertexSelect];celli++)
-                    {
-                      
-                      if(
-                         findInList(cellList,cellNumbers, myPrimalMesh->vertexToCells[vertexSelect][celli])<0
-                         )
-                        {
-                          
-                          cellList[cellNumbers]=myPrimalMesh->vertexToCells[vertexSelect][celli];
-                          
-                          cellNumbers++;
-                          
-                        }
-                    }
-                  
-                  
-                  /*
-                        debug_print( "%-40s : Celli (%ld)   -> VERTEX (%7ld) -> CELL LIST ( ","cellList", it_cell, vertexSelect);
-                        
-                        for(connectivity_int ii=0;ii<cellNumbers;ii++)
-                        {
-                            debug_print("%ld ",cellList[ii]);
-                        }
-                        
-                        debug_print(")\n");
-*/
-                  
-                }                        //                        cellNumbers+=jj;
-              
-              sortListConnectivity(cellList, cellNumbers);
-              
-              myPrimalMesh->cellToCells[it_cell]=(connectivity_int *) malloc(sizeof (connectivity_int)*cellNumbers);
-              
-              for(connectivity_int kk=0;kk<cellNumbers;kk++)
-                {
-                  myPrimalMesh->cellToCells[it_cell][kk] = cellList[kk];
-                }
-              
-              myPrimalMesh->cellToCellsNumbers[it_cell] = cellNumbers;
-              
-            }
-        }
-  
-#ifdef DEBUG  
-  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
-    {
-      debug_print( "%-40s : %ld (%ld) ( ","myPrimalMesh->cellToCells", k, myPrimalMesh->cellToCellsNumbers[k]);
-      
-      for(connectivity_int ii=0;ii<myPrimalMesh->cellToCellsNumbers[k];ii++)
-        {
-          debug_print( "%ld " , myPrimalMesh->cellToCells[k][ii]);
-        }
-      debug_print(")\n");
-    }
-#endif
-  
-  //  for(connectivity_int k=0;k<myPrimalMesh->segmentNumber;k++)
-  //    {
-  //      debug_print( "%-40s : %ld ( ","myPrimalMesh->segmentToVertex", k);
-  
-  //      for(connectivity_int ii=0;ii<SEGMENTVERTEX;ii++)
-  //        {
-  //          debug_print( "%ld " , myPrimalMesh->segmentToVertex[k][ii]);
-  //        }
-  
-  //      debug_print(")\n");
-  //    }
-  
-  free(cellList);
-  free(vertexList);
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-
-void setHexahedreCellToFacesOwnerNeighbour(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  connectivity_int position;
-  connectivity_int selectedCell;
-  connectivity_int numberOfVertex;
-  
-  connectivity_int * vertexList  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024*10);
-  connectivity_int * vertexListBase  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024);
-  connectivity_int * vertexListInverted  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024);
-  connectivity_int * vertexListInvertedTwo  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024);
-  
-  connectivity_int * cellTest  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
-  memset(cellTest,0,sizeof (connectivity_int)*myPrimalMesh->cellNumber);
-  
-  char ** cellFaceTest  = (char ** ) malloc(sizeof (char*)*myPrimalMesh->cellNumber);
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      cellFaceTest[celli]  = (char * ) malloc(sizeof (char)*HEXAHEDRON_FACES);
-      memset(cellFaceTest[celli],0,sizeof (char)*HEXAHEDRON_FACES);
-    }
-  
-  myPrimalMesh->cellToFacesOwner  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->cellNumber);
-  for (connectivity_int ii=0;ii<myPrimalMesh->cellNumber;ii++) {
-      myPrimalMesh->cellToFacesOwner[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
-    }
-  
-  myPrimalMesh->cellToFacesNeighbour  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->cellNumber);
-  for (connectivity_int ii=0;ii<myPrimalMesh->cellNumber;ii++) {
-      myPrimalMesh->cellToFacesNeighbour[ii]  = NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
-    }
-  
-  myPrimalMesh->cellToFacesOwnerNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
-  memset(myPrimalMesh->cellToFacesOwnerNumber,0,myPrimalMesh->cellNumber*sizeof (connectivity_int) );
-  
-  myPrimalMesh->cellToFacesNeighbourNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
-  memset(myPrimalMesh->cellToFacesNeighbourNumber,0,myPrimalMesh->cellNumber*sizeof (connectivity_int) );
-  
-  
-  //    myPrimalMesh->cellToFacesNeighbour = realloc(myPrimalMesh->cellToFacesNeighbour,sizeof (connectivity_int*)*(myPrimalMesh->cellNumber));
-  //    myPrimalMesh->cellToFacesOwner = realloc(myPrimalMesh->cellToFacesOwner,sizeof (connectivity_int*)*(myPrimalMesh->cellNumber));
-  
-  connectivity_int facesNeighbourCount = 0;
-  connectivity_int facesOwnerCount = 0;
-  
-  
-  for(connectivity_int cellAi=0;cellAi<myPrimalMesh->cellNumber;cellAi++)
-    {
-      if(cellAi % 100000 == 0 && cellAi != 0)
-        release_print( "%-40s :  (%ld)\n","CELLS", cellAi);
-      
-      for (connectivity_int faceAi=0;faceAi<HEXAHEDRON_FACES;faceAi++)
-        {
-          
-          for (connectivity_int vertexAi=0;vertexAi<hexaedron_localNodeListNumbers[faceAi];vertexAi++)
-            {
-              vertexListInverted[vertexAi] = myPrimalMesh->cellToVertex[cellAi][ hexaedron_localNodeList[faceAi][hexaedron_localNodeListNumbers[faceAi] -1 - vertexAi] ];
-              vertexListBase[vertexAi] = myPrimalMesh->cellToVertex[cellAi][ hexaedron_localNodeList[faceAi][vertexAi] ];
-            }
-          
-          position = findMinInList(vertexListInverted,hexaedron_localNodeListNumbers[faceAi]);
-          sortList(&vertexListInverted, hexaedron_localNodeListNumbers[faceAi], position);
-          
-          position = findMinInList(vertexListBase,hexaedron_localNodeListNumbers[faceAi]);
-          sortList(&vertexListBase, hexaedron_localNodeListNumbers[faceAi], position);
-          
-          //            if( cellTest[celli]==0)
-          {
-            
-            for(connectivity_int cellBi=0;cellBi<myPrimalMesh->cellToCellsNumbers[cellAi];cellBi++)
-              {
-                
-                selectedCell    = myPrimalMesh->cellToCells[cellAi][cellBi];
-                numberOfVertex  = myPrimalMesh->cellToVertexNumber[selectedCell];
-                
-                
-                for (connectivity_int faceBi=0;faceBi<HEXAHEDRON_FACES;faceBi++)
-                  {
-                    
-                    for (connectivity_int vertexBi=0;vertexBi<hexaedron_localNodeListNumbers[faceBi];vertexBi++)
-                      {
-                        vertexList[vertexBi] = myPrimalMesh->cellToVertex[selectedCell][ hexaedron_localNodeList[faceBi][vertexBi] ];
-                      }
-                    
-                    position = findMinInList(vertexList,hexaedron_localNodeListNumbers[faceBi]);
-                    sortList(&vertexList, hexaedron_localNodeListNumbers[faceBi], position);
-                    
-                    if(memcmp(vertexListBase,vertexList,hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int)) == 0)
-                      {
-                        
-                        if(cellFaceTest[selectedCell][faceBi]==0)
-                          {
-                            cellFaceTest[selectedCell][faceBi]=1;
-                            
-                            facesOwnerCount = (connectivity_int) myPrimalMesh->cellToFacesOwnerNumber[selectedCell];
-                            
-                            myPrimalMesh->faces = (connectivity_int**) realloc(myPrimalMesh->faces,sizeof (connectivity_int*)*(myPrimalMesh->faceNumber+1));
-                            myPrimalMesh->faces[myPrimalMesh->faceNumber] =(connectivity_int*)  malloc(hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int) );
-                            
-                            memcpy( myPrimalMesh->faces[myPrimalMesh->faceNumber], vertexList,hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int) );
-                            
-                            myPrimalMesh->cellToFacesOwner[selectedCell] = (connectivity_int *) realloc(myPrimalMesh->cellToFacesOwner[selectedCell], (facesOwnerCount+1)*sizeof (connectivity_int) );
-                            
-                            myPrimalMesh->cellToFacesOwner[selectedCell][facesOwnerCount] = myPrimalMesh->faceNumber;
-                            myPrimalMesh->cellToFacesOwnerNumber[selectedCell]++;
-                            
-                            myPrimalMesh->faceNumber++;
-                            
-                          }
-                      }
-                    else
-                      {
-                        if(memcmp(vertexListInverted,vertexList,hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int)) == 0)
-                          {
-                            if(cellFaceTest[selectedCell][faceBi]==0)
-                              {
-                                cellFaceTest[selectedCell][faceBi]=-1;
-                                
-                                facesNeighbourCount = (connectivity_int) myPrimalMesh->cellToFacesNeighbourNumber[selectedCell];
-                                
-                                //                                    debug_print("%ld\n",facesNeighbourCount);
-                                
-                                if(myPrimalMesh->cellToFacesNeighbour[selectedCell]==NULL)
-                                  myPrimalMesh->cellToFacesNeighbour[selectedCell] = (connectivity_int*) malloc((facesNeighbourCount+1)*sizeof (connectivity_int) );
-                                else
-                                  myPrimalMesh->cellToFacesNeighbour[selectedCell] = (connectivity_int*) realloc(myPrimalMesh->cellToFacesNeighbour[selectedCell], ((facesNeighbourCount+1)) *sizeof (connectivity_int) );
-                                
-                                connectivity_short testFaceCi = 0;
-                                
-                                //                                for( connectivity_int faceCi= 0; (faceCi<myPrimalMesh->faceNumber) && (testFaceCi == 0) ; faceCi++ )
-                                for( connectivity_int faceCi= (connectivity_int) myPrimalMesh->faceNumber-1; (faceCi>0) && (testFaceCi == 0) ; faceCi-- )
-                                  {
-                                    
-                                    if(memcmp(vertexListBase,myPrimalMesh->faces[faceCi],QUAD*sizeof (connectivity_int))==0)
-                                      {
-                                        testFaceCi = 1;
-                                        myPrimalMesh->cellToFacesNeighbour[selectedCell][facesNeighbourCount]=faceCi;
-                                        myPrimalMesh->cellToFacesNeighbourNumber[selectedCell]++;
-                                      }
-                                  }
-                                
-                              }
-                          }
-                      }
-                  }
-                
-              }
-          }
-          
-          
-          
-          
-          
-          
-        }
-    }
-  
-  free(vertexList);
-  free(vertexListBase);
-  free(vertexListInverted);
-  free(cellTest);
-  free(vertexListInvertedTwo);
-  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    free(cellFaceTest[celli]);
-  free(cellFaceTest);
-  
-#ifdef DEBUG
-  
-  for(connectivity_int k=0;k<myPrimalMesh->faceNumber;k++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->faces", k);
-      
-      for(connectivity_int ii=0;ii<QUAD;ii++)
-        {
-          debug_print( "%ld " , myPrimalMesh->faces[k][ii]);
-        }
-      debug_print(")\n");
-    }
-  
-  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->cellToFacesOwner", celli);
-      
-      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesOwnerNumber[celli];faceAi++)
-        {
-          debug_print( "%ld " , myPrimalMesh->cellToFacesOwner[celli][faceAi]);
-        }
-      debug_print(")\n");
-    }
-  
-  
-  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->cellToFacesNeighbour", k);
-      
-      for(connectivity_int ii=0;ii<myPrimalMesh->cellToFacesNeighbourNumber[k];ii++)
-        {
-          debug_print( "%ld " , myPrimalMesh->cellToFacesNeighbour[k][ii] );
-        }
-      debug_print(")\n");
-    }
-  
-#endif
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-void setHexahedreFaceToCells(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  connectivity_int selectedFace = 0;
-  
-  
-  myPrimalMesh->faceToCells  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->faceNumber);
-  for (connectivity_int ii=0;ii<myPrimalMesh->faceNumber;ii++) {
-      myPrimalMesh->faceToCells[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
-    }
-  
-  myPrimalMesh->faceToCellsNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->faceNumber);
-  memset(myPrimalMesh->faceToCellsNumber,0,myPrimalMesh->faceNumber*sizeof (connectivity_int) );
-  
-  
-  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      
-      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesOwnerNumber[celli];faceAi++)
-        {
-          //          myPrimalMesh->cellToFacesOwner[celli][faceAi];
-          //          debug_print("O: %ld %ld\n",celli, myPrimalMesh->cellToFacesOwner[celli][faceAi]);
-          
-          selectedFace = myPrimalMesh->cellToFacesOwner[celli][faceAi];
-          
-          myPrimalMesh->faceToCells[selectedFace] = (connectivity_int*) realloc(myPrimalMesh->faceToCells[selectedFace],sizeof (connectivity_int)*(myPrimalMesh->faceToCellsNumber[selectedFace]+1));
-          
-          myPrimalMesh->faceToCells[selectedFace][myPrimalMesh->faceToCellsNumber[selectedFace]] = celli;
-          myPrimalMesh->faceToCellsNumber[selectedFace]++;
-          
-        }
-      
-      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesNeighbourNumber[celli];faceAi++)
-        {
-          //          myPrimalMesh->cellToFacesOwner[celli][faceAi];
-          //          debug_print("O: %ld %ld\n",celli, myPrimalMesh->cellToFacesNeighbour[celli][faceAi]);
-          
-          selectedFace = myPrimalMesh->cellToFacesNeighbour[celli][faceAi];
-          
-          myPrimalMesh->faceToCells[selectedFace] = (connectivity_int*) realloc(myPrimalMesh->faceToCells[selectedFace],sizeof (connectivity_int)*(myPrimalMesh->faceToCellsNumber[selectedFace]+1));
-          
-          myPrimalMesh->faceToCells[selectedFace][myPrimalMesh->faceToCellsNumber[selectedFace]] = celli;
-          myPrimalMesh->faceToCellsNumber[selectedFace]++;
-          
-          
-        }
-      
-      
-    }
-  
-  
-#ifdef DEBUG
-  for(connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->faceToCells", faceAi);
-      
-      for(connectivity_int celli=0;celli<myPrimalMesh->faceToCellsNumber[faceAi];celli++)
-        {
-          debug_print( "%ld " , myPrimalMesh->faceToCells[faceAi][celli] );
-        }
-      debug_print(")\n");
-    }
-  
-#endif
-  
-  //  free(copyFace);
-  //  free(vertexList);
-  //  free(vertexListInverted);
-  
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-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__);
-  
-  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 % (int)floor(myPrimalMesh->cellNumber*10/NBAFFICHE) == 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");
-                    }
-                  
-                }
-            }
-        }
-      
-    }
-  
-#ifdef DEBUG  
-  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");
-    }  
-  
-  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 setHexahedreSegmentsCentres(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  myPrimalMesh->segmentCentres = (dataType ** ) malloc(sizeof (dataType*)*myPrimalMesh->segmentNumber);
-  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
-    {
-      myPrimalMesh->segmentCentres[segmenti]  = (dataType * ) malloc(sizeof (dataType)*DIM3D);
-    }
-  
-  
-  for (connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
-    {
-      
-      if(segmenti % 100000 == 0 && segmenti != 0)
-        release_print( "%-40s :  (%ld)\n","SEGMENT", segmenti);
-      
-      myPrimalMesh->segmentCentres[segmenti][0] = (
-            myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT1] ][0]
-          +
-          myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT2] ][0]
-          )/2.0;
-      myPrimalMesh->segmentCentres[segmenti][1] = (
-            myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT1] ][1]
-          +
-          myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT2] ][1]
-          )/2.0;
-      myPrimalMesh->segmentCentres[segmenti][2] = (
-            myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT1] ][2]
-          +
-          myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT2] ][2]
-          )/2.0;
-    }
-  
-#ifdef DEBUG
-  for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
-    {
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->segmentCentres", segmentAi);
-      
-      for(connectivity_int vertexAi=0;vertexAi<DIM3D;vertexAi++)
-        {
-          debug_print( "%lf " , myPrimalMesh->segmentCentres[segmentAi][vertexAi] );
-        }
-      debug_print(")\n");
-    }
-  
-#endif  
-  
-  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);
-  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*)*(myPrimalMesh->cellNumber*6));
-  for (connectivity_int segmentAi=0;segmentAi<(myPrimalMesh->cellNumber*6);segmentAi++)
-    myPrimalMesh->segments[segmentAi]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
-  
-  for (connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
-    //  for (long faceAi=(long)(myPrimalMesh->faceNumber-1);faceAi>=0;faceAi--)
-    {
-      
-      if(faceAi % (int)floor(myPrimalMesh->cellNumber*10/NBAFFICHE) == 0 && faceAi != 0)
-        release_print( "%-40s :  (%ld)\n","FACE", faceAi);
-      
-      
-      memcpy(copyFace,myPrimalMesh->faces[faceAi],sizeof (connectivity_int)*(QUAD));
-      copyFace[QUAD] = copyFace[0];
-      
-      for (connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
-        {
-          
-          vertexList[0] = copyFace[vertexAi];
-          vertexList[1] = copyFace[(vertexAi+1) % QUAD];
-          
-          vertexListInverted[0] = vertexList[1];
-          vertexListInverted[1] = vertexList[0];
-          
-          testSegment = 0;
-          
-          /*
-           * AMELIORATION du temps de calcul :
-           * Augmenter la vitesse de recherche
-           * en incluant une fonction faceToCells puis cellToSegments pour réduire l'impact de la recherche
-           */
-          for (connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber  && testSegment == 0;segmentAi++)
-            {
-              
-              if( vertexList[0] == myPrimalMesh->segments[segmentAi][0])
-                {
-                  if( vertexList[1] == myPrimalMesh->segments[segmentAi][1])
-                    {
-                      testSegment = 1;
-                    }
-                }
-              else
-                if( vertexListInverted[0] == myPrimalMesh->segments[segmentAi][0])
-                  {
-                    if( vertexListInverted[1] == myPrimalMesh->segments[segmentAi][1])
-                      
-                      {
-                        testSegment = 2;
-                      }
-                  }
-            }
-          
-          if(testSegment == 0)
-            {
-              if(myPrimalMesh->cellNumber*HEXAHEDRON_FACES<=myPrimalMesh->segmentNumber)
-                {
-                  myPrimalMesh->segments  = (connectivity_int ** ) realloc(myPrimalMesh->segments, sizeof (connectivity_int*)*(myPrimalMesh->segmentNumber+1));
-                  myPrimalMesh->segments[myPrimalMesh->segmentNumber]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
-                }
-              memcpy(myPrimalMesh->segments[myPrimalMesh->segmentNumber], vertexList, sizeof(connectivity_int)*SEGMENTVERTEX);
-              
-              myPrimalMesh->segmentNumber++;
-            }
-          
-        }
-    }
-  
-#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);
-  
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-
-void setHexahedreVertexToSegments(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 testSegment = 0;
-  
-  myPrimalMesh->vertexToSegmentOwner  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->vertexNumber);
-  for (connectivity_int ii=0;ii<myPrimalMesh->vertexNumber;ii++) {
-      myPrimalMesh->vertexToSegmentOwner[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
-    }
-  
-  myPrimalMesh->vertexToSegmentOwnerNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->vertexNumber);
-  memset(myPrimalMesh->vertexToSegmentOwnerNumber, 0, myPrimalMesh->vertexNumber*sizeof(connectivity_int));
-  
-  myPrimalMesh->vertexToSegmentNeighbour  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->vertexNumber);
-  for (connectivity_int ii=0;ii<myPrimalMesh->vertexNumber;ii++) {
-      myPrimalMesh->vertexToSegmentNeighbour[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
-    }
-  
-  myPrimalMesh->vertexToSegmentNeighbourNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->vertexNumber);
-  memset(myPrimalMesh->vertexToSegmentNeighbourNumber, 0, myPrimalMesh->vertexNumber*sizeof(connectivity_int));
-  
-  
-  connectivity_int pointOwner = 0;
-  connectivity_int pointNeighbour = 0;
-  
-  for (connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
-    {
-      if(segmentAi % (int)floor(myPrimalMesh->cellNumber*10/NBAFFICHE) == 0 && segmentAi!=0)
-        release_print( "%-40s :  (%ld)\n","SEGMENTS", segmentAi);
-      
-      pointOwner = myPrimalMesh->segments[segmentAi][1];
-      
-      myPrimalMesh->vertexToSegmentOwner[pointOwner] = (connectivity_int *) realloc(myPrimalMesh->vertexToSegmentOwner[pointOwner],(myPrimalMesh->vertexToSegmentOwnerNumber[pointOwner]+1)*sizeof (connectivity_int));
-      myPrimalMesh->vertexToSegmentOwner[pointOwner][myPrimalMesh->vertexToSegmentOwnerNumber[pointOwner]] = segmentAi;
-      myPrimalMesh->vertexToSegmentOwnerNumber[pointOwner]++;
-      
-      pointNeighbour = myPrimalMesh->segments[segmentAi][0];
-      
-      myPrimalMesh->vertexToSegmentNeighbour[pointNeighbour] = (connectivity_int *) realloc(myPrimalMesh->vertexToSegmentNeighbour[pointNeighbour],(myPrimalMesh->vertexToSegmentNeighbourNumber[pointNeighbour]+1)*sizeof (connectivity_int));
-      myPrimalMesh->vertexToSegmentNeighbour[pointNeighbour][myPrimalMesh->vertexToSegmentNeighbourNumber[pointNeighbour]] = segmentAi;
-      myPrimalMesh->vertexToSegmentNeighbourNumber[pointNeighbour]++;
-      
-    }
-  
-#ifdef DEBUG
-  for(connectivity_int vertexAi=0;vertexAi<myPrimalMesh->vertexNumber;vertexAi++)
-    {
-      
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToSegmentOwner", vertexAi);
-      
-      for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->vertexToSegmentOwnerNumber[vertexAi];segmentAi++)
-        {
-          debug_print( "%ld " , myPrimalMesh->vertexToSegmentOwner[vertexAi][segmentAi] );
-        }
-      
-      debug_print(")\n");
-      
-    }
-  
-  for(connectivity_int vertexAi=0;vertexAi<myPrimalMesh->vertexNumber;vertexAi++)
-    {
-      
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToSegmentNeighbour", vertexAi);
-      
-      for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->vertexToSegmentNeighbourNumber[vertexAi];segmentAi++)
-        {
-          debug_print( "%ld " , myPrimalMesh->vertexToSegmentNeighbour[vertexAi][segmentAi] );
-        }
-      
-      debug_print(")\n");
-      
-    }
-#endif
-  
-  free(copyFace);
-  free(vertexList);
-  free(vertexListInverted);
-  
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-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 % 100000 == 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));
-  
-  //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 faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
-    {
-      if(faceAi % ((int)(floor(myPrimalMesh->cellNumber*10/NBAFFICHE))) == 0 && faceAi!=0)
-        release_print( "%-40s :  (%ld)\n","FACES", faceAi);
-      
-      memcpy(copyFace,myPrimalMesh->faces[faceAi],sizeof (connectivity_int)*(QUAD));
-      copyFace[QUAD] = copyFace[0];
-      
-      for (connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
-        {
-          connectivity_int testSegment=0;
-          /*
-           * AMELIORATION du temps de calcul :
-           * Augmenter la vitesse de recherche
-           * en incluant une fonction faceToCells puis cellToSegments pour réduire l'impact de la recherche
-           * de segmentToFaceOwner et segmentToFaceNeighbour
-           */
-          for (connectivity_int segmentAi=0 ; segmentAi<myPrimalMesh->segmentNumber && testSegment==0 ;segmentAi++)
-            {
-              
-              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 setDualFaces(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  connectivity_int selectedCell = 0;
-  connectivity_int selectedVertex = 0;
-  connectivity_int * selectedSegments = 0;
-  connectivity_int selectedSegmentNumber = 0;
-  connectivity_int * selectedFaces;
-  connectivity_int   selectedFacesNumber = 0;
-  
-  myDualMesh->internalDualFaces  = (dataType *** ) malloc(sizeof (dataType**)*myDualMesh->internalDualFacesNumber);
-  
-  myDualMesh->segmentToInternalDualFace = (connectivity_int **) malloc(sizeof (connectivity_int*)*myPrimalMesh->segmentNumber);
-  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
-    {
-      myDualMesh->segmentToInternalDualFace[segmenti] = NULL;
-    }  
-  myDualMesh->segmentToInternalDualFaceNumber = (connectivity_int *) malloc(sizeof (connectivity_int)*myPrimalMesh->segmentNumber);
-  memset(myDualMesh->segmentToInternalDualFaceNumber,0,myPrimalMesh->segmentNumber*sizeof (connectivity_int) );
-  
-  
-  connectivity_int * output1;
-  connectivity_int lenOutput1;
-  
-  
-  connectivity_int * output2;
-  connectivity_int lenOutput2;
-  
-  
-  connectivity_int * output3;
-  connectivity_int lenOutput3;
-  
-  output1  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
-  output2  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
-  output3  = (connectivity_int * ) malloc(sizeof (connectivity_int)*MAXSIZECONNECTIVITYVECTOR);
-  
-  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      
-      selectedCell = celli;
-      if(celli % 100000== 0 && celli != 0)
-        release_print( "%-40s :  (%ld)\n","CELL", celli);
-      
-      unionTwoIntegerSet(&selectedFaces, &selectedFacesNumber,
-                         (myPrimalMesh->cellToFacesOwner[celli]) , myPrimalMesh->cellToFacesOwnerNumber[celli] , 
-                         (myPrimalMesh->cellToFacesNeighbour[celli]) , myPrimalMesh->cellToFacesNeighbourNumber[celli]);
-      
-      
-#ifdef DEBUG      
-      debug_print( " ( ");
-      
-      for(connectivity_int vertexi=0;vertexi<selectedFacesNumber;vertexi++)
-        {
-          debug_print( "%ld " , selectedFaces[vertexi] );
-        }
-      debug_print(" )");
-      debug_print(" \n");
-#endif  
-      
-      unionTwoIntegerSet(&selectedSegments, &selectedSegmentNumber,
-                         (myPrimalMesh->cellToSegmentOwner[celli]) , myPrimalMesh->cellToSegmentOwnerNumber[celli] , 
-                         (myPrimalMesh->cellToSegmentNeighbour[celli]) , myPrimalMesh->cellToSegmentNeighbourNumber[celli]);
-      
-      
-      
-      for(connectivity_int segmenti=0;segmenti<selectedSegmentNumber;segmenti++)
-        {
-          // select segments attached to one cell          
-          
-          
-          //          for(connectivity_int facei=0;facei<selectedFacesNumber;facei++)
-          //            {          
-          // select faces attached to one segment
-          // We have to intersect previous set and this one
-          
-          intersectTwoIntegerSet(&output1,&lenOutput1,
-                                 selectedFaces,selectedFacesNumber,
-                                 myPrimalMesh->segmentToFaceOwner[selectedSegments[segmenti]],myPrimalMesh->segmentToFaceOwnerNumber[selectedSegments[segmenti]]
-              );
-          
-          intersectTwoIntegerSet(&output2,&lenOutput2,
-                                 selectedFaces,selectedFacesNumber,
-                                 myPrimalMesh->segmentToFaceNeighbour[selectedSegments[segmenti]],myPrimalMesh->segmentToFaceNeighbourNumber[selectedSegments[segmenti]]
-              );
-          
-          unionTwoIntegerSet(&output3, &lenOutput3,
-                             output1 , lenOutput1 , 
-                             output2 , lenOutput2);
-          
-          
-#ifdef DEBUG
-          
-          debug_print( "Intersect %ld ( ",celli);
-          
-          for(connectivity_int vertexi=0;vertexi<selectedFacesNumber;vertexi++)
-            {
-              debug_print( "%ld " , selectedFaces[vertexi] );
-            }
-          debug_print(" ) ");
-          debug_print( "( ");
-          
-          for(connectivity_int vertexi=0;vertexi<selectedSegmentNumber;vertexi++)
-            {
-              debug_print( "%ld " , selectedSegments[vertexi] );
-            }
-          debug_print(" ) ");
-          debug_print( "( ");
-          
-          for(connectivity_int vertexi=0;vertexi<lenOutput1;vertexi++)
-            {
-              debug_print( "%ld " ,output1[vertexi] );
-            }
-          for(connectivity_int vertexi=0;vertexi<lenOutput2;vertexi++)
-            {
-              debug_print( "%ld " ,output2[vertexi] );
-            }
-          debug_print(" )");
-          debug_print(" \n");
-          
-#endif              
-          
-          if(lenOutput3==2) {
-              //selectedSegments[segmenti]
-              myDualMesh->internalDualFaces = (dataType ***) realloc(myDualMesh->internalDualFaces, (myDualMesh->internalDualFacesNumber+1) * sizeof (dataType**));
-              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber] = (dataType **) malloc( HEXAHEDRON_DUAL_FACE_POINT * sizeof (dataType*));   
-              //              memset(myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber], 0, HEXAHEDRON_DUAL_FACE_POINT*sizeof(connectivity_int));
-              
-              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT1] = (myPrimalMesh->faceCentres[output3[0]]); 
-              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT2] = (myPrimalMesh->volumeCentroid[celli]); 
-              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT3] = (myPrimalMesh->faceCentres[output3[1]]); 
-              myDualMesh->internalDualFaces[myDualMesh->internalDualFacesNumber][PT4] = (myPrimalMesh->segmentCentres[selectedSegments[segmenti]]); 
-              
-              
-              myDualMesh->segmentToInternalDualFace[selectedSegments[segmenti]]= (connectivity_int*) realloc(myDualMesh->segmentToInternalDualFace[selectedSegments[segmenti]] ,sizeof (connectivity_int)*(myDualMesh->segmentToInternalDualFaceNumber[selectedSegments[segmenti]]+1));
-              
-              myDualMesh->segmentToInternalDualFace[selectedSegments[segmenti]][ myDualMesh->segmentToInternalDualFaceNumber[selectedSegments[segmenti]] ] = myDualMesh->internalDualFacesNumber;
-              myDualMesh->segmentToInternalDualFaceNumber[selectedSegments[segmenti]]++;
-              
-              myDualMesh->internalDualFacesNumber++;              
-            }
-          //              else 
-          //                {
-          //                  affiche("Error on setDualFaces definition\n");
-          //                  exit(1);
-          //                }
-        }
-      //        }
-    }
-  
-#ifdef DEBUG
-  
-  
-  
-  for(connectivity_int faceAi=0;faceAi<myDualMesh->internalDualFacesNumber;faceAi++)
-    {
-      
-      debug_print( "%-40s : %ld","myDualMesh->internalDualFaces", faceAi);
-      
-      for(connectivity_int pointi=0;pointi<HEXAHEDRON_DUAL_FACE_POINT;pointi++)
-        {
-          debug_print( " ( ");
-          
-          for(connectivity_int vertexi=0;vertexi<DIM3D;vertexi++)
-            {
-              debug_print( "%lf " , myDualMesh->internalDualFaces[faceAi][pointi][vertexi] );
-            }
-          debug_print(" )");
-        }
-      debug_print(" \n");
-      
-    }
-  
-  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
-    {
-      
-      debug_print( "%-40s : %ld","myDualMesh->segmentToInternalDualFace", segmenti);
-      
-      debug_print( " ( ");
-      
-      
-      for(connectivity_int facei=0;facei<myDualMesh->segmentToInternalDualFaceNumber[segmenti];facei++)
-        {
-          debug_print( "%ld " , myDualMesh->segmentToInternalDualFace[segmenti][facei] );
-        }
-      
-      debug_print(" )");
-      debug_print(" \n");
-      
-    }
-  
-  
-  
-  
-  
-  
-#endif
-  
-  free(output1);
-  free(output2);
-  free(output3);
-  
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-void setDualFacesCentres(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  affiche("\n");
-  
-  connectivity_int actualPoint;
-  connectivity_int nextPoint;
-  
-  dataType *fC;
-
-  dataType  * result1 = (dataType * ) malloc(sizeof (dataType)*DIM3D);
-  dataType  * result2 = (dataType * ) malloc(sizeof (dataType)*DIM3D);
-  dataType    result3 = 0.0;
-  dataType    result4 = 0.0;
-  connectivity_int  face  =0.0;  
-  connectivity_int * segmentVector=NULL;
-  
-  fC =(dataType *) calloc(DIM3D, sizeof(dataType));
-  
-  
-  myDualMesh->internalDualFaceCentres  = (dataType ** ) malloc(sizeof (dataType*)*myDualMesh->internalDualFacesNumber);
-  for(connectivity_int i=0; i<myDualMesh->internalDualFacesNumber; i++)
-    {
-      myDualMesh->internalDualFaceCentres[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-      memset(myDualMesh->internalDualFaceCentres[i], 0.0, DIM3D*sizeof(dataType));
-    }
-  
-  
-  
-  myDualMesh->internalDualFaceArea  = (dataType ** ) malloc(sizeof (dataType*)*myDualMesh->internalDualFacesNumber);
-  for(connectivity_int i=0; i<myDualMesh->internalDualFacesNumber; i++)
-    {
-      myDualMesh->internalDualFaceArea[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-      memset(myDualMesh->internalDualFaceArea[i], 0.0, DIM3D*sizeof(dataType));
-    }
-  
-  
-  for(connectivity_int faceAi=0;faceAi<myDualMesh->internalDualFacesNumber;faceAi++)
-    {
-      if(faceAi % 1000000== 0 && faceAi != 0)
-        release_print( "%-40s :  (%ld)\n","FACE", faceAi);
-      
-      
-      zeroVector(&fC);
-      
-      for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
-        {
-          actualPoint = vertexAi;
-          
-          sumTwoVectors(&fC,fC,myDualMesh->internalDualFaces[faceAi][actualPoint]);
-          
-        }
-      
-      
-      scalarDivVector(&(myDualMesh->internalDualFaceCentres[faceAi]), QUAD,fC);
-      
-#ifdef DEBUG      
-      debug_print( "%-40s : %ld %d ( ","myDualMesh->internalDualFaceCentres Esti", faceAi, QUAD);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , myDualMesh->internalDualFaceCentres[faceAi][ii]);
-        }
-      debug_print(")\n");
-#endif
-      if(QUAD==3) {
-          
-          // Triangle
-          affiche("NON IMPLEMENTED ...");
-          exit(1);
-          
-        }
-      else
-        { //https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C
-          dataType *sumN;
-          dataType sumA       = ZEROSCALAR;
-          dataType *sumAc;
-          
-          dataType *c;
-          dataType a          = ZEROSCALAR;
-          dataType * n       ;
-          
-          dataType *result1;
-          dataType *result2;
-          
-          
-          result1 =(dataType *) calloc(DIM3D, sizeof(dataType));
-          sumN =(dataType *) calloc(DIM3D, sizeof(dataType));
-          sumAc =(dataType *) calloc(DIM3D, sizeof(dataType));
-          c =(dataType *) calloc(DIM3D, sizeof(dataType));
-          n =(dataType *) calloc(DIM3D, sizeof(dataType));
-          result2 =(dataType *) calloc(DIM3D, sizeof(dataType));
-          
-          
-          
-          for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++) 
-            {
-              
-              actualPoint = vertexAi;
-              nextPoint = (vertexAi + 1) % QUAD;
-              
-              sumThreeVectors(&c, (myDualMesh->internalDualFaces[faceAi][actualPoint]), (myDualMesh->internalDualFaces[faceAi][nextPoint]), (myDualMesh->internalDualFaceCentres[faceAi]) );
-              
-              subTwoVectors(&result1, (myDualMesh->internalDualFaces[faceAi][nextPoint]), (myDualMesh->internalDualFaces[faceAi][actualPoint]));
-              subTwoVectors(&result2, (myDualMesh->internalDualFaceCentres[faceAi]), (myDualMesh->internalDualFaces[faceAi][actualPoint]));
-              
-              crossProduct(&n, result1, result2);
-              mag(&(a), n);
-              
-              sumTwoVectors(&sumN, sumN, n);
-              
-              sumA+=a;
-              scalarDotVector(&result1, a, c);
-              sumTwoVectors(&sumAc, sumAc, result1);
-            }
-          
-          if (sumA < SMALL)
-            {
-              zeroVector( &(myDualMesh->internalDualFaceArea[faceAi]) );
-            }
-          else
-            {
-              scalarDotVector(&(myDualMesh->internalDualFaceCentres[faceAi]), 1.0/(3.0*sumA), sumAc); //correct faceCentres after estimating them
-              scalarDotVector(&(myDualMesh->internalDualFaceArea[faceAi]), 0.5, sumN);
-            }
-          
-          
-          free(sumN);
-          free(sumAc);
-          free(c);
-          free(n)       ;
-          free(result1);
-          free(result2);
-          
-        }
-      
-    }
-  
-  // correct direction of seg and area vector of dual mesh
-  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
-    {    
-      segmentVector = myPrimalMesh->segments[segmenti];
-      
-
-      subTwoVectors(&result1, myPrimalMesh->vertex[segmentVector[PT2]], myPrimalMesh->vertex[segmentVector[PT1]]);      
-      
-      for(connectivity_int facei=0;facei<myDualMesh->segmentToInternalDualFaceNumber[segmenti];facei++)
-        {
-          face  = myDualMesh->segmentToInternalDualFace[segmenti][facei];
-          
-          dotProduct(&result4, result1, myDualMesh->internalDualFaceArea[face]) ;     
-          if(result4<0.0)
-            {
-              for(connectivity_int pointi=0;pointi<DIM3D;pointi++)
-                {
-                  myDualMesh->internalDualFaceArea[face][pointi] *= -1.0;
-                }              
-            }
-        }
-      
-      
-#ifdef DEBUG      
-      
-      dotProduct(&result4, result1, myDualMesh->internalDualFaceArea[face]) ;     
-
-      debug_print( "%-40s : %ld ( ","VECTOR", segmenti);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , result1[ii]);
-        }
-      
-      debug_print(") ");     
-      
-      debug_print( "%lf ", result4);
-      
-      debug_print("\n");      
-#endif      
-    }
-  
-  
-  
-  
-  
-  
-  
-#ifdef DEBUG     
-  for(connectivity_int faceAi=0;faceAi<myDualMesh->internalDualFacesNumber;faceAi++)
-    {          
-      debug_print( "%-40s : %ld %d ( ","myDualMesh->internalDualFaceCentres", faceAi, QUAD);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , myDualMesh->internalDualFaceCentres[faceAi][ii]);
-        }
-      
-      debug_print(")\n");
-      
-      debug_print( "%-40s : %ld ( ","myDualMesh->internalDualFaceArea", faceAi);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , myDualMesh->internalDualFaceArea[faceAi][ii]);
-        }
-      
-      debug_print(")\n");
-    }     
-#endif          
-  
-  
-  free(result1);
-  free(result2);
-  free(fC);    
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-
-void setHexahedreSortFaceToVertex(struct primalMesh * myPrimalMesh)
-{
-  //////////////////// TRIE LES NOEUDS
-  
-  clock_t t=startFunction(__FUNCTION__);
-  
-  //    connectivity_int actualPoint;
-  //    connectivity_int nextPoint;
-  
-  // on trie les noeund dans les faces
-  for(connectivity_int k=0;k<myPrimalMesh->faceNumber;k++)
-    {
-      connectivity_int              position=0;
-      
-      
-      for(connectivity_int ii=1;ii<myPrimalMesh->faceToVertexNumber[k];ii++)
-        {
-          if(myPrimalMesh->faceToVertex[k][position]>myPrimalMesh->faceToVertex[k][ii])
-            {
-              position=ii;
-            }
-        }
-      
-      for(connectivity_int ii=0;ii<position;ii++)
-        rotate(myPrimalMesh->faceToVertex[k], myPrimalMesh->faceToVertexNumber[k]);
-      
-      
-    }
-  
-  
-  
-  
-  //        for(conctivity_int k=0;k<myPrimalMesh->faceNumber;k++)
-  //        {
-  //            conctivity_int it_surface=0;
-  //            int             bool=0;
-  //            do
-  //            {
-  //                for(conctivity_int ii=0;ii<myPrimalMesh->faceToVertexNumber[k];ii++)
-  //                {
-  //                    //     ((ii + 1) % myPrimalMesh->faceToVertexNumber[k]) ;
-  
-  //                    if(myPrimalMesh->faceToVertex[k][ii] == myPrimalMesh->faceToVertex[it_surface][0])
-  //                    {
-  //                        bool = 1;
-  //                        debug_print("TROUVE : (%ld) myPrimalMesh->faceToVertex[%ld][%ld] = %ld\n", it_surface,k,ii,myPrimalMesh->faceToVertex[k][ii])
-  //                    }
-  //                }
-  //                it_surface++;
-  //            }
-  //            while( (it_surface<myPrimalMesh->faceNumber) && (bool == 0) );
-  //        }
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-void setHexahedreAllocVertexToSegment(struct primalMesh * myPrimalMesh)
-{
-  
-  
-  clock_t t=startFunction(__FUNCTION__);
-  
-  
-  
-  myPrimalMesh->vertexToSegments = (connectivity_int **) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int*));
-  for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
-    {
-      myPrimalMesh->vertexToSegments[i] = (connectivity_int *) malloc( myPrimalMesh->vertexToSegmentNumber[i] * sizeof(connectivity_int));
-      memset(myPrimalMesh->vertexToSegments[i], 0.0, QUAD*sizeof(connectivity_int));
-    }
-  
-  
-#ifdef DEBUG  
-  for(connectivity_int i=0;i<myPrimalMesh->vertexNumber;i++)
-    {
-      
-      debug_print("%-40s : %ld (%ld)\n",
-                  "myPrimalMesh->vertexToSegmentNumber",
-                  i,
-                  myPrimalMesh->vertexToSegmentNumber[i]
-                  );
-    }
-#endif
-  endFunction(__FUNCTION__, t);
-}
-
-void setHexahedreFaceCentersAreas(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  
-  connectivity_int actualPoint;
-  connectivity_int nextPoint;
-  
-  dataType *fC;
-  
-  
-  fC =(dataType *) calloc(DIM3D, sizeof(dataType));
-  
-  myPrimalMesh->faceCentres = (dataType **) malloc(myPrimalMesh->faceNumber * sizeof(dataType *));
-  for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-    {
-      myPrimalMesh->faceCentres[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-      memset(myPrimalMesh->faceCentres[i], 0.0, DIM3D*sizeof(dataType));
-    }
-  
-  myPrimalMesh->faceAreas = (dataType **) malloc(myPrimalMesh->faceNumber * sizeof(dataType*));
-  for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
-    {
-      myPrimalMesh->faceAreas[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-      memset(myPrimalMesh->faceAreas[i], 0.0, DIM3D*sizeof(dataType));
-    }
-  
-  
-  for(connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
-    {
-      
-      zeroVector(&fC);
-      
-      for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
-        {
-          actualPoint = myPrimalMesh->faces[faceAi][vertexAi];
-          
-          sumTwoVectors(&fC,fC,myPrimalMesh->vertex[actualPoint]);
-          
-        }
-      
-      
-      scalarDivVector(&(myPrimalMesh->faceCentres[faceAi]), QUAD,fC);
-      
-#ifdef DEBUG      
-      debug_print( "%-40s : %ld %d ( ","myPrimalMesh->faceCentres Estimated", faceAi, QUAD);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , myPrimalMesh->faceCentres[faceAi][ii]);
-        }
-#endif
-      debug_print(")\n");
-      if(QUAD==3) {
-          
-          // Triangle
-          affiche("NON IMPLEMENTED ...");
-          exit(1);
-          
-        }
-      else
-        { //https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C
-          dataType *sumN;
-          dataType sumA       = ZEROSCALAR;
-          dataType *sumAc;
-          
-          dataType *c;
-          dataType a          = ZEROSCALAR;
-          dataType * n       ;
-          
-          dataType *result1;
-          dataType *result2;
-          
-          
-          result1 =(dataType *) calloc(DIM3D, sizeof(dataType));
-          sumN =(dataType *) calloc(DIM3D, sizeof(dataType));
-          sumAc =(dataType *) calloc(DIM3D, sizeof(dataType));
-          c =(dataType *) calloc(DIM3D, sizeof(dataType));
-          n =(dataType *) calloc(DIM3D, sizeof(dataType));
-          result2 =(dataType *) calloc(DIM3D, sizeof(dataType));
-          
-          
-          
-          for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++) {
-              
-              actualPoint = myPrimalMesh->faces[faceAi][vertexAi];
-              nextPoint = myPrimalMesh->faces[faceAi][(vertexAi + 1) % QUAD];
-              
-              sumThreeVectors(&c, (myPrimalMesh->vertex[actualPoint]), (myPrimalMesh->vertex[nextPoint]), (myPrimalMesh->faceCentres[faceAi]) );
-              
-              subTwoVectors(&result1, (myPrimalMesh->vertex[nextPoint]), (myPrimalMesh->vertex[actualPoint]));
-              subTwoVectors(&result2, (myPrimalMesh->faceCentres[faceAi]), (myPrimalMesh->vertex[actualPoint]));
-              
-              crossProduct(&n, result1, result2);
-              mag(&(a), n);
-              
-              sumTwoVectors(&sumN, sumN, n);
-              
-              sumA+=a;
-              scalarDotVector(&result1, a, c);
-              sumTwoVectors(&sumAc, sumAc, result1);
-            }
-          
-          if (sumA < SMALL)
-            {
-              zeroVector( &(myPrimalMesh->faceAreas[faceAi]) );
-            }
-          else
-            {
-              scalarDotVector(&(myPrimalMesh->faceCentres[faceAi]), 1.0/(3.0*sumA), sumAc); //correct faceCentres after estimating them
-              scalarDotVector(&(myPrimalMesh->faceAreas[faceAi]), 0.5, sumN);
-            }
-          
-          free(sumN);
-          free(sumAc);
-          free(c);
-          free(n)       ;
-          free(result1);
-          free(result2);
-          
-        }
-      
-    }
-  
-#ifdef DEBUG
-  for(connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
-    {
-      debug_print( "%-40s : %ld %d ( ","myPrimalMesh->faceCentres", faceAi, QUAD);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , myPrimalMesh->faceCentres[faceAi][ii]);
-        }
-      
-      debug_print(")\n");
-      
-      debug_print( "%-40s : %ld ( ","myPrimalMesh->faceAreas", faceAi);
-      
-      for(connectivity_int ii=0;ii<DIM3D;ii++)
-        {
-          debug_print( "%lf " , myPrimalMesh->faceAreas[faceAi][ii]);
-        }
-      
-      debug_print(")\n");
-    }
-#endif
-  
-  free(fC);
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-void setHexahedreEstimateVolumeCentroid(struct primalMesh * myPrimalMesh)
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  
-  
-  dataType *result;
-  
-  // vertex number on faces
-  
-  connectivity_int it_faceOwner,it_faceNeighbour;
-  
-  result =(dataType *) calloc(DIM3D, sizeof(dataType));
-  
-  myPrimalMesh->volumeCentroid = (dataType **) malloc(myPrimalMesh->cellNumber * sizeof(dataType*));
-  for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
-    {
-      myPrimalMesh->volumeCentroid[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
-      memset(myPrimalMesh->volumeCentroid[i], 0.0, DIM3D*sizeof(dataType));
-    }
-  
-  //    myPrimalMesh->cellToFacesNumber = (connectivity_short*) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_short));
-  
-  
-  myPrimalMesh->volume  = (dataType *) malloc(myPrimalMesh->cellNumber * sizeof(dataType));
-  memset(myPrimalMesh->volume, 0.0, myPrimalMesh->cellNumber*sizeof(dataType));
-  
-  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      
-      zeroVector(&result);
-      
-      for (connectivity_int ii=0;ii<myPrimalMesh->cellToFacesOwnerNumber[celli];ii++)
-        {
-          it_faceOwner = myPrimalMesh->cellToFacesOwner[celli][ii];
-          
-          
-          sumTwoVectors(&result, result, (myPrimalMesh->faceCentres[it_faceOwner]) );
-          
-        }
-      
-      for (connectivity_int ii=0;ii<myPrimalMesh->cellToFacesNeighbourNumber[celli];ii++)
-        {
-          it_faceNeighbour = myPrimalMesh->cellToFacesNeighbour[celli][ii];
-          
-          sumTwoVectors(&result, result, (myPrimalMesh->faceCentres[it_faceNeighbour]) );
-          
-        }
-      scalarDivVector(&(myPrimalMesh->volumeCentroid[celli]) , myPrimalMesh->cellToFacesNeighbourNumber[celli]+myPrimalMesh->cellToFacesOwnerNumber[celli], result);
-      
-    }
-  
-#ifdef DEBUG  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      
-      
-      debug_print("%-40s : %ld (%lf %lf %lf)\n",
-                  "myPrimalMesh->volumeCentroid Estimated",
-                  celli,
-                  myPrimalMesh->volumeCentroid[celli][0],
-          myPrimalMesh->volumeCentroid[celli][1],
-          myPrimalMesh->volumeCentroid[celli][2]
-          );
-    }
-#endif  
-  
-  free(result);
-  endFunction(__FUNCTION__, t);
-  
-}
-
-
-void setHexahedreVolumeCentroid(struct primalMesh * myPrimalMesh)
-{
-  clock_t t=startFunction(__FUNCTION__);
-  
-  //  connectivity_int  it_cell=0;
-  dataType        *cellCentroid;
-  dataType        pyr3Vol=0.0;
-  dataType        *result1;
-  dataType        *result2;
-  dataType        *result3;
-  
-  result1 =(dataType *) calloc(DIM3D, sizeof(dataType));
-  result2 =(dataType *) calloc(DIM3D, sizeof(dataType));
-  result3 =(dataType *) calloc(DIM3D, sizeof(dataType));
-  cellCentroid  =(dataType *) calloc(DIM3D, sizeof(dataType));
-  
-  // vertex number on faces
-  connectivity_int it_face;
-  
-  // Estimate centroids
-  setHexahedreEstimateVolumeCentroid(myPrimalMesh);
-  
-  
-  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
-    {
-      
-      equalVector(&cellCentroid, myPrimalMesh->volumeCentroid[celli]);
-      
-      zeroVector(&(myPrimalMesh->volumeCentroid[celli]));
-      
-      for (connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesOwnerNumber[celli];faceAi++)
-        {
-          it_face = myPrimalMesh->cellToFacesOwner[celli][faceAi];
-          
-          subTwoVectors( &result1, myPrimalMesh->faceCentres[it_face], cellCentroid );
-          
-          dotProduct(&pyr3Vol,myPrimalMesh->faceAreas[it_face], result1);
-          
-          scalarDotVector(&result1, 3.0/4.0, myPrimalMesh->faceCentres[it_face]); //
-          scalarDotVector(&result2, 1.0/4.0, cellCentroid); //
-          
-          sumTwoVectors(&result3,result1,result2);
-          
-          scalarDotVector(&result1,pyr3Vol,result3);
-          
-          sumTwoVectors(&(myPrimalMesh->volumeCentroid[celli]),myPrimalMesh->volumeCentroid[celli],result1);
-          
-          (myPrimalMesh->volume[celli])+=pyr3Vol;
-          
-        }
-      
-      for (connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesNeighbourNumber[celli];faceAi++)
-        {
-          it_face = myPrimalMesh->cellToFacesNeighbour[celli][faceAi];
-          
-          subTwoVectors( &result1, cellCentroid , myPrimalMesh->faceCentres[it_face]);
-          
-          dotProduct(&pyr3Vol,myPrimalMesh->faceAreas[it_face], result1);
-          
-          scalarDotVector(&result1, 3.0/4.0, myPrimalMesh->faceCentres[it_face]); //
-          scalarDotVector(&result2, 1.0/4.0, cellCentroid); //
-          
-          sumTwoVectors(&result3,result1,result2);
-          
-          scalarDotVector(&result1,pyr3Vol,result3);
-          
-          sumTwoVectors(&(myPrimalMesh->volumeCentroid[celli]),myPrimalMesh->volumeCentroid[celli],result1);
-          
-          (myPrimalMesh->volume[celli])+=pyr3Vol;
-          
-        }
-      
-      
-      
-      dataType fVol = fabs(myPrimalMesh->volume[celli]);
-      if (fVol > VSMALL)
-        {
-          scalarDivVector(&(myPrimalMesh->volumeCentroid[celli]),myPrimalMesh->volume[celli],myPrimalMesh->volumeCentroid[celli]);
-        }
-      else
-        {
-          equalVector(&(myPrimalMesh->volumeCentroid[celli]), cellCentroid);
-        }
-      
-      
-      myPrimalMesh->volume[celli] *= (1.0/3.0);
-      
-#ifdef DEBUG      
-      debug_print("%-40s : %ld (%lf) (%lf %lf %lf)\n",
-                  "myPrimalMesh->volumeCentroid",
-                  celli,
-                  myPrimalMesh->volume[celli],
-                  myPrimalMesh->volumeCentroid[celli][0],
-          myPrimalMesh->volumeCentroid[celli][1],
-          myPrimalMesh->volumeCentroid[celli][2]
-          );
-#endif      
-    }
-  
-  free(result1);
-  free(result2);
-  free(result3);
-  
-  free(cellCentroid);
-  
-  endFunction(__FUNCTION__, t);
-  
-}
-
-void writeVTK(struct primalMesh * myPrimalMesh, struct readWriteVTK * myReadWriteVTK)
-////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Ecriture dans un fichier VTK du PRIMAL
-////////////////////////////////////////////////////////////////////////////////////////////////////////
-{
-  
-  clock_t t=startFunction(__FUNCTION__);
-  
-  myReadWriteVTK->dataName = "Ma Simulation TEST";
-  
-  myReadWriteVTK->handle = fopen("test.vtk", "wt");
-  
-  fprintf(myReadWriteVTK->handle, "# vtk DataFile Version 2.0\n");
-  fprintf(myReadWriteVTK->handle, "%s\n\n", myReadWriteVTK->dataName);
-  
-  fprintf(myReadWriteVTK->handle, "ASCII\n");
-  
-  fprintf(myReadWriteVTK->handle, "DATASET UNSTRUCTURED_GRID\n");
-  
-  fprintf(myReadWriteVTK->handle, "POINTS %ld FLOAT\n",myPrimalMesh->vertexNumber);
-  
-  for (connectivity_int i=0;i<myPrimalMesh->vertexNumber;i++)
-    {
-      fprintf(myReadWriteVTK->handle,"%f %f %f\n"
-              ,myPrimalMesh->vertex[i][0]
-          ,myPrimalMesh->vertex[i][1]
-          ,myPrimalMesh->vertex[i][2]
-          );
-    }
-  
-  fprintf(myReadWriteVTK->handle, "\n");
-  
-  connectivity_int count = 0;
-  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
-    count +=(myPrimalMesh->cellToVertexNumber[i]+1); // +1 = column of line count
-  
-  fprintf(myReadWriteVTK->handle, "CELLS %ld %ld\n",myPrimalMesh->cellNumber, count);
-  
-  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
-    {
-      
-      fprintf(myReadWriteVTK->handle,"%ld ",myPrimalMesh->cellToVertexNumber[i]);
-      for (connectivity_int j=0;j<myPrimalMesh->cellToVertexNumber[i];j++)
-        fprintf(myReadWriteVTK->handle,"%ld ",myPrimalMesh->cellToVertex[i][j]);
-      fprintf(myReadWriteVTK->handle,"\n");
-      
-    }
-  
-  fprintf(myReadWriteVTK->handle, "CELL_TYPES %ld\n",myPrimalMesh->cellNumber);
-  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
-    {
-      
-      if(myPrimalMesh->cellToVertexNumber[i]==HEXAHEDRON)
-        fprintf(myReadWriteVTK->handle,"%d\n",VTK_HEXAHEDRON);
-      else
-        fprintf(myReadWriteVTK->handle,"???\n");
-      
-      
-    }
-  
-  fclose(myReadWriteVTK->handle);
-  
-  endFunction(__FUNCTION__, t);
-  
-}
 
 
 int main (void)
@@ -3413,9 +40,9 @@ int main (void)
   myPrimalMesh.N = 20; // cell number on Y
   myPrimalMesh.P = 20; // cell number on Z
 #else
-  myPrimalMesh.M = 20; // cell number on X
-  myPrimalMesh.N = 20; // cell number on Y
-  myPrimalMesh.P = 20; // cell number on Z
+  myPrimalMesh.M = 200; // cell number on X
+  myPrimalMesh.N = 200; // cell number on Y
+  myPrimalMesh.P = 50; // cell number on Z
   
 #endif
   
@@ -3465,6 +92,8 @@ int main (void)
   myDualMesh.internalDualFaces               = NULL;
   myDualMesh.segmentToInternalDualFace       = NULL;
   myDualMesh.segmentToInternalDualFaceNumber = NULL;
+  myDualMesh.internalDualFaceArea            = NULL;
+  myDualMesh.internalDualFaceCentres         = NULL;
   
   
   
diff --git a/src/memory.c b/src/memory.c
new file mode 100644 (file)
index 0000000..22619d7
--- /dev/null
@@ -0,0 +1,502 @@
+#include "mmd.h"
+#include "memory.h"
+
+
+
+
+void allocMemoryForMatrixDataType(dataType *** result, connectivity_int N, connectivity_int M )
+{
+  
+  //    affiche("\n");
+  connectivity_int sum=0;
+  
+  (*result) = (dataType **) malloc(N * sizeof(dataType *));
+  if((*result)==NULL)
+    {
+      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+      exit(1);
+    }
+  for(connectivity_int i=0; i<N; i++)
+    {
+      (*result)[i] = (dataType *) malloc(M * sizeof(dataType));
+      memset((*result)[i], 0.0, M*sizeof(connectivity_int));
+      if((*result)[i]==NULL)
+        {
+          debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+          debug_print("i=%ld M=%ld N=%ld  \n",i, M, N);
+          exit(1);
+        }
+    }
+  
+  sum = sizeof(dataType *)*N + M * sizeof(dataType) ;
+  
+  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
+  
+  
+  
+}
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForVectorDataType(dataType ** result, connectivity_int N )
+{
+  
+  //    affiche("\n");
+  connectivity_int sum=0;
+  
+  (*result) = (dataType *) malloc(N * sizeof(dataType ));
+  if((*result)==NULL)
+    {
+      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+      exit(1);
+    }
+  
+  sum = sizeof(dataType )*N ;
+  
+  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
+  
+  
+  
+}
+
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForVectorConnectivity(connectivity_int ** result, connectivity_int N )
+{
+  
+  //    affiche("\n");
+  connectivity_int sum=0;
+  
+  (*result) = (connectivity_int *) malloc(N * sizeof(connectivity_int ));
+  if((*result)==NULL)
+    {
+      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+      exit(1);
+    }
+  
+  sum = sizeof(connectivity_int )*N ;
+  
+  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
+  
+  
+  
+}
+
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForMatrixConnectivity(connectivity_int *** result, connectivity_int N, connectivity_int M )
+{
+  
+  //    affiche("\n");
+  connectivity_int sum=0;
+  
+  (*result) = (connectivity_int **) malloc(N * sizeof(connectivity_int *));
+  if((*result)==NULL)
+    {
+      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+      exit(1);
+    }
+  for(connectivity_int i=0; i<N; i++)
+    {
+      (*result)[i] = (connectivity_int *) malloc(M * sizeof(connectivity_int));
+      memset((*result)[i], 0.0, M*sizeof(connectivity_int));
+      if((*result)[i]==NULL)
+        {
+          debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+          debug_print("i=%ld M=%ld N=%ld  \n",i, M, N);
+          exit(1);
+        }
+    }
+  
+  sum = sizeof(connectivity_int *)*N + M * sizeof(connectivity_int) ;
+  
+  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
+  
+}
+
+
+void allocMemoryForSpecialMatrixConnectivity(connectivity_int *** result, connectivity_int N, connectivity_short *M )
+{
+  
+  connectivity_int sum=0;
+  
+  //    affiche("\n");
+  
+  (*result) = (connectivity_int **) malloc(N * sizeof(connectivity_int *));
+  if((*result)==NULL)
+    {
+      debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+      exit(1);
+    }
+  for(connectivity_int i=0; i<N; i++)
+    {
+      (*result)[i] = (connectivity_int *) malloc(M[i] * sizeof(connectivity_int));
+      memset((*result)[i], 0.0, M[i]*sizeof(connectivity_int));
+      sum+=M[i] * sizeof(connectivity_int);
+      
+      if((*result)[i]==NULL) {
+          debug_print("ERROR : %s %d %s\n",__FUNCTION__, __LINE__, __FILE__);
+          debug_print("i=%ld M=%d N=%ld  \n",i, M[i], N);
+          exit(1);
+        }
+    }
+  sum = sizeof(connectivity_int *)*N + sum ;
+  
+  affiche("%-40s : (%10ld bytes) : (%8.2f Mo)\n","Allocated Memory",sum, sum/1024000.0);
+  
+}
+
+
+
+
+void freeMemory(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh)
+{
+  clock_t t=startFunction(__FUNCTION__);
+  
+  
+  if(myPrimalMesh->vertex!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+        {
+          if(myPrimalMesh->vertex[i]!=NULL)
+            free(myPrimalMesh->vertex[i]);
+        }
+      free(myPrimalMesh->vertex);
+    }
+  
+  if(myPrimalMesh->cellToVertexNumber!=NULL){
+      free(myPrimalMesh->cellToVertexNumber);
+    }
+  
+  if(myPrimalMesh->cellToVertex!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+        {
+          if(myPrimalMesh->cellToVertex[i]!=NULL)
+            free(myPrimalMesh->cellToVertex[i]);
+        }
+      free(myPrimalMesh->cellToVertex);
+    }
+  
+  if(myPrimalMesh->faceToVertex!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+        {
+          if(myPrimalMesh->faceToVertex[i]!=NULL)
+            free(myPrimalMesh->faceToVertex[i]);
+        }
+      free(myPrimalMesh->faceToVertex);
+    }
+  
+  if(myPrimalMesh->faceToVertexNumber!=NULL){
+      free(myPrimalMesh->faceToVertexNumber);
+    }
+  
+  if(myPrimalMesh->faceCentres!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+        {
+          if(myPrimalMesh->faceCentres[i]!=NULL)
+            free(myPrimalMesh->faceCentres[i]);
+        }
+      free(myPrimalMesh->faceCentres);
+    }
+  
+  
+  if(myPrimalMesh->faceAreas!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+        {
+          if(myPrimalMesh->faceAreas[i]!=NULL)
+            free(myPrimalMesh->faceAreas[i]);
+        }
+      free(myPrimalMesh->faceAreas);
+    }
+  
+  if(myPrimalMesh->cellToFaces!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+        {
+          if(myPrimalMesh->cellToFaces[i]!=NULL)
+            free(myPrimalMesh->cellToFaces[i]);
+        }
+      free(myPrimalMesh->cellToFaces);
+    }
+  
+  if(myPrimalMesh->volumeCentroid!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+        {
+          if(myPrimalMesh->volumeCentroid[i]!=NULL)
+            free(myPrimalMesh->volumeCentroid[i]);
+        }
+      free(myPrimalMesh->volumeCentroid);
+    }
+  
+  if(myPrimalMesh->cellToFacesNumber!=NULL){
+      free(myPrimalMesh->cellToFacesNumber);
+    }
+  
+  if(myPrimalMesh->volume!=NULL){
+      free(myPrimalMesh->volume);
+    }
+  
+  
+  //  if(myPrimalMesh->segmentToVertex!=NULL){
+  //      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
+  //        {
+  //          if(myPrimalMesh->segmentToVertex[i]!=NULL)
+  //            free(myPrimalMesh->segmentToVertex[i]);
+  //        }
+  //      free(myPrimalMesh->segmentToVertex);
+  //    }
+  
+  if(myPrimalMesh->faceToSegments!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+        {
+          if(myPrimalMesh->faceToSegments[i]!=NULL)
+            free(myPrimalMesh->faceToSegments[i]);
+        }
+      free(myPrimalMesh->faceToSegments);
+    }
+  
+  
+  if(myPrimalMesh->vertexToSegmentNumber!=NULL){
+      free(myPrimalMesh->vertexToSegmentNumber);
+    }
+  
+  
+  if(myPrimalMesh->vertexToSegments!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+        {
+          if(myPrimalMesh->vertexToSegments[i]!=NULL)
+            free(myPrimalMesh->vertexToSegments[i]);
+        }
+      free(myPrimalMesh->vertexToSegments);
+    }
+  
+  
+  
+  if(myPrimalMesh->vertexToCells!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+        {
+          if(myPrimalMesh->vertexToCells[i]!=NULL)
+            free(myPrimalMesh->vertexToCells[i]);
+        }
+      free(myPrimalMesh->vertexToCells);
+    }
+  
+  
+  
+  if(myPrimalMesh->vertexToCells!=NULL){
+      
+      free(myPrimalMesh->vertexToCellNumbers);
+    }
+  
+  
+  if(myPrimalMesh->cellToCellsNumbers!=NULL){
+      
+      free(myPrimalMesh->cellToCellsNumbers);
+    }
+  
+  
+  if(myPrimalMesh->cellToCells!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+        {
+          if(myPrimalMesh->cellToCells[i]!=NULL)
+            free(myPrimalMesh->cellToCells[i]);
+        }
+      free(myPrimalMesh->cellToCells);
+    }
+  
+  
+  
+  if(myPrimalMesh->faces!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+        {
+          if(myPrimalMesh->faces[i]!=NULL)
+            free(myPrimalMesh->faces[i]);
+        }
+      free(myPrimalMesh->faces);
+    }
+  
+  
+  if(myPrimalMesh->cellToFacesOwnerNumber!=NULL)
+    free(myPrimalMesh->cellToFacesOwnerNumber);
+  if(myPrimalMesh->cellToFacesNeighbourNumber!=NULL)
+    free(myPrimalMesh->cellToFacesNeighbourNumber);
+  
+  
+  if(myPrimalMesh->cellToFacesNeighbour!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+        {
+          if(myPrimalMesh->cellToFacesNeighbour[i]!=NULL)
+            free(myPrimalMesh->cellToFacesNeighbour[i]);
+        }
+      free(myPrimalMesh->cellToFacesNeighbour);
+    }
+  
+  
+  if(myPrimalMesh->cellToFacesOwner!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+        {
+          if(myPrimalMesh->cellToFacesOwner[i]!=NULL)
+            free(myPrimalMesh->cellToFacesOwner[i]);
+        }
+      free(myPrimalMesh->cellToFacesOwner);
+    }
+  
+  
+  if(myPrimalMesh->segments!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
+        {
+          if(myPrimalMesh->segments[i]!=NULL)
+            free(myPrimalMesh->segments[i]);
+        }
+      free(myPrimalMesh->segments);
+    }
+  
+  
+  
+  if(myPrimalMesh->vertexToSegmentOwner!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+        {
+          if(myPrimalMesh->vertexToSegmentOwner[i]!=NULL)
+            free(myPrimalMesh->vertexToSegmentOwner[i]);
+        }
+      free(myPrimalMesh->vertexToSegmentOwner);
+    }
+  
+  
+  
+  if(myPrimalMesh->vertexToSegmentNeighbour!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+        {
+          if(myPrimalMesh->vertexToSegmentNeighbour[i]!=NULL)
+            free(myPrimalMesh->vertexToSegmentNeighbour[i]);
+        }
+      free(myPrimalMesh->vertexToSegmentNeighbour);
+    }
+  
+  
+  if(myPrimalMesh->vertexToSegmentOwnerNumber!=NULL)
+    free(myPrimalMesh->vertexToSegmentOwnerNumber);
+  if(myPrimalMesh->vertexToSegmentNeighbourNumber!=NULL)
+    free(myPrimalMesh->vertexToSegmentNeighbourNumber);
+  
+  
+  
+  
+  if(myPrimalMesh->segmentToFaceOwnerNumber!=NULL)
+    free(myPrimalMesh->segmentToFaceOwnerNumber);
+  
+  
+  if(myPrimalMesh->segmentToFaceOwner!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
+        {
+          if(myPrimalMesh->segmentToFaceOwner[i]!=NULL)
+            free(myPrimalMesh->segmentToFaceOwner[i]);
+        }
+      free(myPrimalMesh->segmentToFaceOwner);
+    }
+  
+  if(myPrimalMesh->segmentToFaceNeighbourNumber!=NULL)
+    free(myPrimalMesh->segmentToFaceNeighbourNumber);
+  
+  if(myPrimalMesh->segmentToFaceNeighbour!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
+        {
+          if(myPrimalMesh->segmentToFaceNeighbour[i]!=NULL)
+            free(myPrimalMesh->segmentToFaceNeighbour[i]);
+        }
+      free(myPrimalMesh->segmentToFaceNeighbour);
+    }
+  
+  if(myPrimalMesh->segmentCentres!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->segmentNumber; i++)
+        {
+          if(myPrimalMesh->segmentCentres[i]!=NULL)
+            free(myPrimalMesh->segmentCentres[i]);
+        }
+      free(myPrimalMesh->segmentCentres);
+    }
+  
+  if(myPrimalMesh->faceToCellsNumber!=NULL)
+    free(myPrimalMesh->faceToCellsNumber);
+  
+  if(myPrimalMesh->faceToCells!=NULL){
+      for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+        {
+          if(myPrimalMesh->faceToCells[i]!=NULL)
+            free(myPrimalMesh->faceToCells[i]);
+        }
+      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); 
+    }
+  
+  
+  
+  /// DUAL MESH
+  
+  
+  if(myDualMesh->internalDualFaces!=NULL)
+    {
+      for(connectivity_int facei=0;facei<myDualMesh->internalDualFacesNumber;facei++)
+        free(myDualMesh->internalDualFaces[facei]);
+      free(myDualMesh->internalDualFaces);  
+    }
+  
+  
+  
+  if(myDualMesh->segmentToInternalDualFace!=NULL)
+    {
+      for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
+        free(myDualMesh->segmentToInternalDualFace[segmenti]);
+      free(myDualMesh->segmentToInternalDualFace);  
+    }
+  
+  
+  if(myDualMesh->segmentToInternalDualFaceNumber!=NULL)
+    {
+      free(myDualMesh->segmentToInternalDualFaceNumber); 
+    }
+  
+  
+  if(myDualMesh->internalDualFaceArea!=NULL)
+    {
+      for(connectivity_int facei=0;facei<myDualMesh->internalDualFacesNumber;facei++)
+        free(myDualMesh->internalDualFaceArea[facei]);
+      free(myDualMesh->internalDualFaceArea);  
+    }
+  
+
+  
+  if(myDualMesh->internalDualFaceCentres!=NULL)
+    {
+      for(connectivity_int facei=0;facei<myDualMesh->internalDualFacesNumber;facei++)
+        free(myDualMesh->internalDualFaceCentres[facei]);
+      free(myDualMesh->internalDualFaceCentres);  
+    }
+  
+
+   
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
diff --git a/src/memory.h b/src/memory.h
new file mode 100644 (file)
index 0000000..08025a9
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef MEMORY_H
+#define MEMORY_H
+
+#include "mmd.h"
+
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForMatrixDataType(dataType *** result, connectivity_int N, connectivity_int M );
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForVectorDataType(dataType ** result, connectivity_int N );
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForVectorConnectivity(connectivity_int ** result, connectivity_int N );
+
+//#define allocMemoryForMatrix(x,y,z) _Generic((x), dataType: allocMemoryForMatrixDataType, char: allocMemoryForMatrixDataType)(x,y,z);
+void allocMemoryForMatrixConnectivity(connectivity_int *** result, connectivity_int N, connectivity_int M );
+
+void freeMemory(struct primalMesh * myPrimalMesh, struct dualMesh * myDualMesh);
+
+#endif // MEMORY_H
diff --git a/src/mmd.c b/src/mmd.c
new file mode 100644 (file)
index 0000000..6e822ab
--- /dev/null
+++ b/src/mmd.c
@@ -0,0 +1,18 @@
+#include "mmd.h"
+
+clock_t startFunction(const char * functionName)
+{
+  affiche("%-40s : Start\n", functionName);
+  
+  return clock();
+}
+
+void endFunction(const char * functionName, clock_t t)
+{
+  t = clock() - t;
+  double time_taken = ((double)t) / CLOCKS_PER_SEC; // in seconds
+  
+  affiche("%-40s : %f seconds to execute\n", functionName, time_taken);
+  
+}
+
index 291b3a0..2259110 100644 (file)
--- a/src/mmd.h
+++ b/src/mmd.h
@@ -1,5 +1,5 @@
-#ifndef INIT_H
-#define INIT_H
+#ifndef MMD_H
+#define MMD_H
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -49,6 +49,13 @@ extern connectivity_int  hexaedron_localSegmentList[HEXAHEDRON_SEGMENTS][SEGMENT
 
 extern connectivity_int  hexaedron_localSegmentsListNumbers[HEXAHEDRON_SEGMENTS];
 
+#define PT1 0
+#define PT2 1
+#define PT3 2
+#define PT4 3
+#define CELL1 0
+#define CELL2 1
+
 struct dualMesh {
 
   connectivity_int    internalDualFacesNumber;
@@ -209,4 +216,8 @@ struct readWriteVTK {
 
 
 
-#endif // INIT_H
+clock_t startFunction(const char * functionName);
+
+void endFunction(const char * functionName, clock_t t);
+
+#endif // MMD_H
diff --git a/src/primal.c b/src/primal.c
new file mode 100644 (file)
index 0000000..93a509e
--- /dev/null
@@ -0,0 +1,2049 @@
+#include "mmd.h"
+#include "primal.h"
+#include "memory.h"
+#include "tensor.h"
+#include "listop.h"
+
+
+DEF_hexaedron_localNodeList
+DEF_hexaedron_localNodeListNumbers
+DEF_hexaedron_localSegmentList
+DEF_hexaedron_localSegmentsListNumbers
+
+void setHexahedreVertex(struct primalMesh * myPrimalMesh)
+{
+  
+  //    clock_t t;
+  //    t = clock();
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  // definition des vertex
+  connectivity_int it_vertex=0;
+  //    connectivity_int it_cell=0;
+  
+  dataType L=myPrimalMesh->L/myPrimalMesh->M;
+  dataType l=myPrimalMesh->l/myPrimalMesh->N;
+  dataType H=myPrimalMesh->H/myPrimalMesh->P;
+  
+  allocMemoryForMatrixDataType(&(myPrimalMesh->vertex) , myPrimalMesh->vertexNumber,DIM3D);
+  
+  for(connectivity_int i=0;i<myPrimalMesh->M+1;i++)
+    for(connectivity_int j=0;j<myPrimalMesh->N+1;j++)
+      for(connectivity_int k=0;k<myPrimalMesh->P+1;k++)
+        {
+          it_vertex = k + j*(myPrimalMesh->P+1) +i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+          myPrimalMesh->vertex[it_vertex][0] = i * L;
+          myPrimalMesh->vertex[it_vertex][1] = j * l;
+          myPrimalMesh->vertex[it_vertex][2] = k * H;
+#ifdef DEBUG  
+          debug_print("%-40s : %ld (%f,%f,%f)\n","myPrimalMesh->vertex", it_vertex, myPrimalMesh->vertex[it_vertex][0], myPrimalMesh->vertex[it_vertex][1], myPrimalMesh->vertex[it_vertex][2]);
+#endif
+        }
+  
+  endFunction(__FUNCTION__, t);
+  
+  
+}
+
+void setHexahedreCellToVertexNumber(struct primalMesh * myPrimalMesh)
+{
+  clock_t t=startFunction(__FUNCTION__);
+  
+  // definition des vertex
+  //    connectivity_int it_vertex=0;
+  connectivity_int it_cell=0;
+  
+  
+  myPrimalMesh->cellToVertexNumber = (connectivity_int *) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_int));
+  
+  // hexaedron number of vertex on hexaedron
+  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
+    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
+      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
+        {
+          it_cell     = k + j*myPrimalMesh->P + i*myPrimalMesh->P*myPrimalMesh->N;
+          myPrimalMesh->cellToVertexNumber[it_cell]=HEXAHEDRON;
+          debug_print("%-40s : %ld (%ld)\n","myPrimalMesh->cellToVertexNumber", it_cell, myPrimalMesh->cellToVertexNumber[it_cell] );
+        }
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+//void setHexahedreFaceToVertexNumber(struct primalMesh * myPrimalMesh)
+//{
+//  // vertex number on faces
+//  clock_t t=startFunction(__FUNCTION__);
+
+//  myPrimalMesh->faceToVertexNumber = (connectivity_short *) malloc(myPrimalMesh->faceNumber * sizeof(connectivity_short));
+
+//  for(connectivity_int i=0;i<myPrimalMesh->faceNumber;i++)
+//    {
+
+
+//      myPrimalMesh->faceToVertexNumber[i] = QUAD;
+
+//      debug_print( "%-40s : %ld (%d)\n",
+//                   "myPrimalMesh.faceToVertexNumber",
+//                   i,
+//                   myPrimalMesh->faceToVertexNumber[i]
+//                   );
+
+
+//    }
+//  endFunction(__FUNCTION__, t);
+//}
+
+//void setHexahedreCellToFacesNumber(struct primalMesh * myPrimalMesh)
+//{
+
+//  clock_t t=startFunction(__FUNCTION__);
+
+//  myPrimalMesh->cellToFacesNumber = (connectivity_short*) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_short));
+
+
+//  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
+//    {
+//      if(myPrimalMesh->cellToVertexNumber[i] == HEXAHEDRON)
+//        myPrimalMesh->cellToFacesNumber[i] = HEXAHEDRON_FACES;
+
+//    }
+
+//  for(connectivity_int ii=0;ii<myPrimalMesh->cellNumber;ii++)
+//    {
+//      debug_print( "%-40s : %ld (%d) \n" ,"myPrimalMesh->cellToFacesNumber", ii, myPrimalMesh->cellToFacesNumber[ii]);
+//    }
+//  endFunction(__FUNCTION__, t);
+//}
+
+
+void setHexahedreCellToVertex(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  
+  connectivity_int it_vertex=0;
+  connectivity_int it_vertex2=0;
+  connectivity_int it_vertex3=0;
+  connectivity_int it_vertex4=0;
+  connectivity_int it_vertex5=0;
+  connectivity_int it_vertex6=0;
+  connectivity_int it_vertex7=0;
+  connectivity_int it_vertex8=0;
+  connectivity_int it_cell=0;
+  // cell 0 : 0 1 9 8 / 2 3 11 10
+  // hexaedron vertex number to define hexaedron
+  
+  connectivity_int vN1 = (myPrimalMesh->P+1) ;
+  connectivity_int vN2 = (myPrimalMesh->P+1)*(myPrimalMesh->N+1) ;
+  connectivity_int cN1 = myPrimalMesh->P*myPrimalMesh->N;
+  
+  
+  
+  myPrimalMesh->cellToVertex = (connectivity_int **) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_int *));
+  for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+    {
+      myPrimalMesh->cellToVertex[i] = (connectivity_int *) malloc(myPrimalMesh->cellToVertexNumber[i] * sizeof(connectivity_int));
+      memset(myPrimalMesh->cellToVertex[i], 0, myPrimalMesh->cellToVertexNumber[i]*sizeof(connectivity_int));
+    }
+  
+  
+  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
+    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
+      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
+        {
+          it_cell     = k + j*myPrimalMesh->P + i*cN1; //cN1 = myPrimalMesh->P*myPrimalMesh->N;
+          
+          /*
+*                 it_vertex =   k      + j*(myPrimalMesh->P+1) +i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+            it_vertex2 = (k + 1) + j*(myPrimalMesh->P+1) +i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+            it_vertex3 = (k + 1) + j*(myPrimalMesh->P+1) +(i+1)*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+            it_vertex4 =  k      + j*(myPrimalMesh->P+1) +(i+1)*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+*/
+          it_vertex =   k      + j*vN1 +i*vN2; // vN2 = (myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+          it_vertex2 = it_vertex  + 1;
+          it_vertex3 = it_vertex2 + vN2; // vN2 = (myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+          it_vertex4 = it_vertex3 - 1;
+          
+          myPrimalMesh->cellToVertex[it_cell][0]=it_vertex;
+          myPrimalMesh->cellToVertex[it_cell][1]=it_vertex2;
+          myPrimalMesh->cellToVertex[it_cell][2]=it_vertex3;
+          myPrimalMesh->cellToVertex[it_cell][3]=it_vertex4;
+          
+          
+          
+          it_vertex5 =  k      + (j+1)*vN1 +i*vN2;
+          it_vertex6 = (k + 1) + (j+1)*vN1 +i*vN2;
+          it_vertex7 = (k + 1) + (j+1)*vN1 +(i+1)*vN2;
+          it_vertex8 =  k      + (j+1)*vN1 +(i+1)*vN2;
+          
+          myPrimalMesh->cellToVertex[it_cell][4]=it_vertex5;
+          myPrimalMesh->cellToVertex[it_cell][5]=it_vertex6;
+          myPrimalMesh->cellToVertex[it_cell][6]=it_vertex7;
+          myPrimalMesh->cellToVertex[it_cell][7]=it_vertex8;
+          
+          
+#ifdef DEBUG  
+          
+          debug_print("%-40s : %ld (%ld %ld %ld %ld %ld %ld %ld %ld)\n",
+                      "myPrimalMesh->cellToVertex",
+                      it_cell,
+                      myPrimalMesh->cellToVertex[it_cell][0],
+              myPrimalMesh->cellToVertex[it_cell][1],
+              myPrimalMesh->cellToVertex[it_cell][2],
+              myPrimalMesh->cellToVertex[it_cell][3],
+              myPrimalMesh->cellToVertex[it_cell][4],
+              myPrimalMesh->cellToVertex[it_cell][5],
+              myPrimalMesh->cellToVertex[it_cell][6],
+              myPrimalMesh->cellToVertex[it_cell][7] );
+#endif
+          
+        }
+  endFunction(__FUNCTION__, t);
+}
+
+
+//void setHexahedreFaceToVertex(struct primalMesh * myPrimalMesh)
+//{
+
+//  clock_t t=startFunction(__FUNCTION__);
+//  affiche("\n");
+
+//  connectivity_int it_cell=0;
+
+//  // vertex number on faces
+//  connectivity_int cN1 =  myPrimalMesh->P*myPrimalMesh->N;
+
+//  connectivity_int it_surface=0;
+//  connectivity_int it_face=0;
+
+
+//  allocMemoryForSpecialMatrixConnectivity(&(myPrimalMesh->faceToVertex),myPrimalMesh->faceNumber, myPrimalMesh->faceToVertexNumber);
+
+
+
+//  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
+//    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
+//      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
+//        {
+//          //it_surface = k + j*(myPrimalMesh->P+1) + i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+//          it_cell     = k + j*myPrimalMesh->P + i*cN1; //cN1 = myPrimalMesh->P*myPrimalMesh->N;
+//          it_face     = 0;
+
+//          if(myPrimalMesh->cellToVertexNumber[it_cell] == HEXAHEDRON)
+//            {
+//              connectivity_int vertexList[HEXAHEDRON];
+//              // FACE 1
+//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][0];
+//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][3];
+//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][2];
+//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][1];
+
+//              //                    vertexList[0] = myPrimalMesh->cellToVertex[it_cell][0];
+//              //                    vertexList[1] = myPrimalMesh->cellToVertex[it_cell][3];
+//              //                    vertexList[2] = myPrimalMesh->cellToVertex[it_cell][2];
+//              //                    vertexList[3] = myPrimalMesh->cellToVertex[it_cell][1];
+
+//              //                    // FAIRE TRIER LISTE
+//              //                    // INVERT LISTE et TRIER LISTE
+
+//              //                    myPrimalMesh->faceToVertex[it_surface][0] = vertexList[0];
+//              //                    myPrimalMesh->faceToVertex[it_surface][1] = vertexList[3];
+//              //                    myPrimalMesh->faceToVertex[it_surface][2] = vertexList[2];
+//              //                    myPrimalMesh->faceToVertex[it_surface][3] = vertexList[1];
+
+//              it_surface+=1;
+
+//              // FACE 2
+//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][0];
+//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][1];
+//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][5];
+//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][4];
+
+//              it_surface+=1;
+
+
+//              // FACE 3
+//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][0];
+//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][4];
+//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][7];
+//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][3];
+
+//              it_surface+=1;
+
+
+//              // FACE 4
+//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][1];
+//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][2];
+//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][6];
+//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][5];
+
+//              it_surface+=1;
+
+
+//              // FACE 5
+//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][4];
+//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][5];
+//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][6];
+//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][7];
+
+//              it_surface+=1;
+
+
+//              // FACE 6
+//              myPrimalMesh->faceToVertex[it_surface][0] = myPrimalMesh->cellToVertex[it_cell][3];
+//              myPrimalMesh->faceToVertex[it_surface][1] = myPrimalMesh->cellToVertex[it_cell][7];
+//              myPrimalMesh->faceToVertex[it_surface][2] = myPrimalMesh->cellToVertex[it_cell][6];
+//              myPrimalMesh->faceToVertex[it_surface][3] = myPrimalMesh->cellToVertex[it_cell][2];
+
+//              it_surface+=1;
+
+//            }
+
+//        }
+
+//  for(connectivity_int k=0;k<myPrimalMesh->faceNumber;k++)
+//    {
+//      debug_print( "%-40s : %ld ( ","myPrimalMesh->faceToVertex", k);
+
+//      for(connectivity_int ii=0;ii<myPrimalMesh->faceToVertexNumber[k];ii++)
+//        {
+//          debug_print( "%ld " , myPrimalMesh->faceToVertex[k][ii]);
+//        }
+//      debug_print(")\n");
+//    }
+
+
+//  endFunction(__FUNCTION__, t);
+
+//}
+
+void setHexahedreVertexToCellNumbers(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  myPrimalMesh->vertexToCellNumbers = (connectivity_int *) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int));
+  memset(myPrimalMesh->vertexToCellNumbers, 0, myPrimalMesh->vertexNumber*sizeof(connectivity_int));
+  
+  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
+    {
+      for(connectivity_int i=0;i<myPrimalMesh->cellToVertexNumber[k];i++)
+        {
+          myPrimalMesh->vertexToCellNumbers[myPrimalMesh->cellToVertex[k][i]]++;
+        }
+    }
+  
+#ifdef DEBUG  
+  
+  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToCellNumbers", k);
+      
+      {
+        debug_print( "%ld " , myPrimalMesh->vertexToCellNumbers[k]);
+      }
+      debug_print(")\n");
+    }
+#endif  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+
+void setHexahedreVertexToCells(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  connectivity_int * tmp ;
+  
+  myPrimalMesh->vertexToCells = (connectivity_int **) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int *));
+  
+  for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+    {
+      myPrimalMesh->vertexToCells[i] = (connectivity_int *) malloc(myPrimalMesh->vertexToCellNumbers[i] * sizeof(connectivity_int));
+      memset(myPrimalMesh->vertexToCells[i], 0, myPrimalMesh->vertexToCellNumbers[i]*sizeof(connectivity_int));
+    }
+  
+  tmp = (connectivity_int *) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int));
+  memset(tmp,0, myPrimalMesh->vertexNumber * sizeof(connectivity_int));
+  
+  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
+    {
+      for(connectivity_int i=0;i<myPrimalMesh->cellToVertexNumber[k];i++)
+        {
+          myPrimalMesh->vertexToCells[myPrimalMesh->cellToVertex[k][i]][tmp[myPrimalMesh->cellToVertex[k][i]]] = k;
+          tmp[myPrimalMesh->cellToVertex[k][i]]++;
+        }
+    }
+  
+  
+  
+  
+#ifdef DEBUG  
+  for(connectivity_int k=0;k<myPrimalMesh->vertexNumber;k++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToCells", k);
+      
+      for(connectivity_int ii=0;ii<myPrimalMesh->vertexToCellNumbers[k];ii++)
+        {
+          debug_print( "%ld " , myPrimalMesh->vertexToCells[k][ii]);
+        }
+      debug_print(")\n");
+    }
+#endif
+  free(tmp);
+  
+  endFunction(__FUNCTION__, t);
+  
+  
+}
+
+
+
+void setHexahedreCellToCells(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  connectivity_int it_cell=0;
+  
+  // vertex number on faces
+  connectivity_int cN1 =  myPrimalMesh->P*myPrimalMesh->N;
+  
+  //  connectivity_int it_face=0;
+  //    connectivity_int it_segment=0;
+  
+  //  allocMemoryForMatrixConnectivity(&(myPrimalMesh->segmentToVertex),myPrimalMesh->segmentNumber,SEGMENTVERTEX);
+  connectivity_int * vertexList= (connectivity_int *) malloc(SEGMENTVERTEX * sizeof(connectivity_int));
+  
+  myPrimalMesh->cellToCells = (connectivity_int **) malloc( (myPrimalMesh->cellNumber) * sizeof(connectivity_int *));
+  myPrimalMesh->cellToCellsNumbers = (connectivity_int *) malloc( (myPrimalMesh->cellNumber) * sizeof(connectivity_int));
+  
+  connectivity_int * cellList  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024*10);
+  
+  for(connectivity_int i=0;i<myPrimalMesh->M;i++)
+    for(connectivity_int j=0;j<myPrimalMesh->N;j++)
+      for(connectivity_int k=0;k<myPrimalMesh->P;k++)
+        {
+          //it_surface = k + j*(myPrimalMesh->P+1) + i*(myPrimalMesh->P+1)*(myPrimalMesh->N+1);
+          it_cell     = k + j*myPrimalMesh->P + i*cN1; //cN1 = myPrimalMesh->P*myPrimalMesh->N;
+          //          it_face     = 0;
+          
+          if(myPrimalMesh->cellToVertexNumber[it_cell] == HEXAHEDRON)
+            {
+              
+              connectivity_int cellNumbers    = 0 ;
+              connectivity_int vertexSelect   = 0 ;
+              
+              for (connectivity_short vertexi=0;vertexi<HEXAHEDRON;vertexi++)
+                {
+                  
+                  vertexSelect = myPrimalMesh->cellToVertex[it_cell][vertexi];
+                  
+                  for (connectivity_short celli=0;celli<myPrimalMesh->vertexToCellNumbers[vertexSelect];celli++)
+                    {
+                      
+                      if(
+                         findInList(cellList,cellNumbers, myPrimalMesh->vertexToCells[vertexSelect][celli])<0
+                         )
+                        {
+                          
+                          cellList[cellNumbers]=myPrimalMesh->vertexToCells[vertexSelect][celli];
+                          
+                          cellNumbers++;
+                          
+                        }
+                    }
+                  
+                  
+                  /*
+                        debug_print( "%-40s : Celli (%ld)   -> VERTEX (%7ld) -> CELL LIST ( ","cellList", it_cell, vertexSelect);
+                        
+                        for(connectivity_int ii=0;ii<cellNumbers;ii++)
+                        {
+                            debug_print("%ld ",cellList[ii]);
+                        }
+                        
+                        debug_print(")\n");
+*/
+                  
+                }                        //                        cellNumbers+=jj;
+              
+              sortListConnectivity(cellList, cellNumbers);
+              
+              myPrimalMesh->cellToCells[it_cell]=(connectivity_int *) malloc(sizeof (connectivity_int)*cellNumbers);
+              
+              for(connectivity_int kk=0;kk<cellNumbers;kk++)
+                {
+                  myPrimalMesh->cellToCells[it_cell][kk] = cellList[kk];
+                }
+              
+              myPrimalMesh->cellToCellsNumbers[it_cell] = cellNumbers;
+              
+            }
+        }
+  
+#ifdef DEBUG  
+  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
+    {
+      debug_print( "%-40s : %ld (%ld) ( ","myPrimalMesh->cellToCells", k, myPrimalMesh->cellToCellsNumbers[k]);
+      
+      for(connectivity_int ii=0;ii<myPrimalMesh->cellToCellsNumbers[k];ii++)
+        {
+          debug_print( "%ld " , myPrimalMesh->cellToCells[k][ii]);
+        }
+      debug_print(")\n");
+    }
+#endif
+  
+  //  for(connectivity_int k=0;k<myPrimalMesh->segmentNumber;k++)
+  //    {
+  //      debug_print( "%-40s : %ld ( ","myPrimalMesh->segmentToVertex", k);
+  
+  //      for(connectivity_int ii=0;ii<SEGMENTVERTEX;ii++)
+  //        {
+  //          debug_print( "%ld " , myPrimalMesh->segmentToVertex[k][ii]);
+  //        }
+  
+  //      debug_print(")\n");
+  //    }
+  
+  free(cellList);
+  free(vertexList);
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+
+void setHexahedreCellToFacesOwnerNeighbour(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  connectivity_int position;
+  connectivity_int selectedCell;
+  connectivity_int numberOfVertex;
+  
+  connectivity_int * vertexList  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024*10);
+  connectivity_int * vertexListBase  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024);
+  connectivity_int * vertexListInverted  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024);
+  connectivity_int * vertexListInvertedTwo  = (connectivity_int * ) malloc(sizeof (connectivity_int)*1024);
+  
+  connectivity_int * cellTest  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
+  memset(cellTest,0,sizeof (connectivity_int)*myPrimalMesh->cellNumber);
+  
+  char ** cellFaceTest  = (char ** ) malloc(sizeof (char*)*myPrimalMesh->cellNumber);
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      cellFaceTest[celli]  = (char * ) malloc(sizeof (char)*HEXAHEDRON_FACES);
+      memset(cellFaceTest[celli],0,sizeof (char)*HEXAHEDRON_FACES);
+    }
+  
+  myPrimalMesh->cellToFacesOwner  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->cellNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->cellNumber;ii++) {
+      myPrimalMesh->cellToFacesOwner[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->cellToFacesNeighbour  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->cellNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->cellNumber;ii++) {
+      myPrimalMesh->cellToFacesNeighbour[ii]  = NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->cellToFacesOwnerNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
+  memset(myPrimalMesh->cellToFacesOwnerNumber,0,myPrimalMesh->cellNumber*sizeof (connectivity_int) );
+  
+  myPrimalMesh->cellToFacesNeighbourNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->cellNumber);
+  memset(myPrimalMesh->cellToFacesNeighbourNumber,0,myPrimalMesh->cellNumber*sizeof (connectivity_int) );
+  
+  
+  //    myPrimalMesh->cellToFacesNeighbour = realloc(myPrimalMesh->cellToFacesNeighbour,sizeof (connectivity_int*)*(myPrimalMesh->cellNumber));
+  //    myPrimalMesh->cellToFacesOwner = realloc(myPrimalMesh->cellToFacesOwner,sizeof (connectivity_int*)*(myPrimalMesh->cellNumber));
+  
+  connectivity_int facesNeighbourCount = 0;
+  connectivity_int facesOwnerCount = 0;
+  
+  
+  for(connectivity_int cellAi=0;cellAi<myPrimalMesh->cellNumber;cellAi++)
+    {
+      if(cellAi % 100000 == 0 && cellAi != 0)
+        release_print( "%-40s :  (%ld)\n","CELLS", cellAi);
+      
+      for (connectivity_int faceAi=0;faceAi<HEXAHEDRON_FACES;faceAi++)
+        {
+          
+          for (connectivity_int vertexAi=0;vertexAi<hexaedron_localNodeListNumbers[faceAi];vertexAi++)
+            {
+              vertexListInverted[vertexAi] = myPrimalMesh->cellToVertex[cellAi][ hexaedron_localNodeList[faceAi][hexaedron_localNodeListNumbers[faceAi] -1 - vertexAi] ];
+              vertexListBase[vertexAi] = myPrimalMesh->cellToVertex[cellAi][ hexaedron_localNodeList[faceAi][vertexAi] ];
+            }
+          
+          position = findMinInList(vertexListInverted,hexaedron_localNodeListNumbers[faceAi]);
+          sortList(&vertexListInverted, hexaedron_localNodeListNumbers[faceAi], position);
+          
+          position = findMinInList(vertexListBase,hexaedron_localNodeListNumbers[faceAi]);
+          sortList(&vertexListBase, hexaedron_localNodeListNumbers[faceAi], position);
+          
+          //            if( cellTest[celli]==0)
+          {
+            
+            for(connectivity_int cellBi=0;cellBi<myPrimalMesh->cellToCellsNumbers[cellAi];cellBi++)
+              {
+                
+                selectedCell    = myPrimalMesh->cellToCells[cellAi][cellBi];
+                numberOfVertex  = myPrimalMesh->cellToVertexNumber[selectedCell];
+                
+                
+                for (connectivity_int faceBi=0;faceBi<HEXAHEDRON_FACES;faceBi++)
+                  {
+                    
+                    for (connectivity_int vertexBi=0;vertexBi<hexaedron_localNodeListNumbers[faceBi];vertexBi++)
+                      {
+                        vertexList[vertexBi] = myPrimalMesh->cellToVertex[selectedCell][ hexaedron_localNodeList[faceBi][vertexBi] ];
+                      }
+                    
+                    position = findMinInList(vertexList,hexaedron_localNodeListNumbers[faceBi]);
+                    sortList(&vertexList, hexaedron_localNodeListNumbers[faceBi], position);
+                    
+                    if(memcmp(vertexListBase,vertexList,hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int)) == 0)
+                      {
+                        
+                        if(cellFaceTest[selectedCell][faceBi]==0)
+                          {
+                            cellFaceTest[selectedCell][faceBi]=1;
+                            
+                            facesOwnerCount = (connectivity_int) myPrimalMesh->cellToFacesOwnerNumber[selectedCell];
+                            
+                            myPrimalMesh->faces = (connectivity_int**) realloc(myPrimalMesh->faces,sizeof (connectivity_int*)*(myPrimalMesh->faceNumber+1));
+                            myPrimalMesh->faces[myPrimalMesh->faceNumber] =(connectivity_int*)  malloc(hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int) );
+                            
+                            memcpy( myPrimalMesh->faces[myPrimalMesh->faceNumber], vertexList,hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int) );
+                            
+                            myPrimalMesh->cellToFacesOwner[selectedCell] = (connectivity_int *) realloc(myPrimalMesh->cellToFacesOwner[selectedCell], (facesOwnerCount+1)*sizeof (connectivity_int) );
+                            
+                            myPrimalMesh->cellToFacesOwner[selectedCell][facesOwnerCount] = myPrimalMesh->faceNumber;
+                            myPrimalMesh->cellToFacesOwnerNumber[selectedCell]++;
+                            
+                            myPrimalMesh->faceNumber++;
+                            
+                          }
+                      }
+                    else
+                      {
+                        if(memcmp(vertexListInverted,vertexList,hexaedron_localNodeListNumbers[faceBi]*sizeof (connectivity_int)) == 0)
+                          {
+                            if(cellFaceTest[selectedCell][faceBi]==0)
+                              {
+                                cellFaceTest[selectedCell][faceBi]=-1;
+                                
+                                facesNeighbourCount = (connectivity_int) myPrimalMesh->cellToFacesNeighbourNumber[selectedCell];
+                                
+                                //                                    debug_print("%ld\n",facesNeighbourCount);
+                                
+                                if(myPrimalMesh->cellToFacesNeighbour[selectedCell]==NULL)
+                                  myPrimalMesh->cellToFacesNeighbour[selectedCell] = (connectivity_int*) malloc((facesNeighbourCount+1)*sizeof (connectivity_int) );
+                                else
+                                  myPrimalMesh->cellToFacesNeighbour[selectedCell] = (connectivity_int*) realloc(myPrimalMesh->cellToFacesNeighbour[selectedCell], ((facesNeighbourCount+1)) *sizeof (connectivity_int) );
+                                
+                                connectivity_short testFaceCi = 0;
+                                
+                                //                                for( connectivity_int faceCi= 0; (faceCi<myPrimalMesh->faceNumber) && (testFaceCi == 0) ; faceCi++ )
+                                for( connectivity_int faceCi= (connectivity_int) myPrimalMesh->faceNumber-1; (faceCi>0) && (testFaceCi == 0) ; faceCi-- )
+                                  {
+                                    
+                                    if(memcmp(vertexListBase,myPrimalMesh->faces[faceCi],QUAD*sizeof (connectivity_int))==0)
+                                      {
+                                        testFaceCi = 1;
+                                        myPrimalMesh->cellToFacesNeighbour[selectedCell][facesNeighbourCount]=faceCi;
+                                        myPrimalMesh->cellToFacesNeighbourNumber[selectedCell]++;
+                                      }
+                                  }
+                                
+                              }
+                          }
+                      }
+                  }
+                
+              }
+          }
+          
+          
+          
+          
+          
+          
+        }
+    }
+  
+  free(vertexList);
+  free(vertexListBase);
+  free(vertexListInverted);
+  free(cellTest);
+  free(vertexListInvertedTwo);
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    free(cellFaceTest[celli]);
+  free(cellFaceTest);
+  
+#ifdef DEBUG
+  
+  for(connectivity_int k=0;k<myPrimalMesh->faceNumber;k++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->faces", k);
+      
+      for(connectivity_int ii=0;ii<QUAD;ii++)
+        {
+          debug_print( "%ld " , myPrimalMesh->faces[k][ii]);
+        }
+      debug_print(")\n");
+    }
+  
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->cellToFacesOwner", celli);
+      
+      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesOwnerNumber[celli];faceAi++)
+        {
+          debug_print( "%ld " , myPrimalMesh->cellToFacesOwner[celli][faceAi]);
+        }
+      debug_print(")\n");
+    }
+  
+  
+  for(connectivity_int k=0;k<myPrimalMesh->cellNumber;k++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->cellToFacesNeighbour", k);
+      
+      for(connectivity_int ii=0;ii<myPrimalMesh->cellToFacesNeighbourNumber[k];ii++)
+        {
+          debug_print( "%ld " , myPrimalMesh->cellToFacesNeighbour[k][ii] );
+        }
+      debug_print(")\n");
+    }
+  
+#endif
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+void setHexahedreFaceToCells(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  connectivity_int selectedFace = 0;
+  
+  
+  myPrimalMesh->faceToCells  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->faceNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->faceNumber;ii++) {
+      myPrimalMesh->faceToCells[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->faceToCellsNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->faceNumber);
+  memset(myPrimalMesh->faceToCellsNumber,0,myPrimalMesh->faceNumber*sizeof (connectivity_int) );
+  
+  
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      
+      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesOwnerNumber[celli];faceAi++)
+        {
+          //          myPrimalMesh->cellToFacesOwner[celli][faceAi];
+          //          debug_print("O: %ld %ld\n",celli, myPrimalMesh->cellToFacesOwner[celli][faceAi]);
+          
+          selectedFace = myPrimalMesh->cellToFacesOwner[celli][faceAi];
+          
+          myPrimalMesh->faceToCells[selectedFace] = (connectivity_int*) realloc(myPrimalMesh->faceToCells[selectedFace],sizeof (connectivity_int)*(myPrimalMesh->faceToCellsNumber[selectedFace]+1));
+          
+          myPrimalMesh->faceToCells[selectedFace][myPrimalMesh->faceToCellsNumber[selectedFace]] = celli;
+          myPrimalMesh->faceToCellsNumber[selectedFace]++;
+          
+        }
+      
+      for(connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesNeighbourNumber[celli];faceAi++)
+        {
+          //          myPrimalMesh->cellToFacesOwner[celli][faceAi];
+          //          debug_print("O: %ld %ld\n",celli, myPrimalMesh->cellToFacesNeighbour[celli][faceAi]);
+          
+          selectedFace = myPrimalMesh->cellToFacesNeighbour[celli][faceAi];
+          
+          myPrimalMesh->faceToCells[selectedFace] = (connectivity_int*) realloc(myPrimalMesh->faceToCells[selectedFace],sizeof (connectivity_int)*(myPrimalMesh->faceToCellsNumber[selectedFace]+1));
+          
+          myPrimalMesh->faceToCells[selectedFace][myPrimalMesh->faceToCellsNumber[selectedFace]] = celli;
+          myPrimalMesh->faceToCellsNumber[selectedFace]++;
+          
+          
+        }
+      
+      
+    }
+  
+  
+#ifdef DEBUG
+  for(connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->faceToCells", faceAi);
+      
+      for(connectivity_int celli=0;celli<myPrimalMesh->faceToCellsNumber[faceAi];celli++)
+        {
+          debug_print( "%ld " , myPrimalMesh->faceToCells[faceAi][celli] );
+        }
+      debug_print(")\n");
+    }
+  
+#endif
+  
+  //  free(copyFace);
+  //  free(vertexList);
+  //  free(vertexListInverted);
+  
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+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__);
+  
+  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 % (int)floor(myPrimalMesh->cellNumber*10/NBAFFICHE) == 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");
+                    }
+                  
+                }
+            }
+        }
+      
+    }
+  
+#ifdef DEBUG  
+  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");
+    }  
+  
+  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 setHexahedreSegmentsCentres(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  affiche("\n");
+  
+  myPrimalMesh->segmentCentres = (dataType ** ) malloc(sizeof (dataType*)*myPrimalMesh->segmentNumber);
+  for(connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
+    {
+      myPrimalMesh->segmentCentres[segmenti]  = (dataType * ) malloc(sizeof (dataType)*DIM3D);
+    }
+  
+  
+  for (connectivity_int segmenti=0;segmenti<myPrimalMesh->segmentNumber;segmenti++)
+    {
+      
+      if(segmenti % 100000 == 0 && segmenti != 0)
+        release_print( "%-40s :  (%ld)\n","SEGMENT", segmenti);
+      
+      myPrimalMesh->segmentCentres[segmenti][0] = (
+            myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT1] ][0]
+          +
+          myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT2] ][0]
+          )/2.0;
+      myPrimalMesh->segmentCentres[segmenti][1] = (
+            myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT1] ][1]
+          +
+          myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT2] ][1]
+          )/2.0;
+      myPrimalMesh->segmentCentres[segmenti][2] = (
+            myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT1] ][2]
+          +
+          myPrimalMesh->vertex[ myPrimalMesh->segments[segmenti][PT2] ][2]
+          )/2.0;
+    }
+  
+#ifdef DEBUG
+  for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
+    {
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->segmentCentres", segmentAi);
+      
+      for(connectivity_int vertexAi=0;vertexAi<DIM3D;vertexAi++)
+        {
+          debug_print( "%lf " , myPrimalMesh->segmentCentres[segmentAi][vertexAi] );
+        }
+      debug_print(")\n");
+    }
+  
+#endif  
+  
+  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);
+  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*)*(myPrimalMesh->cellNumber*6));
+  for (connectivity_int segmentAi=0;segmentAi<(myPrimalMesh->cellNumber*6);segmentAi++)
+    myPrimalMesh->segments[segmentAi]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+  
+  for (connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
+    //  for (long faceAi=(long)(myPrimalMesh->faceNumber-1);faceAi>=0;faceAi--)
+    {
+      
+      if(faceAi % (int)floor(myPrimalMesh->cellNumber*10/NBAFFICHE) == 0 && faceAi != 0)
+        release_print( "%-40s :  (%ld)\n","FACE", faceAi);
+      
+      
+      memcpy(copyFace,myPrimalMesh->faces[faceAi],sizeof (connectivity_int)*(QUAD));
+      copyFace[QUAD] = copyFace[0];
+      
+      for (connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
+        {
+          
+          vertexList[0] = copyFace[vertexAi];
+          vertexList[1] = copyFace[(vertexAi+1) % QUAD];
+          
+          vertexListInverted[0] = vertexList[1];
+          vertexListInverted[1] = vertexList[0];
+          
+          testSegment = 0;
+          
+          /*
+           * AMELIORATION du temps de calcul :
+           * Augmenter la vitesse de recherche
+           * en incluant une fonction faceToCells puis cellToSegments pour réduire l'impact de la recherche
+           */
+          for (connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber  && testSegment == 0;segmentAi++)
+            {
+              
+              if( vertexList[0] == myPrimalMesh->segments[segmentAi][0])
+                {
+                  if( vertexList[1] == myPrimalMesh->segments[segmentAi][1])
+                    {
+                      testSegment = 1;
+                    }
+                }
+              else
+                if( vertexListInverted[0] == myPrimalMesh->segments[segmentAi][0])
+                  {
+                    if( vertexListInverted[1] == myPrimalMesh->segments[segmentAi][1])
+                      
+                      {
+                        testSegment = 2;
+                      }
+                  }
+            }
+          
+          if(testSegment == 0)
+            {
+              if(myPrimalMesh->cellNumber*HEXAHEDRON_FACES<=myPrimalMesh->segmentNumber)
+                {
+                  myPrimalMesh->segments  = (connectivity_int ** ) realloc(myPrimalMesh->segments, sizeof (connectivity_int*)*(myPrimalMesh->segmentNumber+1));
+                  myPrimalMesh->segments[myPrimalMesh->segmentNumber]  = (connectivity_int * ) malloc(sizeof (connectivity_int)*SEGMENTVERTEX);
+                }
+              memcpy(myPrimalMesh->segments[myPrimalMesh->segmentNumber], vertexList, sizeof(connectivity_int)*SEGMENTVERTEX);
+              
+              myPrimalMesh->segmentNumber++;
+            }
+          
+        }
+    }
+  
+#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);
+  
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+
+
+void setHexahedreVertexToSegments(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 testSegment = 0;
+  
+  myPrimalMesh->vertexToSegmentOwner  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->vertexNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->vertexNumber;ii++) {
+      myPrimalMesh->vertexToSegmentOwner[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->vertexToSegmentOwnerNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->vertexNumber);
+  memset(myPrimalMesh->vertexToSegmentOwnerNumber, 0, myPrimalMesh->vertexNumber*sizeof(connectivity_int));
+  
+  myPrimalMesh->vertexToSegmentNeighbour  = (connectivity_int ** ) malloc(sizeof (connectivity_int*)*myPrimalMesh->vertexNumber);
+  for (connectivity_int ii=0;ii<myPrimalMesh->vertexNumber;ii++) {
+      myPrimalMesh->vertexToSegmentNeighbour[ii]  =  NULL;//(connectivity_int * ) malloc(sizeof (connectivity_int*)*0);
+    }
+  
+  myPrimalMesh->vertexToSegmentNeighbourNumber  = (connectivity_int * ) malloc(sizeof (connectivity_int)*myPrimalMesh->vertexNumber);
+  memset(myPrimalMesh->vertexToSegmentNeighbourNumber, 0, myPrimalMesh->vertexNumber*sizeof(connectivity_int));
+  
+  
+  connectivity_int pointOwner = 0;
+  connectivity_int pointNeighbour = 0;
+  
+  for (connectivity_int segmentAi=0;segmentAi<myPrimalMesh->segmentNumber;segmentAi++)
+    {
+      if(segmentAi % (int)floor(myPrimalMesh->cellNumber*10/NBAFFICHE) == 0 && segmentAi!=0)
+        release_print( "%-40s :  (%ld)\n","SEGMENTS", segmentAi);
+      
+      pointOwner = myPrimalMesh->segments[segmentAi][1];
+      
+      myPrimalMesh->vertexToSegmentOwner[pointOwner] = (connectivity_int *) realloc(myPrimalMesh->vertexToSegmentOwner[pointOwner],(myPrimalMesh->vertexToSegmentOwnerNumber[pointOwner]+1)*sizeof (connectivity_int));
+      myPrimalMesh->vertexToSegmentOwner[pointOwner][myPrimalMesh->vertexToSegmentOwnerNumber[pointOwner]] = segmentAi;
+      myPrimalMesh->vertexToSegmentOwnerNumber[pointOwner]++;
+      
+      pointNeighbour = myPrimalMesh->segments[segmentAi][0];
+      
+      myPrimalMesh->vertexToSegmentNeighbour[pointNeighbour] = (connectivity_int *) realloc(myPrimalMesh->vertexToSegmentNeighbour[pointNeighbour],(myPrimalMesh->vertexToSegmentNeighbourNumber[pointNeighbour]+1)*sizeof (connectivity_int));
+      myPrimalMesh->vertexToSegmentNeighbour[pointNeighbour][myPrimalMesh->vertexToSegmentNeighbourNumber[pointNeighbour]] = segmentAi;
+      myPrimalMesh->vertexToSegmentNeighbourNumber[pointNeighbour]++;
+      
+    }
+  
+#ifdef DEBUG
+  for(connectivity_int vertexAi=0;vertexAi<myPrimalMesh->vertexNumber;vertexAi++)
+    {
+      
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToSegmentOwner", vertexAi);
+      
+      for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->vertexToSegmentOwnerNumber[vertexAi];segmentAi++)
+        {
+          debug_print( "%ld " , myPrimalMesh->vertexToSegmentOwner[vertexAi][segmentAi] );
+        }
+      
+      debug_print(")\n");
+      
+    }
+  
+  for(connectivity_int vertexAi=0;vertexAi<myPrimalMesh->vertexNumber;vertexAi++)
+    {
+      
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->vertexToSegmentNeighbour", vertexAi);
+      
+      for(connectivity_int segmentAi=0;segmentAi<myPrimalMesh->vertexToSegmentNeighbourNumber[vertexAi];segmentAi++)
+        {
+          debug_print( "%ld " , myPrimalMesh->vertexToSegmentNeighbour[vertexAi][segmentAi] );
+        }
+      
+      debug_print(")\n");
+      
+    }
+#endif
+  
+  free(copyFace);
+  free(vertexList);
+  free(vertexListInverted);
+  
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+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 % 100000 == 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));
+  
+  //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 faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
+    {
+      if(faceAi % ((int)(floor(myPrimalMesh->cellNumber*10/NBAFFICHE))) == 0 && faceAi!=0)
+        release_print( "%-40s :  (%ld)\n","FACES", faceAi);
+      
+      memcpy(copyFace,myPrimalMesh->faces[faceAi],sizeof (connectivity_int)*(QUAD));
+      copyFace[QUAD] = copyFace[0];
+      
+      for (connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
+        {
+          connectivity_int testSegment=0;
+          /*
+           * AMELIORATION du temps de calcul :
+           * Augmenter la vitesse de recherche
+           * en incluant une fonction faceToCells puis cellToSegments pour réduire l'impact de la recherche
+           * de segmentToFaceOwner et segmentToFaceNeighbour
+           */
+          for (connectivity_int segmentAi=0 ; segmentAi<myPrimalMesh->segmentNumber && testSegment==0 ;segmentAi++)
+            {
+              
+              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 setHexahedreSortFaceToVertex(struct primalMesh * myPrimalMesh)
+{
+  //////////////////// TRIE LES NOEUDS
+  
+  clock_t t=startFunction(__FUNCTION__);
+  
+  //    connectivity_int actualPoint;
+  //    connectivity_int nextPoint;
+  
+  // on trie les noeund dans les faces
+  for(connectivity_int k=0;k<myPrimalMesh->faceNumber;k++)
+    {
+      connectivity_int              position=0;
+      
+      
+      for(connectivity_int ii=1;ii<myPrimalMesh->faceToVertexNumber[k];ii++)
+        {
+          if(myPrimalMesh->faceToVertex[k][position]>myPrimalMesh->faceToVertex[k][ii])
+            {
+              position=ii;
+            }
+        }
+      
+      for(connectivity_int ii=0;ii<position;ii++)
+        rotate(myPrimalMesh->faceToVertex[k], myPrimalMesh->faceToVertexNumber[k]);
+      
+      
+    }
+  
+  
+  
+  
+  //        for(conctivity_int k=0;k<myPrimalMesh->faceNumber;k++)
+  //        {
+  //            conctivity_int it_surface=0;
+  //            int             bool=0;
+  //            do
+  //            {
+  //                for(conctivity_int ii=0;ii<myPrimalMesh->faceToVertexNumber[k];ii++)
+  //                {
+  //                    //     ((ii + 1) % myPrimalMesh->faceToVertexNumber[k]) ;
+  
+  //                    if(myPrimalMesh->faceToVertex[k][ii] == myPrimalMesh->faceToVertex[it_surface][0])
+  //                    {
+  //                        bool = 1;
+  //                        debug_print("TROUVE : (%ld) myPrimalMesh->faceToVertex[%ld][%ld] = %ld\n", it_surface,k,ii,myPrimalMesh->faceToVertex[k][ii])
+  //                    }
+  //                }
+  //                it_surface++;
+  //            }
+  //            while( (it_surface<myPrimalMesh->faceNumber) && (bool == 0) );
+  //        }
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+void setHexahedreAllocVertexToSegment(struct primalMesh * myPrimalMesh)
+{
+  
+  
+  clock_t t=startFunction(__FUNCTION__);
+  
+  
+  
+  myPrimalMesh->vertexToSegments = (connectivity_int **) malloc(myPrimalMesh->vertexNumber * sizeof(connectivity_int*));
+  for(connectivity_int i=0; i<myPrimalMesh->vertexNumber; i++)
+    {
+      myPrimalMesh->vertexToSegments[i] = (connectivity_int *) malloc( myPrimalMesh->vertexToSegmentNumber[i] * sizeof(connectivity_int));
+      memset(myPrimalMesh->vertexToSegments[i], 0.0, QUAD*sizeof(connectivity_int));
+    }
+  
+  
+#ifdef DEBUG  
+  for(connectivity_int i=0;i<myPrimalMesh->vertexNumber;i++)
+    {
+      
+      debug_print("%-40s : %ld (%ld)\n",
+                  "myPrimalMesh->vertexToSegmentNumber",
+                  i,
+                  myPrimalMesh->vertexToSegmentNumber[i]
+                  );
+    }
+#endif
+  endFunction(__FUNCTION__, t);
+}
+
+void setHexahedreFaceCentersAreas(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  
+  connectivity_int actualPoint;
+  connectivity_int nextPoint;
+  
+  dataType *fC;
+  
+  
+  fC =(dataType *) calloc(DIM3D, sizeof(dataType));
+  
+  myPrimalMesh->faceCentres = (dataType **) malloc(myPrimalMesh->faceNumber * sizeof(dataType *));
+  for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+    {
+      myPrimalMesh->faceCentres[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
+      memset(myPrimalMesh->faceCentres[i], 0.0, DIM3D*sizeof(dataType));
+    }
+  
+  myPrimalMesh->faceAreas = (dataType **) malloc(myPrimalMesh->faceNumber * sizeof(dataType*));
+  for(connectivity_int i=0; i<myPrimalMesh->faceNumber; i++)
+    {
+      myPrimalMesh->faceAreas[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
+      memset(myPrimalMesh->faceAreas[i], 0.0, DIM3D*sizeof(dataType));
+    }
+  
+  
+  for(connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
+    {
+      
+      zeroVector(&fC);
+      
+      for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++)
+        {
+          actualPoint = myPrimalMesh->faces[faceAi][vertexAi];
+          
+          sumTwoVectors(&fC,fC,myPrimalMesh->vertex[actualPoint]);
+          
+        }
+      
+      
+      scalarDivVector(&(myPrimalMesh->faceCentres[faceAi]), QUAD,fC);
+      
+#ifdef DEBUG      
+      debug_print( "%-40s : %ld %d ( ","myPrimalMesh->faceCentres Estimated", faceAi, QUAD);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , myPrimalMesh->faceCentres[faceAi][ii]);
+        }
+#endif
+      debug_print(")\n");
+      if(QUAD==3) {
+          
+          // Triangle
+          affiche("NON IMPLEMENTED ...");
+          exit(1);
+          
+        }
+      else
+        { //https://github.com/OpenFOAM/OpenFOAM-dev/blob/master/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFaceCentresAndAreas.C
+          dataType *sumN;
+          dataType sumA       = ZEROSCALAR;
+          dataType *sumAc;
+          
+          dataType *c;
+          dataType a          = ZEROSCALAR;
+          dataType * n       ;
+          
+          dataType *result1;
+          dataType *result2;
+          
+          
+          result1 =(dataType *) calloc(DIM3D, sizeof(dataType));
+          sumN =(dataType *) calloc(DIM3D, sizeof(dataType));
+          sumAc =(dataType *) calloc(DIM3D, sizeof(dataType));
+          c =(dataType *) calloc(DIM3D, sizeof(dataType));
+          n =(dataType *) calloc(DIM3D, sizeof(dataType));
+          result2 =(dataType *) calloc(DIM3D, sizeof(dataType));
+          
+          
+          
+          for(connectivity_int vertexAi=0;vertexAi<QUAD;vertexAi++) {
+              
+              actualPoint = myPrimalMesh->faces[faceAi][vertexAi];
+              nextPoint = myPrimalMesh->faces[faceAi][(vertexAi + 1) % QUAD];
+              
+              sumThreeVectors(&c, (myPrimalMesh->vertex[actualPoint]), (myPrimalMesh->vertex[nextPoint]), (myPrimalMesh->faceCentres[faceAi]) );
+              
+              subTwoVectors(&result1, (myPrimalMesh->vertex[nextPoint]), (myPrimalMesh->vertex[actualPoint]));
+              subTwoVectors(&result2, (myPrimalMesh->faceCentres[faceAi]), (myPrimalMesh->vertex[actualPoint]));
+              
+              crossProduct(&n, result1, result2);
+              mag(&(a), n);
+              
+              sumTwoVectors(&sumN, sumN, n);
+              
+              sumA+=a;
+              scalarDotVector(&result1, a, c);
+              sumTwoVectors(&sumAc, sumAc, result1);
+            }
+          
+          if (sumA < SMALL)
+            {
+              zeroVector( &(myPrimalMesh->faceAreas[faceAi]) );
+            }
+          else
+            {
+              scalarDotVector(&(myPrimalMesh->faceCentres[faceAi]), 1.0/(3.0*sumA), sumAc); //correct faceCentres after estimating them
+              scalarDotVector(&(myPrimalMesh->faceAreas[faceAi]), 0.5, sumN);
+            }
+          
+          free(sumN);
+          free(sumAc);
+          free(c);
+          free(n)       ;
+          free(result1);
+          free(result2);
+          
+        }
+      
+    }
+  
+#ifdef DEBUG
+  for(connectivity_int faceAi=0;faceAi<myPrimalMesh->faceNumber;faceAi++)
+    {
+      debug_print( "%-40s : %ld %d ( ","myPrimalMesh->faceCentres", faceAi, QUAD);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , myPrimalMesh->faceCentres[faceAi][ii]);
+        }
+      
+      debug_print(")\n");
+      
+      debug_print( "%-40s : %ld ( ","myPrimalMesh->faceAreas", faceAi);
+      
+      for(connectivity_int ii=0;ii<DIM3D;ii++)
+        {
+          debug_print( "%lf " , myPrimalMesh->faceAreas[faceAi][ii]);
+        }
+      
+      debug_print(")\n");
+    }
+#endif
+  
+  free(fC);
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+void setHexahedreEstimateVolumeCentroid(struct primalMesh * myPrimalMesh)
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  
+  
+  dataType *result;
+  
+  // vertex number on faces
+  
+  connectivity_int it_faceOwner,it_faceNeighbour;
+  
+  result =(dataType *) calloc(DIM3D, sizeof(dataType));
+  
+  myPrimalMesh->volumeCentroid = (dataType **) malloc(myPrimalMesh->cellNumber * sizeof(dataType*));
+  for(connectivity_int i=0; i<myPrimalMesh->cellNumber; i++)
+    {
+      myPrimalMesh->volumeCentroid[i] = (dataType *) malloc(DIM3D * sizeof(dataType));
+      memset(myPrimalMesh->volumeCentroid[i], 0.0, DIM3D*sizeof(dataType));
+    }
+  
+  //    myPrimalMesh->cellToFacesNumber = (connectivity_short*) malloc(myPrimalMesh->cellNumber * sizeof(connectivity_short));
+  
+  
+  myPrimalMesh->volume  = (dataType *) malloc(myPrimalMesh->cellNumber * sizeof(dataType));
+  memset(myPrimalMesh->volume, 0.0, myPrimalMesh->cellNumber*sizeof(dataType));
+  
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      
+      zeroVector(&result);
+      
+      for (connectivity_int ii=0;ii<myPrimalMesh->cellToFacesOwnerNumber[celli];ii++)
+        {
+          it_faceOwner = myPrimalMesh->cellToFacesOwner[celli][ii];
+          
+          
+          sumTwoVectors(&result, result, (myPrimalMesh->faceCentres[it_faceOwner]) );
+          
+        }
+      
+      for (connectivity_int ii=0;ii<myPrimalMesh->cellToFacesNeighbourNumber[celli];ii++)
+        {
+          it_faceNeighbour = myPrimalMesh->cellToFacesNeighbour[celli][ii];
+          
+          sumTwoVectors(&result, result, (myPrimalMesh->faceCentres[it_faceNeighbour]) );
+          
+        }
+      scalarDivVector(&(myPrimalMesh->volumeCentroid[celli]) , myPrimalMesh->cellToFacesNeighbourNumber[celli]+myPrimalMesh->cellToFacesOwnerNumber[celli], result);
+      
+    }
+  
+#ifdef DEBUG  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      
+      
+      debug_print("%-40s : %ld (%lf %lf %lf)\n",
+                  "myPrimalMesh->volumeCentroid Estimated",
+                  celli,
+                  myPrimalMesh->volumeCentroid[celli][0],
+          myPrimalMesh->volumeCentroid[celli][1],
+          myPrimalMesh->volumeCentroid[celli][2]
+          );
+    }
+#endif  
+  
+  free(result);
+  endFunction(__FUNCTION__, t);
+  
+}
+
+
+void setHexahedreVolumeCentroid(struct primalMesh * myPrimalMesh)
+{
+  clock_t t=startFunction(__FUNCTION__);
+  
+  //  connectivity_int  it_cell=0;
+  dataType        *cellCentroid;
+  dataType        pyr3Vol=0.0;
+  dataType        *result1;
+  dataType        *result2;
+  dataType        *result3;
+  
+  result1 =(dataType *) calloc(DIM3D, sizeof(dataType));
+  result2 =(dataType *) calloc(DIM3D, sizeof(dataType));
+  result3 =(dataType *) calloc(DIM3D, sizeof(dataType));
+  cellCentroid  =(dataType *) calloc(DIM3D, sizeof(dataType));
+  
+  // vertex number on faces
+  connectivity_int it_face;
+  
+  // Estimate centroids
+  setHexahedreEstimateVolumeCentroid(myPrimalMesh);
+  
+  
+  for(connectivity_int celli=0;celli<myPrimalMesh->cellNumber;celli++)
+    {
+      
+      equalVector(&cellCentroid, myPrimalMesh->volumeCentroid[celli]);
+      
+      zeroVector(&(myPrimalMesh->volumeCentroid[celli]));
+      
+      for (connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesOwnerNumber[celli];faceAi++)
+        {
+          it_face = myPrimalMesh->cellToFacesOwner[celli][faceAi];
+          
+          subTwoVectors( &result1, myPrimalMesh->faceCentres[it_face], cellCentroid );
+          
+          dotProduct(&pyr3Vol,myPrimalMesh->faceAreas[it_face], result1);
+          
+          scalarDotVector(&result1, 3.0/4.0, myPrimalMesh->faceCentres[it_face]); //
+          scalarDotVector(&result2, 1.0/4.0, cellCentroid); //
+          
+          sumTwoVectors(&result3,result1,result2);
+          
+          scalarDotVector(&result1,pyr3Vol,result3);
+          
+          sumTwoVectors(&(myPrimalMesh->volumeCentroid[celli]),myPrimalMesh->volumeCentroid[celli],result1);
+          
+          (myPrimalMesh->volume[celli])+=pyr3Vol;
+          
+        }
+      
+      for (connectivity_int faceAi=0;faceAi<myPrimalMesh->cellToFacesNeighbourNumber[celli];faceAi++)
+        {
+          it_face = myPrimalMesh->cellToFacesNeighbour[celli][faceAi];
+          
+          subTwoVectors( &result1, cellCentroid , myPrimalMesh->faceCentres[it_face]);
+          
+          dotProduct(&pyr3Vol,myPrimalMesh->faceAreas[it_face], result1);
+          
+          scalarDotVector(&result1, 3.0/4.0, myPrimalMesh->faceCentres[it_face]); //
+          scalarDotVector(&result2, 1.0/4.0, cellCentroid); //
+          
+          sumTwoVectors(&result3,result1,result2);
+          
+          scalarDotVector(&result1,pyr3Vol,result3);
+          
+          sumTwoVectors(&(myPrimalMesh->volumeCentroid[celli]),myPrimalMesh->volumeCentroid[celli],result1);
+          
+          (myPrimalMesh->volume[celli])+=pyr3Vol;
+          
+        }
+      
+      
+      
+      dataType fVol = fabs(myPrimalMesh->volume[celli]);
+      if (fVol > VSMALL)
+        {
+          scalarDivVector(&(myPrimalMesh->volumeCentroid[celli]),myPrimalMesh->volume[celli],myPrimalMesh->volumeCentroid[celli]);
+        }
+      else
+        {
+          equalVector(&(myPrimalMesh->volumeCentroid[celli]), cellCentroid);
+        }
+      
+      
+      myPrimalMesh->volume[celli] *= (1.0/3.0);
+      
+#ifdef DEBUG      
+      debug_print("%-40s : %ld (%lf) (%lf %lf %lf)\n",
+                  "myPrimalMesh->volumeCentroid",
+                  celli,
+                  myPrimalMesh->volume[celli],
+                  myPrimalMesh->volumeCentroid[celli][0],
+          myPrimalMesh->volumeCentroid[celli][1],
+          myPrimalMesh->volumeCentroid[celli][2]
+          );
+#endif      
+    }
+  
+  free(result1);
+  free(result2);
+  free(result3);
+  
+  free(cellCentroid);
+  
+  endFunction(__FUNCTION__, t);
+  
+}
diff --git a/src/primal.h b/src/primal.h
new file mode 100644 (file)
index 0000000..d472e1a
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef PRIMAL_H
+#define PRIMAL_H
+
+#include "mmd.h"
+
+#define DEF_hexaedron_localNodeList \
+connectivity_int  hexaedron_localNodeList[HEXAHEDRON_FACES][QUAD]={ \
+{0,3,2,1}, \
+{0,1,5,4}, \
+{0,4,7,3}, \
+{1,2,6,5}, \
+{4,5,6,7}, \
+{3,7,6,2} \
+};
+
+
+#define DEF_hexaedron_localNodeListNumbers \
+connectivity_int  hexaedron_localNodeListNumbers[HEXAHEDRON_FACES]={ \
+  QUAD, \
+  QUAD, \
+  QUAD, \
+  QUAD, \
+  QUAD, \
+  QUAD \
+};
+
+
+#define DEF_hexaedron_localSegmentList \
+connectivity_int  hexaedron_localSegmentList[HEXAHEDRON_SEGMENTS][SEGMENTVERTEX]={ \
+{0,1}, \
+{1,5}, \
+{5,4}, \
+{4,0}, \
+{4,7}, \
+{1,2}, \
+{2,3}, \
+{3,7}, \
+{7,6}, \
+{6,2}, \
+{5,6}, \
+{0,3} \
+};
+
+
+
+#define DEF_hexaedron_localSegmentsListNumbers \
+connectivity_int  hexaedron_localSegmentsListNumbers[HEXAHEDRON_SEGMENTS]={ \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX, \
+  SEGMENTVERTEX \
+};
+
+
+
+void setHexahedreVertex(struct primalMesh * myPrimalMesh);
+
+void setHexahedreCellToVertexNumber(struct primalMesh * myPrimalMesh);
+
+void setHexahedreCellToVertex(struct primalMesh * myPrimalMesh);
+
+void setHexahedreVertexToCellNumbers(struct primalMesh * myPrimalMesh);
+
+void setHexahedreVertexToCells(struct primalMesh * myPrimalMesh);
+
+void setHexahedreCellToCells(struct primalMesh * myPrimalMesh);
+
+void setHexahedreCellToFacesOwnerNeighbour(struct primalMesh * myPrimalMesh);
+
+void setHexahedreFaceToCells(struct primalMesh * myPrimalMesh);
+
+void setHexahedreSegments(struct primalMesh * myPrimalMesh);
+
+void setHexahedreSegmentsCentres(struct primalMesh * myPrimalMesh);
+
+void setHexahedreSegments2(struct primalMesh * myPrimalMesh);
+
+void setHexahedreVertexToSegments(struct primalMesh * myPrimalMesh);
+
+void setHexahedreSegmentToFaces(struct primalMesh * myPrimalMesh);
+
+void setHexahedreSegmentToFaces2(struct primalMesh * myPrimalMesh);
+
+void setHexahedreSortFaceToVertex(struct primalMesh * myPrimalMesh);
+
+void setHexahedreAllocVertexToSegment(struct primalMesh * myPrimalMesh);
+
+void setHexahedreFaceCentersAreas(struct primalMesh * myPrimalMesh);
+
+void setHexahedreEstimateVolumeCentroid(struct primalMesh * myPrimalMesh);
+
+void setHexahedreVolumeCentroid(struct primalMesh * myPrimalMesh);
+#endif // PRIMAL_H
diff --git a/src/savedata.c b/src/savedata.c
new file mode 100644 (file)
index 0000000..9000cf9
--- /dev/null
@@ -0,0 +1,70 @@
+#include "mmd.h"
+#include "savedata.h"
+
+
+void writeVTK(struct primalMesh * myPrimalMesh, struct readWriteVTK * myReadWriteVTK)
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Ecriture dans un fichier VTK du PRIMAL
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+{
+  
+  clock_t t=startFunction(__FUNCTION__);
+  
+  myReadWriteVTK->dataName = "Ma Simulation TEST";
+  
+  myReadWriteVTK->handle = fopen("test.vtk", "wt");
+  
+  fprintf(myReadWriteVTK->handle, "# vtk DataFile Version 2.0\n");
+  fprintf(myReadWriteVTK->handle, "%s\n\n", myReadWriteVTK->dataName);
+  
+  fprintf(myReadWriteVTK->handle, "ASCII\n");
+  
+  fprintf(myReadWriteVTK->handle, "DATASET UNSTRUCTURED_GRID\n");
+  
+  fprintf(myReadWriteVTK->handle, "POINTS %ld FLOAT\n",myPrimalMesh->vertexNumber);
+  
+  for (connectivity_int i=0;i<myPrimalMesh->vertexNumber;i++)
+    {
+      fprintf(myReadWriteVTK->handle,"%f %f %f\n"
+              ,myPrimalMesh->vertex[i][0]
+          ,myPrimalMesh->vertex[i][1]
+          ,myPrimalMesh->vertex[i][2]
+          );
+    }
+  
+  fprintf(myReadWriteVTK->handle, "\n");
+  
+  connectivity_int count = 0;
+  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
+    count +=(myPrimalMesh->cellToVertexNumber[i]+1); // +1 = column of line count
+  
+  fprintf(myReadWriteVTK->handle, "CELLS %ld %ld\n",myPrimalMesh->cellNumber, count);
+  
+  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
+    {
+      
+      fprintf(myReadWriteVTK->handle,"%ld ",myPrimalMesh->cellToVertexNumber[i]);
+      for (connectivity_int j=0;j<myPrimalMesh->cellToVertexNumber[i];j++)
+        fprintf(myReadWriteVTK->handle,"%ld ",myPrimalMesh->cellToVertex[i][j]);
+      fprintf(myReadWriteVTK->handle,"\n");
+      
+    }
+  
+  fprintf(myReadWriteVTK->handle, "CELL_TYPES %ld\n",myPrimalMesh->cellNumber);
+  for (connectivity_int i=0;i<myPrimalMesh->cellNumber;i++)
+    {
+      
+      if(myPrimalMesh->cellToVertexNumber[i]==HEXAHEDRON)
+        fprintf(myReadWriteVTK->handle,"%d\n",VTK_HEXAHEDRON);
+      else
+        fprintf(myReadWriteVTK->handle,"???\n");
+      
+      
+    }
+  
+  fclose(myReadWriteVTK->handle);
+  
+  endFunction(__FUNCTION__, t);
+  
+}
+
diff --git a/src/savedata.h b/src/savedata.h
new file mode 100644 (file)
index 0000000..b02289e
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef SAVEDATA_H
+#define SAVEDATA_H
+
+
+void writeVTK(struct primalMesh * myPrimalMesh, struct readWriteVTK * myReadWriteVTK);
+
+#endif // SAVEDATA_H
diff --git a/test/CMakeFiles/CMakeDirectoryInformation.cmake b/test/CMakeFiles/CMakeDirectoryInformation.cmake
new file mode 100644 (file)
index 0000000..3260275
--- /dev/null
@@ -0,0 +1,16 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+# Relative path conversion top directories.
+set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD")
+set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD")
+
+# Force unix paths in dependencies.
+set(CMAKE_FORCE_UNIX_PATHS 1)
+
+
+# The C and CXX include file regular expressions for this directory.
+set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
+set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
+set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
+set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
diff --git a/test/CMakeFiles/progress.marks b/test/CMakeFiles/progress.marks
new file mode 100644 (file)
index 0000000..0cfbf08
--- /dev/null
@@ -0,0 +1 @@
+2
diff --git a/test/CMakeFiles/test01.dir/C.includecache b/test/CMakeFiles/test01.dir/C.includecache
new file mode 100644 (file)
index 0000000..50b963f
--- /dev/null
@@ -0,0 +1,14 @@
+#IncludeRegexLine: ^[  ]*[#%][         ]*(include|import)[     ]*[<"]([^">]+)([">])
+
+#IncludeRegexScan: ^.*$
+
+#IncludeRegexComplain: ^$
+
+#IncludeRegexTransform: 
+
+/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/test01.c
+stdio.h
+-
+stdlib.h
+-
+
diff --git a/test/CMakeFiles/test01.dir/DependInfo.cmake b/test/CMakeFiles/test01.dir/DependInfo.cmake
new file mode 100644 (file)
index 0000000..d4928cb
--- /dev/null
@@ -0,0 +1,26 @@
+# The set of languages for which implicit dependencies are needed:
+set(CMAKE_DEPENDS_LANGUAGES
+  "C"
+  )
+# The set of files for implicit dependencies of each language:
+set(CMAKE_DEPENDS_CHECK_C
+  "/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/test01.c" "/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/CMakeFiles/test01.dir/test01.c.o"
+  )
+set(CMAKE_C_COMPILER_ID "GNU")
+
+# Preprocessor definitions for this target.
+set(CMAKE_TARGET_DEFINITIONS_C
+  "vtkRenderingCore_AUTOINIT=2(vtkInteractionStyle,vtkRenderingOpenGL2)"
+  )
+
+# The include file search paths:
+set(CMAKE_C_TARGET_INCLUDE_PATH
+  "/usr/include/vtk-7.1"
+  )
+
+# Targets to which this target links.
+set(CMAKE_TARGET_LINKED_INFO_FILES
+  )
+
+# Fortran module output directory.
+set(CMAKE_Fortran_TARGET_MODULE_DIR "")
diff --git a/test/CMakeFiles/test01.dir/build.make b/test/CMakeFiles/test01.dir/build.make
new file mode 100644 (file)
index 0000000..98968b2
--- /dev/null
@@ -0,0 +1,118 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+# Delete rule output on recipe failure.
+.DELETE_ON_ERROR:
+
+
+#=============================================================================
+# Special targets provided by cmake.
+
+# Disable implicit rules so canonical targets will work.
+.SUFFIXES:
+
+
+# Disable VCS-based implicit rules.
+% : %,v
+
+
+# Disable VCS-based implicit rules.
+% : RCS/%
+
+
+# Disable VCS-based implicit rules.
+% : RCS/%,v
+
+
+# Disable VCS-based implicit rules.
+% : SCCS/s.%
+
+
+# Disable VCS-based implicit rules.
+% : s.%
+
+
+.SUFFIXES: .hpux_make_needs_suffix_list
+
+
+# Command-line flag to silence nested $(MAKE).
+$(VERBOSE)MAKESILENT = -s
+
+# Suppress display of executed commands.
+$(VERBOSE).SILENT:
+
+
+# A target that is always out of date.
+cmake_force:
+
+.PHONY : cmake_force
+
+#=============================================================================
+# Set environment variables for the build.
+
+# The shell in which to execute make rules.
+SHELL = /bin/sh
+
+# The CMake executable.
+CMAKE_COMMAND = /usr/bin/cmake
+
+# The command to remove a file.
+RM = /usr/bin/cmake -E rm -f
+
+# Escaping for special characters.
+EQUALS = =
+
+# The top-level source directory on which CMake was run.
+CMAKE_SOURCE_DIR = /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+# The top-level build directory on which CMake was run.
+CMAKE_BINARY_DIR = /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+# Include any dependencies generated for this target.
+include test/CMakeFiles/test01.dir/depend.make
+
+# Include the progress variables for this target.
+include test/CMakeFiles/test01.dir/progress.make
+
+# Include the compile flags for this target's objects.
+include test/CMakeFiles/test01.dir/flags.make
+
+test/CMakeFiles/test01.dir/test01.c.o: test/CMakeFiles/test01.dir/flags.make
+test/CMakeFiles/test01.dir/test01.c.o: test/test01.c
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building C object test/CMakeFiles/test01.dir/test01.c.o"
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test && /usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -o CMakeFiles/test01.dir/test01.c.o   -c /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/test01.c
+
+test/CMakeFiles/test01.dir/test01.c.i: cmake_force
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/test01.dir/test01.c.i"
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test && /usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -E /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/test01.c > CMakeFiles/test01.dir/test01.c.i
+
+test/CMakeFiles/test01.dir/test01.c.s: cmake_force
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/test01.dir/test01.c.s"
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test && /usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -S /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/test01.c -o CMakeFiles/test01.dir/test01.c.s
+
+# Object files for target test01
+test01_OBJECTS = \
+"CMakeFiles/test01.dir/test01.c.o"
+
+# External object files for target test01
+test01_EXTERNAL_OBJECTS =
+
+test/test01: test/CMakeFiles/test01.dir/test01.c.o
+test/test01: test/CMakeFiles/test01.dir/build.make
+test/test01: test/CMakeFiles/test01.dir/link.txt
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking C executable test01"
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/test01.dir/link.txt --verbose=$(VERBOSE)
+
+# Rule to build all files generated by this target.
+test/CMakeFiles/test01.dir/build: test/test01
+
+.PHONY : test/CMakeFiles/test01.dir/build
+
+test/CMakeFiles/test01.dir/clean:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test && $(CMAKE_COMMAND) -P CMakeFiles/test01.dir/cmake_clean.cmake
+.PHONY : test/CMakeFiles/test01.dir/clean
+
+test/CMakeFiles/test01.dir/depend:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/CMakeFiles/test01.dir/DependInfo.cmake --color=$(COLOR)
+.PHONY : test/CMakeFiles/test01.dir/depend
+
diff --git a/test/CMakeFiles/test01.dir/cmake_clean.cmake b/test/CMakeFiles/test01.dir/cmake_clean.cmake
new file mode 100644 (file)
index 0000000..6e82e7f
--- /dev/null
@@ -0,0 +1,10 @@
+file(REMOVE_RECURSE
+  "CMakeFiles/test01.dir/test01.c.o"
+  "test01"
+  "test01.pdb"
+)
+
+# Per-language clean rules from dependency scanning.
+foreach(lang C)
+  include(CMakeFiles/test01.dir/cmake_clean_${lang}.cmake OPTIONAL)
+endforeach()
diff --git a/test/CMakeFiles/test01.dir/depend.internal b/test/CMakeFiles/test01.dir/depend.internal
new file mode 100644 (file)
index 0000000..78b46b0
--- /dev/null
@@ -0,0 +1,5 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+test/CMakeFiles/test01.dir/test01.c.o
+ /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/test01.c
diff --git a/test/CMakeFiles/test01.dir/depend.make b/test/CMakeFiles/test01.dir/depend.make
new file mode 100644 (file)
index 0000000..5e92870
--- /dev/null
@@ -0,0 +1,5 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+test/CMakeFiles/test01.dir/test01.c.o: test/test01.c
+
diff --git a/test/CMakeFiles/test01.dir/flags.make b/test/CMakeFiles/test01.dir/flags.make
new file mode 100644 (file)
index 0000000..46204c2
--- /dev/null
@@ -0,0 +1,10 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+# compile C with /usr/bin/cc
+C_FLAGS = -Wall -Wextra  -O3 -DNDEBUG -march=skylake   -mtune=skylake  
+
+C_DEFINES = -DvtkRenderingCore_AUTOINIT="2(vtkInteractionStyle,vtkRenderingOpenGL2)"
+
+C_INCLUDES = -I/usr/include/vtk-7.1 
+
diff --git a/test/CMakeFiles/test01.dir/link.txt b/test/CMakeFiles/test01.dir/link.txt
new file mode 100644 (file)
index 0000000..4489be4
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/cc -Wall -Wextra  -O3 -DNDEBUG -march=skylake         -mtune=skylake    -rdynamic CMakeFiles/test01.dir/test01.c.o  -o test01 
diff --git a/test/CMakeFiles/test01.dir/progress.make b/test/CMakeFiles/test01.dir/progress.make
new file mode 100644 (file)
index 0000000..8808896
--- /dev/null
@@ -0,0 +1,3 @@
+CMAKE_PROGRESS_1 = 6
+CMAKE_PROGRESS_2 = 7
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..98e9037
--- /dev/null
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 2.8)
+project(test01)
+add_executable(test01 test01)
+enable_testing()
+add_test(NAME YeahhhTest COMMAND ${CMAKE_COMMAND} -E echo 'Yeahh')
diff --git a/test/CTestTestfile.cmake b/test/CTestTestfile.cmake
new file mode 100644 (file)
index 0000000..91250c0
--- /dev/null
@@ -0,0 +1,8 @@
+# CMake generated Testfile for 
+# Source directory: /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test
+# Build directory: /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test
+# 
+# This file includes the relevant testing commands required for 
+# testing this directory and lists subdirectories to be tested as well.
+add_test(YeahhhTest "/usr/bin/cmake" "-E" "echo" "'Yeahh'")
+set_tests_properties(YeahhhTest PROPERTIES  _BACKTRACE_TRIPLES "/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/CMakeLists.txt;5;add_test;/home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/CMakeLists.txt;0;")
diff --git a/test/Makefile b/test/Makefile
new file mode 100644 (file)
index 0000000..3496b36
--- /dev/null
@@ -0,0 +1,212 @@
+# CMAKE generated file: DO NOT EDIT!
+# Generated by "Unix Makefiles" Generator, CMake Version 3.17
+
+# Default target executed when no arguments are given to make.
+default_target: all
+
+.PHONY : default_target
+
+# Allow only one "make -f Makefile2" at a time, but pass parallelism.
+.NOTPARALLEL:
+
+
+#=============================================================================
+# Special targets provided by cmake.
+
+# Disable implicit rules so canonical targets will work.
+.SUFFIXES:
+
+
+# Disable VCS-based implicit rules.
+% : %,v
+
+
+# Disable VCS-based implicit rules.
+% : RCS/%
+
+
+# Disable VCS-based implicit rules.
+% : RCS/%,v
+
+
+# Disable VCS-based implicit rules.
+% : SCCS/s.%
+
+
+# Disable VCS-based implicit rules.
+% : s.%
+
+
+.SUFFIXES: .hpux_make_needs_suffix_list
+
+
+# Command-line flag to silence nested $(MAKE).
+$(VERBOSE)MAKESILENT = -s
+
+# Suppress display of executed commands.
+$(VERBOSE).SILENT:
+
+
+# A target that is always out of date.
+cmake_force:
+
+.PHONY : cmake_force
+
+#=============================================================================
+# Set environment variables for the build.
+
+# The shell in which to execute make rules.
+SHELL = /bin/sh
+
+# The CMake executable.
+CMAKE_COMMAND = /usr/bin/cmake
+
+# The command to remove a file.
+RM = /usr/bin/cmake -E rm -f
+
+# Escaping for special characters.
+EQUALS = =
+
+# The top-level source directory on which CMake was run.
+CMAKE_SOURCE_DIR = /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+# The top-level build directory on which CMake was run.
+CMAKE_BINARY_DIR = /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD
+
+#=============================================================================
+# Targets provided globally by CMake.
+
+# Special rule for the target rebuild_cache
+rebuild_cache:
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
+       /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
+.PHONY : rebuild_cache
+
+# Special rule for the target rebuild_cache
+rebuild_cache/fast: rebuild_cache
+
+.PHONY : rebuild_cache/fast
+
+# Special rule for the target edit_cache
+edit_cache:
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
+       /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
+.PHONY : edit_cache
+
+# Special rule for the target edit_cache
+edit_cache/fast: edit_cache
+
+.PHONY : edit_cache/fast
+
+# Special rule for the target test
+test:
+       @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
+       /usr/bin/ctest --force-new-ctest-process $(ARGS)
+.PHONY : test
+
+# Special rule for the target test
+test/fast: test
+
+.PHONY : test/fast
+
+# The main all target
+all: cmake_check_build_system
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test/CMakeFiles/progress.marks
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 test/all
+       $(CMAKE_COMMAND) -E cmake_progress_start /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/CMakeFiles 0
+.PHONY : all
+
+# The main clean target
+clean:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 test/clean
+.PHONY : clean
+
+# The main clean target
+clean/fast: clean
+
+.PHONY : clean/fast
+
+# Prepare targets for installation.
+preinstall: all
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 test/preinstall
+.PHONY : preinstall
+
+# Prepare targets for installation.
+preinstall/fast:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 test/preinstall
+.PHONY : preinstall/fast
+
+# clear depends
+depend:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
+.PHONY : depend
+
+# Convenience name for target.
+test/CMakeFiles/test01.dir/rule:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 test/CMakeFiles/test01.dir/rule
+.PHONY : test/CMakeFiles/test01.dir/rule
+
+# Convenience name for target.
+test01: test/CMakeFiles/test01.dir/rule
+
+.PHONY : test01
+
+# fast build rule for target.
+test01/fast:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f test/CMakeFiles/test01.dir/build.make test/CMakeFiles/test01.dir/build
+.PHONY : test01/fast
+
+test01.o: test01.c.o
+
+.PHONY : test01.o
+
+# target to build an object file
+test01.c.o:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f test/CMakeFiles/test01.dir/build.make test/CMakeFiles/test01.dir/test01.c.o
+.PHONY : test01.c.o
+
+test01.i: test01.c.i
+
+.PHONY : test01.i
+
+# target to preprocess a source file
+test01.c.i:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f test/CMakeFiles/test01.dir/build.make test/CMakeFiles/test01.dir/test01.c.i
+.PHONY : test01.c.i
+
+test01.s: test01.c.s
+
+.PHONY : test01.s
+
+# target to generate assembly for a file
+test01.c.s:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(MAKE) $(MAKESILENT) -f test/CMakeFiles/test01.dir/build.make test/CMakeFiles/test01.dir/test01.c.s
+.PHONY : test01.c.s
+
+# Help Target
+help:
+       @echo "The following are some of the valid targets for this Makefile:"
+       @echo "... all (the default if no target is provided)"
+       @echo "... clean"
+       @echo "... depend"
+       @echo "... edit_cache"
+       @echo "... rebuild_cache"
+       @echo "... test"
+       @echo "... test01"
+       @echo "... test01.o"
+       @echo "... test01.i"
+       @echo "... test01.s"
+.PHONY : help
+
+
+
+#=============================================================================
+# Special targets to cleanup operation of make.
+
+# Special rule to run CMake to check the build system integrity.
+# No rule that depends on this can have commands that come from listfiles
+# because they might be regenerated.
+cmake_check_build_system:
+       cd /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD && $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
+.PHONY : cmake_check_build_system
+
diff --git a/test/cmake_install.cmake b/test/cmake_install.cmake
new file mode 100644 (file)
index 0000000..106789b
--- /dev/null
@@ -0,0 +1,39 @@
+# Install script for directory: /home/alain/CloudStation/MMD_QM/MMD/MMD_github/MMD/test
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX "/usr/local")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+  if(BUILD_TYPE)
+    string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+           CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+  else()
+    set(CMAKE_INSTALL_CONFIG_NAME "Release")
+  endif()
+  message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+  if(COMPONENT)
+    message(STATUS "Install component: \"${COMPONENT}\"")
+    set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+  else()
+    set(CMAKE_INSTALL_COMPONENT)
+  endif()
+endif()
+
+# Install shared libraries without execute permission?
+if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
+  set(CMAKE_INSTALL_SO_NO_EXE "1")
+endif()
+
+# Is this installation the result of a crosscompile?
+if(NOT DEFINED CMAKE_CROSSCOMPILING)
+  set(CMAKE_CROSSCOMPILING "FALSE")
+endif()
+
diff --git a/test/test01 b/test/test01
new file mode 100755 (executable)
index 0000000..23bfbcd
Binary files /dev/null and b/test/test01 differ
diff --git a/test/test01.c b/test/test01.c
new file mode 100644 (file)
index 0000000..bdfae6a
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main()
+  {
+  printf("This is the whole thing.\n");
+  }