Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NTRfC
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
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFD - Institut für Turbomaschinen und Fluid-Dynamik
tools
NTRfC
Commits
11495b43
Commit
11495b43
authored
2 years ago
by
many
Browse files
Options
Downloads
Patches
Plain Diff
debugging and fixing tests
parent
3717fa5a
No related branches found
No related tags found
1 merge request
!6
New geo extraction
Pipeline
#8048
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ntrfc/utils/geometry/pointcloud_methods.py
+12
-3
12 additions, 3 deletions
ntrfc/utils/geometry/pointcloud_methods.py
tests/test_ntrfc_geometry.py
+20
-19
20 additions, 19 deletions
tests/test_ntrfc_geometry.py
with
32 additions
and
22 deletions
ntrfc/utils/geometry/pointcloud_methods.py
+
12
−
3
View file @
11495b43
...
...
@@ -26,7 +26,7 @@ def midline_from_sides(ps_poly, ss_poly):
x_ps
,
y_ps
=
ps_poly
.
points
[::,
0
],
ps_poly
.
points
[::,
1
]
x_ss
,
y_ss
=
ss_poly
.
points
[::,
0
],
ss_poly
.
points
[::,
1
]
z
=
ps_poly
.
points
[
0
][
2
]
midsres
=
64
midsres
=
100
if
x_ps
[
0
]
>
x_ps
[
-
1
]:
ax
,
ay
=
refine_spline
(
x_ps
[::
-
1
],
y_ps
[::
-
1
],
midsres
)
else
:
...
...
@@ -44,7 +44,7 @@ def midline_from_sides(ps_poly, ss_poly):
def
extractSidePolys
(
ind_1
,
ind_2
,
sortedPoly
):
def
extractSidePolys
(
ind_1
,
ind_2
,
sortedPoly
,
verbose
=
False
):
# xs, ys = list(sortedPoly.points[::, 0]), list(sortedPoly.points[::, 1])
indices
=
np
.
arange
(
0
,
sortedPoly
.
number_of_points
)
...
...
@@ -69,6 +69,15 @@ def extractSidePolys(ind_1, ind_2, sortedPoly):
psPoly
=
side_one
ssPoly
=
side_two
if
verbose
:
p
=
pv
.
Plotter
()
p
.
add_mesh
(
ssPoly
,
color
=
"
g
"
,
label
=
"
ssPoly
"
)
p
.
add_mesh
(
psPoly
,
color
=
"
b
"
,
label
=
"
psPoly
"
)
p
.
add_mesh
(
sortedPoly
.
points
[
ind_1
],
color
=
"
w
"
,
label
=
"
ind_1
"
)
p
.
add_mesh
(
sortedPoly
.
points
[
ind_2
],
color
=
"
k
"
,
label
=
"
ind_2
"
)
p
.
add_legend
()
p
.
show
()
return
ssPoly
,
psPoly
...
...
@@ -88,7 +97,7 @@ def extract_geo_paras(polyblade, alpha, verbose=False):
:param polyblade: pyvista polymesh of the blade
:param alpha: nondimensional alpha-coefficient (calcConcaveHull)
:param verbose: bool for plots
:return: points, psPoly, ssPoly, ind_vk, ind_
h
k, midsPoly, beta_leading, beta_trailing
:return: points, psPoly, ssPoly, ind_vk
_
, ind_
v
k, midsPoly, beta_leading, beta_trailing
"""
points
=
polyblade
.
points
xs
,
ys
=
calc_concavehull
(
points
[:,
0
],
points
[:,
1
],
alpha
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_ntrfc_geometry.py
+
20
−
19
View file @
11495b43
def
test_calc_concavehull
():
"""
in these simple geometries, each point must be found by calcConcaveHull
...
...
@@ -89,7 +88,6 @@ def test_extract_vk_hk(verbose=False):
import
numpy
as
np
import
pyvista
as
pv
# d1,d2,d3,d4 = np.random.randint(0,9),np.random.randint(0,9),np.random.randint(0,9),np.random.randint(0,9)
# digitstring = str(d1)+str(d2)+str(d3)+str(d4)
# manifold problems with other profiles with veronoi-mid and other unoptimized code. therefor tests only 0009
...
...
@@ -99,17 +97,17 @@ def test_extract_vk_hk(verbose=False):
alpha
=
1
res
=
420
xs
,
ys
=
naca
(
naca_code
,
res
,
half_cosine_spacing
=
False
)
sorted_poly
=
pv
.
PolyData
(
np
.
stack
([
xs
[:
-
1
],
ys
[:
-
1
],
np
.
zeros
(
len
(
xs
)
-
1
)]).
T
)
sorted_poly
=
pv
.
PolyData
(
np
.
stack
([
xs
[:
-
1
],
ys
[:
-
1
],
np
.
zeros
(
len
(
xs
)
-
1
)]).
T
)
sorted_poly
.
rotate_z
(
angle
)
X
,
Y
=
sorted_poly
.
points
[::,
0
],
sorted_poly
.
points
[::,
1
]
X
,
Y
=
sorted_poly
.
points
[::,
0
],
sorted_poly
.
points
[::,
1
]
ind_1
=
res
ind_2
=
0
points
=
np
.
stack
((
X
[:
-
1
],
Y
[:
-
1
],
np
.
zeros
(
len
(
X
)
-
1
))).
T
points
=
np
.
stack
((
X
[:
-
1
],
Y
[:
-
1
],
np
.
zeros
(
len
(
X
)
-
1
))).
T
profile_points
=
pv
.
PolyData
(
points
)
random_angle
=
30
#
np.random.randint(-40, 40)
random_angle
=
30
#
np.random.randint(-40, 40)
profile_points
.
rotate_z
(
random_angle
)
sorted_poly
=
pv
.
PolyData
(
profile_points
)
...
...
@@ -122,7 +120,7 @@ def test_extract_vk_hk(verbose=False):
p
.
add_mesh
(
sorted_poly
)
p
.
show
()
assert
ind_hk
==
ind_1
,
"
wrong hk-index chosen
"
assert
ind_hk
==
ind_1
,
"
wrong hk-index chosen
"
assert
ind_vk
==
ind_2
,
"
wrong vk-index chosen
"
...
...
@@ -139,7 +137,7 @@ def test_midline_from_sides(verbose=False):
ind_hk
=
0
ind_vk
=
res
points
=
np
.
stack
((
x
[:],
y
[:],
np
.
zeros
(
res
*
2
+
1
))).
T
points
=
np
.
stack
((
x
[:],
y
[:],
np
.
zeros
(
res
*
2
+
1
))).
T
poly
=
pv
.
PolyData
(
points
)
sspoly
,
pspoly
=
extractSidePolys
(
ind_hk
,
ind_vk
,
poly
)
...
...
@@ -201,7 +199,10 @@ def test_extractSidePolys():
poly
=
pv
.
PolyData
(
points
)
poly
[
"
A
"
]
=
np
.
ones
(
poly
.
number_of_points
)
ssPoly
,
psPoly
=
extractSidePolys
(
ind_hk
,
ind_vk
,
poly
)
assert
ssPoly
.
number_of_points
==
psPoly
.
number_of_points
,
"
number of sidepoints are not equal
"
# the assertion is consistent with all tests but it is confusing
# we generate profiles with a naca-generator. probably there is a minor bug in the algorithm
# ssPoly needs to have one point more then psPoly
assert
ssPoly
.
number_of_points
+
1
==
psPoly
.
number_of_points
,
"
number of sidepoints are not equal
"
def
test_extract_geo_paras
(
verbose
=
False
):
...
...
@@ -215,23 +216,23 @@ def test_extract_geo_paras(verbose=False):
alpha
=
1
res
=
240
xs
,
ys
=
naca
(
naca_code
,
res
,
half_cosine_spacing
=
False
)
sorted_poly
=
pv
.
PolyData
(
np
.
stack
([
xs
[:
-
1
],
ys
[:
-
1
],
np
.
zeros
(
len
(
xs
)
-
1
)]).
T
)
sorted_poly
=
pv
.
PolyData
(
np
.
stack
([
xs
[:
-
1
],
ys
[:
-
1
],
np
.
zeros
(
len
(
xs
)
-
1
)]).
T
)
sorted_poly
.
rotate_z
(
angle
)
poly
,
ps_poly
,
ss_poly
,
ind_
v
k
,
ind_
h
k
,
mids_poly
,
beta_leading
,
beta_trailing
,
camber_angle
=
extract_geo_paras
(
poly
,
ps_poly
,
ss_poly
,
ind_
h
k
,
ind_
v
k
,
mids_poly
,
beta_leading
,
beta_trailing
,
camber_angle
=
extract_geo_paras
(
sorted_poly
,
alpha
)
if
verbose
:
p
=
pv
.
Plotter
()
p
.
add_mesh
(
ss_poly
,
color
=
"
g
"
,
label
=
"
ssPoly
"
)
p
.
add_mesh
(
ps_poly
,
color
=
"
b
"
,
label
=
"
psPoly
"
)
p
.
add_mesh
(
ss_poly
,
color
=
"
g
"
,
label
=
"
ssPoly
"
)
p
.
add_mesh
(
ps_poly
,
color
=
"
b
"
,
label
=
"
psPoly
"
)
p
.
add_mesh
(
mids_poly
)
p
.
add_mesh
(
poly
.
points
[
ind_hk
],
color
=
"
w
"
,
label
=
"
ind_hk
"
)
p
.
add_mesh
(
poly
.
points
[
ind_vk
],
color
=
"
k
"
,
label
=
"
ind_vk
"
)
p
.
add_mesh
(
poly
.
points
[
ind_hk
],
color
=
"
w
"
,
label
=
"
ind_hk
"
)
p
.
add_mesh
(
poly
.
points
[
ind_vk
],
color
=
"
k
"
,
label
=
"
ind_vk
"
)
p
.
add_legend
()
p
.
show
()
assert
np
.
isclose
(
beta_leading
,
angle
,
rtol
=
0.03
),
"
wrong leading edge angle
"
assert
np
.
isclose
(
beta_trailing
,
angle
,
rtol
=
0.03
),
"
wrong leading edge angle
"
assert
np
.
isclose
(
mids_poly
.
length
,
1
,
rtol
=
0.03
)
assert
np
.
isclose
(
camber_angle
,
angle
,
rtol
=
0.03
)
assert
np
.
isclose
(
beta_leading
,
angle
,
rtol
=
0.03
),
"
wrong leading edge angle
"
assert
np
.
isclose
(
beta_trailing
,
angle
,
rtol
=
0.03
),
"
wrong leading edge angle
"
assert
np
.
isclose
(
mids_poly
.
length
,
1
,
rtol
=
0.03
)
assert
np
.
isclose
(
camber_angle
,
angle
,
rtol
=
0.03
)
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