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

Simulation takes too long time - Applying w/m to cells, UDF works

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 14, 2017, 09:32
Default Simulation takes too long time - Applying w/m to cells, UDF works
  #1
Member
 
Join Date: Nov 2016
Posts: 67
Rep Power: 3
h0rst is on a distinguished road
Hello everybody,

from APDL, i extracted mesh and w/m created in a tube flowed through by water.
I imported the mesh in the Fluent model. The w/m I took from a .txt file which I created with Apdl and applied the w/m to each cell by UDF which works. The source code is as follows:




#include "udf.h"
#define lines 6672
DEFINE_SOURCE(energy_source,cell,thread,dS,eqn)
{
FILE *hs;
int n;
real x[ND_ND];
real source = 0.;

float array1[lines];

if (1==1)
{
hs=fopen("ejheatcoord.txt","r");

for (n=0;n<lines;n++)
{
fscanf(hs,"%g",&array1[n]);
}
fclose(hs);
}

C_CENTROID(x,cell,thread);
dS[eqn] = 0;

source=array1[cell];

return source;
}




I hooked the Udf as a source term to cell conditions of the tube.

If I simplify the model (6672 elements), it takes 5 minutes for one iteration.
When I do not simplify this which is necessary, I use 130000 elements.

Any ideas how to fasten up the calculating process?


Best regards
h0rst
h0rst is offline   Reply With Quote

Old   January 14, 2017, 09:48
Default
  #2
Senior Member
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,620
Rep Power: 26
flotus1 will become famous soon enoughflotus1 will become famous soon enough
What your UDF does: For EVERY iteration and EVERY cell, it reads the whole file and then adjusts the source value for this one cell. Even if the source value was supposed to change during the iteration process, this would be unnecessarily complicated.
Can't you use a profile file instead that is read once at the beginning of the simulation? Not absolutely sure if this is possible with a source term. Otherwise, use a second UDF that reads the file at the beginning of the simulation once to speed things up.
__________________
Please do not send me CFD-related questions via PM
flotus1 is offline   Reply With Quote

Old   January 14, 2017, 10:47
Default
  #3
Member
 
Join Date: Nov 2016
Posts: 67
Rep Power: 3
h0rst is on a distinguished road
Thank you for the fast answer!

I see your point and would like to do it with 2 Udfs.

The problem is, that when I interpret UDF, I can always only chose one.

Do I need to compile or is it somehow possible to have two Udf's used by using the interpreter?



Best regards
h0rst
h0rst is offline   Reply With Quote

Old   January 14, 2017, 11:14
Default
  #4
Senior Member
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,620
Rep Power: 26
flotus1 will become famous soon enoughflotus1 will become famous soon enough
Did you put both UDFs in the same file? This should usually work even in interpreted mode.
With execution speed and parallelism in mind, you might need to switch to compiled mode sooner or later.
__________________
Please do not send me CFD-related questions via PM
flotus1 is offline   Reply With Quote

Old   January 14, 2017, 12:24
Default
  #5
Member
 
Join Date: Nov 2016
Posts: 67
Rep Power: 3
h0rst is on a distinguished road
it worked out

thank you so much!
h0rst is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 07:47
mixerVesselAMI2D's mass is not balancing sharonyue OpenFOAM Running, Solving & CFD 6 June 10, 2013 09:34
Discrete event simulation vs. fixed time (discrete time simulation) jenjon FLUENT 0 March 10, 2013 07:58
AMI speed performance danny123 OpenFOAM 19 October 24, 2012 07:44


All times are GMT -4. The time now is 00:38.