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
685f614a
Commit
685f614a
authored
2 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Vectorized 'calculate_approximate_solution()'.
parent
1060e1eb
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
scripts/tcd/projection_utils.py
+8
-9
8 additions, 9 deletions
scripts/tcd/projection_utils.py
with
8 additions
and
9 deletions
scripts/tcd/projection_utils.py
+
8
−
9
View file @
685f614a
...
...
@@ -7,7 +7,7 @@
from
typing
import
Tuple
import
numpy
as
np
from
numpy
import
ndarray
from
sympy
import
Symbol
from
sympy
import
Symbol
,
lambdify
from
.Mesh
import
Mesh
from
.Quadrature
import
Quadrature
...
...
@@ -39,18 +39,17 @@ def calculate_approximate_solution(
Array containing approximate evaluation of a function.
"""
num_points
=
len
(
points
)
basis_matrix
=
[[
basis
[
degree
].
subs
(
x
,
points
[
point
])
for
point
in
range
(
num_
points
)]
for
point
in
range
(
len
(
points
)
)
]
for
degree
in
range
(
polynomial_degree
+
1
)]
approx
=
[[
sum
(
projection
[
degree
][
cell
]
*
basis_matrix
[
degree
][
point
]
for
degree
in
range
(
polynomial_degree
+
1
)
)
for
point
in
range
(
num_points
)]
for
cell
in
range
(
len
(
projection
[
0
])
)]
# basis = np.array([np.vectorize(lambdify(x, function, 'numpy'))
#
for
function in basis]
)
# basis_matrix = np.array([basis[degree](np.array(points)) for degree in
#
range(polynomial_degree+1
)]
)
return
np
.
reshape
(
np
.
array
(
approx
),
(
1
,
len
(
approx
)
*
num_points
))
approx
=
projection
.
T
@basis_matrix
return
np
.
reshape
(
approx
,
(
1
,
approx
.
size
))
def
calculate_exact_solution
(
...
...
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