FloSewn / TQMesh

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

multi subdomains merge issue #26

Closed danielsue closed 3 months ago

danielsue commented 5 months ago

Hi @FloSewn,

Sorry for bothering you again. I have questions regarding multi subdomains meshing. It looks to me some of the parameters are shared from former subdomain to the latter subdomains. For example, if I have two subdomains, each with same number of quad refinements, but the former one will be refined twice and the mesh is merged to the latter one, though different output file prefixes are provided.

Attached is the detail job scripts I have used for four subdomains (with subdomain 3 and 4 commented for test purpose)

#===========================================================
#                         TQMESH
#===========================================================

#-----------------------------------------------------------
#                     MESH DEFINITION - SUBDOMAIN 1
#-----------------------------------------------------------
Define mesh:
  Element size: 4
  Element color: 1
  Meshing algorithm: Tri-to-Quad       #Triangulation, Tri-to-Quad
  Number of quad refinements: 1        #1
  Smooth quad layers: 0
  Number of smoothing iterations: 2

  # Output formats: COUT, TXT, VTU
  Output file format: VTU
  Output file prefix: ./frac2d-quad-multi-zone-1

  Define exterior boundary:
    0.0,      -200.0,    1
    58.72267, -200.0,    1
    65.19421, -71.77164, 1
    29.95778, 0.0,       1
    0.0,      0.0,       1
  End exterior boundary

  #---------------------------------------------------------
  #                       QUAD-LAYERS
  #---------------------------------------------------------
  Add quad layers: 58.72267, -200.0, 29.95778, 0.0, 4, 0.1, 1.25

End mesh

#-----------------------------------------------------------
#                     MESH DEFINITION - SUBDOMAIN 2
#-----------------------------------------------------------
Define mesh:
  Element size: 4
  Element color: 1
  Meshing algorithm: Tri-to-Quad       #Triangulation, Tri-to-Quad
  Number of quad refinements: 1        #1
  Smooth quad layers: 0
  Number of smoothing iterations: 2

  # Output formats: COUT, TXT, VTU
  Output file format: VTU
  Output file prefix: ./frac2d-quad-multi-zone-2

  Define exterior boundary:
    29.95778, 0.0,       2
    65.19421, -71.77164, 2
    68.81645, 0.0,       2
  End exterior boundary

  #---------------------------------------------------------
  #                       QUAD-LAYERS
  #---------------------------------------------------------
  Add quad layers: 29.95778, 0.0, 68.81645, 0.0, 4, 0.1, 1.25

End mesh

##-----------------------------------------------------------
##                     MESH DEFINITION - SUBDOMAIN 3
##-----------------------------------------------------------
#Define mesh:
#  Element size: 4
#  Element color: 1
#  Meshing algorithm: Tri-to-Quad       #Triangulation, Tri-to-Quad
#  Number of quad refinements: 1        #1
#  Smooth quad layers: 0
#  Number of smoothing iterations: 2
#
#  # Output formats: COUT, TXT, VTU
#  Output file format: VTU
#  Output file prefix: ./frac2d-quad-multi-zone-3
#  
#  Define exterior boundary:
#    58.72267, -200.0,    3
#    100.0,    -200.0,    3
#    100.0,    -142.6661, 3
#    65.19421, -71.77164, 3
#  End exterior boundary
#  
#  #---------------------------------------------------------
#  #                       QUAD-LAYERS
#  #---------------------------------------------------------
#  Add quad layers: 100.0, -142.6661, 58.72267, -200.0, 4, 0.1, 1.25
#
#End mesh
#
##-----------------------------------------------------------
##                     MESH DEFINITION - SUBDOMAIN 4
##-----------------------------------------------------------
#Define mesh:
#  Element size: 4
#  Element color: 1
#  Meshing algorithm: Tri-to-Quad       #Triangulation, Tri-to-Quad
#  Number of quad refinements: 1        #1
#  Smooth quad layers: 0
#  Number of smoothing iterations: 2
#
#  # Output formats: COUT, TXT, VTU
#  Output file format: VTU
#  Output file prefix: ./frac2d-quad-multi-zone-4
#  
#  Define exterior boundary:   
#    65.19421, -71.77164, 4
#    100.0,    -142.6661, 4
#    100.0,    0,0,       4
#    68.81645, 0.0,       4
#  End exterior boundary
#  
#  #---------------------------------------------------------
#  #                       QUAD-LAYERS
#  #---------------------------------------------------------
#  Add quad layers: 68.81645, 0.0, 100.0, -142.6661, 4, 0.1, 1.25
#
#End mesh

When I separated subdomains from each other, the mesh looks good. The discretization at the shared internal boundary are a bit different, which is probably due to the difference in cell size calculation for the local subdomain. This is not a problem as the it can be fixed by explicitly specified coordinates. However, the refinement for subdomain 1 has been done twice, if I mesh subdomain 1 and subdomain 2 together, and the output in frac2d-quad-multi-zone-2 contains both subdomain 1 and 2.

Would you please let me know if this is a bug or if I didn't use it properly?

Figure Left: mesh each subdomain separately, Figure Right: mesh subdomain 1 and 2 together

Screen Shot 2024-04-09 at 8 51 42 PM

Thanks,

Daniel

FloSewn commented 5 months ago

Hey Daniel,

don't worry about asking questions - I am happy to hear that you might find this little project useful! That's a really interesting mesh configuration.

The behavior you see is as I would expect it - the quad refinement operation is applied to each mesh separately before the next mesh in your parameter file will be constructed.

In order to obtain a uniform refinement you need to set the number of quad refinements only for the last mesh to a value larger than zero:

#===========================================================
#                         TQMESH
#===========================================================

#-----------------------------------------------------------
#                     MESH DEFINITION - SUBDOMAIN 1
#-----------------------------------------------------------
Define mesh:
  Element size: 4
  Element color: 1
  Meshing algorithm: Tri-to-Quad       #Triangulation, Tri-to-Quad
  Number of quad refinements: 0        #1
  Smooth quad layers: 0
  Number of smoothing iterations: 2

  # Output formats: COUT, TXT, VTU
  Output file format: VTU
  Output file prefix: ./frac2d-quad-multi-zone-1

  Define exterior boundary:
    0.0,      -200.0,    1
    58.72267, -200.0,    1
    65.19421, -71.77164, 1
    29.95778, 0.0,       1
    0.0,      0.0,       1
  End exterior boundary

  #---------------------------------------------------------
  #                       QUAD-LAYERS
  #---------------------------------------------------------
  Add quad layers: 58.72267, -200.0, 29.95778, 0.0, 4, 0.1, 1.25

End mesh

#-----------------------------------------------------------
#                     MESH DEFINITION - SUBDOMAIN 2
#-----------------------------------------------------------
Define mesh:
  Element size: 4
  Element color: 1
  Meshing algorithm: Tri-to-Quad       #Triangulation, Tri-to-Quad
  Number of quad refinements: 2        #1
  Smooth quad layers: 0
  Number of smoothing iterations: 2

  # Output formats: COUT, TXT, VTU
  Output file format: VTU
  Output file prefix: ./frac2d-quad-multi-zone-2

  Define exterior boundary:
    29.95778, 0.0,       2
    65.19421, -71.77164, 2
    68.81645, 0.0,       2
  End exterior boundary

  #---------------------------------------------------------
  #                       QUAD-LAYERS
  #---------------------------------------------------------
  Add quad layers: 29.95778, 0.0, 68.81645, 0.0, 4, 0.1, 1.25

End mesh

However, when load the resulting mesh into Paraview, I need to disable the "max_angle" cell array, because it seems that some NaN values are written to it. That's probably related to the really high aspect ratios - but I should definitely fix this bug soon.

I hope this helps you out. If not - feel free to ask any further questions! :-)

Thanks again for your interest.

Regards Flo

danielsue commented 5 months ago

Hi @FloSewn, thanks for your support. Much appreciated. It would be great if the parameter veintersection can be passed from the input file. The default value 0.01 is used in the code. When user specify quad layer height less than 0.01*cellSize, it is very likely to generate some long-narrow cells. After reducing the value to 0.001 or 0.0001, a much smaller quad layer height can be support. Thanks again and best regards, Daniel

FloSewn commented 5 months ago

Hey Daniel,

thanks for that hint and your idea! I will try to implement this for the next release.

Best regards Flo

FloSewn commented 3 months ago

Hello Daniel,

The parameter ve_intersection_ has been removed in the newest release v1.3.2. Thanks again for your help!

Greetings Flo