CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   how to store UDF output for arbitrary/particular cell (https://www.cfd-online.com/Forums/fluent/220819-how-store-udf-output-arbitrary-particular-cell.html)

athalia September 23, 2019 12:44

how to store UDF output for arbitrary/particular cell
 
Hello,

as part of my master thesis, I'm trying new drag models on a cold flow laboratory circulating fluidized bed. [Multiphase, Eulerian, transient]

So far I have a written a UDF to calculate the drag coefficient ["DEFINE_EXCHANGE_PROPERTY()"].

I want to store the drag coefficient, calculated by the UDF, for an arbitrary or a particular cell at the end of each Iteration or timestep.

What I've tried so far:

1.
Code:

if(cell == 1000){
        Message("%g \n", drag_coeff);
        }

I don't know, where this cell=1000 is, which is okay for now.

(I tried to find a particular cell by defining a monitoring point and then in
report definition > Facet Average > Cell Info > Cell Id > mixture
retrieved the cell Id for this point. But I'm not sure if I can use it in UDF to address this particular cell)

The problem is that first I'm simulating on a cluster with 24 processors, so have many duplicates. Second, these lines are printed in between of residual reports after each iteration in the journal file. After 10,000 x 30=Iterations, the journal file is HUGE and practically not readable...

2.
Code:

FILE* f = fopen("file.txt", "a");
 
        if(cell == 1000){
        fprintf(f,"%g \n", drag_coeff);
        }
 
        fclose (f);

Here I have the same problem with duplicates because of 24 processors but the main problem is that the simulation becomes SOO SLOOOOOW...
I've seen a suggestion that opening and writing with EXECUTE_ON_DEMAND and EXECUTE_AT_END will stop the simulation from slowing down. But I'm not sure how to write the code. If that's true, I'll be grateful, if someone could help me out.

I'm pretty sure, defining monitoring point and using report definition won't work in my case...?Correct me if I'm wrong.
Are UDMI, UDS or Schemes an option?

AlexanderZ September 24, 2019 05:02

use FILE* f = fopen("file.txt", "a"); before DEFINE_EXCHANGE_PROPERTY()

if you need additional help, show your code

best regards


All times are GMT -4. The time now is 09:13.