def test_plot_refined_quarter_disk_multiplicity(): knots, cp = quarter_disk() shape = np.asarray(cp.shape) shape[-1] = cp.shape[-1] + 1 B = np.ones((shape)) B[..., :cp.shape[-1]] = cp p = create_figure() p_knots(knots, B[..., :-1], p=p) p_cpoints(B[..., :-1], p=p) p_show(p) from pygeoiga.nurb.refinement import knot_insertion direction = 0 knot_ins = np.asarray([0.2, 0.2, 0.5, 0.5, 0.7, 0.7]) B_new, knots = knot_insertion(B, (2, 2), knots, knot_ins, direction=direction) direction = 1 B_new, knots = knot_insertion(B_new, (2, 2), knots, knot_ins, direction=direction) p = create_figure() p_knots(knots, B_new[..., :-1], p=p) p_cpoints(B_new[..., :-1], p=p) p_show(p)
def create_geom(**kwargs): from pygeoiga.nurb.cad import make_surface_biquadratic knots, B = make_surface_biquadratic() from pygeoiga.nurb.refinement import knot_insertion to_ins = kwargs.get("knot_ins", np.arange(0.1, 1, 0.1)) knots_ins_0 = [x for x in to_ins if x not in knots[0]] B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knots_ins_0, direction=0) knots_ins_1 = [x for x in to_ins if x not in knots[1]] B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knots_ins_1, direction=1) geometry = dict() geometry["quadrat"] = { "B": B, "knots": knots, "kappa": 4, 'color': "gray", "position": (1, 1), "BC": { 0: "bot_bc", 2: "top_bc" } } return geometry
def test_plot_refined_quarter_disk(): knots, cp = quarter_disk() shape = np.asarray(cp.shape) shape[-1] = cp.shape[-1] + 1 B = np.ones((shape)) B[..., :cp.shape[-1]] = cp fig, ax = create_figure() ax = p_cpoints(B, ax=ax, dim=2, color="black", marker="s", point=True, line=False) ax = p_cpoints(B, ax=ax, dim=2, color="red", linestyle="--", point=False, line=True) ax = p_knots(knots, B, ax=ax, dim=2, point=True, line=True) plt.show() from pygeoiga.nurb.refinement import knot_insertion direction = 0 knot_ins = np.asarray([0.2, 0.5, 0.7]) B_new, knots = knot_insertion(B, (2, 2), knots, knot_ins, direction=direction) direction = 1 B_new, knots = knot_insertion(B_new, (2, 2), knots, knot_ins, direction=direction) fig, ax = create_figure() ax = p_cpoints(B_new, ax=ax, dim=2, color="black", marker="s", point=True, line=False) ax = p_cpoints(B_new, ax=ax, dim=2, color="red", linestyle="--", point=False, line=True) ax = p_knots(knots, B_new, ax=ax, dim=2, point=True, line=True) plt.show()
def refinement(geometry: dict): # Knot insertion following the computational procedure of Piegl and Tille (1997) from pygeoiga.nurb.refinement import knot_insertion knot_ins_0 = np.arange(0.1, 1, 0.1) knot_ins_1 = np.arange(0.1, 1, 0.1) for count, patch_name in enumerate(geometry.keys()): B = geometry[patch_name].get("B") knots = geometry[patch_name].get("knots") B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knot_ins_0, direction=0) # U refinement B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knot_ins_1, direction=1) # V refinement geometry[patch_name]["B"] = B geometry[patch_name]["knots"] = knots return geometry
def test_plot_biquadratic(): from pygeoiga.nurb.cad import make_surface_biquadratic from pygeoiga.plot.nrbplotting_mpl import p_knots, create_figure, p_cpoints from pygeoiga.nurb.refinement import knot_insertion knots, cp = make_surface_biquadratic() shape = np.asarray(cp.shape) shape[-1] = cp.shape[-1] + 1 B = np.ones((shape)) B[..., :cp.shape[-1]] = cp fig, ax = create_figure("2d") ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="b") ax.set_axis_off() plt.show() direction = 0 knot_ins = np.asarray([0.2, 0.8]) B_new, knots_new = knot_insertion(B.copy(), (2, 2), knots.copy(), knot_ins, direction=direction) knot_ins = np.asarray([0.3, 0.7]) direction = 1 B_new2, knots_new2 = knot_insertion(B_new, (2, 2), knots_new, knot_ins, direction=direction) fig, ax = create_figure("2d") ax = p_knots(knots_new2, B_new2, ax=ax, dim=2, point=False, line=True, color="b") ax = p_cpoints(B_new2, ax=ax, dim=2, point=True, line=False, color="red") ax.set_axis_off() plt.show() direction = 0 knot_ins = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] B_new, knots_new = knot_insertion(B.copy(), (2, 2), knots.copy(), knot_ins, direction=direction) direction = 1 knot_ins = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] B_new2, knots_new2 = knot_insertion(B_new, (2, 2), knots_new, knot_ins, direction=direction) fig, ax = create_figure("2d") ax = p_knots(knots_new2, B_new2, ax=ax, dim=2, point=False, line=True, color="b") #ax = p_cpoints(geometry[patch_id].get("B"), ax=ax, dim=2, color="black", marker=".", point=True, line=False) ax.set_axis_off() plt.show()
def test_compare_biquadratic(): from pygeoiga.nurb.cad import make_surface_biquadratic knots, B = make_surface_biquadratic() from pygeoiga.nurb.refinement import knot_insertion knot_ins = [np.arange(0.05, 1, 0.05), np.arange(0.05, 1, 0.05)] knots_ins_0 = [x for x in knot_ins[0] if x not in knots[0]] B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knots_ins_0, direction=0) knots_ins_1 = [x for x in knot_ins[1] if x not in knots[1]] B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knots_ins_1, direction=1) geometry = dict() geometry["quadrat"] = { "B": B, "knots": knots, "kappa": 4, 'color': "red", "position": (1, 1), "BC": { 0: "bot_bc", 2: "top_bc" } } T_t = 10 T_b = 25 same_IGA_BEZIER(geometry, T_t, T_b, save=True, filename="biquadratic", levels=[12, 14, 17, 20, 22, 24])
def knot_insert(self, knot_ins: list, direction: int = 0, leave=True): """ Refinement by knot insertion Args: knot_ins: list of knots to insert direction: parametric direction to insert them leave: Show or hide progress bar after completion Returns: """ from pygeoiga.nurb.refinement import knot_insertion self.B, self.knots = knot_insertion(self.B, self.degree, self.knots, knot_ins, direction, leave=leave)
def test_between_mappings(): def plot(B, knots, file_name): from pygeoiga.plot.nrbplotting_mpl import create_figure, p_cpoints, p_knots, p_curve, p_surface fig, ax = plt.subplots(constrained_layout=True) ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="k") ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("$x$") ax.set_ylabel("$y$") ax.set_aspect(0.8) ax.plot(0.7, 3, "r*", markersize=10) fig.tight_layout(pad=0, h_pad=0, w_pad=0) fig.show() from pygeoiga.engine.NURB_engine import basis_function_array_nurbs fig2 = plt.figure(constrained_layout=True) gs = fig2.add_gridspec(2, 2, hspace=0, wspace=0, width_ratios=[0.2, 1], height_ratios=[1, 0.2]) (ax_v, ax2), (no, ax_u) = gs.subplots(sharex=True, sharey=True) no.remove() N_spline_u, _ = basis_function_array_nurbs(knot_vector=knots[0], degree=2, resolution=100) N_spline_v, _ = basis_function_array_nurbs(knot_vector=knots[1], degree=2, resolution=100) resol = np.linspace(0, 1, 100) ax_u.plot(resol, N_spline_u) ax_u.spines["top"].set_visible(False) ax_u.spines["right"].set_visible(False) ax_u.set_xlim(0, 1) ax_u.set_ylim(0, 1) ax_v.plot(N_spline_v, resol) ax_v.spines["top"].set_visible(False) ax_v.spines["right"].set_visible(False) ax_v.set_yticks(knots[2:-2]) ax_v.set_xlim(1, 0) ax_v.set_ylim(0, 1) for i in knots[0]: ax2.vlines(i, 0, 1, 'k') for j in knots[1]: ax2.hlines(j, 0, 1, 'k') ax2.set_xlim(0, 1) ax2.set_ylim(0, 1) ax2.set_axis_off() ax2.plot(0.65, 0.45, "r*", markersize=10) ax_u.set_xlabel("$u$") ax_v.set_ylabel("$v$") ax_v.set_yticks(knots[1][2:-2]) ax_u.set_xticks(knots[0][2:-2]) for ax in ax_u, ax_v, ax2, no: ax.label_outer() fig2.show() fig3, ax3 = plt.subplots() ax3.vlines(-1, -1, 1, 'k') ax3.vlines(1, -1, 1, 'k') ax3.hlines(-1, -1, 1, 'k') ax3.hlines(1, -1, 1, 'k') ax3.spines['left'].set_position('center') ax3.spines['bottom'].set_position('center') # Eliminate upper and right axes ax3.spines['right'].set_visible(False) ax3.spines['top'].set_visible(False) # Show ticks in the left and lower axes only ax3.xaxis.set_ticks_position('bottom') ax3.yaxis.set_ticks_position('left') ax3.set_xlabel(r"$\xi $", fontsize=15) ax3.set_ylabel(r"$\eta$", rotation=0, fontsize=15) ax3.xaxis.set_label_coords(1.05, 0.475) ax3.yaxis.set_label_coords(0.475, 1.05) ax3.set_yticks([-1, -0.5, 0.5, 1]) ax3.set_xticks([-1, -0.5, 0.5, 1]) ax3.set_aspect("equal") fig3.show() save = True if save or save_all: fig.savefig(fig_folder + file_name, **kwargs_savefig) fig2.savefig( fig_folder + file_name.split(".")[0] + "_parameter.pdf", **kwargs_savefig) fig3.savefig(fig_folder + file_name.split(".")[0] + "_element.pdf", **kwargs_savefig) from pygeoiga.nurb.cad import make_surface_biquadratic knots, B = make_surface_biquadratic() from pygeoiga.nurb.refinement import knot_insertion knot_ins_1 = [0.3, 0.6] knot_ins_0 = [0.1, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9] B, knots = knot_insertion(B, (2, 2), knots, knot_ins_0, direction=0) B, knots = knot_insertion(B, (2, 2), knots, knot_ins_1, direction=1) plot(B, knots, "mapping.pdf")
def test_make_NURB_biquadratic(): def plot(B, knots, file_name): from pygeoiga.plot.nrbplotting_mpl import create_figure, p_cpoints, p_knots, p_curve, p_surface fig, [ax2, ax] = plt.subplots(1, 2, figsize=(10, 5), constrained_layout=True) ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="k") ax = p_surface(knots, B, ax=ax, dim=2, color="blue", border=False, alpha=0.5) ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("$x$") ax.set_ylabel("$y$") ax.set_aspect(0.8) ax2 = p_cpoints(B, ax=ax2, dim=2, color="blue", linestyle="-", point=False, line=True) ax2 = p_cpoints(B, ax=ax2, dim=2, color="red", marker="o", point=True, line=False) n, m = B.shape[0], B.shape[1] ax2.spines["right"].set_visible(False) ax2.spines["top"].set_visible(False) ax2.set_xlabel("$x$") ax2.set_ylabel("$y$", rotation=90) ax2.set_aspect(0.8) ax.set_title("Physical space ($x,y$)", fontsize=20) ax2.set_title("Control net", fontsize=20) fig.tight_layout(pad=0, h_pad=0, w_pad=0) fig.show() from pygeoiga.engine.NURB_engine import basis_function_array_nurbs fig3 = plt.figure(constrained_layout=True) gs = fig3.add_gridspec(2, 2, hspace=0, wspace=0, width_ratios=[0.2, 1], height_ratios=[1, 0.2]) (ax_v, ax3), (no, ax_u) = gs.subplots(sharex=True, sharey=True) no.remove() N_spline_u, _ = basis_function_array_nurbs(knot_vector=knots[0], degree=2, resolution=100) N_spline_v, _ = basis_function_array_nurbs(knot_vector=knots[1], degree=2, resolution=100) resol = np.linspace(0, 1, 100) ax_u.plot(resol, N_spline_u) ax_u.spines["top"].set_visible(False) ax_u.spines["right"].set_visible(False) ax_u.set_xlim(0, 1) ax_u.set_ylim(0, 1) ax_v.plot(N_spline_v, resol) ax_v.spines["top"].set_visible(False) ax_v.spines["right"].set_visible(False) ax_v.set_yticks(knots[2:-2]) ax_v.set_xlim(1, 0) ax_v.set_ylim(0, 1) for i in knots[0]: ax3.vlines(i, 0, 1, 'k') for j in knots[1]: ax3.hlines(j, 0, 1, 'k') ax3.set_xlim(0, 1) ax3.set_ylim(0, 1) ax3.set_axis_off() ax3.set_title("Parametric space ($u,v$)", fontsize=20) ax_u.set_xlabel("$u$") ax_v.set_ylabel("$v$") ax_v.set_yticks(knots[1][2:-2]) ax_u.set_xticks(knots[0][2:-2]) for ax in ax_u, ax_v, ax3, no: ax.label_outer() fig3.show() save = False if save or save_all: fig.savefig(fig_folder + file_name, **kwargs_savefig) fig3.savefig( fig_folder + file_name.split(".")[0] + "_parameter.pdf", **kwargs_savefig) from pygeoiga.nurb.cad import make_surface_biquadratic knots, B = make_surface_biquadratic() plot(B, knots, "B-spline_biquadratic.pdf") from pygeoiga.nurb.refinement import knot_insertion knot_ins_1 = [0.3, 0.6] knot_ins_0 = [0.1, 0.2, 0.3, 0.4, 0.6, 0.7, 0.8, 0.9] B, knots = knot_insertion(B, (2, 2), knots, knot_ins_0, direction=0) B, knots = knot_insertion(B, (2, 2), knots, knot_ins_1, direction=1) plot(B, knots, "B-spline_biquadratic_refined.pdf")
def basic_geometry(XY=np.asarray([[0, -10], [100, -10], [0, 10], [100, 10]]), degree=2, refine=10, k={}): """ Args: XY: edges of the square degree: degree of the nurbs refine: number of how many more points to refine Returns: [degree = degree n_xi and n_eta are the number of elements nel = n_xi * n_eta # total number of elements n = n_xi + degree_u # Number of basis functions/ control points in xi direction m = n_eta + degree_v # Number of basis functions/ control points in eta direction ncp = n * m # Total number of control points gDof = ncp # Global degrees of freedom - Temperature C = bezier extractor P = control points W = Weights IEN = Elemental topology of nodes K = Empty stiffness matrix b = load vector empty D = Displacement vector empty] """ U, V, B = make_surface_square(XY, degree) degree_u = len(np.where(U == 0.)[0]) - 1 n_xi = len(U) - (degree_u + 1) * 2 degree_v = len(np.where(V == 0.)[0]) - 1 n_eta = len(V) - (degree_v + 1) * 2 ### Knot refinement direction = 0 knots_ins = np.linspace(0.1, 0.9, refine) knots = [U, V] B, knots = knot_insertion(B, [degree_v, degree_u], knots, knots_ins, direction=direction) direction = 1 B, knots = knot_insertion(B, [degree_v, degree_u], knots, knots_ins, direction=direction) U, V = knots degree_u = len(np.where(U == 0.)[0]) - 1 degree_v = len(np.where(V == 0.)[0]) - 1 #same number of control points as basis functions n_xi = B.shape[0] - degree_u n_eta = B.shape[1] - degree_v #n_xi = len(U) - degree_u - 3 #n_eta = len(V) - degree_u - 3 # n_xi and n_eta are the number of elements nel = n_xi * n_eta # total number of elements n = n_xi + degree_u # Number of basis functions/ control points in xi direction m = n_eta + degree_v # Number of basis functions/ control points in eta direction ncp = n * m # Total number of control points gDof = ncp # Global degrees of freedom - Temperature K = np.zeros((gDof, gDof)) # stiffness matrix size C_xi = bezier_extraction_operator(U, degree_u) C_eta = bezier_extraction_operator(V, degree_v) assert degree_u == degree_v degree = degree_u C = bezier_extraction_operator_bivariate(C_xi, C_eta, n_xi, n_eta, degree) control_points = B[..., :-1] ref_weights = B[..., -1, np.newaxis] P, W = transform_matrix(control_points, ref_weights) # Element topology IEN = IEN_element_topology(n_xi, n_eta, degree) b = np.zeros(gDof) # load vector size D = np.zeros(gDof) return degree, n_xi, n_eta, nel, n, m, ncp, gDof, C, P, W, IEN, K, b, D
def analyze_bezier(knots, B, refine = 3, _refine=True): """ Args: knots: U and V B: control point of surface Returns: [degree = degree n_xi and n_eta are the number of elements nel = n_xi * n_eta # total number of elements n = n_xi + degree_u # Number of basis functions/ control points in xi direction m = n_eta + degree_v # Number of basis functions/ control points in eta direction ncp = n * m # Total number of control points gDof = ncp # Global degrees of freedom - Temperature C = bezier extractor P = control points W = Weights IEN = Elemental topology of nodes K = Empty stiffness matrix b = load vector empty D = Displacement vector empty] """ from pygeoiga.nurb.refinement import knot_insertion from pygeoiga.analysis.common import transform_matrix, IEN_element_topology from pygeoiga.analysis.bezier_extraction import bezier_extraction_operator_bivariate, bezier_extraction_operator U, V = knots degree_u = len(np.where(U == 0.)[0]) - 1 n_xi = len(U) - (degree_u + 1) * 2 degree_v = len(np.where(V == 0.)[0]) - 1 n_eta = len(V) - (degree_v + 1) * 2 ### Knot refinement if _refine: direction = 0 knots_ins = np.linspace(0.1, 0.9, refine) knots = [U, V] B, knots = knot_insertion(B, [degree_v, degree_u], knots, knots_ins, direction=direction) direction = 1 B, knots = knot_insertion(B, [degree_v, degree_u], knots, knots_ins, direction=direction) U, V = knots degree_u = len(np.where(U == 0.)[0]) - 1 degree_v = len(np.where(V == 0.)[0]) - 1 # same number of control points as basis functions n_xi = B.shape[1] - degree_u n_eta = B.shape[0] - degree_v # n_xi = len(U) - degree_u - 3 # n_eta = len(V) - degree_u - 3 # n_xi and n_eta are the number of elements nel = n_xi * n_eta # total number of elements n = n_xi + degree_u # Number of basis functions/ control points in xi direction m = n_eta + degree_v # Number of basis functions/ control points in eta direction ncp = n * m # Total number of control points gDof = ncp # Global degrees of freedom - Temperature K = np.zeros((gDof, gDof)) # stiffness matrix size C_xi = bezier_extraction_operator(U, degree_u) C_eta = bezier_extraction_operator(V, degree_v) assert degree_u == degree_v degree = degree_u C = bezier_extraction_operator_bivariate(C_xi, C_eta, n_xi, n_eta, degree) control_points = B[..., :-1] ref_weights = B[..., -1, np.newaxis] P, W = transform_matrix(control_points, ref_weights) # Element topology IEN = IEN_element_topology(n_xi, n_eta, degree) b = np.zeros(gDof) # load vector size D = np.zeros(gDof) # Displacement vector return degree, n_xi, n_eta, nel, n, m, ncp, gDof, C, P, W, IEN, K, b, D, B, knots
def analyze_IGA(knots, B, refine=3, _refine=True): """ Args: XY: edges of the square degree: degree of the nurbs refine: number of how many more points to refine Returns: [degree = degree n_xi and n_eta are the number of elements nel = n_xi * n_eta # total number of elements n = n_xi + degree_u # Number of basis functions/ control points in xi direction m = n_eta + degree_v # Number of basis functions/ control points in eta direction ncp = n * m # Total number of control points gDof = ncp # Global degrees of freedom - Temperature C = bezier extractor P = control points W = Weights IEN = Elemental topology of nodes K = Empty stiffness matrix b = load vector empty D = Displacement vector empty] """ from pygeoiga.nurb.refinement import knot_insertion from pygeoiga.analysis.common import transform_matrix, IEN_element_topology U, V = knots degree_u = len(np.where(U == 0.)[0]) - 1 n_xi = len(U) - (degree_u + 1) * 2 degree_v = len(np.where(V == 0.)[0]) - 1 n_eta = len(V) - (degree_v + 1) * 2 ### Knot refinement if _refine: direction = 0 knots_ins = np.linspace(0.1, 0.9, refine) knots = [U, V] B, knots = knot_insertion(B, [degree_v, degree_u], knots, knots_ins, direction=direction) direction = 1 B, knots = knot_insertion(B, [degree_v, degree_u], knots, knots_ins, direction=direction) U, V = knots degree_u = len(np.where(U == 0.)[0]) - 1 degree_v = len(np.where(V == 0.)[0]) - 1 n_xi = len(U) - degree_u - 3 n_eta = len(V) - degree_v - 3 #n_xi = len(U) - (degree_u + 1) * 2 #n_eta = len(V) - (degree_v + 1) * 2 # n_xi and n_eta are the number of elements nel = n_xi * n_eta # total number of elements n = n_xi + degree_u # Number of basis functions/ control points in xi direction m = n_eta + degree_v # Number of basis functions/ control points in eta direction ncp = n * m # Total number of control points gDof = ncp # Global degrees of freedom - Temperature K = np.zeros((gDof, gDof)) # stiffness matrix size degree = degree_u control_points = B[..., :-1] ref_weights = B[..., -1, np.newaxis] P, W = transform_matrix(control_points, ref_weights) # Element topology IEN = IEN_element_topology(n_xi, n_eta, degree) b = np.zeros(gDof) # load vector size D = np.zeros(gDof) return degree, n_xi, n_eta, nel, n, m, ncp, gDof, P, W, IEN, K, b, D, knots, B
def make_unconformity_model(refine=False, knot_ins=(np.arange(0.1, 1, 0.1), np.arange(0.1, 1, 0.1))): c_e1 = np.array([[[0, 0], [0, 250], [0, 500]], [[0, 0], [100, 300], [250, 500]], [[0, 0], [50, 350], [500, 500]]]) k_e1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_e2 = np.array([[[0, 0], [50, 350], [500, 500]], [[150, 0], [300, 300], [650, 500]], [[300, 0], [300, 300], [800, 500]]]) k_e2 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_e3 = np.array([[[300, 0], [300, 300], [800, 500]], [[750, 0], [600, 250], [900, 500]], [[1000, 0], [1000, 250], [1000, 500]]]) k_e3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_e4 = np.array([[[0, 500], [0, 600], [0, 700]], [[250, 500], [250, 600], [250, 700]], [[500, 500], [500, 600], [500, 700]]]) k_e4 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_e5 = np.array([[[500, 500], [500, 600], [500, 700]], [[650, 500], [650, 600], [650, 700]], [[800, 500], [800, 600], [800, 700]]]) k_e5 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_e6 = np.array([[[800, 500], [800, 600], [800, 700]], [[900, 500], [900, 600], [900, 700]], [[1000, 500], [1000, 600], [1000, 700]]]) k_e6 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] cpoints = [c_e1, c_e2, c_e3, c_e4, c_e5, c_e6] knots = [k_e1, k_e2, k_e3, k_e4, k_e5, k_e6] B = [] for i, cp in enumerate(cpoints): shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B.append(np.ones(shape)) B[i][..., :2] = cp if refine: from pygeoiga.nurb.refinement import knot_insertion for i in range(len(B)): knots_ins_0 = knot_ins[0] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_0, direction=0) knots_ins_1 = knot_ins[1] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_1, direction=1) red = 3.1 # W/mK Granite blue = 7.5 # W/mK Salt brown = 1.2 # 1.05–1.45 W/mK, shale yellow = 3 # 2.50–4.20 W/mK Sandstone gray = 0.9 # 0.80–1.25 W/mK Claystone-Siltstone green = 3 # 2.50–4.20 W/mK Sandstone geometry = OrderedDict({}) name = ["E1", "E2", "E3", "E4", "E5", "E6"] color = ["red", "blue", "yellow", "gray", "gray", "gray"] kappa = [red, blue, yellow, gray, gray, gray] position = [(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)] for i, mat in enumerate(B): geometry[name[i]] = { "B": mat, "knots": knots[i], "kappa": kappa[i], 'color': color[i], "position": position[i] } geometry["E1"]["patch_faces"] = {1: "E2", 2: "E4"} geometry["E2"]["patch_faces"] = {1: "E3", 2: "E5", 3: "E1"} geometry["E3"]["patch_faces"] = {2: "E6", 3: "E2"} geometry["E4"]["patch_faces"] = {0: "E1", 1: "E5"} geometry["E5"]["patch_faces"] = {0: "E2", 1: "E6", 3: "E4"} geometry["E6"]["patch_faces"] = {0: "E3", 3: "E5"} # For the meshing part. Specify the face that have a boundary condition #geometry["E1"]["BC"] = {0: "bot_bc"} geometry["E2"]["BC"] = {0: "bot_bc"} geometry["E3"]["BC"] = {0: "bot_bc"} geometry["E4"]["BC"] = {2: "top_bc"} geometry["E5"]["BC"] = {2: "top"} geometry["E6"]["BC"] = {2: "top"} return geometry
def test_knot_refinement_1D(): points1D = np.array([ [0, 0, 0], [0, 1, 0], [1, 1, 0], #[1,0,0] ]) knot10 = np.array([0, 0, 0, 1, 1, 1]) #D1 weight1D = np.ones((points1D.shape[0], 1)) nurb1 = NURB(points1D, [knot10], weight1D, engine="python") print(nurb1.B) fig1 = plt.figure("first") ax1 = fig1.add_subplot(111, projection='3d') ax1.plot(nurb1.model[0], nurb1.model[1], nurb1.model[2]) ax1.plot(nurb1.cpoints[..., 0], nurb1.cpoints[..., 1], nurb1.cpoints[..., 2], color='red', marker='s') # , linestyle='None') fig1.show() knot_ins = np.asarray([0.5, 0.6]) B_new, knots = knot_insertion(nurb1.B, nurb1.degree, nurb1.knots, knot_ins, direction=0) nurb1.cpoints = B_new[..., :3] nurb1.weight = B_new[..., 3, np.newaxis] nurb1.B = B_new nurb1.knots = knots nurb1.create_model() #nurb1 = gn.nurb.knot_insertion(nurb1, knot_ins, direction=0) print(nurb1.B) print(nurb1.B.shape) print(nurb1.degree) fig2 = plt.figure("first") ax2 = fig2.add_subplot(111, projection='3d') ax2.plot(nurb1.model[0], nurb1.model[1], nurb1.model[2]) ax2.plot(nurb1.cpoints[..., 0], nurb1.cpoints[..., 1], nurb1.cpoints[..., 2], color='red', marker='s') # , linestyle='None') fig2.show() knot_ins = np.asarray([0.4, 0.5, 0.7]) B_new, knots = knot_insertion(nurb1.B, nurb1.degree, nurb1.knots, knot_ins, direction=0) nurb1.cpoints = B_new[..., :3] nurb1.weight = B_new[..., 3, np.newaxis] nurb1.B = B_new nurb1.knots = knots nurb1.create_model() #nurb1 = gn.nurb.knot_insertion(nurb1, knot_ins, direction=0) print(nurb1.B) print(nurb1.B.shape) print(nurb1.degree) fig3 = plt.figure("first") ax3 = fig3.add_subplot(111, projection='3d') ax3.plot(nurb1.model[0], nurb1.model[1], nurb1.model[2]) ax3.plot(nurb1.cpoints[..., 0], nurb1.cpoints[..., 1], nurb1.cpoints[..., 2], color='red', marker='s') # , linestyle='None') fig3.show()
def test_knot_refinement_2d(): points2D = np.array([[[150, 0, 50], [150, 25, 50], [150, 50, 50], [140, 50, 50], [140, 25, 50], [140, 0, 50]], [[150, 0, 30], [150, 25, 30], [150, 50, 30], [140, 50, 30], [140, 25, 30], [140, 0, 30]], [[150, 0, 15], [150, 25, 15], [150, 50, 15], [140, 50, 15], [140, 25, 15], [140, 0, 15]], [[150, 0, 0], [150, 25, 0], [150, 50, 0], [140, 50, 0], [140, 25, 0], [140, 0, 0]]]) knot1 = np.array([0, 0, 0, 0, 1, 1, 1, 1]) # D1 knot2 = np.array([0, 0, 0, 0.3, 0.5, 0.7, 1, 1, 1]) #D2 weight2D = np.ones((points2D.shape[0], points2D.shape[1], 1)) nurb2 = NURB(points2D, [knot1, knot2], weight2D, engine="python") print(nurb2.B) print(nurb2.B.shape) print(nurb2.degree) fig1 = plt.figure("first") ax1 = fig1.add_subplot(111, projection='3d') ax1.plot(nurb2.model[:, 0], nurb2.model[:, 1], nurb2.model[:, 2], linestyle='None', marker='.', color='blue') ax1.plot_wireframe(nurb2.cpoints[..., 0], nurb2.cpoints[..., 1], nurb2.cpoints[..., 2], color='red') fig1.show() knot_ins = np.asarray([0.5]) direction = 0 B_new, knots = knot_insertion(nurb2.B, nurb2.degree, nurb2.knots, knot_ins, direction=direction) nurb2.cpoints = B_new[..., :3] nurb2.weight = B_new[..., 3, np.newaxis] nurb2.B = B_new nurb2.knots = knots nurb2.create_model() print(nurb2.B) print(nurb2.B.shape) print(nurb2.degree) fig2 = plt.figure("second") ax2 = fig2.add_subplot(111, projection='3d') ax2.plot(nurb2.model[:, 0], nurb2.model[:, 1], nurb2.model[:, 2], linestyle='None', marker='.', color='blue') ax2.plot_wireframe(nurb2.cpoints[..., 0], nurb2.cpoints[..., 1], nurb2.cpoints[..., 2], color='red') fig2.show()
def make_3_layer_patches(refine=False, knot_ins=[ np.arange(0.1, 1, 0.1), np.arange(0.1, 1, 0.1) ]): bottom_c = np.array([[[0., 0.], [0., 50.], [0., 100.]], [[250., 0.], [250., 180.], [250., 250.]], [[500., 0.], [500., 50.], [500., 100.]]]) knot_b = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] middle_c = np.array([[[0., 100.], [0., 200.], [0., 300.]], [[250., 250.], [250., 350.], [250., 400.]], [[500., 100.], [500., 200.], [500., 300.]]]) knot_m = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] upper_c = np.array([[[0., 300.], [0., 400.], [0., 500.]], [[250., 400.], [250., 450.], [250., 500.]], [[500., 300.], [500., 400.], [500., 500.]]]) knot_u = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] cpoints = [bottom_c, middle_c, upper_c] knots = [knot_b, knot_m, knot_u] B = [] for i, cp in enumerate(cpoints): shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B.append(np.ones(shape)) B[i][..., :2] = cp if refine: from pygeoiga.nurb.refinement import knot_insertion for i in range(len(B)): knots_ins_0 = knot_ins[0] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_0, direction=0) knots_ins_1 = knot_ins[1] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_1, direction=1) geometry = OrderedDict({}) name = ["Granite", "Mudstone", "Sandstone"] color = ["red", "blue", "green"] kappa = [3.1, 0.9, 3] position = [(1, 1), (2, 1), (3, 1)] for i, mat in enumerate(B): geometry[name[i]] = { "B": mat, "knots": knots[i], "kappa": kappa[i], 'color': color[i], "position": position[i] } # BOUNDARIES - faces of the patch in contact # 0: down # 1: right # 2: up # 3: left geometry["Granite"]["patch_faces"] = {2: "Mudstone"} geometry["Mudstone"]["patch_faces"] = {0: "Granite", 2: "Sandstone"} geometry["Sandstone"]["patch_faces"] = {0: "Mudstone"} # For the meshing part. Specify the face that have a boundary condition geometry["Granite"]["BC"] = {0: "bot_bc"} geometry["Sandstone"]["BC"] = {2: "top_bc"} return geometry
def test_image_example2(): from pygeoiga.nurb.cad import make_surface_biquadratic knots, B = make_surface_biquadratic() from pygeoiga.nurb.refinement import knot_insertion knot_ins_1 = [0.3, 0.6] knot_ins_0 = [0.25, 0.75] B, knots = knot_insertion(B, (2, 2), knots, knot_ins_0, direction=0) B, knots = knot_insertion(B, (2, 2), knots, knot_ins_1, direction=1) before = B from pygeoiga.plot.nrbplotting_mpl import create_figure, p_cpoints, p_knots, p_curve, p_surface from pygeoiga.engine.NURB_engine import basis_function_array_nurbs fig = plt.figure(constrained_layout=True) gs = fig.add_gridspec(3, 3, hspace=0, wspace=0, width_ratios=[0.2, 0.2, 1], height_ratios=[1, 0.2, 0.2]) (ax_bv, ax_v, ax2), (no1, no2, ax_u), (no3, no4, ax_bu) = gs.subplots(sharex=True, sharey=True) for no in no1, no2, no3, no4: no.remove() N_spline_u, _ = basis_function_array_nurbs(knot_vector=knots[0], degree=2, resolution=100) N_spline_v, _ = basis_function_array_nurbs(knot_vector=knots[1], degree=2, resolution=100) resol = np.linspace(0, 1, 100) ax_u.plot(resol, N_spline_u) ax_u.spines["top"].set_visible(False) ax_u.spines["right"].set_visible(False) ax_u.set_xlim(0, 1) ax_u.set_ylim(0, 1) ax_v.plot(N_spline_v, resol) ax_v.spines["top"].set_visible(False) ax_v.spines["right"].set_visible(False) ax_v.set_yticks(knots[2:-2]) ax_v.set_xlim(0, 1) ax_v.set_ylim(0, 1) ax_u.set_xlabel("$u$") ax_v.set_ylabel("$v$") ax_v.set_xlabel("$N(v)$") ax_u.set_ylabel("$N(u)$") ax_v.set_yticks(knots[1][2:-2]) ax_u.set_xticks(knots[0][2:-2]) for i in knots[0]: ax2.vlines(i, 0, 1, 'k') for j in knots[1]: ax2.hlines(j, 0, 1, 'k') ax2.set_xlim(0, 1) ax2.set_ylim(0, 1) ax2.set_axis_off() fig2, ax = plt.subplots(constrained_layout=True) ax = p_cpoints(B, ax=ax, dim=2, point=False, line=True, color="black", linestyle="-") ax = p_cpoints(B, ax=ax, dim=2, point=True, line=False, color="red") ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("$x$") ax.set_ylabel("$y$") ax.set_aspect(0.8) fig2.tight_layout(pad=0, h_pad=0, w_pad=0) fig2.show() from pygeoiga.nurb.refinement import knot_insertion knot_ins_1 = [0.3, 0.6] knot_ins_0 = [0.25, 0.5, 0.75] B, knots = knot_insertion(B, (2, 2), knots, knot_ins_0, direction=0) B, knots = knot_insertion(B, (2, 2), knots, knot_ins_1, direction=1) new = B N_spline_u, _ = basis_function_array_nurbs(knot_vector=knots[0], degree=2, resolution=100) N_spline_v, _ = basis_function_array_nurbs(knot_vector=knots[1], degree=2, resolution=100) resol = np.linspace(0, 1, 100) ax_bu.plot(resol, N_spline_u) ax_bu.spines["top"].set_visible(False) ax_bu.spines["right"].set_visible(False) ax_bu.set_xlim(0, 1) ax_bu.set_ylim(0, 1) ax_bv.plot(N_spline_v, resol) ax_bv.spines["top"].set_visible(False) ax_bv.spines["right"].set_visible(False) ax_bv.set_yticks(knots[2:-2]) ax_bv.set_xlim(0, 1) ax_bv.set_ylim(0, 1) ax_bu.set_xlabel("$u$") ax_bv.set_ylabel("$v$") ax_bv.set_xlabel("$B(v)$") ax_bu.set_ylabel("$B(u)$") ax_bv.set_yticks(knots[1][2:-2]) ax_bu.set_xticks(knots[0][2:-2]) #for ax in ax_u, ax_v, ax2, no, ax_bu, ax_bv: # ax.label_outer() fig2.show() degree_u = len(np.where(knots[0] == 0.)[0]) - 1 degree_v = len(np.where(knots[1] == 0.)[0]) - 1 n_xi = len(knots[0]) - degree_u - 3 n_eta = len(knots[1]) - degree_v - 3 from pygeoiga.analysis.common import IEN_element_topology, transform_matrix_B IEN = IEN_element_topology(n_xi, n_eta, degree_u) P, W = transform_matrix_B(B) fig3, ax = plt.subplots(constrained_layout=True) for i in range(0, n_xi, 2): pos = IEN[i::n_xi] for e in pos[::2]: # cont = np.hstack([IEN[0][:degree_u+1], IEN[0][degree_u+3], np.flip(IEN[0][-degree_u-1:]), IEN[0][degree_u+1], IEN[0][0]]) cont = np.hstack([ e[:degree_u + 1], e[degree_u + 3], np.flip(e[-degree_u - 1:]), e[degree_u + 1], e[0] ]) ax.plot(P[cont][:, 0], P[cont][:, 1], linestyle="-", color="black", marker=None) ax = p_cpoints(B, ax=ax, dim=2, point=True, line=False, color="red") ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("$x$") ax.set_ylabel("$y$") ax.set_aspect(0.8) fig3.tight_layout(pad=0, h_pad=0, w_pad=0) fig.show() fig2.show() fig3.show() fig_0, ax = plt.subplots(constrained_layout=True) ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="k") ax = p_surface(knots, B, ax=ax, dim=2, fill=True, border=False, color="gray", alpha=0.5) ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("$x$") ax.set_ylabel("$y$") ax.set_aspect(0.8) fig_0.tight_layout(pad=0, h_pad=0, w_pad=0) fig_0.show() save = False if save or save_all: fig.savefig(fig_folder + "bezier_extraction.pdf", **kwargs_savefig) fig_0.savefig(fig_folder + "curve_original.pdf", **kwargs_savefig) fig2.savefig(fig_folder + "control_original.pdf", **kwargs_savefig) fig3.savefig(fig_folder + "control_bezier.pdf", **kwargs_savefig)
def test_image_example(): def plot(B, knots, file_name): from pygeoiga.plot.nrbplotting_mpl import create_figure, p_cpoints, p_knots, p_curve, p_surface fig, ax = plt.subplots(constrained_layout=True) ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="k") ax = p_cpoints(B, ax=ax, dim=2, point=True, line=True, color="red") ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("$x$") ax.set_ylabel("$y$") ax.set_aspect(0.8) fig.tight_layout(pad=0, h_pad=0, w_pad=0) fig.show() from pygeoiga.engine.NURB_engine import basis_function_array_nurbs fig2 = plt.figure(constrained_layout=True) gs = fig2.add_gridspec(2, 2, hspace=0, wspace=0, width_ratios=[0.2, 1], height_ratios=[1, 0.2]) (ax_v, ax2), (no, ax_u) = gs.subplots(sharex=True, sharey=True) no.remove() N_spline_u, _ = basis_function_array_nurbs(knot_vector=knots[0], degree=2, resolution=100) N_spline_v, _ = basis_function_array_nurbs(knot_vector=knots[1], degree=2, resolution=100) resol = np.linspace(0, 1, 100) ax_u.plot(resol, N_spline_u) ax_u.spines["top"].set_visible(False) ax_u.spines["right"].set_visible(False) ax_u.set_xlim(0, 1) ax_u.set_ylim(0, 1) ax_v.plot(N_spline_v, resol) ax_v.spines["top"].set_visible(False) ax_v.spines["right"].set_visible(False) ax_v.set_yticks(knots[2:-2]) ax_v.set_xlim(1, 0) ax_v.set_ylim(0, 1) for i in knots[0]: ax2.vlines(i, 0, 1, 'k') for j in knots[1]: ax2.hlines(j, 0, 1, 'k') ax2.set_xlim(0, 1) ax2.set_ylim(0, 1) ax2.set_axis_off() ax_u.set_xlabel("$u$") ax_v.set_ylabel("$v$") ax_v.set_yticks(knots[1][2:-2]) ax_u.set_xticks(knots[0][2:-2]) for ax in ax_u, ax_v, ax2, no: ax.label_outer() fig2.show() save = False if save or save_all: fig2.savefig(fig_folder + file_name, **kwargs_savefig) from pygeoiga.nurb.cad import make_surface_biquadratic knots, B = make_surface_biquadratic() from pygeoiga.nurb.refinement import knot_insertion knot_ins_1 = [0.3, 0.6] knot_ins_0 = [0.25, 0.75] B, knots = knot_insertion(B, (2, 2), knots, knot_ins_0, direction=0) B, knots = knot_insertion(B, (2, 2), knots, knot_ins_1, direction=1) plot(B, knots, "mapping.pdf") knots, B = make_surface_biquadratic() from pygeoiga.nurb.refinement import knot_insertion knot_ins_1 = [0.3, 0.3, 0.6, 0.6] knot_ins_0 = [0.25, 0.25, 0.5, 0.75, 0.75] B, knots = knot_insertion(B, (2, 2), knots, knot_ins_0, direction=0) B, knots = knot_insertion(B, (2, 2), knots, knot_ins_1, direction=1) plot(B, knots, "mapping.pdf")
def test_show_simple_mesh_IGA(): from pygeoiga.plot.nrbplotting_mpl import create_figure, p_cpoints, p_knots, p_curve, p_surface cp = np.array([[[0, 0], [3, 0]], [[0, 2], [3, 2]]]) kn1 = [0, 0, 1, 1] kn2 = [0, 0, 1, 1] knots = [kn1, kn2] shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B = np.ones(shape) B[..., :2] = cp from pygeoiga.nurb.refinement import knot_insertion B, knots = knot_insertion(B, [1, 1], knots, [0.5], 0) B, knots = knot_insertion(B, [1, 1], knots, [1 / 3, 2 / 3], 1) fig, ax = create_figure("2d") ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("x") ax.set_ylabel("y") ax.set_xticks([]) ax.set_yticks([]) ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="black") ax = p_cpoints(B, ax=ax, dim=2, color="red", marker="o", point=True, line=False) n, m = B.shape[0], B.shape[1] P = np.asarray([(B[x, y, 0], B[x, y, 1]) for x in range(n) for y in range(m)]) for count, point in enumerate(P): ax.annotate(str(count), point, xytext=(5, 5), textcoords="offset points") ax.annotate("$\Omega_1$", (0.5, 0.5), fontsize=20, xytext=(-5, -5), textcoords="offset points") ax.annotate("$\Omega_2$", (1.5, 0.5), fontsize=20, xytext=(-5, -5), textcoords="offset points") ax.annotate("$\Omega_3$", (2.5, 0.5), fontsize=20, xytext=(-5, -5), textcoords="offset points") ax.annotate("$\Omega_4$", (0.5, 1.5), fontsize=20, xytext=(-5, -5), textcoords="offset points") ax.annotate("$\Omega_5$", (1.5, 1.5), fontsize=20, xytext=(-5, -5), textcoords="offset points") ax.annotate("$\Omega_6$", (2.5, 1.5), fontsize=20, xytext=(-5, -5), textcoords="offset points") fig.show() knots = [kn1, kn2] shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B = np.ones(shape) B[..., :2] = cp from pygeoiga.nurb.refinement import degree_elevation B, knots = degree_elevation(B, knots, direction=0) B, knots = degree_elevation(B, knots, direction=1) from pygeoiga.nurb.refinement import knot_insertion B, knots = knot_insertion(B, [2, 2], knots, [0.5], 0) B, knots = knot_insertion(B, [2, 2], knots, [1 / 3, 2 / 3], 1) fig2, ax2 = create_figure("2d") # ax2.set_axis_off() ax2.spines["right"].set_visible(False) ax2.spines["top"].set_visible(False) ax2.set_xlabel("x") ax2.set_ylabel("y") ax2.set_xticks([]) ax2.set_yticks([]) ax2 = p_knots(knots, B, ax=ax2, dim=2, point=False, line=True, color="black") ax2 = p_cpoints(B, ax=ax2, dim=2, color="red", marker="o", point=True, line=False) n, m = B.shape[0], B.shape[1] P = np.asarray([(B[x, y, 0], B[x, y, 1]) for x in range(n) for y in range(m)]) for count, point in enumerate(P): ax2.annotate(str(count), point, xytext=(5, 5), textcoords="offset points") disp = (28, 30) ax2.annotate("$\Omega_1$", (0.5, 0.5), fontsize=20, xytext=disp, textcoords="offset points") ax2.annotate("$\Omega_2$", (1.5, 0.5), fontsize=20, xytext=disp, textcoords="offset points") ax2.annotate("$\Omega_3$", (2.5, 0.5), fontsize=20, xytext=disp, textcoords="offset points") ax2.annotate("$\Omega_4$", (0.5, 1.5), fontsize=20, xytext=disp, textcoords="offset points") ax2.annotate("$\Omega_5$", (1.5, 1.5), fontsize=20, xytext=disp, textcoords="offset points") ax2.annotate("$\Omega_6$", (2.5, 1.5), fontsize=20, xytext=disp, textcoords="offset points") fig2.show() save = True if save or save_all: fig.savefig(fig_folder + "NURB_mesh_1_degree.pdf", **kwargs_savefig) fig2.savefig(fig_folder + "NURB_mesh_2_degree.pdf", **kwargs_savefig)
def make_salt_dome(show=False, refine=False, knot_ins=[np.arange(0.1, 1, 0.1), np.arange(0.1, 1, 0.1)]): U1_1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c1_1 = np.asarray([[[0, 0], [0, 250], [0, 500]], [[1200, 0], [1200, 250], [1200, 500]], [[2400, 0], [2400, 250], [2400, 500]]]) U1_2 = [[0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c1_2 = np.asarray([[[2400, 0], [2400, 250], [2400, 500]], [[2580, 0], [2640, 250], [2700, 500]], [[2880, 0], [2790, 250], [2700, 500]], [[3180, 0], [3040, 450], [2900, 900]], [[3480, 0], [3190, 450], [2900, 900]], [[3600, 0], [3600, 450], [3600, 900]]]) U1_3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c1_3 = np.asarray([[[3600, 0], [3600, 450], [3600, 900]], [[4800, 0], [4800, 450], [4800, 900]], [[6000, 0], [6000, 450], [6000, 900]]]) U2_1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c2_1 = np.asarray([[[0, 500], [0, 650], [0, 800]], [[1200, 500], [1600, 500], [2000, 500]], [[2400, 500], [2400, 566], [2400, 632]]]) U2_2 = [[0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c2_2 = np.asarray([[[2400, 500], [2400, 566], [2400, 632]], [[2700, 500], [2650, 600], [2700, 650]], [[2700, 500], [2650, 700], [2750, 750]], [[2900, 900], [2900, 950], [2900, 1000]], [[2900, 900], [3300, 1000], [3300, 1100]], [[3600, 900], [3600, 1050], [3600, 1200]]]) U2_3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c2_3 = np.asarray([[[3600, 900], [3600, 1050], [3600, 1200]], [[4800, 900], [4200, 900], [4100, 1000]], [[6000, 900], [6000, 905], [6000, 910]]]) U3_1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c3_1 = np.asarray([[[0, 800], [0, 1100], [0, 1400]], [[2000, 500], [1400, 800], [2000, 700]], [[2400, 632], [2600, 700], [2800, 1250]]]) U3_2 = [[0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c3_2 = np.asarray([[[2400, 632], [2600, 700], [2800, 1250]], [[2700, 650], [2700, 800], [2850, 1250]], [[2750, 750], [2750, 900], [2950, 1400]], [[2900, 1000], [2950, 1250], [3000, 1500]], [[3300, 1100], [3150, 1400], [3200, 1700]], [[3600, 1200], [3250, 1600], [3300, 1800]]]) U3_3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c3_3 = np.asarray([[[3600, 1200], [3250, 1600], [3300, 1800]], [[4100, 1000], [4500, 1000], [4000, 1300]], [[6000, 910], [6000, 1100], [6000, 1300]]]) U4_1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c4_1 = np.asarray([[[0, 1400], [0, 1800], [0, 2200]], [[2000, 700], [2000, 1200], [2400, 1800]], [[2800, 1250], [2900, 1600], [2750, 2200]]]) U4_2 = [[0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c4_2 = np.asarray([[[2800, 1250], [2900, 1600], [2750, 2200]], [[2850, 1250], [2900, 2000], [2900, 2200]], [[2950, 1400], [3050, 2000], [3000, 2200]], [[3000, 1500], [3100, 2100], [3200, 2300]], [[3200, 1700], [3150, 2100], [3300, 2350]], [[3300, 1800], [3250, 2000], [3400, 2400]]]) U4_3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c4_3 = np.asarray([[[3300, 1800], [3250, 2000], [3400, 2400]], [[4000, 1300], [4000, 1200], [4000, 1800]], [[6000, 1300], [6000, 1600], [6000, 1800]]]) U5_1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c5_1 = np.asarray([[[0, 2200], [0, 2350], [0, 2500]], [[2400, 1800], [2400, 2100], [2400, 2200]], [[2750, 2200], [2700, 2300], [2700, 2500]]]) U5_2 = [[0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c5_2 = np.asarray([[[2750, 2200], [2700, 2300], [2700, 2500]], [[2900, 2200], [2800, 2500], [2800, 2700]], [[3000, 2200], [3000, 2500], [2900, 2750]], [[3200, 2300], [3150, 2500], [3000, 2790]], [[3300, 2350], [3280, 2500], [3190, 2790]], [[3400, 2400], [3400, 2500], [3300, 2670]]]) U5_3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c5_3 = np.asarray([[[3400, 2400], [3400, 2500], [3300, 2670]], [[4000, 1800], [4000, 2100], [4000, 2200]], [[6000, 1800], [6000, 2000], [6000, 2200]]]) U6_1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c6_1 = np.asarray([[[0, 2500], [0, 2750], [0, 3000]], [[2400, 2200], [2400, 2600], [2400, 3000]], [[2700, 2500], [2700, 2750], [2700, 3000]]]) U6_2 = [[0, 0, 0, 0.25, 0.5, 0.75, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c6_2 = np.asarray([[[2700, 2500], [2700, 2750], [2700, 3000]], [[2800, 2700], [2800, 2850], [2800, 3000]], [[2900, 2750], [2900, 2900], [2900, 3000]], [[3000, 2790], [3000, 2900], [3000, 3000]], [[3190, 2790], [3150, 2900], [3150, 3000]], [[3300, 2670], [3300, 2800], [3300, 3000]]]) U6_3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c6_3 = np.asarray([[[3300, 2670], [3300, 2800], [3300, 3000]], [[4000, 2200], [4000, 2600], [4000, 3000]], [[6000, 2200], [6000, 2600], [6000, 3000]]]) cpoints = [ c1_1, c1_2, c1_3, c2_1, c2_2, c2_3, c3_1, c3_2, c3_3, c4_1, c4_2, c4_3, c5_1, c5_2, c5_3, c6_1, c6_2, c6_3 ] knots = [ U1_1, U1_2, U1_3, U2_1, U2_2, U2_3, U3_1, U3_2, U3_3, U4_1, U4_2, U4_3, U5_1, U5_2, U5_3, U6_1, U6_2, U6_3 ] B = [] for i, cp in enumerate(cpoints): shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B.append(np.ones(shape)) B[i][..., :2] = cp if show: def show_plots(): from pygeoiga.plot.nrbplotting_mpl import p_surface, p_cpoints, p_knots import matplotlib import matplotlib.pyplot as mpl color = None mpl.close("all") figa, axa = mpl.subplots() org = False if org: image = mpl.imread( "/home/danielsk78/GitProjects/master_thesis_IGA-Geothermal-Modeling/IGA/pygeoiga/nurb/data/salt_diapir.png" ) extent = [0, 6000, 0, 3000] axa.imshow(np.flipud(image), extent=extent, origin="lower", aspect="auto") major_ticks_x = np.arange(0, extent[1] + 1, 1000) major_ticks_y = np.arange(0, extent[3] + 1, 1000) minor_ticks_x = np.arange(0, extent[1] + 1, 200) minor_ticks_y = np.arange(0, extent[3] + 1, 200) axa.set_xticks(major_ticks_x) axa.set_xticks(minor_ticks_x, minor=True) axa.set_yticks(major_ticks_y) axa.set_yticks(minor_ticks_y, minor=True) axa.grid(which='both') for i, surf in enumerate(cpoints): col = color[i] if color is not None else np.random.rand(3, ) p_surface(knots[i], surf, ax=axa, dim=2, color=col, alpha=0.5) p_cpoints(surf, ax=axa, line=False, point=True, color=col, dim=2) p_knots(knots[i], surf, ax=axa, dim=2, point=False, color=col) mpl.show() color = [ "red", "red", "red", "blue", "blue", "blue", "brown", "blue", "brown", "yellow", "blue", "yellow", "gray", "blue", "gray", "green", "green", "green" ] figs, axs = mpl.subplots() for i, surf in enumerate(cpoints): col = color[i] if color is not None else np.random.rand(3, ) p_surface(knots[i], surf, ax=axs, dim=2, color=col) #p_cpoints(surf, ax=axs, line=False, point=True, color=col, dim=2) #p_knots(knots[i], surf, ax=axs, dim=2, point=False, color=col) mpl.show() show_plots() if refine: from pygeoiga.nurb.refinement import knot_insertion for i in range(len(B)): knots_ins_0 = knot_ins[0] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_0, direction=0) knots_ins_1 = knot_ins[1] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_1, direction=1) if show: show_plots() red = 3.1 # W/mK Granite blue = 7.5 #W/mK Salt brown = 1.2 # 1.05–1.45 W/mK, shale yellow = 3 # 2.50–4.20 W/mK Sandstone gray = 0.9 #0.80–1.25 W/mK Claystone-Siltstone green = 3.2 # 2.50–4.20 W/mK Sandstone geometry = OrderedDict({}) name = [ "bottom_L", "bottom_C", "bottom_R", "D2_1", "D2_2", "D2_3", "D3_1", "D3_2", "D3_3", "D4_1", "D4_2", "D4_3", "D5_1", "D5_2", "D5_3", "top_L", "top_C", "top_R" ] color = [ "red", "red", "red", "blue", "blue", "blue", "brown", "blue", "brown", "yellow", "blue", "yellow", "gray", "blue", "gray", "green", "green", "green" ] kappa = [ red, red, red, blue, blue, blue, brown, blue, brown, yellow, blue, yellow, gray, blue, gray, green, blue, green ] position = [(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (4, 3), (5, 1), (5, 2), (5, 3), (6, 1), (6, 2), (6, 3)] for i, mat in enumerate(B): geometry[name[i]] = { "B": mat, "knots": knots[i], "kappa": kappa[i], 'color': color[i], "position": position[i] } geometry["bottom_L"]["patch_faces"] = {1: "bottom_C", 2: "D2_1"} geometry["bottom_C"]["patch_faces"] = { 1: "bottom_R", 2: "D2_2", 3: "bottom_L" } geometry["bottom_R"]["patch_faces"] = {2: "D2_3", 3: "bottom_C"} geometry["D2_1"]["patch_faces"] = {0: "bottom_L", 1: "D2_2", 2: "D3_1"} geometry["D2_2"]["patch_faces"] = { 0: "bottom_C", 1: "D2_3", 2: "D3_2", 3: "D2_1" } geometry["D2_3"]["patch_faces"] = {0: "bottom_R", 2: "D3_3", 3: "D2_2"} geometry["D3_1"]["patch_faces"] = {0: "D2_1", 1: "D3_2", 2: "D4_1"} geometry["D3_2"]["patch_faces"] = { 0: "D2_2", 1: "D3_3", 2: "D4_2", 3: "D3_1" } geometry["D3_3"]["patch_faces"] = {0: "D2_3", 2: "D4_3", 3: "D3_2"} geometry["D4_1"]["patch_faces"] = {0: "D3_1", 1: "D4_2", 2: "D5_1"} geometry["D4_2"]["patch_faces"] = { 0: "D3_2", 1: "D4_3", 2: "D5_2", 3: "D4_1" } geometry["D4_3"]["patch_faces"] = {0: "D3_3", 2: "D5_3", 3: "D4_2"} geometry["D5_1"]["patch_faces"] = {0: "D4_1", 1: "D5_2", 2: "top_L"} geometry["D5_2"]["patch_faces"] = { 0: "D4_2", 1: "D5_3", 2: "top_C", 3: "D5_1" } geometry["D5_3"]["patch_faces"] = {0: "D4_3", 2: "top_R", 3: "D5_2"} geometry["top_L"]["patch_faces"] = {0: "D5_1", 1: "top_C"} geometry["top_C"]["patch_faces"] = {0: "D5_2", 1: "top_R", 3: "top_L"} geometry["top_R"]["patch_faces"] = {0: "D5_3", 3: "top_C"} # For the meshing part. Specify the face that have a boundary condition geometry["bottom_L"]["BC"] = {0: "bot_bc"} geometry["bottom_C"]["BC"] = {0: "bot_bc"} geometry["bottom_R"]["BC"] = {0: "bot_bc"} geometry["top_L"]["BC"] = {2: "top_bc"} geometry["top_C"]["BC"] = {2: "top_bc"} geometry["top_R"]["BC"] = {2: "top_bc"} return geometry
def make_L_shape(refine=False, knot_ins=(np.arange(0.1, 1, 0.1), np.arange(0.1, 1, 0.1))): c_d1 = np.array([[[0, 0], [0, 100], [0, 200]], [[50, 0], [85.5, 100], [121, 200]], [[100, 0], [171, 100], [242, 200]]]) k_d1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d2 = np.array([[[100, 0], [171, 100], [242, 200]], [[225, 0], [585.5 / 2, 100], [360, 200]], [[500, 0], [500, 100], [500, 200]]]) k_d2 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d3 = np.array([[[0, 200], [0, 250], [0, 300]], [[121, 200], [138, 250], [155, 300]], [[242, 200], [276, 250], [310, 300]]]) k_d3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] cpoints = [c_d1, c_d2, c_d3] knots = [k_d1, k_d2, k_d3] B = [] for i, cp in enumerate(cpoints): shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B.append(np.ones(shape)) B[i][..., :2] = cp if refine: from pygeoiga.nurb.refinement import knot_insertion for i in range(len(B)): knots_ins_0 = knot_ins[0] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_0, direction=0) knots_ins_1 = knot_ins[1] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_1, direction=1) color = ["red", "blue", "purple"] red = 3 # kappa blue = 2 # kappa yellow = 5 # kappa geometry = OrderedDict({}) name = ["bottom_L", "bottom_R", "top"] kappa = [red, blue, yellow] position = [(1, 1), (1, 2), (2, 1)] for i, mat in enumerate(B): geometry[name[i]] = { "B": mat, "knots": knots[i], "kappa": kappa[i], 'color': color[i], "position": position[i] } geometry["bottom_L"]["patch_faces"] = { 1: "bottom_R", 2: "top" } #{2: "top"}# geometry["bottom_R"]["patch_faces"] = {3: "bottom_L"} geometry["top"]["patch_faces"] = {0: "bottom_L"} # For the meshing part. Specify the face that have a boundary condition geometry["bottom_L"]["BC"] = {0: "bot_bc"} geometry["bottom_R"]["BC"] = {0: "bot_bc"} geometry["top"]["BC"] = {2: "top_bc"} return geometry
def test_single_knot_2d(): C = np.zeros((3, 3, 3)) C[:, :, 0] = [[0.0, 3.0, 5.0], [0.0, 0.0, 0.0], [2.0, 2.0, 7.0]] C[:, :, 1] = [[0.0, 3.0, 5.0], [3.0, 3.0, 3.0], [0.0, 0.0, 5.0]] C[:, :, 2] = [[0.0, 3.0, 5.0], [5.0, 5.0, 5.0], [0.0, 0.0, 5.0]] C = C.transpose() U = np.array([0, 0, 0, 1, 1, 1]) V = np.array([0, 0, 0, 1, 1, 1]) resolution = 20 nurb2 = NURB(C, [U, V], resolution=resolution, engine="python") print(nurb2.B) print(nurb2.B.shape) print(nurb2.degree) print(nurb2.knots) fig1 = plt.figure("first") ax1 = fig1.add_subplot(111, projection='3d') ax1.plot(nurb2.model[:, 0], nurb2.model[:, 1], nurb2.model[:, 2], linestyle='None', marker='.', color='blue') ax1.plot_wireframe(nurb2.cpoints[..., 0], nurb2.cpoints[..., 1], nurb2.cpoints[..., 2], color='red') fig1.show() knot_ins = np.asarray([0.5]) direction = 1 B_new, knots = knot_insertion(nurb2.B, nurb2.degree, nurb2.knots, knot_ins, direction=direction) nurb2.cpoints = B_new[..., :3] nurb2.weight = B_new[..., 3, np.newaxis] nurb2.B = B_new nurb2.knots = knots nurb2.create_model() print(nurb2.B) print(nurb2.B.shape) print(nurb2.degree) print(nurb2.knots) fig2 = plt.figure("second") ax2 = fig2.add_subplot(111, projection='3d') ax2.plot(nurb2.model[:, 0], nurb2.model[:, 1], nurb2.model[:, 2], linestyle='None', marker='.', color='blue') ax2.plot_wireframe(nurb2.cpoints[..., 0], nurb2.cpoints[..., 1], nurb2.cpoints[..., 2], color='red') fig2.show() direction = 0 B_new, knots = knot_insertion(nurb2.B, nurb2.degree, nurb2.knots, knot_ins, direction=direction) nurb2.cpoints = B_new[..., :3] nurb2.weight = B_new[..., 3, np.newaxis] nurb2.B = B_new nurb2.knots = knots nurb2.create_model() print(nurb2.B) print(nurb2.B.shape) print(nurb2.degree) print(nurb2.knots) fig3 = plt.figure("second") ax3 = fig3.add_subplot(111, projection='3d') ax3.plot(nurb2.model[:, 0], nurb2.model[:, 1], nurb2.model[:, 2], linestyle='None', marker='.', color='blue') ax3.plot_wireframe(nurb2.cpoints[..., 0], nurb2.cpoints[..., 1], nurb2.cpoints[..., 2], color='red') fig3.show()
def test_make_NURB_quarter_disk_refined(): from pygeoiga.nurb.cad import quarter_disk knots, B = quarter_disk() from pygeoiga.nurb.refinement import knot_insertion knots_ins_0 = [0.3, 0.6] B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knots_ins_0, direction=0) knots_ins_1 = [0.5] B, knots = knot_insertion(B, degree=(2, 2), knots=knots, knots_ins=knots_ins_1, direction=1) from pygeoiga.plot.nrbplotting_mpl import create_figure, p_cpoints, p_knots, p_curve, p_surface fig, [ax2, ax] = plt.subplots(1, 2, sharey=True) ax = p_knots(knots, B, ax=ax, dim=2, point=False, line=True, color="k") ax = p_surface(knots, B, ax=ax, dim=2, color="blue", border=False, alpha=0.5) ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.set_xlabel("x") ax.set_aspect("equal") ax2 = p_cpoints(B, ax=ax2, dim=2, color="blue", linestyle="-", point=False, line=True) ax2 = p_cpoints(B, ax=ax2, dim=2, color="red", marker="o", point=True, line=False) n, m = B.shape[0], B.shape[1] P = np.asarray([(B[x, y, 0], B[x, y, 1]) for y in range(m) for x in range(n)]) for count, point in enumerate(P): ax2.annotate(str(count), point, fontsize=8, xytext=(3, 7), textcoords="offset points") ax2.spines["right"].set_visible(False) ax2.spines["top"].set_visible(False) ax2.set_xlabel("x") ax2.set_ylabel("y") ax2.set_aspect("equal") fig.show() save = True if save or save_all: fig.savefig(fig_folder + "NURBS_surface.pdf", **kwargs_savefig)
def make_fault_model(refine=False, knot_ins=(np.arange(0.1, 1, 0.1), np.arange(0.1, 1, 0.1))): c_d1 = np.array([[[0, 0], [0, 100], [0, 200]], [[50, 0], [85.5, 100], [121, 200]], [[100, 0], [171, 100], [242, 200]]]) k_d1 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d2 = np.array([[[100, 0], [171, 100], [242, 200]], [[550, 0], [585.5, 100], [621, 200]], [[1000, 0], [1000, 100], [1000, 200]]]) k_d2 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d3 = np.array([[[0, 200], [0, 250], [0, 300]], [[121, 200], [138, 250], [155, 300]], [[242, 200], [276, 250], [310, 300]]]) k_d3 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d4 = np.array([[[242, 200], [276., 250.], [310., 300]], [[621., 200.], [638., 250], [655., 300.]], [[1000., 200.], [1000., 250.], [1000., 300.]]]) k_d4 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d5 = np.array([[[0., 300], [0., 500], [0., 700.]], [[155., 300.], [225., 500.], [295., 700.]], [[310., 300.], [450., 500], [590., 700]]]) k_d5 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d6 = np.array([[[310., 300], [450., 500], [590., 700]], [[655., 300], [725., 500], [795., 700]], [[1000., 300], [1000., 500], [1000., 700]]]) k_d6 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d7 = np.array([[[0., 700], [0., 750], [0., 800.]], [[295., 700], [312.5, 750], [330., 800]], [[590., 700], [625., 750], [660., 800]]]) k_d7 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d8 = np.array([[[590., 700], [625., 750], [660., 800]], [[795., 700], [812.5, 750], [830., 800]], [[1000., 700], [1000., 750], [1000., 800]]]) k_d8 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d9 = np.array([[[0., 800], [0., 900], [0., 1000]], [[330., 800], [365., 900], [400., 1000]], [[660., 800], [730., 900], [800., 1000]]]) k_d9 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] c_d10 = np.array([[[660., 800.], [730., 900], [800., 1000]], [[830., 800], [865., 900], [900., 1000]], [[1000., 800], [1000., 900], [1000., 1000]]]) k_d10 = [[0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]] cpoints = [c_d1, c_d2, c_d3, c_d4, c_d5, c_d6, c_d7, c_d8, c_d9, c_d10] knots = [k_d1, k_d2, k_d3, k_d4, k_d5, k_d6, k_d7, k_d8, k_d9, k_d10] B = [] for i, cp in enumerate(cpoints): shape = np.asarray(cp.shape) shape[-1] = 3 # To include the weights in the last term B.append(np.ones(shape)) B[i][..., :2] = cp if refine: from pygeoiga.nurb.refinement import knot_insertion for i in range(len(B)): knots_ins_0 = knot_ins[0] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_0, direction=0) knots_ins_1 = knot_ins[1] B[i], knots[i] = knot_insertion(B[i], degree=(2, 2), knots=knots[i], knots_ins=knots_ins_1, direction=1) red = 3.1 # kappa blue = 0.9 # salt yellow = 3 # New green geometry = OrderedDict({}) name = [ "bottom_L", "bottom_R", "D3", "D4", "D5", "D6", "D7", "D8", "top_L", "top_R" ] color = [ "red", "red", "red", "blue", "red", "green", "blue", "green", "green", "green" ] # position refer to the location in x,y - x is columns, y rows - from top left to top right position = [(1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2), (4, 1), (4, 2), (5, 1), (5, 2)] kappa = [red, red, red, blue, red, yellow, blue, yellow, yellow, yellow] for i, mat in enumerate(B): geometry[name[i]] = { "B": mat, "knots": knots[i], "kappa": kappa[i], 'color': color[i], "position": position[i] } geometry["bottom_L"]["patch_faces"] = {1: "bottom_R", 2: "D3"} geometry["bottom_R"]["patch_faces"] = {2: "D4", 3: "bottom_L"} geometry["D3"]["patch_faces"] = {0: "bottom_L", 1: "D4", 2: "D5"} geometry["D4"]["patch_faces"] = {0: "bottom_R", 2: "D6", 3: "D3"} geometry["D5"]["patch_faces"] = {0: "D3", 1: "D6", 2: "D7"} geometry["D6"]["patch_faces"] = {0: "D4", 2: "D8", 3: "D5"} geometry["D7"]["patch_faces"] = {0: "D5", 1: "D8", 2: "top_L"} geometry["D8"]["patch_faces"] = {0: "D6", 2: "top_R", 3: "D7"} geometry["top_L"]["patch_faces"] = {0: "D7", 1: "top_R"} geometry["top_R"]["patch_faces"] = {0: "D8", 3: "top_L"} # For the meshing part. Specify the face that have a boundary condition geometry["bottom_L"]["BC"] = {0: "bot_bc"} geometry["bottom_R"]["BC"] = {0: "bot_bc"} geometry["top_L"]["BC"] = {2: "top_bc"} geometry["top_R"]["BC"] = {2: "top_bc"} return geometry