Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
4b74e8c1
Commit
4b74e8c1
authored
4 years ago
by
Célestin Marot
Browse files
Options
Downloads
Patches
Plain Diff
introduce hashtable
parent
907a89bc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/hxt/tetMesh/src/hxt_tetDelaunayReshape.c
+76
-28
76 additions, 28 deletions
contrib/hxt/tetMesh/src/hxt_tetDelaunayReshape.c
with
76 additions
and
28 deletions
contrib/hxt/tetMesh/src/hxt_tetDelaunayReshape.c
+
76
−
28
View file @
4b74e8c1
#include
"hxt_tetDelaunayReshape.h"
#include
"hxt_tetDelaunayReshape.h"
#include
"hxt_mesh.h"
#include
"hxt_message.h"
#include
"hxt_sort.h"
#include
"hxt_tetFlag.h"
#include
"hxt_tetFlag.h"
#include
"predicates.h"
#include
"predicates.h"
#include
<stdint.h>
#include
<stdint.h>
...
@@ -232,16 +235,54 @@ HXTStatus respectEdgeConstraint(TetLocal* local, HXTMesh* mesh, const uint32_t v
...
@@ -232,16 +235,54 @@ HXTStatus respectEdgeConstraint(TetLocal* local, HXTMesh* mesh, const uint32_t v
// make a super simple hash table to get a index in the deleted array (the value) from the index of a tet (the key)
// the hash table is of a size similar to the number of tet in the cavity.
typedef
struct
{
HXTGroup2
*
pairs
;
// key, value pairs
uint64_t
mask
;
}
HXTHashTable
;
HXTStatus
hashTableInit
(
HXTHashTable
*
map
,
uint64_t
numTet
)
{
unsigned
h
=
u64_log2
(
numTet
)
+
1
;
#ifdef DEBUG
if
(
h
>
63
)
return
HXT_ERROR
(
HXT_STATUS_OUT_OF_MEMORY
);
#endif
uint64_t
size
=
UINT64_C
(
1
)
<<
h
;
map
->
mask
=
size
-
1
;
HXT_CHECK
(
hxtMalloc
(
&
map
->
pairs
,
sizeof
(
HXTGroup2
)
*
size
)
);
for
(
uint64_t
i
=
0
;
i
<
size
;
i
++
)
{
map
->
pairs
[
i
].
v
[
0
]
=
HXT_NO_ADJACENT
;
// no tet in here
}
return
HXT_STATUS_OK
;
}
// this super simple hash table does not accept repeating the same element !
void
hashTablePut
(
HXTHashTable
*
map
,
uint64_t
key
,
uint64_t
value
)
{
uint64_t
hash
=
key
&
map
->
mask
;
while
(
map
->
pairs
[
hash
].
v
[
0
]
!=
HXT_NO_ADJACENT
)
{
hash
=
(
hash
+
1
)
&
map
->
mask
;
}
map
->
pairs
[
hash
].
v
[
0
]
=
key
;
map
->
pairs
[
hash
].
v
[
1
]
=
value
;
}
// this super simple hash talbe does not accept key that were not inserted !
uint64_t
hashTableGet
(
HXTHashTable
*
map
,
uint64_t
key
)
{
uint64_t
hash
=
key
&
map
->
mask
;
while
(
map
->
pairs
[
hash
].
v
[
0
]
!=
key
)
{
hash
=
(
hash
+
1
)
&
map
->
mask
;
}
return
map
->
pairs
[
hash
].
v
[
1
];
}
HXTStatus
hashTableDestroy
(
HXTHashTable
*
map
)
{
HXT_CHECK
(
hxtFree
(
&
map
->
pairs
)
);
#define BND_FACE_FLAG (UINT64_C(1)<<63)
return
HXT_STATUS_OK
;
}
// remove the tetrahedra adjacent to the face that does not see the point, progressively, until the cavity is star shaped...
// remove the tetrahedra adjacent to the face that does not see the point, progressively, until the cavity is star shaped...
HXTStatus
reshapeCavityIfNeeded
(
TetLocal
*
local
,
HXTMesh
*
mesh
,
const
uint32_t
vta
,
uint64_t
prevNumDeleted
)
HXTStatus
reshapeCavityIfNeeded
(
TetLocal
*
local
,
HXTMesh
*
mesh
,
const
uint32_t
vta
,
uint64_t
prevNumDeleted
)
...
@@ -253,37 +294,44 @@ HXTStatus reshapeCavityIfNeeded(TetLocal* local, HXTMesh* mesh, const uint32_t v
...
@@ -253,37 +294,44 @@ HXTStatus reshapeCavityIfNeeded(TetLocal* local, HXTMesh* mesh, const uint32_t v
// if the facet is not a facet of the cavity. To differentiate both, BND_FACE_FLAG is set for indices of the ball.
// if the facet is not a facet of the cavity. To differentiate both, BND_FACE_FLAG is set for indices of the ball.
uint64_t
numTet
=
local
->
deleted
.
num
-
prevNumDeleted
;
uint64_t
numTet
=
local
->
deleted
.
num
-
prevNumDeleted
;
uint64_t
*
tets
=
&
local
->
deleted
.
array
[
prevNumDeleted
];
uint64_t
*
tets
=
&
local
->
deleted
.
array
[
prevNumDeleted
];
uint64_t
*
faces
;
HXT_CHECK
(
hxtMalloc
(
&
faces
,
sizeof
(
uint64_t
)
*
4
*
numTet
)
);
for
(
uint64_t
i
=
0
;
i
<
4
*
numTet
;
i
++
)
{
faces
[
i
]
=
0
;
HXTHashTable
map
;
HXT_CHECK
(
hashTableInit
(
&
map
,
numTet
)
);
for
(
uint64_t
i
=
0
;
i
<
numTet
;
i
++
)
{
hashTablePut
(
&
map
,
tets
[
i
],
i
);
}
}
// A priori, the order in which the delete tet appear and the order in which the faces appear should match (see @diggingACavity)
uint64_t
tetToFind
=
mesh
->
tetrahedra
.
neigh
[
local
->
ball
.
array
[
0
].
neigh
];
uint64_t
*
faces
;
HXT_CHECK
(
hxtMalloc
(
&
faces
,
sizeof
(
uint64_t
)
*
4
*
numTet
)
);
// just copy the adjacency into faces
uint64_t
curFace
=
0
;
uint64_t
curFace
=
0
;
uint64_t
curTet
=
0
;
for
(
uint64_t
i
=
0
;
i
<
numTet
;
i
++
)
{
while
(
curTet
<
numTet
)
{
uint64_t
curTet
=
tets
[
i
];
if
(
tets
[
curTet
]
==
tetToFind
/
4
)
{
for
(
uint64_t
j
=
0
;
j
<
4
;
j
++
)
{
uint64_t
index
=
4
*
curTet
+
tetToFind
%
4
;
local
->
ball
.
array
[
curFace
].
neigh
=
index
;
uint64_t
neigh
=
mesh
->
tetrahedra
.
neigh
[
4
*
curTet
+
j
];
faces
[
index
]
=
curFace
;
if
(
neigh
!=
HXT_NO_ADJACENT
&&
getDeletedFlag
(
mesh
,
neigh
/
4
))
{
curFace
++
;
faces
[
4
*
i
+
j
]
=
4
*
hashTableGet
(
&
map
,
neigh
/
4
)
+
neigh
%
4
;
}
if
(
curFace
>=
local
->
ball
.
num
)
else
{
// it should be the next one in the ball, (we didn't change the order since @diggingACavity)
break
;
HXT_ASSERT
(
local
->
ball
.
array
[
curFace
].
neigh
==
neigh
);
faces
[
4
*
i
+
j
]
=
curFace
;
tetToFind
=
mesh
->
tetrahedra
.
neigh
[
local
->
ball
.
array
[
curFace
].
neigh
];
curFace
++
;
}
}
else
{
curTet
++
;
}
}
}
}
if
(
curFace
<
local
->
ball
.
num
)
{
HXT_CHECK
(
hashTableDestroy
(
&
map
)
);
#ifndef NDEBUG
if
(
curFace
!=
local
->
ball
.
num
)
{
return
HXT_ERROR_MSG
(
HXT_STATUS_ERROR
,
"DEBUG: Faces did not appear in the same order as deleted tet"
);
return
HXT_ERROR_MSG
(
HXT_STATUS_ERROR
,
"DEBUG: Faces did not appear in the same order as deleted tet"
);
}
}
#endif
// double *vtaCoord = &mesh->vertices.coord[4 * vta];
// double *vtaCoord = &mesh->vertices.coord[4 * vta];
...
@@ -335,10 +383,10 @@ HXTStatus reshapeCavityIfNeeded(TetLocal* local, HXTMesh* mesh, const uint32_t v
...
@@ -335,10 +383,10 @@ HXTStatus reshapeCavityIfNeeded(TetLocal* local, HXTMesh* mesh, const uint32_t v
// count++;
// count++;
// }
// }
// if(count)
//
//
if(count)
// printf("nbr of tet to undelete = %lu, nbr of deleted tet = %lu\n", count, local->deleted.num);
//
//
printf("nbr of tet to undelete = %lu, nbr of deleted tet = %lu\n", count, local->deleted.num);
// // STEP 3: compute all the flags at once ! ??
// //
//
STEP 3: compute all the flags at once ! ??
// STEP 4: put back the right neighbor value inside the ball struct
// STEP 4: put back the right neighbor value inside the ball struct
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment