|
[Sponsors] |
How can we save flow variables in a file by udf? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 22, 2012, 18:05 |
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: 14 |
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 |
|
December 23, 2012, 00:42 |
|
#2 |
Senior Member
SSL
Join Date: Oct 2012
Posts: 226
Rep Power: 15 |
May you please share your UDF here to check?
|
|
December 23, 2012, 06:22 |
|
#3 |
New Member
Mohammad Sobhani
Join Date: Sep 2012
Location: Iran, Tehran
Posts: 8
Rep Power: 14 |
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 ); } |
|
December 23, 2012, 09:03 |
|
#4 |
Senior Member
SSL
Join Date: Oct 2012
Posts: 226
Rep Power: 15 |
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. |
|
December 23, 2012, 17:28 |
|
#5 |
New Member
Mohammad Sobhani
Join Date: Sep 2012
Location: Iran, Tehran
Posts: 8
Rep Power: 14 |
I changed my udf due to your idea ! but it is doesn't run yet !!!!
ممنون از اینکه وقت گذاشتید و فایل رو بررسی کردید |
|
December 25, 2012, 10:21 |
|
#6 | |
New Member
Fangdian
Join Date: Aug 2012
Posts: 19
Rep Power: 14 |
Quote:
can't it pass the compile? |
||
Tags |
export matrix, macros, post procesing, steady state, udf |
|
|
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 11:03 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |
pisoFoam compiling error with OF 1.7.1 on MAC OSX | Greg Givogue | OpenFOAM Programming & Development | 3 | March 4, 2011 18:18 |
1.7.x Environment Variables on Linux 10.04 | rasma | OpenFOAM Installation | 9 | July 30, 2010 05:43 |
PHI file structure | Eugene | Phoenics | 9 | November 2, 2001 23:00 |