Ferrite-FEM / FerriteGmsh.jl

MIT License
14 stars 7 forks source link

function barriers #40

Open KnutAM opened 2 weeks ago

KnutAM commented 2 weeks ago

Got inspired when seeing #39, after that is fixed, these were the main sources of time spent in the translation.

using Gmsh: Gmsh, gmsh
using FerriteGmsh
using Downloads: download

function get_msh()
    logo_mesh = "logo.geo"
    asset_url = "https://raw.githubusercontent.com/Ferrite-FEM/Ferrite.jl/gh-pages/assets/"
    isfile(logo_mesh) || download(string(asset_url, logo_mesh), logo_mesh)
    Gmsh.initialize()
    gmsh.open("logo.geo")
    gmsh.option.setNumber("Mesh.MeshSizeMax", 0.01)
    gmsh.model.mesh.generate(2)
    gmsh.write("logo.msh")
    Gmsh.finalize()
end

function load_msh()
    return togrid("logo.msh")
end

@time load_msh() goes from 0.250281 seconds (264.77 k allocations: 17.653 MiB) to 0.190106 seconds (36.86 k allocations: 10.099 MiB) without #39 (with #39, the relative change is more significant and almost all time is spent in gmsh.open).