User Defined Memory Problem
Hi everbody,
I have a problem that may be a common problem for Fluent Users. I want to see pressure values of a wall by User Defined Memory at every iteration. The thing is that the pressure values are transfered to F_UDMI(t,f,0) in my UDF, but I can not see them in FLUENT. I mean, every values of F_UDMI(t,t,0) are zero in contour values windows in FLUENT. Here is the simple UDF that transfers pressure values to F_UDMI(t,f,0). Could you please tell me what is wrong with it? #include "udf.h" DEFINE_ADJUST(wall_pressure,domain) { face_t f; int ID = 8; /* Zone ID for wall zone */ Thread *t = Lookup_Thread(domain, ID); begin_f_loop(f, t) { F_UDMI(f,t,0) = F_P(f,t); Message("pressure %e\n",F_UDMI(f,t,0)); } end_f_loop(f, t) } |
Re: User Defined Memory Problem
I have had exactly the same problem with the UDMI macro and the good people at the fluent USC couldn't help me much. I had to use a "dirty trick" to get around this one. If you assign the value of the F_UDMI to the adjcent cell you should then be able to see it in, say, a contour or XY plot with in fluent. If you need help doing this I can help you out with the source code, but you seem to know what you are doing, so I will leave it for the moment.
I hope this helps, happy coding. |
Re: User Defined Memory Problem
I had the same problem too. Maybe it's a bug of FLUENT.
Hi :) ap |
Re: User Defined Memory Problem
Have had a similiar problem, and the bug seams to go away (if the same bug) by first viewing the udm with contours (should be all zeros), then run your udf and then replot. It appears that viewing the udm initializies it for use (atleast thats one interpretation).
|
problem regarding user defined memory
i am trying to calculate source term for X-momentum equation by calculating first the average temperature in a mixed convection case.
I want to store the value of mean temperature using user defined memory and use this value to calculate source term in xmomentum equation. i have written the UDF mentioned below: #include "udf.h" DEFINE_ON_DEMAND(on_demand_calc) { real tavg; real temp,volume,vol_tot; Domain*d; Thread*t; int i; cell_t c; tavg = 0.; vol_tot = 0.; d = Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { volume = C_VOLUME(c,t); temp = C_T(c,t)-273.5; vol_tot += volume; tavg += temp*volume; } end_c_loop(c,t) tavg = tavg/vol_tot; } printf("Tavg = %g\n",tavg); printf("volume = %g\n",volume); printf("vol_tot = %g\n",vol_tot); printf("temp = %g\n",temp); thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,0) = tavg; } end_c_loop(c,t) } } DEFINE_SOURCE(mom_source,c,t,dS,eqn) { real x[ND_ND]; real source; C_CENTROID(x,c,t); source= 1.-5.33*(C_T(c,t)-C_UDMI(c,t,0)); dS[eqn]=0.; return source; } but i am getting zero value when i am trying to plot the user defined memory. please help me regarding this. Regards saad |
UDM problem
Quote:
I am also facing the same problem |
I'm facing exactly the same problem, user defined memory contains just zero value !!
please help me regarding this. |
UDM usage
The usage of the UDM in the code given is not its intentional usage. A simple C variables, tavg itself, could be used. UDM is required only if the variable varies over space, i.e., it may have different value corresponding to each cell.
|
Quote:
I've changed my udm into this : DEFINE_ON_DEMAND(essay) { real temp; cell_t c; Thread *t; Domain* d; d = Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,0) = C_U(c,t); } end_c_loop(c,t) } } " as a small test just to know if i succeed to store the x_velocity or no " once i execute , Fluent shuts down and close without showing any error !! I don't know where is exactly the problem. Thanks |
edit: I got a minimal example working, so I posted below.
Reducing unnecessary stuff and deleted my post here. |
C_UDMI for C_U
Toufik, your code is alright. The issue could be that either the UDM does not exist or you did not initialize it.
First, check if the UDM exists, Go to User-Defined > Memory and ensure that at least one memory exists. Second important part is its initialization. Using UDM without initialization gives error. There are two ways to initialize it. The easiest is to use Patch within Initialization Dialogue box. Use Patch, select UDM, select all cell zones, and patch with value of 0. Other option is to do initialization within the UDF. Once these two processes are done, the UDF should work fine assuming C_U exists, i.e., you have at least one fluid domain and the flow is initialized or solved. |
Incomplete Code
Martin, the code is incomplete or at least not posted here in its complete form. adj_relhum and myHumdity functions are missing. Furthermore, min_mass, max_mass, min_heat, and max_heat variables are undefined. The enum section for UDMs is missing as well. Even if those functions exist, their output is not being used in this code. But enum section or equivalent is required. Values for UDMs are being set to 0, hence, numbers will remain 0. Message reported is as expected from the code since there are no values available for min_mass, etc.
|
Dear Vinerm,
thanks for the thorough answer. Yes, the Code was incomplete, because I wanted to Keep it short - though that's not helpful in the end, as it turns out. I reduced the Code to an example, which is more easy to read, though it is still not minimal. I compiled and loaded UDFs, have enough UDMs reserved through GUI. And newly, I patched the UDMs before calculation - read that somewhere here, thanks for that hint. Then I ran a few steps and turns out, the humidity is calculated correctly. Code:
/****************************************************************** So I'll Keep my example as a working one so far for others - if that is OK?! When I manage to get the other UDMs working, I'll report the solution. |
Caveats
There are a few caveats in the code. First, it assumes that you have water vapor in the gas mixture and second assumption is that it is first in the list of the names that show in the Species list.
demister_mass_source function fetches the relative humidity but does not use it. The value returned is always 0. So, your second UDM will always be 0. Same is true for demister_heat_source function and, consequently, the third UDM is 0 as well. There are some useful checks for ensuring if there are other libraries loaded along with this one that also use UDMs. But those are overkill if this library is not to be used with other libraries. Lastly, molwt_air is declared and defined but never used. |
Sorry again for leaving parts out in the code… well, not leaving out, but I cut it to simplify and search for Errors and had a few unnecessary leftovers in the code.
As far as I can reconstruct my work, it might most likely have been the fault of not patching the UDMs. Despite that I found mistakes here and there. In the end, I want to provide a working example for everyone here. If anyone has additional questions to the specific use or whatever, feel free to write a personal message, as I don't have notifications on the thread. Hope this helps anyone and I didn't hijack this thread for Nothing. Martin Code:
/****************************************************************** |
Is it working
Is the code working properly now or do you face any issues?
|
Yes,
it's working absolutely properly - as far as I could investigate. Should it not? Because I already stated that above. Only issue: convergence is a bit slower, but generally working - I needed about 12-15 iterations per time step instead of less than 10. Reducing time step might be another solution as well. |
Good
Nice to know that it is working. 12-15 iterations per time-step is optimal.
|
All times are GMT -4. The time now is 13:59. |