|
[Sponsors] |
Error in UDF for storing specie mass fraction gradients |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 12, 2021, 08:29 |
Error in UDF for area weighted average of specie mass fraction gradients
|
#1 |
New Member
Iota
Join Date: Jan 2021
Posts: 5
Rep Power: 5 |
Hello every body and good morning. Hope you all are doing well in this horrible pandemic situation.
I am recently writing a udf to calculate at first and then store in UDM (later) the area weighted average specie mass fraction gradient at the fixed boundary.I can do it very easily manually in the surface integral menu of the post processing.However i want to use it in udf for some other operation.This at first seem quite easy task as a lot of information is present in manual. I come up with the following UDF: DEFINE_EXECUTE_AT_END(execute_at_end) { Domain *domain; Thread *t; cell_t c; real area[ND_ND]; real total_area = 0.0; real total_area_ave_grad = 0.0; real G_mean; int ID = 4; /* outlet ID displayed in Fluent boundary conditions panel */ domain = Get_Domain(1); t = Lookup_Thread(domain, ID); begin_c_loop(c, t) { F_AREA(area, c, t); total_area += NV_MAG(area); total_area_ave_grad += NV_MAG(area)*sqrt(C_YI_G(c,t,0)[0]*C_YI_G(c,t,0)[0] + C_YI_G(c,t,0)[1]*C_YI_G(c,t,0)[1]); ; end_c_loop(c, t) } G_mean = total_area_ave_grad/total_area;/* Weighted average of the mass fraction gradeint */ printf("Area averaged gradient: %g\n", G_mean); fflush(stdout); } The code is complied and hooked without any problem but after running the following error appear as attached. What i have already done so far: (Not useful at all) 1. Run on serial node. 2. Include mem.h header file. 3. Use solve/set/expert and gradient save option. 4. Run for few iterations then hook the udf. 5. Tested this code for temperature. Which mean problem is with C_YI_G(c,t,0). Please help me by suggesting necessary solution to this problem as it is frustrating me now. Thank you so much for your kindness. Kind regards. Last edited by iota; January 12, 2021 at 09:53. Reason: Missing details |
|
January 12, 2021, 15:24 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The manual says about that variable: "C_YI_G can be used only in the density-based solver. To use this in the pressure-based solver, you will need to set the rpvar 'species/save-gradients? to #t".
|
|
January 12, 2021, 17:28 |
|
#3 | |
New Member
Iota
Join Date: Jan 2021
Posts: 5
Rep Power: 5 |
Quote:
Therefore, i do not know what is the real problem with memory access or may be i am missing something key one. Thank you so much once again. Kind regards, |
||
January 13, 2021, 02:02 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
F_AREA(area, c, t); arguments are: F_AREA(A,f,t) you are trying to put cell inside as an argument so you need loop over faces not cells. How you code should change i'm not sure. probably you should use gradient from adjusted to face cell using t0 c0 macros btw it is possible to transfer information with data which you are able to get using TUI commands to UDF, ofc it has some limitations. how are you going to use this integral further?
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 13, 2021, 08:20 |
|
#5 | |
New Member
Iota
Join Date: Jan 2021
Posts: 5
Rep Power: 5 |
Quote:
Later on, I do realize the last part of your message which i did not consider previously. Actually i was planning to store this integral in a UDM and call it in other udf function. After your comment i revisit the udf manual and found that UDM exist for face, cell and node and not for any numerical output. I did not find much at present how to import data from TUI to another UDF. This put me in another problem. I will be more thankful if you provide me another quick hint on this part. I will be very thankful for you in this regard. I really appreciate your previous comment. It really helps. Thank you so much. Kind regards, |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inconsistencies in reading .dat file during run time in new injection model | Scram_1 | OpenFOAM | 0 | March 23, 2018 23:29 |
compile of new combination of property in thermophisicalpropery | milad653279 | OpenFOAM Running, Solving & CFD | 4 | April 6, 2017 05:35 |
Water subcooled boiling | Attesz | CFX | 7 | January 5, 2013 04:32 |
Simulation with UDF for species mass fraction and velocity profile | virgy | Fluent UDF and Scheme Programming | 8 | February 7, 2012 05:30 |
PB: Saving mass fraction of species on two points with an udf | biget.a | FLUENT | 2 | July 23, 2009 04:06 |