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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
1b3ac7fc
Commit
1b3ac7fc
authored
3 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added Mesh class.
parent
8552c898
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
projection_utils.py
+73
-0
73 additions, 0 deletions
projection_utils.py
with
73 additions
and
0 deletions
projection_utils.py
+
73
−
0
View file @
1b3ac7fc
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
"""
"""
from
functools
import
cache
from
typing
import
Tuple
from
typing
import
Tuple
import
numpy
as
np
import
numpy
as
np
from
numpy
import
ndarray
from
numpy
import
ndarray
...
@@ -16,6 +17,78 @@ from Initial_Condition import InitialCondition
...
@@ -16,6 +17,78 @@ from Initial_Condition import InitialCondition
x
=
Symbol
(
'
x
'
)
x
=
Symbol
(
'
x
'
)
class
Mesh
:
"""
Class for mesh/grid.
Each cell is characterized by its center.
Attributes
----------
num_grid_cells : int
Number of cells in the mesh (ghost cells notwithstanding). Usually
exponential of 2.
bounds : Tuple[float, float]
Left and right boundary of the mesh interval.
interval_len : float
Length of the mesh interval.
cell_len : float
Length of a mesh cell.
cells : ndarray
Array of cell centers in mesh.
"""
def
__init__
(
self
,
num_grid_cells
:
int
,
num_ghost_cells
:
int
,
left_bound
:
float
,
right_bound
:
float
)
->
None
:
"""
Initialize Mesh.
Parameters
----------
num_grid_cells : int
Number of cells in the mesh (ghost cells notwithstanding). Usually
exponential of 2.
num_ghost_cells : int
Number of ghost cells on each side of the mesh.
left_bound : float
Left boundary of the mesh interval.
right_bound : float
Right boundary of the mesh interval.
"""
self
.
_num_grid_cells
=
num_grid_cells
self
.
_num_ghost_cells
=
num_ghost_cells
self
.
_left_bound
=
left_bound
self
.
_right_bound
=
right_bound
@property
def
num_grid_cells
(
self
)
->
int
:
"""
Return number of grid cells.
"""
return
self
.
_num_grid_cells
@property
def
bounds
(
self
)
->
Tuple
[
float
,
float
]:
"""
Return left and right boundary of the mesh interval.
"""
return
self
.
_left_bound
,
self
.
_right_bound
@property
def
interval_len
(
self
)
->
float
:
"""
Return the length of the mesh interval.
"""
return
self
.
_right_bound
-
self
.
_left_bound
@property
def
cell_len
(
self
)
->
float
:
"""
Return the length of a mesh cell.
"""
return
self
.
interval_len
/
self
.
num_grid_cells
@property
@cache
def
cells
(
self
)
->
ndarray
:
"""
Return the cell centers of the mesh (including ghost cells).
"""
return
np
.
arange
(
self
.
_left_bound
-
(
self
.
_num_ghost_cells
*
2
-
1
)
/
2
*
self
.
cell_len
,
self
.
_right_bound
+
(
self
.
_num_ghost_cells
*
2
+
1
)
/
2
*
self
.
cell_len
,
self
.
cell_len
)
def
calculate_approximate_solution
(
def
calculate_approximate_solution
(
projection
:
ndarray
,
points
:
ndarray
,
polynomial_degree
:
int
,
projection
:
ndarray
,
points
:
ndarray
,
polynomial_degree
:
int
,
basis
:
ndarray
)
->
ndarray
:
basis
:
ndarray
)
->
ndarray
:
...
...
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