目录
〇、VisualSPHysics简介
一、问题
二、解决过程
三、小结
参考文献
〇、VisualSPHysics简介
VisualSPHysics是一款开源工具,用于为SPH模拟打造更为真实的视觉效果。它能够将DualSPHysics、DesignSPHysics的SPH模拟结果导入3D图形软件Blender中,并支持各种视觉效果(真实光影、材质纹理、泡沫模拟等)。VisualSPHysics还在Blender中集成了用户界面,从而更加便于操作。
VisualSPHysics大大提高了科学研究或项目工作成果的视觉效果,能够帮助研究人员更好地展示其成果。
下载地址如下:
VisualSPHysics1.2.1
Releases · EPhysLab-UVigo/VisualSPHysics · GitHub
Blender
blender.org - Home of the Blender project - Free and Open 3D Creation Software
一、问题
| Traceback (most recent call last): File "D:SPHblender-2.83.9-windows642.83scriptsmodulesaddon_utils.py", line 351, in enable mod = __import__(module_name) File "C:UserslenovoAppDataRoamingBlender FoundationBlender2.83scriptsaddonsVisualSPHysics.py", line 30, in import vtkimporter ModuleNotFoundError: No module named 'vtkimporter' |
二、解决过程
(1)查看VisualSPHysics.py中对应行数的代码,如下所示:
| import vtkimporter |
查询python语言import语句用法。未找到解决方案。
(2)注意到论文里要求在Windows系统下安装g++,参考以下网页安装。
Windows下 gcc/g++的安装与配置 - 对弈 - 博客园
(3)在Windows power shell中执行下列操作:
| git clone https://github.com/EPhysLab-UVigo/VisualSPHysics.git cd VisualSPHysics mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=RELEASE cmake --build . --config RELEASE cpack |
出现问题:
| git : 无法将“git”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确, 然后再试一次。 所在位置 行:1 字符: 1 + git clone https://github.com/EPhysLab-UVigo/VisualSPHysics.git + ~~~ + CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException |
应当安装git,从下列链接下载并安装:
Git - Downloading Package
如果因为墙的原因,再运行可能一直卡在Cloning into 'VisualSPHysics'...提示上不动。可以尝试修改为镜像网站。
| git clone https://github.com.cnpmjs.org//EPhysLab-UVigo/VisualSPHysics.git cd VisualSPHysics mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=RELEASE cmake --build . --config RELEASE cpack |
两种方法均失败,放弃。进度条会卡在某一位置不继续clone。
(已解决,参见步骤8)
(6)尝试更换VisualSPHysics版本,更换为15 Apr 2021发布的Version1.2
加载后出现Object: VisualSPHysics Blender Addon选项,但勾选时出现以下提示:
| Traceback (most recent call last): File "D:Blender2.93scriptsmodulesaddon_utils.py", line 351, in enable mod = __import__(module_name) File "C:UserslenovoAppDataRoamingBlender FoundationBlender2.93scriptsaddonsVisualSPHysics.py", line 30, in import vtkimporter importError: DLL load failed while importing vtkimporter: 找不到指定的模块。 |
1.2版本与1.2.1版本区别在于,1.2版本中vtkimporter与diffuseparticles模块已经封装成lib文件与pyd文件,但不能载入模块的原因仍不清楚,下一步继续尝试旧版本。
更正:若下载的包含多个文件夹,说明是源代码(source)程序;若仅包含VisualSPHysics.py及2个模块的lib文件、pyd文件,则说明是已经封装好的Release版本!
(7)尝试20 Sep 2019发布的Version1.1,该版本vtkimporter与diffuseparticles模块仅封装成pyd文件,但仍出现相同问题。
后续参见步骤(9)
(8)重新尝试步骤(3),能够成功下载,可能是网络问题。但仍报错,提示如下
| Cloning into 'VisualSPHysics'... remote: Enumerating objects: 212, done. remote: Counting objects: 100% (56/56), done. remote: Compressing objects: 100% (39/39), done. remote: Total 212 (delta 21), reused 29 (delta 15), pack-reused 156 eceiving objects: 92% (196/212), 3.28 MiB | 381.00 KiB/s Receiving objects: 100% (212/212), 3.44 MiB | 429.00 KiB/s, done. Resolving deltas: 100% (109/109), done. 目录: C:UserslenovoVisualSPHysics Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2021/10/23 15:55 build -- Building for: Visual Studio 12 2013 CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument CMake that the project does not need compatibility with older versions. -- The C compiler identification is MSVC 18.0.31101.0 -- The CXX compiler identification is MSVC 18.0.31101.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: D:/Microsoft Visual Studio 12.0/VC/bin/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: D:/Microsoft Visual Studio 12.0/VC/bin/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Deprecation Warning at foamsimulator/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument CMake that the project does not need compatibility with older versions. -- Found PythonLibs: D:/Python/Python39/libs/python39.lib (found suitable version "3.9.1", minimum required is "3") CMake Warning at foamsimulator/CMakeLists.txt:6 (find_package): By not providing "FindVTK.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "VTK", but CMake did not find one. Could not find a package configuration file provided by "VTK" with any of the following names: VTKConfig.cmake vtk-config.cmake Add the installation prefix of "VTK" to CMAKE_PREFIX_PATH or set "VTK_DIR" to a directory containing one of the above files. If "VTK" provides a separate development package or SDK, be sure it has been installed. CMake Error at foamsimulator/CMakeLists.txt:12 (include): include called with wrong number of arguments. include() only takes one file. -- Found OpenMP_C: -openmp (found version "2.0") -- Found OpenMP_CXX: -openmp (found version "2.0") -- Found OpenMP: TRUE (found version "2.0") CMake Deprecation Warning at vtkimporter/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument CMake that the project does not need compatibility with older versions. -- Found PythonLibs: D:/Python/Python39/libs/python39.lib (found suitable version "3.9.1", minimum required is "3.7") CMake Warning at vtkimporter/CMakeLists.txt:6 (find_package): By not providing "FindVTK.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "VTK", but CMake did not find one. Could not find a package configuration file provided by "VTK" with any of the following names: VTKConfig.cmake vtk-config.cmake Add the installation prefix of "VTK" to CMAKE_PREFIX_PATH or set "VTK_DIR" to a directory containing one of the above files. If "VTK" provides a separate development package or SDK, be sure it has been installed. CMake Error at vtkimporter/CMakeLists.txt:12 (include): include called with wrong number of arguments. include() only takes one file. -- Configuring incomplete, errors occurred! See also "C:/Users/lenovo/VisualSPHysics/build/CMakeFiles/CMakeOutput.log". Microsoft(R) 生成引擎版本 12.0.31101.0 [Microsoft .NET framework 版本 4.0.30319.42000] 版权所有 (C) Microsoft Corporation。保留所有权利。 MSBUILD : error MSB1009: 项目文件不存在。 开关: ALL_BUILD.vcxproj CPack: Create package using ZIP CPack: Install projects CPack: - Install project: VisualSPHysics [] CPack Error: Error when generating package: VisualSPHysics |
此方法实际上是在电脑上对源代码(source)重新编译,放弃。
后续参见步骤(11)
(9)继续尝试直接使用已编译好的版本,根据Blender提示信息:
| Traceback (most recent call last): File " importError: DLL load failed while importing vtkimporter: 找不到指定的模块。 |
根据下列链接,DLL load failed错误时,说明可以找到该模块对应的.pyd文件,但无法找到该.pyd文件对应的dll文件。提供的解决方法为 将对应的同名.dll文件路径放到环境变量PATH中。(或将该.dll文件放到PATH能找到的目录下)
Python import / pyd / dll - 没有什么能够阻挡 - 博客园
为了查找依赖哪些dll文件,提供两种思路:
①尝试使用depends软件查询2个pyd文件链接了哪些dll文件。(推荐)
Depends下载地址:Dependency Walker (depends.exe) Home Page
②直接从源代码中查看依赖哪些dll文件。
采用方案①,depends成功运行,查看vtkimported.pyd,提示如下dll文件均未找到:
| …(省略系统文件) PYTHON37.DLL …(省略系统文件) HVSIFILETRUST.DLL IESHIMS.DLL |
忽略系统文件,缺少的dll文件包括:PYTHON37.DLL、HVSIFILETRUST.DLL、IESHIMS.DLL,从网站下载dll文件并放入C:WindowsSystem32中。
免费下载缺失的 DLL 文件 | DLL‑files.com
再对diffuseparticles.pyd文件进行查看,提示如下:
| …(省略系统文件) |
除系统文件外,没有额外的dll文件缺失。
确认环境变量PATH设置。对“此电脑”右键->属性->高级系统设置,选择“环境变量”,对用户变量和系统变量“Path”进行编辑,添加文件夹“C:WindowsSystem32”。
再次尝试Blender插入VisualSPHysics插件。提示如下:
| Traceback (most recent call last): File "D:Blender2.93scriptsmodulesaddon_utils.py", line 351, in enable mod = __import__(module_name) File "C:UserslenovoAppDataRoamingBlender FoundationBlender2.93scriptsaddonsVisualSPHysics.py", line 30, in import vtkimporter importError: Module use of python37.dll conflicts with this version of Python. |
删除python37.dll。提示如下:
| Traceback (most recent call last): File "D:Blender2.93scriptsmodulesaddon_utils.py", line 351, in enable mod = __import__(module_name) File "C:UserslenovoAppDataRoamingBlender FoundationBlender2.93scriptsaddonsVisualSPHysics.py", line 30, in import vtkimporter importError: DLL load failed while importing vtkimporter: 找不到指定的模块。 |
仍未解决问题!
(10)看到依赖的dll文件中包括python37.dll,而加入后会与Blender2.93内置的python冲突,推测是Blender2.93内置的Python版本过高导致不能运行。
重新下载08 Jul 2021发布的VisualSPHysics1..2..1的Release版本。作者注明“The precompiled addon now supports Blender v2.93 and higher.”说明Blender2.93应当与该版本匹配。
相同问题,用depends进行查看。
通过查阅网络教程得知,前方标注为红色方块的dll文件也应注意,因而再找出属于这一部分的dll文件。教程链接:
用depends 来解决dll文件缺失等相关的问题 使用方法_Nancy_fairy的博客-CSDN博客
查看depends的Help手册了解各标识含义如下:
统计标有红色方块且非系统dll文件如下:
KERNEL32.DLL
MSVCRT.DLL
IESHIMS.DLL(这个是上一步中补充过的dll文件!)
IEframe.DLL
IERTUTIL.DLL
SHCORE.DLL
SHLWAPI.DLL
且注意到除第一个KERNEL32.DLL文件的Subsystem为Console外,Subsystem均为GUI。
KERNEL32.DLL为关键的内核文件,暂不修复。
且注意到IESHIMS.DLL对应CPU为x86,因此先对IESHIMS.DLL进行修复。
(10.1)IESHIMS.DLL
到上述网站中重新下载该文件的x64版本,再使用depends检测,发现已经能够正常加载。
(10.2)MSVCRT.DLL
加载IESHIMS.DLL后MSVCRT.DLL也能够正常加载了。
(10.3)IEframe.DLL
替换该文件时被阻止,提示需要权限,即使进入安全模式仍无权限,暂时放弃。
后续参见步骤(12)
(11)重新尝试步骤(8)。下载1.2.1版本源代码尝试用Cmake进行编译。注意到Cmake3.1之后的版本移除了VTK相关模块,步骤(8)中使用的Cmake为3.22.0版本,因此卸载并下载3.0.0版本的Cmake进行编译。
更正:似乎并非这里的原因!仍使用3.22.0版本,要进行VTK的安装!
用win+R搜索powershell,并执行下列命令:
| cd D:SPHVisualSPHysics-1.2.1-sourceVisualSPHysics-1.2.1 mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=RELEASE cmake --build . --config RELEASE cpack |
提示如下:
| -- The C compiler identification is MSVC 18.0.31101.0 -- The CXX compiler identification is MSVC 18.0.31101.0 -- Check for working C compiler using: Visual Studio 12 2013 -- Check for working C compiler using: Visual Studio 12 2013 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler using: Visual Studio 12 2013 -- Check for working CXX compiler using: Visual Studio 12 2013 -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found PythonLibs: D:/Python/Python39/libs/python39.lib (found suitable version "3.9.1", minimum required is "3") -- VTK not found. Set the VTK_DIR cmake cache entry to the directory containing VTKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/vtk for an installation. For VTK 4.0, this is the location of UseVTK.cmake. This is either the root of the build tree or PREFIX/include/vtk for an installation. CMake Error at foamsimulator/CMakeLists.txt:8 (if): if given arguments: "VTK_VERSION" "VERSION_GREATER_EQUAL" "8.90.0" Unknown arguments specified -- Configuring incomplete, errors occurred! See also "D:/SPH/VisualSPHysics-1.2.1-source/VisualSPHysics-1.2.1/build/CMakeFiles/CMakeOutput.log". Error: could not find CMAKE_GENERATOR in Cache CPack: Create package using ZIP CPack Error: Cannot find description file name: [D:/CMake/share/cmake-3.22/Templates/CPack.GenericDescription.txt] CPack Error: Error when generating package: VisualSPHysics |
应当安装VTK软件。下载VTK8.2.0并借助Cmake3.22.0安装。安装过程中提示如下:
| CMake Error at CMakeLists.txt:3 (project): Configuring incomplete, errors occurred! See also "D:/VTK9.1.0-install/CMakeFiles/CMakeOutput.log". |
推测是编译器选择问题,但没有找到更改编译器的选项,暂时放弃。
(12)重新尝试步骤(10)
设想以下思路解决无权限问题:
新建文件夹DLL,并将其路径加入Path中,在DLL文件夹中放入重新下载的dll文件,再尝试运行。
(12.1)IEframe.DLL
运行depends时发现仍使用c:windowssystem32IEframe.DLL,尝试调整PATH中的顺序。
没有效果,depends仍调用c:windowssystem32IEframe.DLL。
尝试更改权限。失败
再次运行Blender,成功加载Object:VisualSPHysics模块。原因暂时不明
三、小结
VisualSPHysics在Blender中安装失败的原因主要有以下几点(针对Release版):
(1)未安装g++。按以下网址安装即可。
Windows下 gcc/g++的安装与配置 - 对弈 - 博客园
(2)VisualSPHysics调用的dll文件缺失。用Depends软件对封装好的pyd文件查找缺失的dll文件(可忽略带前缀的系统dll文件),并从网上下载添加到环境变量Path的路径下即可。
Depends官网:Dependency Walker (depends.exe) Home Page
DLL-Files网:免费下载缺失的 DLL 文件 | DLL‑files.com
(3)VisualSPHysics版本与Blender版本不相符。目前(2021.11.30)可稳定运行的版本是VisualSPHysics1.2.1与Blender2.93。
安装完成后,首先在DualSPHysics或DesignSPHysics中用IsoSurface输出vtk文件,再在Blender中加载插件,导入vtk文件,进行添加光源、更换材质、模拟泡沫等操作,最后渲染成动画或图片即可。
参考文献
[1] O García-Feal, Crespo A , M Gómez-Gesteira. VisualSPHysics: advanced fluid visualization for SPH models[J]. Computational Particle Mechanics, 2021:1-14.
[2] O García-Feal, Crespo A , JM Domínguez, et al. Advanced fluid visualisation with DualSPHysics and Blender[C]// 11th International SPHERIC Workshop. 2016.



