Using DPF capabilities in an existing project
Last update: 10.07.2023
Using DPF capabilities in an existing project
The Data Processing Framework (DPF) provides numerical simulation users/engineers with a toolbox for accessing and transforming simulation data. It is used to handle complex pre- or post-processing of simulation data within a simulation workflow.
It can be integrated into any existing C++ project.
Prerequisites
To integrate DPF into an existing C++ project, you must have access to the following files of the AWP_ROOT232/dpf/include folder (AWP_ROOT232 being an environment variable defining the root of the Ansys Inc or DPF Server product):
- dpf_api.h
- dpf_api_i.cpp
DPF_HGP_ROOT environment variable must be set to define the location of those files and must be set to follow this tutorial.
Here is the command for Windows: set DPF_HGP_ROOT=%AWP_ROOT232%/dpf/include
It can also be set by editing the environment variables in Windows settings.
Here is the command for Linux: export DPF_HGP_ROOT=${AWP_ROOT232}/dpf/include
Specify location of DPF files
Using Visual Studio
- In the "Properties" of the project, open the "C/C++" tab.
- Switch to the "general" tab. Edit the "Additional Include Directories" section so that it contains the "$(DPF_HGP_ROOT)" field.
- Ensure the compilation is done for the same platform and the build is done using the configuration where the properties have been updated (for example, if the 'Release|x64' properties are modified, build with the 'Release|x64' configuration).
Using CMake
Add the following line in the CMakeLists.txt file:
Integrate DPF into an existing project
In the header file where the DPF capabilities are used, add the following declarations:
Include DPF
This is needed to access DPF capabilities.
Declare DPF LibraryHandle
The LibraryHandle object must be alive all the time DPF is used. It should be unique, instantiated once per project. This is why it is declared as static structure:
Instantiate DPF LibraryHandle
Before using any DPF capabilities, instantiate the LibraryHandle. This initializes DPF. To proceed, add the following line:
For example, it can be added into the main method of the running application.
Use DPF capabilities
Once the LibraryHandle is instantiated, all the DPF capabilities can be used. The following example adds two vectors by components:
Visit the Examples section to learn more about DPF capabilities.
The application can now be compiled.
Run the application
Once the application is compiled, the environment must be updated before running the application: DPF entry point location must be known by the application, using PATH on Windows or LD_LIBRARY_PATH on Linux. The following command can be used.
For Windows:
It can also be set by editing the environment variables in Windows settings.
For Linux:
The application can now be run.
Example full code compiled with Visual Studio on Windows
The following is the complete code showing how to add DPF capabilities in an already existing C++ application which displays "Hello World!".
The following code adds the components of two 3D vectors. It gathers all the instructions previously provided in this section. It can be placed into a IntegrateDpfExample.cpp file, compiled and run:
To compile it with Visual Studio, the following code can be placed into a IntegrateDpfExample.vcxproj file:
Then, the IntegrateDpfExample.vcxproj project can be opened and compiled. Press F5 in Visual Studio to proceed.