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
0502ee6c
"convlab/dst/setsumbt/modeling/setsumbt.py" did not exist on "6238552fc128021a48e561de3c9cfed0166c5265"
Commit
0502ee6c
authored
Sep 19, 2021
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added documentation to 'Limiter'.
parent
ab109864
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
Limiter.py
+173
-3
173 additions, 3 deletions
Limiter.py
with
173 additions
and
3 deletions
Limiter.py
+
173
−
3
View file @
0502ee6c
...
...
@@ -6,33 +6,128 @@
class
Limiter
(
object
):
"""
Class for limiting function.
Methods
-------
get_name()
Returns string of class name.
apply(projection, cell)
Applies limiting to cell.
"""
def
__init__
(
self
,
config
):
"""
Initializes Quadrature.
Parameters
----------
config : dict
Additional parameters for limiter.
"""
self
.
_reset
(
config
)
def
_reset
(
self
,
config
):
"""
Resets instance variables.
Parameters
----------
config : dict
Additional parameters for quadrature.
"""
pass
def
get_name
(
self
):
"""
Returns string of class name.
"""
return
self
.
__class__
.
__name__
def
apply
(
self
,
projection
,
cell
):
"""
Applies limiting to cell.
Parameters
----------
projection : np.array
Matrix of projection for each polynomial degree.
cell
Index of cell.
Returns
-------
np.array
Matrix of updated projection for each polynomial degree.
"""
pass
class
NoLimiter
(
Limiter
):
"""
Class without any limiting.
Methods
-------
get_name()
Returns string of class name.
apply(projection, cell)
Applies no limiting to cell.
"""
def
apply
(
self
,
projection
,
cell
):
"""
Returns projection of cell without limiting.
"""
return
projection
[:,
cell
]
class
MinMod
(
Limiter
):
"""
Class for minmod limiting function.
Sets projection for higher degrees to zero when forward backward, and cell slope values have
not the same sign.
Attributes
----------
erase_degree : int
Polynomial degree up to which projection is not set to zero during limiting.
Methods
-------
get_name()
Returns string of class name.
apply(projection, cell)
Applies limiting to cell.
"""
def
_reset
(
self
,
config
):
"""
Resets instance variables.
Parameters
----------
config : dict
Additional parameters for quadrature.
"""
# Unpack necessary configurations
self
.
_erase_degree
=
config
.
pop
(
'
erase_degree
'
,
0
)
def
get_name
(
self
):
"""
Returns string of class name concatenated with the erase degree.
"""
return
self
.
__class__
.
__name__
+
str
(
self
.
_erase_degree
)
def
apply
(
self
,
projection
,
cell
):
"""
Applies limiting to cell.
Parameters
----------
projection : np.array
Matrix of projection for each polynomial degree.
cell : int
Index of cell.
Returns
-------
adapted_projection : np.array
Matrix of updated projection for each polynomial degree.
"""
cell_slope
=
self
.
_set_cell_slope
(
projection
,
cell
)
is_good_cell
=
self
.
_determine_modification
(
projection
,
cell
,
cell_slope
)
...
...
@@ -46,6 +141,23 @@ class MinMod(Limiter):
return
adapted_projection
def
_determine_modification
(
self
,
projection
,
cell
,
cell_slope
):
"""
Determines whether limiting is applied.
Parameters
----------
projection : np.array
Matrix of projection for each polynomial degree.
cell : int
Index of cell.
cell_slope : float
Slope of the given cell.
Returns
-------
boolean
Flag whether cell should be adjusted.
"""
forward_slope
=
(
projection
[
0
][
cell
+
1
]
-
projection
[
0
][
cell
])
*
(
0.5
**
0.5
)
backward_slope
=
(
projection
[
0
][
cell
]
-
projection
[
0
][
cell
-
1
])
*
(
0.5
**
0.5
)
...
...
@@ -54,6 +166,21 @@ class MinMod(Limiter):
@staticmethod
def
_set_cell_slope
(
projection
,
cell
):
"""
Calculates the slope of the cell.
Parameters
----------
projection : np.array
Matrix of projection for each polynomial degree.
cell : int
Index of cell.
Returns
-------
float
Slope of the given cell.
"""
slope
=
[]
for
current_cell
in
range
(
len
(
projection
[
0
])):
new_entry
=
sum
(
projection
[
degree
][
current_cell
]
*
(
degree
+
0.5
)
**
0.5
...
...
@@ -63,13 +190,38 @@ class MinMod(Limiter):
class
ModifiedMinMod
(
MinMod
):
"""
Do documentation here. Also called Cockburn-Shu limiter.
"""
Class for modified minmod limiting function.
Sets projection for higher degrees to zero when forward backward, and cell slope values have
not the same sign and cell slope is significantly high.
Attributes
----------
cell_len : float
Length of a cell in mesh.
mod_factor : float
Factor determining whether cell slope is significantly high enough for modification.
Methods
-------
get_name()
Returns string of class name.
Notes
-----
Also called Cockburn-Shu limiter.
Here come some parameter.
"""
def
_reset
(
self
,
config
):
"""
Resets instance variables.
Parameters
----------
config : dict
Additional parameters for quadrature.
"""
super
().
_reset
(
config
)
# Unpack necessary configurations
...
...
@@ -77,9 +229,27 @@ class ModifiedMinMod(MinMod):
self
.
_mod_factor
=
config
.
pop
(
'
mod_factor
'
,
0
)
def
get_name
(
self
):
"""
Returns string of class name concatenated with the erase degree.
"""
return
self
.
__class__
.
__name__
+
str
(
self
.
_erase_degree
)
def
_determine_modification
(
self
,
projection
,
cell
,
cell_slope
):
"""
Determines whether limiting is applied.
Parameters
----------
projection : np.array
Matrix of projection for each polynomial degree.
cell : int
Index of cell.
cell_slope : float
Slope of the given cell.
Returns
-------
boolean
Flag whether cell should be adjusted.
"""
if
abs
(
cell_slope
)
<=
self
.
_mod_factor
*
self
.
_cell_len
**
2
:
return
True
...
...
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