Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
1138db00
Commit
1138db00
authored
9 years ago
by
Bert Vandenbroucke
Browse files
Options
Downloads
Patches
Plain Diff
voronoi_intersect now uses unit tested find_closest_vertex function.
parent
504111bc
No related branches found
No related tags found
1 merge request
!321
1D and 2D moving mesh algorithm
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hydro/Shadowswift/voronoi3d_algorithm.h
+12
-160
12 additions, 160 deletions
src/hydro/Shadowswift/voronoi3d_algorithm.h
with
12 additions
and
160 deletions
src/hydro/Shadowswift/voronoi3d_algorithm.h
+
12
−
160
View file @
1138db00
...
@@ -608,168 +608,20 @@ __attribute__((always_inline)) INLINE void voronoi_intersect(
...
@@ -608,168 +608,20 @@ __attribute__((always_inline)) INLINE void voronoi_intersect(
dx
[
2
]
=
-
0
.
5
f
*
odx
[
2
];
dx
[
2
]
=
-
0
.
5
f
*
odx
[
2
];
r2
=
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
];
r2
=
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
];
// test the first vertex: uw = -1 if it is below the plane, 1 if it is above
int
result
=
voronoi_intersect_find_closest_vertex
(
// 0 if it is very close to the plane, and things become complicated...
c
,
dx
,
r2
,
&
u
,
&
up
,
&
us
,
&
uw
,
&
l
,
&
lp
,
&
ls
,
&
lw
,
&
q
,
&
qp
,
&
qs
,
&
qw
);
uw
=
voronoi_test_vertex
(
&
c
->
vertices
[
0
],
dx
,
r2
,
&
u
,
teststack
,
if
(
result
<
0
)
{
&
teststack_size
);
error
(
"Error while searching intersected edge!"
);
up
=
0
;
}
complicated
=
0
;
if
(
!
result
)
{
if
(
uw
==
0
)
{
/* no intersection */
return
;
/* PATH 0 */
}
if
(
result
==
2
)
{
complicated
=
1
;
complicated
=
1
;
}
else
{
}
else
{
complicated
=
0
;
// two options: either the vertex is above or below the plane
}
if
(
uw
==
1
)
{
/* PATH 1 */
// above: try to find a vertex below
// we test all edges of the current vertex stored in up (vertex 0) until
// we either find one below the plane or closer to the plane
lp
=
voronoi_get_edge
(
c
,
up
,
0
);
lw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
lp
],
dx
,
r2
,
&
l
,
teststack
,
&
teststack_size
);
us
=
1
;
/* Not in while: PATH 1.0 */
/* somewhere in while: PATH 1.1 */
/* last valid option of while: PATH 1.2 */
while
(
us
<
c
->
orders
[
up
]
&&
l
>=
u
)
{
lp
=
voronoi_get_edge
(
c
,
up
,
us
);
lw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
lp
],
dx
,
r2
,
&
l
,
teststack
,
&
teststack_size
);
us
++
;
}
// we increased us too much, correct this
us
--
;
if
(
l
>=
u
)
{
/* PATH 1.3 */
// up is the closest vertex to the plane, but is above the plane
// since the entire cell is convex, up is the closest vertex of all
// vertices of the cell
// this means the entire cell is supposedly above the plane, which is
// impossible
error
(
"Cell completely gone! This should not happen. (l >= u, l = %g, u "
"= %g)"
,
l
,
u
);
}
// we know that lp is closer to the plane or below the plane
// now find the index of the edge up-lp in the edge list of lp
ls
=
voronoi_get_edgeindex
(
c
,
up
,
us
);
// if lp is also above the plane, replace up by lp and repeat the process
// until lp is below the plane
while
(
lw
==
1
)
{
u
=
l
;
up
=
lp
;
us
=
0
;
while
(
us
<
ls
&&
l
>=
u
)
{
lp
=
voronoi_get_edge
(
c
,
up
,
us
);
lw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
lp
],
dx
,
r2
,
&
l
,
teststack
,
&
teststack_size
);
us
++
;
}
if
(
l
>=
u
)
{
us
++
;
while
(
us
<
c
->
orders
[
up
]
&&
l
>=
u
)
{
lp
=
voronoi_get_edge
(
c
,
up
,
us
);
lw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
lp
],
dx
,
r2
,
&
l
,
teststack
,
&
teststack_size
);
us
++
;
}
if
(
l
>=
u
)
{
error
(
"Cell completely gone! This should not happen. (l >= u, l = "
"%g, u = %g)"
,
l
,
u
);
}
}
us
--
;
ls
=
voronoi_get_edgeindex
(
c
,
up
,
us
);
}
// if lp is too close to the plane, replace up by lp and proceed to
// complicated setup
if
(
lw
==
0
)
{
up
=
lp
;
complicated
=
1
;
}
}
else
{
/* if(uw == 1) */
// below: try to find a vertex above
// we test all edges of the current vertex stored in up (vertex 0) until
// we either find one above the plane or closer to the plane
qp
=
voronoi_get_edge
(
c
,
up
,
0
);
qw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
qp
],
dx
,
r2
,
&
q
,
teststack
,
&
teststack_size
);
us
=
1
;
while
(
us
<
c
->
orders
[
up
]
&&
u
>=
q
)
{
qp
=
voronoi_get_edge
(
c
,
up
,
us
);
qw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
qp
],
dx
,
r2
,
&
q
,
teststack
,
&
teststack_size
);
us
++
;
}
if
(
u
>=
q
)
{
// up is the closest vertex to the plane and is below the plane
// since the cell is convex, up is the closest vertex of all vertices of
// the cell
// this means that the entire cell is below the plane
/* cell unaltered */
return
;
}
else
{
// the last increase in the loop pushed us too far, correct this
us
--
;
}
// repeat the above process until qp is closer or above the plane
while
(
qw
==
-
1
)
{
qs
=
voronoi_get_edgeindex
(
c
,
up
,
us
);
u
=
q
;
up
=
qp
;
us
=
0
;
while
(
us
<
qs
&&
u
>=
q
)
{
qp
=
voronoi_get_edge
(
c
,
up
,
us
);
qw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
qp
],
dx
,
r2
,
&
q
,
teststack
,
&
teststack_size
);
us
++
;
}
if
(
u
>=
q
)
{
us
++
;
while
(
us
<
c
->
orders
[
up
]
&&
u
>=
q
)
{
qp
=
voronoi_get_edge
(
c
,
up
,
us
);
qw
=
voronoi_test_vertex
(
&
c
->
vertices
[
3
*
qp
],
dx
,
r2
,
&
q
,
teststack
,
&
teststack_size
);
us
++
;
}
if
(
u
>=
q
)
{
/* cell unaltered */
return
;
}
}
us
--
;
}
if
(
qw
==
1
)
{
// qp is above the plane: initialize lp to up and replace up by qp
lp
=
up
;
ls
=
us
;
l
=
u
;
up
=
qp
;
us
=
voronoi_get_edgeindex
(
c
,
lp
,
ls
);
u
=
q
;
}
else
{
// too close to call: go to complicated setup
up
=
qp
;
complicated
=
1
;
}
}
/* if(uw == 1) */
}
/* if(uw == 0) */
int
vindex
=
-
1
;
int
vindex
=
-
1
;
int
visitflags
[
VORONOI3D_MAXNUMVERT
];
int
visitflags
[
VORONOI3D_MAXNUMVERT
];
...
...
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