Re: [deal.II] Difficulty setting manifold with Opencascade using gmsh mesh + salome STEP (or IGES) - Step-54

2020-04-03 Thread Jean-Paul Pelteret
Dear Bruno,

I guess that it would be best to mention this in the tutorial itself, but in 
the mean time I wrote a segment about it in the FAQ:
https://github.com/dealii/dealii/wiki/Frequently-Asked-Questions#how-do-i-ensure-that-my-refined-grid-is-correct-when-using-cad-geometry
 

Please feel free to edit it as you see fit. Never having used this 
functionality in the library before, I hope that I have correctly interpreted 
and massages what Luca had detailed.

Best,
Jean-Paul

> On 03 Apr 2020, at 15:55, Bruno Blais  wrote:
> 
> Dear Jean-Paul,
> Do you think it should be added to the wiki page or as additional information 
> to step-54? I have a bit on my hands, but i'd be glad to work to make the 
> information readily available. Clearly I would not have found that out 
> without Luca's help. 
> Best
> Bruno
> 
> 
> On Friday, 3 April 2020 09:43:33 UTC-4, Jean-Paul Pelteret wrote:
> Dear Bruno,
> 
> I’m glad that you managed to solve this issue with Luca’s aid. I think that 
> the information and workflow that Luca gave was really valuable. Would you 
> care to add this to the Wiki page?
> 
> Best,
> Jean-Paul
> 
>> On 03 Apr 2020, at 06:03, Bruno Blais > 
>> wrote:
>> 
>> Ciao Luca,
>> It works perfectly now even with regular GMSH triangulation (see movie). Now 
>> I understand the difference and how to set it correctly.
>> Thank you very much for the help :)!
>> 
>> 
>> On Thursday, 2 April 2020 11:31:42 UTC-4, luca.heltai wrote:
>> Bruno, it seems like you are attaching your faces to the *boundary* 
>> manifold. Let me try to explain what is happening. 
>> 
>> In the code for step-54, there is a wire that is used to describe the 
>> manifold of the *boundary* of the surface (a curve of dimension one embedded 
>> in dimension three). This is generated by the wire that identifies the 
>> boundary of the TopoDS shape of the face. The manifold attached to it is an 
>> ArcLengthProjectionManifold, where mid points on the curve are added by 
>> computing the distance in arc length, and taking the point in the middle 
>> w.r.t. this length. 
>> 
>> In your code with more than one cell, you are not assigning *just the 
>> boundary faces* to the wire, but *all* faces (including the one in the 
>> middle of your surface, delimitating the two cells). Intermediate points on 
>> those lines will be projected (correctly) on the boundary wire (that’s what 
>> your movie shows). 
>> 
>> Of course any point that is in the middle of the surface does *not* belong 
>> to the *boundary wire*, and you’ll get an exception when trying to construct 
>> the midpoint of an *edge* that belongs to the interior of the domain, with 
>> manifold id 2 (which corresponds to a manifold that describes *the boundary* 
>> of your topology, not its surface). 
>> 
>> With two cells, the internal edge (the only edge that does not belong to the 
>> boundary) should *not* have id 2. If you set its id to 2, the result is that 
>> a point which is in the middle of the edge, is actually in the midlle of the 
>> two points *when running along the curve that describes the boundary*, hence 
>> you get the distortion you show in the movie. 
>> 
>> Try adding a check to the faces in which you set the manifold id to 2 only 
>> if the face is at the boundary. 
>> 
>> The principle is: 
>> 1. start from the lowest codimension objects, identify how to deform them. 
>> In your case, cells of a Tria<2,3> are quads, that should deform as a 
>> TopoDS_FACE. 
>> 2. Attach your favorite manifold to the TopoDS_Face (I’d personally only use 
>> NormalToMeshProjectionManifold) using 
>> cell->set_all_manifold_ids(manifold_id) (Notice the use of 
>> set_all_manifold_ids, and **not** set_manifold_id: you want all children of 
>> these objects to belong to the same manifold, in particular you want all 
>> faces that are internal, i.e., that are shared between two obects with the 
>> same manifold id, to inherit the same manifold id). 
>> 3. Go one codimension lower: in your case, curves (for 3d meshes, surfaces). 
>> Follow the same rule as above, setting all_manifold_ids on faces that you 
>> know should follow a known codimension one geometry (a known TopoDS_EDGE, or 
>> TopoDS_WIRE). In this case I’d only use ArcLengthProjectionManifold objects, 
>> attached to the wires that identify your geometry. 
>> 
>> Doing things in this order guarantees that internal edges get the correct 
>> manifold id, which, in your case, is not happening. 
>> 
>> Best, 
>> Luca. 
>> 
>> 
>> 
>> > On 1 Apr 2020, at 17:32, Bruno Blais gmail.com 
>> > > wrote: 
>> > 
>> > So my investigation on this issue continues... 
>> > It seems the core of my issues stem from using a non-trivial mesh with 
>> > more than one cell as a starting point. 
>> > if I start with a 2 cell spacedim=2 dim=3 mesh such as: 
>> > 
>> > 
>> >  
>> > 
>> 

Re: [deal.II] Difficulty setting manifold with Opencascade using gmsh mesh + salome STEP (or IGES) - Step-54

2020-04-03 Thread Bruno Blais
Dear Jean-Paul,
Do you think it should be added to the wiki page or as additional 
information to step-54? I have a bit on my hands, but i'd be glad to work 
to make the information readily available. Clearly I would not have found 
that out without Luca's help. 
Best
Bruno


On Friday, 3 April 2020 09:43:33 UTC-4, Jean-Paul Pelteret wrote:
>
> Dear Bruno,
>
> I’m glad that you managed to solve this issue with Luca’s aid. I think 
> that the information and workflow that Luca gave was really valuable. Would 
> you care to add this to the Wiki page?
>
> Best,
> Jean-Paul
>
> On 03 Apr 2020, at 06:03, Bruno Blais > 
> wrote:
>
> Ciao Luca,
> It works perfectly now even with regular GMSH triangulation (see movie). 
> Now I understand the difference and how to set it correctly.
> Thank you very much for the help :)!
>
>
> On Thursday, 2 April 2020 11:31:42 UTC-4, luca.heltai wrote:
>>
>> Bruno, it seems like you are attaching your faces to the *boundary* 
>> manifold. Let me try to explain what is happening. 
>>
>> In the code for step-54, there is a wire that is used to describe the 
>> manifold of the *boundary* of the surface (a curve of dimension one 
>> embedded in dimension three). This is generated by the wire that identifies 
>> the boundary of the TopoDS shape of the face. The manifold attached to it 
>> is an ArcLengthProjectionManifold, where mid points on the curve are added 
>> by computing the distance in arc length, and taking the point in the middle 
>> w.r.t. this length. 
>>
>> In your code with more than one cell, you are not assigning *just the 
>> boundary faces* to the wire, but *all* faces (including the one in the 
>> middle of your surface, delimitating the two cells). Intermediate points on 
>> those lines will be projected (correctly) on the boundary wire (that’s what 
>> your movie shows). 
>>
>> Of course any point that is in the middle of the surface does *not* 
>> belong to the *boundary wire*, and you’ll get an exception when trying to 
>> construct the midpoint of an *edge* that belongs to the interior of the 
>> domain, with manifold id 2 (which corresponds to a manifold that describes 
>> *the boundary* of your topology, not its surface). 
>>
>> With two cells, the internal edge (the only edge that does not belong to 
>> the boundary) should *not* have id 2. If you set its id to 2, the result is 
>> that a point which is in the middle of the edge, is actually in the midlle 
>> of the two points *when running along the curve that describes the 
>> boundary*, hence you get the distortion you show in the movie. 
>>
>> Try adding a check to the faces in which you set the manifold id to 2 
>> only if the face is at the boundary. 
>>
>> The principle is: 
>> 1. start from the lowest codimension objects, identify how to deform 
>> them. In your case, cells of a Tria<2,3> are quads, that should deform as a 
>> TopoDS_FACE. 
>> 2. Attach your favorite manifold to the TopoDS_Face (I’d personally only 
>> use NormalToMeshProjectionManifold) using 
>> cell->set_all_manifold_ids(manifold_id) (Notice the use of 
>> set_all_manifold_ids, and **not** set_manifold_id: you want all children of 
>> these objects to belong to the same manifold, in particular you want all 
>> faces that are internal, i.e., that are shared between two obects with the 
>> same manifold id, to inherit the same manifold id). 
>> 3. Go one codimension lower: in your case, curves (for 3d meshes, 
>> surfaces). Follow the same rule as above, setting all_manifold_ids on faces 
>> that you know should follow a known codimension one geometry (a known 
>> TopoDS_EDGE, or TopoDS_WIRE). In this case I’d only use 
>> ArcLengthProjectionManifold objects, attached to the wires that identify 
>> your geometry. 
>>
>> Doing things in this order guarantees that internal edges get the correct 
>> manifold id, which, in your case, is not happening. 
>>
>> Best, 
>> Luca. 
>>
>>
>>
>> > On 1 Apr 2020, at 17:32, Bruno Blais  wrote: 
>> > 
>> > So my investigation on this issue continues... 
>> > It seems the core of my issues stem from using a non-trivial mesh with 
>> more than one cell as a starting point. 
>> > if I start with a 2 cell spacedim=2 dim=3 mesh such as: 
>> > 
>> > 
>> >  
>> > 
>> > 
>> > 
>> > Which is identical to the second step of the adaptation. I get an 
>> aberrant result (see attached out_wrong.mp4). 
>> > 
>> > 
>> > 
>> > I also get issues when I try to apply the manifold on a starting msh 
>> made with GMSH that has a similar topology such as in the following image:
>>  
>> > 
>> >  
>> > 
>> > 
>> > 
>> > In this case, I get an error about a point not being on the manifold 
>> (when it clearly is)... 
>> > 
>> > So I must admit I am at loss here. Right now the code I use to set the 
>> manifold is : 
>> > 
>> > for (const auto  : tria.active_cell_iterators()) 
>> >   { 
>> > 
>> > cell->set_manifold_id(1); 
>> > 
>> > for (const auto  : cell->face_iterators()) 
>> > 
>> >   { 

Re: [deal.II] Difficulty setting manifold with Opencascade using gmsh mesh + salome STEP (or IGES) - Step-54

2020-04-03 Thread Jean-Paul Pelteret
Dear Bruno,

I’m glad that you managed to solve this issue with Luca’s aid. I think that the 
information and workflow that Luca gave was really valuable. Would you care to 
add this to the Wiki page?

Best,
Jean-Paul

> On 03 Apr 2020, at 06:03, Bruno Blais  wrote:
> 
> Ciao Luca,
> It works perfectly now even with regular GMSH triangulation (see movie). Now 
> I understand the difference and how to set it correctly.
> Thank you very much for the help :)!
> 
> 
> On Thursday, 2 April 2020 11:31:42 UTC-4, luca.heltai wrote:
> Bruno, it seems like you are attaching your faces to the *boundary* manifold. 
> Let me try to explain what is happening. 
> 
> In the code for step-54, there is a wire that is used to describe the 
> manifold of the *boundary* of the surface (a curve of dimension one embedded 
> in dimension three). This is generated by the wire that identifies the 
> boundary of the TopoDS shape of the face. The manifold attached to it is an 
> ArcLengthProjectionManifold, where mid points on the curve are added by 
> computing the distance in arc length, and taking the point in the middle 
> w.r.t. this length. 
> 
> In your code with more than one cell, you are not assigning *just the 
> boundary faces* to the wire, but *all* faces (including the one in the middle 
> of your surface, delimitating the two cells). Intermediate points on those 
> lines will be projected (correctly) on the boundary wire (that’s what your 
> movie shows). 
> 
> Of course any point that is in the middle of the surface does *not* belong to 
> the *boundary wire*, and you’ll get an exception when trying to construct the 
> midpoint of an *edge* that belongs to the interior of the domain, with 
> manifold id 2 (which corresponds to a manifold that describes *the boundary* 
> of your topology, not its surface). 
> 
> With two cells, the internal edge (the only edge that does not belong to the 
> boundary) should *not* have id 2. If you set its id to 2, the result is that 
> a point which is in the middle of the edge, is actually in the midlle of the 
> two points *when running along the curve that describes the boundary*, hence 
> you get the distortion you show in the movie. 
> 
> Try adding a check to the faces in which you set the manifold id to 2 only if 
> the face is at the boundary. 
> 
> The principle is: 
> 1. start from the lowest codimension objects, identify how to deform them. In 
> your case, cells of a Tria<2,3> are quads, that should deform as a 
> TopoDS_FACE. 
> 2. Attach your favorite manifold to the TopoDS_Face (I’d personally only use 
> NormalToMeshProjectionManifold) using cell->set_all_manifold_ids(manifold_id) 
> (Notice the use of set_all_manifold_ids, and **not** set_manifold_id: you 
> want all children of these objects to belong to the same manifold, in 
> particular you want all faces that are internal, i.e., that are shared 
> between two obects with the same manifold id, to inherit the same manifold 
> id). 
> 3. Go one codimension lower: in your case, curves (for 3d meshes, surfaces). 
> Follow the same rule as above, setting all_manifold_ids on faces that you 
> know should follow a known codimension one geometry (a known TopoDS_EDGE, or 
> TopoDS_WIRE). In this case I’d only use ArcLengthProjectionManifold objects, 
> attached to the wires that identify your geometry. 
> 
> Doing things in this order guarantees that internal edges get the correct 
> manifold id, which, in your case, is not happening. 
> 
> Best, 
> Luca. 
> 
> 
> 
> > On 1 Apr 2020, at 17:32, Bruno Blais gmail.com 
> > > wrote: 
> > 
> > So my investigation on this issue continues... 
> > It seems the core of my issues stem from using a non-trivial mesh with more 
> > than one cell as a starting point. 
> > if I start with a 2 cell spacedim=2 dim=3 mesh such as: 
> > 
> > 
> >  
> > 
> > 
> > 
> > Which is identical to the second step of the adaptation. I get an aberrant 
> > result (see attached out_wrong.mp4). 
> > 
> > 
> > 
> > I also get issues when I try to apply the manifold on a starting msh made 
> > with GMSH that has a similar topology such as in the following image: 
> > 
> >  
> > 
> > 
> > 
> > In this case, I get an error about a point not being on the manifold (when 
> > it clearly is)... 
> > 
> > So I must admit I am at loss here. Right now the code I use to set the 
> > manifold is : 
> > 
> > for (const auto  : tria.active_cell_iterators()) 
> >   { 
> > 
> > cell->set_manifold_id(1); 
> > 
> > for (const auto  : cell->face_iterators()) 
> > 
> >   { 
> > 
> >   face->set_manifold_id(2); 
> > 
> >   } 
> > 
> >   } 
> > 
> > If anybody has any experience with using the OpenCascade manifold using 
> > initial meshes that have more than 1 cell, I would greatly appreciate 
> > advices :)!. 
> > 
> > Best 
> > 
> > Bruno 
> > 
> > 
> > 
> > 
> > On Wednesday, April 1, 2020 at 9:38:27 AM UTC-4, Bruno Blais wrote: 
> > 
> > So it seems part