When I want to load the .msh file which have been build by the gmsh, it will have many issues, like the file have been occupied.
When I want to build a natural 2D mesh byu Gmsh2D , the fipy can't build it, but for a rectangle data, it could do. But we want to simulate something in a river , it almost not the regular shape. Hope you can help us to solve this problem, Thanks...
# Define the characteristic length
lc = 0.2 # Adjust this value as needed for your mesh
data_points = [
(1, 2),
(1, 3),
(2, 2.5),
(2, 3.5),
(3, 1.5),
(3, 2.5)
]
point_str = ""
line_str = ""
for i, point in enumerate(data_points):
# Include lc in each point definition
point_str += "Point(%d) = {%f, %f, 0, %f};\n" % (i+1, point[0], point[1], lc)
if i > 0:
line_str += "Line(%d) = {%d, %d};\n" % (i, i, i+1)
# Closing the loop
line_str += "Line(%d) = {%d, 1};\n" % (len(data_points), len(data_points))
# Creating a loop and a surface
loop_str = "Line Loop(%d) = {%s};\n" % (len(data_points)+1, ", ".join([str(i) for i in range(1, len(data_points)+1)]))
surface_str = "Plane Surface(%d) = {%d};\n" % (len(data_points)+2, len(data_points)+1)
# Complete Gmsh script
gmsh_script = point_str + line_str + loop_str + surface_str
# Creating mesh in FiPy
from fipy import Gmsh2D
mesh = Gmsh2D(gmsh_script)
# Visualization
from fipy import Viewer
viewer = Viewer(mesh)
viewer.plot()
When I want to load the .msh file which have been build by the gmsh, it will have many issues, like the file have been occupied. When I want to build a natural 2D mesh byu Gmsh2D , the fipy can't build it, but for a rectangle data, it could do. But we want to simulate something in a river , it almost not the regular shape. Hope you can help us to solve this problem, Thanks...