Flowtime tends to "wander" in an transient ensight .encas file



While exporting data in transient ensignt format from a fluent simulation
one might sometimes observe that the flowtime recorded in the .encas file
increases and decreases randomly rather than increaseing continuously
as one would expect.

This apparently happens due to a bug in ensight export. While the bug is
being fixed use the following UDF to fix the problem. See comments at the top
of the UDF source code for usage instructions. Copy and paste the following
UDF in a fine named correct-encas-flowtime.c
/********************************************************************/
/* This is a user defined function for use with Fluent6.1 */
/* filename: correct-encas-flowtime.c */
/* */
/* It is found that the flow time recorded in the .encas */
/* file created while doing a transient ensight export from */
/* from Fluent tends to "wander," i.e. the recorded flowtime */
/* increases and decreases randomly rather than increasing */
/* continuously as one would expect. This is apparently a bug */
/* in Fluent and while it is being repaired, this UDF should */
/* serve as a workaround to "realign" the flowtime in the */
/* .encas file */
/* */
/* USAGE: */
/* 1)Start fluent session; open case/data; setup transient */
/* ensight export */
/* 2)Open this UDF source code in a text editor. In the */
/* function DEFINE_ON_DEMAND change the original encas */
/* filename to that of the ensight casefile name that */
/* you have provided while setting up the transient */
/* ensight export. See the comment in that function */
/* to pinpoint the line where this change has to be made */
/* 3)Save this UDF source code in a file named correct-encas-flowtime.c */
/* 4)In the Fluent session go to DEFINE->USER-DEFINED->FUNCTIONS->COMPILED */
/* and compile and load this UDF */
/* See the UDF Manual on <a target=_blank href="http://www.fluentusers.com">http://www.fluentusers.com</a>http://www.fluentusers.com for more details */
/* 5)Go to DEFINE->USER-DEFINED->FUNCTION-HOOKS Under Execute-at-end */
/* function choose "store_flowtime" */
/* 6)Start iterating */
/* 7)After the case has fully iterated go to DEFINE->USER-DEFINED-> */
/* EXECUTE ON DEMAND select the function "correct_encas" */
/* and click execute */
/* 8)In your working directory you will find a new file created */
/* named "new.encas". This is the corrected encas file. Overwrite */
/* your old encas file with this new encas file */
/* 9)You will also notice a file "temporary-flowtime-storage.txt" */
/* created in your working directory. Ignore/delete it. */
/* */
/* */
/* If there are any questions, please contact your Fluent Support */
/* Engineer */
/* */
/* */
/* Created by: */
/* ********************************* */
/* Sandeep Sovani, Ph.D. */
/* Technical Support Engineer */
/* Fluent Inc. */
/* 220 E. Huron St, Suite 470 */
/* Ann Arbor MI 48104 */
/* Tel: (734)213-6821 x35 */
/* FAX: (734)213-0147 */
/* ********************************* */
/* 27th August 2003 */
/************************************************************************** */

#include "udf.h"

DEFINE_EXECUTE_AT_END(store_flowtime)
{
real time;

FILE *storefile;
storefile = fopen("temporary-flowtime-storage.txt","a");

time = RP_Get_Real("flow-time");

fprintf(storefile,"%g ",time);
fclose(storefile);

printf("Current flowtime entered into temporary storage.n");
}

DEFINE_ON_DEMAND(correct_encas)
{
char c1 = 'a';
char c2 = 'a';
char c3 = 'a';
char c4 = 'a';
char c5 = 'a';
char c;

int flag = 1;

FILE *original;
FILE *new;
FILE *timestorage;

/* Change the filename in the following command to that desired */
original = fopen("original.encas", "r");
new = fopen("new.encas", "w");
timestorage = fopen("temporary-flowtime-storage.txt", "r");

if(original==NULL)
{
printf("ERROR: can't open file the original encas file.n");
printf("Make sure you have specified the correct filename forn");
printf("the original encas file in the UDF source code and try again...n");
}
else
{
while(flag)
{
c5 = c4;
c4 = c3;
c3 = c2;
c2 = c1;
c1 = c;

c = fgetc(original);

if(c5 == 'l' && c4 == 'u' && c3 == 'e' && c2 == 's')
flag = 0;

fprintf(new,"%c",c);

}
}

if(timestorage==NULL)
{
printf("ERROR: can't open file the time storage file.n");
printf("Search for the file temporary-flowtime-storage.txt andn");
printf("move it to your working directory. Then try again...n");
}
else
{
while(1)
{
c = fgetc(timestorage);
if(c!=EOF)
fprintf(new,"%c", c);
else
break;
}
fclose(timestorage);
}

fprintf(new,"nFILE");

while(1)
{
c5 = c4;
c4 = c3;
c3 = c2;
c2 = c1;
c1 = c;

c = fgetc(original);

if(c!=EOF)
{
if(c4 == 'F' && c3 == 'I' && c2 == 'L' && c1 == 'E')
flag = 1;

if(flag == 1)
fprintf(new,"%c", c);

}
else
{
break;
}
}
fclose(original);
fclose(new);
}





Show Form
No comments yet. Be the first to add a comment!