CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

How can we save flow variables in a file by udf?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 22, 2012, 17:05
Default How can we save flow variables in a file by udf?
  #1
New Member
 
Mohammad Sobhani
Join Date: Sep 2012
Location: Iran, Tehran
Posts: 8
Rep Power: 13
moh.sob is on a distinguished road
Hi everybody,
I want to calculate rate of deformation tensor in some points around a sphere. so I wrote a UDF , but it doesn't work !!!
Can any body help me that how I can use converged steady solution to calculate velocity gradients, etc.
After that I want to save these data in a txt file. I don't know which macros can export data to a txt file from a udf !!!

Best
moh.sob is offline   Reply With Quote

Old   December 22, 2012, 23:42
Default
  #2
Senior Member
 
SSL
Join Date: Oct 2012
Posts: 226
Rep Power: 14
msaeedsadeghi is on a distinguished road
May you please share your UDF here to check?
msaeedsadeghi is offline   Reply With Quote

Old   December 23, 2012, 05:22
Default
  #3
New Member
 
Mohammad Sobhani
Join Date: Sep 2012
Location: Iran, Tehran
Posts: 8
Rep Power: 13
moh.sob is on a distinguished road
thanks for your reply msaeedsadeghi;

here is my udf:

#include "udf.h"
#include "surf.h"
#include "cxiface.h"
#include "cxndsearch.h"

DEFINE_ON_DEMAND( rate_of_deformation_tensor )
{
/* Note: All the variables must be defined first. */

Domain *d;

/* Determine Coordinates */
cell_t c;
Thread *t;
CX_Cell_Id cx_cell;
real NV_VEC( pt );
real c_centroid[ ND_ND ];
real V_Grad[ ND_ND ][ ND_ND ];
real D[ ND_ND ][ ND_ND ];
int i, j, k;
int thread_id = 7;

FILE *fp;
fp = fopen( "Rate of Deformation Tensor.txt", "w" );

d = Get_Domain(2);

NV_D( pt, =, -3.0, 0.0, 0.0 );

/* Search */

//CX_Start_ND_Point_Search( pt );
//cx_cell = *CX_Find_Cell_With_Point( pt );
//CX_End_ND_Point_Search( );

//c = RP_CELL( &cx_cell ); /* the right cell number */
//t = RP_THREAD( &cx_cell ); /* the thread */
//C_CENTROID( c_centroid, c, t );

//Message( "Coordinate of the specified point: x = %g, y = %g, z = %g\n", pt[0], pt[1], pt[2] );
//Message( "Coordinate of the cell found: x = %g, y = %g, z = %g\n", c_centroid[0], c_centroid[1], c_centroid[2] );


c = 10;
t = Lookup_Thread(d,thread_id) ;;

/*************** Calculate Rate of Deformation Tensor *******/

for( i = 0; i < ND_ND; i++ )
V_Grad[ 0 ][ i ] = C_U_G(c,t)[ i ];

for( j = 0; j < ND_ND; j++ )
V_Grad[ 1 ][ j ] = C_V_G(c,t)[ j ];

for( k = 0; k < ND_ND; k++ )
V_Grad[ 2 ][ k ] = C_W_G(c,t)[ k ];

printf( "Writing UDF data from data file...\n" );

for( i = 0; i < ND_ND; i++ )
{
for( j = 0; j < ND_ND; j++ )
{
D[ i ][ j ] = 0.5 * ( V_Grad[ i ][ j ] + V_Grad[ j ][ i ] );
fprintf( fp, "%g \t", D[ i ][ j] );
//printf( "%g \t", D[ i ][ j] );
}

fprintf( fp, "\n" );
// printf( "\n" );
}

fclose( fp );
}
moh.sob is offline   Reply With Quote

Old   December 23, 2012, 08:03
Default
  #4
Senior Member
 
SSL
Join Date: Oct 2012
Posts: 226
Rep Power: 14
msaeedsadeghi is on a distinguished road
just send "FILE *fp" to before DEFINE_ON_DEMAND, like this:
-------------------------------
#include "udf.h"
#include "surf.h"
#include "cxiface.h"
#include "cxndsearch.h"
FILE *fp;
DEFINE_ON_DEMAND( rate_of_deformation_tensor )
-------------------------------
It have been solved on my computer.
msaeedsadeghi is offline   Reply With Quote

Old   December 23, 2012, 16:28
Default
  #5
New Member
 
Mohammad Sobhani
Join Date: Sep 2012
Location: Iran, Tehran
Posts: 8
Rep Power: 13
moh.sob is on a distinguished road
I changed my udf due to your idea ! but it is doesn't run yet !!!!

ممنون از اینکه وقت گذاشتید و فایل رو بررسی کردید
moh.sob is offline   Reply With Quote

Old   December 25, 2012, 09:21
Default
  #6
New Member
 
Fangdian
Join Date: Aug 2012
Posts: 19
Rep Power: 13
fangdian is on a distinguished road
Quote:
Originally Posted by moh.sob View Post
Hi everybody,
I want to calculate rate of deformation tensor in some points around a sphere. so I wrote a UDF , but it doesn't work !!!
Can any body help me that how I can use converged steady solution to calculate velocity gradients, etc.
After that I want to save these data in a txt file. I don't know which macros can export data to a txt file from a udf !!!

Best
what is the symptom? why can you say it doesn't work?
can't it pass the compile?
fangdian is offline   Reply With Quote

Reply

Tags
export matrix, macros, post procesing, steady state, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 10:03
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18
1.7.x Environment Variables on Linux 10.04 rasma OpenFOAM Installation 9 July 30, 2010 04:43
PHI file structure Eugene Phoenics 9 November 2, 2001 22:00


All times are GMT -4. The time now is 17:07.