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

How to read values from matrix using UDF programming (as initial condition)?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2015, 08:54
Default How to read values from matrix using UDF programming (as initial condition)?
  #1
New Member
 
Hussam Hikmat
Join Date: Sep 2015
Posts: 1
Rep Power: 0
hussam_alziadi86 is on a distinguished road
I have two matrices ones is the u-component velocity and the other is v-component velocity,I am trying to read the values of these two matrices and put them as an initial conditions in the domain of my model. I use the code below but I do not know how to read the values from the matrices and then write them into the model.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include "udf.h"
#define pi 4.*atan(1.)

DEFINE_INIT(uv_intial,d)
{

cell_t c;
Thread *t;
real xc[ND_ND];
FILE *fp;

real r1;
real xo1 = 0.00;
real yo1 = 0.00;

/* loop over all cell threads in the domain */
thread_loop_c(t,d)
{
/* loop over all cells */
begin_c_loop_all(c,t)
{
C_CENTROID(xc,c,t);

r1=sqrt(ND_SUM(pow(xc[0] - xo1,2.),
pow(xc[1] - yo1,2.),
pow(xc[2] - 0,2.)));
/* Note xc[0] is x coordinate, xc[1] is y and xc[2] is z */

if ( r1 != 0.0)
{
fp=fopen("u.txt","r");

fscanf(fp,"lf% %lf",&r1,&u);

DEFINE_RW_FILE(uv_intial,fp)


C_U(c,t) =
C_V(c,t) =
}
else
{
C_U(c,t) = 0.0;
C_V(c,t) = 0.0;
}

}

end_c_loop_all(c,t)
fclose(fp);
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


thanks in advance for your help
hussam_alziadi86 is offline   Reply With Quote

Reply


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
Problem with chtMultiregionFoam radiation boundary condition baran_foam OpenFOAM Running, Solving & CFD 10 December 17, 2019 17:36
a problem with convergence in buoyantSimpleFoam skuznet OpenFOAM Running, Solving & CFD 6 November 15, 2017 12:12
Wrong fluctuation of pressure in transient simulation caitao OpenFOAM Running, Solving & CFD 2 March 5, 2015 21:33
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Orifice Plate with a fully developed flow - Problems with convergence jonmec OpenFOAM Running, Solving & CFD 3 July 28, 2011 05:24


All times are GMT -4. The time now is 16:33.