|
[Sponsors] |
Injection initialization generate a segmentation fault!! |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 3, 2019, 18:28 |
Injection initialization generate a segmentation fault!!
|
#1 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
Hello!
I am trying to track the particle trajectory by DPM model using unsteady tracking. First I simulate steady flow for my continuous phase without activating DPM model, after convergence, I import the profile of velocity and temperature at the outlet for using it as inlet conditions for the new simulation with the DPM. Now I want to assign the velocity and temperature of the fluid to particles in each injection. However, my domain is a cylinder so I have to work with the cylindrical coordinates. I used this UDF to impose to particles the velocity of the flow when they will be injected(initialization). The code was compiled successfully but when calculation started I get a Segmentation fault. Code:
#include "mem.h" #define Boltzmann 1.3806505e-23 #define pi 3.14159265358979323846 #define nu_f 0.001075 #define b1 0.186 #define b2 0.653 #define b3 0.437 #define b4 7178.74 Domain *d; /******initializes particle injection properties********/ /************************************************** *****/ DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Particle *p; cell_t c=RP_CELL(&(p->cCell)); Thread *t=RP_THREAD(&(p->cCell)); real NV_VEC(origin), NV_VEC(axis),NV_VEC(V), NV_VEC(r), NV_VEC(R), NV_VEC(B),NV_VEC(W),NV_VEC(del),NV_VEC(delT),NV_VEC(er), NV_VEC(et),NV_VEC(M),NV_VEC(J); real xc[ND_ND]; real Bmag, rmag,pver,pvet,pvaxis; real ua, ur, ut; ///transforme the coordinates into cylindrical field/////// /* Get origin vector of fluid region */ NV_V(origin, =, THREAD_VAR(t).cell.origin); /* Get axis of fluid region */ NV_V (axis, =, THREAD_VAR(t).cell.axis); /* Store the 3 cartesian velocity components in vector V */ N3V_D(V, =, C_U(c,t),C_V(c,t),C_W(c,t)); /* Get current cell coordinate */ C_CENTROID(xc,c,t); /* Calculate (R) = (Xc)-(Origin) */ NV_VV(R, =, xc, -, origin); /* Calculate |B| = (R) dot (axis)*/ Bmag = NV_DOT(R,axis); /* Calculate (B) = |B|*axis */ NV_VS(B,=,axis,*,Bmag); /* Calculate (r) = (R)-(B) This is the local radial vector*/ NV_VV(r, =, R, -, B); /* Calculate |r|*/ rmag = NV_MAG(r); if (rmag != 0.) { NV_VS (er,=,r,/,rmag); NV_CROSS(et, axis, er); ur = NV_DOT(V,er); ut = NV_DOT(V,et); ua = NV_DOT(V,axis); } else { ur = 0.0; ut = 0.0; ua = NV_DOT(V,axis); } N3V_D(M, =,P_VEL(p)[0],P_VEL(p)[1],P_VEL(p)[2]); NV_VS (er,=,r,/,rmag); NV_CROSS(et, axis, er); pver = NV_DOT(M,er); pvet = NV_DOT(M,et); pvaxis = NV_DOT(M,axis); loop(p,I->p_init) { cell_t c=RP_CELL(&(p->cCell)); Thread *t=RP_THREAD(&(p->cCell)); pver=ur; pvet =ut; pvaxis=ua; P_T(p)=C_T(c,t); } } Last edited by zahrae; July 5, 2019 at 17:36. |
|
July 4, 2019, 01:04 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
use message0 macro to figure out which line leads to error
best regards |
|
July 5, 2019, 17:33 |
|
#3 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
Thanks for your reply!
I Insert the message0 macro after each line, but it didn't show me anything, it still generates the same error. Any suggestions? Code:
#include "udf.h" #include "dpm.h" #include "mem.h" #include "math.h" #define Boltzmann 1.3806505e-23 #define pi 3.14159265358979323846 #define nu_f 0.001075 #define b1 0.186 #define b2 0.653 #define b3 0.437 #define b4 7178.74 /******initializes particle injection properties********/ /************************************************** *****/ DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Domain *d; Particle *p; cell_t c=RP_CELL(&(p->cCell)); Thread *t=RP_THREAD(&(p->cCell)); real NV_VEC(origin), NV_VEC(axis),NV_VEC(V), NV_VEC(r), NV_VEC(R), NV_VEC(B),NV_VEC(W),NV_VEC(del),NV_VEC(delT),NV_VEC(er), NV_VEC(et),NV_VEC(M),NV_VEC(J); real xc[ND_ND]; real Bmag, rmag,pver,pvet,pvaxis; real ua, ur, ut; Message("point a\n"); ///transforme the coordinates into cylindrical field/////// /* Get origin vector of fluid region */ NV_V(origin, =, THREAD_VAR(t).cell.origin); Message(" point 1 \n"); /* Get axis of fluid region */ NV_V (axis, =, THREAD_VAR(t).cell.axis); Message(" point 2 \n"); /* Store the 3 cartesian velocity components in vector V */ N3V_D(V, =, C_U(c,t),C_V(c,t),C_W(c,t)); Message(" point 3 \n"); /* Get current cell coordinate */ C_CENTROID(xc,c,t); Message(" point 4 \n"); /* Calculate (R) = (Xc)-(Origin) */ NV_VV(R, =, xc, -, origin); Message(" point 5 \n"); /* Calculate |B| = (R) dot (axis)*/ Bmag = NV_DOT(R,axis); Message(" point 6 \n"); /* Calculate (B) = |B|*axis */ NV_VS(B,=,axis,*,Bmag); Message(" point 7 \n"); /* Calculate (r) = (R)-(B) This is the local radial vector*/ NV_VV(r, =, R, -, B); Message(" point 8 \n"); /* Calculate |r|*/ rmag = NV_MAG(r); Message(" point 9 \n"); if (rmag != 0.) { NV_VS (er,=,r,/,rmag); Message(" point 10 \n"); NV_CROSS(et, axis, er); Message(" point 11 \n"); ur = NV_DOT(V,er); Message(" point 12 \n"); ut = NV_DOT(V,et); Message(" point 13 \n"); ua = NV_DOT(V,axis); Message(" point 14 \n"); } else { ur = 0.0; Message(" point 15 \n"); ut = 0.0; Message(" point 16 \n"); ua = NV_DOT(V,axis); Message(" point 17 \n"); } N3V_D(M, =,P_VEL(p)[0],P_VEL(p)[1],P_VEL(p)[2]); Message(" point 18 \n"); NV_VS (er,=,r,/,rmag); Message(" point 19 \n"); NV_CROSS(et, axis, er); Message(" point 20 \n"); pver = NV_DOT(M,er); Message(" point 21 \n"); pvet = NV_DOT(M,et); Message(" point 22 \n"); pvaxis = NV_DOT(M,axis); Message(" point 23 \n"); loop(p,I->p_init) { cell_t c=RP_CELL(&(p->cCell)); Message(" point 24 \n"); Thread *t=RP_THREAD(&(p->cCell)); Message(" point 25 \n"); pver=ur; Message(" point 26 \n"); pvet =ut; Message(" point 27 \n"); pvaxis=ua; Message(" point 28 \n"); P_T(p)=C_T(c,t); Message(" point 29 \n"); } } |
|
July 7, 2019, 18:18 |
|
#4 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
AlexanderZ please I need to know if I did something wrong? can you please give me any guidelines?
|
|
July 8, 2019, 01:43 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
the reason could be the fact, that you didn't define domian
add Code:
Domain *d; d=Get_Domain(1); |
|
July 8, 2019, 05:59 |
|
#6 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
I added these two lines in the code but the same error still remain
|
|
July 8, 2019, 07:18 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
show your UDF,
compile it and show log RP_CELL macro is defined in "surf.h" library, which is not defined in your UDF, but you said, you've compiled without errors best regards |
|
July 8, 2019, 20:26 |
|
#8 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
here is the message that I get after compilation:
Code:
> Copied C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier/initial1.c to libudf33\src Creating user_nt.udf file for 3ddp ... (system "copy "C:\PROGRA~1\ANSYSI~1\v170\fluent"\fluent17.0.0\src\udf\makefile_nt.udf "libudf33\win64\3ddp\makefile" ") 1 fichier(s) copi(s). (chdir "libudf33")(chdir "win64\3ddp")# Generating ud_io1.h initial1.c C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier\libudf33\src\initial1.c(20) : warning C4700: variable locale 'p' non initialise utilise # Generating udf_names.c because of makefile initial1.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj initial1.obj Microsoft (R) Incremental Linker Version 14.21.27702.2 Copyright (C) Microsoft Corporation. All rights reserved. Création de la bibliothèque libudf.lib et de l'objet libudf.exp Done. Opening library "C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier\libudf33"... Library "C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier\libudf33\win64\3ddp\libudf.dll" opened inj_vel Done. Code:
> Copied C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier/initialisation.c to libudf32\src Creating user_nt.udf file for 3ddp ... (system "copy "C:\PROGRA~1\ANSYSI~1\v170\fluent"\fluent17.0.0\src\udf\makefile_nt.udf "libudf32\win64\3ddp\makefile" ") 1 fichier(s) copi(s). (chdir "libudf32")(chdir "win64\3ddp")# Generating ud_io1.h initialisation.c C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier\libudf32\src\initialisation.c(22) : warning C4700: variable locale 'p' non initialise utilise # Generating udf_names.c because of makefile initialisation.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj initialisation.obj Microsoft (R) Incremental Linker Version 14.21.27702.2 Copyright (C) Microsoft Corporation. All rights reserved. Création de la bibliothèque libudf.lib et de l'objet libudf.exp Done. Opening library "C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier\libudf32"... Library "C:\Users\hp\Downloads\Compressed\Nouveau dossier\Nouveau dossier\Nouveau dossier\libudf32\win64\3ddp\libudf.dll" opened inj_vel Done. I don't get it, how to initialize the pârticle, I use originally this UDF for initializing my injected particles? |
|
July 9, 2019, 01:57 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
when you run your UDF did you ever get ????
Code:
point a Code:
Message("point a\n"); everywhere I've found this macro it is used as Boolean (true or false) how this should work from your point of view? Code:
NV_V(origin, =, THREAD_VAR(t).cell.origin); Code:
#include "udf.h" #include "dpm.h" #include "mem.h" #include "math.h" #define Boltzmann 1.3806505e-23 #define pi 3.14159265358979323846 #define nu_f 0.001075 #define b1 0.186 #define b2 0.653 #define b3 0.437 #define b4 7178.74 /******initializes particle injection properties********/ /************************************************** *****/ DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Domain *d; Particle *p; cell_t c=RP_CELL(&(p->cCell)); Thread *t=RP_THREAD(&(p->cCell)); real NV_VEC(origin), NV_VEC(axis),NV_VEC(V), NV_VEC(r), NV_VEC(R), NV_VEC(B),NV_VEC(W),NV_VEC(del),NV_VEC(delT),NV_VEC(er), NV_VEC(et),NV_VEC(M),NV_VEC(J); real xc[ND_ND]; real Bmag, rmag,pver,pvet,pvaxis; real ua, ur, ut; Message("point a\n"); ///transforme the coordinates into cylindrical field/////// /* Get origin vector of fluid region */ } best regards |
|
July 9, 2019, 12:01 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Your problem is that you forget to loop. See your code (simplified):
Code:
DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Particle *p; cell_t c=RP_CELL(&(p->cCell)); ... } What do you want? You first want p to point to the first particle in the injection. Then to the second. Then to the third. And so on. So it's a loop. And the Fluent manual on DEFINE_DPM_INJECTION_INIT shows how to use this loop! So just add this loop, and let p loop over all particles in the injection: Code:
DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Particle *p; loop(p,I->p) { cell_t c=RP_CELL(&(p->cCell)); ... } } |
|
July 9, 2019, 19:41 |
|
#11 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
AlexanderZ thanks for your cooperation
1-even I use the macro Code:
Message("point a\n"); 2- Actually first I didn't know how to program the conversion from cartesian to cylindrical coordinates by Fluent macros and I did some research. I found Code:
NV_V(origin, =, THREAD_VAR(t).cell.origin); so I use the part of the code in my own program, I think Code:
NV_V(origin, =, THREAD_VAR(t).cell.origin); 3- I run Code:
#include "udf.h" #include "dpm.h" #include "mem.h" #include "math.h" #define Boltzmann 1.3806505e-23 #define pi 3.14159265358979323846 #define nu_f 0.001075 #define b1 0.186 #define b2 0.653 #define b3 0.437 #define b4 7178.74 /******initializes particle injection properties********/ /************************************************** *****/ DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Domain *d; Particle *p; cell_t c=RP_CELL(&(p->cCell)); Thread *t=RP_THREAD(&(p->cCell)); real NV_VEC(origin), NV_VEC(axis),NV_VEC(V), NV_VEC(r), NV_VEC(R), NV_VEC(B),NV_VEC(W),NV_VEC(del),NV_VEC(delT),NV_VEC(er), NV_VEC(et),NV_VEC(M),NV_VEC(J); real xc[ND_ND]; real Bmag, rmag,pver,pvet,pvaxis; real ua, ur, ut; Message("point a\n"); ///transforme the coordinates into cylindrical field/////// /* Get origin vector of fluid region */ } |
|
July 9, 2019, 20:00 |
|
#12 |
Member
imane
Join Date: Aug 2018
Posts: 62
Rep Power: 8 |
pakk thanks for your explanation!
1- I used the Code:
loop(p,I->p_init) { } 2- after your suggestion the warning is gone and also the segmentation fault. I think my program was wrong. I did some changes now, do you think my code is correct now, first I transformed the velocities of fluid and particles from cartesian to cylindrical and I suppose that the velocity and temperature of particles at the inlet of my pipe initially equal to those of the fluid. Code:
#include "udf.h" #include "dpm.h" #include "mem.h" #include "math.h" #define Boltzmann 1.3806505e-23 #define pi 3.14159265358979323846 #define nu_f 0.001075 #define b1 0.186 #define b2 0.653 #define b3 0.437 #define b4 7178.74 /******initializes particle injection properties********/ /************************************************** *****/ DEFINE_DPM_INJECTION_INIT(inj_vel,I) { Domain *d; d=Get_Domain(1); Particle *p; loop(p,I->p_init) { cell_t c=RP_CELL(&(p->cCell)); Thread *t=RP_THREAD(&(p->cCell)); real NV_VEC(origin), NV_VEC(axis),NV_VEC(V), NV_VEC(r), NV_VEC(R), NV_VEC(B),NV_VEC(W),NV_VEC(del),NV_VEC(delT),NV_VEC(er), NV_VEC(et),NV_VEC(M),NV_VEC(J); real xc[ND_ND]; real Bmag, rmag,pver,pvet,pvaxis; real ua, ur, ut; ///transforme the coordinates into cylindrical field/////// /* Get origin vector of fluid region */ NV_V(origin, =, THREAD_VAR(t).cell.origin); /* Get axis of fluid region */ NV_V (axis, =, THREAD_VAR(t).cell.axis); /* Store the 3 cartesian velocity components in vector V */ N3V_D(V, =, C_U(c,t),C_V(c,t),C_W(c,t)); /* Get current cell coordinate */ C_CENTROID(xc,c,t); /* Calculate (R) = (Xc)-(Origin) */ NV_VV(R, =, xc, -, origin); /* Calculate |B| = (R) dot (axis)*/ Bmag = NV_DOT(R,axis); /* Calculate (B) = |B|*axis */ NV_VS(B,=,axis,*,Bmag); /* Calculate (r) = (R)-(B) This is the local radial vector*/ NV_VV(r, =, R, -, B); /* Calculate |r|*/ rmag = NV_MAG(r); if (rmag != 0.) { NV_VS (er,=,r,/,rmag); NV_CROSS(et, axis, er); ur = NV_DOT(V,er); ut = NV_DOT(V,et); ua = NV_DOT(V,axis); pver = NV_DOT(M,er); pvet = NV_DOT(M,et); pvaxis = NV_DOT(M,axis); } else { ur = 0.0; ut = 0.0; ua = NV_DOT(V,axis); pver = 0.0; pvet =0.0; pvaxis = NV_DOT(M,axis); } pver=ur; pvet =ut; pvaxis=ua; P_T(p)=C_T(c,t); } } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Segmentation fault | Tushar_Telmasre | Fluent UDF and Scheme Programming | 4 | June 1, 2017 17:19 |
injection problem | Mark New | FLUENT | 0 | August 4, 2013 02:30 |
segmentation fault when installing OF-2.1.1 on a cluster | Rebecca513 | OpenFOAM Installation | 9 | July 31, 2012 16:06 |
Segmentation Fault | Shawn_A | OpenFOAM Running, Solving & CFD | 6 | October 31, 2011 15:38 |
KIVA and Segmentation Fault | Felix | Main CFD Forum | 2 | January 18, 2006 02:24 |