Ansys Common Fluids Factory API
Last update: 16.07.2025Introduction
Before reading or writing to a Common Fluids Restart or Common Fluids Post file it is necessary to obtain an instance of the API. Two factory methods exist to obtain an instance of the API for obtaining an object to:
Obtaining an Object to Read a CFF File
To read a CFF file, you must first create an instance of the ansys::CffProvider API.
A factory method exists to perform this action:
ansys::getDataProvider should be used to obtain an ansys::CffFileProvider object.
This object is a subclass of ansys::CffProvider, specifically handling files.
Although you are specifying a file name to the factory when requesting a new provider, the object isn't aware of the filename you have used to create the object at this stage.
The reason for this is that the provider created is unaware as to whether the filename you provided is expected to contain mesh, topology and settings information (in other words, a cas file) or is expected to contain solution data (in other words, a dat file).
How to determine which cas file goes with which dat file?
For some simulations you may find that there are multiple cas and dat files available.
If these are referenced from within a CFFProject file to access the CFFRestart or CFFPost files the association between a dat file and a specific cas file can be explictly found within the Project data. See Project API.
If you don't have a CFFProject file, you cannot always assume that the cas file associated with the dat file will always have the same name. In fact in the case of a transient sequence it is likely that each dat file may be different from the cas files. In this case you should always determine the cas file to use from the information found within the dat file.
This can be done by opening the dat file first and requesting a specific setting using the function below:
After finding out the name of the cas file it is preferable to destroy the instance of the provider just created and create a new one, as is shown below.
You can now specify the files to the new instance of the ansys::CfFileProvider by follwing the instructions here.
Obtaining an Object to Write a CFF File
To write a file using the CFF API you must first obtain a ansys::CffFileConsumer object.
You should then set the file attributes you require. For example:
The file can then be opened:
The functions in the ansys::CffConsumer class can then be used to write your data.