|
[Sponsors] |
April 16, 2019, 15:46 |
segmentation fault?
|
#1 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
Kindly read the attachment before going through the code.
sample explanation: Add a source term to the cells adjacent to a wall Problem/Description: How do I add a source term to the cells adjacent to a wall? Solution: A source term can be added with a UDF (using the macro ‘DEFINE_SOURCE’). The UDF below enables: - To add a source term equals to 10 to the cells adjacent to the boundary with the ID equal to ‘boundaryID’ (defined below); - To add a source term equals to 5 to the other cells. The source term is stored in User-Defined Memory (UDM) via the macro DEFINE_ON_DEMAND. The macro DEFINE_SOURCE returns the value of the UDM. If the source term changes during the calculation, the DEFINE_ON_DEMAND macro can be adapted in a DEFINE_ADJUST macro. Here is the code: #include "udf.h" /* This UDF enables - to add a source term equals to 10 to the cells adjacent to the boundary with the ID equals boundaryID (defined below); - to add a source term equals to 5 to the other cells. The source term is stored in User-Defined Memory (UDM) via the macro DEFINE_ON_DEMAND. The macro DEFINE_SOURCE returns the value of the UDM. If the source term changes during the calculation, the DEFINE_ON_DEMAND macro can be adapted in a DEFINE_ADJUST macro. */ int boundaryID=1; DEFINE_SOURCE(source,c,t,dS,eqn) { return C_UDMI(c,t,0); } DEFINE_ON_DEMAND(on_demand_calc) { face_t f; cell_t c; Domain *domain=Get_Domain(1); Thread *t; thread_loop_c(t,domain) { begin_c_loop(c,t) { C_UDMI(c,t,0)=5; } end_c_loop(c,t) } thread_loop_f(t,domain) { if (THREAD_ID(t)==boundaryID) { begin_f_loop(f,t) { C_UDMI(F_C0(f,t),THREAD_T0(t),0)=10; } end_f_loop(f,t) } } Message0("\n\n UDF DONE \n\n"); } My code: DEFINE_ADJUST(calc,domain) { face_t f; Thread *t; real mf_co,mf_co2;/* variable declaration */ real c_co,c_co2;/* variable declaration */ int boundaryID=1; /*wall ID*/ thread_loop_f(t,domain) { if (THREAD_ID(t)==boundaryID) { begin_f_loop(f,t) { mf_co=C_YI(f, t, 3); mf_co2=C_YI(f, t, 4); conc_co=mf_co*C_R(f, t); C_UDMI(F_C0(f,t),THREAD_T0(t),0)=-0.0092976*c_co; } end_f_loop(f,t) } Message0("\n\n UDF DONE \n\n"); } } DEFINE_SOURCE(CO_source,c,t,dS,eqn) { real x[ND_ND]; real source; source = C_UDMI(F_C0(c,t),THREAD_T0(t),0); dS[eqn] = 0.0; return source; } segmentation fault is coming because of this line i guess : C_UDMI(F_C0(f,t),THREAD_T0(t),0)=-0.0092976*c_co; Thanks a lot in advance . Kndly help me out to get rid of this ...................................... |
|
April 17, 2019, 02:19 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try
Code:
DEFINE_ADJUST(calc,domain) { face_t f; Thread *t; real mf_co,mf_co2;/* variable declaration */ real c_co,c_co2;/* variable declaration */ int boundaryID=1; /*wall ID*/ thread_loop_f(t,domain) { if (THREAD_ID(t)==boundaryID) { begin_f_loop(f,t) { mf_co=F_YI(f, t, 3); mf_co2=F_YI(f, t, 4); conc_co=mf_co*F_R(f, t); C_UDMI(F_C0(f,t),THREAD_T0(t),0)=-0.0092976*c_co; } end_f_loop(f,t) } Message0("\n\n UDF DONE \n\n"); } } DEFINE_SOURCE(CO_source,c,t,dS,eqn) { real source; source = C_UDMI(c,t,0); dS[eqn] = 0.0; return source; } |
|
April 17, 2019, 06:13 |
|
#3 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
thanks a lot for replying,
the highlighted step below has been changed by you to source = C_UDMI(c,t,0); But in reality the wall boundary flux is stored in C_UDMI(F_C0(f,t),THREAD_T0(t),0)=-0.0092976*c_co; Kindly help me out.........as i am unsure about................... how to call this memory argument C_UDMI(F_C0(f,t),THREAD_T0(t),0)" DEFINE_SOURCE(CO_source,c,t,dS,eqn) { real x[ND_ND]; real source; source = C_UDMI(F_C0(c,t),THREAD_T0(t),0); dS[eqn] = 0.0; return source; } so is this representation correct? |
|
April 17, 2019, 22:55 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
not correct
Code:
source = C_UDMI(c,t,0); Read about C_UDMIs in Ansys Fluent Customization manual best regards |
|
April 18, 2019, 01:25 |
|
#5 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
thanks a lot for that reply
|
|
April 21, 2019, 03:33 |
|
#6 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
when i add the adjust function its working and displaying msg UDF done etc but when i add the source term..........its hows the error as shown below.
I cant resolve it. Kindly help me out ================================================== ============================ Node 0: Process 2956: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 1: Process 13268: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 2: Process 4248: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 3: Process 3152: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ |
|
April 21, 2019, 22:41 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
what did you put in source?
best regards |
|
April 22, 2019, 01:48 |
|
#8 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
DEFINE_ADJUST(calc,domain)
{ face_t f; Thread *t; real mf_co;/* variable declaration */ real c_co;/* variable declaration */ int boundaryID=1; /*wall ID*/ thread_loop_f(t,domain) { if (THREAD_ID(t)==boundaryID) { begin_f_loop(f,t) { mf_co=F_YI(f, t, 3); c_co=mf_co*F_R(f, t); C_UDMI(F_C0(f,t),THREAD_T0(t),6)=-0.0092976*c_co; } end_f_loop(f,t) } Message0("\n\n UDF DONE \n\n"); } } DEFINE_SOURCE(CO_source,c,t,dS,eqn) { real source; source = C_UDMI(c,t,6); dS[eqn] = 0.0; return source; } this is the code there is nothing much in it to cause any big problem. My domain is just a sphere where all the volumetric reactions are happening thats all |
|
April 22, 2019, 01:54 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
did you allocate 7 UDMS in fluent gui?
go to user defined -> Memory -> number of UDM Locations -> set 7 (at least) best regards |
|
April 22, 2019, 01:57 |
|
#10 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
yes sir..................really sorry the error i am getting is
I cant resolve it. Kindly help me out ================================================== ============================ Node 0: Process 2956: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 1: Process 13268: Received signal SIGSEGV. not segmentation fault ================================================== ============================ ================================================== ============================ Node 2: Process 4248: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 3: Process 3152: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ |
|
April 22, 2019, 02:01 |
|
#11 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
Is this because i am attaching C_UDMI(F_C0(f,t),THREAD_T0(t),6) i.e face into source which is kg/m3 etc............... ?
|
|
April 22, 2019, 03:38 |
|
#12 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
i dont think so, make a contour of UDMI_6, what are max min values?
best regards |
|
April 22, 2019, 04:24 |
|
#13 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
F_YI(f, t, 3),F_R(f, t)
These two are the problem as its working when i give C_UDMI(F_C0(f,t),THREAD_T0(t),6)=-0.0092976 its running fine but when i introduce C_UDMI(F_C0(f,t),THREAD_T0(t),6)=-0.0092976*F_YI(f, t, 3)*F_R(f, t); Updating solution at time level N... done. iter continuity x-velocity y-velocity z-velocity energy fe3o4 feo fe co co2 c time/iter ================================================== ============================ Node 0: Process 6044: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 1: Process 3788: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 2: Process 11644: Received signal SIGSEGV. this error comes what to do.? |
|
April 22, 2019, 21:33 |
|
#14 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
check what you get you get using F_YI(f, t, 3) and F_R(f, t) using UDMs
best regards |
|
April 23, 2019, 02:33 |
|
#15 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
ok sir thanks a lot for ur reply
|
|
April 23, 2019, 09:06 |
|
#16 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
the F_YI(f, t, 3) is varying in an increasing pattern shown below and F_R(f, t) varying in an decreasing pattern similarly but dnt know y the overall code is not working.
C_UDMI(F_C0(f,t),THREAD_T0(t),6)=0.0092976*F_YI(f, t, 3) its running fine but when i introduce C_UDMI(F_C0(f,t),THREAD_T0(t),6)=0.0092976*F_YI(f, t, 3)*F_R(f, t); still not working same error exits. simlarly when i use C_UDMI(F_C0(f,t),THREAD_T0(t),6)=0.0092976*F_R(f, t); not working same error exits. so the problem is with F_R(f, t) what to do |
|
April 23, 2019, 11:12 |
|
#17 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
there is a warning suggesting
.c(101) warning C4002: too many actual parameters for macro 'F_R' when i use C_UDMI(F_C0(f,t),THREAD_T0(t),6)=3*0.00972*F_YI(f, t, 3)*1000*F_R(f,t)/12; line 101 any suggestions sir? |
|
April 24, 2019, 01:44 |
|
#18 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
i dont see any problems in line
Code:
C_UDMI(F_C0(f,t),THREAD_T0(t),6)=3*0.00972*F_YI(f, t, 3)*1000*F_R(f,t)/12; Code:
real species_mass_fraction, my_rho; cell_t *c0; Thread t0; .... species_mass_fraction = F_YI(f, t, 3); my_rho = F_R(f,t); c0 = F_C0(f,t); t0 = THREAD_T0(t); C_UDMI(c0,t0,6)=3*0.00972*species_mass_fraction*1000*my_rho/12; |
|
April 24, 2019, 02:13 |
|
#19 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
same error is coming up sir. Is there any other way of getting individual species density
|
|
April 25, 2019, 07:02 |
|
#20 |
Member
Join Date: Apr 2017
Location: india
Posts: 96
Rep Power: 9 |
thanks a lot everyone.........I have solved it in a different way
|
|
Tags |
udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Segmentation fault when running dieselFoam or dieselEngineFoam in parallel | francesco | OpenFOAM Bugs | 4 | May 2, 2017 22:59 |
Segmentation fault in SU2 V5.0 | ygd | SU2 | 2 | March 1, 2017 05:38 |
Segmentation fault when running in parallel | Pj. | OpenFOAM Running, Solving & CFD | 3 | April 8, 2015 09:12 |
Segmentation Fault w/ compiled OF 2.2.0 - motorBike example | sudo | OpenFOAM Running, Solving & CFD | 3 | April 2, 2013 18:27 |
segmentation fault when installing OF-2.1.1 on a cluster | Rebecca513 | OpenFOAM Installation | 9 | July 31, 2012 16:06 |