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

Vectorized 'calculate_exact_solution()'.

parent 685f614a
No related branches found
No related tags found
No related merge requests found
...@@ -79,25 +79,15 @@ def calculate_exact_solution( ...@@ -79,25 +79,15 @@ def calculate_exact_solution(
Array containing exact evaluation of a function. Array containing exact evaluation of a function.
""" """
grid = []
exact = []
num_periods = np.floor(wave_speed * final_time / mesh.interval_len) num_periods = np.floor(wave_speed * final_time / mesh.interval_len)
for cell_center in mesh.non_ghost_cells: grid = np.repeat(mesh.non_ghost_cells, quadrature.num_nodes) + \
eval_points = cell_center+mesh.cell_len / 2 * \ mesh.cell_len/2 * np.tile(quadrature.nodes, mesh.num_cells)
quadrature.nodes exact = np.array([init_cond.calculate(
mesh=mesh, x=point-wave_speed*final_time+num_periods*mesh.interval_len)
for point in grid])
eval_values = [] grid = np.reshape(grid, (1, grid.size))
for eval_point in eval_points: exact = np.reshape(exact, (1, exact.size))
new_entry = init_cond.calculate(mesh=mesh, x=eval_point
- wave_speed * final_time
+ num_periods * mesh.interval_len)
eval_values.append(new_entry)
grid.append(eval_points)
exact.append(eval_values)
exact = np.reshape(np.array(exact), (1, len(exact) * len(exact[0])))
grid = np.reshape(np.array(grid), (1, len(grid) * len(grid[0])))
return grid, exact return grid, exact
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment