CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   change of boundary condition (https://www.cfd-online.com/Forums/fluent/48255-change-boundary-condition.html)

Giacomo de Renzi May 16, 2008 05:46

change of boundary condition
 
Hello,

I need to switch a boundary condition (from OUTFLOW to WALL, and from INLET-VELOCITY to WALL) depending on the temperature value on a Zone.

[my problem is the analogous to the functioning of an air conditioning system: if a check temperature is higher than a fixed value the air conditioner must be ON (INLET-VELOCITY) whereas in the opposite case the air conditioner must be OFF (WALL)]

is it possible to switch the boundary condition automatically?? for example with some kind ok UDF??

thanks to everybody, Giacomo

vijay May 16, 2008 09:41

Re: change of boundary condition
 
Hi Giacomo de Renzi,

There is one UDF written for changing the boundary condition type with respect to time written by Fluent Enginners it is available in www.fluentusers.com, whether r u able to access that one..

Because i am also solving manifold problem in that i need to change my boundary condition from wall to pressure outlet with respect to time...

So i am also trying for that UDF....Suppose if u get that means please forward it to me...

With regards, Vijay

Giacomo de Renzi May 16, 2008 12:39

Re: change of boundary condition
 
thanks for answering, I'm not able to access www.fluentusers.com until monday when I'll be at the University, if you have it and you can, could you get the UDF and write it here? otherwise I must wait two days..

otherwise I'll get it on monday or tuesday,

thanks, Giacomo

vijay May 17, 2008 01:11

Re: change of boundary condition
 
Hi Giacomo,

Here i dont have access to use that site.. So please send me that udf a copy to me... Its is found in fluentuser in that to go UDF archeive... In that u can find one UDF names as changing the Boundary type...

So please send me an copy of that UDF after u get it...

With regds, Vijay

Giacomo de Renzi May 17, 2008 06:13

Re: change of boundary condition
 
ok, I'm going to send it to you when I'll get it, I guess it will happen on tuesday morning

vijay May 18, 2008 23:38

Re: change of boundary condition
 
Ok giacomo thanks for that.......

Giacomo de Renzi May 20, 2008 16:21

Re: change of boundary condition
 
this is the UDF got by www.fluentusers.com... I'm trying to understan how does it run... it isn't easy..

#include "udf.h"

/* The RP_Set_List_of_Integer function does not in V6.1 but is in V6.2 */ /* Remove next line and list_of_integer.[ch] files for V6.2 */ #include "list_of_integer.h"

#define N_SWITCHES 4

#define UNKNOWN 0 #define LEAVE 0 #define CLOSED 1 #define OPENED 2

DEFINE_ON_DEMAND(set_switches) { #if !RP_NODE /* only does things on HOST or SERIAL */

static int states[N_SWITCHES] = {UNKNOWN,UNKNOWN,UNKNOWN,UNKNOWN};

real shifts[N_SWITCHES] = {0.0, 90.0, 270.0, 180.0};

int i, change, switches[N_SWITCHES]; real rpm = 6000.0; real time, period, phase, shift_phase;

period = 60.0/rpm; /* seconds */ time=CURRENT_TIME;

Message("\n-----------------------------------------------\n");

period = 60.0/rpm; /* seconds */

time= CURRENT_TIME + CURRENT_TIMESTEP; /* time at NEXT time step */ Message("Time is %f(s)\n",time);

phase=time/period; phase=360.0*(phase-floor(phase)); /* degrees */ Message("Phase is %f(degs)\n",phase);

for (i=0;i<N_SWITCHES;i++)

{

shift_phase = phase + shifts[i];

while(shift_phase >= 360.0) /* refix modulo after addition of shift */

shift_phase -= 360.0;

if(shift_phase< 80.0)

change=OPENED;

else

change=CLOSED;

if(states[i]==change)

switches[i]=LEAVE;

else

{

states[i]=change;

switches[i]=change;

}

}

RP_Set_List_of_Integer("udf-switches", switches, N_SWITCHES);

Message("-----------------------------------------------\n"); #endif /* !RP_NODE */ }

DEFINE_PROFILE(Mprof, ft, m) { face_t f;

begin_f_loop(f, ft)

{

F_PROFILE(f, ft, m) = 250;

} end_f_loop(f, ft) }

/* list_of_integer.c */ #include "cxserv.h"

static void rpsetvar(char *s, Pointer val) { Pointer p; stack *oldstk = Save_Stack(); extern Pointer sym_quote; Pointer sym_uienv; Pointer sym_rpsetvarlocal;

sym_uienv = intern("user-initial-environment"); sym_rpsetvarlocal = intern("rpsetvarlocal");

Push_Stack0(val); /* protect val from garbage collection */ /* (eval `(rpsetvarlocal ',s ',v) user-initial-environment) */ Push_Stack(p); p = cons(NIL,NIL); CAR(p) = cons(val,NIL); CAR(p) = cons(sym_quote,CAR(p)); p = cons(NIL,p); CAR(p) = cons(intern(s),NIL); CAR(p) = cons(sym_quote,CAR(p)); p = cons(sym_rpsetvarlocal,p); (void) eval(p, eval(sym_uienv,NIL)); Restore_Stack(oldstk); }

void RP_Set_List_of_Integer(char *s, int a[], int len) { int n; Pointer result = NIL; stack *oldstk;

if (len <= 0) err("RP_Set_List_of_Integer: zero length list", NIL);

oldstk = Save_Stack(); Push_Stack(result);

for (n=len-1; n>=0; n--)

{

result = cons(NIL,result);

CAR(result) = fixcons(a[n]);

}

rpsetvar(s,result); Restore_Stack(oldstk); }

/* list_of_integer.h */ void RP_Set_List_of_Integer(char *s, int a[], int len);

;; switch.scm ;; load this file into fluent so that (run-switched nts) is available

(if (not (rp-var-object 'udf-switches))

(rp-var-define 'udf-switches () 'list #f))

(define run-switched/stop-filename "run-switched-stop.txt")

(define (run-switched . t-steps) (if

(do ((i (car t-steps) (- i 1)))

((or (= i 0) (file-exists? run-switched/stop-filename)) (> i 0))

(let ((list)(len)(state))

(format "~%Time Steps Remaining ~d~%" i)

(%udf-on-demand "set_switches")

(set! list (%rpgetvar 'udf-switches))

(set! len (length (%rpgetvar 'udf-switches)))

(do ((j 1 (+ j 1))) ((> j len) j)

(set! state (car list))

(set! list (cdr list))

(if (= state 1)

(ti-menu-load-string

(format #f "/def/bc/mz/zone-type/mass_flow_inlet.~d wall~%" j)))

(if (= state 2)

(begin

(ti-menu-load-string

(format #f "/def/bc/mz/zone-type/ mass_flow_inlet.~d mass-flow-inlet~%" j))

(ti-menu-load-string

(format #f "/def/bc/mfi mass_flow_inlet.~d n y y \"udf\" \"Mprof\" n 330 n 0 y y y n 1 n 0 n 0~%" j))

))

)

(err-protect (physical-time-steps 1

(rpgetvar 'max-iterations-per-step)))))

(begin

(remove-file run-switched/stop-filename)

(format "~%(run-switched ~d) Stopped~%" (car t-steps)))

(format "~%(run-switched ~d) Completed~%" (car t-steps))))


Vijay May 21, 2008 01:46

Re: change of boundary condition
 
Hi,

Thanks for ur co operation giacomo, and me too stuggling hard to study this one... First twenty lines is some what clear after that i cant understand properly...

Whether have u got some idea about this udf tell me?????

With regards, Vijay

Giacomo de Renzi May 22, 2008 05:18

Re: change of boundary condition
 
I couldn't still understand the UDF... and you?? I found that in fluentusers.com there was also a little explanation of the UDF, that's the seguent:

"In time dependent runs, it is often desirable to change an inlet to a wall or an outlet to an inlet. Normally this needs some sort of journal file. The scheme file below defines a funtion (run-switched n-time-steps) that does standard timestepping but calls an on-demand udf before each timestep. The on-demand sets an array of switches (list of integers in scheme) that tells the (run-switched) function which actions to perform before the next timestep. These actions can be anything you'd put in a journal file, so changing BC types or values is possible. Currently I've only done an unsteady version, but such events could be done in a steady solver on an iteration-by-iteration basis. The first C file is the ON_DEMAND UDF. It does a simple cylinder valve port open close cycle. The next C & .h file are not needed in V6.2 but V6.1 doesnt have the RP_Set_List_of_Integer function. The final scheme is the main switch testing loop. The user need only change the (format) functions to change the operation due to each switch. Example case & data files (3d & 3d_parallel) are available on request. The (run-switched n-time-steps) must be run instead of the usual timestepping command. Interrupting is also not possible, so to stop the timestepping, a checkpointing file is used. create a file called "run-switched-stop.txt" with anything in it and if it is found in the current fluent directory, the timestepping will stop cleanly."

but even with this I can't understand how to create my UDF... I hope this will help you so you could help me!! greetings Giacomo

vijay May 22, 2008 06:42

Re: change of boundary condition
 
S giacomo let me take some days to understand this UDF first... After that we will try to solve our analysis...

With regards, Vijay


All times are GMT -4. The time now is 23:49.