How to control surface mesh quality?
Dear all, I have the following code to substract a very small box from a sphere. I generated the surface mesh of the new object, however, the quality of triangles near the small box is very bad, is there any method to control the quality of surface mesh and could anyone help me to take a look the code?
Thanks, Tang Laoya
#include <set>
#include <cmath>
#include <gmsh.h>
#include <GmshMessage.h>
int main(int argc, char **argv)
{
gmsh::initialize();
gmsh::option::setNumber("Mesh.Algorithm", 6);
gmsh::option::setNumber("Mesh.MeshSizeMin", 0.4);
gmsh::option::setNumber("Mesh.MeshSizeMax", 0.4);
double R = 1.4, Rs = R * .7, Rt = R * 1.25;
std::vector<std::pair<int, int> > ov;
std::vector<std::vector<std::pair<int, int> > > ovv;
gmsh::model::occ::addSphere(0, 0, 0, Rt, 2);
double boxwide = 1e-5, boxlen = 1e-4;
gmsh::model::occ::addBox(Rt - boxlen / 2, 0, 0, boxlen, boxwide, boxwide, 10);
gmsh::model::occ::cut({{3, 2}}, {{3, 10}}, ov, ovv, 8);
gmsh::model::geo::addPhysicalGroup(3, {8}, 1);
gmsh::model::occ::synchronize();
gmsh::model::mesh::generate(2);
gmsh::write("substract.msh");
gmsh::finalize();
return 0;
}
Another similar case (surface mesh failed):
int main(int argc, char **argv)
{
gmsh::initialize();
double R = 1.4, Rs = R * .7, Rt = R * 1.25;
std::vector<std::pair<int, int> > ov;
std::vector<std::vector<std::pair<int, int> > > ovv;
double wr1 = 0.1,wr2=0.08;
gmsh::model::occ::addCylinder(0, 0, 0, 0, 0, 100*R, wr1, 1);
gmsh::model::occ::addCylinder(0, 0, 0, 0, 0, 100 * R, wr2, 2);
gmsh::model::occ::cut({{3, 1}}, {{3, 2}}, ov, ovv, 3);
gmsh::model::geo::addPhysicalGroup(3, {3}, 1);
gmsh::model::occ::synchronize();
gmsh::model::mesh::generate(2);
gmsh::write("longtube.msh");
gmsh::finalize();
return 0;
}