Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
pyMOR
pymor
Commits
f9607f00
Commit
f9607f00
authored
Jul 05, 2022
by
René Fritze
Browse files
[tests] remove non-negative grid coord assumption
parent
54353a6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/pymortests/affine_grid.py
View file @
f9607f00
...
...
@@ -17,8 +17,10 @@ def _scale_tols_if_domain_bad(g, atol=1e-05, rtol=1e-08):
# "badly" shaped domains produce excessive errors
# same for large differences in absolute coord values
bbox
=
g
.
bounding_box
()
scale
=
1.0
lower_left
,
upper_right
=
bbox
[
0
],
bbox
[
1
]
magic_downscale
=
1e-3
if
g
.
dim
==
2
:
lower_left
,
upper_right
=
bbox
[
0
],
bbox
[
1
]
upper_left
=
np
.
array
([
lower_left
[
0
],
upper_right
[
1
]])
lower_right
=
np
.
array
([
lower_left
[
1
],
upper_right
[
0
]])
h
=
np
.
linalg
.
norm
(
upper_left
-
lower_left
)
...
...
@@ -26,10 +28,15 @@ def _scale_tols_if_domain_bad(g, atol=1e-05, rtol=1e-08):
min_l
=
min
(
w
,
h
)
max_l
=
max
(
w
,
h
)
ll
,
rr
=
np
.
linalg
.
norm
(
lower_left
),
np
.
linalg
.
norm
(
upper_right
)
scale
=
max
(
max_l
/
min_l
,
abs
(
rr
-
ll
)
*
1e-2
)
if
scale
>
100
:
rtol
*=
scale
/
10
atol
*=
scale
/
10
scale
=
max
(
max_l
/
min_l
,
abs
(
rr
-
ll
)
*
magic_downscale
)
if
g
.
dim
==
1
:
ratio
=
abs
(
upper_right
)
/
abs
(
lower_left
)
if
not
np
.
isfinite
(
ratio
):
ratio
=
abs
(
upper_right
)
*
magic_downscale
scale
=
max
(
ratio
,
abs
(
upper_right
-
lower_left
)
*
magic_downscale
)[
0
]
if
scale
>
10
:
rtol
*=
scale
atol
*=
scale
assert
np
.
isfinite
(
atol
)
assert
np
.
isfinite
(
rtol
)
return
atol
,
rtol
...
...
src/pymortests/fixtures/grid.py
View file @
f9607f00
...
...
@@ -16,15 +16,17 @@ from pymor.discretizers.builtin.grids.unstructured import UnstructuredTriangleGr
def
hy_domain_bounds
(
draw
,
grid_type
):
# domain points are limited to allow their norm2 computations
# TODO: allow negative coordinate points
max_abs
=
grid_type
.
MAX_DOMAIN_WIDTH
/
2
min_abs
=
grid_type
.
MIN_DOMAIN_WIDTH
/
2
domain_point
=
hyst
.
floats
(
allow_infinity
=
False
,
allow_nan
=
False
,
min_value
=
min_abs
,
max_value
=
max_abs
)
max_val
=
grid_type
.
MAX_DOMAIN_WIDTH
/
2
min_val
=
-
grid_type
.
MAX_DOMAIN_WIDTH
/
2
domain_point
=
hyst
.
floats
(
allow_infinity
=
False
,
allow_nan
=
False
,
allow_subnormal
=
False
,
min_value
=
min_val
,
max_value
=
max_val
)
ll
=
draw
(
hyst
.
tuples
(
*
[
domain_point
]
*
grid_type
.
dim
))
def
_filter
(
d
):
return
all
(
l
<
r
for
l
,
r
in
zip
(
ll
,
d
))
and
grid_type
.
_check_domain
((
ll
,
d
))
return
(
all
(
l
<
r
and
abs
(
r
-
l
)
>
grid_type
.
MIN_DOMAIN_WIDTH
for
l
,
r
in
zip
(
ll
,
d
))
and
grid_type
.
_check_domain
((
ll
,
d
)))
ll
=
draw
(
hyst
.
tuples
(
*
[
domain_point
]
*
grid_type
.
dim
))
rr
=
draw
(
hyst
.
tuples
(
*
[
domain_point
]
*
grid_type
.
dim
).
filter
(
_filter
))
return
ll
,
rr
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment