Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
c34e69cf
Commit
c34e69cf
authored
Sep 22, 2020
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Replaced transposing with vectorized access when feasible.
parent
6acd9c49
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
DG_Approximation.py
+4
-3
4 additions, 3 deletions
DG_Approximation.py
Limiter.py
+2
-21
2 additions, 21 deletions
Limiter.py
Troubled_Cell_Detector.py
+1
-2
1 addition, 2 deletions
Troubled_Cell_Detector.py
Update_Scheme.py
+6
-13
6 additions, 13 deletions
Update_Scheme.py
with
13 additions
and
39 deletions
DG_Approximation.py
+
4
−
3
View file @
c34e69cf
...
@@ -14,7 +14,7 @@ TODO: Contemplate erasing inv_mass-matrix as it is identity -> Discuss
...
@@ -14,7 +14,7 @@ TODO: Contemplate erasing inv_mass-matrix as it is identity -> Discuss
TODO: Investigate why we need inverse mass matrix for initial projection,
\
TODO: Investigate why we need inverse mass matrix for initial projection,
\
but not A and B
but not A and B
TODO: Investigate why there are no weights in approx calc
TODO: Investigate why there are no weights in approx calc
TODO: Change transposing to vectorized access if feasible
TODO: Change transposing to vectorized access if feasible
-> Done
TODO: Implement argument check for unpacking of all configs
TODO: Implement argument check for unpacking of all configs
TODO: Contemplate verbose = show_plot?
TODO: Contemplate verbose = show_plot?
TODO: Change order of methods -> Done for Stability_Method
TODO: Change order of methods -> Done for Stability_Method
...
@@ -25,8 +25,9 @@ TODO: Write documentation for all methods
...
@@ -25,8 +25,9 @@ TODO: Write documentation for all methods
TODO: Add a verbose option
TODO: Add a verbose option
TODO: Check whether consistency is given/possible for each class instance
TODO: Check whether consistency is given/possible for each class instance
TODO: Make projection local variable -> Done (not for Limiter and Troubled_Cell_Detector)
TODO: Make projection local variable -> Done
TODO: Vector faster than Trans for longer processes, therefore replace ->
TODO: Vector faster than Trans for longer processes, therefore replace -> Done
TODO: Make sure time is changed to current_time everywhere
"""
"""
import
numpy
as
np
import
numpy
as
np
...
...
This diff is collapsed.
Click to expand it.
Limiter.py
+
2
−
21
View file @
c34e69cf
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
@author: Laura C. Kühle
@author: Laura C. Kühle
"""
"""
import
numpy
as
np
import
timeit
class
Limiter
(
object
):
class
Limiter
(
object
):
...
@@ -55,27 +53,10 @@ class MinMod(Limiter):
...
@@ -55,27 +53,10 @@ class MinMod(Limiter):
return
adapted_projection
return
adapted_projection
def
_set_cell_slope
(
self
,
projection
):
def
_set_cell_slope
(
self
,
projection
):
tic
=
timeit
.
default_timer
()
slope
=
[]
slope
=
[]
transposed_projection
=
np
.
transpose
(
projection
)
for
cell
in
range
(
len
(
projection
[
0
])):
for
cell
in
range
(
len
(
transposed_projection
)):
new_entry
=
sum
(
projection
[
degree
][
cell
]
*
(
degree
+
0.5
)
**
0.5
for
degree
in
range
(
1
,
len
(
projection
)))
new_entry
=
sum
(
transposed_projection
[
cell
][
degree
]
*
(
degree
+
0.5
)
**
0.5
for
degree
in
range
(
1
,
len
(
projection
)))
slope
.
append
(
new_entry
)
slope
.
append
(
new_entry
)
toc
=
timeit
.
default_timer
()
# print('Trans:', toc-tic)
tic
=
timeit
.
default_timer
()
slope1
=
[]
transposed_projection
=
projection
for
cell
in
range
(
len
(
transposed_projection
[
0
])):
new_entry
=
sum
(
transposed_projection
[
degree
][
cell
]
*
(
degree
+
0.5
)
**
0.5
for
degree
in
range
(
1
,
len
(
projection
)))
slope1
.
append
(
new_entry
)
toc
=
timeit
.
default_timer
()
# print('Vecto:', toc-tic)
#
# print(slope == slope1)
self
.
cell_slope
=
slope
[
self
.
cell
]
self
.
cell_slope
=
slope
[
self
.
cell
]
def
_determine_modification
(
self
,
projection
):
def
_determine_modification
(
self
,
projection
):
...
...
This diff is collapsed.
Click to expand it.
Troubled_Cell_Detector.py
+
1
−
2
View file @
c34e69cf
...
@@ -62,10 +62,9 @@ class WaveletDetector(TroubledCellDetector):
...
@@ -62,10 +62,9 @@ class WaveletDetector(TroubledCellDetector):
return
matrix
return
matrix
def
_calculate_wavelet_coeffs
(
self
,
projection
):
def
_calculate_wavelet_coeffs
(
self
,
projection
):
transposed_vector
=
np
.
transpose
(
projection
)
output_matrix
=
[]
output_matrix
=
[]
for
i
in
range
(
int
(
len
(
projection
[
0
])
/
2
)):
for
i
in
range
(
int
(
len
(
projection
[
0
])
/
2
)):
new_entry
=
0.5
*
(
transposed_vector
[
2
*
i
]
@
self
.
M1
+
transposed_vector
[
2
*
i
+
1
]
@
self
.
M2
)
new_entry
=
0.5
*
(
projection
[:,
2
*
i
]
@
self
.
M1
+
projection
[:,
2
*
i
+
1
]
@
self
.
M2
)
output_matrix
.
append
(
new_entry
)
output_matrix
.
append
(
new_entry
)
return
np
.
transpose
(
np
.
array
(
output_matrix
))
return
np
.
transpose
(
np
.
array
(
output_matrix
))
...
...
This diff is collapsed.
Click to expand it.
Update_Scheme.py
+
6
−
13
View file @
c34e69cf
...
@@ -13,6 +13,7 @@ TODO: Find better names for A, B, M1, and M2
...
@@ -13,6 +13,7 @@ TODO: Find better names for A, B, M1, and M2
"""
"""
import
numpy
as
np
import
numpy
as
np
import
timeit
class
UpdateScheme
(
object
):
class
UpdateScheme
(
object
):
...
@@ -105,17 +106,13 @@ class UpdateScheme(object):
...
@@ -105,17 +106,13 @@ class UpdateScheme(object):
new_projection
=
self
.
current_projection
.
copy
()
new_projection
=
self
.
current_projection
.
copy
()
for
cell
in
self
.
troubled_cells
:
for
cell
in
self
.
troubled_cells
:
np
.
transpose
(
new_projection
)
[
cell
]
=
self
.
limiter
.
apply
(
self
.
current_projection
,
cell
)
new_projection
[
:,
cell
]
=
self
.
limiter
.
apply
(
self
.
current_projection
,
cell
)
self
.
current_projection
=
new_projection
self
.
current_projection
=
new_projection
def
_enforce_boundary_condition
(
self
):
def
_enforce_boundary_condition
(
self
):
transposed_projection
=
np
.
transpose
(
self
.
current_projection
)
self
.
current_projection
[:,
0
]
=
self
.
current_projection
[:,
self
.
num_grid_cells
]
self
.
current_projection
[:,
self
.
num_grid_cells
+
1
]
=
self
.
current_projection
[:,
1
]
transposed_projection
[
0
]
=
transposed_projection
[
self
.
num_grid_cells
]
transposed_projection
[
self
.
num_grid_cells
+
1
]
=
transposed_projection
[
1
]
self
.
current_projection
=
np
.
transpose
(
transposed_projection
)
class
SSPRK3
(
UpdateScheme
):
class
SSPRK3
(
UpdateScheme
):
...
@@ -142,16 +139,12 @@ class SSPRK3(UpdateScheme):
...
@@ -142,16 +139,12 @@ class SSPRK3(UpdateScheme):
self
.
_enforce_boundary_condition
()
self
.
_enforce_boundary_condition
()
def
_update_right_hand_side
(
self
):
def
_update_right_hand_side
(
self
):
# Transpose projection for easier calculation
transposed_projection
=
np
.
transpose
(
self
.
current_projection
)
# Initialize vector and set first entry to accommodate for ghost cell
# Initialize vector and set first entry to accommodate for ghost cell
right_hand_side
=
[
0
]
right_hand_side
=
[
0
]
for
j
in
range
(
self
.
num_grid_cells
):
for
j
in
range
(
self
.
num_grid_cells
):
right_hand_side
.
append
(
right_hand_side
.
append
(
2
*
(
self
.
A
@
self
.
current_projection
[:,
j
+
1
]
2
*
(
self
.
A
@
transposed_projection
[
j
+
1
]
+
self
.
B
@
self
.
current_projection
[:,
j
]))
+
self
.
B
@
transposed_projection
[
j
]))
# Set ghost cells to respective value
# Set ghost cells to respective value
right_hand_side
[
0
]
=
right_hand_side
[
self
.
num_grid_cells
]
right_hand_side
[
0
]
=
right_hand_side
[
self
.
num_grid_cells
]
...
...
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