|
[Sponsors] |
September 17, 2017, 14:50 |
code for product of rho and velocity
|
#1 |
Member
ARAVIND SRIDHARA
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
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 |
|
September 17, 2017, 22:12 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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" 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_UDMI(c,t,0)=rho*u; } end_c_loop(c,t) } } 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 |
|
September 18, 2017, 02:20 |
|
#3 | |
Member
ARAVIND SRIDHARA
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
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. |
||
September 19, 2017, 00:41 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Hello
Try this code Code:
#include "udf.h" DEFINE_ON_DEMAND(my_density) { Domain *domain; Thread *t; cell_t c; real rho, u; real x[ND_ND]; domain= Get_Domain(1); thread_loop_c (t,domain) { begin_c_loop (c,t) { C_CENTROID(x,c,t); rho = C_R(c,t); u = C_U(c,t); C_UDMI(c,t,0)=rho; C_UDMI(c,t,1)=u; C_UDMI(c,t,2)=rho*u; } end_c_loop(c,t) } Message0("\n On demand executed\n"); } |
|
September 19, 2017, 04:59 |
|
#5 |
Senior Member
|
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. |
|
September 21, 2017, 07:11 |
|
#6 | |
Member
ARAVIND SRIDHARA
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
Quote:
Thank you |
||
September 21, 2017, 07:17 |
|
#7 | |
Member
ARAVIND SRIDHARA
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
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. |
||
September 21, 2017, 07:23 |
|
#8 |
Senior Member
|
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. |
|
September 22, 2017, 03:27 |
|
#9 | |
Member
ARAVIND SRIDHARA
Join Date: Jan 2017
Posts: 32
Rep Power: 9 |
Quote:
Thank you |
||
Tags |
segmentaion fault, udf code, udmi.uds, udsi |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem about Rotor simulation whit high rotating speed | Thomas pan | OpenFOAM Running, Solving & CFD | 4 | June 20, 2018 07:24 |
Problem with SIMPLEC-like finite volume channel flow boundary conditions | ghobold | Main CFD Forum | 3 | June 15, 2015 12:14 |
settlingFoam crash when velocity increase | jimbean | OpenFOAM Running, Solving & CFD | 1 | March 26, 2014 04:59 |
should Courant number always be kept below 1? | wc34071209 | OpenFOAM Running, Solving & CFD | 16 | March 9, 2014 20:31 |
Why RNGkepsilon model gives floating error | shipman | OpenFOAM Running, Solving & CFD | 3 | September 7, 2013 09:00 |