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
a380e3d2
Commit
a380e3d2
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Moved inverse mass matrix to 'Basis_Function'.
parent
f05ef836
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Basis_Function.py
+32
-0
32 additions, 0 deletions
Basis_Function.py
DG_Approximation.py
+6
-21
6 additions, 21 deletions
DG_Approximation.py
with
38 additions
and
21 deletions
Basis_Function.py
+
32
−
0
View file @
a380e3d2
...
...
@@ -22,6 +22,8 @@ class Vector:
Array of basis.
wavelet : ndarray
Array of wavelet.
inv_mass: ndarray
Inverse mass matrix.
Methods
-------
...
...
@@ -29,6 +31,8 @@ class Vector:
Returns basis vector.
get_wavelet_vector
Returns wavelet vector.
get_inverse_mass_matrix()
Returns inverse mass matrix.
get_basis_projections()
Returns basis projections.
get_wavelet_projections()
...
...
@@ -47,6 +51,7 @@ class Vector:
self
.
_polynomial_degree
=
polynomial_degree
self
.
_basis
=
self
.
_build_basis_vector
(
x
)
self
.
_wavelet
=
self
.
_build_wavelet_vector
(
z
)
self
.
_inv_mass
=
self
.
_build_inverse_mass_matrix
()
def
get_basis_vector
(
self
):
"""
Returns basis vector.
"""
...
...
@@ -88,6 +93,21 @@ class Vector:
"""
return
[]
def
get_inverse_mass_matrix
(
self
):
"""
Returns inverse mass matrix.
"""
return
self
.
_inv_mass
def
_build_inverse_mass_matrix
(
self
):
"""
Constructs inverse mass matrix.
Returns
-------
ndarray
Inverse mass matrix.
"""
pass
def
get_basis_projections
(
self
):
"""
Returns basis projection.
"""
pass
...
...
@@ -238,6 +258,18 @@ class OrthonormalLegendre(Legendre):
raise
ValueError
(
'
Invalid value: Alpert
\'
s wavelet is only available
\
up to degree 4 for this application
'
)
def
_build_inverse_mass_matrix
(
self
):
mass_matrix
=
[]
for
i
in
range
(
self
.
_polynomial_degree
+
1
):
new_row
=
[]
for
j
in
range
(
self
.
_polynomial_degree
+
1
):
new_entry
=
0.0
if
i
==
j
:
new_entry
=
1.0
new_row
.
append
(
new_entry
)
mass_matrix
.
append
(
new_row
)
return
np
.
array
(
mass_matrix
)
def
get_basis_projections
(
self
):
"""
Returns basis projection.
...
...
This diff is collapsed.
Click to expand it.
DG_Approximation.py
+
6
−
21
View file @
a380e3d2
...
...
@@ -4,7 +4,7 @@
Urgent:
TODO: Extract do_initial_projection() from DGScheme -> Done
TODO: Move inverse mass matrix to basis
TODO: Move inverse mass matrix to basis
-> Done
TODO: Extract calculate_cell_average() from TCD
TODO: Extract calculate_[...]_solution() from Plotting
TODO: Extract plotting from TCD completely
...
...
@@ -364,18 +364,6 @@ def do_initial_projection(initial_condition, basis, quadrature,
number of grid cells and p being the polynomial degree.
"""
# Set inverse mass matrix
mass_matrix
=
[]
for
i
in
range
(
polynomial_degree
+
1
):
new_row
=
[]
for
j
in
range
(
polynomial_degree
+
1
):
new_entry
=
0.0
if
i
==
j
:
new_entry
=
1.0
new_row
.
append
(
new_entry
)
mass_matrix
.
append
(
new_row
)
inv_mass
=
np
.
array
(
mass_matrix
)
# Initialize matrix and set first entry to accommodate for ghost cell
output_matrix
=
[
0
]
basis_vector
=
basis
.
get_basis_vector
()
...
...
@@ -386,19 +374,16 @@ def do_initial_projection(initial_condition, basis, quadrature,
eval_point
=
left_bound
+
(
cell
+
0.5
)
*
cell_len
for
degree
in
range
(
polynomial_degree
+
1
):
new_entry
=
sum
(
initial_condition
.
calculate
(
new_row
.
append
(
np
.
float64
(
sum
(
initial_condition
.
calculate
(
eval_point
+
cell_len
/
2
*
quadrature
.
get_eval_points
()[
point
]
-
adjustment
)
*
quadrature
.
get_eval_points
()[
point
]
-
adjustment
)
*
basis_vector
[
degree
].
subs
(
x
,
quadrature
.
get_eval_points
()[
point
])
*
quadrature
.
get_weights
()[
point
]
for
point
in
range
(
quadrature
.
get_num_points
()))
new_row
.
append
(
np
.
float64
(
new_entry
))
for
point
in
range
(
quadrature
.
get_num_points
()))))
new_row
=
np
.
array
(
new_row
)
output_matrix
.
append
(
inv_mass
@
new_row
)
output_matrix
.
append
(
basis
.
get_inverse_mass_matrix
()
@
new_row
)
# Set ghost cells to respective value
output_matrix
[
0
]
=
output_matrix
[
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