FloSewn / TQMesh

A simple two-dimensional mesh generator with triangular and quadrilateral elements in C++
MIT License
57 stars 16 forks source link

One square next to each other #12

Open hejfil opened 1 year ago

hejfil commented 1 year ago

Should final mesh be symmetric ?

image

Example_1.para.txt

FloSewn commented 1 year ago

Hey there,

thank you so much for pointing out this error and sorry for my late response - unfortunately I don't have much spare time at the moment for this project - hopefully this will change in some weeks...

I looked at your example file and found out, that it is possible to achieve a symmetry, if the vertices of the second mesh are slightly arranged (see the updated file attached to this message). In your given parameter file, the first edge of the second mesh was attached to the other mesh and that probably led to this bug. I will try to fix it in for a future release.

Thanks again for pointing this out! :-)

Greetings Flo

MeshPlot

Example_1_updated.para.txt

fei-xu commented 1 year ago

Hi @Florian,

I have been using TQMesh for a week. It's a very useful tool for creating 2D meshes with quality! I had a similar problem to the above one but with refinements. I have been looking into the source code trying to solve it but had no clue. Luckily I found this discussion and this trick solved my issue. Many thanks! But why this works and which part of the code relates to this? could you shed some light here.

Regards, Fei

FloSewn commented 1 year ago

Hello Fei,

sorry for my late response and thank you so much for your kind words!

I just finished a new release (v1.3) where this problem is partly resolved - this is the output from the initial input file without using the re-arrangement trick (bug_issue12_commit76a4813.txt).

bug_issue12_commit76a4813

The reason for the asymmetry is the following: When we start with the generation of a mesh, we typically choose the largest boundary edge for the first advancing front triangle. Since all edges in this example are of equal length, the one is chosen which has been defined first.

In the provided input file, the first defined edge of the right mesh is located at the bottom side, whereas the first defined edge of the left mesh is located on its right side (the interface where both meshes touch). This difference causes the placement of the first triangle and thus the asymmetry of both meshes.

I hope I could help you with this explanation.

Greetings Flo

fei-xu commented 1 year ago

Hi Florian,

Many thanks for your detailed reply! Congratulations on your new release! Recently I found the 'develop' branch and I see you have made a lot of improvements there and of course the new release. The mesh quality especially the quad-layer generation is much higher than the previous release! πŸ‘ Recently, I have been using TQMesh for meshing a semiconductor device that needs lots of quad layers. Sometimes, I encounter a problem that happens when the height of the quad layer approaches the mesh size. Here I enclose an example .para file and the mesh figure (generated from v1.3). I am new to C++, I am struggling to read the source code. Can you help me solve this problem? I would be grateful if you give me a hand at your convenience.

Regards, Fei

Florian Setzwein @.***> 于2023εΉ΄8月27ζ—₯周ζ—₯ 23:35ε†™ι“οΌš

Hello Fei,

sorry for my late response and thank you so much for your kind words!

I just finished a new release (v1.3) where this problem is partly resolved

[image: bug_issue12_commit76a4813] https://user-images.githubusercontent.com/69447532/263538585-4593eb15-68f7-4da2-8f57-7ee2ca8f11f9.png

The reason for the asymmetry is the following: When we start a the generation of a mesh, we typically choose the largest boundary edge for the first advancing front triangle. Since all edges in this example are of equal length, that one is chosen which has been defined first.

In the provided input file, the first defined edge of the right mesh is located at the bottom side, whereas the first defined edge of the left mesh is located on its right side (the interface where both meshes touch).

I hope I could help you with this explanation.

Greetings Flo

β€” Reply to this email directly, view it on GitHub https://github.com/FloSewn/TQMesh/issues/12#issuecomment-1694697637, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVRALJI6EGQNUWGZZUDV5DXXNSLVANCNFSM6AAAAAAVIDAJ4Q . You are receiving this because you commented.Message ID: @.***>

Fei2015 commented 1 year ago

It seems the attachments from the email are not showing up. I put them here. quad_layering_problem

Example_quadlayer.txt

FloSewn commented 12 months ago

Hey Fei,

that is an interesting bug! Thank you so much for pointing it out :-)

I will try to take a look at this problem in the coming days. But if you need an ad-hoc solution, you can try to change the variable "rangefactor" (in the file "src/algorithm/QuadLayerStrategy.h", line 972) from a value of 1.1 to a value of 0.9 - this solved the problem for your example.

Unfortunately, a smaller value leads to problems during the quad layer generation when dealing with sharp edges, so it is not a general solution...

Anyways, thanks again for your help!

By the way: I'm curious what you're working on (just in case you want to write about it). What kind of semiconductor application are you simulating and what software do you use? I wasn't aware that these kind of meshes are also of interest for such problems - very cool!

Kind regards, Flo

Fei2015 commented 12 months ago

Hey Fei,

that is an interesting bug! Thank you so much for pointing it out :-)

I will try to take a look at this problem in the coming days. But if you need an ad-hoc solution, you can try to change the variable "rangefactor" (in the file "src/algorithm/QuadLayerStrategy.h", line 972) from a value of 1.1 to a value of 0.9 - this solved the problem for your example.

Unfortunately, a smaller value leads to problems during the quad layer generation when dealing with sharp edges, so it is not a general solution...

Anyways, thanks again for your help!

By the way: I'm curious what you're working on (just in case you want to write about it). What kind of semiconductor application are you simulating and what software do you use? I wasn't aware that these kind of meshes are also of interest for such problems - very cool!

Kind regards, Flo

Hi Florian,

Thanks for your interest : ) I tried the value 0.9 for the "rangefactor", the mesh is perfect for a rectangular area. Many thanks for pointing it out! Btw, I am not sure if it's a bug, since this kind of mesh is quite different from a typical CFD mesh. I hope the fix will not take you much time. Now I am trying to improve the quad-layer quality for a wedge-shaped area. The quad-layer front curls gradually at the end when the height is approaching local mesh size. I guess this relates to the functions "place_start_vertex()" and "place_end_vertex()" in the QuadLayerStrategy.h. Is it a good guess? 😊 Btw, I am not sure if it's a bug, since this kind of mesh is quite different from a typical CFD mesh. I hope the fix will not take you much time. For your curious questions 😊, I am a CFDer, I used to use Ansys Fluent and OpenFOAM for simulating blood flows. Now I am looking for a position in the semiconductor industry. Currently, I started learning C++, the physics, and numerics for semiconductor devices (not on a specific application). So basically I am learning the solver algorithms and of course the mesh generation algorithms 😊 for a better understanding of simulation software. I am not about to write something currently but if I do and it relates to TQMesh, your work will definitely be cited.

Let's keep in touch.πŸ˜‰

Regards, Fei