Dear Rene, An alternative solution would be to use RefineMesh (GModel::refineMesh), which should do what you want directly. Can you give it a try?
Christophe On 21 Mar 2013, at 14:23, Rene Schneider <[email protected]> wrote: > Dear list > > I'm developing a FEM solver, and recently integrated a routine to read gmsh > .msh files. The FEM solver uses hierarchical meshes to enable fast solvers > (multigrid preconditioning). For this reason I prefer to start with a coarse > mesh (generated by gmsh) and to let my code refine this mesh. > > In order to deal with curved geometry in the refinement, it is common > practise to project the new surface points onto their (curved) geometry. > Since I didn't find a simple means to do so with gmsh directly, I modified > one of the api-demos to this end. See attached files (which I keep in the > utils/api_demos directory). > > This routine reads a file with a list of points and associated geometry tags. > Then it uses the > edge->closestPoint > and > face->closestPoint > methods, to project these points onto their respective geometry. The result > is then written to file again, for the FE solver to read. > So far this seems to be working fine. (See below for a performance example.) > > A few comments/questions: > > 1. I'd be glad if some gmsh developers could comment on the code. > (Is there a better way to achieve this?) > > 2. My attempts in the CMakeList.txt to create a statically linked version all > failed. Any suggestions on this? > > 3. I provide these files under same license as gmsh in the hope that this can > be integrated into future releases of gmsh. I suggest the utils/api_demos > folder. > > 4. Is it easily possible to influence the accuracy of the projection? I had a > look on some of the code for closestPoint and noticed that this is done in an > iterative way, with fairly loose stoping criterion. In the future I might be > interested in differentiating the node positions with respect to geometry > parameters. These derivatives could easily be approximated by finite > differences. However, the projection accuracy is critical then. > > 5. Are there some error-flags in case the projection goes wrong? For one > geometry > http://www.opencascade.org/ex/att/15_cylinder_head.brep.gz > from > http://www.opencascade.org/showroom/shapegallery/gal4/ > I had problems with a some of the sub-geometries, which were projected to the > origin. Even though I got no error messages or similar. > > > Regards > > Rene > > > P.S.: As a sample of the performance: > > Poisson equation in 3D domain with curved boundary from > http://www.opencascade.org/ex/att/31_misc2.brep.gz > We use gmsh to create a coarse mesh of 7,334 nodes, P1 elements. The finest > mesh so far has 21,909,034 nodes. Solution on this finest mesh is computed in > 15m34.028s including file write of solution for paraview. :) > > Visualisation (paraview): > http://www-user.tu-chemnitz.de/~rens/software/feins/examples/full/31_misc2_lvl4_21909034_nodes_s.png > http://www-user.tu-chemnitz.de/~rens/software/feins/examples/full/31_misc2_lvl4_21909034_nodes_swe_large.png > > > > > > -- > ---------------------------------------------------- > > Dr. Rene Schneider > > TU Chemnitz, Fakultaet fuer Mathematik, > 09107 Chemnitz, Germany > > Besucheradresse / Visitor address: > Reichenhainer Str. 41 / Raum 625 > 09126 Chemnitz, Germany > > Tel.: +49-371-531-33953 > Fax: +49-371-531-8-33953 > [email protected] > > http://www.tu-chemnitz.de/~rens > > ---------------------------------------------------- > <gmsh_closest_points.cpp><CMakeLists.txt>_______________________________________________ > gmsh mailing list > [email protected] > http://www.geuz.org/mailman/listinfo/gmsh -- Prof. Christophe Geuzaine University of Liege, Electrical Engineering and Computer Science http://www.montefiore.ulg.ac.be/~geuzaine _______________________________________________ gmsh mailing list [email protected] http://www.geuz.org/mailman/listinfo/gmsh
