trixi-framework / HOHQMesh

High Order Hex-Quad Mesh (HOHQMesh) package to automatically generate all-quadrilateral meshes with high order boundary information.
https://trixi-framework.github.io/HOHQMesh
Other
45 stars 8 forks source link

Mesh not symmetrical #95

Closed hejfil closed 21 hours ago

hejfil commented 1 month ago

Hello, I am testing your mesh generator and I would like to ask why it is not symmetrical ?

\begin{CONTROL_INPUT}
\begin{RUN_PARAMETERS}
stats file name = None
mesh file format = ISM
polynomial order = 4
plot file format = skeleton
\end{RUN_PARAMETERS}
\begin{BACKGROUND_GRID}
background grid size = [0.050000, 0.050000, 0.050000 ]
\end{BACKGROUND_GRID}
\begin{SPRING_SMOOTHER}
smoothing = ON
smoothing type = LinearAndCrossbarSpring
number of iterations = 25
\end{SPRING_SMOOTHER}
\end{CONTROL_INPUT}
\begin{MODEL}
\begin{OUTER_BOUNDARY}
\begin{END_POINTS_LINE}
name = B4
xStart = [ 0.000000, 0.300000, 0.000000 ]
xEnd = [ 0.000000, 0.000000, 0.000000 ]
\end{END_POINTS_LINE}
\begin{END_POINTS_LINE}
name = B0
xStart = [ 0.000000, 0.000000, 0.000000 ]
xEnd = [ 0.100000, 0.250000, 0.000000 ]
\end{END_POINTS_LINE}
\begin{END_POINTS_LINE}
name = B1
xStart = [ 0.100000, 0.250000, 0.000000 ]
xEnd = [ 0.200000, 0.000000, 0.000000 ]
\end{END_POINTS_LINE}
\begin{END_POINTS_LINE}
name = B2
xStart = [ 0.200000, 0.000000, 0.000000 ]
xEnd = [ 0.200000, 0.300000, 0.000000 ]
\end{END_POINTS_LINE}
\begin{END_POINTS_LINE}
name = B3
xStart = [ 0.200000, 0.300000, 0.000000 ]
xEnd = [ 0.000000, 0.300000, 0.000000 ]
\end{END_POINTS_LINE}
\end{OUTER_BOUNDARY}
\end{MODEL}
\end{FILE}

image

andrewwinters5000 commented 1 month ago

From the example mesh given above it appears you want to have symmetry with respect to the vertical line about the midpoint of the domain. There is no guarantee that the unstructured mesh generation algorithms available in HOHQMesh will produce a mesh that is symmetric with respect to a particular axis. Enforcing symmetry in unstructured algorithms is difficult as it goes against the very paradigm of the method. Symmetry inherently assumes some kind of structure and there is no way to directly do this via unstructured algorithms.

That is not to say this cannot be done, but one would need to implement such a feature. One could mesh half of the domain and then reflect it over the symmetry axis to generate the elements. After such a flip there would need to be some cleanup of duplicate edges and then one can generate the mesh connectivity.

Apart from this, I see from the control file you provided that the outer boundary curve begins at the upper left corner. Sometimes it helps to reorder the outer boundary curves. For instance, I reordered your outer boundary curves to start at the lower right corner of the domain and generated the mesh in the figure below. Though not 100% symmetric about the midpoint, this might get you nearer to your goal. I also include the control file I used (where no other parameters were changed apart from the boundary curve ordering).

triangle_spike.control ``` \begin{CONTROL_INPUT} \begin{RUN_PARAMETERS} plot file name = triangle_splike.tec mesh file name = triangle_splike.mesh stats file name = triangle_splike.txt mesh file format = ISM polynomial order = 4 plot file format = skeleton \end{RUN_PARAMETERS} \begin{BACKGROUND_GRID} background grid size = [0.050000, 0.050000, 0.000000 ] \end{BACKGROUND_GRID} \begin{SPRING_SMOOTHER} smoothing = ON smoothing type = LinearAndCrossbarSpring number of iterations = 25 \end{SPRING_SMOOTHER} \end{CONTROL_INPUT} \begin{MODEL} \begin{OUTER_BOUNDARY} \begin{END_POINTS_LINE} name = B2 xStart = [ 0.200000, 0.000000, 0.000000 ] xEnd = [ 0.200000, 0.300000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = B3 xStart = [ 0.200000, 0.300000, 0.000000 ] xEnd = [ 0.000000, 0.300000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = B4 xStart = [ 0.000000, 0.300000, 0.000000 ] xEnd = [ 0.000000, 0.000000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = B0 xStart = [ 0.000000, 0.000000, 0.000000 ] xEnd = [ 0.100000, 0.250000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = B1 xStart = [ 0.100000, 0.250000, 0.000000 ] xEnd = [ 0.200000, 0.000000, 0.000000 ] \end{END_POINTS_LINE} \end{OUTER_BOUNDARY} \end{MODEL} \end{FILE} ```
andrewwinters5000 commented 1 month ago
triangle_domain
hejfil commented 1 month ago

Thank you very much for your answer. It is valuable advice to reorder outlines and it helped quite a lot in this case I think. Unfortunately I have some other difficulties.

1) Is it possible to somehow have constant division of boundary lines? 2) I have U polygon and some triangles are missing in the mesh. What am I doing wrong if I can ask?

image

testU.control.txt

andrewwinters5000 commented 1 month ago

Sharp corners are always tricky, especially when I see the scale you are working with in this domain. The scaling combined with the tolerances in the minimization algorithm to find the closest boundary point might be causing issues. My best advice would be to try adding manual refinement regions in the trouble areas and/or adjust the background grid size slightly. For instance, when I run your control file with

background grid size = [0.0075000, 0.0075000, 0.0 ]                                                                              

the mesh is better, although some of the corner elements may still need adjusted to avoid very oblique / acute angles.

Screenshot 2024-05-02 at 19 18 43
andrewwinters5000 commented 21 hours ago

We have added a feature where a symmetric mesh can be created by defining half of the model / domain, labeling one (or several co-linear) straight sided outer boundaries with the name :symmetry, and then HOHQMesh will create a symmetric mesh about the indicated line. For more details see the docs or the new tutorial in HOHQMesh.jl.

Below I attach an example of such a control file as well as the resulting mesh.

triangle_spike_symmetric.control ``` \begin{CONTROL_INPUT} \begin{RUN_PARAMETERS} plot file name = triangle_splike.tec mesh file name = triangle_splike.mesh stats file name = triangle_splike.txt mesh file format = ISM polynomial order = 4 plot file format = skeleton \end{RUN_PARAMETERS} \begin{BACKGROUND_GRID} background grid size = [0.10000, 0.10000, 0.000000 ] \end{BACKGROUND_GRID} \begin{SPRING_SMOOTHER} smoothing = ON smoothing type = LinearAndCrossbarSpring number of iterations = 25 \end{SPRING_SMOOTHER} \end{CONTROL_INPUT} \begin{MODEL} \begin{OUTER_BOUNDARY} \begin{END_POINTS_LINE} name = B2 xStart = [ 0.200000, 0.000000, 0.000000 ] xEnd = [ 0.200000, 0.300000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = B3 xStart = [ 0.200000, 0.300000, 0.000000 ] xEnd = [ 0.100000, 0.300000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = :symmetry xStart = [ 0.100000, 0.300000, 0.000000 ] xEnd = [ 0.100000, 0.250000, 0.000000 ] \end{END_POINTS_LINE} \begin{END_POINTS_LINE} name = B1 xStart = [ 0.100000, 0.250000, 0.000000 ] xEnd = [ 0.200000, 0.000000, 0.000000 ] \end{END_POINTS_LINE} \end{OUTER_BOUNDARY} \end{MODEL} \end{FILE} ```
andrewwinters5000 commented 21 hours ago

triangle_spike_symmetric