|
[Sponsors] |
using value of surface integral in source term UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 23, 2019, 04:59 |
using value of surface integral in source term UDF
|
#1 |
New Member
Mori
Join Date: Oct 2012
Posts: 9
Rep Power: 14 |
Hi every one,
I ma trying to write a UDF to calculate the surface integral the interface between two zones, and then used the calculated value as a source term for one of the zones. In other words, my source term is a function of surface integral at the interface. in other words, I want to calculate a specific function on the C0 cells adjacent to the interface, then the values are supposed to be summed and the final value will be used in the source term. below is the UDF I wrote and I was able to compile it without any error. But every time I activate the source term, I receive the segmentation fault which means that there is something in the UDF that the solver does not have access to. I would be grateful if anyone can help me with this. #include "udf.h" #include "mem.h" DEFINE_ADJUST(interface_integral, domain) { face_t f; /* Index that identifies a face. */ real T; /* cell temperature */ real vx; /* x component of velocity */ real vy; /* y component of velocity */ real vz; /* z component of velocity */ real rho; /* density */ real cp; /* specific heat */ int ID = 11; /* retreiving interface by Zone ID assigned fluent GUI */ real firstterm; real surfaceinteg=0.; /* initial value of surface integral before loop */ cell_t c, c0; Thread t, *tf, *t0; tf = Lookup_Thread(domain, ID); c0=F_C0(f, tf); begin_f_loop(f, tf) { t0 = THREAD_T0(tf); T=C_T(c0,t0); rho=C_R(c0,t0); cp=C_CP(c0,t0); vx=C_U(c0,t0); vy=C_V(c0,t0); vz=C_W(c0,t0); firstterm=rho*cp*T*((vx)+(vy)+(vz)); surfaceinteg +=firstterm; } end_f_loop(f, tf) begin_f_loop(f,tf) { F_UDMI(f,tf,1) = surfaceinteg; } end_f_loop(f,t) } /* end of define_adjust */ DEFINE_SOURCE(energy_source, c, t, dS, eqn) { real source, surfaceinteg; face_t f; /* Index that identifies a face. */ Thread *tf; surfaceinteg=F_UDMI(f,tf,1); source=(1/(C_VOLUME(c, t)))*surfaceinteg; dS[eqn] =0.0; return source; } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
Source Term UDF VS Porous Media Model | pchoopanya | Fluent UDF and Scheme Programming | 1 | August 28, 2013 07:12 |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
UDF source term | jerome_ | FLUENT | 2 | July 11, 2011 12:55 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |