[Gmsh] projecting points to geometry

Rene Schneider rene.schneider at mathematik.tu-chemnitz.de
Mon Apr 8 09:13:06 CEST 2013


On 04/05/2013 10:01 AM, Christophe Geuzaine wrote:
>
> 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?

Dear Christophe,

thanks for following up on that.

No, unfortunately Gmshs own refinement routine will not suffice for this 
purpose. For the linear solver methods employed in my FE code, hierarchy 
information is required for the meshes, i.e. for linear elements, which 
two parent nodes created which child node. This information is 
essential. To be precise, we use (geometric) Multigrid Methods, so not 
just the final mesh is used, but a whole hierarchic sequence of meshes, 
and the mesh transfers.

Of course it might be possible to modify RefineMesh to create the 
required info, but that would require to transfer the whole sequence of 
meshes as well as the hierarchy information between the FE-code and Gmsh.

On the other hand, if I let the mesh-refinement be done in the FE code, 
I only need to transfer the coarsest mesh and some information on the 
new surface nodes of the fine meshes forth and back. This latter part is 
done with the routine I proposed in my post.

Rene


>
> On 21 Mar 2013, at 14:23, Rene Schneider <rene.schneider at mathematik.tu-chemnitz.de> 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
       rene.schneider at mathematik.tu-chemnitz.de

       http://www.tu-chemnitz.de/~rens

----------------------------------------------------