Commit c2bdb138 authored by Célestin Marot's avatar Célestin Marot
Browse files

here is the full bench sources

parent 657452b7
#!/bin/bash
# usage: `export GMSH=/usr/bin/gmsh; bash gmsh_bench.sh`
#make a symbolic link to /dev/null
ln -is /dev/null tmp.msh
bash benchmark_speed.sh \
-n5 \
-o results/gmsh_bench \
-f "meshes/*.geo" \
-a '/Done tetrahedrizing [0-9]+ nodes/ && !emptyMesh {emptyMesh=$8+0}
/Done reconstructing mesh/ {bndRecov=$7+0}
/Done meshing 3D/ {refine=$7 - emptyMesh - bndRecov}
/Done optimizing mesh/ {opti=$7+0}
/[0-9]+ nodes [0-9]+ elements/ {ntet=$5}
END{print emptyMesh,bndRecov,refine,opti,ntet}' \
$GMSH -3 -format msh41 -bin -optimize_threshold 0.35 -o tmp.msh
rm tmp.msh
\ No newline at end of file
File added
cmake_minimum_required(VERSION 3.9)
project(hxt_tetMesh C CXX)
# include guard for CMake:
# if you plan to include multiple directory that depend on this one,
# you need to include this directory first
if(TARGET hxt_tetMesh)
return()
endif()
#################################################################################
# Options
#################################################################################
option(HXT_TETMESH_OBJECT_ONLY "Do not create hxt_tetMesh library" OFF)
option(HXT_TETMESH_BUILD_CLI "build hxt_tetMesh CLI tools" ON)
#################################################################################
# Library definition
#################################################################################
set(HXT_TETMESH_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/src/HXTSPR.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetFlag.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetMesh.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetOpti.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetSync.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetColor.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetUtils.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_vertices.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_smoothing.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetRefine.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetRepair.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetQuality.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_edgeRemoval.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetDelaunay.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetNodalSize.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/HXTSPR.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetSync.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetColor.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetUtils.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_smoothing.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetRefine.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetQuality.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_edgeRemoval.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetNodalSize.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetOptiUtils.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_tetPartition.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_tetDelaunay.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_tetFlag.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_tetMesh.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_tetOpti.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_tetRepair.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_vertices.h"
)
if(HXT_TETMESH_OBJECT_ONLY)
add_library(hxt_tetMesh OBJECT ${HXT_TETMESH_SRC})
else()
add_library(hxt_tetMesh ${HXT_TETMESH_SRC})
endif()
add_subdirectory(deps/core "${CMAKE_CURRENT_BINARY_DIR}/core")
add_subdirectory(deps/predicates "${CMAKE_CURRENT_BINARY_DIR}/predicates")
target_include_directories(hxt_tetMesh
PUBLIC include
PRIVATE src)
target_link_libraries(hxt_tetMesh
PUBLIC hxt_core
PRIVATE hxt_predicates m)
target_compile_features(hxt_tetMesh PRIVATE c_std_99)
#################################################################################
# Executable definition
#################################################################################
if(HXT_TETMESH_BUILD_CLI)
# tetMesh_CLI
add_executable(tetMesh_CLI "${CMAKE_CURRENT_SOURCE_DIR}/exe/tetMesh_CLI.c")
add_subdirectory(deps/tetBR "${CMAKE_CURRENT_BINARY_DIR}/tetBR")
target_link_libraries(tetMesh_CLI hxt_core hxt_predicates hxt_tetMesh hxt_tetBR)
# # Delaunay_CLI
add_executable(Delaunay_CLI "${CMAKE_CURRENT_SOURCE_DIR}/exe/Delaunay_CLI.c")
target_link_libraries(Delaunay_CLI hxt_core hxt_predicates hxt_tetMesh)
# tetOpti_CLI
add_executable(tetOpti_CLI "${CMAKE_CURRENT_SOURCE_DIR}/exe/tetOpti_CLI.c")
target_link_libraries(tetOpti_CLI hxt_core hxt_predicates hxt_tetMesh)
endif()
\ No newline at end of file
cmake_minimum_required(VERSION 3.9)
project(hxt_core C)
# include guard for CMake:
# if you plan to include multiple directory that depend on this one,
# you need to include this directory first
if(TARGET hxt_core)
return()
endif()
#################################################################################
# Options
#################################################################################
option(HXT_ENABLE_OPENMP "Enable OpenMP" ON)
option(HXT_ALIGN_ALLOCATIONS "Align allocation" OFF)
option(HXT_CORE_OBJECT_ONLY "Do not create hxt_core library" ON)
#################################################################################
# Library definition
#################################################################################
set(HXT_CORE_SRC
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_bbox.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_mesh.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_message.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_opt.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hxt_sort.c"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_bbox.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_mesh.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_message.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_omp.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_opt.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_sort.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/hxt_tools.h"
)
if(HXT_CORE_OBJECT_ONLY)
# make an object library (no archive)
add_library(hxt_core OBJECT ${HXT_CORE_SRC})
else()
add_library(hxt_core ${HXT_CORE_SRC})
endif()
target_include_directories(hxt_core PUBLIC include)
target_compile_features(hxt_core PRIVATE c_std_99)
if(HXT_ENABLE_OPENMP)
find_package(OpenMP 4)
if(OpenMP_C_FOUND)
target_link_libraries(hxt_core PUBLIC OpenMP::OpenMP_C)
endif()
endif()
#################################################################################
# Compilation flags corresponding to options
#################################################################################
if(HXT_ALIGN_ALLOCATIONS)
target_compile_definitions(hxt_core PUBLIC HXT_ALIGN_ALLOCATIONS)
endif()
// Hxt - Copyright (C)
// 2016 - 2020 UCLouvain
//
// See the LICENSE.txt file for license information.
//
// Contributor(s):
// Célestin Marot
#ifndef HXT_BBOX_H
#define HXT_BBOX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <hxt_tools.h> // for stdint.h and hxtDeclareAligned32 only
#include <float.h>
// the fourth member is unused...
typedef struct hxtBboxStruct{
double hxtDeclareAligned32 min[3];
uint64_t pad_u64; // padding U can use however you want
double hxtDeclareAligned32 max[3];
double pad_double; // padding U can use however you want
} HXTBbox;
static inline void hxtBboxInit(HXTBbox* bbox){
bbox->min[0] = DBL_MAX;
bbox->min[1] = DBL_MAX;
bbox->min[2] = DBL_MAX;
bbox->max[0] = -DBL_MAX;
bbox->max[1] = -DBL_MAX;
bbox->max[2] = -DBL_MAX;
}
static inline void hxtBboxFrom(HXTBbox* bbox,
double* coord)
{
for (unsigned i=0; i<3; i++)
{
bbox->min[i] = coord[i];
bbox->max[i] = coord[i];
}
}
/* update the bounding box with one new vertex */
static inline void hxtBboxAddOne(HXTBbox* bbox,
double* coord)
{
for (unsigned i=0; i<3; i++)
{
if(coord[i]<bbox->min[i])
bbox->min[i] = coord[i];
if(coord[i]>bbox->max[i])
bbox->max[i] = coord[i];
}
}
/* update the bounding box with an array of n vertices at once (far quicker) */
void hxtBboxAdd(HXTBbox* bbox, double* coord, const uint32_t n);
static inline int hxtBboxesIntersect(HXTBbox* bb0, HXTBbox* bb1) {
if(bb0->min[0] > bb1->max[0] ||
bb0->min[1] > bb1->max[1] ||
bb0->min[2] > bb1->max[2] ||
bb0->max[0] < bb1->min[0] ||
bb0->max[1] < bb1->min[1] ||
bb0->max[2] < bb1->min[2])
return 0;
return 1;
}
/* merge two bbox (result can be a pointer to bbox1 or bbox2) */
// void hxtBboxMerge(HXTBbox* bbox1, HXTBbox* bbox2, HXTBbox* bboxResult);
#ifdef __cplusplus
}
#endif
#endif
#ifndef HXT_MESH_H
#define HXT_MESH_H
#ifdef __cplusplus
extern "C" {
#endif
#include "hxt_message.h"
#include <stdint.h>
#define HXT_GHOST_VERTEX UINT32_MAX
#define HXT_NO_ADJACENT UINT64_MAX
/* Element types, same as Gmsh */
typedef enum {
HXT_NO_ELT = 0,
HXT_LINE = 1,
HXT_TRI = 2,
HXT_QUAD = 3,
HXT_TET = 4,
HXT_HEX = 5,
HXT_PRI = 6,
HXT_PYR = 7
} HXT_ELT_TYPE;
typedef struct {
// vertices
struct {
uint32_t num;
uint32_t size;
double* coord; // 3 coordinates + 1 double per vertex!
} vertices;
// tetrahedra
struct {
uint32_t* node; // aligned (size = tetrahedra.size*4*sizeof(uint32_t))
uint64_t* neigh; // aligned (size = tetrahedra.size*4*sizeof(uint64_t))
uint8_t* neighType;
uint16_t* colors;
uint16_t* flag;
uint64_t num; // number of tetrahedra
uint64_t size; // reserved number of tetrahedra (size of the vector)
} tetrahedra;
// hexahedra
struct {
uint32_t* node; // aligned (size = hexahedra.size*8*sizeof(uint32_t))
uint64_t* neigh; // aligned (size = hexahedra.size*6*sizeof(uint64_t))
uint8_t* neighType;
uint16_t* colors;
uint16_t* flag;
uint64_t num; // number of tetrahedra
uint64_t size; // reserved number of hexahedra (size of the vector)
} hexahedra;
// prisms
struct {
uint32_t* node; // aligned (size = prisms.size*6*sizeof(uint32_t))
uint64_t* neigh; // aligned (size = prisms.size*5*sizeof(uint64_t))
uint8_t* neighType;
uint16_t* colors;
uint16_t* flag;
uint64_t num; // number of tetrahedra
uint64_t size; // reserved number of prisms (size of the vector)
} prisms;
// pyramids
struct {
uint32_t* node; // aligned (size = pyramids.size*5*sizeof(uint32_t))
uint64_t* neigh; // aligned (size = pyramids.size*5*sizeof(uint64_t))
uint8_t* neighType;
uint16_t* colors;
uint16_t* flag;
uint64_t num; // number of tetrahedra
uint64_t size; // reserved number of pyramids (size of the vector)
} pyramids;
// triangles // TODO: consider writing a array of structure...
struct {
uint32_t* node;
uint64_t* neigh;
uint16_t* colors;
uint64_t num;
uint64_t size;
} triangles;
struct {
uint32_t* node;
uint64_t* neigh;
uint16_t* colors;
uint64_t num;
uint64_t size;
} triangles2;
// quads
struct {
uint32_t* node;
uint16_t* colors;
uint64_t num;
uint64_t size;
} quads;
// lines // TODO: consider writing a array of structure...
struct {
uint32_t* node;
uint16_t* colors;
uint64_t num;
uint64_t size;
} lines;
struct {
uint32_t* node;
uint16_t* colors;
uint32_t num;
uint32_t size;
} points;
// boundary representation
struct {
uint16_t numVolumes;
uint16_t *numSurfacesPerVolume;
uint16_t *surfacesPerVolume;
uint16_t numSurfaces;
uint16_t *numCurvesPerSurface;
uint16_t *curvesPerSurface;
uint16_t numCurves;
uint16_t *endPointsOfCurves;
uint16_t numPoints;
uint16_t *points;
} brep;
} HXTMesh;
HXTStatus hxtMeshCreate ( HXTMesh** mesh);
HXTStatus hxtMeshDelete ( HXTMesh** meshPtr);
// mesh I/O
HXTStatus hxtMeshReadGmsh ( HXTMesh* mesh, const char* filename);
HXTStatus hxtMeshWriteGmsh ( HXTMesh* mesh, const char* filename);
#ifdef __cplusplus
}
#endif
#endif
// Hxt - Copyright (C)
// 2016 - 2020 UCLouvain
//
// See the LICENSE.txt file for license information.
//
// Contributor(s):
// Célestin Marot
#ifndef HXT_MESSAGE_H
#define HXT_MESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdarg.h>
/* HEXTREME FUNCTIONS ONLY RETURN A STATUS (except hxtGetMessageString)*/
typedef enum
{
// positive values mean a success => HXT_CHECK does nothing for positive values
HXT_STATUS_OK = 0,
HXT_STATUS_TRUE = 0,
HXT_STATUS_FALSE = 1,
// ====== ERRORS
// negatives values means errors
// Fatal Errors => HXT_CHECK give trace message and return
HXT_STATUS_ERROR = -1,
HXT_STATUS_FAILED = -2,
HXT_STATUS_ASSERTION_FAILED = -3,
HXT_STATUS_OUT_OF_MEMORY = -4,
HXT_STATUS_FILE_CANNOT_BE_OPENED = -5,
HXT_STATUS_POINTER_ERROR = -6,
HXT_STATUS_READ_ERROR = -7,
HXT_STATUS_WRITE_ERROR = -8,
HXT_STATUS_RANGE_ERROR = -9,
HXT_STATUS_FORMAT_ERROR = -10,
// INTERNAL Errors (<= HXT_STATUS_INTERNAL) => HXT_CHECK does not give trace message but returns... should be catched internally !
HXT_STATUS_INTERNAL = -1024,
HXT_STATUS_SKIP = -1025,
HXT_STATUS_TRYAGAIN = -1026,
// a smoothing or topological operation can silently fail because of these
HXT_STATUS_CONFLICT = -1027,
HXT_STATUS_CONSTRAINT = -1028,
HXT_STATUS_NOTBETTER = -1029,
HXT_STATUS_DOUBLE_PT = -1030
}HXTStatus;
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#define HXT_INFO(...) hxtMessageInfo(__func__, __FILE__, STRINGIFY(__LINE__), ## __VA_ARGS__ )
#define HXT_INFO_COND(cond, ...) ((cond)?HXT_INFO(__VA_ARGS__):HXT_STATUS_OK)
#define HXT_WARNING(...) hxtMessageWarning(__func__, __FILE__, STRINGIFY(__LINE__), ## __VA_ARGS__ )
/* print an error message corresponding to a status */
#define HXT_ERROR_MSG(status, ...) hxtMessageError(status, __func__, __FILE__, STRINGIFY(__LINE__), ## __VA_ARGS__ )
#define HXT_ERROR(status) HXT_ERROR_MSG(status,NULL)
/* give trace message if status is not OK, but does not return */
#define HXT_TRACE_MSG(status, ...) hxtMessageTraceError(status, __func__, __FILE__, STRINGIFY(__LINE__), ## __VA_ARGS__ )
#define HXT_TRACE(status) HXT_TRACE_MSG(status, NULL)
/* give trace message and return the error status if not ok */
#define HXT_CHECK_MSG(status, ...) \
do { \
HXTStatus _tmp_ = status; \
if(_tmp_<0) { \
if (_tmp_>HXT_STATUS_INTERNAL) { \
HXT_TRACE_MSG(_tmp_, ## __VA_ARGS__); \
} \
return _tmp_; \
} \
} while(0)
#define HXT_CHECK(status) HXT_CHECK_MSG(status,NULL)
/* use to check some expression inside of function, throw error if exp is not true */
#ifndef NDEBUG
#define HXT_ASSERT_MSG(exp, ...) \
do { \
if (!(exp)) { \
HXT_ERROR_MSG(HXT_STATUS_ASSERTION_FAILED, ## __VA_ARGS__ ); \
abort(); \
} \
} while(0)
#define HXT_ASSERT(exp) HXT_ASSERT_MSG(exp, "assertion (" #exp ") Failed")
#else
#define HXT_ASSERT_MSG(exp, ...)
#define HXT_ASSERT(exp)
#endif
const char* hxtGetStatusString(HXTStatus status);
/* MESSAGE */
typedef struct {
/* the message content */
const char* string; // lifetime = time of callback function
/* information about the location of the code which sent the message */
const char* func; // lifetime = forever
const char* file; // lifetime = forever
const char* line; // lifetime = forever
int threadId; // the thread which sent the message
int numThreads; // the number of threads
enum{
HXT_MSGLEVEL_INFO = 0,
HXT_MSGLEVEL_DEBUG = 1,
HXT_MSGLEVEL_WARNING = 2,
HXT_MSGLEVEL_ERROR = 3,
HXT_MSGLEVEL_TRACE = 4
} level;
} HXTMessage;
/* MESSAGE AND ERROR HANDLING */
HXTStatus hxtSetMessageCallback (HXTStatus (*hxtMsgCallback)(HXTMessage* msg));
HXTStatus hxtMessageInfo ( const char* func, const char* file, const char* line, const char *fmt, ...);
HXTStatus hxtMessageWarning ( const char* func, const char* file, const char* line, const char *fmt, ...);
HXTStatus hxtMessageError ( HXTStatus status, const char* func, const char* file, const char* line, const char *fmt, ...);
HXTStatus hxtMessageTraceError ( HXTStatus status, const char* func, const char* file, const char* line, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif
#ifndef _HXT_OMP_H_
#define _HXT_OMP_H_
#ifdef _OPENMP
#include <omp.h>
#else
#include <time.h>
static inline int omp_get_max_threads(void) {return 1;}
static inline int omp_get_thread_num(void) {return 0;}
static inline int omp_get_num_threads(void) {return 1;}
static inline int omp_get_num_procs(void) {return 1;}
static inline int omp_get_thread_limit(void) {return 1;}
static inline void omp_set_num_threads(int n) { ; }
static inline double omp_get_wtime(void) {
clock_t t = clock();
return (double)t/CLOCKS_PER_SEC;
}
#endif
#endif //_HXT_OMP_H_
// Hxt - Copyright (C)
// 2016 - 2020 UCLouvain
//
// See the LICENSE.txt file for license information.
//
// Contributor(s):
// Célestin Marot
#ifndef __HXT_OPT_H__
#define __HXT_OPT_H__
#include "hxt_message.h"
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************************
* argument type: the type of the argument that must be given to the option
* or HXT[_NO]_FLAG to indicate that the option doesn't have an argument
***************************************************************************************/
typedef enum {
// flags
// no argument must be given, the value must be an integer set to 0 (it is set to 1 when option is called)
HXT_FLAG,
// no argument must be given, the value must be an integer set to 1 (it is set to 0 when option is called)
HXT_NO_FLAG,
// floating point values:
HXT_DOUBLE,
HXT_FLOAT,
// integer values
HXT_INT,
HXT_I64,
HXT_I32,
HXT_I16,
// unsigned integer values
HXT_UNSIGNED,