question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mesh generation with overlapping geometries

See original GitHub issue

Describe the bug Hi Robbie

I’ve been playing around with how merging sections works and noted a few odd things happening that may either be bugs or simply limitations in the code or the way geometry can be merged that might need further investigation or at a the very least some additional coverage in the documentation if these are limitations.

Merging two geometries where they are touching or overlapping has mixed effects on the mesh generated. API documentation seems to only briefly discuss/note that overlapping geometries can be merged and cleaning the geometry will attempt to fix any issues with the mesh. I have noted in testing some scenarios that the mesh seems to be created but seems to bug out a bit and assume this is not intended!

Consider the following 4 scenarios which might cover practical use cases for generating merged sections to demonstrate the varying results in the mesh being generated:-

  1. If the two geometries just touch, and no closed regions are created the mesh seems to be generated as intended. Assuming this is the intended behaviour. Figure_1
  2. If the two geometries just overlap, say one goes into the other by 5mm, the mesh seems to be created ok, with facets on the lines of overlap. Assuming this is the intended behaviour. Though see point on the control point in 3 below as may also trigger incorrect mesh if control point is in the overlap region. Figure_2
  3. If the two geometries fully overlap such that part of the geometry completely crosses the other, the mesh seems to bug out as shown in this screenshot. Assuming either this is a bug or simply not possible to generate geometry like this. In practice you might use this method to model plates on either side of a central plate to simply generating the model. But might need to be split into another geometry for each projection, or add documentation around this limitation? I am assuming its something to do with there being no control point within one ‘part’ of the section as the mesh seems ok within the regions with the control point specified (similar to what was discussed in #1) Figure_3
  4. If the two geometries are merged such that a closed internal ‘hole’ is created, again the meshing seems to bug out and takes the closed region as being solid. There does not seem to be any way to account for the hole being a hole. Again the mesh seems to bug out with a larger mesh in the hole region. I assume this is not intended, nor does there seem to be any practical way to join predefined sections with the formation of a hole and get the code to treat it as a hole. I assume in this case the only way to do it would be to generate the whole thing as one custom section and define the hole? Or is there something I’m missing here to get it working as intended? Figure_4

To Reproduce Run the code below to demonstrate all 4 scenarios:

import sectionproperties.pre.sections as sections
from sectionproperties.analysis.cross_section import CrossSection

# Scenario 1 - just touching, assume this is intended behaviour regarding meshing
geometry1 = sections.AngleSection(d=150, b=100, t=8, r_r=12, r_t=5, n_r=16, shift=[230, 200])
geometry1.rotate_section(angle=180, rot_point=[230, 200])
geometry2 = sections.ISection(d=250, b=250, t_f=20, t_w=10, r=10, n_r=10)
geometry = sections.MergedSection([geometry1, geometry2])
geometry.clean_geometry(verbose=True)
mesh = geometry.create_mesh(mesh_sizes=[5, 5])
section = CrossSection(geometry, mesh)
section.display_mesh_info()
section.plot_mesh()

# Scenario 2 - slightly overlapping, assume this is the intended behaviour (provided control point is not in the overlapped region)
geometry1 = sections.AngleSection(d=150, b=100, t=8, r_r=12, r_t=5, n_r=16, shift=[223, 200])
geometry1.rotate_section(angle=180, rot_point=[223, 200])
geometry2 = sections.ISection(d=250, b=250, t_f=20, t_w=10, r=10, n_r=10)
geometry = sections.MergedSection([geometry1, geometry2])
geometry.clean_geometry(verbose=True)
mesh = geometry.create_mesh(mesh_sizes=[5, 5])
section = CrossSection(geometry, mesh)
section.display_mesh_info()
section.plot_mesh()

# Scenario 3 - two geometries completely overlapping, mesh only generated correctly within the regions with the control points?
geometry1 = sections.AngleSection(d=150, b=100, t=8, r_r=12, r_t=5, n_r=16, shift=[150, 200])
geometry1.rotate_section(angle=180, rot_point=[150, 200])
geometry2 = sections.ISection(d=250, b=250, t_f=20, t_w=10, r=10, n_r=10)
geometry = sections.MergedSection([geometry1, geometry2])
geometry.clean_geometry(verbose=True)
mesh = geometry.create_mesh(mesh_sizes=[5, 5])
section = CrossSection(geometry, mesh)
section.display_mesh_info()
section.plot_mesh()

# Scenario 4 - just touching but formation of a closed region, as no way to recognise the formation of the 'hole'?
geometry1 = sections.AngleSection(d=150, b=100, t=8, r_r=12, r_t=5, n_r=16, shift=[230, 170])
geometry1.rotate_section(angle=180, rot_point=[230, 170])
geometry2 = sections.ISection(d=250, b=250, t_f=20, t_w=10, r=10, n_r=10)
geometry = sections.MergedSection([geometry1, geometry2])
geometry.clean_geometry(verbose=True)
mesh = geometry.create_mesh(mesh_sizes=[5, 5])
section = CrossSection(geometry, mesh)
section.display_mesh_info()
section.plot_mesh()

Expected behavior Some way of accounting for these scenarios without having to resort to defining custom sections (in the case of scenario 4) or more geometry elements (in the case of scenario 3)?

Or outline any limitations in the geometry merging method in the documentation?

Desktop (please complete the following information):

  • OS: Windows 10
  • Version - latest master commit 90f8ffb485c631a0e497ae3d86a682316e0747b7

Many thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
robbievanleeuwencommented, May 6, 2019

Hi Agent6-6-6,

Thanks for looking into this. I am really at the mercy of the meshing algorithm I chose to implement when it comes to mesh generation as this is a topic that is well outside of my area of knowledge. Having said that, triangle is an excellent mesh generation tool and I am probably (almost definitely) not fully utilising its potential!

Regarding the above examples:

  1. Yes this is the intended behaviour.
  2. I wouldn’t recommend having overlapping regions, although in most cases things work out ok like in this example.
  3. This highlights one of the issues when trying to mesh overlapping regions. You’re right that you get an issue with the control points. You can try to get around this by manually adding additional control points and mesh sizes to the final geometry object but this is a bit of a hack. I would recommend modelling each region so there are no overlaps, although this may be a bit more effort in some cases.
  4. Correct, if you create a closed region the default response of the meshing algorithm will be to fill in this hole with elements. An easy workaround is to manually add a hole: geometry.add_hole([200, 100]) - you can see this in action in the example below. Although there may be some way to program a way of detecting this issue, for me at least, this is a problem that is beyond my expertise when you consider that arbitrary sections can be formed from merging an infinite number of arbitrary sub-sections. I would advise the user to check the mesh and add holes as required.

Here’s a bonus fifth scenario building on scenario four - a welded angle to i-section with variables for weld size and section separation:

import copy
import sectionproperties.pre.sections as sections
from sectionproperties.analysis.cross_section import CrossSection

# Scenario 5 - angle welded to I-section
weld_length = 6
gap = 1

# create angle and isection
angle = sections.AngleSection(d=150, b=100, t=8, r_r=12, r_t=5, n_r=16, shift=[230 - gap, 170 - gap])
angle.rotate_section(angle=180, rot_point=[230, 170])
isection = sections.ISection(d=250, b=250, t_f=20, t_w=10, r=10, n_r=10)

# create two welds at the origin
weld1 = sections.CustomSection(
	points=[[0,0], [weld_length, 0], [0, weld_length]],
	facets=[[0,1], [1,2], [2,0]],
	holes=[],
	control_points=[[weld_length / 3, weld_length / 3]]
)
weld2 = copy.deepcopy(weld1)

# assign a shift to the first weld and shift to the new lcoation
weld1.shift = [130, 170 + gap]
weld1.shift_section()

# assign a shift to the second weld and shift to the new lcoation
weld2.shift = [230 + gap, 20]
weld2.shift_section()

geometry = sections.MergedSection([angle, isection, weld1, weld2])
geometry.clean_geometry(verbose=True)
geometry.add_hole([200, 100])
geometry.plot_geometry()

mesh = geometry.create_mesh(mesh_sizes=[5, 5, 1, 1])
section = CrossSection(geometry, mesh)
section.display_mesh_info()
section.plot_mesh()

weld

0reactions
robbievanleeuwencommented, Oct 12, 2020

Also it may be because you are trying to do a draft PR? I only have a free account so it may not work:

Draft pull requests are available in public repositories with GitHub Free for organizations and legacy per-repository billing plans, and in public and private repositories with GitHub Team and GitHub Enterprise Cloud. For more information, see “GitHub’s products.”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overlapping Meshes - CentaurSoft
Overlapping meshes allow for prisms/hexahedra to grow from a certain part of a geometry, such as a flap or blade, ignoring the presence...
Read more >
Finding Intersecting Mesh
This command is useful for identifying cases where the geometry does not intersect but the mesh does. The command can find intersecting 2-dimensional...
Read more >
generate mesh from overlapping geometries - FEAssistant
Hey guys, I have some questions regarding meshing overlapped geometries. I have this geometry with two pieces: the yellow piece and the bl....
Read more >
Apparent mesh overlap in Gmsh - CFD Online
Hi I am trying to create a simple geometry and mesh it. ... there seems to be an overlap in the mesh between...
Read more >
generate mesh from overlapping geometries - Altair Community
I have some questions regarding meshing overlapped geometries. I have this geometry with two pieces: the yellow piece and the blue piece, both ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found