|
[Sponsors] |
Simulation takes too long time - Applying w/m³ to cells, UDF works |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 14, 2017, 09:32 |
Simulation takes too long time - Applying w/m³ to cells, UDF works
|
#1 |
Member
Join Date: Nov 2016
Posts: 73
Rep Power: 10 |
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 |
|
January 14, 2017, 09:48 |
|
#2 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
January 14, 2017, 10:47 |
|
#3 |
Member
Join Date: Nov 2016
Posts: 73
Rep Power: 10 |
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 |
|
January 14, 2017, 11:14 |
|
#4 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
January 14, 2017, 12:24 |
|
#5 |
Member
Join Date: Nov 2016
Posts: 73
Rep Power: 10 |
it worked out
thank you so much! |
|
|
|
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 |