[Gmsh] (Adaptive) Mesh refinement in libmesh c++ application

Joa Ljungvall gmsh at joa.me.uk
Wed Oct 28 19:24:39 CET 2009


Hi,


I'm the FEM software libmesh to calculate electric fields inside gamma-ray 
detectors. To do this I define the detector geometry using OpenCASCADE and
then create a mesh using gmsh. I do this inside a c++ application, something
like
 .
 .
 TopoDS_Shape detector = BRepAlgoAPI_Common(hexagonpart,cylcomplete);
 //Then mesh it with gmsh
 GmshInitialize(argc, argv);
 GModel m;
 m.importOCCShape((void*)&detector);
 GmshSetOption("Mesh", "CharacteristicLengthFromCurvature",(unsigned int)1);
 try{
    m.mesh(3);
 }
 catch(...){
   printf("Unrecoverable error in gmsh--aborting mesh!\n");
 }
 m.writeMSH("tmp.msh");
 .
 .

I then read the mesh and solve the Laplace equation using libmesh. What I would
like to do is to take the solution, and produce a mesh better adapted 
to my problem. The refinment methods inside libmesh does not allow me to 
respect the geometry of my detector, which is why in the first place I use 
FEM... I have the feeling this should be possible with Gmsh but I have a 
hard time finding the proper c++ code for it, having searched on in the
documentation and the mailing list

kind regards

Dr. Joa Ljungvall