Commit 1f75bfa4 by Christophe Geuzaine

first pass of julia api done

parent 8dcd4241
Pipeline #1623 passed with stage
in 17 minutes 8 seconds
......@@ -254,8 +254,8 @@ def ovectorint(name, value=None, python_value=None, julia_value=None):
a.python_arg = "byref(" + api_name + "), byref(" + api_name_n + ")"
a.python_return = "_ovectorint(" + api_name + ", " + api_name_n + ".value)"
a.julia_ctype = "Ptr{Ptr{Cint}}, Ptr{Csize_t}"
a.julia_pre = (api_name + "= Vector{Ptr{Cint}}(1)\n " +
api_name_n + "= Vector{Csize_t}(1)")
a.julia_pre = (api_name + " = Vector{Ptr{Cint}}(1)\n " +
api_name_n + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n
a.julia_post = (name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_n + "[1], true)")
......@@ -278,8 +278,8 @@ def ovectordouble(name, value=None, python_value=None, julia_value=None):
a.python_arg = "byref(" + api_name + "), byref(" + api_name_n + ")"
a.python_return = "_ovectordouble(" + api_name + ", " + api_name_n + ".value)"
a.julia_ctype = "Ptr{Ptr{Cdouble}}, Ptr{Csize_t}"
a.julia_pre = (api_name + "= Vector{Ptr{Cdouble}}(1)\n " +
api_name_n + "= Vector{Csize_t}(1)")
a.julia_pre = (api_name + " = Vector{Ptr{Cdouble}}(1)\n " +
api_name_n + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n
a.julia_post = (name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_n + "[1], true)")
......@@ -306,6 +306,13 @@ def ovectorstring(name, value=None, python_value=None, julia_value=None):
a.python_arg = "byref(" + api_name + "), byref(" + api_name_n + ")"
a.python_return = "_ovectorstring(" + api_name + ", " + api_name_n + ".value)"
a.julia_ctype = "Ptr{Ptr{Cchar}}, Ptr{Csize_t}"
a.julia_pre = (api_name + " = Vector{Ptr{Cstring}}(1)\n " +
api_name_n + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n
a.julia_post = ("tmp_" + api_name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_n + "[1], true)\n " +
name + " = [unsafe_string(tmp_" + api_name + "[i]) for i in 1:length(tmp_" +
api_name + ") ]")
return a
def ovectorpair(name, value=None, python_value=None, julia_value=None):
......@@ -328,8 +335,8 @@ def ovectorpair(name, value=None, python_value=None, julia_value=None):
a.python_arg = "byref(" + api_name + "), byref(" + api_name_n + ")"
a.python_return = "_ovectorpair(" + api_name + ", " + api_name_n + ".value)"
a.julia_ctype = "Ptr{Ptr{Cint}}, Ptr{Csize_t}"
a.julia_pre = (api_name + "= Vector{Ptr{Cint}}(1)\n " +
api_name_n + "= Vector{Csize_t}(1)")
a.julia_pre = (api_name + " = Vector{Ptr{Cint}}(1)\n " +
api_name_n + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n
a.julia_post = ("tmp_" + api_name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_n + "[1], true)\n " +
......@@ -362,13 +369,13 @@ def ovectorvectorint(name, value=None, python_value=None, julia_value=None):
a.python_return = ("_ovectorvectorint(" + api_name + ", " + api_name_n + ", " +
api_name_nn + ")")
a.julia_ctype = "Ptr{Ptr{Ptr{Cint}}}, Ptr{Ptr{Csize_t}}, Ptr{Csize_t}"
a.julia_pre = (api_name + "= Vector{Ptr{Ptr{Cint}}}(1)\n " +
api_name_n + "= Vector{Ptr{Csize_t}}(1)\n " +
api_name_nn + "= Vector{Csize_t}(1)")
a.julia_pre = (api_name + " = Vector{Ptr{Ptr{Cint}}}(1)\n " +
api_name_n + " = Vector{Ptr{Csize_t}}(1)\n " +
api_name_nn + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n + ", " + api_name_nn
a.julia_post = ("tmp_" + api_name + "= unsafe_wrap(Array, " + api_name + "[1], " +
a.julia_post = ("tmp_" + api_name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_nn + "[1], true)\n " +
"tmp_" + api_name_n + "= unsafe_wrap(Array, " + api_name_n + "[1], " +
"tmp_" + api_name_n + " = unsafe_wrap(Array, " + api_name_n + "[1], " +
api_name_nn + "[1], true)\n " +
name + " = [ unsafe_wrap(Array, tmp_" + api_name + "[i], " +
"tmp_" + api_name_n + "[i], true) for i in 1:" +
......@@ -401,6 +408,17 @@ def ovectorvectordouble(name, value=None, python_value=None, julia_value=None):
a.python_return = ("_ovectorvectordouble(" + api_name + ", " + api_name_n + ", " +
api_name_nn + ")")
a.julia_ctype = "Ptr{Ptr{Ptr{Cdouble}}}, Ptr{Ptr{Csize_t}}, Ptr{Csize_t}"
a.julia_pre = (api_name + " = Vector{Ptr{Ptr{Cdouble}}}(1)\n " +
api_name_n + " = Vector{Ptr{Csize_t}}(1)\n " +
api_name_nn + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n + ", " + api_name_nn
a.julia_post = ("tmp_" + api_name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_nn + "[1], true)\n " +
"tmp_" + api_name_n + " = unsafe_wrap(Array, " + api_name_n + "[1], " +
api_name_nn + "[1], true)\n " +
name + " = [ unsafe_wrap(Array, tmp_" + api_name + "[i], " +
"tmp_" + api_name_n + "[i], true) for i in 1:" +
api_name_nn + "[1] ]")
return a
def ovectorvectorpair(name, value=None, python_value=None, julia_value=None):
......@@ -413,7 +431,7 @@ def ovectorvectorpair(name, value=None, python_value=None, julia_value=None):
a.c_arg = api_name
a.c_post = (" vectorvectorpair2intptrptr(" + api_name + ", " + name +
", " + name + "_n, " + name + "_nn);\n")
a.c = "int *** " + name + ", size_t ** " + name + "_n, size_t *" + name + "_nn"
a.c = "int *** " + name + ", size_t ** " + name + "_n, size_t *" + name + "_nn"
a.cwrap_pre = "int **" + api_name + "; size_t *" + api_name_n + ", " + api_name_nn + ";\n"
a.cwrap_arg = "&" + api_name + ", " + "&" + api_name_n + ", " + "&" + api_name_nn
a.cwrap_post = (name + ".resize(" + api_name_nn + "); " +
......@@ -431,6 +449,20 @@ def ovectorvectorpair(name, value=None, python_value=None, julia_value=None):
a.python_return = ("_ovectorvectorpair(" + api_name + ", " + api_name_n + ", " +
api_name_nn + ")")
a.julia_ctype = "Ptr{Ptr{Ptr{Cint}}}, Ptr{Ptr{Csize_t}}, Ptr{Csize_t}"
a.julia_pre = (api_name + " = Vector{Ptr{Ptr{Cint}}}(1)\n " +
api_name_n + " = Vector{Ptr{Csize_t}}(1)\n " +
api_name_nn + " = Vector{Csize_t}(1)")
a.julia_arg = api_name + ", " + api_name_n + ", " + api_name_nn
a.julia_post = ("tmp_" + api_name + " = unsafe_wrap(Array, " + api_name + "[1], " +
api_name_nn + "[1], true)\n " +
"tmp_" + api_name_n + " = unsafe_wrap(Array, " + api_name_n + "[1], " +
api_name_nn + "[1], true)\n " +
name + " = []\n " +
"for i in 1:" + api_name_nn + "[1]\n " +
" tmp = unsafe_wrap(Array, tmp_" + api_name + "[i], tmp_" +
api_name_n + "[i], true)\n " +
" push!(" + name + ", [(tmp[i], tmp[i+1]) for i in 1:2:length(tmp)])\n " +
"end")
return a
def argcargv():
......
# This file reimplements gmsh/tutorial/t16.geo in Julia.
import gmsh
model = gmsh.model
factory = model.occ
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
model.add("t16")
factory.addBox(0,0,0, 1,1,1, 1)
factory.addBox(0,0,0, 0.5,0.5,0.5, 2)
factory.cut([(3,1)], [(3,2)], 3)
x = 0; y = 0.75; z = 0; r = 0.09
holes = []
for t in 1:5
x += 0.166
z += 0.166
factory.addSphere(x,y,z,r, 3 + t)
t = (3, 3 + t)
push!(holes, t)
end
ov = factory.fragment([(3,3)], holes)
factory.synchronize()
lcar1 = .1
lcar2 = .0005
lcar3 = .055
ov = model.getEntities(0);
model.mesh.setSize(ov, lcar1);
ov = model.getBoundary(holes, false, false, true);
model.mesh.setSize(ov, lcar3);
eps = 1e-3
ov = model.getEntitiesInBoundingBox(0.5-eps, 0.5-eps, 0.5-eps,
0.5+eps, 0.5+eps, 0.5+eps, 0)
model.mesh.setSize(ov, lcar2)
model.mesh.generate(3)
gmsh.write("t16.msh")
gmsh.finalize()
......@@ -64,7 +64,7 @@ shells = []
# When the tag is not specified, a new one is automatically provided
sl = factory.addSurfaceLoop([35,31,29,37,33,23,39,25,27])
append!(shells, sl)
push!(shells, sl)
function cheeseHole(x, y, z, r, lc, shells)
p1 = factory.addPoint(x, y, z, lc)
......@@ -108,7 +108,7 @@ function cheeseHole(x, y, z, r, lc, shells)
sl = factory.addSurfaceLoop([s1, s2, s3, s4, s5, s6, s7, s8])
v = factory.addVolume([sl])
append!(shells, sl)
push!(shells, sl)
return v
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment