fix mesh/surface/sdf#

Syntax#

fix ID group-ID mesh/surface/sdf file filename type atom_type keyword value ...
  • ID, group-ID are documented in fix command. The group-ID is ignored for this command.

  • mesh/surface/sdf = style name of this fix command.

  • file filename = name of the STL mesh file to read.

  • type atom_type = atom type assigned to the mesh wall for material property pairing.

  • Zero or more keyword/value pairs may be appended:

Keyword

Values

Description

cell_size / dx

\(\Delta x > 0\)

Grid spacing for the 3D Eulerian Cartesian SDF grid.

margin

\(\text{margin} \ge 0\)

Bounding box margin around the mesh (default: \(4 \times \Delta x\)).

thickness / shell

\(t > 0\)

Enables two-sided thin-shell SDF modeling with specified thickness for open meshes.

solid

inside or outside

For closed (watertight) meshes, defines whether the interior is solid (\(\phi < 0\)) or exterior (default: inside).

invert_sign

yes or no

Inverts the sign of the distance field (default: no).

cache

filename.sdf

File path to save/load precomputed binary SDF grid data, drastically reducing setup time on subsequent runs.

dump_vtk

filename.vtk

Exports the 3D SDF grid scalar field to a legacy VTK structured points file for visual inspection in ParaView.

Examples#

# Import an open chute STL mesh with thin-shell SDF and caching
fix cad all mesh/surface/sdf file meshes/simple_chute.stl type 1 dx 0.005 thickness 0.01 dump_vtk post/sdf_chute.vtk cache chute.sdf

# Moving boundary: apply periodic wiggling motion to the SDF mesh
fix movecad all move/mesh mesh cad wiggle amplitude 0.0 0.0 0.006 period 0.02

# Define particle-wall contact interaction using the SDF mesh
fix zw all wall/gran/sdf sdf cad model hertz tangential history

Description#

fix mesh/surface/sdf constructs an Eulerian 3D Cartesian Signed Distance Function (SDF) grid representation of an imported triangulated surface mesh (STL format) (Shigeto & Sakai, 2013).

Compared to standard triangle-based wall models (fix wall/gran), the SDF representation offers key computational advantages:

  • Constant-Time \(O(1)\) Lookup: Contact distance and surface normals are evaluated via trilinear interpolation on a regular 3D grid, decoupling computational cost from triangle mesh resolution.

  • Smooth Analytical Normals: Distance gradients \(\nabla \phi\) yield continuously varying surface normals, eliminating force discontinuities and numerical instability at triangle edges and sharp vertices.

  • Open Mesh & Thin-Shell Support: Open STL geometries (e.g., chutes, baffle plates, vibrating screens) are natively supported via the thickness parameter.

Algorithmic Details#

  1. AABB Tree Acceleration & Exact Distances: During initialization, an Axis-Aligned Bounding Box (AABB) tree is constructed over all mesh triangles. For each grid vertex \(\mathbf{x}_{ijk}\), the exact point-to-triangle distance is computed using the Eberly algorithm.

  2. Two-Sided Thin-Shell Modeling (Open Meshes): When thickness \(t\) is specified, the signed distance is evaluated as:

    \[\phi(\mathbf{x}) = d(\mathbf{x}) - \frac{1}{2} t\]

    where \(d(\mathbf{x})\) is the unsigned Euclidean distance to the surface. Particles approaching from either side of the open sheet experience positive distance (\(\phi > 0\)) outside the shell and penetrate into \(\phi \le 0\), allowing realistic two-sided collisions without needing to create artificially thick or closed CAD solids.

  3. Phantom Surface Elimination: For open meshes, distance points projecting beyond boundary edges are dynamically filtered to prevent artificial “phantom wall” forces from projecting into empty simulation domains.

  4. Kinematic Moving Frame Coupling: fix mesh/surface/sdf seamlessly couples with fix move/mesh. Rigid-body motions (linear translation, rotation, harmonic oscillation, and wiggling) are tracked via coordinate transformation matrices:

    • Particle coordinates are mapped into the mesh local reference frame to query the static SDF grid.

    • Computed contact normals and distance gradients are transformed back to the laboratory frame.

    • Surface velocities \(\mathbf{v}_{\text{wall}} = \mathbf{v}_{\text{trans}} + \boldsymbol{\omega} \times (\mathbf{x}_{\text{contact}} - \mathbf{x}_{\text{rot}})\) are calculated analytically, accurately transferring linear and angular momentum to contacting particles.

  5. Binary Caching: Generating high-resolution 3D SDF grids for complex CAD geometry can require significant computation. Specifying cache <filename.sdf> writes the grid data to a portable binary file on rank 0 during the first run. On subsequent executions, the grid is loaded instantly and broadcast via MPI.

  6. Watertight Mesh Sign Determination via BVH Ray-Casting: For closed, watertight surface meshes (without the thickness keyword), grid node sign classification (interior vs exterior) is evaluated using a robust Bounding Volume Hierarchy (BVH) ray-casting algorithm. Rays are cast from each grid vertex to determine triangle intersection parity, ensuring exact classification of interior solid cells (\(\phi < 0\)) and exterior void cells (\(\phi > 0\)) even for complex topologies and sharp geometric features.

Restart, Fix_modify, Output Info#

  • Restarts: Moving frame transformations, rotation matrices, and displacement histories are automatically stored in binary restart files (write_restart / read_restart), guaranteeing bit-exact restart reproducibility.

  • VTK Output & Directory Creation: Specifying dump_vtk <filename.vtk> outputs the scalar distance field \(\phi\) on the 3D structured grid, which can be loaded directly into ParaView for visual verification. When exporting files using dump_vtk or cache, any non-existent parent directories in the target path are created automatically.

Restrictions#

  • This fix must be paired with fix wall/gran/sdf to apply contact forces to granular particles.

  • In parallel simulations, all MPI ranks require access to the mesh file or binary cache file. Rank 0 broadcasts the grid to other ranks automatically.

References#

  • (Shigeto & Sakai, 2013) Y. Shigeto, M. Sakai, “Numerical simulation of granular flow in a complex geometry using the signed distance function”, Chemical Engineering Journal, 231, pp. 464–476, 2013.