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

Moved histories to DG_Approximation.

parent 07bac37c
Branches
Tags
No related merge requests found
......@@ -23,6 +23,7 @@ TODO: Contemplate moving plots to pertaining files
TODO: Contemplate moving A and B to Vectors_of_Polynomials
TODO: Combine plot for coarse and fine approximation for wavelet detectors
TODO: Improve access to names of classes
TODO: Move histories to DG_Approximation -> Done
"""
import numpy as np
......@@ -109,11 +110,15 @@ class DGScheme(object):
Here come some parameter.
"""
projection = self._do_initial_projection()
time_step = abs(self.cfl_number * self.cell_len / self.wave_speed)
current_time = 0
iteration = 0
troubled_cell_history = []
time_history = []
while current_time < self.final_time:
# Adjust for last cell
if current_time+time_step > self.final_time:
......@@ -123,9 +128,15 @@ class DGScheme(object):
# Update projection
projection, troubled_cells = self.update_scheme.step(projection, self.cfl_number, current_time)
iteration += 1
if (iteration % self.history_threshold) == 0:
troubled_cell_history.append(troubled_cells)
time_history.append(current_time)
current_time += time_step
self._plot_shock_tube()
self._plot_shock_tube(troubled_cell_history, time_history)
self._plot_coarse_mesh(projection, 'k-', 'y')
self._plot_fine_mesh(projection, 'k-.', 'b')
......@@ -426,10 +437,7 @@ class DGScheme(object):
plt.ylabel('Detail Coefficients')
plt.title('Wavelet Coefficients')
def _plot_shock_tube(self):
time_history = self.update_scheme.get_time_history()
troubled_cell_history = self.update_scheme.get_troubled_cell_history()
def _plot_shock_tube(self, troubled_cell_history, time_history):
plt.figure(6)
for pos in range(len(time_history)):
current_cells = troubled_cell_history[pos]
......
......@@ -37,21 +37,9 @@ class UpdateScheme(object):
def get_name(self):
return self.name
def get_troubled_cell_history(self):
return self.troubled_cell_history
def get_time_history(self):
return self.time_history
def step(self, projection, cfl_number, current_time):
current_projection, troubled_cells = self._apply_stability_method(projection, cfl_number)
self.iteration += 1
if (self.iteration % self.history_threshold) == 0:
self.troubled_cell_history.append(troubled_cells)
self.time_history.append(current_time)
return current_projection, troubled_cells
def _apply_stability_method(self, projection, cfl_number):
......@@ -62,9 +50,6 @@ class UpdateScheme(object):
self.name = 'None'
self.interval_len = self.right_bound-self.left_bound
self.cell_len = self.interval_len / self.num_grid_cells
self.troubled_cell_history = []
self.time_history = []
self.iteration = 0
# Set matrix A
matrix = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment