Skip to main content

Common Fluids Format 2024 R2

Ansys Common Fluids API

Last update: 16.07.2025

Introduction

The Ansys Common Fluids Data Models have been implemented as CFF Restart or CFF Post files. Each file contains data associated with a specifc point solution.

When a set of point solutions exist, a set of files will exist and those files may be sequenced using a Project file. A Project file should be read or written using the Project API.

The Ansys Common Fluids Application Programers Interface (CFF API or API) provides several classes, functions, and enumerated types that provide methods to read, write, and modify a number of data models. Data models exist for Mesh, Topology, Physics, and Solution data.

During the setup phase, typically you will set up data within the Mesh, Topology, and Physics data models. This document refers to the combination of these three models as a Case.

A solver will typically extract the data stored with the Case, solve the simulation, and store output data in the Solution data model. Within this document we also refer to this as the Results.

A post-processor will typically need access to both the Case and the Solution models.

APIs are provided to obtain an instance of the API for:

Once obtained, the object returned can be used to:

  • Read Case or Results data

or

  • Write Case or Results data

Background to Using the Common Fluids API

The API is implemented in 'C++'. Familiarity with with C++ and the Standard Template Library (STL) will enable you to quickly use the CFF API to access data in a CFF file within your application.

Additional 'C' wrappers have been provided but they do not fully implement all the functionality in the C++ API.

The API consists of a number of classes, functions, and enumerated types. These all exist within the ansys C++ namespace. You must use the namespace name when using functionality in the API.

APIs are provided to write the Case and Results to independent files, which allows a single instance of the Case file to be used with multiple Results files. Similarly, APIs exist to read back the data from any file written.

For example, ansys::CffFileProvider is a subclass of ansys::CffProvider and simply provides some additional file access functionality.

Using the Common Fluids Format API

The API is provided as a number of dynamically linked library / shared objects and a number of header files within the Ansys Common Fluids Format SDK.

You must include the header files and link the libraries into your program during compilation.

Opening Files for Read

Before you can open a file, you must have an instance of ansys::CffFileProvider. Refer to Obtaining an Object to Read a CFF File, which details how to obtain an instance from the Factory methods.

Once you have an object you will be able to open case and results files for read.

Opening Case (cas) and Results (dat) Files for Read

Having obtained an instance of ansys::CffFileProvider, you will now need to start reading from the appropriate files. The following code shows how this is done.

if (provider || !provider->startReading(casFileName, ansys::DataClass::CFF_CASE)) {
std::cerr << "Unable to read cas file" << std::endl;
exit(1);
}
if (!provider->startReading(datFileName, ansys::DataClass::CFF_RESULTS)) {
std::cerr << "Unable to read dat file" << std::endl;
exit(1);
}
// Both files are now open and ready for processing.
Class that provides functions to access data stored within a CFF file.
Definition: CffFileProvider.hpp:18
bool startReading(const std::string &file, DataClass dataClass)
Start reading data of the class specified from the file passed in.
Definition: CffFileProviderMethods.cpp:38
@ CFF_CASE
Definition: CffTypes.h:419
@ CFF_RESULTS
Definition: CffTypes.h:421
ANSYS_FLUIDS_FACTORY_DLL CffFileProvider * getDataProvider(const std::string &sourceFile)
A function that provides that obtains an instance of an ansys::CffFileProvider that can be used to re...
Definition: providers.cpp:105
Note
In order to read the dat file successfuly it is always necessary to start reading the correct cas file first.

APIIndex

Connect with Ansys