Download 23.py from TestCaseGeneration/NumFEM_Eval: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/datasets/TestCaseGeneration/NumFEM_Eval/resolve/main/23.py
- Command line
-
hf download hf://datasets/TestCaseGeneration/NumFEM_Eval/23.py
-
curl -L -o 23.py https://huggingface.co/datasets/TestCaseGeneration/NumFEM_Eval/resolve/main/23.py
1.75 kB
| from numpy import array | |
| p20 = array([1.0, 1.0]) | |
| p21 = array([2.0, 2.0]) | |
| p22 = array([2.0, 2.0]) | |
| p23 = array([3.0, 1.0]) | |
| p30 = array([1.0, 3.0]) | |
| p31 = array([2.0, 4.0]) | |
| p32 = array([2.0, 4.0]) | |
| p33 = array([3.5, 4.0]) | |
| def cubic_bezier_curve(t, p0, p1, p2, p3): | |
| return (1.0 - t) ** 3.0 * p0 + 3.0 * (1.0 - t) ** 2.0 * t * p1 + 3.0 * (1.0 - t) * t * t * p2 + t ** 3.0 * p3 | |
| def curve_bottom(t): | |
| return cubic_bezier_curve(t, p0=p20, p1=p21, p2=p22, p3=p23) | |
| def curve_top(t): | |
| return cubic_bezier_curve(t, p0=p30, p1=p31, p2=p32, p3=p33) | |
| import numpy as np | |
| def transfinite(xi_count, eta_count, xi_curve_bottom, xi_curve_top, eta_curve_left, eta_curve_right): | |
| nodes = np.zeros((xi_count * eta_count, 2), dtype=np.float64) | |
| elements = np.zeros(((xi_count - 1) * (eta_count - 1), 4), dtype=np.int32) | |
| points_xi = np.linspace(0.0, 1.0, num=xi_count) | |
| points_eta = np.linspace(0.0, 1.0, num=eta_count) | |
| a = xi_curve_bottom(0.0) | |
| b = xi_curve_top(0.0) | |
| c = xi_curve_bottom(1.0) | |
| d = xi_curve_top(1.0) | |
| for i in range(xi_count): | |
| xi = points_xi[i] | |
| for j in range(eta_count): | |
| eta = points_eta[j] | |
| p = ((1.0 - xi) * eta_curve_left(eta) + xi * eta_curve_right(eta) + (1.0 - eta) * xi_curve_bottom(xi) + eta * xi_curve_top(xi) - (1.0 - xi) * (1.0 - eta) * a - (1.0 - xi) * eta * b - xi * (1.0 - eta) * c - xi * eta * d) | |
| nodes[i * eta_count + j, 0] = p[0] | |
| nodes[i * eta_count + j, 1] = p[1] | |
| for i in range(xi_count - 1): | |
| for j in range(eta_count - 1): | |
| elem_idx = i * (eta_count - 1) + j | |
| elements[elem_idx] = [i * eta_count + j, (i + 1) * eta_count + j, (i + 1) * eta_count + (j + 1),i * eta_count + j + 1] | |
| return nodes, elements |