|
发表于 2011-1-11 21:47:52
|
显示全部楼层
回复 1# liuzheyoungman 的帖子
Data_Valid_P is defined in the id.h header file, and is included in udf.h. The function returns 1 (true) if the data that is passed as an argument is valid, and 0 (false) if it is not.
You can check that the cell values of the variables that appear in your UDF are accessible before you use them in a computation by using the Data_Valid_P macro.
Suppose you read a case file and, in the process, load a UDF. If the UDF performs a calculation using variables that have not yet been initialized, such as the velocity at interior cells, then an error will occur. To avoid this kind of error, an if else condition can be added to your code. If ( if) the data are available, the function can be computed in the normal way. If the data are not available ( else), then no calculation, or a trivial calculation can be performed instead. Once the flow field has been initialized, the function can be reinvoked so that the correct calculation can be performed. |
|