# FLUENT 6 - Improving convergence of calculations involving porous media with high resistance in the flow direction

 In calculations that involve porous media with high resistance in the flow direction, a good initial guess for pressure upstream may be necessary to ensure mass balance and good convergence. But the correct magnitude of the overall pressure drop may not be known. This solution provides a user-defined function (UDF) that automatically corrects the pressure value based on mass imbalance in the domain. It can be used for steady state flows. The UDF corrects the pressure in the cells based on the mass imbalance. The zone ids of the inlets and outlets are to be given to the UDF. A relaxation for pressure correction is also provided. The UDF can be hooked in the DEFINE_ADJUST panel from the start of the iterations or in between based on convergence behavior. A non-zero static pressure is needed as an initial guess for the UDF to work. /* UDF for getting the correct mass balance in porous zones with high */ /* resistance. Inputs needed by the UDF zone ids of inlet, ids of outlet */ /*The pressure in the domain is adjusted based on the mass imbalance */ /* An underrelaxation is provided for correcting the pressure */ #include "udf.h" #define noinsurf 2 /* Number of inlet zones */ #define nooutsurf 2 /*Number of outlet zones */ DEFINE_ADJUST(adjustpressure, d) { int INLET_ID[noinsurf]; int OUTLET_ID[nooutsurf]; /*Ids of inlet and outlet zones */ INLET_ID=8; INLET_ID=9; OUTLET_ID=6; OUTLET_ID=7; real urlp = 0.5; /*Under relaxation for pressure correction */ int i; face_t f; cell_t c; Thread *t; real x[ND_ND], multiplier; Domain *domain =Get_Domain(1); real totmassin = 0.0; for (i = 0 ; i < noinsurf; i++) { t= Lookup_Thread(domain,INLET_ID[i]); begin_f_loop (f,t) { totmassin += F_FLUX(f,t); } end_f_loop (f,t) } real totmassout = 0.0; for (i = 0 ; i < nooutsurf; i++) { t= Lookup_Thread(domain,OUTLET_ID[i]); begin_f_loop (f,t) { totmassout += F_FLUX(f,t); } end_f_loop (f,t) } multiplier = totmassin/totmassout; if (multiplier < 0.0) { multiplier = multiplier*(-1.0); } /* Message(" %f n", multiplier); */ /* Message(" %f n", totmassin); */ /* Message(" %f n", totmassout); */ Thread *c_thread; thread_loop_c(c_thread, domain) /*loops over all cell threads in domain*/ { if (FLUID_THREAD_P(c_thread)) { begin_c_loop_all (c,c_thread) { C_P(c,c_thread) = C_P(c,c_thread)*(1.0 + (multiplier-1.0)*urlp); } end_c_loop_all (c,c_thread) } }

 No comments yet. Be the first to add a comment!