FloSewn / TQMesh

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

Mesh refinement #14

Closed JamesKeeF closed 1 year ago

JamesKeeF commented 1 year ago

Hey,

I've been waiting for years for someone to release something like this.

While I commend you for your work, I've browsed through the code and I could see quite a bit of things that could be improved hence I'm disappointed. I'm curious, are you a professional coder?

Anyway, I did some testing and maybe I don't quite understand what sizing and range actually are. I would expect sizing to mean the size of the refinement and the range to be how far the refinement reaches from the vertex (point). Is this not the case?

Here are the parts I changed from example number 1. I don't see any refinement whatsoever. What might be the reason?

Also attached a picture of the result.

Boundary& b_ext = domain.add_exterior_boundary();

Vertex& v0 = domain.add_vertex( 0.0, 0.0 ); Vertex& v1 = domain.add_vertex( 500.0, 0.0 ); Vertex& v2 = domain.add_vertex( 500.0, 500.0 ); Vertex& v3 = domain.add_vertex( 0.0, 500.0 );

b_ext.add_edge( v0, v1, 1 ); b_ext.add_edge( v1, v2, 1 ); b_ext.add_edge( v2, v3, 1 ); b_ext.add_edge( v3, v0, 1 );

Boundary& b_int = domain.add_interior_boundary();

double sizing = 1.0; double range = 5.0;

Vertex& v4 = domain.add_vertex( 100.0, 100.0, sizing, range ); Vertex& v5 = domain.add_vertex( 400.0, 400.0 ); Vertex& v6 = domain.add_vertex( 400.0, 100.0 );

b_int.add_edge( v4, v5, 2 ); b_int.add_edge( v5, v6, 2 ); b_int.add_edge( v6, v4, 2 );

Screenshot from 2023-04-26 23-08-15

FloSewn commented 1 year ago

Hey there,

thanks for taking the time to look at the code and sorry for the disappointment ;-) I am working in Academia in the field of computational fluid dynamics and was writing this code during the Covid pandemic to learn C++ and only in my free time - so there's probably a lot to improve... unfortunately I don't have much time at the moment to change things, but I will maybe try to in a few months. Of course I would be very happy about suggestions and ideas about how to improve the code :-)

Concerning your question: The sizing factor is a factor defined at each vertex by which the global mesh size is locally multiplied. So if you reduce it - say to 0.9 - a refinement should be observable. The range factor - just as you said - is meant to control the range around that specific vertex where the scaling of the mesh size should be applied.

However, with this approach the scaling factors of nearby vertices might interact - so you have to try a bit in order to get your desired mesh size.
That is something that I definitely would like to improve in the future.

Greetings, Flo

FloSewn commented 1 year ago

Hey there,

the mesh size parameters have been re-defind in the latest release (v1.3), since the old syntax was probably a bit confusing. Your chosen "sizing" values should now produce a mesh with your desired local mesh scales.

Greetings Flo