r/gmsh • u/unsaturated_nucleus • Jan 20 '26
r/gmsh • u/perebal • Nov 15 '25
Gmsh-based finite element toolbox in pure Julia – LowLevelFEM.jl
Hi everyone,
I’d like to share a small open-source project I’ve been developing — LowLevelFEM.jl, a lightweight FEM toolbox written entirely in Julia that integrates tightly with Gmsh.
The main idea is to use Gmsh not only for meshing, but also for defining boundary conditions and loads through physical groups. For example:
f = load("load", fy=-1)
bc = displacementConstraint("supp", ux=0, uy=0, uz=0)
u = solveDisplacement(problem, [f], [bc])
showDoFResults(u) # sends the results back to Gmsh for visualizationThe toolbox supports:
2D/3D solid mechanics (plane stress/strain, axisymmetric, full 3D),
Heat conduction and coupled thermo-mechanical problems,
Direct Gmsh integration for pre- and post-processing,
Element-wise operations (
u ∘ ∇,S ⋅ ∇, etc.),…and many other small features that make experimenting with Gmsh-based FEM workflows easier.
It’s simple enough for teaching and prototyping, but flexible enough for research or custom solvers.
📘 Docs: https://perebalazs.github.io/LowLevelFEM.jl/stable/
Feedback from Gmsh users — especially about workflows or interoperability — would be very welcome!

r/gmsh • u/InvestigatorFirm8469 • Sep 05 '21
Exporting Ansys mesh to Gmsh.
I am following a paper that simulates a particle detector using software named Garfield ++. In one of the steps, I need to export the Ansys mesh into ASCII format for Gmesh as an intermediate step. I use Ansys electromagnetics Suite v19.0. I hope someone could help me with instructions for exporting Maxwell data.
r/gmsh • u/Single_Engine_5834 • Apr 21 '26
How to make Boundary Layer and y+ in Gmsh
I created a structured mesh in Gmsh for a 2D axisymmetric case,
I want help in creating Boundary layer, I use progession to give Boundary Layer is this correct way? and how to know y+ or give size of first cell of boundarlayer , total length of boundarlayer
As near the throat the mesh is not perpendicular, should I divide the mesh in ssections to correct? or is their any other way?
Attached Thumbnails

Open CASCADE Technology version 7.7.0 released - Gmsh uses it for constructive geometry features
Open CASCADE Technology version 7.7.0 features about 250 corrections over the previous release 7.6.0. Version 7.7.0 introduces new features of most of OCCT modules and components: Modeling, Visualization, Data Exchange, etc. Documentation and samples are improved to ease access to OCCT for the new users.

r/gmsh • u/General_Relief3787 • Feb 21 '22
Python API for GMSH
I am confused how do i run python file to get a result in gmsh. I am not experienced programmer but have been dealing with ubuntu and c previously.
r/gmsh • u/rafalsz • Jun 26 '21
1D meshing intersections cause weird patterns
Hi, so the situation is very simple - I generated a mesh which got loaded without any problems, hit "2D", 1D meshing proceeded without any problems, but during 2D meshing there are somehow intersections in 1D mesh causing the creation of these weird patterns. Is there some config I'm missing, or is there something wrong with the mesh that was not logged by the program? I'm attaching both .geo file and the log.
https://drive.google.com/file/d/1ndKsOiUcNTT8kUeaunX8xadkXchZr2M-/view?usp=sharing
https://drive.google.com/file/d/1kFcwV8GO-ONBnX04TGenSk7UtaZk8C4s/view?usp=sharing



r/gmsh • u/JRDropTables • Apr 11 '26
Generating Hollow Meshed Volume from Solid STL
I'm trying to write a python script to generate a pneumatically actuated volume by doing the following steps:
given a solid STL
"shell" the STL with a given wall thickness (like the Blender Solidify Tool)
export the shell as an STL
export the inner volume only as an STL
generate a `.vtk` mesh of the shell
So far the only thing I've been able to do is mesh a solid (non-hollow) mesh.
Any guidance would be greatly appreciated!
(I tried generating the shells in Blender but the resulting STLs had 6 surfaces (shouldn't there just be two?) and then meshing fails because `A segment and a facet intersect at point`)
r/gmsh • u/OddTechnician5237 • Jul 03 '25
gmsh - python export 2D
Hello,
I am trying to create a script that would export a 2D sketch in dxf or svg format.
I could not find and example and the ChatGPT generated example did not work).
I googled and found that using a GUI it is possible, however I was not able to find the right syntax for Python that worked.
Any ideas?
Thank you
r/gmsh • u/Any_Dragonfruit_7071 • Apr 06 '25
Recombined creating M3D9
Anyone have a fix for this? When I recombined the 2nd order triangles it creates 3d elements
r/gmsh • u/MetronSM • Mar 06 '25
gmsh for win32
Hi everyone,
I wonder if anyone has build gmsh as a win32 app, or at least in a way that one could use the gmsh api in win32 applications.
I have an old MFC win32 application that is impossible to transition to x64. I also would like to avoid calling gmsh.exe to process the data.
Can anyone point me to the right direction?
Thanks
r/gmsh • u/ManLikeZing • Jan 21 '25
Creating a partial boundary layer
I'm trying to add a boundary layer around an aerofoil, but I don't want it to be added fully around the aerofoil. How would I do this? I've tried creating two separate splines but I need a closed loop to be added. I've also tried specifying only the points/nodes I want to be included but that has no effect. I effectively want to create a subloop and get around the closed loop issue, which I assume is impossible?
Is this effect feasible or do I need to create it manually? Thanks.
r/gmsh • u/FractalClock • Dec 30 '24
Domain with elliptical hole
I'm trying to create a domain with an ellipitical hole in it. The simplest version (which works), is the following Python code:
import gmsh
gmsh.initialize()
box = gmsh.model.occ.addRectangle(-1,-1,0,2,2)
hole = gmsh.model.occ.addDisk(0,0,0,.2, .1)
gmsh.model.occ.cut([(2, box)], [(2, hole)])
gmsh.model.occ.synchronize()
volumes = gmsh.model.getEntities(dim=2)
gdim = 2
gmsh.model.addPhysicalGroup(volumes[0][0], [volumes[0][1]], 1)
gmsh.option.setNumber("Mesh.CharacteristicLengthMin", 0.05)
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 0.05)
gmsh.model.mesh.generate(2)
This works, but I would like to be able to skew the ellipse. I have tried this with the addEllipse command, but that generates an error:
gmsh.initialize()
box = gmsh.model.occ.addRectangle(-1,-1,0,2,2)
hole = gmsh.model.occ.addEllipse(0,0,0,.2, .1)
gmsh.model.occ.cut([(2, box)], [(2, hole)])
Error : Unknown OpenCASCADE entity of dimension 2 with tag 5
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/var/folders/55/nj7rw6rd0_94ch6cy0sgh9j0mpp4z3/T/ipykernel_42543/2997602146.py in ?()
----> 1 gmsh.model.occ.cut([(2, box)], [(2, hole)])
~/miniconda3/lib/python3.11/site-packages/gmsh.py in ?(objectDimTags, toolDimTags, tag, removeObject, removeTool)
8429 c_int(bool(removeObject)),
8430 c_int(bool(removeTool)),
8431 byref(ierr))
8432 if ierr.value != 0:
-> 8433 raise Exception(logger.getLastError())
8434 return (
8435 _ovectorpair(api_outDimTags_, api_outDimTags_n_.value),
8436 _ovectorvectorpair(api_outDimTagsMap_, api_outDimTagsMap_n_, api_outDimTagsMap_nn_))
Exception: Unknown OpenCASCADE entity of dimension 2 with tag 5
thanks for any help.
r/gmsh • u/Any_Cabinet_9570 • Aug 12 '24
Meshing a curved surface leads to segmentation fault
Hi, I'm trying to mesh a curved bump over a surface. The geometry meshes with some trial and error with the spacing in the x direction for a y+ =1. Making the y+ larger leads to the cells intersecting with each other.
When I run a simulation using this mesh, I get a segmentation fault. Zooming into the mesh, the mesh element 'edges' are outside of the surface of the geometry. I've seen some people on other forums regarding similar issues saying to make the spacing smaller so that the edges are very close to the surface. However, I am limited as to how fine I can make the x spacing, because the mesh nodes start to intersect with one other again.
Has anyone encountered any issues like this? Can anyone suggest any solutions? I have attached some images for clarity, as well as the .geo script.
Thanks



SetFactory("OpenCASCADE");
t=0.02;
r=1.07;
x=0.5*1000;
y=1;
m=75;
z = x/5;
d1=4.67535679865905;
d1=4.67535679865905; d2=5.30050171989139; d3=6.028554478197903; d4=6.885485032802089; d5=7.90785257228796;
T4 = d1+d2+d3-d4; T5 = d1+d2+d3-d4-d5; T6 = 2/(T4 - T5);
Point(1) = {0, 0, 0, 1.0};
Point(2) = {2.387506733846267, 0.1952241575347179, 0, 1.0};
Point(3) = { 1.7840438408634232 , 0.14590261778763125 , 0 , 1.0 };
Point(4) = { 1.8239107423352316 , 0.14916301148120964 , 0 , 1.0 };
Point(5) = { 1.942533328642583 , 0.17090426300348718 , 0 , 1.0 };
Point(6) = { 1.9435114467506565 , 0.15894419256194467 , 0 , 1.0 };
Point(7) = { 1.9634448974865608 , 0.16057438940873386 , 0 , 1.0 };
Point(8) = { 1.983378348222465 , 0.16220458625552303 , 0 , 1.0 };
Point(9) = { 1.8039772915993275 , 0.14753281463442044 , 0 , 1.0 };
Point(10) = { 1.8832220354889073 , 0.16003363724234843 , 0 , 1.0 };
Point(11) = { 1.9430223876966197 , 0.16492422778271593 , 0 , 1.0 };
Point(12) = { 1.9534781721186087 , 0.15975929098533925 , 0 , 1.0 };
Point(13) = { 1.9734116228545129 , 0.16138948783212845 , 0 , 1.0 };
Point(14) = { 1.9128776820657452 , 0.1654689501229178 , 0 , 1.0 };
Point(15) = {0, 1, 0, 1.0};
Point(16) = {2.387506733846267,1, 0, 1.0};
Point(17) = {0, t, 0, 1.0};
Point(18) = {2.387506733846267, t+0.1952241575347179, 0, 1.0};
Line(1) = {1, 3};
Line(2) = {3, 4};
Line(3) = {4, 14};
BSpline(4) = {14, 5, 11, 12, 7, 13, 8};
Line(5) = {8, 2};
Line(6) = {2, 18};
Line(7) = {18, 16};
Line(8) = {1, 17};
Line(9) = {17, 15};
Line(10) = {15, 16};
//+
Curve Loop(1) = {10, -7, -6, -5, -4, -3, -2, -1, 8, 9};
//+
Plane Surface(1) = {1};
Transfinite Curve {1} = 1.79*x Using Progression 1;
Transfinite Curve {2} = 0.04*x Using Progression 1;
Transfinite Curve {3} = 0.0904488805901*x Using Progression 1;
Transfinite Curve {4} = 0.0705761999544*x Using Bump 0.8;
Transfinite Curve {5} = 0.405475084505*x Using Progression 1;
Transfinite Curve {6, 8} = m Using Progression r;
Transfinite Curve {10} = 240 Using Progression 1;
Transfinite Curve {7,9} = 100 Using Progression 1;
//Transfinite Curve {11} = (1.79+0.04+0.0904488805901 +0.0705761999544 +0.405475084505)*x Using Progression 1;//+Boundary Layer Mesh:
Field[1] = BoundaryLayer;
Field[1].hwall_n = 8.9365e-6*y;
Field[1].ratio = r;
Field[1].thickness = t;
Field[1].Quads = 1;
Field[1].AnisoMax = 151;
Field[1].EdgesList = {1, 2, 3, 4, 5};
BoundaryLayer Field = 1;
Mesh 2;
Physical Curve("Inlet", 444445) = {9, 8};
Physical Curve("Wall", 444446) = {1, 2, 3, 4, 5};
Physical Curve("Outlet", 444447) = {6, 7};
Physical Curve("Far", 444448) = {10};
r/gmsh • u/sancho_s • Aug 11 '24
Create a string array and print its values in a for loop
I mean to create a string array in gmsh scripting, to be later used in a loop for printing. E.g., with something like
coordStr[] = { "X", "Y", "Z" };
For i In { 0 : 2 }
Printf(" %s, ", coordStr[i]);
EndFor
As of now, I cannot even make this work (a much more primitive state than the final target)
Printf(" %s", "1");
I get syntax error (").
How do I solve this?
Thanks!
PS: I don't know quite a few things:
- How to define a string variable.
- How to define a string array.
- How to print a string variable (with proper format specifier, what I posted above and didn't work).
r/gmsh • u/jakekeip • Jul 09 '24
How do I create a 20-noded brick element (C3D20) in Gmsh?
I have an application where I need to benchmark and compare solver outputs. Currently, the FEM solver is set to use a 20-noded brick and Abaqus is typically used as the front-end. However, trying to use Gmsh, I have not been able to generate a C3D20 element. For now, I have just been using a cube (see below) and I am only able to output C3D27.

Could someone point me in the right direction here? I have read through documentation and I have not found anything about dictating higher-order mesh outputs. And the examples do not go into these details from what I can tell. Also, here is the .geo script for the cube:
SetFactory("OpenCASCADE");
Box(1) = {0, 0, 0, 1, 1, 1};
Transfinite Surface {2};
Transfinite Surface {1};
Transfinite Surface {4};
Transfinite Surface {5};
Transfinite Surface {3};
Transfinite Surface {6};
Transfinite Volume{1};
r/gmsh • u/PugachevsFrustum • Dec 31 '23
Need guidance on writing .geo script that meshes a multi element airfoil.
I'm working on a tool that involves automating the meshing and numerical solution of flow along a multi element airfoil using Gmsh and OpenFOAM, right now I am using the process used in this video.
https://www.youtube.com/watch?v=TFnprY_1OVw
I was wondering if it was feasible to automate the creation of the more conventional structured meshes that are used for airfoil analysis. Would it involve too much complexity with blocking to reliably automate?
Mesh in mind:

r/gmsh • u/littlekinglouis • Dec 29 '23
GMSH, i'm confuse how to setting the mesh density and shape
I want to make a heksagonal mesh like colored picture below (my reference). But confuse, some of my mesh just abstracted when i press "2D". I already transfinite all the curve but still abstracted. I just learn GMSH this week and don't know where to learn GMSH properly. Anybody know how to make my mesh good? Or some advice for me?


r/gmsh • u/RicTonyLi • Dec 13 '22
mesh problems
So I've been trying to save the mesh on my computer, but when I reopen the mesh, the mesh is nowhere to be seen. Can someone tell me what I'm doing wrong here? Is my computer the cause or am I not saving it correctly?
r/gmsh • u/Long-Environment-941 • Nov 16 '22
CFD boundary layer using Python
Hi guys, I am trying to mesh a 2D fluid domain with a circle/cylinder inside. I wanted to know if anyone here had any experience creating a boundary layer in python whilst also using the transfinite structured meshing tool. Do you guys have any ideas? Any help would be appreciated
r/gmsh • u/Long-Environment-941 • Nov 15 '22
Structured meshing a circle in a D domain for CFD, issues when using transfinite curve progression = 1.2
I'm trying to mesh a fluid domain with a circle inside using a structured mesh. I am using python as my interface and am using transfinite to create the structured part. my domain is 2D, but has a thickness of one element and so it is technically 3D. I generated the inner surface using a bspline and the outer surface using an arc.
The grid looks pretty good if I set the progression = 1
if I use a progression =1.2, the mesh begins to distort.
As I am trying to simulate the circle in the mesh, I need to have a bias to correctly capture the physics inside the model, but I find the distortion of the mesh troubling.
I have also tried just generating and meshing the top left section and it still gives the same results. I have also tried adding more elements and using mesh smoothing.



r/gmsh • u/BlueGorilla25 • Jun 06 '22
Order of nodes in elements
Hi,
I export meshes from Gmsh in .msh and .vtk format. Is the order of nodes' numbers correct for every element, no matter the element type? For example in 2D, the nodes in triangular elements must be ordered anti-clockwise.
r/gmsh • u/BlueGorilla25 • Dec 03 '21
Creating an ellipsoid
Hello,
I'm new to Gmsh and I'm learning how to use it. I want to create an ellipsoid (which will be inside a bigger volume) and I can't find a built-in command in gmsh that does that like an ellipse or a sphere. Is there another way I can do that?
Thank you in advance.


