gmsh::model::isInside not working properly
Hello, Sorry if this was brought up before but here's the issue: I'm using Gmsh 4.9.5 on windows 10 with the c++ api
the issue is with gmsh::model::isInside() which is meant to test if points are inside an entity. it seems to always answer yes no matter the point coordinates and entity tested. i.e : it always returns an int equal to the number points tested meaning it considers all of them inside the entity.
on the console output, interestingly, points that are outside the entity give a "warning : could not converge parametrisation of on , taking parameter with lowest error" while points inside the entity do not give this warning.
So my workaround is to use the isInside method and use gmsh::logger to detect whether gmsh gave this warning or not to determine if the point is inside the entity or not.
However, this workaround only works when the model is constructed using the gmsh::model::geo api or if loaded from the .geo file and not when loaded from .msh file (in this case all points give the warning)
Here's minimal code demonstrating the issue :
The ex1.geo file :
Point(1) = {0 ,0 ,0, 0.2};
Point(2) = {0 ,2 ,0, 0.2};
Line(1) = {1, 2};
the c++ code :
gmsh::initialize();
gmsh::open("minimal code/ex1.geo");
gmsh::model::geo::synchronize();
std::cout << "Opening with .geo" << std::endl;
std::cout << "Point is inside gives :" << std::endl;
std::cout << gmsh::model::isInside(1, 1, {0, 1, 0}, false) << std::endl;
std::cout << "Point is outside gives :" << std::endl;
std::cout << gmsh::model::isInside(1, 1, {0, 3, 0}, false) << std::endl;
gmsh::model::mesh::generate(1);
gmsh::write("minimal code/ex1.msh");
gmsh::clear();
gmsh::open("minimal code/ex1.msh");
gmsh::model::geo::synchronize();
std::cout << "Opening with .msh" << std::endl;
std::cout << "Point is inside gives :" << std::endl;
std::cout << gmsh::model::isInside(1, 1, {0, 1, 0}, false) << std::endl;
std::cout << "Point is outside gives :" << std::endl;
std::cout << gmsh::model::isInside(1, 1, {0, 3, 0}, false) << std::endl;
gmsh::finalize();
the console output :
Info : Reading 'minimal code/ex1.geo'...
Info : Done reading 'minimal code/ex1.geo'
Opening with .geo
Point is inside gives :
1
Point is outside gives :
Warning : Could not converge parametrisation of (0,3,0) on curve 1, taking parameter with lowest error
1
Info : Meshing 1D...
Info : Meshing curve 1 (Line)
Info : Done meshing 1D (Wall 0.0013717s, CPU 0s)
Info : 11 nodes 12 elements
Info : Writing 'minimal code/ex1.msh'...
Info : Done writing 'minimal code/ex1.msh'
Info : Clearing all models and views...
Info : Done clearing all models and views
Info : Reading 'minimal code/ex1.msh'...
Info : 3 entities
Info : 11 nodes
Info : 12 elements
Info : Done reading 'minimal code/ex1.msh'
Opening with .msh
Point is inside gives :
Warning : Could not converge parametrisation of (0,1,0) on curve 1, taking parameter with lowest error
1
Point is outside gives :
Warning : Could not converge parametrisation of (0,3,0) on curve 1, taking parameter with lowest error
1
I'm just getting into gmsh so I might've completely misunderstood everything here so if so please tell me. But if this is in fact an issue, is it a known issue ? is it only an issue with the geo engine and not occ ? (I never got to use occ successfully yet). wouldn't the fix to this issue be easy since gmsh knows when to give the warning ? so all there's left to do is return 0 instead of 1 for every point where it "can't converge parametrisation" ?
For now the workaround works fine. Just thought I'd let you know about the issue and hopefully help me understand better what's going on here.
Cheers.