WELSIM is the #1 engineering simulation software for the open-source community.
Saturday, May 30, 2026
Mesh of Engineering Simulation 2: Element Size Control
Most modern engineering simulation software can perform complex meshing, making controlling mesh element size one of the most commonly used features in every operation. Categorized by specific geometric entities, common element size controls span across four levels: vertex, edge, face, and volume. A robust element size control feature helps users quickly obtain high-quality, optimized meshes, which benefits subsequent numerical computations. From a developer’s perspective, this article discusses the application and technical details on how to precisely control element size.
Press enter or click to view image in full size
Characteristic Length
Characteristic length is the most critical numerical value in mesh generation. When performing finite element meshing on a geometric shape (such as a BRep entity imported from a STEP file), we always set one or more global characteristic lengths. The most ubiquitious characteristic length is the maximum element size, which limits the size of the elements to control mesh density. Of course, algorithmically, certain characteristic lengths are internally generated. Calculating based on the geometric body’s bounding box size or curve curvature, the algorithm compares characteristic lengths at each node location and chooses the minimum value.
In practicality, due to the complexity of the geometry, users often need to manually refine the mesh at specific locations. This requires setting a local characteristic length for that area which maintains a higher priority than the global characteristic length, overriding it during the meshing process. Although the local locations chosen by users can be points, lines, or faces, these selected regions will all convert into Cartesian coordinates within the mesh space. When generating the mesh, the algorithm determines the final characteristic length size through evaluation and comparison of the current node’s position.
Example
Taking a 3D cube model as an example, select one of the six faces and set the maximum element size of the chosen face to 0.2.
Press enter or click to view image in full size
After meshing, we observe that the mesh density on and near the selected face is significantly higher than in other areas.
Press enter or click to view image in full size
In this example, only one face was selected, but if desired users can select multiple. If dealing with an assembly model, different faces across multiple bodies can be selected. Similarly, mesh refinement can be achieved by selecting a geometric edge.
Press enter or click to view image in full size
Alternatively, selecting a geometric vertex allows for local mesh refinement around that specific vertex.
Press enter or click to view image in full size
Conclusion
The local density of a finite element mesh depends on the characteristic length of the local elements. When multiple characteristic lengths exist in the same region, the algorithm compares them to determine the minimum characteristic length to use for meshing. For common Delaunay or Advancing Front algorithms, the characteristic length is used to determine the position of the next adjacent mesh node. Because the selected geometric entities are all converted into Cartesian spatial coordinates, there is no difference at the algorithmic level whether the front-end GUI selects a geometric face, edge, or vertex: the characteristic length is always determined based on the spatial position of each node.
Thursday, May 28, 2026
工程仿真软件中的网格2:单元尺寸控制
现代工程仿真软件都可以进行复杂的网格划分,控制网格单元大小是所有复杂网格划分中最常用到的功能。按照指定几何实体来区分,常见的单元尺寸控制分别体现在几何点,几何边,几何面,和几何体四个层级。一个很好的单元尺寸控制功能,可以帮助使用者快速地得到高质量且优化的网格,有助于后续的数值计算。本文从开发者角度,讨论精确控制单元尺寸的应用与技术细节。
Image
特征长度
特征长度是网格划分中的最重要数值。在对几何体(如STEP文件导入生成的BRep实体)进行有限元网格划分时,我们都会设置一个或多个全局特征长度,最常见的特征长度就是最大单元尺寸,这个值限制了单元的大小,从而达到控制网格密度的效果。当然,算法上也可以根据几何体的Bounding Box大小或曲线曲率,内部生成一些特征长度,在每个节点位置比较这些特征长度并取最小值。
实际网格划分中,由于几何体的复杂性,需要人为对某一特定位置加密网格,这就需要对特定位置设定局部特征长度。而局部特征长度优先级会大于全局特征长度,覆盖全局特征长度,参与网格划分。虽然用户常选择的局部位置是点、线、面,而在网格空间,这些选择的区域都转化为笛卡尔坐标。生成网格时,算法会根据当前节点的位置,通过判定和比较,而决定最终的特称长度大小。
示例
以三维立方体模型为例,选择六个面中的一个,并设置所选面的最大单元尺寸为0.2。
Image
网格划分后,可以看到,在所选面及其附近,网格密度明显大于其他位置。
Image
本例只选择了一个面,用户也可以选择多个面,如果是装配体模型,可以选择多个体上的不同的面。同样的,如果选择一条几何边进行加密,也是可以实现。
Image
或者是选择一个几何节点,可以实现对局部节点的网格加密。
Image
总结
有限元网格的局部密度取决于局部单元的特征长度。当同一区域有多个特征长度时,算法上会比较得出最小的特征长度,用于网格划分。对于常见的Delaunay或者Advancing Front算法,特征长度会用于确定下一个相邻网格节点的位置。因为所选的几何实体都会转换为笛卡尔空间坐标,无论前端GUI选择的是几何面,边,还是点,算法层面都没有区别,都是根据每个节点的空间位置来确定特征长度。
Wednesday, May 20, 2026
The mesh of engineering simulation 1: data structures
Modern engineering simulation software is feature-rich. Being the first stage of any simulation pipeline, meshing plays a critical role across the entire software system. The functionality, stability, and efficiency of the meshing module directly impact the usability of the overall software, as meshing is intimately linked to computational functionality, 3D visualization, and human-computer interaction. This blog series will explore the meshing module in engineering simulation software from a developer’s perspective, covering mesh generation, algorithms, data structures, and specialized features. As the first article in the series, this piece discusses mesh data structures and their import/export operations.
Press enter or click to view image in full size
Data structures of finite element mesh
Finite element software connects CAD software to solvers; it takes in geometric topology data from upstream CAD models and generates meshes for downstream solvers. Thus, finite element mesh data structure must bridge the gap between the two by incorporating information from both fields. On top of that, it must support 3D mesh visualization, requiring developers to meticulously develop the underlying data structures. The most common approach is to anchor the design in geometric topology, having each geometric entity contain its lower-level constituents along with the associated finite element node and element information.
Press enter or click to view image in full size
For example, a geometric model, named Model in the diagram above, might contain data blocks named Region, Face, Edge, and Vertex. This is essentially a simplified Boundary Representation (B-Rep) format — a method that represents solid objects using their boundaries (faces, edges, and vertices), allowing exact curved surfaces and precise topological geometry. Ranked from the highest to the lowest hierarchical level, the topology follows:
Compound -> CompSolid -> Solid -> Shell -> Face -> Loop -> Wire -> Edge -> Vertex
Become a Medium member
This is the standard B-Rep data scheme used by most CAD engines. In this hierarchy:
A Wire differs from an Edge in that a Wire possesses curvature.
A Loop is a closed sequence of edges that forms the boundary of a Face.
A Shell is a connected set of Faces.
A CompSolid consists of multiple attached Solids, representing the data format for multi-body parts. Mesh generation requires the special handling of a CompSolid to ensure that the mesh aligns perfectly along embedded faces and embedded edges. (The details of B-Rep data will be discussed in depth in future).
The mapping of individual data components is structured as follows:
Region: Points to CompSolid and Solid geometries. It contains all geometric face information, all embedded geometric entities, and mesh volumetric element information.
Face: Points to Face and Shell geometries. It contains all geometric edge information, the parent geometry it belongs to, embedded geometric entities, and mesh face element information (such as triangular, quadrilateral, and polygonal elements).
Edge: Points to Wire and Edge geometries. It contains all geometric vertex information, the parent geometric faces, and the associated mesh line elements.
Vertex: Points to Vertex geometries. It contains information about the associated geometric vertex, mesh nodes, and the parent geometric edges.
This mapping approach enables rapid queries between mesh and geometry data — such as retrieving all surface elements or nodes on a specific geometric face — which is frequently needed when applying boundary conditions in finite element analysis.
Geometry-to-Mesh Conversion
There are two primary types of conversions from B-Rep to mesh data:
Tessellation/Triangulation: Converts geometry into surface meshes purely for visualization purposes.
Solid Meshing: Generates volumetric meshes used for both finite element computation and mesh visualization (e.g., using VTK’s unstructured grid data format).
Modern finite element software should support both of these conversions, meanwhile reverse-engineering a mesh back into a B-Rep model is rarely implemented because it is nearly impossible to achieve flawlessly.
Import and export of mesh data
Mesh data involves heavy traffic. Beyond supporting their own proprietary mesh formats, modern simulation software must also support universal formats. For finite element, finite volume, and spectral element meshes, widely used formats include UNV, VTU (PVTU), GMSH, EXO, CGNS, MED, and INP, each offering unique advantages.
Press enter or click to view image in full size
Developers can directly leverage these formats or their corresponding SDKs to build core software data structures and handle mesh file I/O:
UNV is a feature-rich and easy-to-use mesh format that supports a wide array of mesh elements. It allows the definition of group information (vital for boundary conditions) and supports both ASCII and Binary formats for read/write operations.
VTU holds a natural advantage in graphical visualization. It’s backed by the entire open-source VTK source code and ecosystem, making it an excellent format for mesh data I/O.
Currently, WELSIM primarily utilizes the UNV and VTU formats as its foundational mesh data structure, fully supporting data import and export for both.
As simulation software scales with additional features, developers often need to incorporate supplementary data. This includes mapping relationships between CAD topology and the mesh, hierarchical relationships for remeshing, and mesh mapping between sub-models and global models. Because these datasets vary in size, they require a flexible, compressible data format — ideally the HDF5 file format. Upon completing a mesh generation, WELSIM produces a file named s2m.h5 to store the mapping relationships between the geometric topology and the mesh.
Conclusion
This article discussed the mesh data structures and I/O methodologies use in simulation software — establishing a proven framework for the meshing modules of general-purpose simulation platforms. It fulfills most functional requirements and adapts exceptionally well to advanced meshing features, like real-time simulation and parallel computing. Furthermore, other complex, specialized features can be successfully developed on top of this foundational data structure, such as boundary layer meshing and internal embedded surface meshing for multi-body parts.
Saturday, May 16, 2026
工程仿真软件中的网格1:数据结构
现代工程仿真软件的功能丰富,网格作为所有仿真计算的入口模块,在整个软件中占据着越来越重要的位置。网格模块的功能、稳定性与效率,直接影响到整个仿真软件的使用。网格直接关系到软件的计算功能,三维显示,人机交互等方面。本系列从开发者的角度探讨工程仿真软件中的网格模块,内容覆盖网格划分,算法,数据结构,特殊功能等。本文作为系列的第一篇文章,讨论网格的数据结构及其输入输出。
Image
有限元网格的数据结构
有限元软件向上承接CAD软件的几何拓扑数据,向下生成求解器支持的网格,因此有限元网格数据需要包含两者的信息,起到承上启下的作用。同时,还需要支持网格的三维显示,因此开发者必须要对数据结构进行精心地构架。最常见的方式,是以几何拓扑为出发点,每个几何体(entity)都包含下一级的几何体和相关的有限元节点与单元信息。
Image
如几何模型命名为Model,会包含名为Region,Face, Edge,和Vertex数据,这本质上是一种简化版的B-Rep格式,即用物体的边界(面/边/点)来表示实体,是精确的曲面与精确的拓扑数据几何。从层级由高到低分类,
Compound → CompSolid → Solid → Shell → Face → Loop → Wire-> Edge → Vertex
这也是常见CAD引擎的B-Rep数据方式,其中Wire与Edge的区别是Wire会有曲率,Loop是闭合边序列,构成Face的边界。Shell是连通的Face集合。CompSolid是多个Solid粘连,是多体零件的数据形式。网格划分对于CompSolid要对做特殊处理,需要确保网格要沿着共享内表面和共享边划分。关于B-Rep数据的细节会在以后的文章中详细讨论。
Region数据指向的是CompSolid和Solid几何体,包含所有的几何面信息,内部的几何面,几何边,几何节点,和网格体单元信息。
Face数据指向的是Face和Shell几何体,包含所有几何边信息,所属的几何体,内部的几何边与几何节点信息,以及网格面单元信息,如三角单元,四边形单元,和多边形单元。
Edge数据指向的是Wire与Edge几何体,包含所有的几何节点信息,所属的几何面,所含有的网格线单元。
Vertex数据指向Vertex几何体,包含所属几何节点与网格节点信息,所属几何边的信息。
这样的数据映射方式,可以快速的查找网格与几何体数据,如获得某一个几何面上的网格面单元或节点,这在有限元计算的边界条件上经常用到。
B-Rep与网格的转换有两种,一种是通过tessellation/triangulation网格化/三角化转变为表面网格,用于显示几何体。另一种是实体网格,用于有限元计算和网格显示,如使用VTK的非结构网格数据。现代有限元软件,两种转换都是必备的。而逆向的网格转换为B-Rep几乎难以完美实现,因此很少应用。
网格数据的输入与输出
网格数据有大量的交互需求,现代仿真软件除了支持自有的网格格式外,还需要能够支持常见的通用格式。对于有限元(包含有限体积,谱单元)等类型的网格,常见的格式有UNV, VTU(PVTU), GMSH,EXO,CGNS, MED, INP等。这些格式都各有优点。
Image
开发者可以直接应用这些格式或开发包,来构建软件的核心数据结构和读写网格文件。UNV是一款功能丰富且易于使用的网格格式,支持大量的网格元素,如定义可以支持边界条件的组信息,读写都有ASCII与Binary两种格式支持。VTU在图形显示上有着天然的优势,有整个VTK开源代码与生态的支持,也是一款很好的网格数据读写格式。目前WELSIM主要使用UNV和VTU两种格式作为基础网格数据,同时支持这些格式的数据导入与到处。
当仿真软件的功能变多时,开发者可能还需要增加其他的数据。如CAD拓扑信息与网格的映射关系,动网格数据每个层级的关系,子模型与全局模型的网格映射等等。这些数据是基础网格数据的重要补充,由于这些数据大小可能不一,需要一种灵活且可压缩的数据格式来支持,比较理想的是用Hdf5格式文件。WELSIM会在网格划分完毕后,生成一个名为s2m.h5的文件,来包含几何拓扑与网格的映射关系。
总结
本文讨论了仿真软件的网格数据结构与输入输出方式。是被验证了可以应用于通用仿真软件的网格模块。可以满足大部分功能需求。甚至对于一些高级网格功能,如实时仿真,并行计算都能够很好的适应。对于一些复杂的特殊功能,如边界层网络,多体零件的内部嵌入面网格划分,都可以在此数据结构上进行开发。
Subscribe to:
Posts (Atom)