Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psaap3-weno
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
Model registry
Operate
Environments
Monitor
Incidents
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
Andreas Klöckner
psaap3-weno
Commits
23a45444
Commit
23a45444
authored
5 years ago
by
Timothy A. Smith
Browse files
Options
Downloads
Patches
Plain Diff
introduce new test to check whether bug is in WENO.F90 or Mathematica script
parent
14bdf2b4
No related branches found
Branches containing commit
No related tags found
1 merge request
!33
Reference implementation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test.py
+43
-0
43 additions, 0 deletions
test.py
utilities.py
+2
-1
2 additions, 1 deletion
utilities.py
with
45 additions
and
1 deletion
test.py
+
43
−
0
View file @
23a45444
...
...
@@ -24,6 +24,49 @@ from data_for_test import ( # noqa: F401
def
test_weno_weight_computation
(
ctx_factory
,
flux_test_data_fixture
):
data
=
flux_test_data_fixture
def
weno_weights
(
oscillation
):
linear
=
np
.
array
([
0.1
,
0.6
,
0.3
])
eps
=
1e-6
raw_weights
=
np
.
empty
((
5
,
3
))
for
i
in
range
(
5
):
for
j
in
range
(
3
):
raw_weights
[
i
,
j
]
=
linear
[
j
]
/
(
oscillation
[
i
,
j
]
+
eps
)
**
2
weight_sum
=
raw_weights
.
sum
(
axis
=
1
)
weights
=
np
.
empty
((
5
,
3
))
for
i
in
range
(
5
):
for
j
in
range
(
3
):
weights
[
i
,
j
]
=
raw_weights
[
i
,
j
]
/
weight_sum
[
i
]
return
weights
prg
=
u
.
get_weno_program_with_root_kernel
(
"
weno_weights_pos
"
)
queue
=
u
.
get_queue
(
ctx_factory
)
weights_dev
=
u
.
empty_array_on_device
(
queue
,
data
.
nvars
,
3
)
prg
(
queue
,
nvars
=
data
.
nvars
,
characteristic_fluxes
=
data
.
char_fluxes_pos
,
combined_frozen_metrics
=
1.0
,
w
=
weights_dev
)
w
=
weno_weights
(
data
.
oscillation_pos
)
u
.
compare_arrays
(
weights_dev
.
get
(),
w
)
prg
=
u
.
get_weno_program_with_root_kernel
(
"
weno_weights_neg
"
)
queue
=
u
.
get_queue
(
ctx_factory
)
weights_dev
=
u
.
empty_array_on_device
(
queue
,
data
.
nvars
,
3
)
prg
(
queue
,
nvars
=
data
.
nvars
,
characteristic_fluxes
=
data
.
char_fluxes_neg
,
combined_frozen_metrics
=
1.0
,
w
=
weights_dev
)
w
=
weno_weights
(
data
.
oscillation_neg
)
u
.
compare_arrays
(
weights_dev
.
get
(),
w
)
def
test_weno_flux_uniform_grid
(
ctx_factory
,
flux_test_data_fixture
):
data
=
flux_test_data_fixture
...
...
This diff is collapsed.
Click to expand it.
utilities.py
+
2
−
1
View file @
23a45444
...
...
@@ -11,7 +11,8 @@ from pytest import approx
# {{{ arrays
def
compare_arrays
(
a
,
b
):
assert
a
==
approx
(
b
,
rel
=
1e-5
,
abs
=
2e-5
)
#assert a == approx(b, rel=1e-5, abs=2e-5)
assert
a
==
approx
(
b
,
rel
=
1e-12
,
abs
=
1e-14
)
def
random_array_on_device
(
queue
,
*
shape
):
...
...
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