layer_list = [] primitives_list = [] problem_list = [] bump_analytic_list = [] ################################################################################ # #Meshes: #-------------------- for M in range(N_mesh): if MESH_SPLITTING: #Generates first mesh from bump0.geo and the other by splitting of the first mesh if M == 0: os.system('gmsh -2 inputs/bump{}.geo -o inputs/bump{}.msh'.format(First_mesh, First_mesh)) TG, vertex_labels, boundary_labels = fk.read_msh('inputs/bump{}.msh'.format(First_mesh)) triangular_mesh = fk.TriangularMesh(TG, vertex_labels, boundary_labels) triangular_mesh_list.append(triangular_mesh) os.system('rm inputs/bump{}.msh'.format(First_mesh)) else: triangular_mesh = triangular_mesh.refine_by_splitting() triangular_mesh_list.append(triangular_mesh) else: #Generates all meshes from bump#.geo files os.system('gmsh -2 inputs/bump{}.geo -o inputs/bump{}.msh'.format(M, M)) TG, vertex_labels, boundary_labels = fk.read_msh('inputs/bump{}.msh'.format(M)) triangular_mesh_list.append(fk.TriangularMesh(TG, vertex_labels, boundary_labels)) os.system('rm inputs/bump{}.msh'.format(M)) NT.append(triangular_mesh_list[M].NT) if PLOT_MESH: fk_plt.plot_mesh(triangular_mesh_list[M])
file_in = 'inputs/tiny_square.mesh' file_out = 'inputs/tiny_square.msh' fk.convert_to_msh(file_in, file_out) ################################################################################ # #.. note:: # Mesh conversion is compatible with MEDIT .mesh and GMSH .msh file_in format. # ################################################################################ # # Check file conversion succeded #------------------------------- TG, vertex_labels, boundary_labels = fk.read_msh(file_out) x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) plt.triplot(x, y, trivtx) plt.show() ################################################################################ # #Remove file_out which was only built for example purpose: # os.system('rm {}'.format(file_out))
triang.set_mask(isbad) ax.plot_trisurf(triang2, scale*z, lw=0.01, edgecolor="w", color='grey', alpha=0.2) csetb = ax.tricontour(triang2, scale*z, 1, zdir='x', offset=4, color='grey') csetb = ax.tricontour(triang2, scale*z, 1, zdir='y', offset=0, color='grey') ax.plot_trisurf(triang, scale*elevation, lw=0.0, edgecolor="w", cmap=cm.jet,alpha=0.9) cset = ax.tricontour(triang, scale*elevation, 1, zdir='x', offset=4, cmap=cm.coolwarm) cset = ax.tricontour(triang, scale*elevation, 1, zdir='y', offset=0, cmap=cm.coolwarm) ax.set_title("Free surface at time={}".format(time)) ################################################################################ # # Mesh: #-------------------- os.system('gmsh -2 ../simulations/inputs/thacker2d_huge.geo -o inputs/thacker2d.msh') TG, vertex_labels, boundary_labels = fk.read_msh('inputs/thacker2d.msh') os.system('rm inputs/thacker2d.msh') x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) x *= 0.4 y *= 0.4 triangular_mesh = fk.TriangularMesh(TG, vertex_labels, boundary_labels) ################################################################################ # # Define analytic solution: #---------------------------
################################################################################ # #In this example we compare all laws for a wind intensity of 20 m/s. Fluid #dynamic viscosity is set to 1Pa.s and free surface to 2m. # ################################################################################ # # Mesh: #-------------------- # dir_path = os.path.abspath(os.path.dirname(sys.argv[0])) TG, vertex_labels, boundary_labels = fk.read_msh(dir_path + '/inputs/simple_canal_2.msh') x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) x *= 10 y *= 10 triangular_mesh = fk.TriangularMesh(TG, vertex_labels, boundary_labels) fk_plt.plot_mesh(triangular_mesh) ################################################################################ # # Cases set-up: #--------------------
# Time loop: #-------------------- simutime = fk.SimuTime(final_time=4.5, time_iteration_max=10000, second_order=SECOND_ORDER) when = [0., 2.25, 4.5] create_figure_scheduler = fk.schedules(times=when) ################################################################################ # # Mesh: #-------------------- dir_path = os.path.abspath(os.path.dirname(sys.argv[0])) TG, vertex_labels, boundary_labels = fk.read_msh(dir_path + '/inputs/thacker2d.msh') x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) x *= 0.4 y *= 0.4 triangular_mesh = fk.TriangularMesh(TG, vertex_labels, boundary_labels) if not args.nographics: fk_plt.plot_mesh(triangular_mesh) ################################################################################ # # Analytic solution:
import matplotlib.pyplot as plt import numpy as np import freshkiss3d as fk import freshkiss3d.extra.plots as fk_plt ################################################################################ # # Read a Mesh #-------------------- # #There is two ways to visualize a mesh from a file. You can either build a #TriangularMesh or directly use the read_msh function. # TG, vertex_labels, boundary_labels = fk.read_msh('inputs/tiny.msh') ################################################################################ # #.. warning:: # The read_msh function is compatible with ``.msh``, ``.msh`` (GMSH) and ``.mesh`` # (MEDIT) formats ONLY. Note that the ``.msh`` used in freshkiss3d isn't the # same as gmsh ``.msh`` format. # ################################################################################ # # Construct a TriangularMesh #------------------------------ #
# # Time loop: #-------------------- FINAL_TIME = 20. simutime = fk.SimuTime(final_time=FINAL_TIME, time_iteration_max=20000, second_order=True) create_figure_scheduler = fk.schedules(times=[0., 4., 6., 8.]) ################################################################################ # # Mesh: #-------------------- dir_path = os.path.abspath(os.path.dirname(sys.argv[0])) TG, vertex_labels, boundary_labels = fk.read_msh(dir_path + '/inputs/square2.mesh') x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) x *= 10. y *= 10. triangular_mesh = fk.TriangularMesh(TG, vertex_labels, boundary_labels) if not args.nographics: fk_plt.plot_mesh(triangular_mesh) ################################################################################ # # Layers:
triangular_mesh_list = [] NT = [] layer_list = [] primitives_list = [] problem_list = [] thacker3d_analytic_list = [] CPUTime_list = [] ################################################################################ # #Meshes: #-------------------- os.system('gmsh -2 inputs/thacker2d{}.geo -o inputs/thacker2d{}.msh'.format( First_mesh, First_mesh)) TG, vertex_labels, boundary_labels = fk.read_msh( 'inputs/thacker2d{}.msh'.format(First_mesh)) os.system('rm inputs/thacker2d{}.msh'.format(First_mesh)) x = np.asarray(TG.x) y = np.asarray(TG.y) trivtx = np.asarray(TG.trivtx) x *= 0.12 y *= 0.12 x -= 0.6 y -= 0.6 triangular_mesh_list.append( fk.TriangularMesh(TG, vertex_labels, boundary_labels)) NT.append(triangular_mesh_list[0].NT) if PLOT_MESH: fk_plt.plot_mesh(triangular_mesh_list[0]) for M in range(1, N_mesh): if MESH_SPLITTING: