The CCM specification is a loose specification where data is stored in pieces, rather than in a strict domain-subdomain hierarchy. This allows the flexibility for future changes. Similarly, the CCMIO API is also fairly loose. It has a knowledge of different entities and a defined hierarchy, but the functions are not strongly hierarchical. This puts part of the burden of following the hierarchy on the user of the API. Thus it is helpful to refer to the CCM specification while using the CCMIO API.
The API is divided into three sections: the Intermediate API, the Core API, and utility functions. The Intermediate API is the main API for reading and writing CCM files. The Core API is the lowest-level API, and is mostly a wrapper around the ADF library. This API is intended for use in writing the Intermediate API, but is provided in case the Intermediate API is not sufficient. There are also some strictly unnecessary but helpful functions in both the Intermediate and Core APIs that are classified as utility functions. The functions for optional nodes in the Intermediate API are provided to avoid the need to use the Core API, and the Core API has some utility functions to do standard tasks more quickly.
The CCMIO API has been written in C to avoid incompatibilities and differing standards between C++ compilers and libraries on the many platforms that CD-adapco supports. Unfortunately, this means that some internal data structures are exposed in the header files. These should not be be used; all CCMIO structures should be treated as opaque objects. In the rare case that you need to drop down to the Core API, the function CCMIOGetEntityNode() should be used to get the CCMIONode corresponding to the CCMIOEntity.
Design Considerations
The API makes certain assumptions about the nature of usability; these are:
- Compile-time checking: more type-safe functions are better than fewer functions that take structures and switch parameters to determine behavior. Unfortunately, because C does not have polymorphic functions or inheritance, this leads to more functions than are desirable. We feel that although the function count may be larger, the API will be easier to use (and debug) than if a few functions each did many somewhat related tasks.
- No dynamic data: the API will not create arrays for the caller; the caller is responsible for determining the size of any array passed to the API. (The API will, of course, provide access to the necessary sizes.) There is one exception: some functions in the Core API will allocate memory which must be then freed by the caller. These, however, should really only be used within the library itself.
- Easy error handling: error handling requires one check at the end of all the function calls to the API; it is not necessary to check errors after every library call. This is accomplished by means of passing the error to each function (or NULL, if the check is to be avoided); if an error has already occurred, the function will do nothing, and if an error does occur, the value of the error parameter will be updated. Return values of all functions will be the value of the error parameter, for convenience of the caller. Of course, error handling may be performed as often as desired, however it need not be done after every call. (Please see the CCMIO Error Handling section for more details)
Caveats
- The CCMIO library currently uses ADF as the underlying file format. Unfortunately, deleting ADF nodes, as is necessary when rewriting mesh and post results, leads to fragmentation and loss of usable file space. This means that the ADF file will usually grow each time data is changed. A function, CCMIOCompress(), has been provided to compress the file to its minimum size, and should be called judiciously.
- The ADF format is particularly slow for large numbers of nodes. Deleting 300 nodes, for instance, can take tens of seconds. So unless it is absolutely necessary, we recommend each entity or node having less than 100 children. (This is mostly likely to be an issue with boundary face nodes)
- You may wish to use an ADF viewer to assist in debugging. A Tcl/Tk tool is available at the CGNS website. This requires Tcl/Tk 8.3. Download both cgnslib and cgnstools.
Generated on Mon Jun 5 17:16:02 2006 for libccmio by
1.2.18