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

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

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread 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: 73
Rep Power: 10
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
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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.
flotus1 is offline   Reply With Quote

Old   January 14, 2017, 10:47
Default
  #3
Member
 
Join Date: Nov 2016
Posts: 73
Rep Power: 10
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
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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.
flotus1 is offline   Reply With Quote

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

thank you so much!
h0rst 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
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 05:13
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 08:47
mixerVesselAMI2D's mass is not balancing sharonyue OpenFOAM Running, Solving & CFD 6 June 10, 2013 10:34
Discrete event simulation vs. fixed time (discrete time simulation) jenjon FLUENT 0 March 10, 2013 07:58


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