diff --git a/scripts/tcd/projection_utils.py b/scripts/tcd/projection_utils.py index c6b710b2e98e8df12190a401d2342b910180b17b..6d3c0bf00e021344d36a7096863703e36274f37f 100644 --- a/scripts/tcd/projection_utils.py +++ b/scripts/tcd/projection_utils.py @@ -7,7 +7,7 @@ from typing import Tuple import numpy as np from numpy import ndarray -from sympy import Symbol +from sympy import Symbol, lambdify from .Mesh import Mesh from .Quadrature import Quadrature @@ -39,18 +39,17 @@ def calculate_approximate_solution( Array containing approximate evaluation of a function. """ - num_points = len(points) - basis_matrix = [[basis[degree].subs(x, points[point]) - for point in range(num_points)] + for point in range(len(points))] for degree in range(polynomial_degree+1)] - approx = [[sum(projection[degree][cell] * basis_matrix[degree][point] - for degree in range(polynomial_degree+1)) - for point in range(num_points)] - for cell in range(len(projection[0]))] + # basis = np.array([np.vectorize(lambdify(x, function, 'numpy')) + # for function in basis]) + # basis_matrix = np.array([basis[degree](np.array(points)) for degree in + # range(polynomial_degree+1)]) - return np.reshape(np.array(approx), (1, len(approx) * num_points)) + approx = projection.T@basis_matrix + return np.reshape(approx, (1, approx.size)) def calculate_exact_solution(