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
abc8e917
Commit
abc8e917
authored
2 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Vectorized '_reset()' for update scheme.
parent
8981d4b4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Snakefile
+1
-1
1 addition, 1 deletion
Snakefile
scripts/tcd/Update_Scheme.py
+18
-27
18 additions, 27 deletions
scripts/tcd/Update_Scheme.py
with
19 additions
and
28 deletions
Snakefile
+
1
−
1
View file @
abc8e917
...
@@ -23,7 +23,7 @@ TODO: Discuss name for quadrature mesh (now: grid)
...
@@ -23,7 +23,7 @@ TODO: Discuss name for quadrature mesh (now: grid)
TODO: Contemplate using lambdify for basis
TODO: Contemplate using lambdify for basis
Urgent:
Urgent:
TODO: Vectorize '_reset()' for update scheme
TODO: Vectorize '_reset()' for update scheme
-> Done
TODO: Vectorize 'plot_details()'
TODO: Vectorize 'plot_details()'
TODO: Replace loops/list comprehension with vectorization if feasible
TODO: Replace loops/list comprehension with vectorization if feasible
TODO: Replace loops with list comprehension if feasible
TODO: Replace loops with list comprehension if feasible
...
...
This diff is collapsed.
Click to expand it.
scripts/tcd/Update_Scheme.py
+
18
−
27
View file @
abc8e917
...
@@ -55,36 +55,27 @@ class UpdateScheme(ABC):
...
@@ -55,36 +55,27 @@ class UpdateScheme(ABC):
def
_reset
(
self
):
def
_reset
(
self
):
"""
Resets instance variables.
"""
"""
Resets instance variables.
"""
matrix_shape
=
(
self
.
_polynomial_degree
+
1
,
self
.
_polynomial_degree
+
1
)
root_vector
=
np
.
array
([
np
.
sqrt
(
degree
+
0.5
)
for
degree
in
range
(
self
.
_polynomial_degree
+
1
)])
degree_matrix
=
np
.
matmul
(
root_vector
[:,
np
.
newaxis
],
root_vector
[:,
np
.
newaxis
].
T
)
# Set stiffness matrix
# Set stiffness matrix
matrix
=
[]
matrix
=
np
.
ones
(
matrix_shape
)
for
i
in
range
(
self
.
_polynomial_degree
+
1
):
new_row
=
[]
for
j
in
range
(
self
.
_polynomial_degree
+
1
):
if
self
.
_wave_speed
>
0
:
if
self
.
_wave_speed
>
0
:
new_entry
=
-
1.0
matrix
[
np
.
fromfunction
(
if
(
j
<
i
)
&
((
i
+
j
)
%
2
==
1
):
lambda
i
,
j
:
(
j
>=
i
)
|
((
i
+
j
)
%
2
==
0
),
matrix_shape
)]
=
-
1.0
new_entry
=
1.0
else
:
else
:
new_entry
=
1.0
matrix
[
np
.
fromfunction
(
if
(
j
>
i
)
&
((
i
+
j
)
%
2
==
1
):
lambda
i
,
j
:
(
j
>
i
)
&
((
i
+
j
)
%
2
==
1
),
matrix_shape
)]
=
-
1.0
new_entry
=
-
1.0
self
.
_stiffness_matrix
=
matrix
*
degree_matrix
new_row
.
append
(
new_entry
*
np
.
sqrt
((
i
+
0.5
)
*
(
j
+
0.5
)))
matrix
.
append
(
new_row
)
self
.
_stiffness_matrix
=
np
.
array
(
matrix
)
# former: inv_mass @ np.array(matrix)
# Set boundary matrix
# Set boundary matrix
matrix
=
[]
matrix
=
np
.
fromfunction
(
lambda
i
,
j
:
(
-
1.0
)
**
i
,
matrix_shape
)
\
for
i
in
range
(
self
.
_polynomial_degree
+
1
):
new_row
=
[]
for
j
in
range
(
self
.
_polynomial_degree
+
1
):
new_entry
=
np
.
sqrt
((
i
+
0.5
)
*
(
j
+
0.5
))
*
(
-
1.0
)
**
i
\
if
self
.
_wave_speed
>
0
\
if
self
.
_wave_speed
>
0
\
else
np
.
sqrt
((
i
+
0.5
)
*
(
j
+
0.5
))
*
(
-
1.0
)
**
j
else
np
.
fromfunction
(
lambda
i
,
j
:
(
-
1.0
)
**
j
,
matrix_shape
)
new_row
.
append
(
new_entry
)
self
.
_boundary_matrix
=
matrix
*
degree_matrix
matrix
.
append
(
new_row
)
self
.
_boundary_matrix
=
np
.
array
(
matrix
)
# former: inv_mass @ np.array(matrix)
def
get_name
(
self
):
def
get_name
(
self
):
"""
Returns string of class name.
"""
"""
Returns string of class name.
"""
...
...
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