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
ae52db8f
Commit
ae52db8f
authored
Apr 26, 2022
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Hard-coded simplification of cell average and reconstruction calculations for OrthonormalLegendre.
parent
37b4bf22
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Basis_Function.py
+79
-0
79 additions, 0 deletions
Basis_Function.py
with
79 additions
and
0 deletions
Basis_Function.py
+
79
−
0
View file @
ae52db8f
...
@@ -412,3 +412,82 @@ class OrthonormalLegendre(Legendre):
...
@@ -412,3 +412,82 @@ class OrthonormalLegendre(Legendre):
row
.
append
(
np
.
float64
(
entry
))
row
.
append
(
np
.
float64
(
entry
))
matrix
.
append
(
row
)
matrix
.
append
(
row
)
return
matrix
return
matrix
def
calculate_cell_average
(
self
,
projection
,
stencil_length
,
add_reconstructions
=
True
):
"""
Calculate cell averages for a given projection.
Calculate the cell averages of all cells in a projection.
If desired, reconstructions are calculated for the middle cell
and added left and right to it, respectively.
Notes
-----
To increase speed. this function uses a simplified calculation
specific to the orthonormal Legendre polynomial basis.
Parameters
----------
projection : ndarray
Matrix of projection for each polynomial degree.
stencil_length : int
Size of data array.
add_reconstructions: bool, optional
Flag whether reconstructions of the middle cell are included.
Default: True.
Returns
-------
ndarray
Matrix containing cell averages (and reconstructions) for given
projection.
"""
cell_averages
=
np
.
array
([
projection
[
0
]
/
np
.
sqrt
(
2
)])
if
add_reconstructions
:
middle_idx
=
stencil_length
//
2
left_reconstructions
,
right_reconstructions
=
\
self
.
_calculate_reconstructions
(
projection
[:,
middle_idx
:
middle_idx
+
1
])
return
np
.
array
(
list
(
map
(
np
.
float64
,
zip
(
cell_averages
[:,
:
middle_idx
],
left_reconstructions
,
cell_averages
[:,
middle_idx
],
right_reconstructions
,
cell_averages
[:,
middle_idx
+
1
:]))))
return
np
.
array
(
list
(
map
(
np
.
float64
,
cell_averages
)))
def
_calculate_reconstructions
(
self
,
projection
):
"""
Calculate left and right reconstructions for a given projection.
Notes
-----
To increase speed. this function uses a simplified calculation
specific to the orthonormal Legendre polynomial basis.
Parameters
----------
projection : ndarray
Matrix of projection for each polynomial degree.
Returns
-------
left_reconstruction: list
List containing left reconstructions for given projection.
right_reconstruction: list
List containing right reconstructions for given projection.
"""
left_reconstructions
=
[
sum
(
projection
[
degree
][
cell
]
*
(
-
1
)
**
degree
*
np
.
sqrt
(
degree
+
0.5
)
for
degree
in
range
(
self
.
_polynomial_degree
+
1
))
for
cell
in
range
(
len
(
projection
[
0
]))]
right_reconstructions
=
[
sum
(
projection
[
degree
][
cell
]
*
np
.
sqrt
(
degree
+
0.5
)
for
degree
in
range
(
self
.
_polynomial_degree
+
1
))
for
cell
in
range
(
len
(
projection
[
0
]))]
return
left_reconstructions
,
right_reconstructions
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