Thank you very much for these very useful ideas!
Thanks Christophe, I guess this is true from the Gmsh engine perspective, but suppose a naïve user creates two overlapping boxes in the OpenCASCADE kernel and forgets to do a BooleanDifference, the user will get a non-conformal mesh. Is there any known way to check that? We noticed that most if not all beginners make that mistake, which typically leads to unphysical results, and it becomes especially bad when people build complex geometries.
I would like to know if there is any computationally efficient way to automatically check if a mesh produced by Gmsh is conformal or not.
To be clear: I do not need to make the mesh conformal. I only need to check if it is conformal or not.
Is there any method implemented in Gmsh to do this?
If not, is there any know way that could be easily implemented?
Merci beaucoup !
Hello, I would also be interested in trying to impose a mirror symmetry to a mesh. However, the links given above (e.g. https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/demos/api/mirror_mesh.py) seem to be dead. Indeed, I am getting the following error message: "demos/api/mirror_mesh.py" did not exist on "master"
Is there any other place where I could find this script ?
Hello, is there any file format that allows saving a geometry generated in Gmsh with OpenCASCADE while simultaneously storing physical volumes and physical surfaces?
The following script ("gaafet.geo") causes me problems.
SetFactory("OpenCASCADE");
// Geometry parameters
L = 10; // Channel length
r0 = 1.5; // Channel radius
tox = 1; // Oxide thickness
Lc = 5; // Source/drain thickness
Mesh.CharacteristicLengthMin = 1.0;
Mesh.CharacteristicLengthMax = 1.0;
// Mesh.CharacteristicLengthMin = 0.2;
// Mesh.CharacteristicLengthMax = 0.2;
Cylinder(1) = {0, 0, 0, 0, 0, L+2*Lc, r0+tox, 2*Pi};
Cylinder(2) = {0, 0, 0, 0, 0, L+2*Lc, r0, 2*Pi};
BooleanFragments{ Volume{2}; Volume{1}; Delete; }{ }
Cylinder(4) = {0, 0, Lc, 0, 0, L, r0+tox, 2*Pi};
Cylinder(5) = {0, 0, Lc, 0, 0, L, r0, 2*Pi};
BooleanFragments{ Volume{2}; Volume{3}; Volume{4}; Volume{5}; Delete; }{ }
//+
Physical Volume("channel", 33) = {5};
//+
Physical Volume("drain", 34) = {6};
//+
Physical Volume("channel_ox", 35) = {9};
//+
Physical Volume("source", 36) = {7};
//+
Physical Volume("source_ox", 37) = {10};
//+
Physical Volume("drain_ox", 38) = {8};
//+
Physical Surface("source_bnd", 39) = {19};
//+
Physical Surface("drain_bnd", 40) = {17};
//+
Physical Surface("gate_bnd", 41) = {23};
Mesh 1;
Mesh 2;
Mesh 3;
Save "gaafet.geo_unrolled";
Save "gaafet.msh2";
Executing the script with "gmsh gaafet.geo" works fine, and produces the .msh2 and geo_unrolled files without problem.
However, subsequently loading the geo_unrolled file in the Python API fails. If I do:
import gmsh
gmsh.initialize()
gmsh.open("gaafet.geo_unrolled")
then I get the following error message:
Info : Reading 'unittests/point_charge/meshes/gaafet_2.geo_unrolled'...
Info : Starting subloop 1 in curve loop 16 (are you sure about this?)
Info : Starting subloop 1 in curve loop 20 (are you sure about this?)
Error : Curve loop 21 is wrong
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\fbeau\miniconda3\envs\poissonfem\lib\site-packages\gmsh.py", line 295, in open
raise Exception(logger.getLastError())
Exception: Curve loop 21 is wrong
I don't understand how a curve loop could be wrong since I am not using any. I am just defining cylinders and then taking Boolean fragments with OpenCASCADE.
I am using Gmsh version 4.10.5.
Thank you !
Hello,
I would like to know if Gmsh allows to input a mesh size map to determine mesh refinement.
More precisely, suppose I start with an initial mesh, solve some problem over it, and evaluate some error measure at each mesh point. Is there any way to give Gmsh a target element characteristic length for each node of the initial mesh (a mesh size map), and produce a new mesh according to those new characteristic length specifications ?
This would be immensely useful for adaptive meshing.
Best regards,
Félix
Thanks.
@jeremy I am following your link but not understanding your suggestion. Is it to set Mesh.SecondOrderLinear to True, and if so why ? My code crashes because at some point I need to find which tetrahedra are associated to which triangles. The function I wrote for this assumes that all nodes of the second-order element lie on the surface of a tetrahedron (i.e. within a triangle). But this is not the case, e.g., for the element I illustrated above.
FYI, I am using gmsh version 4.8.4. Help: About gmsh yields:
Gmsh
version 4.8.4 Copyright (C) 1997-2021 Christophe Geuzaine and Jean-Francois Remacle Credits and licensing information Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues
I am getting an unexpected problem with second-order Lagrange elements.
I am producing a second-order mesh for a relatively simple cylindrical geometry (more complicated geometries will also be considered in the future). The .geo file producing the geometry and mesh is attached here: gaafet_2.geo.
When plotting the mesh, everything looks fine at first glance, however, running my code on it causes it to crash. After some investigation, I found that roughly 200 elements in the mesh are the cause of the problem. An example of such an element is the 207th tetrahedron, i.e., element # 1259 in the .msh2 file (for compatibility reasons, I can only use msh format 2).
The coordinates of the 10 local nodes of this element are:
x | y | z |
---|---|---|
8.0902 | -5.8779 | 0 |
5.8779 | -8.0902 | 2.5 |
5.6959 | -5.1652 | 2.5 |
5.8779 | -8.0902 | 0 |
7.0711 | -7.0711 | 1.25 |
5.7869 | -6.6277 | 2.5 |
6.8930 | -5.5215 | 1.25 |
7.0711 | -7.0711 | 0 |
5.7869 | -6.6277 | 1.25 |
5.8779 | -8.0902 | 1.25 |
If I plot the tetrahedron, using nodes 1 to 4 as the tetrahedron vertices, and then display dots at the position of each node, then it is easy to see that nodes 5 and 7 do not lie exactly on the tetrahedron edges, as normally required for a second-order Lagrange element: .
I was wondering why this is the case. Is this a bug, or are the second-order elements generated by gmsh different from the usual T10 elements, i.e., one node at each tetrahedron vertex, and one additional node at the center of each edge ?