code for product of rho and velocity
Hii all
I am simulation 3D compressible supersonic flow with hydrogen as fuel and air as oxidizer. I want to write a UDF for mixing efficiency which involves surface integral of (Y**u). where y is species mass fraction, ρ is density , u is velocity. and plot the same along axial length. Since i am learning to write Udf i started of with writing a simple code to find product of ρ*u and allocate these scalar to a memory. so thst i can use the in postprocessing. The code looks as follows. The code is able to interpret but getting fatal signal (segmentation error) while executing. Can u guys please help me in correcting my code. #include "udf.h" DEFINE_ON_DEMAND(density) { Thread *t; cell_t c; real rho, u; domain= Get_Domain(1); thread_loop_c (t,domain) { begin_c_loop (c,t) { rho = C_R(c,t); u = C_U(c,t); C_UDSI(c,t,0)= rho*u; } end_c_loop(c,t) begin_c_loop(c,t) { C_UDMI(c,t,0)=rho*u; } end_c_loop(c,t) } } Please help me in correcting my code |
Hello.
to get the value of rho*u you do not need scalar (UDSI), you need variable (UDMI) only. UDSI is used to define User-Defined Scalar (UDS) Transport Equations, see ANSYS Fluent Customization Manual: 2.7. User-Defined Scalar (UDS) Transport Equation DEFINE Macros ANSYS Fluent Theory Guide: 1.3. User-Defined Scalar (UDS) Transport Equations Code:
#include "udf.h" Go to User-Defined -> Memory -> User Defined Memory locations -> 1 (was 0). This is number of udm variables that you use in UDF. Now you can plot rho*u the same way, as you plot for example velocity, find User Defined Memory... in the drop down list Best regards |
Quote:
i have allocated user defined memory location as 1, and implemented the code u had suggested (i.e the same code u wrote above). but still i am getting error as '' Received a fatal signal (Segmentation fault)''. Can u please help me in resolving this issue. I am modelling 3D supersonic compressible flows using pressure based and k-e for turbulence. and i use species transport to define mixture properties for h2-air. |
Hello
Try this code Code:
#include "udf.h" |
A segmentation fault inevitably means you are accessing some memory location you are not supposed to access.
My first shot would be that you either have not initialized the solution or that something related to the species transport has to be considered (just guessing, I expect the density to depend on the species concentration, so accessing it in a DEFINE_ON_DEMAND udf might be dangerous as you might try to access it when it is not yet available). Usually, the best way to debug something is to make it more simple, not the opposite. Start with just the cell centroid (useful for debug, because always present). Then try just with the velocity (no species effect should be present). Then the density (maybe some species effect is present for DEFINE_ON_DEMAND). According to where the problem comes out you take further steps. |
Quote:
Thank you |
Quote:
Error: Error code: 193\n Error Object: #f can u tell me y i am getting this error? I have installed microsoft visual studio v17.0. |
So, interpreting works with all the variables?
I have no idea of what that error means. If interpreting works, I would first stick to that. Only later I would bother with compiling, as any troubles can then be related just to the compilation process and not the udf in itself. |
Quote:
Thank you |
All times are GMT -4. The time now is 22:51. |