Sunday, May 26, 2024

Export the CAE simulation result files in WELSIM

 Modern general-purpose CAE simulation software has a high degree of integration, especially since many commercial software no longer support the export of computational results. This creates some limitations for using result data in third-party software. For example, users may wish to export result data or perform special processing on the results, such as coupling computation. The general-purpose CAE simulation software WELSIM provides a results export feature, allowing users to quickly and conveniently obtain result files.

Currently, there are two ways to export results: exporting all historical results or exporting the results at the current time step.

Exporting All-Time History Results

For transient analysis, the results will contain data from multiple time steps. Users can export the results from all time steps at once. Supported formats include binary PVD and ASCII PVD. For detailed information about the PVD format, you can refer to the article “ParaView Data (pvd) file format and writing”.

To achieve this, find the “Export All Results” command in the right-click context menu of the solution node and click it.

After selecting “Export All Results,” a dialog box will prompt you to enter a file name. Here you can choose to export in ASCII or binary format.

Afterward, you will be able to find the exported result files at the target path. As shown below, the entry file for the results set is called WelSim_Results.pvd. It can be directly read by open-source post-processing software, such as ParaView. Each folder corresponds to the result data at a specific time step.

Exporting Current Time Step Results

Sometimes, users only need the result data at a certain time step, like the final step result of a steady-state analysis. In order to do this, you can click the corresponding results object, set the “Set Number,” and select “Export Result” from the right-click context menu to export the results at the current time step. Supported file formats include VTU, PVTU, classic VTK, Tecplot, and text. The exported result file will contain all types of results at the current time step.

After selecting “Export Result,” you will be prompted to enter a file name where you can choose the export format.

In this example, the PVTU format was chosen for export. Users can open this file in ParaView or VisIt software to engage in post-processing work in these third-party software.

For more details on saving files in VTU/VTK format, you can refer to the article “Exporting VTK Format Result Data from WELSIM”.

Conclusion

WELSIM provides mainstream result file formats. For time-based transient analysis results, you can export the entire time history in PVD format. For steady-state results, you can export in VTU, PVTU, VTK, or Tecplot formats.

All exported files contain the mesh data of nodes and elements.

With the continuance of new updated versions, WELSIM will support more types of result files.

WELSIM and the author are not affiliated with ParaView, VTK, and TecPlot. ParaView, VTK, and TecPlot are used only as a nominative reference to the open-source projects and software developed and released by these teams or institutions.

Friday, May 17, 2024

WELSIM中导出CAE仿真结果数据文件

 现代通用CAE仿真软件集成度高,尤其是很多商业软件已经不再支持计算结果的导出。这对于结果数据在第三方软件上的使用带来了一些限制。有时用户希望能导出计算结果,或者对结果进行特殊处理,如耦合计算等。通用CAE仿真软件WELSIM提供了结果导出功能,用户可以快速便捷地获得计算结果文件。

目前,计算结果的导出支持两种方式,一是保存所有历史结果,另一个是保存当前时间步下的结果。

导出全部时间历程结果

对于瞬态分析,结果会含有多个时间步的数据。用户可以一次性导出全部时间步下的结果。支持格式有二进制的pvd和ASCII的pvd,关于pvd格式的详细内容可以参见《ParaView数据文件(pvd)的格式与读写》一文。

实现方法是,在结果节点的右键弹出菜单中,找到Export All Results命令,并点击。

选择Export All Results后,会弹出对话框提示输入文件名,同时可以选择导出格式为ASCII还是二进制。

之后就能够在目标路径中,得到导出的结果文件了。 如下图所示,WelSim_Results.pvd是结果集的入口文件,可以用开源后处理软件ParaView等直接读取。每个文件夹对应一个时间步下的结果数据。

导出当前时间步结果

有时,我们只需要当前时间步下的结果数据,如稳态分析的最后一步结果。可以点击对应的结果节点,设置Set Number,在右键弹出菜单中选择Export Result导出当前时间步下的结果。支持的文件格式有vtu, pvtu, 经典vtk, Tecplot, 和文本。导出的结果文件会包含当前时间步下的所有类型的结果。

选择Export Result后,会提示输入文件名,同时可以选择导出的格式。

本文算例中选择了导出pvtu格式的文件,用户可以在ParaView或VisIt软件中打开此文件,并在这些第三方软件中从事后处理工作。

关于保存为vtu/vtk格式文件的内容,还可以参见《从WELSIM中导出VTK格式的结果数据》一文。

总结

WELSIM提供了主流的结果文件格式,对于基于时间的瞬态分析结果,可以pvd格式导出全部时间历程下的结果。对于稳态结果,可以导出vtu, pvtu, vtk或Tecplot格式。

所有的导出文件中都含有节点与单元的网格信息。

随着版本的迭代与更新,WELSIM中会支持更多的结果文件类型。

WelSim不隶属于ParaView,VTK,Tecplot。和ParaView,VTK, Tecplot 的开发者没有直接关系。这里引用ParaView,VTK, Tecplot 仅用作技术博客文章与软件使用的参考。

Tuesday, May 14, 2024

WELSIM releases the 2024R2, supporting more open-source solvers

 The general-purpose engineering simulation software WELSIM has released its latest 2024R2 (internal version 2.9). Compared to its previous releases, the 2024R2 version contains many new features and enhancements, which can better support various types of engineering simulation analysis.

Added support for CalculiX

The new 2024R2 version adds a pre-processing module for the CalculiX solver, allowing users to quickly generate input scripts required for CalculiX computation, or directly call CalculiX for solving through WELSIM.

Currently, 60 commands are supported, which accounts for 42% of all CalculiX commands. All of which are core commands, capable of common analysis needs.

Added support for Elmer FEM

The new version adds pre-processing support for Elmer FEM, allowing users to quickly generate input scripts required for Elmer FEM calculations. Upon successful export, a solver input script named elmer_welsim.sif will be generated, along with a mesh dataset consisting of four files named mesh.header, mesh.nodes, mesh.elements, and mesh.boundary.

Users can also directly call Elmer FEM for calculations through WELSIM. Currently supported Elmer equations include: Coil Solver, Fluidic Force, Free Surface Reduced, Heat Equation, MagnetoDynamics, Mesh Update, Navier-Stokes, Poisson BEM, Save Line, Save Scalars, Static Electrical Solver, Static Current Solver, Stress Analysis, Stream Solver, etc.

WELSIM introduced a new Additional Solver object to support users in adding various Elmer solver settings.

Enhancements

To conclude, the 2024R2 version has new features and improvements, such as adding a search function to the solver output window, and supporting the import and export of csv format files for the table window. WELSIM has added a specific gas constant material property. Furthermore, the free material editing software MatEditor has added the feature to export material data in CalculiX and Elmer FEM formats.

The automatic testing system has become more user-friendly and contains more tests. WELSIM has created support for reading and saving of test group files *.wstb, and support for the deletion of selected test cases. WELSIM now also provides system-level operations, such as deleting local files and confirming specified files. In the new 2024R2 version, more than 200 test cases can be found and utilized.

WELSIM and the author are not affiliated with CalculiX and Elmer FEM. CalculiX and Elmer FEM is used only as a nominative reference to the open-source project and software developed and released by these teams or institutions.

Building an automated testing system for graphical software using QtTesting

 Automated testing is an essential component of modern large-scale software. High amounts of automated test cases are used to maintain the stability of large software products. For the software with a graphical user interface (GUI), establishing an automated testing system can be challenging due to limited resources. Previously, the author has written articles on automated testing for engineering simulation CAE software, see “Automated Testing for General-Purpose Engineering Simulation CAE Software”, “Quickly Create Regression Test Cases for WELSIM”, and “Automated Regression Testing for General-Purpose Engineering Simulation CAE Software”. This article presents how to use QtTesting to quickly implement an automated testing system for graphical software from a software development perspective.

QtTesting is an open-source testing framework with a friendly license, similar to BSD3, and can be used for commercial products. It has been applied in practical instances for large-scale software such as VTK, ParaView, Slider3D, and WELSIM, proving to be an effective and user-friendly testing framework. As long as the software utilizes QT as its GUI framework, QtTesting can be used as the foundational component for the testing system. The source code of QtTesting can be directly downloaded from https://gitlab.kitware.com/paraview/qttesting or https://github.com/Kitware/QtTesting.

QtTesting is officially endorsed for UI testing. Although, in practical use, it not only can test GUI, but also can test any other functionalities of a product through the properties provided by the GUI, such as the accuracy of calculation results. Many of the numerical results in WELSIM can be validated through the functionality of QtTesting.

QtTesting Framework

The Testing Module of QtTesting consists of two major modules: Translator and Player. Both modules establish connections with widgets in the QT framework to interact with the GUI framework. The translator captures events or signals of the widgets, while the player controls the widgets by traversing all active widgets to obtain the current object of the widget.

Test Translator

The translator module provides users with a fast way to create test files, essentially acting as a macro command for mouse, keyboard, and widget controls. When users perform certain low-level Qt actions such as “mouse movement,” “button press,” “button release,” etc., the generated signals will be captured and converted into higher-level events that can be serialized and played, such as “button activation.” The pqWidgetEventTranslator class and its derived classes play an important role in QtTesting. The derived classes of pqWidgetEventTranslator need to implement the translateEvent() method to handle Qt events and convert signals into high-level events consisting of two strings: a command and a command parameter (which may be empty). Finally, the high-level events are passed to their output container by emitting the recordEvent() signal once or multiple times. This is saved to an XML file, completing the recording of a macro command.

During program execution, pqEventTranslator receives every Qt event that occurs in the entire application runtime and sequentially passes Qt events to each pqWidgetEventTranslator instance. The high-level events emitted by pqEventTranslator can be captured by corresponding observers. Observers either serialize and print the high-level events, or save them. Currently, QtTesting includes two observers, pqEventObserverStdout and pqEventObserverXML, which serialize high-level events to standard screen output and XML files, respectively. Developers can also create their own observers to implement custom functions, such as serializing events to log files or Python scripts.

The translator module can also record check events, such as verifying a property. During the check, an overlay will be drawn on the widget where the mouse hovers. A green overlay indicates that the widget can be checked; if the overlay is red, it indicates otherwise. When clicking on the widget for checking, a check event will be recorded, and a related QString value will be output. This feature is a crucial part when verifying numerical results in WELSIM automated testing.

Running Tests

The essence of running automated tests is to play back recorded macro commands. In the QtTesting framework, pqEventSource provides an abstract interface for objects that provide a stream of “high-level events.” pqXMLEventSource inherits from pqEventSource and implements specific functionality. It is capable of reading XML files generated by pqEventObserverXML.

pqEventPlayer maintains a set of pqWidgetEventPlayer objects responsible for converting high-level events into low-level events. pqEventDispatcher retrieves events from pqEventSource and passes them to an instance of pqEventPlayer for execution. During runtime, each high-level event is encoded into three strings (object pointer, command, and parameters). Those are passed to pqEventPlayer::playEvent(). pqEventPlayer decodes the pointer address and uses it to locate the corresponding widget. Then, pqEventPlayer passes the high-level event and widget to each pqWidgetEventPlayer until one emits a signal indicating the event has been handled.

Creating New Translators and Players

A new translator must at least reimplement the translateEvent(QObject object, QEvent event, int eventType, bool& error) method. First, it must check if the object is of the correct class. Then, it should handle the case of pqEventTypes::ACTION_EVENT, saving the command and related parameters. Sometimes it should also be able to handle pqEventTypes::CHECK_EVENT.

Similarly, a new player should at least reimplement the playEvent(QObject* object, const QString& command, const QString& arguments, int eventType, bool& error) method. First, it should handle pqEventTypes::ACTION_EVENT, converting the read command and parameters into Qt commands, returning true for events it can handle. For checking commands, it should be able to handle the pqEventTypes::CHECK_EVENT event type. Using the provided command and parameters to check the current value of the Qt object, it should set the error variable to false in case of different values, but it should return true for all handled check events, even failed ones.

Sometimes translator and player classes will correspond one-to-one. Developers can refer to pqLineEditEventTranslator and pqLineEditEventPlayer for simple examples, and pqAbstractItemViewEventTranslatorBase/pqAbstractItemViewEventPlayerBase for advanced examples.

Running Tests

The source code of QtTesting is easy to compile, provided with a CMake program, which allows quick compilation into a static or dynamic library. Since this testing module is called in only a few places in the product, compilation into a static library is appropriate.

QtTesting has been successfully applied in software such as VTK, ParaView, but no test cases are available publicly. Fortunately, the general-purpose engineering simulation software WELSIM not only uses QtTesting as the GUI testing framework, but also open-sourced all test cases. Users can download WELSIM and the test cases to experience automated testing based on QtTesting.

WELSIM’s automated testing user interface is based on the interface of QtTesting, with additional features, such as:

1. Support for reading *.wstb files, which contain a set of *.xml files, allowing for easier reading of multiple test cases at once.

2. Saving failed test cases to *.wstb files. Users do not need to manually select test cases for saving.

3. Adding a right-click context menu for selecting or deselecting test cases.

Developers can also add other functionalities as needed.

Conclusion

QtTesting is a free testing system for Qt GUI frameworks. It not only provides the core functions for capturing QT events and signals, but also offers a user-friendly interface, making it friendly for both developers and end-users. QtTesting can assist software developers with quickly establishing testing systems. Its built-in functionality for capturing and controlling widgets can meet the testing needs of most products, and it is easy to adapt. Developers can add new testing modules based on the widgets of their own products.

We have successfully applied QtTesting to the automated testing of the simulation software WELSIM, achieving great results. The content discussed in this article can be applied not only to CAE simulation software, but also to any graphical software built using the QT framework.

WelSim and the author are not affiliated with Qt or QtTesting. There is no direct relationship between WelSim, the author, and the Qt or QtTesting development teams or organizations. The reference to Qt and QtTesting here is solely for technical blog articles and software usage reference.