예제 #1
0
def test_plot_solution_inverse_fault():
    from pygeoiga.nurb.cad import make_fault_model
    from pygeoiga.analysis.MultiPatch import patch_topology, form_k_IGA_mp, boundary_condition_mp
    from pygeoiga.analysis.common import solve
    from pygeoiga.plot.solution_mpl import p_temperature, p_temperature_mp
    from pygeoiga.analysis.MultiPatch import map_MP_elements
    geometry = make_fault_model(refine=True)
    geometry, gDoF = patch_topology(geometry)
    K_glob = np.zeros((gDoF, gDoF))
    K_glob = form_k_IGA_mp(geometry, K_glob)

    D = np.zeros(gDoF)
    b = np.zeros(gDoF)

    T_t = 10  # [°C]
    T_b = 40  # [°C]
    T_l = None#10
    T_r = None#40
    bc, D = boundary_condition_mp(geometry, D, T_t, T_b, T_l, T_r)
    bc["gDOF"] = gDoF
    D, b = solve(bc, K_glob, b, D)

    geometry = map_MP_elements(geometry, D)
    from pygeoiga.plot.nrbplotting_mpl import p_surface, p_cpoints, p_knots, create_figure
    fig, ax = create_figure("2d")
    #ax.view_init(azim=270, elev=90)
    fig_sol, ax_sol = create_figure("2d")
    geometrypatch = make_fault_model(refine=False)
    figpatch, axpatch = create_figure("2d")
    for patch_id in geometry.keys():
        ax = p_surface(geometry[patch_id].get("knots"), geometry[patch_id].get("B"), ax=ax, dim=2,
                       color=geometry[patch_id].get("color"), alpha=0.5)
        #ax = p_cpoints(geometry[patch_id].get("B"), ax=ax, dim=2, color="black", marker=".", point=True, line=False)
        ax = p_knots(geometry[patch_id].get("knots"), geometry[patch_id].get("B"), ax=ax, dim=2, point=False,
                         line=True)

        axpatch = p_surface(geometrypatch[patch_id].get("knots"), geometrypatch[patch_id].get("B"), ax=axpatch, dim=2,
                       color=geometrypatch[patch_id].get("color"), alpha=0.5)
        #axpatch = p_cpoints(geometry[patch_id].get("B"), ax=axpatch, dim=2, color="black", marker=".", point=True, line=False)
        axpatch = p_knots(geometrypatch[patch_id].get("knots"), geometrypatch[patch_id].get("B"), ax=axpatch, dim=2, point=False,
                     line=True)

        #ax_sol = p_cpoints(geometry[patch_id].get("B"), ax=ax_sol, dim=2, color=geometry[patch_id].get("color"), marker=".", point=True, line=False)
        ax_sol = p_surface(geometry[patch_id].get("knots"), geometry[patch_id].get("B"), ax=ax_sol, dim=2,
                       color="k", fill=False)
        x = geometry[patch_id].get("x_sol")
        y = geometry[patch_id].get("y_sol")
        t = geometry[patch_id].get("t_sol")
        ax_sol = p_temperature(x,y,t, vmin = np.min(D), vmax = np.max(D), levels=50, show=False, colorbar=True, ax=ax_sol,
                               point = False, fill=True)#, color = "k")

    fig.show()
    fig_sol.show()
    figpatch.show()

    fig_all, ax_all = create_figure("2d")
    p_temperature_mp(geometry=geometry, vmin=np.min(D), vmax=np.max(D), levels=50, show=False, colorbar=True,
                     ax=ax_all, point=False, fill=True, contour=False)
    plt.show()
def test_same_fault():
    from pygeoiga.nurb.cad import make_fault_model
    geometry = make_fault_model(refine=True)
    same_IGA_BEZIER(geometry,
                    10,
                    40,
                    save=True,
                    filename="fault",
                    levels=[12, 16, 20, 24, 28, 32, 36])
예제 #3
0
def test_mesh_mp_fault():
    from pygeoiga.nurb.cad import make_fault_model
    geometry = make_fault_model(refine=False)
    mesh, script, physical_tag_id = convert_geometry_mp_to_gmsh(
        geometry,
        size=50,
        save_geo=data_path + "fault_model.geo",
        save_msh=data_path + "fault_model.msh")
    print(script, physical_tag_id)
    plot_mesh(mesh)
예제 #4
0
def test_create_script_fault():
    from pygeoiga.nurb.cad import make_fault_model
    from pygeoiga.nurb.nrb_to_gmsh import convert_geometry_mp_to_gmsh
    geometry = make_fault_model(refine=False)
    mesh, script, physical_tag_id = convert_geometry_mp_to_gmsh(
        geometry,
        size=50,
        save_geo=datapath + "fault_model.geo",
        save_msh=datapath + "fault_model.msh")
    from pygeoiga.FE_solvers.run_moose import create_script
    input = datapath + "fault_model.msh"
    create_script(input,
                  topology_info=physical_tag_id,
                  top_bc=10,
                  bot_bc=40,
                  geometry=geometry)
예제 #5
0
def test_run_workflow_fault():
    from pygeoiga.nurb.cad import make_fault_model
    from pygeoiga.nurb.nrb_to_gmsh import convert_geometry_mp_to_gmsh
    geometry = make_fault_model(refine=False)
    mesh, script, physical_tag_id = convert_geometry_mp_to_gmsh(
        geometry,
        size=50,
        save_geo=datapath + "fault_model.geo",
        save_msh=datapath + "fault_model.msh")
    from pygeoiga.FE_solvers.run_fenics import convert_msh_to_xdmf, run_simulation
    input = datapath + "fault_model.msh"
    convert_msh_to_xdmf(input)
    nodal_coordinates, temperature_nodes = run_simulation(
        input,
        topology_info=physical_tag_id,
        top_bc=10,
        bot_bc=40,
        geometry=geometry)
예제 #6
0
def test_solve_fault():
    geometry = make_fault_model()
    geometry, gDoF = patch_topology(geometry)
    K_glob = np.zeros((gDoF, gDoF))
    K_glob = form_k_IGA_mp(geometry, K_glob)

    D = np.zeros(gDoF)
    b = np.zeros(gDoF)

    T_t = 10  # [°C]
    T_b = 40  # [°C]
    T_l = None
    T_r = None
    bc, D = boundary_condition_mp(geometry, D, T_t, T_b, T_l, T_r)
    bc["gDOF"] = gDoF
    D, b = solve(bc, K_glob, b, D)

    plt.spy(K_glob)
    plt.show()
    print(D)
예제 #7
0
def test_plot_solution_mp_fault():
    from pygeoiga.nurb.cad import make_fault_model
    geometry = make_fault_model(refine=True)
    geometry, gDoF = patch_topology(geometry)
    K_glob = np.zeros((gDoF, gDoF))
    K_glob = form_k_IGA_mp(geometry, K_glob)

    D = np.zeros(gDoF)
    b = np.zeros(gDoF)

    T_t = 10  # [°C]
    T_b = 40  # [°C]
    T_l = None
    T_r = None
    bc, D = boundary_condition_mp(geometry, D, T_t, T_b, T_l, T_r)
    bc["gDOF"] = gDoF
    D, b = solve(bc, K_glob, b, D)
    from pygeoiga.analysis.MultiPatch import map_MP_elements

    geometry = map_MP_elements(geometry, D)
    plot_pvista(geometry)
예제 #8
0
def test_plot_solution_fault_model_mp():
    from pygeoiga.nurb.cad import make_fault_model
    levels = [12, 16, 20, 24, 28, 32, 36]
    T_t = 10
    T_b = 40
    T_l = None
    T_r = None

    geometry = make_fault_model(refine=True)
    geometry, gDoF = patch_topology(geometry)
    geometry = bezier_extraction_mp(geometry)

    K_glob = np.zeros((gDoF, gDoF))
    K_glob = form_k_bezier_mp(geometry, K_glob)

    D = np.zeros(gDoF)
    b = np.zeros(gDoF)

    bc, D = boundary_condition_mp(geometry, D, T_t, T_b, T_l, T_r)
    bc["gDOF"] = gDoF
    D, b = solve(bc, K_glob, b, D)

    geometry = map_MP_elements(geometry, D)
    plot_mp_FEM(geometry, D, gDoF, levels=levels)