Meshing#
A finite element mesh is required to perform a cross-section analysis. After a geometry
has been created, a finite element mesh can then be created for the geometry by using
the sectionproperties.pre.geometry.Geometry.create_mesh()
or
sectionproperties.pre.geometry.CompoundGeometry.create_mesh()
methods:
- Geometry.create_mesh(mesh_sizes: float | list[float], min_angle: float = 30.0, coarse: bool = False) Geometry [source]
Creates a quadratic triangular mesh from the Geometry object.
- Parameters:
mesh_sizes (float | list[float]) – A float describing the maximum mesh element area to be used within the Geometry-object finite-element mesh (may also be a list of length 1).
min_angle (float) – The meshing algorithm adds vertices to the mesh to ensure that no angle smaller than the minimum angle (in degrees, rounded to 1 decimal place). Note that small angles between input segments cannot be eliminated. If the minimum angle is 20.7 deg or smaller, the triangulation algorithm is theoretically guaranteed to terminate (given sufficient precision). The algorithm often doesn’t terminate for angles greater than 33 deg. Some meshes may require angles well below 20 deg to avoid problems associated with insufficient floating-point precision.
coarse (bool) – If set to True, will create a coarse mesh (no area or quality constraints)
- Raises:
ValueError –
mesh_sizes
is not valid- Returns:
Geometry
object with mesh data stored in.mesh
attribute. ReturnedGeometry
object is self, not a new instance.- Return type:
Example
The following example creates a circular cross-section with a diameter of 50 mm with 64 points, and generates a mesh with a maximum triangular area of 2.5 mm2.
from sectionproperties.pre.library import circular_section from sectionproperties.analysis import Section geom = circular_section(d=50, n=64) geom = geom.create_mesh(mesh_sizes=2.5) Section(geom).plot_mesh(materials=False)
(
Source code
,png
,hires.png
,pdf
)
- CompoundGeometry.create_mesh(mesh_sizes: float | list[float], min_angle: float = 30.0, coarse: bool = False) CompoundGeometry [source]
Creates a quadratic triangular mesh from the CompoundGeometry object.
- Parameters:
mesh_sizes (float | list[float]) – A float describing the maximum mesh element area to be used in the finite-element mesh for each Geometry object within the CompoundGeometry object. If a list of length 1 or a float is passed, then the one size will be applied to all constituent Geometry meshes.
min_angle (float) – The meshing algorithm adds vertices to the mesh to ensure that no angle smaller than the minimum angle (in degrees, rounded to 1 decimal place). Note that small angles between input segments cannot be eliminated. If the minimum angle is 20.7 deg or smaller, the triangulation algorithm is theoretically guaranteed to terminate (given sufficient precision). The algorithm often doesn’t terminate for angles greater than 33 deg. Some meshes may require angles well below 20 deg to avoid problems associated with insufficient floating-point precision.
coarse (bool) – If set to True, will create a coarse mesh (no area or quality constraints)
- Returns:
CompoundGeometry
object with mesh data stored in.mesh
attribute. ReturnedCompoundGeometry
object is self, not a new instance.- Return type:
Example
The following example creates a mesh for a plate with a hole, with a refined mesh around the hole region:
from sectionproperties.pre.library import rectangular_section from sectionproperties.pre.library import circular_section from sectionproperties.analysis import Section outer_rect = rectangular_section(d=100, b=200) inner_rect = rectangular_section(d=50, b=50).align_center( align_to=outer_rect ) circle = circular_section(d=20, n=32).align_center(align_to=outer_rect) geom = outer_rect - inner_rect + inner_rect - circle geom.create_mesh(mesh_sizes=[100, 5]) Section(geometry=geom).plot_mesh(materials=False)
(
Source code
,png
,hires.png
,pdf
)
Warning
The length of mesh_sizes
must match the number of regions in the geometry object.
Once the mesh has been created, it is stored within the geometry object and the geometry
object can then be passed to Section
for
analysis.
Mesh quality analysis, such as plotting the mesh and displaying mesh metrics, can be
performed using the Section
class. Please
see Analysis for further information on performing analyses.