CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   Stupid question (

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 compressible_flow::calculate_advection() {

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


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









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


return ret;


Thanks in advance

All times are GMT -4. The time now is 12:20.