Download 22.py from TestCaseGeneration/NumFEM_Eval: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/datasets/TestCaseGeneration/NumFEM_Eval/resolve/main/22.py
- Command line
-
hf download hf://datasets/TestCaseGeneration/NumFEM_Eval/22.py
-
curl -L -o 22.py https://huggingface.co/datasets/TestCaseGeneration/NumFEM_Eval/resolve/main/22.py
1.45 kB
| from numpy import array | |
| p00 = array([1.0, 1.0]) | |
| p01 = array([0.0, 2.0]) | |
| p02 = array([1.0, 2.0]) | |
| p03 = array([1.0, 3.0]) | |
| p10 = array([3.0, 1.0]) | |
| p11 = array([4.0, 1.0]) | |
| p12 = array([2.0, 3.0]) | |
| p13 = 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 left_curve(t): | |
| return cubic_bezier_curve(t, p0=p00, p1=p01, p2=p02, p3=p03) | |
| def right_curve(t): | |
| return cubic_bezier_curve(t, p0=p10, p1=p11, p2=p12, p3=p13) | |
| import numpy as np | |
| def two_curved_domain(xi_count, eta_count, left_curve, right_curve): | |
| 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) | |
| for i in range(xi_count): | |
| xi = points_xi[i] | |
| for j in range(eta_count): | |
| eta = points_eta[j] | |
| p = (1.0 - xi) * left_curve(eta) + xi * right_curve(eta) | |
| 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 | |