CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Stupid question (http://www.cfd-online.com/Forums/main/11950-stupid-question.html)

 Dr. Nick August 5, 2006 16:31

Stupid question

Hello all! Need a help, coz i can't see the mistake. What do i do wrong for the advection equation [ dU/dt=-Cx(dU/dx)-Cy(dU/dy)-Cz(dU/dz) ] in 3D unstructured tetrahedral mesh? Here's the code in C++ for the tetrahedra element. The spatial discrimination of the flux for a 1-st order Godunov method (made it just to check the code). CosX[i] etc.. are unit normals of a face. Here i calculate face values, to sum them, and divide by volume to get a flux in the center. It should work, but it doesn't! I know it's stupid, but what's wrong? I get spurious oscillations. Here's the part of the code:

double ret=0.0;

// for each face

for(int i=0;i<4;i++){

double Ux=0.0;

double Uy=0.0;

double Uz=0.0;

double Cx=-0.5;//velocities

double Cy=0.0; //

double Cz=0.0; //

if(cosX[i]*Cx>0) // Nx*VelocityX

Ux=cv[number].U; // U inside of a tetrahedra

else

Ux=U_t; // U outside of a tetrahedra, next to the face 'i'

if(cosY[i]*Cy>0)

Uy=cv[number].U;

else

Uy=U_t;

if(cosZ[i]*Cz>0)

Uz=cv[number].U;

else

Uz=U_t;

ret=ret+S[i]*( Cx*Ux*cosX[i]+Cy*Uy*cosY[i]+Cz*Uz*cosZ[i] );

}

return ret;

}