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

Made projection a local varibale

parent cc781fa9
Branches
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ 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
TODO: Make projection local variable -> Done
TODO: Check whether current and original projection in Update_Scheme are identical
"""
......@@ -58,9 +58,7 @@ class DGScheme(object):
self.left_bound = kwargs.pop('left_bound', -1)
self.right_bound = kwargs.pop('right_bound', 1)
self.show_plot = kwargs.pop('show_plot', False)
self.history_threshold = kwargs.pop('history_threshold',
math.ceil(0.2/self.cfl_number))
self.history_threshold = kwargs.pop('history_threshold', math.ceil(0.2/self.cfl_number))
self.detector = detector
self.detector_config = kwargs.pop('detector_config', {})
self.init_cond = kwargs.pop('init_cond', 'Sine')
......@@ -122,7 +120,7 @@ class DGScheme(object):
Here come some parameter.
"""
self._do_initial_projection()
projection = self._do_initial_projection()
time_step = abs(self.cfl_number * self.cell_len / self.wave_speed)
......@@ -135,15 +133,14 @@ class DGScheme(object):
/ self.num_grid_cells
# Update projection
self.projection, troubled_cells = self.update_scheme.step(
self.projection, self.cfl_number, current_time)
projection, troubled_cells = self.update_scheme.step(projection, self.cfl_number, current_time)
current_time += time_step
self._plot_shock_tube()
self._plot_coarse_mesh('k-', 'y')
self._plot_coarse_mesh(projection, 'k-', 'y')
approx = self._plot_fine_mesh('k-.', 'b')
approx = self._plot_fine_mesh(projection, 'k-.', 'b')
# What is that??? What is it for?
......@@ -217,8 +214,6 @@ class DGScheme(object):
self.basis = OrthonormalLegendre(
self.polynom_degree).get_vector(x)
self.projection = []
# Set additional necessary config parameters
self.detector_config['num_grid_cells'] = self.num_grid_cells
self.detector_config['polynom_degree'] = self.polynom_degree
......@@ -282,7 +277,7 @@ class DGScheme(object):
output_matrix.append(output_matrix[1])
print(np.array(output_matrix).shape)
self.projection = np.transpose(np.array(output_matrix))
return np.transpose(np.array(output_matrix))
def _calculate_approximate_solution(self, projection):
points = self.quadrature.get_eval_points()
......@@ -327,7 +322,7 @@ class DGScheme(object):
return grid, exact
def _plot_coarse_mesh(self, color_exact, color_approx):
def _plot_coarse_mesh(self, projection, color_exact, color_approx):
basis_matrix_left = self._set_basis_matrix(xi, 0.5*(xi-1))
basis_matrix_right = self._set_basis_matrix(xi, 0.5*(xi+1))
coarse_cell_len = 2*self.cell_len
......@@ -337,7 +332,7 @@ class DGScheme(object):
# Calculate projection on coarse mesh
tic = timeit.default_timer()
transposed_vector = np.transpose(self.projection[:, 1:-1])
transposed_vector = np.transpose(projection[:, 1:-1])
output_matrix = []
for i in range(int(len(transposed_vector)/2)):
# print(transposed_vector[2*i].shape)
......@@ -353,7 +348,7 @@ class DGScheme(object):
# print()
tic = timeit.default_timer()
transposed_vector = self.projection[:, 1:-1]
transposed_vector = projection[:, 1:-1]
output_matrix = []
for i in range(int(len(transposed_vector[0])/2)):
# print(transposed_vector[:, 2*i].shape)
......@@ -375,11 +370,9 @@ class DGScheme(object):
color_exact, color_approx)
# plt.legend(['Exact-Coarse', 'Approx-Coarse'])
def _plot_fine_mesh(self, color_exact, color_approx):
grid, exact = self._calculate_exact_solution(self.mesh[2:-2],
self.cell_len)
approx = self._calculate_approximate_solution(
self.projection[:, 1:-1])
def _plot_fine_mesh(self, projection, color_exact, color_approx):
grid, exact = self._calculate_exact_solution(self.mesh[2:-2], self.cell_len)
approx = self._calculate_approximate_solution(projection[:, 1:-1])
pointwise_error = np.abs(exact-approx)
max_error = np.max(pointwise_error)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment