Saturday, December 23, 2023

Select the interior surface of three-dimensional shapes using selection layer view

 In three-dimensional CAE simulation analysis, it is often necessary to select interior surfaces of geometric bodies or choose surfaces that are occluded. This is applicable when setting up contact conditions for complex assemblies in structural analysis, defining boundary conditions for inner surfaces in electromagnetic, fluid, or thermal analyses, among other scenarios. Such requirements pose significant demands on the pre-processing modules of engineering simulation software.


Currently, a common approach in the industry is to add a selection layer view in a small region within the 3D graphics window. This feature displays the selection layers after clicking on a geometric body, enabling the user to modify the desired surfaces. This method is simple, intuitive, and provides a good user experience. However, this service adds extra software development work, as it requires incorporating an additional viewport in the 3D window. When implementing a selection layer view, the impact the feature has on the overall software performance must also be payed attention to.

Selection layer view

In the model below, there is a sphere with two small spherical cavities inside. When the model is set to be semi-transparent, the positions and sizes of the internal cavities can be observed. In 3D electromagnetic analysis, the exterior surface is often set as the far-field boundary, and various excitations are applied to the inner surface, such as voltage. Similarly, in fluid and thermal analysis, certain boundary conditions are set for the inner surface. In such cases, the GUI operation needs to be able to select the interior surfaces of the sphere.


When clicking on the position of the internal spherical cavity, the default outermost surface is selected and highlighted in green. If there are more optional surfaces, the layer view will be displayed. At this point, the layer view shows two layers: the unselected inner surface on the left, represented in gray; the selected outer surface on the right, highlighted in green.

Moving the mouse to the left side of the layer view automatically selects the left layer. Now, the model updates the selected surface shown - the inner surface is now selected and highlighted in green.

The layer view simplifies the process of selecting inner surfaces. In this example, a spherical model demonstrates how to select the inner surfaces of 3D geometric bodies. The video demonstration is as follows:

This method is correspondingly applicable to other types of geometric bodies. When the position of the mouse click involves multiple surfaces, the layer view will display the corresponding number of layers. If the position involves fewer than two surfaces, the layer view remains hidden.

The layer view is a new feature introduced in the WELSIM 2024R1 version, primarily aimed at enhancing the pre-processing capabilities in three-dimensional fluid and electromagnetic simulations.

Monday, December 18, 2023

图层演示器用于三维实体内表面的选择

在三维模型CAE仿真分析中,我们常需要选择几何体的内表面,或者选择被遮挡的表面。如结构分析时复杂装配体的接触设置,电磁、流体或热分析时内表面的边界条件等。这对工程仿真软件的前处理模块提出了比较高的要求。


目前,业界比较常见的方式是:在三维图形窗口中的一个小区域增加图层演示器,允许用户在点选几何体后,显示图层演示器,此时用户可以更改所需要的表面。这种方式简单直观,用户体验好。然而增加了额外的软件开发工作,需要在三维窗口中增加一个额外视图。增加此功能时,也需要注意对软件整体性能的影响。

图层演示器示例

下图模型是一个球体,内部含有两个小的球体空腔,当设置模型为半透明时,可以看到内部的球体空腔位置与大小。在三维电磁场分析时,我们常会将外表面设置为远场边界,内表面设置各种激励,如电压等。类似的,流体与热分析中,内表面也会设置某种边界条件。此时GUI操作就需要能够选中球形内表面。


当点击内部球体空腔位置时,会选中默认的最外层表面,并以绿色高亮显示。如有额外的可选表面时,图层演示器会显示出来。此时,图层演示器显示两个图层,左边是未选中的内表面,以灰色表示,右边是选中的外表面,以绿色高亮表示。

将鼠标移动至图层演示器的的左边,就会自动选择左边的图层,同时模型会更新所选中的表面,内表面被选中,并以绿色高亮显示。



图层演示器使得选择内表面变得简单。本例通过一个圆球演示如何选取三维几何体内表面。视频演示如下:

对于其他类型的几何体,此方法同样适用。当鼠标的点击位置含有多个表面,图层演示器会显示相应数量的图层。而当点击位置少于两个表面,则不会显示图层演示器。

图层演示器是WELSIM 2024R1版本中新添加的功能,主要用于增强在三维流体和电磁仿真中的前处理能力。

Monday, November 20, 2023

Compile the electromagnetic simulation solver Palace in Windows

 Palace is an open-source, large-scale computational electromagnetic software package supported by the AWS Lab. It is feature-rich and capable of running on various high-performance hardware, supporting OpenMP, MPI, and GPU parallel computing. The use of the Apache open-source license is also highly advantageous. For more details, refer to the article ‘Generating the solver input scripts of the computational electromagnetics software Palace using WELSIM’.

Although Palace is powerful, being a scientific computing program developed based on Linux, the official support for the Windows operating system is not complete. We have conducted research on the feasibility of running Palace on Windows, compiled Palace using Visual Studio, and generated a native Windows application with simulation results.

Palace provides the Superbuild compilation method with CMake, which automatically downloads all required libraries and compiles them completely. It compiles effortlessly on Linux. However, on Windows, many core libraries such as PETSc, SLEPc, libCEED, MUMPS, and others require manual compilation. Therefore, the Superbuild mode provided officially cannot compile as smoothly on Windows. Users need to apply the manual method of establishing Visual Studio projects to complete the building.

System and dependency libraries

Operating System: Windows 10, 64-bit

Compiler: Visual Studio 2022 Community, C++17. Intel Fortran Compiler 2022.

Palace Version: 0.11.2

Dependency Libraries:

Intel MKL: A popular linear algebra solver, using oneAPI 2022.2.0, consistent with the version of Fortran compiler.

METIS: A mesh partitioning tool for parallel computing, version 5.3.

Hypre: A computational library, version 2.52.

nlhmann/json: Modern C++-based JSON read-write package.

{fmt}: Formatting tool for input-output streams in C/C++.

Eigen: A well-known C++ numerical computing package, has no need for compilation; supports direct header file invocation.

libCEED: A linear algebra computation management terminal that supports parallel computing on various CPUs, GPUs, and clusters.

SuperLU_DIST: The parallel version of SuperLU, a sparse direct linear algebra solver library.

STRUMPACK: An open-source software library for large-scale sparse matrix computing.

MUMPS: An open-source software library from France for solving large-scale sparse linear systems.

SLEPc: A complex number linear algebra solver for eigenvalue problems, based on PETSc.

ARPACK-NG: A complex number linear algebra solver for eigenvalue problems, programmed using Fortran 77 langauge.

GSLIB: An interpolation sovler for high-order spectral elements, optional.

Among these, at least one of the three optional linear solvers SuperLU_DIST, STRUMPACK, MUMPS must be present. This article uses MUMPS. Additionally, out of the two complex solvers, SLEPc and ARPACK, at least one is required. Without them, eigenvalue-related computing cannot be performed. This article uses ARPACK.

Visual studio projects

Establish two projects, namely the static library project libpalace, and the executable file project palace. libpalace contains all header and source files. palace is the final generated executable file, containing only a main.cpp file. This is shown in the figure.

Project libpalace

Set the external header file directories.

Add preprocessor macros:

CEED_SKIP_VISIBILITY

PALACE_WITH_ARPACK

_CRT_SECURE_NO_WARNINGS

Project palace

The method to add external header files and preprocessor macros is essentially the same as libpalace, so it will not be repeated here. Compiling the executable program requires linking all dependent libraries. The added linked libraries are as follows,

After building, place all dependent dynamic libraries (*.dll files) together with the palace.exe to run Palace. Test the executable program by running it on the Windows console.

You can also use the mpiexec command for MPI parallel computing. GPU parallel computing should also be feasible and will be discussed in future articles.

To contribute to simulation and the open-source communities, we have open-sourced the building files for Palace, shared at https://github.com/WelSimLLC/palace, and provided the compiled palace.exe executable file for users to use directly.

Conclusion

There are not many available open-source electromagnetic simulation solvers, and Palace provides powerful computing capabilities while also having a very friendly open-source license. WELSIM has become the first developer in the world to successfully compile Palace on Windows and open-source the building methods and files.

Some of Palace’s dependency libraries that also face challenges when building on Windows will be discussed in future articles.

WelSim is not affiliated with Palace and Visual Studio. The development team and organization behind Palace and Visual Studio have no connection to WelSim. This reference is used here solely for the purpose of a technical blog article and software usage.

Sunday, November 19, 2023

Windows环境下编译电磁仿真求解器Palace

Palace是一款开源的大规模计算电磁学软件包,由亚马逊云端业务实验室(AWS Lab)支持。功能丰富,同时能够在不同的高性能硬件上运行,软件上支持OpenMP, MPI和GPU并行计算。Apache的开源协议也是极为友好。详情参见《使用WELSIM生成电磁计算软件Palace的求解器文件》一文。

尽管Palace功能强大,但作为一款基于Linux开发的科学计算程序,官方并没有提供对Windows操作系统的完全支持。笔者对Palace在Windows系统运行的可行性做了研究,使用Visual Studio编译Palace,生成了原生的Windows版本应用程序,并计算得到仿真结果。

Palace提供了CMake的Superbuild编译方式,会自动下载全部的所需依赖库并完全编译。在Linux下可以顺利编译。然而在Windows系统下,大量的依赖库如PETSc,SLEPc,libCEED,MUMPS等核心依赖库需要手动编译,因此官方提供的Superbuild模式,还无法在Windows下顺利编译。我们需要通过手动建立Visual Studio项目的方法,完成编译。

系统环境与依赖库

操作系统:Windows 10, 64-bit

编译器:Visual Studio 2022 Community, C++17。Inter Fortran Compiler 2022。

Palace版本:0.11.2

依赖库

  • Intel MKL:著名的线性矩阵求解器。使用oneAPI 2022.2.0,和Fortran编译器版本一致。
  • METIS:用于并行计算的网格分区工具。使用5.3版本。
  • Hypre:计算包,使用2.52版本。
  • nlhmann/json:一款现代的基于C++的JSON语言读写包。
  • {fmt}:支持C/C++的输入输出流的格式化工具包。
  • Eigen:大名顶顶的C++数值计算包,无需编译,支持头文件直接调用。
  • libCEED:是一款线性代数计算管理终端,支持对各种CPU,GPU和集群的并行计算。
  • SuperLU_DIST:SuperLU的并行版本,是一个并行的稀疏直接线性代数求解器库。
  • STRUMPACK:一款大规模稀疏矩阵直接数值计算的开源软件库。
  • MUMPS:来自法国的求解大规模稀疏线性方程组的开源软件库。
  • SLEPc:支持复数线性矩阵计算,用于特征值计算。需要基于PETSc编译。
  • ARPACK-NG:支持复数线性矩阵计算,用于特征值计算。以F77程序为主,无需依赖PETSc,可以独立编译。
  • GSLIB:用于高阶谱单元的插值计算,可选。

其中,SuperLU_DIST,STRUMPACK,MUMPS三个可选的直接线代求解器至少要有一个。本文选用了MUMPS。SLEPc和ARPACK这两个复数求解器,需要至少一个。如果没有,将无法实现特征值相关的计算。本文选用了ARPACK。

建立项目文件

建立两个项目,分别是静态库项目libpalace,和可执行文件项目palace。libpalace包含所有的头文件和源文件。palace是最后生成的可执行文件,只含有一个main.cpp文件。如图所示,

libpalace项目设置

设置外部头文件链接位置

添加预处理宏命令

CEED_SKIP_VISIBILITY
PALACE_WITH_ARPACK
_CRT_SECURE_NO_WARNINGS

palace项目设置

添加外部头文件和预处理宏命令的方式,与libpalace几乎一样,这里不在赘述。编译可执行程序需要链接所有依赖库。添加的链接库如下

编译后,需要将所有的依赖动态库放置与palace.exe文件在一起,即可运行palace了。测试可执行程序,可以在Windows的命令行下运行。

也可以使用mpiexec命令进行MPI并行计算。GPU并行计算应该也可以实现,会在以后的文章中讨论。

为贡献仿真与开源社区,笔者开源了Palace的编译文件,分享在 github.com/WelSimLLC/pa,并提供了编译好的palace.exe可执行文件,供用户直接使用。

总结

目前可用的开源电磁场仿真求解器不多,Palace提供了强大的计算功能同时,也有着很友好的开源协议。Welsim也成为了世界上第一个在Windows下成功编译Palace,并开源编译方法与文件的开发者。

Palace的一些依赖库在Windows下编译也存在难点,将在以后的文章中讨论。


WelSim与作者不隶属于Palace。和Palace开发团队与机构没有直接关系。这里引用Palace仅用作技术博客文章与软件使用的参考。