Some MLPG formulations — in particular MLPG5 with rectangular control volumes — require a structured, regular node distribution to guarantee that adjacent control volumes are geometrically consistent (i.e., they tile the domain without overlap or gap, so the coefficient of variation CV ≈ 0). In such cases, a quasi-random distribution (Poisson disk) introduces irregular control volume sizes that degrade the accuracy of the integration.
The UnifiedSampler2DRegular generates a single rectangular grid over the bounding box of each planar face, and then classifies each grid point as boundary or interior based on its distance to the polygon boundary. This approach:
Guarantees perfectly uniform inter-node spacing in the interior (h in both directions).
Snaps near-boundary grid nodes onto the actual boundary polygon, to maintain geometric accuracy.
Is the fastest method to generate a large cloud (no iterative sampling loop).
2. Algorithm
Step 1: Grid generation
A regular rectangular grid is generated over the 2D bounding box [xmin, xmax] × [ymin, ymax] of the face boundary polygon, with spacing h in both directions:
xij = (xmin + i · h, ymin + j · h), i = 0,…,Nx, j = 0,…,Ny
Step 2: Domain containment filter
Grid points that fall outside the face boundary polygon are discarded (ray-casting test via matplotlib.path.Path.contains_points()).
Step 3: Classification and boundary snapping
For each remaining grid point, the signed distance to the nearest boundary edge is computed. A snap band of width 0.65 h is defined:
Points at distance ≥ 0.65 h from the boundary: classified as interior nodes. Position unchanged.
Points at distance < 0.65 h: classified as boundary nodes. Their position is snapped (projected) onto the nearest edge. The outward in-plane normal is recomputed from the edge tangent at the projected point.
The snap band threshold of 0.65 h was determined empirically to produce a clean boundary-to-interior transition without leaving gaps or overlapping nodes.
3. Control Volume Consistency (MLPG5-rect)
In the MLPG5 formulation, the local subdomain of each interior node is a rectangle of half-side αs h / 2 centred at the node. For two adjacent nodes at distance h, their control volumes share exactly one edge (no overlap, no gap) if and only if the node distribution is regular. The coefficient of variation of control volume areas is CV = 0 for a perfect grid.
For Poisson disk distributions, CV > 0 (typically 0.05–0.15), which introduces a small but non-zero integration inconsistency. The regular grid eliminates this source of error entirely at the cost of isotropy.
Note: The regular grid is isotropic by design — the same spacing in both x and y directions. This is appropriate for isotropic material properties and uniform loading. For highly anisotropic problems or non-rectangular domains with complex boundaries, the Poisson disk or Delaunay methods may produce better results near the boundary.
4. Parameters
h (float): Grid spacing [model units]. Applies equally in x and y.
n_max (int or None): Hard cap on total nodes per entity.
5. When to Use
Use "regular_grid" when:
Running MLPG5 with rectangular control volumes (CV = 0 requirement).
The domain is approximately rectangular or has smooth boundaries.
Reproducibility without a random seed is desired (the grid is deterministic).
Maximum computational efficiency in node generation is needed.
6. References
Atluri, S. N., & Shen, S. (2002). "The Meshless Local Petrov-Galerkin (MLPG) Method: A Simple & Less-costly Alternative to the Finite Element and Boundary Element Methods." CMES: Computer Modeling in Engineering & Sciences, 3(1), 11–51. Link
Liu, G. R., & Gu, Y. T. (2005). An Introduction to Meshfree Methods and Their Programming. Springer. (Chapter 2)
Sladek, J., Sladek, V., & Atluri, S. N. (2004). "Meshless local Petrov-Galerkin method for heat conduction problem in an anisotropic medium." CMES: Computer Modeling in Engineering & Sciences, 6(3), 309–318.