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

use full buffer for 2nd part of fastAdjacencies

parent 2b2bdfb7
......@@ -41,6 +41,7 @@ typedef struct HXT_Delaunay_struct {
uint64_t size_deleted;
void* buffer;
uint64_t bufferN;
} Delaunay_t;
static inline uint64_t walking2cavity(mesh_t* mesh, uint64_t curTet, const uint32_t vta);
......@@ -49,6 +50,18 @@ static inline status_t fillingacavity(mesh_t* mesh, Delaunay_t* Del, uint64_t* c
static inline status_t remove_deleted(mesh_t* mesh, Delaunay_t* Del);
static inline void compute_subDet(mesh_t* mesh, const uint64_t curTet);
/* by Jim Ulery , to avoid linking to libm*/
static unsigned julery_isqrt(unsigned long val) {
unsigned long temp, g=0, b = 0x8000, bshft = 15;
do {
if (val >= (temp = (((g << 1) + b)<<bshft--))) {
g += b;
val -= temp;
}
} while (b >>= 1);
return g;
}
status_t HXT_mesh_create ( mesh_t** mesh) {
HXT_CHECK( HXT_malloc (mesh, sizeof(mesh_t)) );
......@@ -227,7 +240,8 @@ status_t HXT_tetrahedra_compute(mesh_t* mesh){
HXT_CHECK( HXT_malloc(&Del.tmp, Del.size_tmp*sizeof(Del.tmp[0])) );
HXT_CHECK( HXT_malloc(&Del.deleted, Del.size_deleted*sizeof(uint64_t)) );
HXT_CHECK( HXT_malloc(&Del.buffer, MAX(sizeof(uint64_t)*1024, sizeof(uint32_t)*(mesh->num_vertices+1))) );
HXT_CHECK( HXT_malloc(&Del.buffer, MAX(sizeof(uint64_t)*32*32, sizeof(uint32_t)*(mesh->num_vertices+1))) );
Del.bufferN = MAX(32, julery_isqrt((mesh->num_vertices+1)/2))*2 - 4;
uint64_t curTet = 0; // we always begin with the first tet. (index 0)
......@@ -568,8 +582,9 @@ status_t diggingacavity(mesh_t* mesh, Delaunay_t* Del, uint64_t curTet, const ui
// 2N triangle on the surface of the cavity, x3 (4*0.5+1) data = 6N+9 uint64_t
// => enough place for the 3N edge x2 data = 6N uint64_t
status_t computeAdjacencies(mesh_t* mesh, Delaunay_t* Del, const uint64_t start, const uint64_t blength){
if(blength<=60){ // N+2<=32 => N<=30 => 2N<=60
if(blength<=Del->bufferN){ // N+2<=32 => N<=30 => 2N<=60
// for each point p on the surface of the cavity, compute p-vti
uint32_t npts = 0;
{
uint32_t* bufferu32 = Del->buffer;
uint64_t i;
......@@ -580,7 +595,6 @@ status_t computeAdjacencies(mesh_t* mesh, Delaunay_t* Del, const uint64_t start,
bufferu32[Node[3]+1] = UINT32_MAX;
}
uint64_t npts = 0;
for (i=0; i<blength; i++)
{
uint32_t* Node = Del->tmp[i].node;
......@@ -596,10 +610,6 @@ status_t computeAdjacencies(mesh_t* mesh, Delaunay_t* Del, const uint64_t start,
bufferu32[Node[3]+1] = npts++;
}
Node[3] = bufferu32[Node[3]+1];
HXT_ASSERT(Node[1]<=mesh->num_vertices);
HXT_ASSERT(Node[2]<=mesh->num_vertices);
HXT_ASSERT(Node[3]<=mesh->num_vertices);
}
}
......@@ -607,16 +617,16 @@ status_t computeAdjacencies(mesh_t* mesh, Delaunay_t* Del, const uint64_t start,
uint64_t i;
for (i=0; i<blength; i++)
{
bufferu64[Del->tmp[i].node[1]*32 + Del->tmp[i].node[2]] = Del->tmp[i].bnd + 3;
bufferu64[Del->tmp[i].node[2]*32 + Del->tmp[i].node[3]] = Del->tmp[i].bnd + 1;
bufferu64[Del->tmp[i].node[3]*32 + Del->tmp[i].node[1]] = Del->tmp[i].bnd + 2;
bufferu64[Del->tmp[i].node[1]*npts + Del->tmp[i].node[2]] = Del->tmp[i].bnd + 3;
bufferu64[Del->tmp[i].node[2]*npts + Del->tmp[i].node[3]] = Del->tmp[i].bnd + 1;
bufferu64[Del->tmp[i].node[3]*npts + Del->tmp[i].node[1]] = Del->tmp[i].bnd + 2;
}
for (i=0; i<blength; i++)
{
mesh->tetrahedra.neigh[Del->tmp[i].bnd+ 1] = bufferu64[Del->tmp[i].node[3]*32 + Del->tmp[i].node[2]];
mesh->tetrahedra.neigh[Del->tmp[i].bnd+ 2] = bufferu64[Del->tmp[i].node[1]*32 + Del->tmp[i].node[3]];
mesh->tetrahedra.neigh[Del->tmp[i].bnd+ 3] = bufferu64[Del->tmp[i].node[2]*32 + Del->tmp[i].node[1]];
mesh->tetrahedra.neigh[Del->tmp[i].bnd+ 1] = bufferu64[Del->tmp[i].node[3]*npts + Del->tmp[i].node[2]];
mesh->tetrahedra.neigh[Del->tmp[i].bnd+ 2] = bufferu64[Del->tmp[i].node[1]*npts + Del->tmp[i].node[3]];
mesh->tetrahedra.neigh[Del->tmp[i].bnd+ 3] = bufferu64[Del->tmp[i].node[2]*npts + Del->tmp[i].node[1]];
}
}
else{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment