You can access the last calculated report definition value for any report definition you
created in Fluent using the Get_Report_Definition_Values
API.
Before calling this API you must either specify the output arguments as
NULL or allocate appropriate memory to them. The API will fill
the output arguments that are not specified as NULL. If memory is
not appropriately allocated, the calculation run may crash or result in unexpected
behavior.
int Get_Report_Definition_Values(const char* name, int timeStep/iteration, int* nrOfvalues, real* values, int* ids, int* index)
A return value of 0 means the call was successful,
1 means the specified report definition does not exist.
|
Argument Type |
Description |
|
|
name of the report definition |
|
|
flag with a value of 0 or 1. 0 provides the value calculated at an iteration, 1 provides the value at a time-step. (1 is only valid for unsteady calculations.) |
|
int* [output] |
number of values available for the report definition |
|
real* [output] |
values for the report definition |
|
** int* [output] |
surface/zone ids corresponding to the values |
|
int* [output] |
calculation index |
|
** If the per-zone or per-surface option is disabled and the number of
surfaces/zones is greater than 1, the surface/zone id will return
|
The following example shows how to use the API for a steady-state case:
int nrOfvalues=0;
real *values;
int *ids;
int index;
int counter;
/*First call to get the number of values. For number of values,
the int pointer is passed, which is 0 for iterations.*/
int rv = Get_Report_Definition_Values("report-def-0", 0, &nrOfvalues, NULL, NULL,NULL);
if (rv==0 && nrOfvalues)
{
Message("Report definition evaluated at iteration has %d values\n", nrOfvalues);
/*Memory is allocated for values and ids.*/
values = (real*) malloc(sizeof(real)* nrOfvalues);
ids = (int*) malloc(sizeof(int)* nrOfvalues);
/* Second call to get data. The number of values is null, but the last
* three are not.*/
rv = Get_Report_Definition_Values("report-def-0", 0, NULL, values, ids, &index);
Message("Values correspond to iteration index:%d\n", index);
for ( counter = 0; counter < nrOfvalues; counter++ )
{
Message("report definition values: %d, %f\n", ids[counter], values[counter]);
}
/*Memory is freed.*/
free(values);
free(ids);
}
else
{
/*The command can be unsuccessful if the report definition does not exist
or if it has not been evaluated yet.*/
if (rv == 1)
{
Message("report definition: %s does not exist\n", "report-def-0");
}
else if ( nrOfvalues == 0 )
{
Message("report definition: %s not evaluated at iteration level\n", "report-def-0");
}
}
The following example shows how to use the API for a transient case:
int nrOfvalues=0;
real *values;
int *ids;
int index;
int counter;
/*First call to get the number of values. For number of values,
the int pointer is passed, which is 1 for timesteps.*/
int rv = Get_Report_Definition_Values("report-def-0", 1, &nrOfvalues, NULL, NULL,NULL);
if (rv==0 && nrOfvalues)
{
Message("Report definition evaluated at time-step has %d values\n", nrOfvalues);
/*Memory is allocated for values and ids.*/
values = (real*) malloc(sizeof(real)* nrOfvalues);
ids = (int*) malloc(sizeof(int)* nrOfvalues);
/* Second call to get data. The number of values is null, but the last
* three are not.*/
rv = Get_Report_Definition_Values("report-def-0", 1, NULL, values, ids, &index);
Message("Values correspond to time-step index:%d\n", index);
for ( counter = 0; counter < nrOfvalues; counter++ )
{
Message("report definition values: %d, %f\n", ids[counter], values[counter]);
}
/*Memory is freed.*/
free(values);
free(ids);
}
else
{
/*The command can be unsuccessful if the report definition does not exist
or if it has not been evaluated yet.*/
if (rv == 1)
{
Message("report definition: %s does not exist\n", "report-def-0");
}
else if ( nrOfvalues == 0 )
{
Message("report definition: %s not evaluated at time-step level\n", "report-def-0");
}
}