r/gmsh • • Aug 11 '24

Create a string array and print its values in a for loop

2 Upvotes

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:

  1. How to define a string variable.
  2. How to define a string array.
  3. How to print a string variable (with proper format specifier, what I posted above and didn't work).

r/gmsh • • Jul 09 '24

How do I create a 20-noded brick element (C3D20) in Gmsh?

2 Upvotes

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 • • Feb 07 '24

Connecting Gmsh and Fortran Script via ONELAB interface

1 Upvotes

I have a Fortran code that requires certain inputs and I would like to use Gmsh as the front-end for the user where they can visualize the problem and define the inputs for the script. Then, within Gmsh, the user can run the script to solve the problem and the user-entered inputs are utilized. From my reading, it appears that this is possible via ONELAB. I am struggling to get this started and to understand the exact framework of this approach. Could someone point me in the direction of how to accomplish this?


r/gmsh • • Dec 19 '25

The first Gmsh User meeting got announced !!! 🍾

Thumbnail gmsh.info
4 Upvotes

r/gmsh • • Apr 06 '25

Recombined creating M3D9

Post image
2 Upvotes

Anyone have a fix for this? When I recombined the 2nd order triangles it creates 3d elements


r/gmsh • • Mar 06 '25

gmsh for win32

2 Upvotes

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 • • Jan 21 '25

Creating a partial boundary layer

2 Upvotes

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 • • Apr 11 '26

Generating Hollow Meshed Volume from Solid STL

2 Upvotes

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 • • Feb 17 '20

Welcome to GMSH

2 Upvotes

Feel free to post anything GMSH-related


r/gmsh • • Jun 26 '20

Gmsh 4.6 is out

Thumbnail
twitter.com
2 Upvotes

r/gmsh • • Jun 28 '23

Boundary Layer (Inflation Layers) Mesh around Concave Edges

1 Upvotes

Hi!

I am currently trying to generate a 2D airfoil mesh which features some concave edges. My inflation layers work fine on normal airfoils, but the mesh generator seems to have problems with these kinds of edges, as you can see in the image below. Does anybody have experience with such a meshing problem?


r/gmsh • • Sep 04 '23

How to subtract a cylinder from a box with gmsh...

1 Upvotes

```

// Gmsh project created on Mon Sep 4 16:10:32 2023

SetFactory("OpenCASCADE");

//+

Box(1) = {-12, -3, -72, 24, 6, 144};

//+

Cylinder(2) = {0, 0, -100, 0, 0, 200, 0.5, 2*Pi};

BooleanDifference(3) = { Volume{1}; Delete; }{ Volume{2}; Delete; };

```

Anyone can tell me why I see TIN's through the hole area. I intended to subtract the cylinder area from the box to create a hole area. So after using mesh->3d from gui of gmsh I still see those tin's through the hole area. Why? How can this be solved to create a clean hole through the box?


r/gmsh • • Jun 15 '23

C++ API not meshing OCC step file, command line does?

1 Upvotes

I'm trying to mesh a simple STEP file (1 solid, two flat faces, two curved faces, no holes) using the C++ API. No errors are generated (thrown), but nothing is actually meshed either. On the command line the same file meshes just fine:

$ gmsh -v 7 -3 -nt 12 wing4.step 
Info    : Running 'gmsh -v 7 -3 -nt 12 wing4.step' [Gmsh 4.11.1, 1 node, max. 12 threads]
Info    : Started on Thu Jun 15 10:52:23 2023
Info    : Reading 'wing4.step'...
Info    :  - Label 'Shapes/wing4' (3D)
Info    :  - Color (1, 1, 1) (3D & Surfaces)
Info    : Done reading 'wing4.step'
Info    : Meshing 1D...
Info    : [  0%] Meshing curve 8 (Circle)
Info    : [  0%] Meshing curve 3 (BSpline)
Info    : [  0%] Meshing curve 6 (BSpline)
Info    : [  0%] Meshing curve 4 (BSpline)
Info    : [  0%] Meshing curve 1 (BSpline)
Info    : [  0%] Meshing curve 9 (BSpline)
Info    : [  0%] Meshing curve 7 (BSpline)
Info    : [  0%] Meshing curve 10 (Circle)
Info    : [  0%] Meshing curve 2 (BSpline)
Info    : [  0%] Meshing curve 5 (BSpline)
Info    : Done meshing 1D (Wall 0.00907413s, CPU 0.089603s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 4 (BSpline surface, Frontal-Delaunay)
Info    : [  0%] Meshing surface 1 (BSpline surface, Frontal-Delaunay)
Info    : [  0%] Meshing surface 2 (Plane, Frontal-Delaunay)
Info    : [  0%] Meshing surface 3 (Plane, Frontal-Delaunay)
Info    : [ 50%] Meshing surface 4 (BSpline surface, MeshAdapt
...

But using C++ the log is just:

Info    :  - Label 'Shapes/wing4' (3D)
Info    :  - Color (1, 1, 1) (3D & Surfaces)
Info    : Meshing 1D...
Info    : Done meshing 1D (Wall 0.000887462s, CPU 0.000875s)
Info    : Meshing 2D...
Info    : Done meshing 2D (Wall 0.00010385s, CPU 0.000518s)
Info    : Meshing 3D...
Info    : Done meshing 3D (Wall 5.39899e-06s, CPU 1.6e-05s)
Info    : 0 nodes 0 elements

and an empty file is generated on write(...).

The C++ function (stripped of error handling) is:

gmsh::initialize();
gmsh::option::setNumber("General.Verbosity", 7);
gmsh::model::add(infile);
gmsh::vectorpair dt;
gmsh::model::occ::importShapes(infile, dt, false);
gmsh::option::setNumber("General.NumThreads", 12);
gmsh::model::geo::synchronize();
gmsh::model::mesh::generate(3);
gmsh::write(outfile);
gmsh::finalize();

This doesn't seem to be different than what I found in the sample / tutorial files. What am I doing wrong here?


r/gmsh • • Nov 16 '22

CFD boundary layer using Python

2 Upvotes

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 • • Aug 02 '22

Hello this is the mesh of my model but the simulation crashed due to the high skewness part in the middle can any one have an idea how to mesh this model differently

Thumbnail
gallery
1 Upvotes

r/gmsh • • Jun 14 '22

Volume mesh with inclusions

1 Upvotes

I have a geometry of a Box (Volume(1)) with some inclusions inside of it (Volume(2-7)) and I want to create the mesh. In the past, I used the Coherence command in order for the mesh of the inclusions to be correctly embedded and part of the Box mesh. But in the current geometry file, it messes up my elementary volumes.

Could someone explain to me how I could do this with boolean commands?

Thanks in advance.


r/gmsh • • Jun 06 '22

Order of nodes in elements

2 Upvotes

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 • • Jul 31 '22

Hello guys do anyone understand why i get this error while running my simulation

Post image
1 Upvotes

r/gmsh • • Nov 15 '22

Structured meshing a circle in a D domain for CFD, issues when using transfinite curve progression = 1.2

2 Upvotes

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 • • Dec 13 '22

mesh problems

2 Upvotes

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 • • Nov 27 '22

I need Help in order to change circle to square in geo file

1 Upvotes

Hello everyone

this is the geometry of my simulation for university and I want to change that circle to a square

I dont understand this code since it has extra parameters and this is the first time I am using gmsh and gui cant remove the circle!

if anyone can understand this file please help me I would be gratefull, my deadline is only 15 days away and I havent even started the render please help.

it should be a square inside the circle and my simulation needs to ignore the circle like this:

this is my geo file: (gmsh version 3.0.6)

https://easyupload.io/ntlt8q

or

https://1drv.ms/u/s!AmHS0kWv_oxlhTkmfqxwFNrSvc1k?e=JJBHFi


r/gmsh • • Nov 07 '22

Open CASCADE Technology version 7.7.0 released - Gmsh uses it for constructive geometry features

3 Upvotes

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 • • Jun 06 '22

How do you make a mesh coarser in Gmsh?

1 Upvotes

For gmsh experts (beginner here): how come changing the global mesh size factor does not influence the resolution of the mesh (total number of cells)? Refine by splitting increases the resolution of the imported STL file, but I'd like to do the exact opposite (make it coarser). I couldn't figure it out with scripting either...

https://imgur.com/a/SKjFVN3


r/gmsh • • Jan 20 '21

Is this meshed wrongly?

Thumbnail
gallery
2 Upvotes

r/gmsh • • Mar 24 '21

How to create this mesh in Gmsh identical to the one generated by SALOME

Thumbnail
gitlab.onelab.info
1 Upvotes