CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   an error problem for a change of boundary condition (https://www.cfd-online.com/Forums/fluent/99146-error-problem-change-boundary-condition.html)

tsi07 March 27, 2012 05:39

an error problem for a change of boundary condition
 
HI every body,

it's my first time on this forum.:D

I'm trying to change a boundary condition on a wall to put a velocity inlet but I have some problem when I want to use the adjacent cells of the face thread.

Can Anyone help me, I don't understand what is the problem.

I tried to find the problem, and I think it comes from the "F_C0" command.

The error message that it's appear is :

FLUENT received fatal signal (ACCESS_VIOLATION)

Here is my UDF,
////////////////////////////
#include "udf.h"
#include "mem.h"

double V_n[ND_ND], V_t[ND_ND], BC[ND_ND], VC[ND_ND];
real K, n, TAU0; /* consistency, power law parameter, limit yield stress for flowing */
real m, Cf, SL; /* regularization parameter, friction coefficient, limit yield stress for slipping */
double vmag, StrainRate, constante, TAUxx, TAUxy, TAUyy, VC_MAG;
double dudx, dudy, dvdx, dvdy; /* derivatives */
face_t f;
cell_t c0;

DEFINE_PROFILE(wall_new_boundary, thread, position)
{
K=1;
n=1;
TAU0=1;
m=100000;
SL=0.6;
begin_f_loop(f, thread)
{
F_AREA(V_n,f,thread);
c0 = F_C0(f,thread); /* adjacent cell to f */
vmag=-NV_MAG(V_n); /* magnitude and opposite of normal vector */
V_n[0]=V_n[0]/vmag; /* normed vector */
V_n[1]=V_n[1]/vmag; /* normed vector */
F_CENTROID(BC, f, thread);
NV_D(V_t,=,-V_n[1],V_n[0]); /* tangent vector */
StrainRate = C_STRAIN_RATE_MAG(c0, thread);
constante = K*pow(StrainRate,(n-1))+TAU0*(1-exp(-m*StrainRate))/StrainRate;
dudx = C_U_G(c0,thread)[0];
dudy = C_U_G(c0,thread)[1];
dvdx = C_V_G(c0,thread)[0];
dvdy = C_V_G(c0,thread)[1];
TAUxx=2*constante*dudx; /* stress tensor's xx componant*/
TAUyy=2*constante*dvdy; /* stress tensor's yy componant*/
TAUxy=constante*(dudy+dvdx); /* stress tensor's xy componant*/
VC[0]=(TAUxx*V_n[0]+TAUxy*V_n[1])*(pow(V_t[0],2)); /* stress vector's x componant*/
VC[1]=(TAUxy*V_n[0]+TAUyy*V_n[1])*(pow(V_t[1],2)); /* stress vector's y componant*/
VC_MAG=NV_MAG(VC); /* stress vector's magnitude */
if ( VC_MAG < SL)
{
F_PROFILE(f, thread, position)=0;
}
else {
F_PROFILE(f, thread, position)= -VC[0]*(VC_MAG-SL)/(VC_MAG*Cf);
}
}
end_f_loop(f, thread)
}
////////////////////////////

Thanks for your help !! :)

tsi07 March 27, 2012 12:10

a simplified issue to solve my problem
 
Here is a simplified UDF. It has no physical sense but it much more readable.

My problem is that I need to use the adjacent cell of face to chek the velocity there, but when I use "F_C0" command for it I have an error message which is :

Quote:

FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
ANd here is the code :
Code:

#include "udf.h"
#include "mem.h"

double VC[ND_ND];
real SL;
double VC_MAG;
double dudx, dvdy;                /* derivatives */
face_t f;
cell_t c0;

DEFINE_PROFILE(wall_velocity_x, thread, position)
        {
        SL=0.6;
        begin_f_loop(f, thread)
                {
                c0 = F_C0(f,thread);                        /* adjacent cell to f */
                dudx = C_U_G(c0,thread)[0];
                dvdy = C_V_G(c0,thread)[1];
                VC[0]=dudx;
                VC[1]=dvdy;
                VC_MAG=NV_MAG(VC);
                if ( VC_MAG < SL)
                        {
                        F_PROFILE(f, thread, position)=0;
                        }
                else        {
                        F_PROFILE(f, thread, position)= VC_MAG-SL;
                        }
                }
        end_f_loop(f, thread)
        }

If anyone have an idea, I'll take it !

Thanks.......

tsi07 March 28, 2012 11:21

Can I call an adjacent cell with an other way ?
 
I have no answer up to now.

So I change my question to be helped one day...:(

Can I call an adjacent cell with an other way or must I use C_F0 ?

banty March 28, 2012 14:10

Hello,

In Micro (dudx = C_U_G(c0,thread)[0]) thread is the cell thread not face thread. The cells on either side of a face may or may not belong to the same cell thread. If a face is on the boundary of a domain, then only c0 exists. ( c1 is undefined for an external face). Alternatively, if the face is in the interior of the domain, then both c0 and c1 exist.
There are two macros, THREAD_T0(t) and THREAD_T1(t), that can be used to identify cell threads that are adjacent to a given face f in a face thread t.

This may be helpful to u.

tsi07 March 29, 2012 04:26

I understood now !
 
Thank you very much Banty :), I have not seen that when I wrote my UDF.
It works perfectly now ! :D

thank you !

moun139 May 14, 2012 17:03

boundary condition problems
 
i wrote a udf for a boundary condition with mass fraction ,but when i want to initialize it write me : error: fluent receive fatal .....
....
....
...

i tried keep memory...[yes]
and solve/expert/ save gradient ? to #t

this is my udf

/* my condition is rearanged as ma=map-(D/jv)*(dma/dy)*/



#include "udf.h"



DEFINE_PROFILE(frac,t,i)
{
real ma=0.0002; /*initialization of mass fraction */
real grad=0.0002;/*initialization of gradient */
cell_t c;
face_t f;

begin_f_loop(f,t)
{
c=F_C0(f,t);
THREAD_T0(t);


grad=C_YI_RG(c,t,i)[1];

ma=0.000055-0.00002199301*grad;

F_PROFILE(f,t,i)=ma;
}
end_f_loop(f,t)
}

please ,help me .

thank you a lot

tsi07 May 15, 2012 06:18

You define noting with the command THREAD_T0(t) in your code.

First you have to define a thread name that we point on it with the command C_THREAD_T0 and after you have to define it.
Then for all command start with "C_" you have to use the cell thread that you have defined (here the name of the thread is "cell_thread". you can choose a shorter name if you want) and not the face thread.

#include "udf.h"

DEFINE_PROFILE(frac,t,i)
{
real ma=0.0002; /*initialization of mass fraction */
real grad=0.0002; /*initialization of gradient */
cell_t c;
face_t f;
Thread *cell_thread; /* the star is to say that we will point on it */

begin_f_loop(f,t)
{
c=F_C0(f,t);
cell_thread=THREAD_T0(t); /* the cell thread adjacent to the face thread */


grad=C_YI_RG(c,cell_thread,i)[1];

ma=0.000055-0.00002199301*grad;

F_PROFILE(f,t,i)=ma;
}
end_f_loop(f,t)
}

I hope that helps you. ;)

moun139 May 15, 2012 07:56

boundary
 
Dear tsi ,
thank you for your information,i try it but it write me the same problem ,also i changed solver to density based because it mentioned in UDF manual

'C YI RG can be used only in the density-based solver.'

can another persone help me ?

thx





All times are GMT -4. The time now is 05:04.