Skip to content
Snippets Groups Projects
Commit 83a45cda authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Started replacing transposing with vectorized access. Removed completed TODOs.

parent fde3fa8c
No related branches found
No related tags found
No related merge requests found
......@@ -25,11 +25,8 @@ TODO: Write documentation for all methods
TODO: Add a verbose option
TODO: Check whether consistency is given/possible for each class instance
TODO: Make projection local variable -> Done
TODO: Check whether current and original projection in Update_Scheme are identical -> Done (No)
TODO: Adjust line breaks to standard -> Done
TODO: Remove redundant passes -> Done
TODO: Shorten returns for True/False and redundant variables -> Done
TODO: Make projection local variable -> Done (not for Limiter and Troubled_Cell_Detector)
TODO: Vector faster than Trans for longer processes, therefore replace ->
"""
import numpy as np
......@@ -336,7 +333,7 @@ class DGScheme(object):
toc = timeit.default_timer()
print('Vecto:', toc-tic)
print(coarse_projection == coarse_projection1)
# print(coarse_projection == coarse_projection1)
# Plot exact and approximate solutions for coarse mesh
grid, exact = self._calculate_exact_solution(coarse_mesh[1:-1], coarse_cell_len)
......
......@@ -2,8 +2,6 @@
"""
@author: Laura C. Kühle
TODO: Rename initial conditions -> Done
"""
import numpy as np
......
......@@ -4,6 +4,7 @@
"""
import numpy as np
import timeit
class Limiter(object):
......@@ -23,7 +24,7 @@ class NoLimiter(Limiter):
self.function_name = 'NoLimiter'
def apply(self, projection, cell):
return np.transpose(projection)[cell]
return projection[:, cell]
class MinMod(Limiter):
......@@ -47,21 +48,36 @@ class MinMod(Limiter):
is_good_cell = self._determine_modification()
if is_good_cell:
return np.transpose(self.projection)[self.cell]
return self.projection[:, self.cell]
adapted_projection = np.transpose(self.projection)[self.cell].copy()
adapted_projection = self.projection[:, self.cell].copy()
for i in range(len(adapted_projection)):
if i > self.erase_degree:
adapted_projection[i] = 0
return adapted_projection
def _set_cell_slope(self):
tic = timeit.default_timer()
slope = []
transposed_projection = np.transpose(self.projection)
for cell in range(len(transposed_projection)):
new_entry = sum(transposed_projection[cell][degree] * (degree+0.5)**0.5
for degree in range(1, len(self.projection)))
slope.append(new_entry)
toc = timeit.default_timer()
print('Trans:', toc-tic)
tic = timeit.default_timer()
slope1 = []
transposed_projection = self.projection
for cell in range(len(transposed_projection[0])):
new_entry = sum(transposed_projection[degree][cell] * (degree+0.5)**0.5
for degree in range(1, len(self.projection)))
slope1.append(new_entry)
toc = timeit.default_timer()
print('Vecto:', toc-tic)
print(slope == slope1)
self.cell_slope = slope[self.cell]
def _determine_modification(self):
......
......@@ -7,7 +7,9 @@ Docstring-Style: D200, D400
"""
from DG_Approximation import DGScheme
import timeit
tic = timeit.default_timer()
alpha = 1
p = 2
......@@ -49,6 +51,9 @@ dg_scheme = DGScheme(detector, detector_config=detector_config, init_cond=init_c
# __, __, troubled_cells, __ =
dg_scheme.approximate()
dg_scheme.save_plots()
toc = timeit.default_timer()
print("Time:", toc-tic)
# =============================================================================
#
# print(troubled_cells)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment