trixi-framework / HOHQMesh

High Order Hex-Quad Mesh (HOHQMesh) package to automatically generate all-quadrilateral meshes with high order boundary information.

Home Page:https://trixi-framework.github.io/HOHQMesh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can HOHQMesh support multiple domains?

TangLaoya opened this issue · comments

Dear developer,
I have another requirement: I need to generate meshes for multiple domains. I need to generate meshes for all domains with their interfaces, and then assign different materials with different domains, not just an outer boundary with multiple inner boundaries with holes. Can your HOHQMesh support this kind of multiple domains?

Thanks & Happy New Year,
Tang Laoya

Ah yes, that capability is in there, but as I noted in the other thread, the meshes thus generated were rather poor. I also have not maintained that capability in a while. If there is significant interest, I can revisit it.

Dear David,
Thank you very much for your kindly reply. Is there any input example to show that capability? I wish I can have change to test it.

Thanks,
Tang Laoya

Let me look. I'll want to try out to see if i haven't messed something up over the last several changes. Like I said, this is something I put in about seven years ago, but have not maintained. Give me a couple of days, though to get back to you.

Oh my god! 7 years ago!!! What I am doing at that day? :)

As I suspected, the code has a segmentation fault when I run a simple case. That will take a while to track down, as you see we have a number of pull requests out there right now, and I have a couple of other things that I am doing, including a decline before the end of the month. I'm attaching an example control file to give you an idea of what it looks like.

%
% ------------------------------------------------------------------
% Control file for two materials embedded in a background material.
% ------------------------------------------------------------------
%
% -------------
% Control Block
% -------------
%
\begin{CONTROL_INPUT}
%
% Plot and stats file names can be "none" if no output
% is desired.
%
\begin{RUN_PARAMETERS}
mesh file name = MeshFiles/BoneAndMarrow.mesh
plot file name = PlotFiles/BoneAndMarrow.tec
stats file name = Statistics/BoneAndMarrow.txt
mesh file format = ISM
polynomial order = 5
plot file format = skeleton
\end{RUN_PARAMETERS}

\begin{MESH_PARAMETERS}
element type = quad
\end{MESH_PARAMETERS}

\begin{BACKGROUND_GRID}
x0 = [-10.0, -10.0, 0.0]
dx = [1.0, 1.0, 1.0]
N = [20, 20, 0]
\end{BACKGROUND_GRID}

\begin{MATERIALS}
background Material name = Muscle
\end{MATERIALS}
%
% Spring smoother parameters are pretty standard after lots
% of trials.
%
\begin{SPRING_SMOOTHER}
smoothing type = LinearAndCrossBarSpring
number of iterations = 25
\end{SPRING_SMOOTHER}

\end{CONTROL_INPUT}
%
% -----------
% Model Block
% -----------
%
\begin{MODEL}
%
% If an outer boundary is not specified, then it is assumed to be a box
% the outer boundary is implicitly a CHAIN. There is only one. Curves
% implemented are SPLINE_CURVE, END_POINTS_LINE, PARAMETRIC_EQUATION_CURVE
%
%
% There are an arbitrary number of inner boundaries.
% Each is a chain of curves, even if there is only
% one curve in the chain.
%
\begin{INTERFACE_BOUNDARIES}

   \begin{CHAIN}
      name = Bone
      \begin{PARAMETRIC_EQUATION_CURVE}
         name = Circle1
         xEqn = f(t) = 6.5*cos(2*pi*t)
         yEqn = f(t) = 6.5*sin(2*pi*t)
         zEqn = z(t) = 0.0
      \end{PARAMETRIC_EQUATION_CURVE}
   \end{CHAIN}

   \begin{CHAIN}
      name = Marrow
      \begin{PARAMETRIC_EQUATION_CURVE}
         name = Circle2
         xEqn = f(t) = 1.5 + 1.5*cos(2*pi*t)
         yEqn = f(t) = 1.5*sin(2*pi*t)
         zEqn = z(t) = 0.0
      \end{PARAMETRIC_EQUATION_CURVE}
   \end{CHAIN}
  
\end{INTERFACE_BOUNDARIES}

\end{MODEL}
\end{FILE}

Dear David,
Thank you very much for providing so beautiful control file. I have successfully get the meshes just by modified two locations:

MeshGeneratorMethods.f90->SUBROUTINE GenerateQuadMeshFromGrid
IF( numberOfBoundaries > 0 ) THEN
! Tang Laoya @01/06/2022
if(allocated(aPointInsideTheCurve))deallocate(aPointInsideTheCurve)
if(allocated(curveTypeForID))deallocate(curveTypeForID)
ALLOCATE( aPointInsideTheCurve(3,numberOfBoundaries) )
ALLOCATE( curveTypeForID(numberOfBoundaries) )
CALL flagBoundaryTypes
END IF

MeshGeneratorMethods.f90->SUBROUTINE GenerateQuadMeshFromGrid
IF(ALLOCATED(aPointInsideTheCurve)) DEALLOCATE(aPointInsideTheCurve)
! Zhanghong Tang@01/06/2022
!IF(ALLOCATED(curveTypeForID)) DEALLOCATE(curveTypeForID)

Now I still have two questions:

  1. how to define materials in different domains?
  2. how to define outer boundary for this control? I modified the control file as follows, but the program crashed.

Thanks,
Tang Laoya

%
% ------------------------------------------------------------------
% Control file for two materials embedded in a background material.
% ------------------------------------------------------------------
%
% -------------
% Control Block
% -------------
%
\begin{CONTROL_INPUT}
%
% Plot and stats file names can be "none" if no output
% is desired.
%
\begin{RUN_PARAMETERS}
mesh file name = Benchmarks/MeshFiles/Tests/BoneAndMarrow.mesh
plot file name = Benchmarks/PlotFiles/Tests/BoneAndMarrow.tec
stats file name = Benchmarks/StatsFiles/Tests/BoneAndMarrow.txt
mesh file format = ISM
polynomial order = 5
plot file format = skeleton
\end{RUN_PARAMETERS}

\begin{MESH_PARAMETERS}
element type = quad
\end{MESH_PARAMETERS}

\begin{BACKGROUND_GRID}
x0 = [-10.0, -10.0, 0.0]
dx = [1.0, 1.0, 1.0]
N = [20, 20, 0]
\end{BACKGROUND_GRID}

\begin{MATERIALS}
background Material name = Muscle
\end{MATERIALS}
%
% Spring smoother parameters are pretty standard after lots
% of trials.
%
\begin{SPRING_SMOOTHER}
smoothing type = LinearAndCrossBarSpring
number of iterations = 25
\end{SPRING_SMOOTHER}

\end{CONTROL_INPUT}
%
% -----------
% Model Block
% -----------
%
\begin{MODEL}
%
% If an outer boundary is not specified, then it is assumed to be a box
% the outer boundary is implicitly a CHAIN. There is only one. Curves
% implemented are SPLINE_CURVE, END_POINTS_LINE, PARAMETRIC_EQUATION_CURVE
%
%
% There are an arbitrary number of inner boundaries.
% Each is a chain of curves, even if there is only
% one curve in the chain.
%
\begin{OUTER_BOUNDARY}

\begin{PARAMETRIC_EQUATION_CURVE}
name = outer
xEqn = x(t) = 14.0cos(2pit)
yEqn = y(t) = 14.0
sin(2pit)
zEqn = z(t) = 0.0
\end{PARAMETRIC_EQUATION_CURVE}

\end{OUTER_BOUNDARY}

\begin{INTERFACE_BOUNDARIES}

\begin{CHAIN}
name = Bone
\begin{PARAMETRIC_EQUATION_CURVE}
name = Circle1
xEqn = f(t) = 6.5cos(2pit)
yEqn = f(t) = 6.5
sin(2pit)
zEqn = z(t) = 0.0
\end{PARAMETRIC_EQUATION_CURVE}
\end{CHAIN}

\begin{CHAIN}
name = Marrow
\begin{PARAMETRIC_EQUATION_CURVE}
name = Circle2
xEqn = f(t) = 1.5 + 1.5cos(2pit)
yEqn = f(t) = 1.5
sin(2pit)
zEqn = z(t) = 0.0
\end{PARAMETRIC_EQUATION_CURVE}
\end{CHAIN}

\end{INTERFACE_BOUNDARIES}
\end{MODEL}
\end{FILE}

Thanks for finding that bug. What I will do is create a branch for the embedded grid, put those in and try it out. Once all this gets sorted out it can be documented and merged into the main branch.

  1. how to define materials in different domains?

That seems to be a casualty of the switch to a dictionary-based control file. We'll have to add that back in. The data structures are still all in place, and there is an ISM-MM output format still there. I envision adding a "material" keyword to the interface curve definitions (or just use the name of the curve) for the input. I'll have to remember how the materialID's used to be set. It would be done when the cookie-cutter removes quads near boundaries and determines if a node is inside or outside a boundary (or interface) curve. That's about it. Should be pretty short work.

  1. how to define outer boundary for this control? I modified the control file as follows, but the program crashed.

Obviously crashing is bad, but the BACKGROUND_GRID block needs to be changed from the version with no outer boundary to the one with an outer boundary, e.g.
\begin{BACKGROUND_GRID}
background grid size = [3.0,3.0,0.0]
\end{BACKGROUND_GRID}
If that fixes the problem, then I need to add a check on the input data so that an error is posted rather than a crash.

Dear David,
Thank you very much for your kindly reply, and thanks for your latter plan. For my second question, after I modified the BACKGROUND_GRID block, the program didn't crash, but the output mesh is wrong.

Thanks,
Tang Laoya

Unfortunately, it seems that there still is a memory issue when using the interface boundaries. The crashes are random. Worst kind to track down. I'll try the outer boundary next.

When it does run, the mesh with the outer boundary looks fine, (using a grid spacing of 1.0 as in the previous), and the inner grids look the same. Basically looks as I'd expect.

It appears to be happening in SplitInterfaceElements, which indeed does a bunch of memory manipulations. Will look at this tomorrow or the next day.

Dear David,
Thank you very much for your kindly reply. It seems that the mesh generation rely on the background grid or manual local refinement setting? Can the mesher process multi-scale input polygons, for example, the picture in your startup page of this project without manual setting of local refinement, i.e., let the mesher refine based on the quality control instead of the size control?

Thanks,
Tang Laoya

The code controls size through the sizer object. It is automatic in that it sizes the elements to accommodate the background grid size, the geometry (curvature, distance of a curve to itself and others), and manual refinement as specified. The latter is expected to only be needed in special circumstances not known to the geometry, e.g. the need to refine in a wake. The idea is to input the geometry (model) and the background grid and let the mesher determine the grid sizes. The Trixi mesh on the cover page is done like that. There is no manual refinement used there.

I can't say if it is possible to do refinement based on element quality, since I haven't though about that. The algorithm used is not set up that way. It generates elements, then you determine quality. There is no feedback loop. That's the way it is now.

Dear David,
Thank you very much for your kindly reply.
Do you mean that your algorithm deeply relies on the background grid, instead of meshing by somewhat like the paving algorithm? Let me understand, the algorithm first construct initial meshes basing on the background grid (including refined background grid specified by manual), and then snap grid onto boundaries, smooth meshes, and then remove the meshes outside boundaries? That's a good idea and the mesh could be very fast. But I don't know whether it can work or not for complex geometries, especially multi-scaled geometries.

Thanks,
Tang Laoya

Dear David,
Sorry to bother you. I constructed interesting polygon examples of 'dog' and 'tiger', it will take long time to generate the meshes even I removed the inner boundaries. For the 'dog', If the inner boundaries are here, the mesher failed and for the 'tiger', it shows that the mesh failed. Could you please help me to take a look at what's the problem in the control file?

Thanks,
Tang Laoya
dog.zip
tiger.zip

Dear David,
Sorry to bother you again. Here I attached another control file that include multi-scaled structure. It has run for more than 4 hours and memory usage is about 60 GB, but still hasn't got a result. Could you please help me to take a look at it?

Thanks,
Tang Laoya
test4.zip

You are specifying a background grid size of 0.5, but your geometry has length scales of 10^-6. That will cause problems. I'd suggest scaling the domain.

The discussion has gotten off topic (does HOHQMesh handle multiple materials), so I will close this soon. The answer is not yet, but I have created a branch to debug that feature that has never been advertised. You have raised two other points that I will add to the list of tasks. One is that the code uses curvature to subdivide, but does not use curve length for straight sides. The other is that we've never looked at the rounding error/scale interactions.

Oh, I am sorry latter I will create new topic if it is not the same one. I wish I can involve the coding and study something.

Thanks,
Tang Laoya