|
[Sponsors] |
March 20, 2022, 07:47 |
Udf define property
|
#1 |
New Member
pxy
Join Date: Apr 2021
Posts: 5
Rep Power: 5 |
Hello everyone, I am learning Fluent, but I have a problem:
Can UDF get the value of another cell? For example, I want to define the viscosity of the cell, but I need to use the value of the cell adjacent to the wall. The line between these two points is perpendicular to the wall. I tried using Looping macros in DEFINE_PROPERTY Macros, or looping each cell in DEFINE_ADJUST Macro and then nested loops inside to get the value of the wall adjacent cell, but running would show: Received signal SIGSEGV. Is it because UDFs can't nest with loops? Thank you very much! here is my code |
|
March 20, 2022, 08:15 |
|
#2 |
New Member
pxy
Join Date: Apr 2021
Posts: 5
Rep Power: 5 |
[CODE]
#include"udf.h" #include"mem.h" #define F 0.4 #define B 500 #define g 9.81 #define h 0.3 #define l 0.0051 DEFINE_ADJUST(adjust, d) { #if !RP_HOST Thread* t; cell_t c; face_t f; real x[ND_ND], xc[ND_ND]; real a; int ID1 = 11, ID2 = 35; Thread* t1 = Lookup_Thread(d, ID1); Thread* t2 = Lookup_Thread(d, ID2); thread_loop_c(t, d) { begin_c_loop(c, t) { if (C_VOF(c, t) >= 0.70) { C_CENTROID(x, c, t); if ((x[1] - x[0]) / 2 > -h) { a = (x[1] - x[0]) / 2; begin_f_loop(f, t1) { Thread* t0 = THREAD_T0(t1); cell_t c0 = F_C0(f, t1); C_CENTROID(xc, c0, t0); if (sqrt(pow((xc[1] - a), 2) + pow((xc[0] + a), 2)) < l) { C_UDMI(c, t, 1) = C_UDMI(c0, t0, 0); } } end_f_loop(f, t1) begin_f_loop(f, t2) { Thread* t0 = THREAD_T0(t2); cell_t c0 = F_C0(f, t2); C_CENTROID(xc, c0, t0); if (sqrt(pow((xc[1] + h), 2) + pow((xc[0] - x[0]), 2)) < l) { C_UDMI(c, t, 1) = C_UDMI(c0, t0, 0); } } end_f_loop(f, t2) } else { begin_f_loop(f, t2) { Thread* t0 = THREAD_T0(t2); cell_t c0 = F_C0(f, t2); C_CENTROID(xc, c0, t0); if (sqrt(pow((xc[1] - a), 2) + pow((xc[0] + a), 2)) < l) { C_UDMI(c, t, 1) = C_UDMI(c0, t0, 0); } } end_f_loop(f, t2) } } } end_c_loop(c, t) } #endif /* only compute nodes are involved */ } [CODE] |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to define movement/deformation relative to a rigid body motion in Fluent by udf? | eagle_001 | Fluent UDF and Scheme Programming | 6 | May 17, 2022 04:41 |
using define mass transfer udf for cavitation | Komon | Fluent UDF and Scheme Programming | 14 | June 21, 2016 03:50 |
udf eror + Define property + density | rezvan | Fluent UDF and Scheme Programming | 10 | July 10, 2015 05:30 |
Installing OF 1.6 on Mac OS X | gschaider | OpenFOAM Installation | 129 | June 19, 2010 10:23 |
UDF FOR UNSTEADY TIME STEP | mayur | FLUENT | 3 | August 9, 2006 11:19 |