Hello all,
I am a begineer to Julia!
I want to create three .vtk files. To do that, first I want to create three .msh files. The three .msh files should be generated under a for
loop. To do so, I am running this Julia code in Jupyter Notebook:
xh = XLSX.readdata("LHS_sampling.xlsx", "Sheet1!A1:C100")
xh_c1 = xh[:,1]
xh_c2 = xh[:,2]
xh_c3 = xh[:,3]
const L = 8.0
const LL = 0.475.*L
const LR = 0.525.*L
const ls = 0.03
const hfc = ls/100 #Mesh size parameter
const hf = ls/2.1 #Mesh size parameter
const h = 100*hf #Mesh size parameter
const H = 4.0
for i in 1:3
using Gmsh: gmsh
#const H = 2.0
#const CH = 0.4 #Crack height
CH = xh_c3[i] #Crack height
#const CW = 0.2 #Crack Width
CW = xh_c2[i] #Crack Width
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
#gmsh.model.geo.addPoint((L/10)+(CW/2), 0.0 , 0.0, hf ,1)
gmsh.model.geo.addPoint((xh_c1[i])+(xh_c2[i]/2), 0.0 , 0.0, hf ,1)
gmsh.model.geo.addPoint(L, 0.0, 0.0, h, 2)
gmsh.model.geo.addPoint(L, H, 0.0, h, 3)
gmsh.model.geo.addPoint(LR , H, 0.0, hf, 4)
gmsh.model.geo.addPoint(LL , H, 0.0, hf, 5)
gmsh.model.geo.addPoint(0.0, H, 0.0, h, 6)
gmsh.model.geo.addPoint(0.0, 0.0, 0.0, h, 7)
#gmsh.model.geo.addPoint((L/10) -(CW/2), 0.0 , 0.0, hf ,8)
gmsh.model.geo.addPoint((xh_c1[i])-(xh_c2[i]/2), 0.0 , 0.0, hf ,8)
#gmsh.model.geo.addPoint((L/10), CH , 0.0, hfc , 9)
gmsh.model.geo.addPoint(xh_c1[i], CH , 0.0, hfc , 9)
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(2, 3, 2)
gmsh.model.geo.addLine(3, 4, 3)
gmsh.model.geo.addLine(4, 5, 4)
gmsh.model.geo.addLine(5, 6, 5)
gmsh.model.geo.addLine(6, 7, 6)
gmsh.model.geo.addLine(7, 8, 7)
gmsh.model.geo.addLine(8, 9, 8)
gmsh.model.geo.addLine(9, 1, 9)
gmsh.model.geo.addCurveLoop([1,2,3,4,5,6,7,8,9],1)
gmsh.model.geo.addPlaneSurface([1], 1)
gmsh.model.addPhysicalGroup(2, [1],1)
gmsh.model.addPhysicalGroup(1, [4],1)
gmsh.model.addPhysicalGroup(0, [7],2)
gmsh.model.addPhysicalGroup(0, [2],3)
gmsh.model.setPhysicalName(2, 1, "Domain")
gmsh.model.setPhysicalName(1, 1, "LoadLine")
gmsh.model.setPhysicalName(0, 2, "LeftSupport")
gmsh.model.setPhysicalName(0, 3, "RightSupport")
gmsh.model.mesh.field.add("Box", 10)
gmsh.model.mesh.field.setNumber(10, "VIn", hf)
gmsh.model.mesh.field.setNumber(10, "VOut", h)
#gmsh.model.mesh.field.setNumber(10, "XMin", (L/8)-CW)
gmsh.model.mesh.field.setNumber(10, "XMin", xh_c1[i]-xh_c2[i])
#gmsh.model.mesh.field.setNumber(10, "XMax", (L/8)+CW)
gmsh.model.mesh.field.setNumber(10, "XMax", xh_c1[i]+xh_c2[i])
gmsh.model.mesh.field.setNumber(10, "YMin", 0)
gmsh.model.mesh.field.setNumber(10, "YMax", H)
gmsh.model.mesh.field.setAsBackgroundMesh(10)
gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(2)
gmsh.write("BeamWithNotchSymThreePtBending$i.msh")
gmsh.finalize()
end
I am getting this error:
Warning : Gmsh has aleady been initialized
Error : GEO point with tag 1 already exists
GEO point with tag 1 already exists
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] addPoint(x::Float64, y::Float64, z::Float64, meshSize::Float64, tag::Int64)
@ Gmsh.gmsh.model.geo C:\Users\Anirban\.julia\artifacts\f93bed7ed0bd321ab0b0ae233750c27274ad54b2\lib\gmsh.jl:3693
[3] top-level scope
@ In[60]:21
[4] eval
@ .\boot.jl:373 [inlined]
[5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1196
model = GmshDiscreteModel("BeamWithNotchSymThreePtBending.msh")
writevtk(model ,"BeamWithNotchSymThreePtBending")