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
d6837143
Commit
d6837143
authored
2 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Vectorized 'do_initial_projection()'.
parent
a1951eb1
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/DG_Approximation.py
+22
-23
22 additions, 23 deletions
scripts/tcd/DG_Approximation.py
with
22 additions
and
23 deletions
scripts/tcd/DG_Approximation.py
+
22
−
23
View file @
d6837143
...
@@ -181,26 +181,25 @@ def do_initial_projection(init_cond, mesh, basis, quadrature,
...
@@ -181,26 +181,25 @@ def do_initial_projection(init_cond, mesh, basis, quadrature,
number of mesh cells and p being the polynomial degree of the basis.
number of mesh cells and p being the polynomial degree of the basis.
"""
"""
# Initialize matrix and set first entry to accommodate for ghost cell
# Initialize output matrix
output_matrix
=
[
0
]
output_matrix
=
np
.
zeros
((
basis
.
polynomial_degree
+
1
,
mesh
.
num_cells
+
2
))
for
eval_point
in
mesh
.
non_ghost_cells
:
# Calculate basis based on quadrature
new_row
=
[]
basis_matrix
=
np
.
array
([
np
.
vectorize
(
basis
.
basis
[
degree
].
subs
)(
for
degree
in
range
(
basis
.
polynomial_degree
+
1
):
x
,
quadrature
.
nodes
)
for
degree
in
range
(
basis
.
polynomial_degree
+
1
)])
new_row
.
append
(
np
.
float64
(
sum
(
init_cond
.
calculate
(
x
=
eval_point
+
mesh
.
cell_len
/
2
# Calculate points based on initial condition
*
quadrature
.
nodes
[
point
]
-
x_shift
,
mesh
=
mesh
)
points
=
quadrature
.
nodes
[:,
np
.
newaxis
]
@
\
*
basis
.
basis
[
degree
].
subs
(
np
.
repeat
(
mesh
.
cell_len
/
2
,
mesh
.
num_cells
)[:,
np
.
newaxis
].
T
+
\
x
,
quadrature
.
nodes
[
point
])
np
.
tile
(
mesh
.
non_ghost_cells
-
x_shift
,
(
quadrature
.
num_nodes
,
1
))
*
quadrature
.
weights
[
point
]
init_matrix
=
np
.
vectorize
(
init_cond
.
calculate
,
otypes
=
[
np
.
float
])(
for
point
in
range
(
quadrature
.
num_nodes
))))
x
=
points
,
mesh
=
mesh
)
new_row
=
np
.
array
(
new_row
)
# Set output matrix for regular cells
output_matrix
.
append
(
basis
.
inverse_mass_matrix
@
new_row
)
output_matrix
[:,
1
:
-
1
]
=
(
basis_matrix
*
quadrature
.
weights
)
@
init_matrix
# Set ghost cells to respective value
# Set ghost cells
output_matrix
[
0
]
=
output_matrix
[
mesh
.
num_cells
]
output_matrix
[:,
0
]
=
output_matrix
[:,
-
2
]
output_matrix
.
append
(
output_matrix
[
1
])
output_matrix
[:,
-
1
]
=
output_matrix
[:,
1
]
# print(np.array(output_matrix).shape)
return
output_matrix
return
np
.
transpose
(
np
.
array
(
output_matrix
))
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