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

bugs in INTERFACE_BOUNDARIES? #90

Open TangLaoya opened 4 months ago

TangLaoya commented 4 months ago

Dear developers,

I am trying to use the INTERFACE_BOUNDARIES to generate meshes with multiple domains. I used the example given in the last of 'the-model.md' (just replaced the INNER_BOUNDRIES to INTERFACE_BOUNDARIES, see attachment 'interfaceboundary.control'), the mesh is error. Could you please help me to take a look at it?

BTW: I usually use the polygons as input, such as 'test.off' attached, how to use 'SPLINE_CURVE' input these polyons (just segments instead of curves)?

Thanks,

Tang Laoya

test.zip

andrewwinters5000 commented 4 months ago

What type of error occurs? For example, is it an issue parsing the control file or the nesting of the embedded objects?

If you want to build polygons with straight sides it will probably be easier to use END_POINTS_LINE to connect the polygon corners. In doing so, the straight line "curves" must be added in counter-clockwise order. As an example, below is a code snippet to create an inner boundary chain for a triangle with corner points $(-2.3, -1)$, $(-1.7, -1)$ and $(-2,-0.4)$.

      \begin{CHAIN}
         name = inner_curve
            \begin{END_POINTS_LINE}
               name = triangle
               xStart = [-2.3,-1.0,0.0]
               xEnd = [-1.7,-1.0,0.0]
            \end{END_POINTS_LINE}
            \begin{END_POINTS_LINE}
               name = triangle
               xStart = [-1.7,-1.0,0.0]
               xEnd = [-2.0,-0.4,0.0]
            \end{END_POINTS_LINE}
            \begin{END_POINTS_LINE}
               name = triangle
               xStart = [-2.0,-0.4,0.0]
               xEnd = [-2.3,-1.0,0.0]
            \end{END_POINTS_LINE}
      \end{CHAIN}
TangLaoya commented 4 months ago

Display ' For some reason an interface element has no interface nodes!' when running. And the output mesh is like this:

image

TangLaoya commented 4 months ago

The method you provide to input straight line is just like the issue #31 I posted before, it will take a long time and huge memory.

Thanks.

TangLaoya commented 4 months ago

the time spending function is here (for the case test.off): OuterToInnerboundaryDistances

  DO j = 1, N ! N=989
         DO i = 1, nSegments  ! nSegments  = 257
            DO k = 1, numberOfInsideBoundaries
               DO l = 1, innerSegmentedCurveChain % curveCount()
                  DO m = 1, innerSegment % COUNT()
andrewwinters5000 commented 4 months ago

BTW: I usually use the polygons as input, such as 'test.off' attached, how to use 'SPLINE_CURVE' input these polyons (just segments instead of curves)?

After plotting the first two faces from the .off file you provided, see attached figure for reference, revealed that these boundary curves are quite complicated. To create inner boundary chains would likely require an intricate mixture of splines and straight lines. These boundary chain would need to be "hand rolled" by the user. There is no in-built mechanism in HOHQMesh that can parse this information and form the boundary curves automatically. For a SPLINE_CURVE one needs to create parametric spline segments from the given data points and then chain everything together in counter-clockwise order.

There are also many intricate features on these boundary curves, which will likely require the definition of local refinement centers / lines from the control file. The automatic sizing functionality in HOHQMesh uses the background grid to seed how small elements can become. The default sizer only allows up to 8 levels of refinement before a warning is thrown.

Screenshot 2024-02-21 at 11 03 12
TangLaoya commented 4 months ago

Dear andrewwinters5000,

Thank you very much for your kindly reply. Yes, the inner boundaries I studied are very complicated. I need mesh all the domains inside the outer boundary, with the complicated inner (interface) boundaries.

1) Do you mean that ALL polygons should be counter-clockwise order, no matter whether they are filled or hollowed? In HOHQMesh you use 'INTERFACE_BOUNDARIES' to indicate that they are filled and 'INNER_BOUNDARIES' to indicate that they are hollowed?

2) if I can chain everything together in counter-clockwise order, how to use SPLINE_CURVE to input inner/interface boundaries, could you please give me a very simple example?

3) for 'only allows up to 8 levels of refinement', can I overcome this problem by increase the number of levels or use a smaller background mesh?

Thanks,

Tang Laoya

andrewwinters5000 commented 4 months ago
  • Do you mean that ALL polygons should be counter-clockwise order, no matter whether they are filled or hollowed? In HOHQMesh you use 'INTERFACE_BOUNDARIES' to indicate that they are filled and 'INNER_BOUNDARIES' to indicate that they are hollowed?

All curves, whether they are OUTER_BOUNDARY, INTERFACE_BOUNDARIES or INNER_BOUNDARIES must have counter-clockwise orientation for the algorithms to work properly.

  • if I can chain everything together in counter-clockwise order, how to use SPLINE_CURVE to input inner/interface boundaries, could you please give me a very simple example?

Here is an example of an INNER_BOUNDARIES block with a single CHAIN that connects an END_POINTS_LINE to a CIRCULAR_ARC to a SPLINE defined by 5 data points.

   \begin{INNER_BOUNDARIES}
      \begin{CHAIN}
         \begin{END_POINTS_LINE}
            name = Line1
            xStart = [0.0,-7.0,0.0]
            xEnd = [5.0,3.0,0.0]
         \end{END_POINTS_LINE}
         \begin{CIRCULAR_ARC}
            name = Arc
            units = degrees
            radius = 5.0
            start angle = 0.0
            center = [0.0,3.0,0.0]
            end angle = 180.0
         \end{CIRCULAR_ARC}
         \begin{SPLINE_CURVE}
            name = Spline
            nKnots = 5
            \begin{SPLINE_DATA}
                0.0 -5.0 3.0 0.0
                0.25 -2.0 1.0 0.0
                0.5 -4.0 0.5 0.0
                0.75 -2.0 -3.0 0.0
                1.0 0.0 -7.0 0.0
            \end{SPLINE_DATA}
         \end{SPLINE_CURVE}
      \end{CHAIN}
   \end{INNER_BOUNDARIES}
  • for 'only allows up to 8 levels of refinement', can I overcome this problem by increase the number of levels or use a smaller background mesh?

Yes, one can use the input flag -sLimit when running HOHQMesh to dictate the number of refinement levels, e.g.,

./HOHQMesh -sLimit 9 -f <pathToControlFile>

would increase the allowed number of refinement levels to 9.

andrewwinters5000 commented 4 months ago

Display ' For some reason an interface element has no interface nodes!' when running.

The problem is that the combination of the background grid size and automatic sizing has trouble resolving the small circular internal boundaries. I added a few REFINEMENT_CENTERS manually located at the center of each interior circle and the output from HOHQMesh no longer throws this warning (and the mesh statistics are better). I include the modified control file below as well as a similar figure to your previous post.

interfaceboundary.control ``` \begin{CONTROL_INPUT} \begin{RUN_PARAMETERS} mesh file name = interfaceboundary.mesh plot file name = interfaceboundary.tec stats file name = interfaceboundary.mesh mesh file format = ISM polynomial order = 4 plot file format = skeleton \end{RUN_PARAMETERS} \begin{BACKGROUND_GRID} background grid size = [2.0, 2.0, 0.0] \end{BACKGROUND_GRID} \begin{SPRING_SMOOTHER} smoothing = ON smoothing type = LinearAndCrossbarSpring number of iterations = 25 \end{SPRING_SMOOTHER} % % Manual local refinement % \begin{REFINEMENT_REGIONS} \begin{REFINEMENT_CENTER} type = smooth x0 = [-10.25,3.0,0.0] h = 0.1 w = 0.5 \end{REFINEMENT_CENTER} \begin{REFINEMENT_CENTER} type = smooth x0 = [-5.1,-4.1,0.0] h = 0.3 w = 1.5 \end{REFINEMENT_CENTER} \begin{REFINEMENT_CENTER} type = smooth x0 = [-12.0,-0.5,0.0] h = 0.15 w = 1.0 \end{REFINEMENT_CENTER} \end{REFINEMENT_REGIONS} \end{CONTROL_INPUT} \begin{MODEL} \begin{OUTER_BOUNDARY} \begin{PARAMETRIC_EQUATION_CURVE} name = outer xEqn = x(t) = 14.0*cos(2*pi*t) yEqn = y(t) = 14.0*sin(2*pi*t) zEqn = z(t) = 0.0 \end{PARAMETRIC_EQUATION_CURVE} \end{OUTER_BOUNDARY} % % Inner boundaries, if any, are any number of chains % of curves. Each inner boundary is defined within a CHAIN. % \begin{INTERFACE_BOUNDARIES} \begin{CHAIN} name = Boundary1 \begin{PARAMETRIC_EQUATION_CURVE} name = Circle1 xEqn = f(t) = -10.25 + 0.2*cos(2*pi*t) yEqn = f(t) = 3.0 + 0.2*sin(2*pi*t) zEqn = z(t) = 0.0 \end{PARAMETRIC_EQUATION_CURVE} \end{CHAIN} \begin{CHAIN} name = Boundary2 \begin{PARAMETRIC_EQUATION_CURVE} name = Circle2 xEqn = f(t) = -5.1 + 1.0*cos(2*pi*t) yEqn = f(t) = 1.0*sin(2*pi*t) - 4.1 zEqn = z(t) = 0.0 \end{PARAMETRIC_EQUATION_CURVE} \end{CHAIN} \begin{CHAIN} name = Boundary3 \begin{PARAMETRIC_EQUATION_CURVE} name = Circle3 xEqn = f(t) = -12.0 + 0.5*cos(2*pi*t) yEqn = f(t) = 0.5*sin(2*pi*t) - 0.5 zEqn = z(t) = 0.0 \end{PARAMETRIC_EQUATION_CURVE} \end{CHAIN} \end{INTERFACE_BOUNDARIES} \end{MODEL} \end{FILE} ```
Screenshot 2024-02-21 at 12 09 24
TangLaoya commented 4 months ago

Referen

\begin{SPLINE_CURVE}
            name = Spline
            nKnots = 5
            \begin{SPLINE_DATA}
                0.0 -5.0 3.0 0.0
                0.25 -2.0 1.0 0.0
                0.5 -4.0 0.5 0.0
                0.75 -2.0 -3.0 0.0
                1.0 0.0 -7.0 0.0
            \end{SPLINE_DATA}

Thank you very much, this part is just what I want to know. Do you mean that if I have N discrete points to form a polygon, the first number of every line should be 0, 1/N, 2/N, ..., 1? By this way (together with nKnots =5) I can keep the input polygons are straight lines instead of curves?

Thanks,

Tang Laoya

andrewwinters5000 commented 4 months ago

Do you mean that if I have N discrete points to form a polygon, the first number of every line should be 0, 1/N, 2/N, ..., 1?

Yes, this is one way to create the parametric variable t needed by the SPLINE data of the form t x y z. One small note if you would have step size 1/N if you have N+1 points as in the example where nKnots = 5 such that N = 4 and the stepsize for t was 1/N = 1/4.

TangLaoya commented 4 months ago

Thank you very much for your kindly remind. just now I set an error nKnots, but even I correct it, the program still display error message, could you please help me to take a look at it?

Thanks,

Tang Laoya testoff.zip

andrewwinters5000 commented 4 months ago

You can only have a single INNER_BOUNDARIES block, i.e., the control file should only have one instance of \BEGIN{INNER_BOUNDARIES} and \END{INNER_BOUNDARIES} each of the inner boundary curves are a CHAIN, which you already have. The error that gets thrown is that the subdivision level exceeds the allowed limit. Because your mesh features are quite small I would suggest only including the OUTER_BOUNDARY and a single inner boundary first to determine the resolution required. Jumping in directly to mesh the domain with all 20 internal faces could prove difficult.

Also, your stats file and mesh file output have the same name, which might cause a conflict.

DavidAKopriva commented 4 months ago

You don't want to define the boundaries as polygons as one would for a FEM mesh. HOHQMesh is designed for generating meshes for high order methods, and higher order boundary curves than usual low order FEMs. Because HOMs are sensitive to singularities, even in curvature, HOHQMesh tries to put an element corner at every joint so that the joint singularities are not straddled by high order polynomials. Making chains of large numbers of small straight line segments makes that impossible. Instead, you want to define your boundaries as "large" segments of smooth curves with few joints. You probably want to use splines for those chains of piecewise linear curves. You should check the manual for how the splines are defined, but the first argument is the parametrization for the spline, i.e. \vec x = \vec S(t). It is traditional (though recent work of Sherwin's group suggests it's not optimal) to parametrize by arc length. My book discusses this, but for straight line segments it is easy to get the length of each segment to compute the location of a node as the fraction along the total length of the curve. If you want to define your boundaries as polygonal with large numbers of straight line segments, the you should use a FEM mesh generator.

TangLaoya commented 4 months ago

You can only have a single INNER_BOUNDARIES block, i.e., the control file should only have one instance of \BEGIN{INNER_BOUNDARIES} and \END{INNER_BOUNDARIES} each of the inner boundary curves are a CHAIN, which you already have. The error that gets thrown is that the subdivision level exceeds the allowed limit. Because your mesh features are quite small I would suggest only including the OUTER_BOUNDARY and a single inner boundary first to determine the resolution required. Jumping in directly to mesh the domain with all 20 internal faces could prove difficult.

Also, your stats file and mesh file output have the same name, which might cause a conflict.

Dear andrewwinters5000,

Thank you very much for your kindly remind. After decreased the number of 'INNER_BOUNDARIES' to 1, the program can work now, but after a long time it displayed the following error:

 **************************************************************************
 It appears that an edge is not connected
 Plot the file 'DebugPlot.tec' to see where additional resolution is needed
 **************************************************************************

Meshing Terminated. See stderr

and the test files and output files are attached. Could you please give me some hint on how to check the disconnected edges according to the output information (althrough I think the input is correct :) )?

Thanks,

Tang Laoya

testoff.zip

TangLaoya commented 4 months ago

You can only have a single INNER_BOUNDARIES block, i.e., the control file should only have one instance of \BEGIN{INNER_BOUNDARIES} and \END{INNER_BOUNDARIES} each of the inner boundary curves are a CHAIN, which you already have. The error that gets thrown is that the subdivision level exceeds the allowed limit. Because your mesh features are quite small I would suggest only including the OUTER_BOUNDARY and a single inner boundary first to determine the resolution required. Jumping in directly to mesh the domain with all 20 internal faces could prove difficult.

Also, your stats file and mesh file output have the same name, which might cause a conflict.

Dear andrewwinters5000,

Further tests show that if I only keep the out_boundary, the program return the wrong mesh (I also changed 'polynomial order = 1').

The test file is attached.

Thanks,

Tang Laoya

testoff.zip

andrewwinters5000 commented 4 months ago

Further tests show that if I only keep the out_boundary, the program return the wrong mesh (I also changed 'polynomial order = 1').

It is hard to say what is going wrong. With fine features you may need to add manual refinement centers based on the problematic areas you can identify when you plot the DebugPlot.tec file. The first thing I would double check is that the nodes for your spline are correct, e.g., checking that there are no duplicates.