The Configuration Exporter
allows computational enginers
to export simulation's results to VTK files.
.
The provided code is the export package of my Ph.D. work, which eases the exportation of numerical simulations' configurations to VTK files, where ParaView supports it for post-processing.
If you answer one of the following questions with NO, then this code probably is no help for you.
- Do you have knowledge of numerical simulations?
- Do you use C++17 for your models?
- Are you searching for a way to reduce your simulations' exportation cost in a safe way?
The Configuration Exporter is not the faster nor the most optimized code for exporting configurations to the VTK format. Configuration Exporter is developed to address the following problems:
- In the world of computational engineering, we always search to reduce the cost of computation. However, the secondary costs like exporting the simulations' results often take a large portion of the resources, which are preferable to be dedicated to running the simulation itself. The Configuration Exporter utilizes a series of temporary files and flushes the simulation result into them immediately as they become available. Thus it allocates resources as minimum as possible during run time.
- To provide better post-processing experience, simulators often use a separate post-processing software. The data will then be stored inside a database or a binary file format. This approach, however, demands that the user wait until the simulation is over. The Configuration Exporter provides the means to export the modeling stages (i.e., configurations) parallel to the simulation. Thus the end-user can start post-processing simulation results in parallel with undergoing analyses. This allows the researcher to stop the simulation if the desired result is not achieved or simulation is not propagated as assumed.
The code uses some of the C++17
features, thus a compatible compiler is required.
No installation required, simply download or fork the code and start using it.
-
Include the
Configuration Exporter
to your project by forking this repository. -
Include the
Configuration Exporter
to your simulation core.#include "exporting/VTK.h" using namespace exporting::vtk;
-
Create a
VTKFile
:auto pointCluster = File(path , "point-cluster", "vtk");
or
VTKFileSeries
:auto vtkSeries = FileSeries(desktopPath, "all_cells", "vtk", 20);
-
Append cells and their point-map to the VTK file,
for(Counter cell = 0; cell < numberOfPoints; cell++) pointClusterFile.appendCell(Cell::Vertex, {points[cell]});
or any other
vtd::Cell
to the file series,vtkSeries.at(11).appendCell(Cell::Hexahedron, {points[0], points[8], points[9], points[10], points[11], points[12], points[13], points[14]});
-
Create as many attributes as required. Attributes are extra information in the form of scalar, vector, and tensor that can be applied to either point or cell as the source of that attribute.
- first set the source (i.e,
AttSource::Point
orAttSource::Cell
) of the attribute
pointCluster["distance_double"].setSource(AttSource::Point);
- next set the type of the attribute (
AttType::Scalar
,AttType::Vector
, orAttType::Tensor
):
pointCluster["distance_double"].setAttributeType(AttType::Scalar);
- Finally, append the attribute values to the file, keep in mind that the order of the attribute data is the same as the point (if
AttSource::Point
is selected), or cells (ifAttSource::Cell
is selected).
pointCluster["distance_to_origin"].appendAttribute(distances);
- first set the source (i.e,
-
Assemble the files.
pointCluster.assemble(true);
vtkSeries.at(11).assemble(true);
-
Open the files with ParaView and explore them.
You can find complete code to create the above example (point cluster) and more in the 'examples'
directory of this repository.
Note that the Qt Creator is used to provide examples because it is a cross-platform IDE, and QMake provides simple syntax. To run the examples,
- first, on your machine, copy the content of the example directory to the source directory,
- next, open the QtCreator, and under the
Welcome
window, click onOpen
or go toFile>Open File or Project...
in the menu bar. - next, select the
.pro
file, and click theOpen
button, - next, select the
Desktop <Qt Version> clang
compiler, - the
Qt Creator
will configure a new project namedConfigurationExporter
- next, click on the triangle on the right side of the project to open it,
- next, navigate to the
Sources/<ExampleFileName>.cpp
and double click on it. - next, find the following code and edit it so that
desktopPath
contains your divice absolute desktop path,const string home = "<yourComputeName>"; const string desktopPath = " /Users/" + home + "/Desktop/";
- Finally, run the examples by hitting
cmd
+r
on mac andctrl
+r
on windows and Linux.
The code is well documented using Doxygen.
To contribute to Configuration Exporter
, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b '<feature/mycoolfeature>'
. - Make your changes and commit them:
git commit -m '<your_commit_message>'
- Push to the original branch:
git push origin '<feature/mycoolfeature>'
- Create the pull request.
Alternatively see the GitHub documentation on creating a pull request.
Copyright (c) 2020-present, Ali Jenabidehkordi